H.264 - 序列参数集(SPS)

内容取自Recommendation ITU-T H.264

SPS 语法(seq_parameter_set_data)

7.3.2.1.1 Sequence parameter set data syntax

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_2bits /* equal to 0 */0u(2)
level_idc0u(8)
seq_parameter_set_id0ue(v)
  if( profile_idc = = 100 | | profile_idc = = 110 | | profile_idc = = 122 | | profile_idc = = 244 | | profile_idc = = 44 | | profile_idc = = 83 | | profile_idc = = 86 | | profile_idc = = 118 | | profile_idc = = 128 | | profile_idc = = 138 | | profile_idc = = 139 | | profile_idc = = 134 | | profile_idc = = 135 ) {
    chroma_format_idc0ue(v)
    if( chroma_format_idc = = 3 )
      separate_colour_plane_flag0u(1)
    bit_depth_luma_minus80ue(v)
    bit_depth_chroma_minus80ue(v)
    qpprime_y_zero_transform_bypass_flag0u(1)
    seq_scaling_matrix_present_flag0u(1)
    if( seq_scaling_matrix_present_flag )
      for( i = 0; i < ( ( chroma_format_idc != 3 ) ? 8 : 12 ); i++ ) {
        seq_scaling_list_present_flag[ I ]0u(1)
        if( seq_scaling_list_present_flag[ i ] )
          if( i < 6 )
            scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ] )0
          else
            scaling_list( ScalingList8x8[ i − 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i − 6 ] )0
    }
  }
log2_max_frame_num_minus40ue(v)
pic_order_cnt_type0ue(v)
  if( pic_order_cnt_type = = 0 )
    log2_max_pic_order_cnt_lsb_minus40ue(v)
 else if( pic_order_cnt_type = = 1 ) {
    delta_pic_order_always_zero_flag0u(1)
    offset_for_non_ref_pic0se(v)
    offset_for_top_to_bottom_field0se(v)
    num_ref_frames_in_pic_order_cnt_cycle0ue(v)
    for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )
      offset_for_ref_frame[ I ]0se(v)
  }
max_num_ref_frames0ue(v)
gaps_in_frame_num_value_allowed_flag0u(1)
pic_width_in_mbs_minus10ue(v)
pic_height_in_map_units_minus10ue(v)
frame_mbs_only_flag0u(1)
  if( !frame_mbs_only_flag )
    mb_adaptive_frame_field_flag0u(1)
direct_8x8_inference_flag0u(1)
frame_cropping_flag0u(1)
  if( frame_cropping_flag ) {
    frame_crop_left_offset0ue(v)
    frame_crop_right_offset0ue(v)
    frame_crop_top_offset0ue(v)
    frame_crop_bottom_offset0ue(v)
  }
vui_parameters_present_flag0u(1)
  if( vui_parameters_present_flag )
    vui_parameters( )0
}

分辨率

chroma_format_idcseparate_colour_plane_flagChroma FormatSubWidthCSubHeightC
00monochrome--
104:2:022
204:2:221
304:4:411
314:4:4--

宽度

The variable for the picture width in units of macroblocks is derived as
    PicWidthInMbs = pic_width_in_mbs_minus1 + 1 (7-13)
The variable for picture width for the luma component is derived as
    PicWidthInSamplesL = PicWidthInMbs * 16 (7-14)
The variable for picture width for the chroma components is derived as
    PicWidthInSamplesC = PicWidthInMbs * MbWidthC

PicWidthInMbs:表示水平宏块数。
SubWidthCSubHeightC:根据以上表格,每个色度格式有对应的值。

PicWidthInMbs = pic_width_in_mbs_minus1 + 1

  1. chroma_format_idc的值是0时,表示这张图片没有色度格式,仅有亮度(luma),是一张灰度图。
    PicWidthInSamplesL(分辨率宽度) = PicWidthInMbs * 16
  2. 当chroma_format_idc为1~3时,这张图有对应的色度格式。
    MbWidthC = 16 / SubWidthC
    PicWidthInSamplesC(分辨率宽度) = PicWidthInMbs \* MbWidthC

高度

The variables PicHeightInMapUnits and PicSizeInMapUnits are derived as
    PicHeightInMapUnits = pic_height_in_map_units_minus1 + 1 (7-16)
The variable FrameHeightInMbs is derived as
    FrameHeightInMbs = ( 2 − frame_mbs_only_flag ) * PicHeightInMapUnits (7-18)
The variable for the picture height in units of macroblocks is derived as
    PicHeightInMbs = FrameHeightInMbs / ( 1 + field_pic_flag ) (7-26)
The variable for picture height for the luma component is derived as
    PicHeightInSamplesL = PicHeightInMbs * 16 (7-27)
The variable for picture height for the chroma component is derived as
    PicHeightInSamplesC = PicHeightInMbs * MbHeightC (7-28)
The variable for the picture height in units of macroblocks is derived as
    PicHeightInMbs = FrameHeightInMbs / ( 1 + field_pic_flag ) (7-26)
