//--------------------------------------------------------------------------- // Packet "B0" void File_AvsV::video_sequence_start() { Element_Name("video_sequence_start"); //Parsing int32u bit_rate_upper, bit_rate_lower; Get_B1 ( profile_id, "profile_id"); Get_B1 ( level_id, "level_id"); BS_Begin(); Get_SB ( progressive_sequence, "progressive_sequence"); Get_S2 (14, horizontal_size, "horizontal_size"); Get_S2 (14, vertical_size, "vertical_size"); Get_S1 ( 2, chroma_format, "chroma_format"); Skip_S1( 3, "sample_precision"); Get_S1 ( 4, aspect_ratio, "aspect_ratio"); Param_Info(AvsV_aspect_ratio[aspect_ratio]); Get_S1 ( 4, frame_rate_code, "frame_rate_code"); Param_Info(AvsV_frame_rate[frame_rate_code]); Get_S3 (18, bit_rate_lower, "bit_rate_lower"); Mark_1 (); Get_S3 (12, bit_rate_upper, "bit_rate_upper"); bit_rate=(bit_rate_upper<<18)+bit_rate_lower; Param_Info(bit_rate*8, " bps"); Get_SB ( low_delay, "low_delay"); Mark_1 (); Skip_S3(18, "bbv_buffer_size"); Skip_SB( "reserved"); Skip_SB( "reserved"); Skip_SB( "reserved"); BS_End(); //Not sure, but the 3 first official files have this if (Element_Size-Element_Offset) { BS_Begin(); Mark_1(); BS_End(); } FILLING_BEGIN(); //NextCode NextCode_Clear(); NextCode_Add(0xB2); //user_data_start NextCode_Add(0xB3); //picture_start (I) NextCode_Add(0xB5); //extension_start //Autorisation of other streams Streams[0xB1].Searching_Payload=true, //video_sequence_end Streams[0xB2].Searching_Payload=true; //user_data_start Streams[0xB3].Searching_Payload=true, //picture_start (I) Streams[0xB4].Searching_Payload=true, //reserved Streams[0xB5].Searching_Payload=true; //extension_start Streams[0xB6].Searching_Payload=true, //picture_start (P or B) Streams[0xB7].Searching_Payload=true; //video_edit Streams[0xB8].Searching_Payload=true, //reserved video_sequence_start_IsParsed=true; FILLING_END(); }
//--------------------------------------------------------------------------- // Packet "B5" void File_AvsV::extension_start() { Element_Name("Extension"); //Parsing int8u extension_start_code_identifier; BS_Begin(); Get_S1 ( 4, extension_start_code_identifier, "extension_start_code_identifier"); Param_Info(AvsV_extension_start_code_identifier[extension_start_code_identifier]); Element_Info(AvsV_extension_start_code_identifier[extension_start_code_identifier]); switch (extension_start_code_identifier) { case 2 :{ //sequence_display //Parsing Get_S1 ( 3, video_format, "video_format"); Param_Info(AvsV_video_format[video_format]); Skip_SB( "sample_range"); TEST_SB_SKIP( "colour_description"); Skip_S1( 8, "colour_primaries"); Skip_S1( 8, "transfer_characteristics"); Skip_S1( 8, "matrix_coefficients"); TEST_SB_END(); Get_S2 (14, display_horizontal_size, "display_horizontal_size"); Mark_1 (); Get_S2 (14, display_vertical_size, "display_vertical_size"); Skip_SB( "reserved"); Skip_SB( "reserved"); BS_End(); } break; case 4 :{ //copyright //Parsing Skip_SB( "copyright_flag"); Skip_S1( 8, "copyright_id"); Skip_SB( "original_or_copy"); Skip_S1( 7, "reserved"); Mark_1 (); Info_S3(20, copyright_number_1, "copyright_number_1"); Mark_1 (); Info_S3(22, copyright_number_2, "copyright_number_2"); Mark_1 (); Info_S3(22, copyright_number_3, "copyright_number_3"); Param_Info(Ztring::ToZtring(((int64u)copyright_number_1<<44)+((int64u)copyright_number_2<<22)+(int64u)copyright_number_3, 16)); BS_End(); } break; case 11 :{ //camera_parameters //Parsing Skip_SB( "reserved"); Skip_S1( 7, "camera_id"); Mark_1 (); Skip_S3(22, "height_of_image_device"); Mark_1 (); Skip_S3(22, "focal_length"); Mark_1 (); Skip_S3(22, "f_number"); Mark_1 (); Skip_S3(22, "vertical_angle_of_view"); Mark_1 (); Skip_S3(16, "camera_position_x_upper"); Mark_1 (); Skip_S3(16, "camera_position_x_lower"); Mark_1 (); Skip_S3(16, "camera_position_y_upper"); Mark_1 (); Skip_S3(16, "camera_position_y_lower"); Mark_1 (); Skip_S3(16, "camera_position_z_upper"); Mark_1 (); Skip_S3(16, "camera_position_z_lower"); Mark_1 (); Skip_S3(22, "camera_direction_x"); Mark_1 (); Skip_S3(22, "camera_direction_y"); Mark_1 (); Skip_S3(22, "camera_direction_z"); Mark_1 (); Skip_S3(22, "camera_plane_vertical_x"); Mark_1 (); Skip_S3(22, "camera_plane_vertical_y"); Mark_1 (); Skip_S3(22, "camera_plane_vertical_z"); Mark_1 (); Skip_S4(32, "reserved"); BS_End(); } break; default:{ //Parsing Skip_S1(4, "data"); BS_End(); Skip_XX(Element_Size-Element_Offset, "data"); } } //Not sure, but the 3 first official files have this if (Element_Size-Element_Offset) { BS_Begin(); Mark_1(); BS_End(); } FILLING_BEGIN(); //NextCode NextCode_Test(); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Adif::FileHeader_Parse() { //Parsing Ztring comment_field_data; int32u bitrate; int8u num_program_config_elements; int8u object_type=(int8u)-1; int8u sampling_frequency_index=(int8u)-1; int8u num_front_channel_elements=(int8u)-1; int8u num_side_channel_elements=(int8u)-1; int8u num_back_channel_elements=(int8u)-1; int8u num_lfe_channel_elements=(int8u)-1; int8u num_assoc_data_elements; int8u num_valid_cc_elements; bool bitstream_type; Skip_C4( "adif_id"); BS_Begin(); TEST_SB_SKIP( "copyright_id_present"); Skip_S4(32, "copyright_id"); Skip_S4(32, "copyright_id"); Skip_S4( 8, "copyright_id"); TEST_SB_END(); Skip_SB( "original_copy"); Skip_SB( "home"); Get_SB ( bitstream_type, "bitstream_type"); Param_Info(bitstream_type?"VBR":"CBR"); Get_S3 (23, bitrate, "bitrate"); Get_S1 ( 4, num_program_config_elements, "num_program_config_elements"); if (!bitstream_type) Skip_S3(20, "adif_buffer_fullness"); for (int8u Pos=0; Pos<num_program_config_elements+1; Pos++) { Element_Begin("program_config_element"); int8u comment_field_bytes; Skip_S1(4, "element_instance_tag"); Get_S1 (2, object_type, "object_type"); Param_Info(ADIF_object_type[object_type]); Get_S1 (4, sampling_frequency_index, "sampling_frequency_index"); Param_Info(ADIF_sampling_frequency[sampling_frequency_index]); Get_S1 (4, num_front_channel_elements, "num_front_channel_elements"); Get_S1 (4, num_side_channel_elements, "num_side_channel_elements"); Get_S1 (4, num_back_channel_elements, "num_back_channel_elements"); Get_S1 (2, num_lfe_channel_elements, "num_lfe_channel_elements"); Get_S1 (3, num_assoc_data_elements, "num_assoc_data_elements"); Get_S1 (4, num_valid_cc_elements, "num_valid_cc_elements"); TEST_SB_SKIP( "mono_mixdown_present"); Skip_S1(4, "mono_mixdown_element_number"); TEST_SB_END(); TEST_SB_SKIP( "stereo_mixdown_present"); Skip_S1(4, "stereo_mixdown_element_number"); TEST_SB_END(); TEST_SB_SKIP( "matrix_mixdown_idx_present"); Skip_S1(2, "matrix_mixdown_idx"); Skip_S1(2, "pseudo_surround_enable"); TEST_SB_END(); for (int8u Pos2=0; Pos2<num_front_channel_elements; Pos2++) { Element_Begin("front_channel_element"); Skip_SB( "front_element_is_cpe"); Skip_S1(4, "front_element_tag_select"); Element_End(); } for (int8u Pos2=0; Pos2<num_side_channel_elements; Pos2++) { Element_Begin("side_channel_element"); Skip_SB( "back_element_is_cpe"); Skip_S1(4, "back_element_tag_select"); Element_End(); } for (int8u Pos2=0; Pos2<num_back_channel_elements; Pos2++) { Element_Begin("back_channel_element"); Skip_SB( "back_element_is_cpe"); Skip_S1(4, "back_element_tag_select"); Element_End(); } for (int8u Pos2=0; Pos2<num_lfe_channel_elements; Pos2++) { Element_Begin("lfe_channel_element"); Skip_S1(4, "lfe_element_tag_select"); Element_End(); } for (int8u Pos2=0; Pos2<num_assoc_data_elements; Pos2++) { Element_Begin("assoc_data_element"); Skip_S1(4, "assoc_data_element_tag_select"); Element_End(); } for (int8u Pos2=0; Pos2<num_valid_cc_elements; Pos2++) { Element_Begin("valid_cc_element"); Skip_SB( "cc_element_is_ind_sw"); Skip_S1(4, "valid_cc_element_tag_select"); Element_End(); } BS_End(); Get_B1 (comment_field_bytes, "comment_field_bytes"); if (comment_field_bytes>0) Get_Local(comment_field_bytes, comment_field_data, "comment_field_data"); BS_Begin(); Element_End(); //We only support 1 element in ADIF Pos=num_program_config_elements; } BS_End(); FILLING_BEGIN(); File__Tags_Helper::Stream_Prepare(Stream_General); Fill(Stream_General, 0, General_Format, "ADIF"); Fill(Stream_General, 0, General_Comment, comment_field_data); File__Tags_Helper::Stream_Prepare(Stream_Audio); Fill (Stream_Audio, 0, Audio_Format, "AAC"); Fill (Stream_Audio, 0, Audio_Format_Version, "Version 2"); if (object_type!=(int8u)-1) Fill (Stream_Audio, 0, Audio_Format_Profile, ADIF_Format_Profile[object_type]); Fill (Stream_Audio, 0, Audio_Codec, ADIF_object_type[object_type]); Fill(Stream_Audio, 0, Audio_BitRate_Mode, bitstream_type?"VBR":"CBR"); if (bitrate>0) Fill(Stream_Audio, 0, bitstream_type?Audio_BitRate_Maximum:Audio_BitRate, bitrate); if (sampling_frequency_index!=(int8u)-1) Fill(Stream_Audio, 0, Audio_SamplingRate, ADIF_sampling_frequency[sampling_frequency_index]); if (num_front_channel_elements!=(int8u)-1) Fill(Stream_Audio, 0, Audio_Channel_s_, num_front_channel_elements+num_side_channel_elements+num_back_channel_elements+num_lfe_channel_elements); Fill(Stream_Audio, 0, Audio_Resolution, 16); Fill(Stream_Audio, 0, Audio_MuxingMode, "ADIF"); //No more need data File__Tags_Helper::Accept("ADIF"); File__Tags_Helper::Finish("ADIF"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_H263::Data_Parse() { //Parsing int8u Temporal_Reference_Temp; BS_Begin(); Skip_S3(22, "Picture Start Code (PSC)"); Get_S1 ( 8, Temporal_Reference_Temp, "Temporal Reference (TR)"); if (!Temporal_Reference_IsValid) { Temporal_Reference=Temporal_Reference_Temp; Temporal_Reference_IsValid=true; } else Temporal_Reference++; if (Temporal_Reference_Temp!=Temporal_Reference) { Trusted_IsNot("Out of Order"); Open_Buffer_Unsynch(); return; } Element_Begin1("Type Information (PTYPE)"); Mark_1(); Mark_0(); Skip_SB( "Split screen indicator"); Skip_SB( "Document camera indicator"); Skip_SB( "Full Picture Freeze Release"); Get_S1 (3, Source_Format, "Source Format"); Param_Info1(H263_Source_Format[Source_Format]); if (Source_Format!=7) { Skip_SB( "Picture Coding Type"); Skip_SB( "Unrestricted Motion Vector mode"); Skip_SB( "Syntax-based Arithmetic Coding mode"); Skip_SB( "Advanced Prediction mode"); Skip_SB( "PB-frames mode"); } Element_End0(); if (Source_Format==7) // Extended PTYPE { Element_Begin1("Plus PTYPE (PLUSPTYPE)"); int8u Ufep, PixelAspectRatioCode=0, Width=0, Height=0; Get_S1 ( 3, Ufep, "Update Full Extended PTYPE (UFEP)"); switch (Ufep) { case 0 : break; case 1 : Element_Begin1("Optional Part of PLUSPTYPE (OPPTYPE)"); Get_S1 (3, Source_Format, "Source Format"); Param_Info1(H263_Source_Format[Source_Format]); Skip_SB( "Custom PCF"); Skip_SB( "Unrestricted Motion Vector (UMV) mode"); Skip_SB( "Syntax-based Arithmetic Coding (SAC) mode"); Skip_SB( "Advanced Prediction (AP) mode"); Skip_SB( "Advanced INTRA Coding (AIC) mode"); Skip_SB( "Deblocking Filter (DF) mode"); Skip_SB( "Slice Structured (SS) mode"); Skip_SB( "Reference Picture Selection (RPS) mode"); Skip_SB( "Independent Segment Decoding (ISD) mode"); Skip_SB( "Alternative INTER VLC (AIV) mode"); Skip_SB( "Modified Quantization (MQ) mode"); Mark_1(); Mark_0(); Mark_0(); Mark_0(); Element_End0(); break; default : BS_End(); Skip_XX(Element_Size-Element_Offset, "Unknown"); return; //TODO: frame count... } Element_Begin1("mandatory part of PLUSPTYPE when PLUSPTYPE present (MPPTYPE)"); Skip_S1(3, "Picture Type Code"); Skip_SB( "Reference Picture Resampling (RPR) mode"); Skip_SB( "Reduced-Resolution Update (RRU) mode"); Skip_SB( "Rounding Type (RTYPE)"); Mark_0(); Mark_0(); Mark_1(); Element_End0(); Element_End0(); Skip_SB( "CPM"); Skip_S1(2, "PSBI"); Element_Begin1("Custom Picture Format (CPFMT)"); Get_S1 (4, PixelAspectRatioCode, "Pixel Aspect Ratio Code"); Get_S1 (4, Width, "Picture Width Indication"); Width++; Width<<=2; Param_Info2(Width, " pixels"); Mark_1(); Get_S1 (4, Height, "Picture Height Indication"); Height<<=2; Param_Info2(Height, " pixels"); Element_End0(); if (PixelAspectRatioCode==0xF) { Element_Begin1("Extended Pixel Aspect Ratio (EPAR)"); Get_S1 (8, PAR_W, "PAR Width"); Get_S1 (8, PAR_H, "PAR Height"); Element_End0(); } else { PAR_W=H263_PAR_W[PixelAspectRatioCode]; PAR_H=H263_PAR_H[PixelAspectRatioCode]; } } BS_End(); Skip_XX(Element_Size-Element_Offset, "Other data"); FILLING_BEGIN(); Element_Info1(Frame_Count); Frame_Count++; //Filling if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid) { Accept("H.263"); Finish("H.263"); } FILLING_END(); }
//--------------------------------------------------------------------------- void File_DolbyE::Block() { //Parsing Skip_S3(BitDepth, "Synchro"); if (ScrambledBitStream) { //We must change the buffer switch (BitDepth) { case 16 : if (!Descramble_16bit()) return; break; case 20 : if (!Descramble_20bit()) return; break; case 24 : if (!Descramble_24bit()) return; break; default : ; } } Skip_S2(14, "Unknown"); Get_S1 ( 6, ProgramConfiguration, "Program configuration"); Param_Info1(DolbyE_ChannelPositions[ProgramConfiguration]); Get_S1 ( 4, FrameRate, "Frame rate 1"); Param_Info3(Mpegv_frame_rate[FrameRate], 3, " fps"); Skip_S1( 4, "Frame rate 2? Always same as Frame rate 1"); Skip_S2(16, "Frame number?"); Element_Begin1("SMPTE time code?"); int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens; bool DropFrame; Skip_S1(4, "BG8"); Skip_S1(4, "BG7"); Skip_SB( "BGF2 / Field Phase"); Skip_SB( "BGF1"); Get_S1 (2, Hours_Tens, "Hours (Tens)"); Get_S1 (4, Hours_Units, "Hours (Units)"); Skip_S1(4, "BG6"); Skip_S1(4, "BG5"); Skip_SB( "BGF0 / BGF2"); Get_S1 (3, Minutes_Tens, "Minutes (Tens)"); Get_S1 (4, Minutes_Units, "Minutes (Units)"); Skip_S1(4, "BG4"); Skip_S1(4, "BG3"); Skip_SB( "FP - Field Phase / BGF0"); Get_S1 (3, Seconds_Tens, "Seconds (Tens)"); Get_S1 (4, Seconds_Units, "Seconds (Units)"); Skip_S1(4, "BG2"); Skip_S1(4, "BG1"); Skip_SB( "CF - Color fame"); Get_SB ( DropFrame, "DP - Drop frame"); Get_S1 (2, Frames_Tens, "Frames (Tens)"); Get_S1 (4, Frames_Units, "Frames (Units)"); Skip_BS(Data_BS_Remain(), "Unknown"); if (Hours_Tens<3) { int64u TimeCode=(int64u)(Hours_Tens *10*60*60*1000 + Hours_Units *60*60*1000 + Minutes_Tens *10*60*1000 + Minutes_Units *60*1000 + Seconds_Tens *10*1000 + Seconds_Units *1000 + (Mpegv_frame_rate[FrameRate]?float64_int32s((Frames_Tens*10+Frames_Units)*1000/Mpegv_frame_rate[FrameRate]):0)); Element_Info1(Ztring().Duration_From_Milliseconds(TimeCode)); //TimeCode if (SMPTE_time_code_StartTimecode==(int64u)-1) SMPTE_time_code_StartTimecode=TimeCode; } }