ZigZag Sin
登 陆
上一篇:3-5 *代码-正式解析开始前的一些抽象 下一篇:从 SPS 中提取信息计算图像的宽高

3-6 *代码-开始读取 SPS

乔红
2021-1-23 17:39 阅读 2258

开始读取 SPS

现在,我们可以重写 NaluSPSParse 函数了。我们先在 Parse 函数里构建一个 BitStream 对象,把 EBSP 传给这个 BitStream 对象,这样,我们就能利用 BitStream 来进行指数哥伦布的解码了。

RBSP 的第一个字节,其实就是 Nalu Header,我们之前已经解析过,所以我们直接跳过第一个字节。在构建 BitStream 的时候,我们向后位移一个字节。

int NaluSPS::Parse()
{
    uint8_t * buf   = rbsp.buf;
    int bufLen      = rbsp.len;

    BitStream bitStream(buf + 1, bufLen - 1);

    return 0;
}

profile_idc

我们翻开文档,先看前面的一部分。

seq_parameter_set_data()CDescriptor
    profile_idc0u(8)
    constraint_set0_flag0u(1)
    constraint_set1_flag0u(1)
    constraint_set2_flag0u(1)
    constraint_set3_flag0u(1)
    constraint_set4_flag0u(1)
    constraint_set5_flag0u(1)
    reserved_zero_2bits0u(2)
    level_idc0u(8)
    seq_parameter_set_id0ue(8)

第一个就是一个叫做 profile_idc 的属性,根据 Descriptor 我们知道,他占用了 8 bit 的大小,那么我们只需要读取 8bit 的数据出来就可以了。

profile_idc = bitStream.ReadU(8);

constraint_set(X)_flag

TODO

H.264/AVC 中的常见档次

profile_idc 表示的是当前这路码流的编码档次,我们有时候会说一路码流是 BaselineMain 等等,就是这个属性所决定的。具体的映射表如下:

  • Baseline profile 66
  • Main profile 77
  • Extended profile 88
  • High profile 100
  • High 10 profile 110
  • High 4:2:2 profile 122
  • High 4:4:4 Predictive profile 244
  • High 10 Intra profile 100 or 110
  • High 4:2:2 Intra profile 100, 110, or 122
  • High 4:4:4 Intra profile 44, 100, 110, 122, or 244
  • CAVLC 4:4:4 Intra profile 44

可以看到,这里有非常多的档次,但是其实很多我们平时都接触不上,我们这里介绍几个常见的。一些不常见的,大家可以自行翻阅。

  • Baseline profile
  • Main profile
  • High profile
上一篇:3-5 *代码-正式解析开始前的一些抽象 下一篇:从 SPS 中提取信息计算图像的宽高
给我买个键盘吧。。。求打赏。。。
欢迎加群,一起交流~~~