分析一段H264视频数据

分析一段H264视频数据

Posted on 2007-05-31 09:42 vcommon 阅读(1968) 评论(8)  编辑 收藏 引用

分析

00 00 00 01 67 42 00 1E 99 A0 B1 31 00 00 00 01

H264的数据流分为两种,一种是NAL UNIT stream(RTP),一种是 bits stream,

两者可以互相转换。我们分析的这个是 bit stream,根据Annex B

00 00 00 01 67 42 00 1E 99 A0 B1 31 是 一个NAL,在两个00 00 00 01之间

0110 0111 0100 0010 0000 0000 0001 1110 1001 1001 1010 0000 1011 0001 0011 0001

forbidden_zero_bit(1= 0

nal_ref_idc(2)= 11

nal_unit_type(5= 0 0111seq_parameter_set_rbsp( )

所以 processSPS

profile_idc(8):42:0100 0010

constraint_set0_flag(1):0

constraint_set1_flag(1):0

constraint_set2_flag(1):0

constraint_set3_flag(1):0

reserved_zero_4bits(4):0

level_idc(8):1E

seq_parameter_set_id(UE(V)):

ue(v): unsigned integer Exp-Golomb-coded syntax element with the left bit first. The parsing process for this descriptor is specified in subclause 9.1

uvlC: 1001:根据Table9.1 , value= 0,只占1bit.

根据profile_idc忽略掉一部分。

log2_max_frame_num_minus4(ue(v): 001 1001,len = 5,value= 5

pic_order_cnt_type(ue(v)):01 1010,len = 3,value = 2

根据pic_order_cnt_type忽略几个参数

num_ref_framesue):010,len = 3,value = 1

0000 1011 0001 0011 0001

gaps_in_frame_num_value_allowed_flag(1) = 0

pic_width_in_mbs_minus1(ue):000 1011 ,len = 7,value = 10;

pic_height_in_map_units_minus1(ue):0001 001,len = 7,value = 8

frame_mbs_only_flag(1) = 1

忽略1

direct_8x8_inference_flag(1):0

忽略

vui_parameters_present_flag(1):0

忽略

NALU结束

 

68 CE 38 80 00 00 00 01

0110 1000

forbidden_zero_bit(1= 0

nal_ref_idc(2)= 11

nal_unit_type(5=01000pic_parameter_set_rbsp( ),7.3.2.2

1100

pic_parameter_set_id (ue)=0

seq_parameter_set_id(ue)=0

entropy_coding_mode_flag(1) :0,   重要的flag,0 表示编码Exp-Golomb coded and CAVLC,1表示CABAC

pic_order_present_flag(1):0

1110

num_slice_groups_minus1(ue):0

忽略

num_ref_idx_l0_active_minus1(ue):0

num_ref_idx_l1_active_minus1(ue):0

weighted_pred_flag(1);0

0011 1000 1000 0000

weighted_bipred_idc(2):00

pic_init_qp_minus26 /* relative to 26 */(se):0

pic_init_qs_minus26 /* relative to 26 */(se):0

chroma_qp_index_offset(se):0

deblocking_filter_control_present_flag(1);0

constrained_intra_pred_flag(1):0

redundant_pic_cnt_present_flag(1):0

忽略

NALU结束

 

65 88 80 21 71 27 1B 88…….3888*16 byte

65:0110 0101

forbidden_zero_bit(1= 0

nal_ref_idc(2)= 11

nal_unit_type(50 0101slice_layer_without_partitioning_rbsp( ),IDR浈

Slice

Slice_Header:

first_mb_in_slice(ue):0

slice_type(ue):000 1000 = 7

pic_parameter_set_id(ue) = 0

80 21:000 0000 0010 0001

frame_num(u(v): frame_num is used as an identifier for pictures and shall be represented by log2_max_frame_num_minus4 + 4 bits,9 bits = 0

忽略

if( nal_unit_type = = 5 ) //IDR frame

idr_pic_id(u(e)):0

忽略N

ref_pic_list_reordering( ) 见7。3。3。1忽略,Islice,SI slice,B slice

nal_ref_idc  =11 所以dec_ref_pic_marking( )

       nal_unit_type = 5,所以

       no_output_of_prior_pics_flag(1):0

long_term_reference_flag(1):0

忽略

。。71 27

001 0111 0001 0010 0111

slice_qp_deltasev):001 01 4-2

忽略

 

slice_data( ):7.3.4

对I-Slice:忽略N

进入if( moreDataFlag ) { if( MbaffFrameFlag && ( CurrMbAddr % 2 = = 0 | |                  ( CurrMbAddr % 2 = = 1 && prevMbSkipped ) ) )mb_field_decoding_flag

macroblock_layer( )}

mb_field_decoding_flag忽略

macroblock_layer( )

mb_type(ue(v):0

mb_pred( mb_type )

prev_intra4x4_pred_mode_flag[ luma4x4BlkIdx ] (1bit, 对babac是ae(v)):1

1 27:0001 0010 0111

prev_intra4x4_pred_mode_flag[ 1 ] : 0001,0,001

0010 0111

prev_intra4x4_pred_mode_flag[ 2 ] : 0010,0,010

prev_intra4x4_pred_mode_flag[ 3] : 0111,0,111

……16

1b 88 00 3e cf.

intra_chroma_pred_modeue(v) : 最后的一个1bit:0

 

接下来是macroblock_layer的coded_block_pattern和run level,既系数

c0 06 ad a0 18

1100 0000 0000 0110 1010 0000 0001 1000

coded_block_pattern(me(v):0,根据Table 9?4,= 47,0x2f

mb_qp_delta(se(v):):0 len =1

residual( )见7.3.5.3

residual_block( LumaLevel[ i8x8 * 4 + i4x4 ], 16 )

coeff_token(ce(v): 00 0000 0000 0110 1

       nc = 0(left block and top block 相关的)

len: {   // 0702

      { 1, 6, 8, 9,10,11,13,13,13,14,14,15,15,16,16,16,16},

      { 0, 2, 6, 8, 9,10,11,13,13,14,14,15,15,15,16,16,16},

      { 0, 0, 3, 7, 8, 9,10,11,13,13,14,14,15,15,16,16,16},

      { 0, 0, 0, 5, 6, 7, 8, 9,10,11,13,14,14,15,15,16,16},

    },                                                

    {                                                  

      { 2, 6, 6, 7, 8, 8, 9,11,11,12,12,12,13,13,13,14,14},

      { 0, 2, 5, 6, 6, 7, 8, 9,11,11,12,12,13,13,14,14,14},

      { 0, 0, 3, 6, 6, 7, 8, 9,11,11,12,12,13,13,13,14,14},

      { 0, 0, 0, 4, 4, 5, 6, 6, 7, 9,11,11,12,13,13,13,14},

    },                                                

    {                                                 

      { 4, 6, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 9,10,10,10,10},

      { 0, 4, 5, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 9,10,10,10},

      { 0, 0, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,10},

      { 0, 0, 0, 4, 4, 4, 4, 4, 5, 6, 7, 8, 8, 9,10,10,10},

    },

code:

      { 1, 5, 7, 7, 7, 7,15,11, 8,15,11,15,11,15,11, 7,4},

      { 0, 1, 4, 6, 6, 6, 6,14,10,14,10,14,10, 1,14,10,6},

      { 0, 0, 1, 5, 5, 5, 5, 5,13, 9,13, 9,13, 9,13, 9,5},

      { 0, 0, 0, 3, 3, 4, 4, 4, 4, 4,12,12, 8,12, 8,12,8},

    },

    {

      { 3,11, 7, 7, 7, 4, 7,15,11,15,11, 8,15,11, 7, 9,7},

      { 0, 2, 7,10, 6, 6, 6, 6,14,10,14,10,14,10,11, 8,6},

      { 0, 0, 3, 9, 5, 5, 5, 5,13, 9,13, 9,13, 9, 6,10,5},

      { 0, 0, 0, 5, 4, 6, 8, 4, 4, 4,12, 8,12,12, 8, 1,4},

    },

    {

      {15,15,11, 8,15,11, 9, 8,15,11,15,11, 8,13, 9, 5,1},

      { 0,14,15,12,10, 8,14,10,14,14,10,14,10, 7,12, 8,4},

      { 0, 0,13,14,11, 9,13, 9,13,10,13, 9,13, 9,11, 7,3},

      { 0, 0, 0,12,11,10, 9, 8,13,12,12,12, 8,12,10, 6,2},

    },

根据表查的:

code = 13,len = 15,i= 12,j=2

       所以numcoeff = 12,numtrailingones = 2

010 0000 0001 1000: totalzeros:根据numcoeff

 int lentab[TOTRUN_NUM][16] =

 {

   

    { 1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9}, 

    { 3,3,3,3,3,4,4,4,4,5,5,6,6,6,6}, 

    { 4,3,3,3,4,4,3,3,4,5,5,6,5,6}, 

    { 5,3,4,4,3,3,3,4,3,4,5,5,5}, 

    { 4,4,4,3,3,3,3,3,4,5,4,5}, 

    { 6,5,3,3,3,3,3,3,4,3,6}, 

    { 6,5,3,3,3,2,3,4,3,6}, 

    { 6,4,5,3,2,2,3,3,6}, 

    { 6,6,4,2,2,3,2,5}, 

    { 5,5,3,2,2,2,4}, 

    { 4,4,3,3,1,3}, 

    { 4,4,2,1,3}, numcoeff开始

    { 3,3,1,2}, 

    { 2,2,1}, 

    { 1,1}, 

 };

 

 int codtab[TOTRUN_NUM][16] =

 {

    {1,3,2,3,2,3,2,3,2,3,2,3,2,3,2,1},

    {7,6,5,4,3,5,4,3,2,3,2,3,2,1,0},

    {5,7,6,5,4,3,4,3,2,3,2,1,1,0},

    {3,7,5,4,6,5,4,3,3,2,2,1,0},

    {5,4,3,7,6,5,4,3,2,1,1,0},

    {1,1,7,6,5,4,3,2,1,1,0},

    {1,1,5,4,3,3,2,1,1,0},

    {1,1,1,3,3,2,2,1,0},

    {1,0,1,3,2,1,1,1,},

    {1,0,1,3,2,1,1,},

    {0,1,1,2,1,3},

    {0,1,1,1,1}, numcoeff开始

    {0,1,1,1},

    {0,1,1},

    {0,1}, 

 };

Code = 1,len = 2,i=2,j = 0, totzeros = 2

Read run: 0 0000 0001 1000根据totzeros = 2

 int lentab[TOTRUN_NUM][16] =

 {

    {1,1},

    {1,2,2},

    {2,2,2,2},

    {2,2,2,3,3},

    {2,2,3,3,3,3},

    {2,3,3,3,3,3,3},

    {3,3,3,3,3,3,3,4,5,6,7,8,9,10,11},

 };

 

 int codtab[TOTRUN_NUM][16] =

 {

    {1,0},

    {1,1,0},

    {3,2,1,0},

    {3,2,1,1,0},

    {3,2,3,2,1,0},

    {3,0,1,3,2,5,4},

    {7,6,5,4,3,2,1,1,1,1,1,1,1,1,1},

Code = 1,len =1,I = 0,j = 0

 

0.1.1         Slice data syntax

 

slice_data( ) {

C

Descriptor

     if( entropy_coding_mode_flag )

 

 

         while( !byte_aligned( ) )

 

 

              cabac_alignment_one_bit

2

f(1)

     CurrMbAddr = first_mb_in_slice * ( 1 + MbaffFrameFlag )

 

 

     moreDataFlag = 1

 

 

     prevMbSkipped = 0

 

 

     do {

 

 

         if( slice_type != I && slice_type != SI )

 

 

              if( !entropy_coding_mode_flag ) {

 

 

                  mb_skip_run

2

ue(v)

                  prevMbSkipped = ( mb_skip_run > 0 )

 

 

                  for( i="0"; i<mb_skip_run; i++ )

 

 

                       CurrMbAddr = NextMbAddress( CurrMbAddr )

 

 

                  moreDataFlag = more_rbsp_data( )

 

 

              } else {

 

 

                  mb_skip_flag

2

ae(v)

                  moreDataFlag = !mb_skip_flag

 

 

              }

 

 

         if( moreDataFlag ) {

 

 

              if( MbaffFrameFlag && ( CurrMbAddr % 2 = = 0 | | 

                  ( CurrMbAddr % 2 = = 1 && prevMbSkipped ) ) )

 

 

                  mb_field_decoding_flag

2

u(1) | ae(v)

              macroblock_layer( )

2 | 3 | 4

 

         }

 

 

         if( !entropy_coding_mode_flag )

 

 

              moreDataFlag = more_rbsp_data( )

 

 

         else {

 

 

              if( slice_type != I && slice_type != SI )

 

 

                  prevMbSkipped = mb_skip_flag

 

 

              if( MbaffFrameFlag && CurrMbAddr % 2 = = 0 )

 

 

                  moreDataFlag = 1

 

 

              else {

 

 

                  end_of_slice_flag

2

ae(v)

                  moreDataFlag = !end_of_slice_flag

 

 

              }

 

 

         }

 

 

         CurrMbAddr = NextMbAddress( CurrMbAddr )

 

 

     } while( moreDataFlag )

 

 

}

 

 

 

 

 

 

se(v) : CABAC正式介绍。根据Table 9 5 – coeff_token mapping to TotalCoeff( coeff_token ) and TrailingOnes( coeff_token )

chroma_format_idc 无

 

 

 

 

Bit string form

Range of codeNum

          1

0

        0 1 x0

1-2

      0 0 1 x1 x0

3-6

    0 0 0 1 x2 x1 x0

7-14

 0 0 0 0 1 x3 x2 x1 x0

15-30

0 0 0 0 0 1 x4 x3 x2 x1 x0

31-62

 

0.1.1.1      Slice layer without partitioning RBSP syntax

 

slice_layer_without_partitioning_rbsp( ) {

C

Descriptor

     slice_header( )

2

 

     slice_data( ) /* all categories of slice_data( ) syntax */

2 | 3 | 4

 

     rbsp_slice_trailing_bits( )

2

 

}

 

 

 

 

 

 

0.1.1.2      Sequence parameter set RBSP syntax

 

seq_parameter_set_rbsp( ) {

C

Descriptor

     profile_idc

0

u(8)

     constraint_set0_flag

0

u(1)

     constraint_set1_flag

0

u(1)

     constraint_set2_flag

0

u(1)

     constraint_set3_flag

0

u(1)

     reserved_zero_4bits /* equal to 0 */

0

u(4)

     level_idc

0

u(8)

     seq_parameter_set_id

0

ue(v)

     if( profile_idc = = 100 | | profile_idc = = 110 | |
          profile_idc = = 122 | | profile_idc = = 144 ) {

 

 

         chroma_format_idc

0

ue(v)

         if( chroma_format_idc = = 3 )

 

 

              residual_colour_transform_flag

0

u(1)

         bit_depth_luma_minus8

0

ue(v)

         bit_depth_chroma_minus8

0

ue(v)

         qpprime_y_zero_transform_bypass_flag

0

u(1)

         seq_scaling_matrix_present_flag

0

u(1)

         if( seq_scaling_matrix_present_flag )

 

 

              for( i = 0; i < 8; i++ ) {

 

 

                  seq_scaling_list_present_flag[ i ]

0

u(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_minus4

0

ue(v)

     pic_order_cnt_type

0

ue(v)

     if( pic_order_cnt_type = = 0 )

 

 

         log2_max_pic_order_cnt_lsb_minus4

0

ue(v)

     else if( pic_order_cnt_type = = 1 ) {

 

 

         delta_pic_order_always_zero_flag

0

u(1)

         offset_for_non_ref_pic

0

se(v)

         offset_for_top_to_bottom_field

0

se(v)

         num_ref_frames_in_pic_order_cnt_cycle

0

ue(v)

         for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )

 

 

              offset_for_ref_frame[ i ]

0

se(v)

     }

 

 

     num_ref_frames

0

ue(v)

     gaps_in_frame_num_value_allowed_flag

0

u(1)

     pic_width_in_mbs_minus1

0

ue(v)

     pic_height_in_map_units_minus1

0

ue(v)

     frame_mbs_only_flag

0

u(1)

     if( !frame_mbs_only_flag )

 

 

         mb_adaptive_frame_field_flag

0

u(1)

     direct_8x8_inference_flag

0

u(1)

     frame_cropping_flag

0

u(1)

     if( frame_cropping_flag ) {

 

 

         frame_crop_left_offset

0

ue(v)

         frame_crop_right_offset

0

ue(v)

         frame_crop_top_offset

0

ue(v)

         frame_crop_bottom_offset

0

ue(v)

     }

 

 

     vui_parameters_present_flag

0

u(1)

     if( vui_parameters_present_flag )

 

 

         vui_parameters( )

0

 

     rbsp_trailing_bits( )

0

 

}

 

 

 

 

Table 7?1 – NAL unit type codes

nal_unit_type

Content of NAL unit and RBSP syntax structure

C

0

Unspecified

 

1

Coded slice of a non-IDR picture
slice_layer_without_partitioning_rbsp( )

2, 3, 4

2

Coded slice data partition A
slice_data_partition_a_layer_rbsp( )

2

3

Coded slice data partition B
slice_data_partition_b_layer_rbsp( )

3

4

Coded slice data partition C
slice_data_partition_c_layer_rbsp( )

4

5

Coded slice of an IDR picture
slice_layer_without_partitioning_rbsp( )

2, 3

6

Supplemental enhancement information (SEI)
sei_rbsp( )

5

7

Sequence parameter set
seq_parameter_set_rbsp( )

0

8

Picture parameter set
pic_parameter_set_rbsp( )

1

9

Access unit delimiter
access_unit_delimiter_rbsp( )

6

10

End of sequence
end_of_seq_rbsp( )

7

11

End of stream
end_of_stream_rbsp( )

8

12

Filler data
filler_data_rbsp( )

9

13

Sequence parameter set extension
seq_parameter_set_extension_rbsp( )

10

14..18

Reserved

 

19

Coded slice of an auxiliary coded picture without partitioning
slice_layer_without_partitioning_rbsp( )

2, 3, 4

20..23

Reserved

 

24..31

Unspecified

 

 

 

 

 

byte_stream_nal_unit( NumBytesInNALunit ) {

C

Descriptor

     while( next_bits( 24 ) != 0x000001 &&
                  next_bits( 32 ) != 0x00000001 )

 

 

         leading_zero_8bits /* equal to 0x00 */

 

f(8)

     if( next_bits( 24 ) != 0x000001 )

 

 

         zero_byte /* equal to 0x00 */

 

f(8)

     start_code_prefix_one_3bytes /* equal to 0x000001 */

 

f(24)

     nal_unit( NumBytesInNALunit )

 

 

     while( more_data_in_byte_stream( ) &&
                  next_bits( 24 ) != 0x000001 &&
                  next_bits( 32 ) != 0x00000001 )

 

 

         trailing_zero_8bits /* equal to 0x00 */

 

f(8)

}

 

 

 

 

 

 

0.1.1.3      Picture parameter set RBSP syntax

 

pic_parameter_set_rbsp( ) {

C

Descriptor

     pic_parameter_set_id

1

ue(v)

     seq_parameter_set_id

1

ue(v)

     entropy_coding_mode_flag

1

u(1)

     pic_order_present_flag

1

u(1)

     num_slice_groups_minus1

1

ue(v)

     if( num_slice_groups_minus1 > 0 ) {

 

 

         slice_group_map_type

1

ue(v)

         if( slice_group_map_type = = 0 )

 

 

              for( iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++ )

 

 

                  run_length_minus1[ iGroup ]

1

ue(v)

         else if( slice_group_map_type = = 2 )

 

 

              for( iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++ ) {

 

 

                  top_left[ iGroup ]

1

ue(v)

                  bottom_right[ iGroup ]

1

ue(v)

              }

 

 

         else if( slice_group_map_type = = 3 | | 
                       slice_group_map_type = = 4 | | 
                       slice_group_map_type = = 5 ) {

 

 

              slice_group_change_direction_flag

1

u(1)

              slice_group_change_rate_minus1

1

ue(v)

         } else if( slice_group_map_type = = 6 ) {

 

 

              pic_size_in_map_units_minus1

1

ue(v)

              for( i = 0; i <= pic_size_in_map_units_minus1; i++ )

 

 

                  slice_group_id[ i ]

1

u(v)

         }

 

 

     }

 

 

     num_ref_idx_l0_active_minus1

1

ue(v)

     num_ref_idx_l1_active_minus1

1

ue(v)

     weighted_pred_flag

1

u(1)

     weighted_bipred_idc

1

u(2)

     pic_init_qp_minus26 /* relative to 26 */

1

se(v)

     pic_init_qs_minus26 /* relative to 26 */

1

se(v)

     chroma_qp_index_offset

1

se(v)

     deblocking_filter_control_present_flag

1

u(1)

     constrained_intra_pred_flag

1

u(1)

     redundant_pic_cnt_present_flag

1

u(1)

     if( more_rbsp_data( ) ) {

 

 

         transform_8x8_mode_flag

1

u(1)

         pic_scaling_matrix_present_flag

1

u(1)

         if( pic_scaling_matrix_present_flag )

 

 

              for( i = 0; i < 6 + 2* transform_8x8_mode_flag; i++ ) {

 

 

                  pic_scaling_list_present_flag[ i ]

1

u(1)

                  if( pic_scaling_list_present_flag[ i ] )

 

 

                       if( i < 6 )

 

 

                           scaling_list( ScalingList4x4[ i ], 16,
                                                UseDefaultScalingMatrix4x4Flag[ i ] )

1

 

                       else

 

 

                           scaling_list( ScalingList8x8[ i – 6 ], 64,
                                                UseDefaultScalingMatrix8x8Flag[ i – 6 ] )

1

 

              }

 

 

         second_chroma_qp_index_offset

1

se(v)

     }

 

 

     rbsp_trailing_bits( )

1

 

}

 

 

 

0.1.2         Slice header syntax

 

slice_header( ) {

C

Descriptor

     first_mb_in_slice

2

ue(v)

     slice_type

2

ue(v)

     pic_parameter_set_id

2

ue(v)

     frame_num

2

u(v)

     if( !frame_mbs_only_flag ) {

 

 

         field_pic_flag

2

u(1)

         if( field_pic_flag )

 

 

              bottom_field_flag

2

u(1)

     }

 

 

     if( nal_unit_type = = 5 )

 

 

         idr_pic_id

2

ue(v)

     if( pic_order_cnt_type = = 0 ) {

 

 

         pic_order_cnt_lsb

2

u(v)

         if( pic_order_present_flag && !field_pic_flag )

 

 

              delta_pic_order_cnt_bottom

2

se(v)

     }

 

 

     if( pic_order_cnt_type = = 1 && !delta_pic_order_always_zero_flag ) {

 

 

         delta_pic_order_cnt[ 0 ]

2

se(v)

         if( pic_order_present_flag && !field_pic_flag )

 

 

              delta_pic_order_cnt[ 1 ]

2

se(v)

     }

 

 

     if( redundant_pic_cnt_present_flag )

 

 

         redundant_pic_cnt

2

ue(v)

     if( slice_type = = B )

 

 

         direct_spatial_mv_pred_flag

2

u(1)

     if( slice_type = = P | | slice_type = = SP | | slice_type = = B ) {

 

 

         num_ref_idx_active_override_flag

2

u(1)

         if( num_ref_idx_active_override_flag ) {

 

 

              num_ref_idx_l0_active_minus1

2

ue(v)

              if( slice_type  = = B )

 

 

                  num_ref_idx_l1_active_minus1

2

ue(v)

         }

 

 

     }

 

 

     ref_pic_list_reordering( )

2

 

     if( ( weighted_pred_flag && ( slice_type = = P | | slice_type = = SP ) ) | |
         ( weighted_bipred_idc = = 1 && slice_type = = B ) )

 

 

         pred_weight_table( )

2

 

     if( nal_ref_idc != 0 )

 

 

         dec_ref_pic_marking( )

2

 

     if( entropy_coding_mode_flag && slice_type != I && slice_type != SI )

 

 

         cabac_init_idc

2

ue(v)

     slice_qp_delta

2

se(v)

     if( slice_type  = = SP | | slice_type = = SI ) {

 

 

         if( slice_type = = SP )

 

 

              sp_for_switch_flag

2

u(1)

         slice_qs_delta

2

se(v)

     }

 

 

     if( deblocking_filter_control_present_flag ) {

 

 

         disable_deblocking_filter_idc

2

ue(v)

         if( disable_deblocking_filter_idc != 1 ) {

 

 

              slice_alpha_c0_offset_div2

2

se(v)

              slice_beta_offset_div2

2

se(v)

         }

 

 

     }

 

 

     if( num_slice_groups_minus1 > 0 &&
         slice_group_map_type >= 3 && slice_group_map_type <= 5)

 

 

         slice_group_change_cycle

2

u(v)

}

 

 

 

0.1.3         Slice data syntax

 

slice_data( ) {

C

Descriptor

     if( entropy_coding_mode_flag )

 

 

         while( !byte_aligned( ) )

 

 

              cabac_alignment_one_bit

2

f(1)

     CurrMbAddr = first_mb_in_slice * ( 1 + MbaffFrameFlag )

 

 

     moreDataFlag = 1

 

 

     prevMbSkipped = 0

 

 

     do {

 

 

         if( slice_type != I && slice_type != SI )

 

 

              if( !entropy_coding_mode_flag ) {

 

 

                  mb_skip_run

2

ue(v)

                  prevMbSkipped = ( mb_skip_run > 0 )

 

 

                  for( i="0"; i<mb_skip_run; i++ )

 

 

                       CurrMbAddr = NextMbAddress( CurrMbAddr )

 

 

                  moreDataFlag = more_rbsp_data( )

 

 

              } else {

 

 

                  mb_skip_flag

2

ae(v)

                  moreDataFlag = !mb_skip_flag

 

 

              }

 

 

         if( moreDataFlag ) {

 

 

              if( MbaffFrameFlag && ( CurrMbAddr % 2 = = 0 | | 

                  ( CurrMbAddr % 2 = = 1 && prevMbSkipped ) ) )

 

 

                  mb_field_decoding_flag

2

u(1) | ae(v)

              macroblock_layer( )

2 | 3 | 4

 

         }

 

 

         if( !entropy_coding_mode_flag )

 

 

              moreDataFlag = more_rbsp_data( )

 

 

         else {

 

 

              if( slice_type != I && slice_type != SI )

 

 

                  prevMbSkipped = mb_skip_flag

 

 

              if( MbaffFrameFlag && CurrMbAddr % 2 = = 0 )

 

 

                  moreDataFlag = 1

 

 

              else {

 

 

                  end_of_slice_flag

2

ae(v)

                  moreDataFlag = !end_of_slice_flag

 

 

              }

 

 

         }

 

 

         CurrMbAddr = NextMbAddress( CurrMbAddr )

 

 

     } while( moreDataFlag )

 

 

}

 

 

The variable MbaffFrameFlag is derived as follows.

MbaffFrameFlag = ( mb_adaptive_frame_field_flag && !field_pic_flag )                           (7-22)

 

0.1.4         Macroblock layer syntax

 

macroblock_layer( ) {

C

Descriptor

     mb_type

2

ue(v) | ae(v)

     if( mb_type = = I_PCM ) {

 

 

         while( !byte_aligned( ) )

 

 

              pcm_alignment_zero_bit

2

f(1)

         for( i = 0; i < 256; i++ )

 

 

              pcm_sample_luma[ i ]

2

u(v)

         for( i = 0; i < 2 * MbWidthC * MbHeightC; i++ )

 

 

              pcm_sample_chroma[ i ]

2

u(v)

     } else {

 

 

         noSubMbPartSizeLessThan8x8Flag = 1

 

 

         if( mb_type != I_NxN &&

              MbPartPredMode( mb_type, 0 ) != Intra_16x16 &&

              NumMbPart( mb_type ) = = 4 ) {

 

 

              sub_mb_pred( mb_type )

2

 

              for( mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++ )

 

 

                  if( sub_mb_type[ mbPartIdx ] != B_Direct_8x8 ) {

 

 

                       if( NumSubMbPart( sub_mb_type[ mbPartIdx ] ) > 1 )

 

 

                           noSubMbPartSizeLessThan8x8Flag = 0

 

 

                  } else if( !direct_8x8_inference_flag )

 

 

                       noSubMbPartSizeLessThan8x8Flag = 0

 

 

         } else {

 

 

              if( transform_8x8_mode_flag && mb_type = = I_NxN )

 

 

                  transform_size_8x8_flag

2

u(1) | ae(v)

              mb_pred( mb_type )

2

 

         }

 

 

         if( MbPartPredMode( mb_type, 0 ) != Intra_16x16 ) {

 

 

              coded_block_pattern

2

me(v) | ae(v)

              if( CodedBlockPatternLuma > 0 &&

                   transform_8x8_mode_flag && mb_type != I_NxN &&

                   noSubMbPartSizeLessThan8x8Flag &&

                   ( mb_type != B_Direct_16x16 | | direct_8x8_inference_flag ) )

 

 

                  transform_size_8x8_flag

2

u(1) | ae(v)

         }

 

 

         if( CodedBlockPatternLuma > 0 | | CodedBlockPatternChroma > 0 | |
              MbPartPredMode( mb_type, 0 ) = = Intra_16x16 ) {

 

 

              mb_qp_delta

2

se(v) | ae(v)

              residual( )

3 | 4

 

         }

 

 

     }

 

 

}

 

 

 

0.1.4.1      Macroblock prediction syntax

 

mb_pred( mb_type ) {

C

Descriptor

     if( MbPartPredMode( mb_type, 0 ) = = Intra_4x4 | | 
         MbPartPredMode( mb_type, 0 ) = = Intra_8x8 | | 
         MbPartPredMode( mb_type, 0 ) = = Intra_16x16 ) {

 

 

         if( MbPartPredMode( mb_type, 0 ) = = Intra_4x4 )

 

 

              for( luma4x4BlkIdx=0; luma4x4BlkIdx<16; luma4x4BlkIdx++ ) {

 

 

                  prev_intra4x4_pred_mode_flag[ luma4x4BlkIdx ]

2

u(1) | ae(v)

                  if( !prev_intra4x4_pred_mode_flag[ luma4x4BlkIdx ] )

 

 

                       rem_intra4x4_pred_mode[ luma4x4BlkIdx ]

2

u(3) | ae(v)

              }

 

 

         if( MbPartPredMode( mb_type, 0 ) = = Intra_8x8 )

 

 

              for( luma8x8BlkIdx=0; luma8x8BlkIdx<4; luma8x8BlkIdx++ ) {

 

 

                  prev_intra8x8_pred_mode_flag[ luma8x8BlkIdx ]

2

u(1) | ae(v)

                  if( !prev_intra8x8_pred_mode_flag[ luma8x8BlkIdx ] )

 

 

                       rem_intra8x8_pred_mode[ luma8x8BlkIdx ]

2

u(3) | ae(v)

              }

 

 

         if( chroma_format_idc != 0 )

 

 

              intra_chroma_pred_mode

2

ue(v) | ae(v)

     } else if( MbPartPredMode( mb_type, 0 ) != Direct ) {

 

 

         for( mbPartIdx = 0; mbPartIdx < NumMbPart( mb_type ); mbPartIdx++)

 

 

              if( ( num_ref_idx_l0_active_minus1 > 0 | |
                       mb_field_decoding_flag ) && 
                   MbPartPredMode( mb_type, mbPartIdx ) != Pred_L1 )

 

 

                  ref_idx_l0[ mbPartIdx ]

2

te(v) | ae(v)

         for( mbPartIdx = 0; mbPartIdx < NumMbPart( mb_type ); mbPartIdx++)

 

 

              if( ( num_ref_idx_l1_active_minus1 > 0 | |
                       mb_field_decoding_flag ) && 
                  MbPartPredMode( mb_type, mbPartIdx ) != Pred_L0 )

 

 

                  ref_idx_l1[ mbPartIdx ]

2

te(v) | ae(v)

         for( mbPartIdx = 0; mbPartIdx < NumMbPart( mb_type ); mbPartIdx++)

 

 

              if( MbPartPredMode ( mb_type, mbPartIdx ) != Pred_L1 )

 

 

                  for( compIdx = 0; compIdx < 2; compIdx++ )

 

 

                       mvd_l0[ mbPartIdx ][ 0 ][ compIdx ]

2

se(v) | ae(v)

         for( mbPartIdx = 0; mbPartIdx < NumMbPart( mb_type ); mbPartIdx++)

 

 

              if( MbPartPredMode( mb_type, mbPartIdx ) != Pred_L0 )

 

 

                  for( compIdx = 0; compIdx < 2; compIdx++ )

 

 

                       mvd_l1[ mbPartIdx ][ 0 ][ compIdx ]

2

se(v) | ae(v)

     }

 

 

}

 

 

 

0.1.4.2      Residual data syntax

 

residual( ) {

C

Descriptor

     if( !entropy_coding_mode_flag )

 

 

         residual_block = residual_block_cavlc

 

 

     else

 

 

         residual_block = residual_block_cabac

 

 

     if( MbPartPredMode( mb_type, 0 ) = = Intra_16x16 )

 

 

         residual_block( Intra16x16DCLevel, 16 )

3

 

     for( i8x8 = 0; i8x8 < 4; i8x8++ ) /* each luma 8x8 block */

 

 

         if( !transform_size_8x8_flag | | !entropy_coding_mode_flag )

 

 

              for( i4x4 = 0; i4x4 < 4; i4x4++ ) { /* each 4x4 sub-block of block */

 

 

                  if( CodedBlockPatternLuma & ( 1 << i8x8 ) )

 

 

                       if( MbPartPredMode( mb_type, 0 ) = = Intra_16x16 )

 

 

                           residual_block( Intra16x16ACLevel[ i8x8 * 4 + i4x4 ], 15 )

3

 

                       else

 

 

                           residual_block( LumaLevel[ i8x8 * 4 + i4x4 ], 16 )

3 | 4

 

                  else if( MbPartPredMode( mb_type, 0 ) = = Intra_16x16 )

 

 

                       for( i = 0; i < 15; i++ )

 

 

                           Intra16x16ACLevel[ i8x8 * 4 + i4x4 ][ i ] = 0

 

 

                  else

 

 

                       for( i = 0; i < 16; i++ )

 

 

                           LumaLevel[ i8x8 * 4 + i4x4 ][ i ] = 0

 

 

                  if( !entropy_coding_mode_flag && transform_size_8x8_flag )

 

 

                       for( i = 0; i < 16; i++ )

 

 

                           LumaLevel8x8[ i8x8 ][ 4 * i + i4x4 ] =
                                                     LumaLevel[ i8x8 * 4 + i4x4 ][ i ]

 

 

              }

 

 

         else if( CodedBlockPatternLuma & ( 1 << i8x8 ) )

 

 

              residual_block( LumaLevel8x8[ i8x8 ], 64 )

3 | 4

 

         else

 

 

              for( i = 0; i < 64; i++ )

 

 

                  LumaLevel8x8[ i8x8 ][ i ] = 0

 

 

     if( chroma_format_idc != 0 ) {

 

 

         NumC8x8 = 4 / ( SubWidthC * SubHeightC )

 

 

         for( iCbCr = 0; iCbCr < 2; iCbCr++ )

 

 

              if( CodedBlockPatternChroma & 3 ) /* chroma DC residual present */

 

 

                  residual_block( ChromaDCLevel[ iCbCr ], 4 * NumC8x8 )

3 | 4

 

              else

 

 

                  for( i = 0; i < 4 * NumC8x8; i++ )

 

 

                       ChromaDCLevel[ iCbCr ][ i ] = 0

 

 

         for( iCbCr = 0; iCbCr < 2; iCbCr++ )

 

 

              for( i8x8 = 0; i8x8 < NumC8x8; i8x8++ )

 

 

                  for( i4x4 = 0; i4x4 < 4; i4x4++ )

 

 

                       if( CodedBlockPatternChroma & 2 )
                                                             /* chroma AC residual present */

 

 

                           residual_block( ChromaACLevel[ iCbCr ][ i8x8*4+i4x4 ], 15)

3 | 4

 

                       else

 

 

                           for( i = 0; i < 15; i++ )

 

 

                                ChromaACLevel[ iCbCr ][ i8x8*4+i4x4 ][ i ] = 0

 

 

     }

 

 

 

 

residual_block_cavlc( coeffLevel, maxNumCoeff ) {

C

Descriptor

    for( i = 0; i < maxNumCoeff; i++ )

 

 

       coeffLevel[ i ] = 0

 

 

    coeff_token

3 | 4

ce(v)

    if( TotalCoeff( coeff_token ) > 0 ) {

 

 

       if( TotalCoeff( coeff_token ) > 10 && TrailingOnes( coeff_token ) < 3 )

 

 

           suffixLength = 1

 

 

       else

 

 

           suffixLength = 0

 

 

       for( i = 0; i < TotalCoeff( coeff_token ); i++ )

 

 

           if( i < TrailingOnes( coeff_token ) ) {

 

 

              trailing_ones_sign_flag

3 | 4

u(1)

              level[ i ] = 1 – 2 * trailing_ones_sign_flag

 

 

           } else {

 

 

              level_prefix

3 | 4

ce(v)

              levelCode = ( Min( 15, level_prefix ) << suffixLength )

 

 

              if( suffixLength > 0 | | level_prefix >= 14 ) {

 

 

                  level_suffix

3 | 4

u(v)

                  levelCode += level_suffix

 

 

              }

 

 

              if( level_prefix > = 15 && suffixLength = = 0 )

 

 

                  levelCode += 15

 

 

              if( level_prefix > = 16 )

 

 

                  levelCode += ( 1 << ( level_prefix – 3 ) ) – 4096

 

 

              if( i = = TrailingOnes( coeff_token ) && 
                   TrailingOnes( coeff_token ) < 3 )

 

 

                  levelCode += 2

 

 

              if( levelCode % 2 = = 0 )

 

 

                  level[ i ] = ( levelCode + 2 ) >> 1

 

 

              else

 

 

                  level[ i ] = ( –levelCode – 1 ) >> 1

 

 

              if( suffixLength = = 0 )

 

 

                  suffixLength = 1

 

 

              if( Abs( level[ i ] ) > ( 3 << ( suffixLength – 1 ) ) && 
                   suffixLength < 6 )

 

 

                  suffixLength++

 

 

           }

 

 

       if( TotalCoeff( coeff_token ) < maxNumCoeff ) {

 

 

           total_zeros

3 | 4

ce(v)

           zerosLeft = total_zeros

 

 

       } else

 

 

           zerosLeft = 0

 

 

       for( i = 0; i < TotalCoeff( coeff_token ) – 1; i++ ) {

 

 

           if( zerosLeft > 0 ) {

 

 

              run_before

3 | 4

ce(v)

              run[ i ] = run_before

 

 

           } else

 

 

              run[ i ] = 0

 

 

           zerosLeft = zerosLeft – run[ i ]

 

 

       }

 

 

       run[ TotalCoeff( coeff_token ) – 1 ] = zerosLeft

 

 

       coeffNum = ?1

 

 

       for( i = TotalCoeff( coeff_token ) – 1; i >= 0; i-- ) {

 

 

           coeffNum += run[ i ] + 1

 

 

           coeffLevel[ coeffNum ] = level[ i ]

 

 

       }

 

 

    }

 

 

}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/455964.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

springboot springmvc mybatis_12道重点的Spring Boot面试题,帮你整理好了!

今天跟大家分享下SpringBoot常见面试题的知识。最新2020整理收集的一些面试题&#xff08;都整理成文档&#xff09;&#xff0c;有很多干货&#xff0c;包含mysql&#xff0c;netty&#xff0c;spring&#xff0c;线程&#xff0c;spring cloud等详细讲解&#xff0c;也有详细…

【数据分析】快速获取微博用户数据,图片,视频

功能输出实例运行环境使用说明 下载脚本安装依赖程序设置设置数据库&#xff08;可选&#xff09;运行脚本按需求修改脚本&#xff08;可选&#xff09; 如何获取user_id添加cookie与不添加cookie的区别&#xff08;可选&#xff09;如何获取cookie&#xff08;可选&#xff09…

“云计算”越来越重要 但更重要的是“云安全”

据Gartner公司的预测&#xff0c;云安全服务业务继续保持强劲&#xff0c;2017年最终将达到59亿美元的规模&#xff0c;比2016年上涨了21&#xff05;。 云安全服务市场的增长速度将超过整体信息安全市场。Gartner表示&#xff0c;电子邮件的安全性&#xff0c;网络安全和身份识…

H.264的两个概念:DC系数和AC系数。 MV预测过程详解(附图)

在做熵编码之前&#xff0c;先明确两个概念&#xff1a;DC系数和AC系数。 量化后得到的仍是64个系数&#xff0c;量化并没有改变系数的性质。大家知到DCT变换是将数据域从时&#xff08;空&#xff09;域变换到频域&#xff0c;在频域平面上变换系数是二维频域变量u和v的函数。…

1028. List Sorting (25)

题目链接&#xff1a;http://www.patest.cn/contests/pat-a-practise/1028 题目&#xff1a; 1028. List Sorting (25) 时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueExcel can sort records according to any column. Now you are suppose…

【后端开发】分析抖音后台架构

最后分享抖音美女爬虫 https://github.com/wangshub/Douyin-Bot

看日本如何用IoT打造智能工厂

在技术、市场、政策等方面因素的推动下&#xff0c;全球正在掀起一股智能制造的热潮&#xff0c;越来越多的国家大力推进智能工厂的建设。有机构预测&#xff0c;未来五年智能工厂领域的投资将促进生产力增长27%&#xff0c;预计到2022年年底&#xff0c;21%的工厂将会成为智能…

c++ 测试串口速率_纳米软件案例之电流控制测试系统

项目背景西安某机电研究所电流控制测试系统软件需要用记录仪设置采样速率对电流数据进行采集&#xff0c;并能够进行数据实时显示、保存。为更好的分析实验现象&#xff0c;需要历史测试数据可查询并显示。目前采用的传统的手动测试&#xff0c;测试操作繁杂。数据保存困难&…

【Sublime】使用 Sublime 工具时运行python文件

使用 Sublime 工具时报Decode error - output not utf-8解决办法 在菜单中tools中第四项编译系统 内最后一项增添新的编译系统 自动新建 Python.sublime-build文件,并添加"encoding":"cp936"这一行,保存即可 使用python2 则注释encoding改为utf-8 {&quo…

【python】有意思的python小项目GitHub地址汇总

Licence_plate_recognize 车牌识别 Djang-Stu 基于python的Django框架学生信息管理系统 sklearn-machine-learning 数据分析-机器学习-深度学习【个人学习笔记】 movie_analysis 对电影影评分析生成词云 spider_doubanTOP 爬取豆瓣电影top250/爬取豆瓣图书top250 yuyin_re…

R 包的安装,使用,更新

R包的使用方法 包就是提供了种类繁多的函数&#xff0c;当然还有它的一些数据集&#xff0c;可以使用这些函数来操作这些数据集&#xff0c;来学习使用。 library()&#xff0c;当前的工作环境里&#xff0c;可以使用的包 包的帮助文档&#xff1a;help(package"包名"…

nginx 电子书_13本免费的电子书,拿走,不谢

傻白甜程序员13本电子书的清单01《PyTorch官方教程中文版》傻白甜程序员中&#xff0c;后台回复“pytorch”获取02《Think Python》傻白甜程序员中&#xff0c;后台回复“ThinkPython”获取03《走向分布式》傻白甜程序员中&#xff0c;后台回复“分布式”获取04《Nginx教程&…

Redis数据类型:字符串

2019独角兽企业重金招聘Python工程师标准>>> 概要 字符串类型是Redis最基本的数据类型&#xff0c;能够存储任何形式的字符串&#xff0c;单个健值最大能够存放512兆的数据&#xff0c;据传将来会放开512M的限制。 命令 设置值&#xff1a;set foo bar 获取值&#…

【docker】docker虚拟容器的使用大全

Docker容器详解 Docker是基于Go语言开发的开源应用容器引擎&#xff0c;遵从Apache Licence 2.0协议&#xff0c;可以让开发者打包应用以及应用的依赖包到一个可移植的容器中&#xff0c;然后发布到各种发行版本的Linux系统上。 Docker简介 软件开发中最为麻烦的事情可能就是…

【树莓派】修改树莓派盒子MAC地址

用树莓派盒子&#xff0c;在某些客户方实施过程中&#xff0c;不同客户的网络环境对树莓派盒子的要求不同&#xff0c;网络管理配置要求MAC地址和IP绑定。 一种情况下&#xff0c;查询盒子的MAC地址&#xff0c;添加到网络管理的路由规则中即可&#xff1b; 另一种情况下&#…

编程随想 关系图_IT什么岗位比较好找工作?一张金字塔图就能明白

IT(Internet Technology)互联网技术是指在计算机技术的基础上开发建立的一种信息技术。IT行业这些年一直很火爆&#xff0c; 对于IT就业岗位的选择一直也都是热门话题。一、IT人才总体供需金字塔型人才需求和市场供应关系图&#xff1a;人才供需图一般IT 行业供需关系可以比喻为…

诺基亚收购了阿朗:那与 TCL 的“阿尔卡特”品牌授权协议到期后咱办?

在被诺基亚收购之后&#xff0c;“阿尔卡特-朗讯”的牌子算是被这家芬兰公司收入囊中。尴尬的是&#xff0c;TCL 很早就获得了“阿尔卡特”这个智能手机品牌的授权。当然&#xff0c;对于因为错抱了微软 Windows Phone 这条大腿、以致于多年后再借着 HMD Global 重返 Android 智…

python编辑器_没有人比它更懂少儿编程,慧编程Python'吮指编辑器'

咳咳&#xff01;大家好&#xff0c;我是偶尔写文章的康康老师。今天跟大家介绍的是慧编程家的&#xff0c;睡在Scratch上铺的兄弟——慧编程Python编辑器。这是一款集才华和颜值为一体的吮指编辑器&#xff01;忘记肯德基&#xff0c;你的手指应该为编程而生&#xff01;话不多…

浅谈数据库索引

1.什么是索引 数据库索引好比是一本书前面的目录&#xff0c;能加快数据库的查询速度。 例如这样一个查询&#xff1a;select * from table1 where id44。如果没有索引&#xff0c;必须遍历整个表&#xff0c;直到ID等于44的这一行被找到为止;有了索引之后(必须是在ID这一列上建…

iphone屏幕突然变暗_如果你的iPhone屏幕突然变暗,可以这样解决

​​如果在使用 iPhone 的过程中&#xff0c;屏幕忽然变暗&#xff0c;可能有如下原因&#xff1a;开启了“亮度自动调节”功能在 iPhone 中有一项“亮度自动调节”的功能&#xff0c;此功能是根据设备周围的光线条件来调整亮度级别&#xff1a;在光线较暗的地方&#xff0c;传…