The variable for picture height for the luma component is derived as
    PicHeightInSamplesL = PicHeightInMbs * 16 (7-27)
The variable for picture height for the chroma component is derived as
    PicHeightInSamplesC = PicHeightInMbs * MbHeightC (7-28)

PicHeightInMapUnits:表示垂直单位数量。
frame_mbs_only_flag:0为帧编码(逐行扫描,p),1为场编码(隔行扫描,i)。
FrameHeightInMbs:分辨率
field_pic_flag:这个再研究,目前个人使用场景为0。
PicHeightInMapUnits = pic_height_in_map_units_minus1 + 1
FrameHeightInMbs = ( 2 − frame_mbs_only_flag ) * PicHeightInMapUnits
MbHeightC = 16 / SubHeightC
PicHeightInMbs = FrameHeightInMbs / ( 1 + field_pic_flag )

  1. chroma_format_idc的值是0时,是一张灰度图。
    PicHeightInSamplesL(分辨率高度) = PicHeightInMbs * 16
  2. 当chroma_format_idc为1~3时,这张图有对应的色度格式。
    MbWidthC = 16 / SubWidthC
    PicHeightInSamplesC(分辨率高度) = PicHeightInMbs \* MbHeightC

对图片进行裁剪,获取正确分辨率

– If ChromaArrayType is equal to 0, CropUnitX and CropUnitY are derived as:
CropUnitX = 1 (7-19)
CropUnitY = 2 − frame_mbs_only_flag (7-20)
– Otherwise (ChromaArrayType is equal to 1, 2, or 3), CropUnitX and CropUnitY are derived as:
CropUnitX = SubWidthC (7-21)
CropUnitY = SubHeightC * ( 2 − frame_mbs_only_flag ) (7-22)
Let CroppedWidth and CroppedHeight be the width and height, respectively, of the cropped frame area output from the
decoder in units of luma samples, derived as follows:
CroppedWidth = PicWidthInSamplesL − CropUnitX * ( frame_crop_left_offset + frame_crop_right_offset )
(D-30)
CroppedHeight = PicHeightInSamplesL − CropUnitY * ( frame_crop_top_offset + frame_crop_bottom_offset )
(D-31)

frame_cropping_flag:当这个值为1的时候才需要对图片进行裁剪。

  1. chroma_format_idc的值是0时,是一张灰度图。
    CropUnitX = 1
    CropUnitY = 2 − frame_mbs_only_flag
  2. 当chroma_format_idc为1~3时,这张图有对应的色度格式。
    CropUnitX = SubWidthC
    CropUnitY = SubHeightC * ( 2 − frame_mbs_only_flag )

裁剪后正确尺寸:
CroppedWidth = PicWidthInSamplesL − CropUnitX * ( frame_crop_left_offset + frame_crop_right_offset )
CroppedHeight = PicHeightInSamplesL − CropUnitY * ( frame_crop_top_offset + frame_crop_bottom_offset )



vui 结构(vui_parameters)

Extended_SAR = 255

vui_parameters( ) {CDescriptor
aspect_ratio_info_present_flag0u(1)
  if( aspect_ratio_info_present_flag ) {
    aspect_ratio_idc0u(8)
    if( aspect_ratio_idc = = Extended_SAR ) {
      sar_width0u(16)
      sar_height0u(16)
    }
  }
overscan_info_present_flag0u(1)
  if( overscan_info_present_flag )
    overscan_appropriate_flag0u(1)
video_signal_type_present_flag0u(1)
  if( video_signal_type_present_flag ) {
    video_format0u(3)
    video_full_range_flag0u(1)
    colour_description_present_flag0u(1)
    if( colour_description_present_flag ) {
     colour_primaries0u(8)
      transfer_characteristics0u(8)
      matrix_coefficients0u(8)
    }
  }
chroma_loc_info_present_flag0u(1)
  if( chroma_loc_info_present_flag ) {
    chroma_sample_loc_type_top_field0ue(v)
    chroma_sample_loc_type_bottom_field0ue(v)
  }
timing_info_present_flag0u(1)
  if( timing_info_present_flag ) {
    num_units_in_tick0u(32)
    time_scale0u(32)
    fixed_frame_rate_flag0u(1)
  }
nal_hrd_parameters_present_flag0u(1)
  if( nal_hrd_parameters_present_flag )
    hrd_parameters( )0
vcl_hrd_parameters_present_flag0u(1)
  if( vcl_hrd_parameters_present_flag )
    hrd_parameters( )0
  if( nal_hrd_parameters_present_flag | | vcl_hrd_parameters_present_flag )
    low_delay_hrd_flag0u(1)
pic_struct_present_flag0u(1)
bitstream_restriction_flag0u(1)
  if( bitstream_restriction_flag ) {
    motion_vectors_over_pic_boundaries_flag0u(1)
    max_bytes_per_pic_denom0ue(v)
    max_bits_per_mb_denom0ue(v)
    log2_max_mv_length_horizontal0ue(v)
    log2_max_mv_length_vertical0ue(v)
    max_num_reorder_frames0ue(v)
    max_dec_frame_buffering0ue(v)
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值