📄 gethdr.cpp
字号:
((frame_rate_extension_n+1)/(frame_rate_extension_d+1)); /* special case for 422 profile & level must be made */ if((profile_and_level_indication>>7) & 1) { /* escape bit of profile_and_level_indication set */ /* 4:2:2 Profile @ Main Level */ if((profile_and_level_indication&15)==5) { profile = PROFILE_422; level = MAIN_LEVEL; } } else { profile = profile_and_level_indication >> 4; /* Profile is upper nibble */ level = profile_and_level_indication & 0xF; /* Level is lower nibble */ } horizontal_size = (horizontal_size_extension<<12) | (horizontal_size&0x0fff); vertical_size = (vertical_size_extension<<12) | (vertical_size&0x0fff); /* ISO/IEC 13818-2 does not define bit_rate_value to be composed of * both the original bit_rate_value parsed in sequence_header() and * the optional bit_rate_extension in sequence_extension_header(). * However, we use it for bitstream verification purposes. */ bit_rate_value += (bit_rate_extension << 18); bit_rate = ((double) bit_rate_value) * 400.0; vbv_buffer_size += (vbv_buffer_size_extension << 10);#ifdef VERIFY verify_sequence_extension++;#endif /* VERIFY */}/* decode sequence display extension */static void sequence_display_extension(){ int pos; pos = ld->Bitcnt; video_format = Get_Bits(3); color_description = Get_Bits(1);
if (color_description) { color_primaries = Get_Bits(8); transfer_characteristics = Get_Bits(8); matrix_coefficients = Get_Bits(8); } display_horizontal_size = Get_Bits(14); marker_bit("sequence_display_extension"); display_vertical_size = Get_Bits(14);#ifdef VERIFY verify_sequence_display_extension++;#endif /* VERIFY */}/* decode quant matrix entension *//* ISO/IEC 13818-2 section 6.2.3.2 */static void quant_matrix_extension(){ int i; int pos; pos = ld->Bitcnt; if((ld->load_intra_quantizer_matrix = Get_Bits(1))) { for (i=0; i<64; i++) { ld->chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = ld->intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); } } if((ld->load_non_intra_quantizer_matrix = Get_Bits(1))) { for (i=0; i<64; i++) { ld->chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = ld->non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); } } if((ld->load_chroma_intra_quantizer_matrix = Get_Bits(1))) { for (i=0; i<64; i++) ld->chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); } if((ld->load_chroma_non_intra_quantizer_matrix = Get_Bits(1))) { for (i=0; i<64; i++) ld->chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); }#ifdef VERIFY verify_quant_matrix_extension++;#endif /* VERIFY */}/* decode sequence scalable extension *//* ISO/IEC 13818-2 section 6.2.2.5 */static void sequence_scalable_extension(){ int pos; pos = ld->Bitcnt; /* values (without the +1 offset) of scalable_mode are defined in Table 6-10 of ISO/IEC 13818-2 */ ld->scalable_mode = Get_Bits(2) + 1; /* add 1 to make SC_DP != SC_NONE */ layer_id = Get_Bits(4); if (ld->scalable_mode==SC_SPAT) { lower_layer_prediction_horizontal_size = Get_Bits(14); marker_bit("sequence_scalable_extension()"); lower_layer_prediction_vertical_size = Get_Bits(14); horizontal_subsampling_factor_m = Get_Bits(5); horizontal_subsampling_factor_n = Get_Bits(5); vertical_subsampling_factor_m = Get_Bits(5); vertical_subsampling_factor_n = Get_Bits(5); } if (ld->scalable_mode==SC_TEMP) Error("temporal scalability not implemented\n");#ifdef VERIFY verify_sequence_scalable_extension++;#endif /* VERIFY */}/* decode picture display extension *//* ISO/IEC 13818-2 section 6.2.3.3. */static void picture_display_extension(){ int i; int number_of_frame_center_offsets; int pos; pos = ld->Bitcnt; /* based on ISO/IEC 13818-2 section 6.3.12 (November 1994) Picture display extensions */ /* derive number_of_frame_center_offsets */ if(progressive_sequence) { if(repeat_first_field) { if(top_field_first) number_of_frame_center_offsets = 3; else number_of_frame_center_offsets = 2; } else { number_of_frame_center_offsets = 1; } } else { if(picture_structure!=FRAME_PICTURE) { number_of_frame_center_offsets = 1; } else { if(repeat_first_field) number_of_frame_center_offsets = 3; else number_of_frame_center_offsets = 2; } } /* now parse */ for (i=0; i<number_of_frame_center_offsets; i++) { frame_center_horizontal_offset[i] = Get_Bits(16); marker_bit("picture_display_extension, first marker bit"); frame_center_vertical_offset[i] = Get_Bits(16); marker_bit("picture_display_extension, second marker bit"); }#ifdef VERIFY verify_picture_display_extension++;#endif /* VERIFY */}/* decode picture coding extension */static void picture_coding_extension(){ int pos; pos = ld->Bitcnt; f_code[0][0] = Get_Bits(4); f_code[0][1] = Get_Bits(4); f_code[1][0] = Get_Bits(4); f_code[1][1] = Get_Bits(4); intra_dc_precision = Get_Bits(2); picture_structure = Get_Bits(2); top_field_first = Get_Bits(1); frame_pred_frame_dct = Get_Bits(1); concealment_motion_vectors = Get_Bits(1); ld->q_scale_type = Get_Bits(1); intra_vlc_format = Get_Bits(1); ld->alternate_scan = Get_Bits(1); repeat_first_field = Get_Bits(1); chroma_420_type = Get_Bits(1); progressive_frame = Get_Bits(1); composite_display_flag = Get_Bits(1); if (composite_display_flag) { v_axis = Get_Bits(1); field_sequence = Get_Bits(3); sub_carrier = Get_Bits(1); burst_amplitude = Get_Bits(7); sub_carrier_phase = Get_Bits(8); }#ifdef VERIFY verify_picture_coding_extension++;#endif /* VERIFY */}/* decode picture spatial scalable extension *//* ISO/IEC 13818-2 section 6.2.3.5. */static void picture_spatial_scalable_extension(){ int pos; pos = ld->Bitcnt; ld->pict_scal = 1; /* use spatial scalability in this picture */ lower_layer_temporal_reference = Get_Bits(10); marker_bit("picture_spatial_scalable_extension(), first marker bit"); lower_layer_horizontal_offset = Get_Bits(15); if (lower_layer_horizontal_offset>=16384) lower_layer_horizontal_offset-= 32768; marker_bit("picture_spatial_scalable_extension(), second marker bit"); lower_layer_vertical_offset = Get_Bits(15); if (lower_layer_vertical_offset>=16384) lower_layer_vertical_offset-= 32768; spatial_temporal_weight_code_table_index = Get_Bits(2); lower_layer_progressive_frame = Get_Bits(1); lower_layer_deinterlaced_field_select = Get_Bits(1);#ifdef VERIFY verify_picture_spatial_scalable_extension++;#endif /* VERIFY */}/* decode picture temporal scalable extension * * not implemented *//* ISO/IEC 13818-2 section 6.2.3.4. */static void picture_temporal_scalable_extension(){ Error("temporal scalability not supported\n");#ifdef VERIFY verify_picture_temporal_scalable_extension++;#endif /* VERIFY */}/* decode extra bit information *//* ISO/IEC 13818-2 section 6.2.3.4. */static int extra_bit_information(){ int Byte_Count = 0; while (Get_Bits1()) { FLUSH_BUFFER(8); Byte_Count++; } return(Byte_Count);}/* ISO/IEC 13818-2 section 5.3 *//* Purpose: this function is mainly designed to aid in bitstream conformance testing. A simple Flush_Buffer(1) would do */void marker_bit(char *text){ int marker; marker = Get_Bits(1);#ifdef VERIFY #endif}/* ISO/IEC 13818-2 sections 6.3.4.1 and 6.2.2.2.2 */static void user_data(){ /* skip ahead to the next start code */ next_start_code();}/* Copyright extension *//* ISO/IEC 13818-2 section 6.2.3.6. *//* (header added in November, 1994 to the IS document) */static void copyright_extension(){ int pos; int reserved_data; pos = ld->Bitcnt; copyright_flag = Get_Bits(1); copyright_identifier = Get_Bits(8); original_or_copy = Get_Bits(1); /* reserved */ reserved_data = Get_Bits(7); marker_bit("copyright_extension(), first marker bit"); copyright_number_1 = Get_Bits(20); marker_bit("copyright_extension(), second marker bit"); copyright_number_2 = Get_Bits(22); marker_bit("copyright_extension(), third marker bit"); copyright_number_3 = Get_Bits(22); #ifdef VERIFY verify_copyright_extension++;#endif /* VERIFY */}/* introduced in September 1995 to assist Spatial Scalability */static void Update_Temporal_Reference_Tacking_Data(){ static int temporal_reference_wrap = 0; static int temporal_reference_old = 0; if (ld == &base) /* *CH* */ { if (picture_coding_type!=B_TYPE && temporal_reference!=temporal_reference_old) /* check first field of */ { /* non-B-frame */ if (temporal_reference_wrap) {/* wrap occured at previous I- or P-frame */ /* now all intervening B-frames which could still have high temporal_reference values are done */ Temporal_Reference_Base += 1024; temporal_reference_wrap = 0; } /* distinguish from a reset */ if (temporal_reference<temporal_reference_old && !Temporal_Reference_GOP_Reset) temporal_reference_wrap = 1; /* we must have just passed a GOP-Header! */ temporal_reference_old = temporal_reference; Temporal_Reference_GOP_Reset = 0; } True_Framenum = Temporal_Reference_Base + temporal_reference; /* temporary wrap of TR at 1024 for M frames */ if (temporal_reference_wrap && temporal_reference <= temporal_reference_old) True_Framenum += 1024; True_Framenum_max = (True_Framenum > True_Framenum_max) ? True_Framenum : True_Framenum_max; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -