全部博文(584)
分类: LINUX
2010-05-20 18:54:41
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 |
|
|
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 无
9‑1 – Bit strings with “prefix” and “suffix” bits and assignment to codeNum ranges (informative)
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 |
… |
… |
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 |
|
} |
|
|
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 | | |
|
|
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, |
0 |
|
else |
|
|
scaling_list(
ScalingList8x8[ i – 6 ], 64, |
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 ) { |
|
|
|
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 |
|
} |
|
|
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 |
2, 3, 4 |
2 |
Coded slice data partition A |
2 |
3 |
Coded slice data partition B |
3 |
4 |
Coded slice data partition C |
4 |
5 |
Coded slice of an IDR picture |
2, 3 |
6 |
Supplemental enhancement information
(SEI) |
5 |
7 |
Sequence parameter set |
0 |
8 |
Picture parameter set |
1 |
9 |
Access unit delimiter |
6 |
10 |
End of sequence |
7 |
11 |
End of stream |
8 |
12 |
Filler data |
9 |
13 |
Sequence parameter set extension |
10 |
14..18 |
Reserved |
|
19 |
Coded slice of an auxiliary coded
picture without partitioning |
2, 3, 4 |
20..23 |
Reserved |
|
24..31 |
Unspecified |
|
byte_stream_nal_unit( NumBytesInNALunit ) { |
C |
Descriptor |
while(
next_bits( 24 ) != 0x000001 && |
|
|
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( )
&& |
|
|
trailing_zero_8bits /* equal to 0x00 */ |
|
f(8) |
} |
|
|
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_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, |
1 |
|
else |
|
|
scaling_list(
ScalingList8x8[ i – 6 ], 64, |
1 |
|
} |
|
|
second_chroma_qp_index_offset |
1 |
se(v) |
} |
|
|
rbsp_trailing_bits( ) |
1 |
|
} |
|
|
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 ) ) | | |
|
|
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_change_cycle |
2 |
u(v) |
} |
|
|
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 |
|
|
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)
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 | | |
|
|
mb_qp_delta |
2 |
se(v) | ae(v) |
residual( ) |
3 | 4 |
|
} |
|
|
} |
|
|
} |
|
|