简体   繁体   English

如何理解H.265的header

[英]How to understand header of H.265

Could someone explain me the difference between the H.264 header and H.265 header?有人可以解释一下 H.264 header 和 H.265 header 之间的区别吗? I just need to parse H265 header but I have difficult to find proper reference.我只需要解析 H265 header 但我很难找到合适的参考。

I did a first version of the parser.我做了第一个版本的解析器。 I need to retrieve the pic_width_in_luma_samples, pic_height_in_luma_samples, and the aspectRatioH, aspectRatioV.我需要检索 pic_width_in_luma_samples、pic_height_in_luma_samples 和 aspectRatioH、aspectRatioV。

my code is something like:我的代码是这样的:

while (buf->Size > 0)
{
    //forbidden bit

    flushbits(buf, 1); 

    int nNALType = showbits(buf, 6);

    if (nNALType == NAL_TYPE_SPS)
    {
        // flushbits until I retrieve desired parameter

        flushbits(buf, 4); // sps_video_parameter_set_id
    }
    else
    {
        // align bits

        buf->Size -= buf->BitsLeft & 0x7; 
    }
}

this is the correct way to do?这是正确的做法吗? There is a method where I can skip bits until I find a "start sequence" that indicates my desired SPS NAL TYPE?有一种方法可以让我跳过位,直到找到指示我想要的 SPS NAL 类型的“开始序列”?

The syntax of H.264 and H.265 is relative similar. H.264 和 H.265 的语法相对相似。

Both have parameter sets (PPS, SPS) you find the details in the specification below.两者都有参数集(PPS、SPS),您可以在下面的规范中找到详细信息。 For H.265 - page 33 section 7.3 describes the video parameters sets in detail.对于 H.265 - 第 33 页,第 7.3 节详细描述了视频参数集。 The specification is done in 'C' like pseudocode so relatively easy to translate the specification into compiling code.规范是用类似伪代码的“C”语言完成的,因此将规范翻译成编译代码相对容易。

You can always look at some existing code - for example:您可以随时查看一些现有代码 - 例如:

https://github.com/GStreamer/gstreamer/blob/main/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c https://github.com/GStreamer/gstreamer/blob/main/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c

The H.264 (AVC) specification is here: H.264 (AVC) 规范在这里:

https://www.itu.int/rec/T-REC-H.264-202108-I/en https://www.itu.int/rec/T-REC-H.264-202108-I/en

The H.265 (HEVC) specification is here: H.265 (HEVC) 规范在这里:

https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.265-201802-S!!PDF-E&type=items https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.265-201802-S!!PDF-E&type=items

follow those step to parse H265按照这些步骤解析 H265

  • each NAL unit starts with a start code that is 3 bytes with value 0x01 (so 00 00 01).每个 NAL 单元都以 3 字节的起始码开始,值为 0x01(即 00 00 01)。 Identify each NAL unit;识别每个 NAL 单元;
  • parse the header (2 bytes)解析 header(2 字节)
  • for the other part of NAL sequence: find for 3 byte sequence 00 00 03, keep the first 2 bytes (00 00) and discard the 03 byte.对于 NAL 序列的另一部分:查找 3 字节序列 00 00 03,保留前 2 个字节(00 00)并丢弃 03 字节。
  • with the bytes don't discarded, you can do the parsing (depending of the NAL unit type you have)不丢弃字节,您可以进行解析(取决于您拥有的 NAL 单元类型)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM