H265码流格式

简称HEVC

  • High Efficiency Video Coding

推出组织

  • HEVC是ITU-T视频编码组与ISO/IEC MPEG组共同努力的结果。ITU-T促进了电信标准的建立和采用,ISO/IEC则负责电子行业相关标准的管理

优势

  • 相同质量的视频文件,使用HEVC编码的文件大小是H.264标准的一半,MPEG-2标准的四分之一,能够显著减少文件的存储和分发成本

profile

  • H.264拥有7个profile(profile定义了一组用于创建码流的编码工具),HEVC仅支持3个:Main、Main 10和Main Still Picture。不过,2013年1月推出的HEVC仅仅是第一个版本(version 1),未来随着12-bit、14-bit位深、4:2:2、4:4:4色度采样、MVC、SVC等方面的延伸,profile还将得到进一步的扩展。

标准下载地址

nal unit header

nal_unit_header( ) { Descriptor
forbidden_zero_bit f(1)
nal_unit_type u(6)
nuh_layer_id u(6)
nuh_temporal_id_plus1 u(3)
}
  • 从图中可以看出hHEVC的nal包结构与h264有明显的不同,hevc加入了nal所在的时间层的ID,取去除了nal_ref_idc,此信息合并到了naltype中,
    通常情况下F为0,layerid为0, TID为1。

  • 和264的&0x1f不同。265是 : int type = (code & 0x7E)>>1;

  • nalu 类型定义

    定义 描述
    VPS 视频参数集 32
    SPS 序列参数集 33
    PPS 图像参数集 34
    SEI 补充增强信息 39
    IDR RADL图像的IDR图像的SS编码数据 19
    non 被参考的后置图像,且非TSA、非STSA的SS编码数据 1
  • VPS

    • 背景:在一些应用场合如广播和多播中,由于SEI中的部分信息会重复出现在SPS中,造成参数重传而引起延迟等问题,因此H.265中增加了视频参数集(Video Parameter Set,VPS)。

    • 作用:VPS主要用于传输视频分级信息,有利于兼容标准在可分级视频编码或多视点视频的扩展。

    • 内容:(1)多个子层和操作点共享的语法元素。(2)会话所需的有关操作点的关键信息,如档次、级别。(3)其它不属于SPS的操作点特性信息,例如与多层或子层相关的虚拟参考解码器HRD参数。

    • 注意:对于一个视频序列,无论它每一层的SPS是否相同,都参考相同的VPS。

  • HEVC压缩码流结构及SPS,PPS,VPS之间的引用关系

image

nalu type 定义

/**
 * Table 7-1: NAL unit type codes
 */
enum HEVCNALUnitType {
    HEVC_NAL_TRAIL_N    = 0,
    HEVC_NAL_TRAIL_R    = 1,
    HEVC_NAL_TSA_N      = 2,
    HEVC_NAL_TSA_R      = 3,
    HEVC_NAL_STSA_N     = 4,
    HEVC_NAL_STSA_R     = 5,
    HEVC_NAL_RADL_N     = 6,
    HEVC_NAL_RADL_R     = 7,
    HEVC_NAL_RASL_N     = 8,
    HEVC_NAL_RASL_R     = 9,
    HEVC_NAL_VCL_N10    = 10,
    HEVC_NAL_VCL_R11    = 11,
    HEVC_NAL_VCL_N12    = 12,
    HEVC_NAL_VCL_R13    = 13,
    HEVC_NAL_VCL_N14    = 14,
    HEVC_NAL_VCL_R15    = 15,
    HEVC_NAL_BLA_W_LP   = 16,
    HEVC_NAL_BLA_W_RADL = 17,
    HEVC_NAL_BLA_N_LP   = 18,
    HEVC_NAL_IDR_W_RADL = 19,
    HEVC_NAL_IDR_N_LP   = 20,
    HEVC_NAL_CRA_NUT    = 21,
    HEVC_NAL_IRAP_VCL22 = 22,
    HEVC_NAL_IRAP_VCL23 = 23,
    HEVC_NAL_RSV_VCL24  = 24,
    HEVC_NAL_RSV_VCL25  = 25,
    HEVC_NAL_RSV_VCL26  = 26,
    HEVC_NAL_RSV_VCL27  = 27,
    HEVC_NAL_RSV_VCL28  = 28,
    HEVC_NAL_RSV_VCL29  = 29,
    HEVC_NAL_RSV_VCL30  = 30,
    HEVC_NAL_RSV_VCL31  = 31,
    HEVC_NAL_VPS        = 32,
    HEVC_NAL_SPS        = 33,
    HEVC_NAL_PPS        = 34,
    HEVC_NAL_AUD        = 35,
    HEVC_NAL_EOS_NUT    = 36,
    HEVC_NAL_EOB_NUT    = 37,
    HEVC_NAL_FD_NUT     = 38,
    HEVC_NAL_SEI_PREFIX = 39,
    HEVC_NAL_SEI_SUFFIX = 40,
};


The format of the MKV CodecPrivate element for HEVC has been aligned with MP4 and GPAC/MP4Box.
The definition of MP4 for HEVC has not been finalized. The version of MP4Box appears to be
aligned with the latest version of the HEVC standard. The configuration_version field should be
kept 0 until CodecPrivate for HEVC have been finalized. Thereafter it shall have the required value of 1.
The CodecPrivate format is flexible and allows storage of arbitrary NAL units.
However it is restricted by MP4 to VPS, SPS and PPS headers and SEI messages that apply to the
whole stream as for example user data. The table below specifies the format:
Value                               Bits  Description
-----                               ----  -----------
configuration_version               8	  The value should be 0 until the format has been finalized. Thereafter is should have the specified value (probably 1). This allows us to recognize (and ignore) non-standard CodecPrivate
general_profile_space               2     Specifies the context for the interpretation of general_profile_idc and  general_profile_compatibility_flag
general_tier_flag                   1     Specifies the context for the interpretation of general_level_idc
general_profile_idc                 5     Defines the profile of the bitstream
general_profile_compatibility_flag  32    Defines profile compatibility, see [2] for interpretation
general_progressive_source_flag     1     Source is progressive, see [2] for interpretation.
general_interlace_source_flag       1     Source is interlaced, see [2] for interpretation.
general_nonpacked_constraint_flag   1     If 1 then no frame packing arrangement SEI messages, see [2] for more information
general_frame_only_constraint_flag  1     If 1 then no fields, see [2] for interpretation
reserved                            44    Reserved field, value TBD 0
general_level_idc                   8     Defines the level of the bitstream
reserved                            4     Reserved Field, value '1111'b
min_spatial_segmentation_idc        12    Maximum possible size of distinct coded spatial segmentation regions in the pictures of the CVS
reserved                            6     Reserved Field, value '111111'b
parallelism_type                    2     0=unknown, 1=slices, 2=tiles, 3=WPP
reserved                            6     Reserved field, value '111111'b
chroma_format_idc                   2     See table 6-1, HEVC
reserved                            5     Reserved Field, value '11111'b
bit_depth_luma_minus8               3     Bit depth luma minus 8
reserved                            5     Reserved Field, value '11111'b
bit_depth_chroma_minus8             3     Bit depth chroma minus 8
reserved                            16    Reserved Field, value 0
reserved                            2     Reserved Field, value 0
max_sub_layers                      3     maximum number of temporal sub-layers
temporal_id_nesting_flag            1     Specifies whether inter prediction is additionally restricted. see [2] for interpretation.
size_nalu_minus_one                 2     Size of field NALU Length – 1
num_parameter_sets                  8     Number of parameter sets
for (i=0;i<num_parameter_sets;i++) {
  array_completeness                1     1 when there is no duplicate parameter set with same id in the stream, 0 otherwise or unknown
  reserved                          1     Value '1'b
  nal_unit_type                     6     Nal unit type, restricted to VPS, SPS, PPS and SEI, SEI must be of declarative nature which applies to the whole stream such as user data sei.
  nal_unit_count                    16    Number of nal units
  for (j=0;j<nalu_unit_count;j+) {
    size                            16    Size of nal unit
    for(k=0;k<size;k++) {
      data[k]                       8     Nalu data+
    }
  }
}

url

名词解释

  • numTemporalLayers, Temporal Scalability,在多人远程会议或直播系统中,参与的用户可能处于不同的网络环境(有线、wifi、3G、4G)中,网络质量各不一致,为了所有用户可进行远程会议或者直播的观看,简单的做法就是降低发送端的视频码流,这样不管网络质量好坏,参与的用户都将观看低码率的视频流。这种方案缺点在于大部分网络较好的用户会被少数的网络较差的用户给拖累。这里介绍 H264 编码器中的 Temporal Scalability 机制来优化该方案。
    Temporal Scalability 是 H264/SVC 编码器中的概念,意思为时间上可伸缩的,在实际编码中编码器进行了分层编码,可简单的理解为 编码器对同一组输入的数据进行编码,可以输出不同帧率的码流,例如当前编码器输入帧率为 30fps 的流,编码器可同时输出多个码流,例如同时输出 3 层码流,从而可以得到不同帧率的码流。这里的 3层码流是有依赖关系,比如输出有 A、B、C 3 层码流,单独的发送 A 层则得到低帧率的码流例如 5fps,如果同时发送 A 和 B 两层码流,则能得到相对较高的码流例如 15fps,如果同时发送 ABC ,则能得到最高的码流例如 30fps。
  • 在对视频序列进行压缩的时候,会将其先分割成若干个小的图像组(GOP,Group of Pictures),定义一个GOP编码后生成的压缩数据为CVS(Coded Video Sequence)
    视频编解中,存在封闭式GOP和开放式GOP,每个图像组包含若干张图片,每张图片可以划分为一个或多个片(Slice)每个GOP分为若干个片(Slice),片与片之间进行独立编码
    每个片由一个或者多个片段(SS,Slice Segment)组成一个SS在编码时,被分割成大小相同的树形结构单元(CTU,Coding Tree Unit),CTU是HEVC新引进的概念每个CTU按照四叉树分割方式分割成不同类型的编码单元(CU,Coding Unit)

猜你喜欢

转载自blog.csdn.net/qq_39977813/article/details/88774316
今日推荐