• 浅谈h264和h265的区别


    相比h264,压缩同样的视频获得同样的质量的情况下,h265可以做到压缩后的大小为前者的一半,但压缩时间复杂度增加。h264编码单元为宏块(MB),最大划分为16x16,而h265编码单元为编码树单元(CTU),最大划分为64x64。h264的NALU类型占用5位,理论上最多可以支持32种,但实际上有一些是reserved和unspecified的;h265的NALU类型占用6位,理论上最多可以支持32种,但实际上也有一些是reserved和unspecified的。

    1. char const* nal_unit_type_description_h264[32] = {
    2. "Unspecified", //0
    3. "Coded slice of a non-IDR picture", //1
    4. "Coded slice data partition A", //2
    5. "Coded slice data partition B", //3
    6. "Coded slice data partition C", //4
    7. "Coded slice of an IDR picture", //5
    8. "Supplemental enhancement information (SEI)", //6
    9. "Sequence parameter set", //7
    10. "Picture parameter set", //8
    11. "Access unit delimiter", //9
    12. "End of sequence", //10
    13. "End of stream", //11
    14. "Filler data", //12
    15. "Sequence parameter set extension", //13
    16. "Prefix NAL unit", //14
    17. "Subset sequence parameter set", //15
    18. "Reserved", //16
    19. "Reserved", //17
    20. "Reserved", //18
    21. "Coded slice of an auxiliary coded picture without partitioning", //19
    22. "Coded slice extension", //20
    23. "Reserved", //21
    24. "Reserved", //22
    25. "Reserved", //23
    26. "Unspecified", //24
    27. "Unspecified", //25
    28. "Unspecified", //26
    29. "Unspecified", //27
    30. "Unspecified", //28
    31. "Unspecified", //29
    32. "Unspecified", //30
    33. "Unspecified" //31
    34. };
    35. char const* nal_unit_type_description_h265[64] = {
    36. "Coded slice segment of a non-TSA, non-STSA trailing picture", //0
    37. "Coded slice segment of a non-TSA, non-STSA trailing picture", //1
    38. "Coded slice segment of a TSA picture", //2
    39. "Coded slice segment of a TSA picture", //3
    40. "Coded slice segment of a STSA picture", //4
    41. "Coded slice segment of a STSA picture", //5
    42. "Coded slice segment of a RADL picture", //6
    43. "Coded slice segment of a RADL picture", //7
    44. "Coded slice segment of a RASL picture", //8
    45. "Coded slice segment of a RASL picture", //9
    46. "Reserved", //10
    47. "Reserved", //11
    48. "Reserved", //12
    49. "Reserved", //13
    50. "Reserved", //14
    51. "Reserved", //15
    52. "Coded slice segment of a BLA picture", //16
    53. "Coded slice segment of a BLA picture", //17
    54. "Coded slice segment of a BLA picture", //18
    55. "Coded slice segment of an IDR picture", //19
    56. "Coded slice segment of an IDR picture", //20
    57. "Coded slice segment of a CRA picture", //21
    58. "Reserved", //22
    59. "Reserved", //23
    60. "Reserved", //24
    61. "Reserved", //25
    62. "Reserved", //26
    63. "Reserved", //27
    64. "Reserved", //28
    65. "Reserved", //29
    66. "Reserved", //30
    67. "Reserved", //31
    68. "Video parameter set", //32
    69. "Sequence parameter set", //33
    70. "Picture parameter set", //34
    71. "Access unit delimiter", //35
    72. "End of sequence", //36
    73. "End of bitstream", //37
    74. "Filler data", //38
    75. "Supplemental enhancement information (SEI)", //39
    76. "Supplemental enhancement information (SEI)", //40
    77. "Reserved", //41
    78. "Reserved", //42
    79. "Reserved", //43
    80. "Reserved", //44
    81. "Reserved", //45
    82. "Reserved", //46
    83. "Reserved", //47
    84. "Unspecified", //48
    85. "Unspecified", //49
    86. "Unspecified", //50
    87. "Unspecified", //51
    88. "Unspecified", //52
    89. "Unspecified", //53
    90. "Unspecified", //54
    91. "Unspecified", //55
    92. "Unspecified", //56
    93. "Unspecified", //57
    94. "Unspecified", //58
    95. "Unspecified", //59
    96. "Unspecified", //60
    97. "Unspecified", //61
    98. "Unspecified", //62
    99. "Unspecified", //63
    100. };

    h265的参数集比h264的多了一个vps(video parameter set)码流先从vps,sps,pps开始。

    h264的NALU头只占一个字节,而h265得NALU头占用两个字节。

    h264的NALU头组成:

    F(forbidden_zero_bit) :1 bit

    nal_ref_idc :2 bits

    nal_unit_type :5 bits

    h265的NALU头组成:

    F(forbidden_zero_bit) :1 bit

    Type(nal_unit_type) :6 bits

    LayerId(nuh_layer_id) :6 bits

    TID(nuh_temporal_id_plus1) :3 bits

    下面以一段h265的码流来分析一下:

     NALU头“40 01”对应类型为32(VPS)

     NALU头“42 01”对应类型为33(SPS)

    NALU头“44 01”表示类型为33(PPS)

    NALU头“4E 01”表示类型为39(SEI)

    h265编码出来的NALU码流的分隔,和h264一样,也是使用00 00 00 01 start code,而且防竞争机制(emulation)也一样。防竞争机制是防止NALU码流中出现00 00 01这种短start code,对NALU分隔造成干扰,在其中插入一个03,即变为00 00 03 01。通常编码器出来的码流都是做过防竞争处理的,在传输或保存NALU时无论是使用start code前缀还是长度前缀,都不需要做去03处理,解码器解码的时候会做这一步操作,当然如果要分析NALU码流,就需要先做去03处理。

    具体实现可参考live555源码中的\live\liveMedia\H264or5VideoStreamFramer.cpp文件。

  • 相关阅读:
    网络安全检测与防范 测试题(二)
    【喜闻乐见,包教包会】二分图最大匹配:匈牙利算法(洛谷P3386)
    牛客 NC25077 [USACO 2007 Ope B]Bronze Cow Party
    如何在App里面运行Mac OS 8?
    spring cloud kubernetes踩坑:Null key for a Map not allowed in JSON
    去耦电路设计应用指南(四)电源 PDN 配置
    dubbo如何平滑重启
    任意版本JLink驱动官方下载详解
    RocketMQ源码分析(十三)之ConsumeQueue
    Linux驱动之INPUT子系统框架
  • 原文地址:https://blog.csdn.net/qiuchangyong/article/details/128114071