//--------------------------------------------------------------------------- void File_HuffYuv::FrameHeader() { //Version if (Element_Size<4) { Reject(); return; } int8u Version; if (Buffer[3]==0) { Version=Element_Size>4?2:1; } else Version=3; //Parsing int8u bpp_override=0, chroma_v_shift=0, chroma_h_shift=0, interlace; bool alpha=false, chroma=false, rgb=false; Element_Begin1("method"); BS_Begin(); Skip_SB( "unknown"); Skip_SB( "decorrelate"); Skip_S1(6, "predictor"); Element_End0(); if (Version<=2) { Get_S1 (8, bpp_override, "bpp_override"); } else { Get_S1 (4, bpp_override, "bit_depth"); Param_Info2(bpp_override+1, "bits"); Get_S1 (2, chroma_v_shift, "chroma_v_shift"); Get_S1 (2, chroma_h_shift, "chroma_h_shift"); } Skip_SB( "unknown"); Skip_SB( "context"); Get_S1 (2, interlace, "interlace"); if (Version<=2) { Skip_S1(4, "unknown"); Skip_S1(8, "zero"); } else { Skip_SB( "unknown"); Get_SB ( alpha, "alpha"); Get_SB ( rgb, "rgb"); if (rgb) Skip_SB( "unused"); else Get_SB ( chroma, "chroma"); Skip_S1(7, "unused"); Skip_SB( "version 3+ indicator"); } BS_End(); if (Frame_Count==0) { if (Version==2) { //BiCount; if (bpp_override) BitCount=bpp_override; Fill(Stream_Video, 0, Video_BitDepth, 8); } else { Fill(Stream_Video, 0, Video_BitDepth, bpp_override+1); } Fill(Stream_Video, 0, Video_Format_Version, __T("Version ")+Ztring::ToZtring(Version)); if (Version==2) { Fill(Stream_Video, 0, Video_ColorSpace, HuffYUV_ColorSpace(BitCount)); Fill(Stream_Video, 0, Video_ChromaSubsampling, HuffYUV_ChromaSubsampling(BitCount)); } else { Fill(Stream_Video, 0, Video_ColorSpace, HuffYUV_ColorSpace(rgb, chroma, alpha)); string ChromaSubsampling; if (chroma) { switch (chroma_h_shift) { case 0 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:4:4"; break; default: ; } break; case 1 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:2:2"; break; case 1 : ChromaSubsampling="4:2:0"; break; default: ; } break; case 2 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:1:1"; break; case 1 : ChromaSubsampling="4:1:0"; break; case 2 : ChromaSubsampling="4:1:0 (4x4)"; break; default: ; } break; default: ; } } if (!ChromaSubsampling.empty() && alpha) ChromaSubsampling+=":4"; Fill(Stream_Video, 0, Video_ChromaSubsampling, ChromaSubsampling); } switch (interlace) { case 0 : if (Version<=2 && Height) Fill(Stream_Video, 0, Video_ScanType, Height>288?"Interlaced":"Progressive"); break; case 1 : Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); break; case 2 : Fill(Stream_Video, 0, Video_ScanType, "Progressive"); break; default:; } } }
//--------------------------------------------------------------------------- void File_Wvpk::Data_Parse() { //Specific if (FromMKV && !FromMKV_CodecPrivateParsed) { //Parsing Get_L2 (version, "version"); FILLING_BEGIN(); FromMKV_CodecPrivateParsed=true; FILLING_END(); return; } //Counting Frame_Count++; //Parsing Element_Begin1("Block Header"); if (!FromMKV) Get_L2 (version, "version"); if (version/0x100==0x4) { while (Element_Offset<Element_Size) { int32u total_samples=(int32u)-1, block_index=(int32u)-1, block_samples=0, flags, blocksize=(int32u)-1; bool initial_block=true, final_block=true; if (!FromMKV) { Skip_L1( "track_no"); Skip_L1( "index_no"); Get_L4 (total_samples, "total_samples"); Get_L4 (block_index, "block_index"); } if (!FromMKV || Element_Offset==0) Get_L4 (block_samples, "block_samples"); if (block_samples!=0) //empty frames have other values empty { if (!FromMKV) { if (block_index==0) //Only the frame with block_index==0 total_samples_FirstFrame=total_samples; //Note: total_samples is not trustable for a cutted file if (Frame_Count==1) block_index_FirstFrame=block_index; //Save the block_index of the first block block_index_LastFrame=block_index; block_samples_LastFrame=block_samples; } Get_L4 (flags, "flags"); Get_Flags (flags, 0, resolution0, "resolution0"); Get_Flags (flags, 1, resolution1, "resolution1"); Get_Flags (flags, 2, mono, "mono"); Get_Flags (flags, 3, hybrid, "hybrid"); Get_Flags (flags, 4, joint_stereo, "joint stereo"); Get_Flags (flags, 5, cross_channel_decorrelation, "cross-channel decorrelation"); Skip_Flags(flags, 6, "hybrid noise shaping"); Skip_Flags(flags, 7, "floating point data"); Skip_Flags(flags, 8, "extended size integers"); Skip_Flags(flags, 9, "hybrid mode parameters control bitrate"); Skip_Flags(flags, 10, "hybrid noise balanced between channels"); Get_Flags (flags, 11, initial_block, "initial block in sequence"); Get_Flags (flags, 12, final_block, "final block in sequence"); Skip_Flags(flags, 13, "amount of data left-shift after decode"); Skip_Flags(flags, 14, "amount of data left-shift after decode"); Skip_Flags(flags, 15, "amount of data left-shift after decode"); Skip_Flags(flags, 16, "amount of data left-shift after decode"); Skip_Flags(flags, 17, "amount of data left-shift after decode"); Skip_Flags(flags, 18, "maximum magnitude of decoded data"); Skip_Flags(flags, 19, "maximum magnitude of decoded data"); Skip_Flags(flags, 20, "maximum magnitude of decoded data"); Skip_Flags(flags, 21, "maximum magnitude of decoded data"); Skip_Flags(flags, 22, "maximum magnitude of decoded data"); Skip_Flags(flags, 23, "sampling rate"); Skip_Flags(flags, 24, "sampling rate"); Skip_Flags(flags, 25, "sampling rate"); Skip_Flags(flags, 26, "sampling rate"); SamplingRate=(int8u)(((flags>>23)&0xF)); Param_Info1(Wvpk_SamplingRate[SamplingRate]); Skip_Flags(flags, 27, "reserved"); Skip_Flags(flags, 28, "reserved"); Skip_Flags(flags, 29, "use IIR for negative hybrid noise shaping"); Skip_Flags(flags, 30, "false stereo"); Skip_Flags(flags, 31, "reserved"); } else { Skip_L4( "flags (empty)"); //Counting Frame_Count--; //This is not a real frame } Skip_L4( "crc"); Element_End0(); int64u End=Element_Size; if (FromMKV && !(initial_block && final_block)) { Get_L4 (blocksize, "blocksize"); End=Element_Offset+blocksize; if (End>=Element_Size) End=Element_Size; } //Sub-block int8u id; while (Element_Offset<End) { Element_Begin0(); int32u word_size; bool large, odd_size; BS_Begin(); Get_SB (large, "large"); Get_SB (odd_size, "odd_size"); Get_S1 (6, id, "id"); Element_Info1(Wvpk_id(id)); BS_End(); if (large) { Get_L3 (word_size, "word_size"); } else { int8u word_size1; Get_L1 (word_size1, "word_size"); word_size=word_size1; } if (word_size==0 && odd_size) Size=0; //Problem! else Size=word_size*2-(odd_size?1:0); Element_Name(Ztring().From_CC1(id)); switch (id) { case 0x07 : id_07(); break; case 0x0D : id_0D(); break; case 0x25 : id_25(); break; default : if (word_size) Skip_XX(Size, "data"); } if (odd_size) Skip_XX(1, "padding"); Element_End0(); } } }
//--------------------------------------------------------------------------- void File_DtvccTransport::Read_Buffer_Continue() { //Parsing Element_Begin1(Format==Format_DVD?"DVD Captions":"DTVCC Transport"); int8u cc_count; bool process_cc_data_flag, additional_data_flag; BS_Begin(); if (Format==Format_DVD) { //Modified DTVCC Transport from DVD Skip_SB( "field 1 then field 2"); Get_S1 (7, cc_count, "cc_count"); process_cc_data_flag=true; additional_data_flag=false; } else { //Normal DTVCC Transport bool process_em_data_flag; Get_SB (process_em_data_flag, "process_em_data_flag"); Get_SB (process_cc_data_flag, "process_cc_data_flag"); Get_SB (additional_data_flag, "additional_data_flag"); Get_S1 (5, cc_count, "cc_count"); Skip_S1(8, process_em_data_flag?"em_data":"reserved"); //Emergency message } BS_End(); if (process_cc_data_flag) { for (int8u Pos=0; Pos<cc_count; Pos++) { if (Element_Offset+3>Element_Size) break; //Found one stream with bad cc_count, we discard cc_count without flagging the stream as untrusted for the moment Element_Begin1("cc"); int8u cc_type; bool cc_valid; BS_Begin(); Mark_1(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); if (Format==Format_DVD) { //Modified DTVCC Transport from DVD Mark_1(); Mark_1(); Get_S1 (1, cc_type, "cc_type"); Param_Info1(DtvccTransport_cc_type(cc_type)); cc_valid=true; } else { //Normal DTVCC Transport Get_SB ( cc_valid, "cc_valid"); Get_S1 (2, cc_type, "cc_type"); Param_Info1(DtvccTransport_cc_type(cc_type)); } BS_End(); #if MEDIAINFO_ADVANCED if (cc_type>=2 && !Streams[2] && Config->File_Eia708_DisplayEmptyStream_Get()) CreateStream(2); #endif //MEDIAINFO_ADVANCED if (cc_valid) { Element_Begin1("cc_data"); //Calculating the parser position int8u Parser_Pos=cc_type==3?2:cc_type; //cc_type 2 and 3 are for the same text //Stream creation if (Streams[Parser_Pos]==NULL) CreateStream(Parser_Pos); //Parsing #if MEDIAINFO_DEMUX Element_Code=Parser_Pos; Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream); #endif //MEDIAINFO_DEMUX if (!Streams[Parser_Pos]->Parser->Status[IsFinished]) { //Parsing if (Streams[Parser_Pos]->Parser->PTS_DTS_Needed) { Streams[Parser_Pos]->Parser->FrameInfo.PCR=FrameInfo.PCR; Streams[Parser_Pos]->Parser->FrameInfo.PTS=FrameInfo.PTS; Streams[Parser_Pos]->Parser->FrameInfo.DTS=FrameInfo.DTS; } if (Parser_Pos==2) { #if defined(MEDIAINFO_EIA708_YES) ((File_Eia708*)Streams[2]->Parser)->cc_type=cc_type; if (AspectRatio) ((File_Eia708*)Streams[2]->Parser)->AspectRatio=AspectRatio; #endif if (cc_type==3) { ((File_Eia708*)Streams[2]->Parser)->cc_type=4; //Magic value saying that the buffer must be kept (this is only a point of synchro from the undelying layer) Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 0); ((File_Eia708*)Streams[2]->Parser)->cc_type=3; } } else { } #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser->ServiceDescriptors=ServiceDescriptors; #endif Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 2); Element_Show(); Element_Offset+=2; } else Skip_XX(2, "Data"); Element_End0(); } else Skip_XX(2, "Junk"); Element_End0(); } FILLING_BEGIN(); if (!Status[IsAccepted]) Accept("DTVCC Transport"); FILLING_END(); } else Skip_XX(cc_count*2, "Junk"); if (Format==Format_A53_4_GA94_03) { //Normal DTVCC Transport BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); BS_End(); if (additional_data_flag) { Skip_XX(Element_Size-Element_Offset, "additional_user_data"); } while (Element_Offset<Element_Size) { Skip_B1( "Zero"); //TODO: test Zero } } Element_End0(); }
//--------------------------------------------------------------------------- void File_Pdf::trailer() { Element_Begin1("Trailer"); //Parsing int32u Prev=(int32u)-1; string Key; Ztring Value; Skip_String(SizeOfLine(), "Object name"); while (Element_Offset<Element_Size) { if (Get_Next(Key, Value)) { for (;;) { Get_Next(Key, Value); if (Key.empty()) break; else if (Key=="Root") { int32u ObjectNumber=Value.To_int32u(); Objects[ObjectNumber].Type=Type_Root; Objects[ObjectNumber].TopObject=(int32u)-1; Objects[(int32u)-1].Bottoms.push_back(ObjectNumber); Param_Info1(__T("Document Catalog is at offset 0x"+Ztring().From_Number(Objects[ObjectNumber].Offset, 16))); } else if (Key=="Info") { int32u ObjectNumber=Value.To_int32u(); Objects[ObjectNumber].Type=Type_Info; Objects[ObjectNumber].TopObject=(int32u)-1; Objects[(int32u)-1].Bottoms.push_back(ObjectNumber); Param_Info1(__T("Info is at offset 0x"+Ztring().From_Number(Objects[ObjectNumber].Offset, 16))); } else if (Key=="Prev") { Prev=Value.To_int32u(); Param_Info1(__T("Previous Cross-Reference Table is at offset 0x"+Ztring().From_Number(Prev, 16))); } } continue; } if (Key.empty()) break; } Element_End0(); //Previous Cross-Reference Table if (Prev!=(int32u)-1) { GoTo(Prev); return; } objects::iterator Object_Top=Objects.find((int32u)-1); if (Offsets.empty() || Object_Top==Objects.end()) { ForceFinish(); return; } sort(Offsets.begin(), Offsets.end()); //Offsets_Current=Offsets.end(); //No more used for the moment Objects[(int32u)-1].BottomPos=0; Objects_Current=Objects.find(Object_Top->second.Bottoms[0]); GoTo(Objects_Current->second.Offset); State=State_Parsing_object; }
//--------------------------------------------------------------------------- void File_Jpeg::SOF_() { //Parsing vector<Jpeg_samplingfactor> SamplingFactors; int16u Height, Width; int8u Resolution, Count; Get_B1 (Resolution, "P - Sample precision"); Get_B2 (Height, "Y - Number of lines"); Get_B2 (Width, "X - Number of samples per line"); Get_B1 (Count, "Nf - Number of image components in frame"); for (int8u Pos=0; Pos<Count; Pos++) { Jpeg_samplingfactor SamplingFactor; Element_Begin1("Component"); Info_B1(Ci, "Ci - Component identifier"); Element_Info1(Ci); BS_Begin(); Get_S1 (4, SamplingFactor.Hi, "Hi - Horizontal sampling factor"); Element_Info1(SamplingFactor.Hi); Get_S1 (4, SamplingFactor.Vi, "Vi - Vertical sampling factor"); Element_Info1(SamplingFactor.Vi); BS_End(); Skip_B1( "Tqi - Quantization table destination selector"); Element_End0(); //Filling list of HiVi SamplingFactors.push_back(SamplingFactor); } FILLING_BEGIN_PRECISE(); if (Frame_Count==0 && Field_Count==0) { Accept("JPEG"); if (Count_Get(StreamKind_Last)==0) Stream_Prepare(StreamKind_Last); Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "JPEG"); Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), "JPEG"); if (StreamKind_Last==Stream_Image) Fill(Stream_Image, 0, Image_Codec_String, "JPEG", Unlimited, true, true); //To Avoid automatic filling if (StreamKind_Last==Stream_Video) Fill(Stream_Video, 0, Video_InternetMediaType, "video/JPEG", Unlimited, true, true); Fill(StreamKind_Last, 0, "ColorSpace", "YUV"); Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_BitDepth), Resolution); Fill(StreamKind_Last, 0, "Height", Height*Height_Multiplier); Fill(StreamKind_Last, 0, "Width", Width); //Chroma subsampling if (SamplingFactors.size()==3 && SamplingFactors[1].Hi==1 && SamplingFactors[2].Hi==1 && SamplingFactors[1].Vi==1 && SamplingFactors[2].Vi==1) { string ChromaSubsampling; switch (SamplingFactors[0].Hi) { case 1 : switch (SamplingFactors[0].Vi) { case 1 : ChromaSubsampling="4:4:4"; break; default: ; } break; case 2 : switch (SamplingFactors[0].Vi) { case 1 : ChromaSubsampling="4:2:2"; break; case 2 : ChromaSubsampling="4:2:0"; break; default: ; } break; case 4 : switch (SamplingFactors[0].Vi) { case 1 : ChromaSubsampling="4:1:1"; break; default: ; } break; default: ; } if (!ChromaSubsampling.empty()) Fill(StreamKind_Last, 0, "ChromaSubsampling", ChromaSubsampling); } } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Gxf_TimeCode::Read_Buffer_Continue() { int8u Validity[504]; if (!IsAtc) { if (Element_Size!=4096) { Skip_XX(Element_Size, "Data"); return; } //Reading bitmap first (validity of first byte is at the end) Element_Offset=504*8; Element_Begin1("Validity"); BS_Begin_LE(); //is Little Endian for (size_t Pos=0; Pos<504; Pos++) { bool Validity_Bit; Get_TB (Validity_Bit, "Bit"); Validity[Pos]=Validity_Bit?1:0; } BS_End_LE(); Skip_B1( "Pad"); Element_End0(); } //Parsing Element_Offset=0; for (size_t Pos=0; Pos<(IsAtc?(size_t)1:(size_t)504); Pos++) { if (IsAtc || Validity[Pos]) { Element_Begin1("TimeCode"); int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens; bool DropFrame; int8u DBB1=0, DBB2=0; if (IsAtc) { bool Temp; BS_Begin(); Get_S1 (4, Frames_Units, "Frames (Units)"); Get_SB ( Temp, "DBB1_0"); if (Temp) DBB1|=(1<<0); Skip_S1(3, "Zero"); Skip_S1(4, "BG1"); Get_SB ( Temp, "DBB1_1"); if (Temp) DBB1|=(1<<1); Skip_S1(3, "Zero"); Skip_SB( "CF - Color fame"); Get_SB ( DropFrame, "DP - Drop frame"); Get_S1 (2, Frames_Tens, "Frames (Tens)"); Get_SB ( Temp, "DBB1_2"); if (Temp) DBB1|=(1<<2); Skip_S1(3, "Zero"); Skip_S1(4, "BG2"); Get_SB ( Temp, "DBB1_3"); if (Temp) DBB1|=(1<<3); Skip_S1(3, "Zero"); Get_S1 (4, Seconds_Units, "Seconds (Units)"); Get_SB ( Temp, "DBB1_4"); if (Temp) DBB1|=(1<<4); Skip_S1(3, "Zero"); Skip_S1(4, "BG3"); Get_SB ( Temp, "DBB1_5"); if (Temp) DBB1|=(1<<5); Skip_S1(3, "Zero"); Skip_SB( "FM - Frame Mark"); Get_S1 (3, Seconds_Tens, "Seconds (Tens)"); Get_SB ( Temp, "DBB1_6"); if (Temp) DBB1|=(1<<6); Skip_S1(3, "Zero"); Skip_S1(4, "BG4"); Get_SB ( Temp, "DBB1_7"); if (Temp) DBB1|=(1<<7); Skip_S1(3, "Zero"); Get_S1 (4, Minutes_Units, "Minutes (Units)"); Get_SB ( Temp, "DBB2_0"); if (Temp) DBB2|=(1<<0); Skip_S1(3, "Zero"); Skip_S1(4, "BG5"); Get_SB ( Temp, "DBB2_1"); if (Temp) DBB2|=(1<<1); Skip_S1(3, "Zero"); Skip_SB( "BGF0"); Get_S1 (3, Minutes_Tens, "Minutes (Tens)"); Get_SB ( Temp, "DBB2_2"); if (Temp) DBB2|=(1<<2); Skip_S1(3, "Zero"); Skip_S1(4, "BG6"); Get_SB ( Temp, "DBB2_3"); if (Temp) DBB2|=(1<<3); Skip_S1(3, "Zero"); Get_S1 (4, Hours_Units, "Hours (Units)"); Get_SB ( Temp, "DBB2_4"); if (Temp) DBB2|=(1<<4); Skip_S1(3, "Zero"); Skip_S1(4, "BG7"); Get_SB ( Temp, "DBB2_5"); if (Temp) DBB2|=(1<<5); Skip_S1(3, "Zero"); Skip_SB( "BGF2"); Skip_SB( "BGF1"); Get_S1 (2, Hours_Tens, "Hours (Tens)"); Get_SB ( Temp, "DBB2_6"); if (Temp) DBB2|=(1<<6); Skip_S1(3, "Zero"); Skip_S1(4, "BG8"); Get_SB ( Temp, "DBB2_7"); if (Temp) DBB2|=(1<<7); Skip_S1(3, "Zero"); BS_End(); } else { BS_Begin(); Skip_S1(4, "BG1"); Get_S1 (4, Frames_Units, "Frames (Units)"); Skip_S1(4, "BG2"); Skip_SB( "CF - Color fame"); Get_SB ( DropFrame, "DP - Drop frame"); Get_S1 (2, Frames_Tens, "Frames (Tens)"); Skip_S1(4, "BG3"); Get_S1 (4, Seconds_Units, "Seconds (Units)"); Skip_S1(4, "BG4"); Skip_SB( "FM - Frame Mark"); Get_S1 (3, Seconds_Tens, "Seconds (Tens)"); Skip_S1(4, "BG5"); Get_S1 (4, Minutes_Units, "Minutes (Units)"); Skip_S1(4, "BG6"); Skip_SB( "BGF0"); Get_S1 (3, Minutes_Tens, "Minutes (Tens)"); Skip_S1(4, "BG7"); Get_S1 (4, Hours_Units, "Hours (Units)"); Skip_S1(4, "BG8"); Skip_SB( "BGF2"); Skip_SB( "BGF1"); Get_S1 (2, Hours_Tens, "Hours (Tens)"); BS_End(); } int64u TimeCode_Ms=(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 + (Gxf_FrameRate(FrameRate_Code)==0?0:((Frames_Tens*10+Frames_Units)*1000/float64_int32s(Gxf_FrameRate(FrameRate_Code)/(Gxf_FrameRate(FrameRate_Code)>30?2:1))))); if (TimeCode_FirstFrame.empty()) { TimeCode_FirstFrame+=('0'+Hours_Tens); TimeCode_FirstFrame+=('0'+Hours_Units); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Minutes_Tens); TimeCode_FirstFrame+=('0'+Minutes_Units); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Seconds_Tens); TimeCode_FirstFrame+=('0'+Seconds_Units); TimeCode_FirstFrame+=DropFrame?';':':'; TimeCode_FirstFrame+=('0'+Frames_Tens); TimeCode_FirstFrame+=('0'+Frames_Units); } #if MEDIAINFO_TRACE string TimeCode; TimeCode+=('0'+Hours_Tens); TimeCode+=('0'+Hours_Units); TimeCode+=':'; TimeCode+=('0'+Minutes_Tens); TimeCode+=('0'+Minutes_Units); TimeCode+=':'; TimeCode+=('0'+Seconds_Tens); TimeCode+=('0'+Seconds_Units); TimeCode+=DropFrame?';':':'; TimeCode+=('0'+Frames_Tens); TimeCode+=('0'+Frames_Units); Element_Info1(TimeCode.c_str()); #endif //MEDIAINFO_TRACE if (IsAtc) { Settings=Atc_PayloadType(DBB1); Element_Info1(__T("PayloadType=")+Ztring().From_UTF8(Settings.c_str())); Element_Info1(__T("VitcLineSelect=")+Ztring::ToZtring(DBB2&0x1F)); } Element_End0(); FILLING_BEGIN(); if (TimeCode_FirstFrame_ms==(int64u)-1) TimeCode_FirstFrame_ms=TimeCode_Ms; FILLING_END(); } else Skip_XX(8, "Junk"); } //bitmap, already parsed Element_Offset+=64; FILLING_BEGIN(); if (!Status[IsFilled] && TimeCode_FirstFrame_ms!=(int64u)-1) { Accept(); Fill(); if (Config->ParseSpeed<1.0) Finish(); } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Gxf_TimeCode::Read_Buffer_Continue() { if (Element_Size!=4096) { Skip_XX(Element_Size, "Data"); return; } //Reading bitmap first (validity of first byte is at the end) Element_Offset=504*8; Element_Begin1("Validity"); int8u Validity[504]; BS_Begin_LE(); //is Little Endian for (size_t Pos=0; Pos<504; Pos++) { bool Validity_Bit; Get_TB (Validity_Bit, "Bit"); Validity[Pos]=Validity_Bit?1:0; } BS_End_LE(); Skip_B1( "Pad"); Element_End0(); //Parsing Element_Offset=0; for (size_t Pos=0; Pos<504; Pos++) { if (Validity[Pos]) { Element_Begin1("TimeCode"); int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens; bool DropFrame; BS_Begin(); Skip_S1(4, "BG1"); Get_S1 (4, Frames_Units, "Frames (Units)"); Skip_S1(4, "BG2"); Skip_SB( "CF - Color fame"); Get_SB ( DropFrame, "DP - Drop frame"); Get_S1 (2, Frames_Tens, "Frames (Tens)"); Skip_S1(4, "BG3"); Get_S1 (4, Seconds_Units, "Seconds (Units)"); Skip_S1(4, "BG4"); Skip_SB( "FM - Frame Mark"); Get_S1 (3, Seconds_Tens, "Seconds (Tens)"); Skip_S1(4, "BG5"); Get_S1 (4, Minutes_Units, "Minutes (Units)"); Skip_S1(4, "BG6"); Skip_SB( "BGF0"); Get_S1 (3, Minutes_Tens, "Minutes (Tens)"); Skip_S1(4, "BG7"); Get_S1 (4, Hours_Units, "Hours (Units)"); Skip_S1(4, "BG8"); Skip_SB( "BGF2"); Skip_SB( "BGF1"); Get_S1 (2, Hours_Tens, "Hours (Tens)"); int64u TimeCode_Ms=(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 + (Gxf_FrameRate(FrameRate_Code)==0?0:((Frames_Tens*10+Frames_Units)*1000/float64_int32s(Gxf_FrameRate(FrameRate_Code)/(Gxf_FrameRate(FrameRate_Code)>30?2:1))))); Element_Info1(Ztring().Duration_From_Milliseconds(TimeCode_Ms)); BS_End(); Element_End0(); FILLING_BEGIN(); if (TimeCode_First==(int64u)-1) TimeCode_First=TimeCode_Ms; FILLING_END(); } else Skip_XX(8, "Junk"); } //bitmap, already parsed Element_Offset+=64; FILLING_BEGIN(); if (!Status[IsFilled] && TimeCode_First!=(int64u)-1) { Accept(); Fill(); if (MediaInfoLib::Config.ParseSpeed_Get()<1) Finish(); } 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_Aac::ALSSpecificConfig() { //Not in spec, but something weird in the example I have int32u Junk; while (Data_BS_Remain()) { Peek_S4(32, Junk); if (Junk!=0x414C5300) { Skip_SB( "Unknown"); } else break; } if (Data_BS_Remain()==0) return; //There is a problem Element_Begin1("ALSSpecificConfig"); bool chan_config,chan_sort,crc_enabled,aux_data_enabled; int32u samp_freq, samples; int16u channels,frame_length; int8u ra_flag,random_access, file_type; Skip_BS(32,"als_id"); Get_BS (32, samp_freq, "samp_freq"); Get_BS (32, samples, "samples"); Get_S2 (16, channels, "channels"); Param_Info2(channels+1, " channel(s)"); Get_S1 (3, file_type, "file_type"); Skip_S1(3,"resolution"); Skip_SB("floating"); Skip_SB("msb_first"); Get_S2 (16,frame_length,"frame_length"); Get_S1 (8,random_access,"random_access"); Get_S1 (2,ra_flag,"ra_flag"); Skip_SB("adapt_order"); Skip_S1(2,"coef_table"); Skip_SB("long_term_prediction"); Skip_S2(10,"max_order"); Skip_S1(2,"block_switching"); Skip_SB("bgmc_mode"); Skip_SB("sb_part"); Skip_SB("joint_stereo"); Skip_SB("mc_coding"); Get_SB (chan_config,"chan_config"); Get_SB (chan_sort,"chan_sort"); Get_SB (crc_enabled,"crc_enabled"); Skip_SB("RLSLMS"); Skip_BS(5,"(reserved)"); Get_SB (aux_data_enabled,"aux_data_enabled"); if (chan_config) Skip_S2(16,"chan_config_info"); if (chan_sort) { int16u ChBits=(int16u)ceil(log((double)(channels+1))/log((double)2)); for (int8u c=0; c<=channels; c++) Skip_BS(ChBits, "chan_pos[c]"); } if(Data_BS_Remain()%8) Skip_S1(Data_BS_Remain()%8, "byte_align"); BS_End(); int32u header_size,trailer_size; Get_B4(header_size, "header_size"); Get_B4(trailer_size, "trailer_size"); #ifdef MEDIAINFO_RIFF_YES if (file_type==1) //WAVE file { Element_Begin1("orig_header"); File_Riff MI; Open_Buffer_Init(&MI); Open_Buffer_Continue(&MI, Buffer+Buffer_Offset+(size_t)Element_Offset, header_size); Element_Offset+=header_size; File__Analyze::Finish(&MI); //No merge of data, only for trace information, because this is the data about the decoded stream, not the encoded stream Element_End0(); } else #endif //MEDIAINFO_RIFF_YES Skip_XX(header_size, "orig_header[]"); Skip_XX(trailer_size, "orig_trailer[]"); if (crc_enabled) Skip_B4( "crc"); if ((ra_flag == 2) && (random_access > 0)) for (int32u f=0; f<((samples-1)/(frame_length+1))+1; f++) Skip_B4( "ra_unit_size[f]"); if (aux_data_enabled) { int32u aux_size; Get_B4(aux_size, "aux_size"); Skip_XX(aux_size, "aux_data[]"); } Element_End0(); BS_Begin(); //To be in sync with other objectTypes FILLING_BEGIN(); //Filling File__Analyze::Stream_Prepare(Stream_Audio); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, channels+1); //Forcing default confignuration (something weird in the example I have) channelConfiguration=0; sampling_frequency_index=(int8u)-1; sampling_frequency=samp_freq; FILLING_END(); }
//--------------------------------------------------------------------------- void File_Cdp::ccsvcinfo_section() { //Parsing int8u svc_count; Element_Begin1("ccsvcinfo_section"); Skip_B1( "ccsvcinfo_id"); BS_Begin(); Skip_SB( "reserved"); Skip_SB( "svc_info_start"); Skip_SB( "svc_info_change"); Skip_SB( "svc_info_complete"); Get_S1 (4, svc_count, "svc_count"); BS_End(); for (int8u Pos=0; Pos<svc_count; Pos++) { Element_Begin1("svc"); bool csn_size; BS_Begin(); Skip_SB( "reserved"); Get_SB ( csn_size, "csn_size"); if (csn_size) { Skip_SB( "reserved"); Skip_S1(5, "caption_service_number"); } else Skip_S1(6, "caption_service_number"); BS_End(); //svc_data_byte - caption_service_descriptor Element_Begin1("service"); string language; int8u caption_service_number=0; bool digital_cc, line21_field=false; Get_String(3, language, "language"); BS_Begin(); Get_SB (digital_cc, "digital_cc"); Skip_SB( "reserved"); if (digital_cc) //line21 Get_S1 (6, caption_service_number, "caption_service_number"); else { Skip_S1(5, "reserved"); Get_SB ( line21_field, "line21_field"); //Coherency test if (line21_field && svc_count==1) line21_field=false; // Wrong info in the descriptor? } Skip_SB( "easy_reader"); Skip_SB( "wide_aspect_ratio"); Skip_S2(14, "reserved"); BS_End(); Element_End0(); Element_End0(); FILLING_BEGIN(); #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (digital_cc) { #if defined(MEDIAINFO_EIA708_YES) ServiceDescriptors->ServiceDescriptors708[caption_service_number].language=language; #endif } else { #if defined(MEDIAINFO_EIA708_YES) ServiceDescriptors->ServiceDescriptors608[line21_field?1:0].language=language; #endif } #endif //Stream creation int8u Parser_Pos; if (digital_cc) //line21 Parser_Pos = 2; else Parser_Pos= (line21_field ? 1 : 0); //cc_type 2 and 3 are for the same text if (Streams[Parser_Pos]==NULL) CreateStream(Parser_Pos); FILLING_END(); } Element_End0(); }
//--------------------------------------------------------------------------- void File_Aac::MPEG_1_2_SpecificConfig() { Element_Begin1("MPEG_1_2_SpecificConfig"); Skip_SB( "extension"); Element_End0(); }
void File_Exr::channels() { //Parsing std::vector<Exr_channel> ChannelList; while (Element_Offset+1<Element_Size) { Element_Begin1("channel"); //Name size_t name_Size=0; while (Element_Offset+name_Size<Element_Size) { if (!Buffer[Buffer_Offset+(size_t)Element_Offset+name_Size]) break; name_Size++; } name_End++; Exr_channel Channel; Get_String(name_Size, Channel.name, "name"); Element_Info1(Channel.name); Element_Offset++; //Null byte Skip_L4( "pixel type"); Skip_L1( "pLinear"); Skip_B3( "reserved"); Get_L4 (Channel.xSampling, "xSampling"); Get_L4 (Channel.ySampling, "ySampling"); ChannelList.push_back(Channel); Element_End0(); } //Color space /* TODO: not finished bool HasAlpha=false; string ColorSpace, ChromaSubsampling; if (!ChannelList.empty() && ChannelList[0].name=="A") { HasAlpha=true; ChannelList.erase(ChannelList.begin()); } if (ChannelList.size()==1 && ChannelList[0].name=="Y") { ColorSpace="Y"; } else if (ChannelList.size()==3 && ChannelList[0].name=="V" && ChannelList[1].name=="U" && ChannelList[2].name=="Y") { ColorSpace="YUV"; //Chroma subsampling if (ChannelList[2].xSampling==1 && ChannelList[2].xSampling==1 && ChannelList[0].xSampling==ChannelList[1].xSampling && ChannelList[0].ySampling==ChannelList[1].ySampling) { switch (ChannelList[0].xSampling) { case 1 : switch (ChannelList[0].ySampling) { case 1 : ChromaSubsampling="4:4:4"; break; default: ; } break; case 2 : switch (ChannelList[0].ySampling) { case 1 : ChromaSubsampling="4:2:2"; break; case 2 : ChromaSubsampling="4:2:0"; break; default: ; } break; case 4 : switch (ChannelList[0].ySampling) { case 1 : ChromaSubsampling="4:1:1"; break; case 2 : ChromaSubsampling="4:1:0"; break; default: ; } break; default: ; } } } else if (ChannelList.size()==3 && ChannelList[0].name=="B" && ChannelList[1].name=="G" && ChannelList[2].name=="R") { ColorSpace="RGB"; } else { //TODO } if (!ColorSpace.empty()) { if (HasAlpha) ColorSpace+='A'; Fill(StreamKind_Last, 0, "ColorSpace", ColorSpace); } if (!ChromaSubsampling.empty()) Fill(StreamKind_Last, 0, "ChromaSubsampling", ChromaSubsampling); */ }
//--------------------------------------------------------------------------- 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; } }
//--------------------------------------------------------------------------- void File_Ptx::Read_Buffer_Continue() { if (File_Offset || Buffer_Offset) { if (Buffer_Size) Reject(); //Problem return; } //Parsing ZtringList Names; Ztring LibraryName, LibraryVersion, Format, Directory; int32u LibraryName_Length, LibraryVersion_Length, LibraryRelease_Length, Format_Length, Platform_Length, Info_Count, Names_Count, Info_Length, Name_Length, FileName_Count, Directory_Length; int32u Opaque2_Length, Audio_Count; int16u Opaque1_Length; Element_Begin1("Header"); Skip_B1( "Magic"); Skip_Local(16, "Magic"); Skip_L2( "0x0500"); Skip_L1( "Unknown [1]"); Skip_L1( "0x5A [1]"); Skip_L2( "0x0001"); Skip_L2( "0x0004"); Skip_L2( "0x0000 [1]"); Skip_L4( "Unknown [2]"); Skip_L2( "0x035A"); Skip_L2( "0x6400"); Skip_L2( "0x0000 [1]"); Skip_L2( "0x0300"); Skip_L2( "0x0000 [1]"); Get_L4 (LibraryName_Length, "WritingLibrary name length"); Get_UTF8(LibraryName_Length, LibraryName, "Library name"); Skip_L4( "0x00000003"); Skip_L4( "Library version, major"); Skip_L4( "Library version, minor"); Skip_L4( "Library version, revision"); Get_L4 (LibraryVersion_Length, "Library version length"); Get_UTF8(LibraryVersion_Length, LibraryVersion, "Library version"); Skip_L1( "0x01"); Get_L4 (LibraryRelease_Length, "Library release length"); Skip_UTF8(LibraryRelease_Length, "Library release"); Skip_L1( "0x00 [1]"); Get_L4 (Format_Length, "Format length"); Get_UTF8(Format_Length, Format, "Format"); if (Format!=__T("Pro Tools Session File")) { Element_End(); Reject(); return; } Skip_L2( "0x0006"); Get_L4 (Platform_Length, "Platform length"); Skip_UTF8(Platform_Length, "Platform"); Skip_L4( "0x00000000"); Skip_L2( "0x5A05"); Get_L2 (Opaque1_Length, "Info list, Opaque length"); //0x0006 (10.2-) or 0x0008 (10.3+) Skip_L4( "Unknown [3]"); Skip_L4( "0x00002067"); Skip_L2( "0x0000 [1]"); Skip_L2( "0x0000 (once) or 0x002A"); Skip_L2( "0x0000 [1]"); Skip_L2( "Unknown [4]"); Skip_L4( "Unknown [5]"); Skip_L4( "Unknown [6]"); Element_End(); Element_Begin1("Info list"); Get_L4 (Info_Count, "Info count"); if (4*Info_Count>Element_Size) { Element_End(); Reject(); return; } for (int32u Pos=0; Pos<Info_Count; Pos++) { Element_Begin1("Info"); Get_L4 (Info_Length, "Info length"); if (Info_Length) { Info_UTF8(Info_Length, Info, "Name"); Element_Info1(Info); } Element_End(); } Element_End(); Element_Begin1("Unknown"); Skip_L4( "0x00000000"); Element_Begin1("Names list 1"); Get_L4 (Names_Count, "Names count minus 1"); if (4*Names_Count>Element_Size) { Element_End(); Reject(); return; } for (int16u Pos=0; Pos<1+Names_Count; Pos++) { Element_Begin1("Name"); Get_L4 (Name_Length, "Name length"); if (Name_Length) { Info_UTF8(Name_Length, Name, "Name"); Element_Name(Name); } Element_End(); } Element_End(); Skip_L4( "0x00000000"); Skip_L4( "0x00000000 or 0x0000002A"); Skip_L4( "Unknown [7]"); Skip_L4( "Unknown [8]"); Element_Begin1("Names list 2"); Get_L4 (Names_Count, "Names count"); if (4*Names_Count>Element_Size) { Element_End(); Reject(); return; } for (int16u Pos=0; Pos<Names_Count; Pos++) { Element_Begin1("Name"); Get_L4 (Name_Length, "Name length"); if (Name_Length) { Info_UTF8(Name_Length, Name, "Name"); Element_Name(Name); } Element_End(); } Element_End(); Skip_L4( "0x00000000"); Skip_L4( "0x0000002A [1]"); Skip_L4( "Unknown [9]"); Skip_L4( "Unknown [10]"); Skip_L4( "0x00000000"); Skip_L1( "0x00 or 0x01 [2]"); Skip_L1( "0x01"); Skip_L1( "0x00 or 0x01 or 0x02"); Skip_L1( "0x00 [2]"); Skip_L1( "0x01"); Skip_L1( "0x00 (once) or 0x01"); Skip_L1( "0x00 or 0x01 (once)"); Skip_L1( "0x00 or 0x01 (once) or 0x5A"); if (Opaque1_Length<6) { if (Opaque1_Length) Skip_XX(Opaque1_Length, "Opaque1"); } else { Skip_L4( "Opaque1 - Unknown [1]"); Skip_L2( "Opaque1 - Unknown [2]"); if (Opaque1_Length<8) { if (Opaque1_Length-6) Skip_XX(Opaque1_Length-6, "Opaque1 - Unknown [3]"); } else { Skip_L2( "Opaque1 - 0x0000"); if (Opaque1_Length>8) Skip_XX(Opaque1_Length-8, "Opaque1 - Unknown [3]"); } } Skip_L2( "0x2519"); Skip_L2( "0x0001"); Skip_L4( "0x00000000 or B5112287"); Skip_L4( "0x00000000 or 4037F9DC"); Skip_L4( "0x00000001 [1]"); Skip_L2( "0x0003"); Element_End(); Get_L4 (Audio_Count, "Audio count"); if (111*Audio_Count>Element_Size) { Reject(); return; } Element_Begin1("Audio tracks list 1"); for (int16u Pos=0; Pos<Audio_Count; Pos++) { Element_Begin1("Name"); Skip_L2( "0x0000 [New]"); Get_L4 (Name_Length, "(Same 1/2/3) Name length"); Info_UTF8(Name_Length, Name, "(Same 1/2/3) Name"); Skip_L2( "(Same 1/2/3) 0x0000 "); Skip_L4( "(Same 1/2/3) 0x00000000"); Skip_L4( "(Same 1/2/3) 0x0000002A"); Skip_L4( "(Same 1/2/3) Unknown"); Skip_L4( "(Same 1/2/3) Unknown"); Info_L3(Number, "(Same 1/2/3) Ordered number"); Element_Info1(Number); Element_Info1(Name); Element_End(); if (Name==__T("Lf")) //Exception? Typo? Name=__T("Lfe"); Name.MakeLowerCase(); Names.push_back(Name); } Element_End(); Element_Begin1("Audio tracks list 2"); for (int16u Pos=0; Pos<Audio_Count; Pos++) { Element_Begin1("Name"); int32u Size; Skip_L3( "(Same 2/3) 0x00025A [1]"); Get_L4 (Size, "(Same 2/3) Size"); Skip_L4( "(Same 2/3) 0x0000251A"); Get_L4 (Name_Length, "(Same 1/2/3) Name length"); Info_UTF8(Name_Length, Name, "(Same 1/2/3) Name"); Skip_L2( "(Same 1/2/3) 0x0000 "); Skip_L4( "(Same 1/2/3) 0x00000000"); Skip_L4( "(Same 1/2/3) 0x0000002A"); Skip_L4( "(Same 1/2/3) Unknown"); Skip_L4( "(Same 1/2/3) Unknown"); Info_L3(Number, "(Same 1/2/3) Ordered number"); Element_Info1(Number); Skip_L2( "(Same 2/3) 0x0000"); Element_Info1(Name); if (Name_Length+31!=Size) { Element_End(); Element_End(); Reject(); return; } Element_End(); } Element_End(); Get_L4 (Audio_Count, "Audio count"); if (4*Audio_Count>Element_Size) { Reject(); return; } Element_Begin1("Audio tracks list 3"); for (int16u Pos=0; Pos<Audio_Count; Pos++) { Element_Begin1("Name"); int32u Size; Skip_L3( "(Same 2/3) 0x00025A [2]"); Get_L4 (Size, "(Same 2/3) Size"); if (Size>0x10000) { Element_End(); Element_End(); Reject(); return; } Skip_L4( "(Same 2/3) 0x0000251A"); Get_L4 (Name_Length, "(Same 1/2/3) Name length"); Info_UTF8(Name_Length, Name, "(Same 1/2/3) Name"); Skip_L2( "(Same 1/2/3) 0x0000 "); Skip_L4( "(Same 1/2/3) 0x00000000"); Skip_L4( "(Same 1/2/3) 0x0000002A"); Skip_L4( "(Same 1/2/3) Unknown"); Skip_L4( "(Same 1/2/3) Unknown"); Info_L3(Number, "(Same 1/2/3) Ordered number"); Element_Info1(Number); Skip_L2( "(Same 2/3) 0x0000"); Element_Info1(Name); if (Name_Length+31!=Size) { Element_End(); Element_End(); Reject(); return; } Element_End(); } Element_End(); Skip_L2( "0x0000 [4]"); Skip_L2( "0x0018"); Skip_L4( "0x00000001 [2]"); Skip_L2( "0x0018"); Skip_L4( "0x00000001 [2]"); Skip_L2( "0x0001 [3]"); Skip_L3( "0x00095A"); Get_L4 (Opaque2_Length, "Opaque2 length"); Skip_XX(Opaque2_Length, "Opaque2"); Skip_L1( "0x5A [2]"); Skip_L2( "0x0003 (10.0) or 0x0004 (10.2+)"); Get_L4 (Opaque2_Length, "Opaque3 length"); //0x0012 (10.0) or 0x0016 (10.2+) if (Opaque2_Length<0x12) Skip_XX(Opaque2_Length, "Opaque3"); else { Skip_L4( "Opaque3 - 0x06002026"); Skip_L4( "Opaque3 - 0x00000000 [1]"); Skip_L2( "Opaque3 - 0x0000"); Skip_L4( "Opaque3 - Unknown [1]"); Skip_L4( "Opaque3 - Unknown [2]"); if (Opaque2_Length<0x16) { if (Opaque2_Length-0x12) Skip_XX(Opaque2_Length-0x12, "Opaque3 - Unknown [3]"); } else { Skip_L4( "Opaque3 - 0x00000000 [2]"); if (Opaque2_Length>0x16) Skip_XX(Opaque2_Length-0x16, "Opaque3 - Unknown [4]"); } } Skip_L3( "0x00025A [3]"); Get_L4 (Opaque2_Length, "0x00000015 (Opaque4 length?) or something else"); if (Opaque2_Length==0x00000015) { Skip_L4( "0x075A2032"); Skip_L4( "0x00000C00"); Skip_L4( "0x01204200"); Skip_L4( "0x00000000 or 0x01000000"); Skip_L4( "Unknown [13]"); Skip_L1( "0x00 [3]"); Skip_L3( "0x00025A [4]"); Skip_L4( "Unknown [14]"); } Skip_L4( "Unknown [15]"); Skip_L4( "0x015A0000"); Skip_L4( "Unknown [16]"); Skip_L4( "Unknown [17]"); Skip_L4( "0x01000000"); Get_L4 (FileName_Count, "File name count"); if (13*FileName_Count>Element_Size) { Reject(); return; } Get_L4 (Directory_Length, "Directory length"); Get_UTF8(Directory_Length, Directory, "Directory"); Skip_L4( "0x00000000 [11]"); Element_Begin1("File names"); vector<int8u> Roles; vector<Ztring> FileNames; vector<Ztring> FileNamesLowerCase; vector<int32u> Purposes; for (int32u Pos=0; Pos<FileName_Count; Pos++) { Ztring FileName; int32u FileName_Length, Purpose; int8u Role; // Element_Begin1("File names"); Get_L1 (Role, "role? (0x02 for WAV files)"); Skip_L4( "Ordered number except WAV files and -1"); Get_L4 (FileName_Length, "File Name length"); Get_UTF8(FileName_Length, FileName, "File Name"); Element_Name(FileName); Get_C4 (Purpose, "Purpose (e.g. EVAW for .wav files)"); //Found 1 .wav file without "EWAV". Element_End(); Roles.push_back(Role); FileNames.push_back(FileName); FileName.MakeLowerCase(); FileNamesLowerCase.push_back(FileName); Purposes.push_back(Purpose); } Element_End(); Skip_XX(Element_Size-Element_Offset, "Unknown"); FILLING_BEGIN(); Accept("Ptx"); //Could be Ptf (former format but not supported, so we don't care currently) Fill("Ptx"); Fill(Stream_General, 0, General_Format, "Pro Tools Session"); Fill(Stream_General, 0, General_Format_Version, "Version 10"); Fill(Stream_General, 0, General_Encoded_Library_Name, LibraryName); Fill(Stream_General, 0, General_Encoded_Library_Version, LibraryVersion); // Role==2 + Purpose==EWAV + listed if (Names.size()>1 || FileNames.size()==1) { size_t Pos_Offset=0; for (int32u Pos=0; Pos<FileName_Count; Pos++) { if (Roles[Pos]==0x02 && Purposes[Pos]==0x45564157 //"EWAV" && Pos-Pos_Offset<Names.size() && FileNames[Pos]!=__T("1 kHz @ -20dB.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("1k@0vu -20.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos].find(__T(".1Khz.wav"))==string::npos //Exception? && FileNames[Pos].find(__T("_1KTONE_"))==string::npos //Exception? && FileNamesLowerCase[Pos].find(Names[Pos-Pos_Offset]+__T(".wav"))!=string::npos && FileNamesLowerCase[Pos].find(Names[Pos-Pos_Offset]+__T(".wav"))+Names[Pos-Pos_Offset].size()+4==FileNames[Pos].size()) { sequence* Sequence=new sequence; Sequence->StreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } else if (!ReferenceFiles->Sequences_Size()) Pos_Offset++; } if (Names.size()!=ReferenceFiles->Sequences_Size()) ReferenceFiles->Clear(); //Failed to detect correctly } // Role==2 + listed if (!ReferenceFiles->Sequences_Size() && (Names.size()>1 || FileNames.size()==1)) { size_t Pos_Offset=0; for (int32u Pos=0; Pos<FileName_Count; Pos++) { if (Roles[Pos]==0x02 && Pos-Pos_Offset<Names.size() && FileNames[Pos]!=__T("1 kHz @ -20dB.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("1k@0vu -20.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos].find(__T(".1Khz.wav"))==string::npos //Exception? && FileNames[Pos].find(__T("_1KTONE_"))==string::npos) //Exception? { Ztring FileName=FileNames[Pos]; Ztring Name=Names[Pos-Pos_Offset]; FileName.MakeLowerCase(); Name.MakeLowerCase(); if (FileName.find(Name)==0 || FileName.find(Name+__T(".wav"))+5==Name.size()) { sequence* Sequence=new sequence; Sequence->StreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } else if (!ReferenceFiles->Sequences_Size()) Pos_Offset++; } else if (!ReferenceFiles->Sequences_Size()) Pos_Offset++; } if (Names.size()!=ReferenceFiles->Sequences_Size()) ReferenceFiles->Clear(); //Failed to detect correctly } // Role==2 + Purpose==EWAV + listed, special case with specific file names if (!ReferenceFiles->Sequences_Size() && (Names.size()>1 || FileNames.size()==1)) { for (int32u Pos=0; Pos<FileName_Count; Pos++) { if (Roles[Pos]==0x02 && Purposes[Pos]==0x45564157 //"EWAV" && FileNames[Pos]!=__T("1 kHz @ -20dB.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("1k@0vu -20.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos].find(__T(".1Khz.wav"))==string::npos //Exception? && FileNames[Pos].find(__T("_1KTONE_"))==string::npos) //Exception? { for (int32u Pos2=0; Pos2<Names.size(); Pos2++) if (FileNamesLowerCase[Pos].find(Names[Pos2])==0) { sequence* Sequence=new sequence; Sequence->StreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); break; } } } } // Role==2 + Purpose==EWAV if (!ReferenceFiles->Sequences_Size()) { for (int32u Pos=0; Pos<FileName_Count; Pos++) { if (Roles[Pos]==0x02 && Purposes[Pos]==0x45564157 //"EWAV" && FileNames[Pos]!=__T("1 kHz @ -20dB.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("1k@0vu -20.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos].find(__T(".1Khz.wav"))==string::npos //Exception? && FileNames[Pos].find(__T("_1KTONE_"))==string::npos) //Exception? { sequence* Sequence=new sequence; Sequence->StreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } } } // Role==2 if (!ReferenceFiles->Sequences_Size()) { for (int32u Pos=0; Pos<FileName_Count; Pos++) { if (Roles[Pos]==0x02 && FileNames[Pos]!=__T("1 kHz @ -20dB.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos]!=__T("1k@0vu -20.wav") //Exception? && FileNames[Pos]!=__T("*****@*****.**") //Exception? && FileNames[Pos].find(__T(".1Khz.wav"))==string::npos //Exception? && FileNames[Pos].find(__T("_1KTONE_"))==string::npos) //Exception? { sequence* Sequence=new sequence; Sequence->StreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } } } FILLING_END(); }
bool File_Zip::central_directory() { if (Element_Offset+46>Element_Size) //central_directory up to relative offset of local header included return false; //Not enough data //Retrieving complete local_file_header size int16u file_name_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+28); int16u extra_field_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+30); int16u file_comment_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+32); if (Element_Offset+46+file_name_length+extra_field_length+file_comment_length>Element_Size) //central_directory_structure all included return false; //Not enough data int16u general_purpose_bit_flag; bool efs; int16u version_made_by,compression_method; //Parsing Element_Begin1("Central directory"); Skip_C4("central file header signature"); Get_L2 (version_made_by,"version made by");Param_Info1((version_made_by>>8)>20?"unused":Zip_made_by[version_made_by>>8]); Skip_L2("version needed to extract"); Get_L2 (general_purpose_bit_flag,"general purpose bit flag"); Skip_Flags(general_purpose_bit_flag, 0, "encrypted file"); Skip_Flags(general_purpose_bit_flag, 1, "8K sliding dictionary"); Skip_Flags(general_purpose_bit_flag, 2, "3 Shannon-Fano trees"); Skip_Flags(general_purpose_bit_flag, 3, "data descriptor"); Skip_Flags(general_purpose_bit_flag, 4, "Reserved for use with method 8"); Skip_Flags(general_purpose_bit_flag, 4, "file is compressed patched data"); Skip_Flags(general_purpose_bit_flag, 4, "Strong encryption"); //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused"); //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused"); //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused"); //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused"); Get_Flags (general_purpose_bit_flag, 11, efs, "Language encoding flag (EFS)"); //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE for enhanced compression"); //~ Skip_Flags(general_purpose_bit_flag, 4, ""); //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE"); //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE"); Get_L2 (compression_method,"compression method"); Param_Info1C((compression_method<20), Zip_compression_method[compression_method]); Param_Info1C((compression_method==97||compression_method==98), Zip_compression_method[compression_method-97+20]); Skip_L2("last mod file time"); Skip_L2("last mod file date"); Skip_L4("crc-32"); Skip_L4("compressed size"); Skip_L4("uncompressed size"); Skip_L2("file name length"); Skip_L2("extra field length"); Skip_L2("file comment length"); Skip_L2("disk number start"); Skip_L2("internal file attributes"); Skip_L4("external file attributes"); Skip_L4("relative offset of local header"); if(efs) { Skip_UTF8(file_name_length,"file name"); Skip_UTF8(extra_field_length,"extra field"); Skip_UTF8(file_comment_length,"file comment"); } else { Skip_Local(file_name_length,"file name"); Skip_Local(extra_field_length,"extra field"); Skip_Local(file_comment_length,"file comment"); } Element_End0(); return true; }
//--------------------------------------------------------------------------- void File_AfdBarData::bar_data() { //Parsing Element_Begin1("bar_data"); bool top_bar_flag, bottom_bar_flag, left_bar_flag, right_bar_flag; BS_Begin(); Get_SB (top_bar_flag, "top_bar_flag"); Get_SB (bottom_bar_flag, "bottom_bar_flag"); Get_SB (left_bar_flag, "left_bar_flag"); Get_SB (right_bar_flag, "right_bar_flag"); if (Format==Format_S2016_3) { Mark_0_NoTrustError(); Mark_0_NoTrustError(); Mark_0_NoTrustError(); Mark_0_NoTrustError(); } else { Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); } if (top_bar_flag) { Mark_1(); Mark_1(); Get_S2 (14, line_number_end_of_top_bar, "line_number_end_of_top_bar"); } if (bottom_bar_flag) { Mark_1(); Mark_1(); Get_S2 (14, line_number_start_of_bottom_bar, "line_number_start_of_bottom_bar"); } if (left_bar_flag) { Mark_1(); Mark_1(); Get_S2 (14, pixel_number_end_of_left_bar, "pixel_number_end_of_left_bar"); } if (right_bar_flag) { Mark_1(); Mark_1(); Get_S2 (14, pixel_number_start_of_right_bar, "pixel_number_start_of_right_bar"); } if (!top_bar_flag && !bottom_bar_flag && !left_bar_flag && !right_bar_flag) { Mark_1_NoTrustError(); Mark_1_NoTrustError(); Skip_S2(14, "reserved"); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Skip_S2(14, "reserved"); } BS_End(); Element_End0(); if (Format==Format_A53_4_DTG1) { BS_Begin(); Mark_1(); Mark_1(); Mark_1(); Mark_1(); Mark_1(); Mark_1(); Mark_1(); Mark_1(); BS_End(); if (Element_Size-Element_Offset) Skip_XX(Element_Size-Element_Offset, "additional_bar_data"); } }
//--------------------------------------------------------------------------- void File_Umf::Read_Buffer_Continue() { //Parsing int32u Tracks, Segments; Element_Begin1("Payload description"); Skip_L4( "Total length of the UMF data"); Skip_L4( "Version of this file"); Get_L4 (Tracks, "Number of tracks in the material"); Skip_L4( "Offset to track description section"); Skip_L4( "Size of the track description section"); Get_L4 (Segments, "Number of segments"); Skip_L4( "Offset to media description section"); Skip_L4( "Size of the media description section"); Skip_L4( "Offset to the user data section"); Skip_L4( "Size of the user data section"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Element_End0(); Element_Begin1("Material description"); Skip_L4( "Attributes"); Skip_L4( "Maximum length of the material in fields"); Skip_L4( "Minimum length of the material in fields"); Skip_L4( "Material mark in value in fields"); Skip_L4( "Material mark out value in fields"); Skip_L4( "Time code at mark in value"); Skip_L4( "Time code at mark out value"); Skip_L4( "last modified time (Most)"); Skip_L4( "last modified time (Least)"); Skip_L4( "creation time (Most)"); Skip_L4( "creation time (Least)"); Skip_L2( "Reserved"); Skip_L2( "Reserved"); Skip_L2( "Number of audio tracks"); Skip_L2( "Number of time code tracks"); Skip_L2( "Reserved"); Skip_L2( "Number of MPEG-1, MPEG-2, and MPEG-2 HD video tracks"); Element_End0(); for (int32u Pos=0; Pos<Tracks; Pos++) { Element_Begin1("Track description"); Skip_C1( "Track information - Track type"); Skip_C1( "Track information - Track logical number"); Skip_L2( "Number of segments on this track"); Element_End0(); if (Element_Offset>=Element_Size) break; } for (int32u Pos=0; Pos<Segments; Pos++) { Element_Begin1("Media description"); int32u Type; int16u Length; Get_L2 (Length, "Length of this media description"); int64u End=Element_Offset+Length-2; Skip_C1( "Track information - Track type"); Skip_C1( "Track information - Track logical number"); Skip_L2( "Media Sequence number"); Skip_L2( "Reserved"); Skip_L4( "Number of fields in segment"); Skip_L4( "Reserved"); Skip_L4( "Mark in value for the media file in fields"); Skip_L4( "Mark out value for the media file in fields"); Skip_Local(88, "Source device media file name"); Get_L4 (Type, "Type of media track"); Skip_L4( "Sampling rates for this track"); Skip_L4( "Size of sample for audio and time codes"); Skip_L4( "Reserved"); switch (Type) { case 0x00000004 : case 0x00000007 : case 0x00000009 : //MPEG-Video { #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX int32u P, B; #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX Skip_L4( "Color difference format"); Skip_L4( "GoP structure"); Skip_L4( "Frame/field structure"); Skip_L4( "Target I-pictures per GoP"); #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX Get_L4 (P, "Target P-pictures per I-picture"); Get_L4 (B, "Target B-pictures per P-picture or I-picture"); #else //MEDIAINFO_SEEK || MEDIAINFO_DEMUX Skip_L4( "Target P-pictures per I-picture"); Skip_L4( "Target B-pictures per P-picture or I-picture"); #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX Skip_L4( "MPEG video attributes"); Skip_L4( "Reserved"); #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX GopSize=(1+P)*(1+B); #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX } break; case 0x00000003 : //TimeCode Skip_L4( "Time code attributes"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); break; case 0x00000002 : //Audio //Skip_LF8( "Level at which to play this segment"); //Skip_LF8( "Level at which to terminate this segment"); Skip_L8( "Level at which to play this segment"); Skip_L8( "Level at which to terminate this segment"); Skip_L4( "Number of fields over which to ramp up"); Skip_L4( "Number of fields over which to ramp down"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); break; case 0x00000005 : //DV25 case 0x00000006 : //DV50 Skip_L4( "Attributes"); //With Aspect ratio Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX GopSize=1; #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX break; default : Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); } if (Element_Offset<End) Skip_XX(End-Element_Offset, "Unknown"); Element_End0(); if (Element_Offset>=Element_Size) break; } while (Element_Offset<Element_Size) { Element_Begin1("User data"); int32u Length; Get_L4 (Length, "The length of this user data record"); Skip_L4( "Position on the material time line"); Skip_L2( "Track associated with the user data record"); Skip_L2( "Media Sequence Numbe"); Skip_L4( "User-defined key"); if (Length>18) Skip_XX(Length-18, "User data"); else Skip_XX(Element_Size-Element_Offset-2, "User data"); Skip_L1( "NULL byte"); Skip_L1( "Reserved byte"); Element_End0(); } }
//--------------------------------------------------------------------------- void File_Jpeg::SIZ() { //Parsing vector<float> SamplingFactors; vector<int8u> BitDepths; int8u SamplingFactors_Max=0; int32u Xsiz, Ysiz; int16u Count; Skip_B2( "Rsiz - Capability of the codestream"); Get_B4 (Xsiz, "Xsiz - Image size X"); Get_B4 (Ysiz, "Ysiz - Image size Y"); Skip_B4( "XOsiz - Image offset X"); Skip_B4( "YOsiz - Image offset Y"); Skip_B4( "tileW - Size of tile W"); Skip_B4( "tileH - Size of tile H"); Skip_B4( "XTOsiz - Upper-left tile offset X"); Skip_B4( "YTOsiz - Upper-left tile offset Y"); Get_B2 (Count, "Components and initialize related arrays"); for (int16u Pos=0; Pos<Count; Pos++) { Element_Begin1("Initialize related array"); int8u BitDepth, compSubsX, compSubsY; BS_Begin(); Skip_SB( "Signed"); Get_S1 (7, BitDepth, "BitDepth"); Param_Info1(1+BitDepth); Element_Info1(1+BitDepth); BS_End(); Get_B1 ( compSubsX, "compSubsX"); Element_Info1(compSubsX); Get_B1 ( compSubsY, "compSubsY"); Element_Info1(compSubsY); Element_End0(); //Filling list of HiVi if (compSubsX) { SamplingFactors.push_back(((float)compSubsY)/compSubsX); if (((float)compSubsY)/compSubsX>SamplingFactors_Max) SamplingFactors_Max=(int8u)((float)compSubsY)/compSubsX; } if (BitDepths.empty() || BitDepth!=BitDepths[0]) BitDepths.push_back(BitDepth); } FILLING_BEGIN_PRECISE(); if (Frame_Count==0 && Field_Count==0) { Accept("JPEG 2000"); if (Count_Get(StreamKind_Last)==0) Stream_Prepare(StreamKind_Last); Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "JPEG 2000"); Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), "JPEG 2000"); if (StreamKind_Last==Stream_Image) Fill(Stream_Image, 0, Image_Codec_String, "JPEG 2000", Unlimited, true, true); //To Avoid automatic filling Fill(StreamKind_Last, 0, StreamKind_Last==Stream_Image?(size_t)Image_Width:(size_t)Video_Width, Xsiz); Fill(StreamKind_Last, 0, StreamKind_Last==Stream_Image?(size_t)Image_Height:(size_t)Video_Height, Ysiz*(Interlaced?2:1)); //If image is from interlaced content, must multiply height by 2 if (BitDepths.size()==1) Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_BitDepth), 1+BitDepths[0]); //Chroma subsampling if (SamplingFactors_Max) while (SamplingFactors_Max<4) { for (size_t Pos=0; Pos<SamplingFactors.size(); Pos++) SamplingFactors[Pos]*=2; SamplingFactors_Max*=2; } while (SamplingFactors.size()<3) SamplingFactors.push_back(0); Ztring ChromaSubsampling; for (size_t Pos=0; Pos<SamplingFactors.size(); Pos++) ChromaSubsampling+=Ztring::ToZtring(SamplingFactors[Pos], 0)+__T(':'); if (!ChromaSubsampling.empty()) { ChromaSubsampling.resize(ChromaSubsampling.size()-1); Fill(StreamKind_Last, 0, "ChromaSubsampling", ChromaSubsampling); } } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Dpx::GenericSectionHeader_Dpx() { Element_Name("Generic section header"); //Parsing Element_Begin1("File information"); std::string Version, CreationDate, Creator, Project, Copyright; int32u Size_Header, Size_Total, Size_Generic, Size_Industry, Size_User; Skip_String(4, "Magic number"); Get_X4 (Size_Header, "Offset to image data"); Get_String(8, Version, "Version number of header format"); Get_X4 (Size_Total, "Total image file size"); Skip_B4( "Ditto Key"); Get_X4 (Size_Generic, "Generic section header length"); Get_X4 (Size_Industry, "Industry specific header length"); Get_X4 (Size_User, "User-defined header length"); Skip_UTF8 (100, "FileName"); Get_String (24, CreationDate, "Creation Date"); Get_String (100, Creator, "Creator"); Get_String (200, Project, "Project"); Get_String (200, Copyright, "Right to use or copyright statement"); Skip_B4( "Encryption key"); Skip_XX(104, "Reserved for future use"); Element_End0(); Element_Begin1("Image information"); int32u Width, Height, PAR_H, PAR_V; int16u ImageElements; Info_B2(ImageOrientation, "Image orientation");Param_Info1(DPX_Orientation[ImageOrientation]); Get_X2 (ImageElements, "Number of image elements"); if (ImageElements>8) ImageElements=8; Get_X4 (Width, "Pixels per line"); Get_X4 (Height, "Lines per image element"); for(int16u ImageElement=0; ImageElement<ImageElements; ImageElement++) GenericSectionHeader_Dpx_ImageElement(); if (ImageElements!=8) Skip_XX((8-ImageElements)*72, "Padding"); Skip_XX(52, "Reserved for future use"); Element_End0(); Element_Begin1("Image source information"); Skip_B4( "X Offset"); Skip_B4( "Y Offset"); Skip_BF4( "X center"); Skip_BF4( "Y center"); Skip_B4( "X original size"); Skip_B4( "Y original size"); Skip_UTF8(100, "Source image filename"); Skip_UTF8(24, "Source image date/time"); Skip_UTF8(32, "Input device name"); Skip_UTF8(32, "Input device serial number"); Element_Begin1("Border validity"); Skip_B2( "XL border"); Skip_B2( "XR border"); Skip_B2( "YT border"); Skip_B2( "YB border"); Element_End0(); Get_X4 (PAR_H, "Pixel ratio : horizontal"); Get_X4 (PAR_V, "Pixel ratio : vertical"); Element_Begin1("Additional source image information"); Skip_BF4( "X scanned size"); Skip_BF4( "Y scanned size"); Skip_XX(20, "Reserved for future use"); Element_End0(); FILLING_BEGIN(); //Coherency tests if (File_Offset+Buffer_Offset+Size_Total!=Config->File_Current_Size) Size_Total=(int32u)(Config->File_Current_Size-(File_Offset+Buffer_Offset)); //The total size is bigger than the real size if (Size_Generic==(int32u)-1) Size_Generic=(int32u)Element_Size; if (Size_Industry==(int32u)-1) Size_Industry=0; if (Size_User==(int32u)-1) Size_User=0; if (Size_Generic+Size_Industry+Size_User>Size_Header || Size_Header>Size_Total) { Reject(); return; } //Filling sizes Sizes.push_back(Size_Header); Sizes.push_back(Size_Industry); Sizes.push_back(Size_User); Sizes.push_back(Size_Header-(Size_Generic+Size_Industry+Size_User)); //Size of padding Sizes.push_back(Size_Total-Size_Header); //Size of image //Filling meta if (Frame_Count==0) { Fill(Stream_General, 0, General_Encoded_Date, DPX_DateTime2Iso(CreationDate)); Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", DPX_DateTime2Iso(CreationDate)); Fill(Stream_General, 0, General_Encoded_Library, Creator); Fill(StreamKind_Last, StreamPos_Last, "Encoded_Library", Creator); Fill(Stream_General, 0, "Project", Project); //ToDo: map to a MediaInfo field (which one?) Fill(Stream_General, 0, General_Copyright, Copyright); Fill(StreamKind_Last, StreamPos_Last, "Format", "DPX"); if (Version.size()>2 && Version[0]=='V' && Version[1]>='0' && Version[2]<='9') Version.insert(1, "ersion "); Fill(StreamKind_Last, StreamPos_Last, "Format_Version", Version); Fill(Stream_General, 0, General_Format_Version, Version); Fill(StreamKind_Last, StreamPos_Last, "Width", Width); Fill(StreamKind_Last, StreamPos_Last, "Height", Height); if (PAR_V && PAR_H!=(int32u)-1 && PAR_V!=(int32u)-1) Fill(StreamKind_Last, StreamPos_Last, "PixelAspectRatio", ((float)PAR_H)/PAR_V); else Fill(StreamKind_Last, StreamPos_Last, "PixelAspectRatio", (float)1, 3); } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Mpc::FileHeader_Parse() { //Parsing Element_Begin1("SV7 header"); Ztring Encoder; int32u FrameCount; int16u TitleGain, AlbumGain; int8u Profile, Link, SampleFreq, EncoderVersion; Skip_C3( "Signature"); BS_Begin(); Skip_S1(4, "PNS"); Skip_S1(4, "Version"); BS_End(); Get_L4 (FrameCount, "FrameCount"); Skip_L2( "MaxLevel"); BS_Begin(); Get_S1 (4, Profile, "Profile"); Param_Info1(Mpc_Profile[Profile]); Get_S1 (2, Link, "Link"); Param_Info1(Mpc_Link[Link]); Get_S1 (2, SampleFreq, "SampleFreq"); Param_Info1(Mpc_SampleFreq[SampleFreq]); Skip_SB( "IntensityStereo"); Skip_SB( "MidSideStereo"); Skip_S1(6, "MaxBand"); BS_End(); Skip_L2( "TitlePeak"); Get_L2 (TitleGain, "TitleGain"); Param_Info3(((float32)((int16s)TitleGain))/1000, " dB", 2); Skip_L2( "AlbumPeak"); Get_L2 (AlbumGain, "AlbumGain"); Param_Info3(((float32)((int16s)TitleGain))/1000, " dB", 2); BS_Begin(); Skip_S2(16, "unused"); Skip_S1( 4, "LastFrameLength (part 1)"); Skip_SB( "FastSeekingSafe"); Skip_S1( 3, "unused"); Skip_SB( "TrueGapless"); Skip_S1( 7, "LastFrameLength (part 2)"); BS_End(); Get_L1 (EncoderVersion, "EncoderVersion"); Encoder.From_Number(((float)EncoderVersion)/100, 2); if (EncoderVersion%10==0); else if (EncoderVersion%2==0) Encoder+=__T(" Beta"); else if (EncoderVersion%2==1) Encoder+=__T(" Alpha"); Param_Info1(Encoder); Element_End0(); FILLING_BEGIN(); File__Tags_Helper::Accept("Musepack SV7"); File__Tags_Helper::Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_SamplingRate, Mpc_SampleFreq[SampleFreq]); Fill(Stream_Audio, 0, Audio_SamplingCount, FrameCount*1152); Fill(Stream_Audio, 0, Audio_Format, "Musepack SV7"); Fill(Stream_Audio, 0, Audio_Codec, "SV7"); Fill(Stream_Audio, 0, Audio_Codec_Settings, Mpc_Profile[Profile]); Fill(Stream_Audio, 0, Audio_Encoded_Library, Encoder); Fill(Stream_Audio, 0, Audio_BitDepth, 16); //MPC support only 16 bits Fill(Stream_Audio, 0, Audio_Duration, ((int64u)FrameCount)*1152*1000/Mpc_SampleFreq[SampleFreq]); if (FrameCount) Fill(Stream_Audio, 0, Audio_BitRate, (File_Size-25)*8*Mpc_SampleFreq[SampleFreq]/FrameCount/1152); //No more need data File__Tags_Helper::Finish("Musepack SV7"); FILLING_END(); }
void File_OtherText::Read_Buffer_Continue() { if (Buffer_Size<0x200) { Element_WaitForMoreData(); return; } Element_Offset=File_Size-(File_Offset+Buffer_Offset); Ztring Format, FormatMore, Codec; Ztring File; ZtringList Lines; //Feed File and Lines File.From_UTF8((const char*)Buffer, Buffer_Size>65536?65536:Buffer_Size); if (File.empty()) File.From_Local((const char*)Buffer, Buffer_Size>65536?65536:Buffer_Size); // Trying from local code page if (File.size()<0x100) { File.From_Unicode((wchar_t*)Buffer, 0, Buffer_Size/sizeof(wchar_t)); //Unicode with BOM //TODO: Order of bytes (big or Little endian) if (File.size()<0x100) { Reject("Other text"); return; } } if (File.size()>0x1000) File.resize(0x1000); //Do not work on too big File.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive); File.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive); Lines.Separator_Set(0, __T("\n")); Lines.Write(File); Lines.resize(0x20); if (Lines[0]==__T("[Script Info]") && (Lines.Find(__T("ScriptType: v4.00"))!=Error || Lines.Find(__T("Script Type: V4.00"))!=Error) && Lines.Find(__T("[V4 Styles]"))!=Error ) { Format=__T("SSA"); FormatMore=__T("SubStation Alpha"); Codec=__T("SSA"); } else if (Lines[0]==__T("[Script Info]") && (Lines.Find(__T("ScriptType: v4.00+"))!=Error || Lines.Find(__T("Script Type: V4.00+"))!=Error) && Lines.Find(__T("[V4+ Styles]"))!=Error ) { Format=__T("ASS"); FormatMore=__T("Advanced SubStation Alpha"); Codec=__T("ASS"); } else if (Lines[0].size()>24 && Lines[0][ 0]==__T('0') && Lines[0][ 1]==__T('0') && Lines[0][ 2]==__T(':') && Lines[0][ 5]==__T(':') && Lines[0][ 8]==__T(':') && Lines[0][11]==__T(' ') && Lines[0][12]==__T('0') && Lines[0][13]==__T('0') && Lines[0][14]==__T(':') && Lines[0][17]==__T(':') && Lines[0][20]==__T(':') && Lines[0][23]==__T(' ') ) { Format=__T("Adobe encore DVD"); Codec=__T("Adobe"); } else if (Lines[0].size()==11 && Lines[0][0]==__T('-') && Lines[0][1]==__T('-') && Lines[0][2]==__T('>') && Lines[0][3]==__T('>') && Lines[0][4]==__T(' ') && Lines[0][5]==__T('0') && Lines[1].empty()!=true ) { Format=__T("AQTitle"); Codec=__T("AQTitle"); } else if (Lines[0].size()>28 && Lines[0][ 0]==__T('0') && Lines[0][ 1]==__T('0') && Lines[0][ 2]==__T(':') && Lines[0][ 5]==__T(':') && Lines[0][ 8]==__T(':') && Lines[0][11]==__T(' ') && Lines[0][12]==__T(',') && Lines[0][13]==__T(' ') && Lines[0][14]==__T('0') && Lines[0][15]==__T('0') && Lines[0][16]==__T(':') && Lines[0][19]==__T(':') && Lines[0][22]==__T(':') && Lines[0][25]==__T(' ') && Lines[0][16]==__T(',') && Lines[0][27]==__T(' ') ) { Format=__T("Captions 32"); Codec=__T("Caption 32"); } else if (Lines[0].size()==23 && Lines[0]==__T("*Timecode type: PAL/EBU") && Lines[1].empty() && Lines[2].size()==23 && Lines[2][ 0]==__T('0') && Lines[2][ 1]==__T('0') && Lines[2][ 2]==__T(':') && Lines[2][ 5]==__T(':') && Lines[2][ 8]==__T(':') && Lines[2][11]==__T(' ') && Lines[2][12]==__T('0') && Lines[2][13]==__T('0') && Lines[2][14]==__T(':') && Lines[2][17]==__T(':') && Lines[2][20]==__T(':') && Lines[2].size()>0 ) { Format=__T("Captions Inc"); Codec=__T("Captions inc"); } else if (Lines[0].size()>1 && Lines[0][0]==__T('*') && Lines.Find(__T("** Caption Number 1"))!=Error ) { Format=__T("Cheeta"); } else if (Lines[0].size()>10 && Lines[0][0]==__T('~') && Lines[0][1]==__T('C') && Lines[0][2]==__T('P') && Lines[0][3]==__T('C') && Lines[0][9]==__T('~') && Lines[1][ 0]==__T('0') && Lines[1][ 1]==__T('0') && Lines[1][ 2]==__T(':') && Lines[1][ 5]==__T(':') && Lines[1][ 8]==__T(':') ) { Format=__T("CPC Captioning"); Codec=__T("CPC Captioning"); } else if (Lines[0].find(__T("<SAMI>"))==0) { Format=__T("SAMI"); } else return; if (Format.empty()) return; Accept("Other text"); if (!IsSub) { Fill(Stream_General, 0, General_Format, Format); Fill(Stream_General, 0, General_Format_Info, FormatMore, true); } Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, Text_Format, Format); Fill(Stream_Text, 0, Text_Codec, Codec); //No more need data Element_Begin1(Format); Element_End0(); Finish("Other text"); }
//--------------------------------------------------------------------------- void File_Cdp::ccdata_section() { //Parsing int8u cc_count; Element_Begin1("ccdata_section"); Skip_B1( "ccdata_id"); BS_Begin(); Mark_1(); Mark_1(); Mark_1(); Get_S1 (5, cc_count, "cc_count"); BS_End(); for (int8u Pos=0; Pos<cc_count; Pos++) { Element_Begin1("cc"); int8u cc_type; bool cc_valid; BS_Begin(); Mark_1(); Mark_1(); Mark_1(); Mark_1(); Mark_1(); Get_SB ( cc_valid, "cc_valid"); Get_S1 (2, cc_type, "cc_type"); Param_Info1(Cdp_cc_type(cc_type)); BS_End(); if (cc_valid) { Element_Begin1("cc_data"); //Calculating the parser position int8u Parser_Pos=cc_type==3?2:cc_type; //cc_type 2 and 3 are for the same text //Parsing #if MEDIAINFO_DEMUX Element_Code=Parser_Pos; #endif //MEDIAINFO_DEMUX if (Streams[Parser_Pos]==NULL) Streams[Parser_Pos]=new stream; if (Streams[Parser_Pos]->Parser==NULL) { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (cc_type<2) { #if defined(MEDIAINFO_EIA608_YES) Streams[Parser_Pos]->Parser=new File_Eia608(); ((File_Eia608*)Streams[Parser_Pos]->Parser)->cc_type=cc_type; #else //defined(MEDIAINFO_EIA608_YES) Streams[Parser_Pos]->Parser=new File__Analyze(); #endif //defined(MEDIAINFO_EIA608_YES) } else { #if defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser=new File_Eia708(); #else //defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser=new File__Analyze(); #endif //defined(MEDIAINFO_EIA708_YES) } #else //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser=new File__Analyze(); #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Open_Buffer_Init(Streams[Parser_Pos]->Parser); } Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream); if (!Streams[Parser_Pos]->Parser->Status[IsFinished]) { if (Streams[Parser_Pos]->Parser->PTS_DTS_Needed) { Streams[Parser_Pos]->Parser->FrameInfo.PCR=FrameInfo.PCR; Streams[Parser_Pos]->Parser->FrameInfo.PTS=FrameInfo.PTS; Streams[Parser_Pos]->Parser->FrameInfo.DTS=FrameInfo.DTS; } if (Parser_Pos==2) { #if defined(MEDIAINFO_EIA708_YES) ((File_Eia708*)Streams[2]->Parser)->cc_type=cc_type; if (AspectRatio) ((File_Eia708*)Streams[2]->Parser)->AspectRatio=AspectRatio; #endif //defined(MEDIAINFO_EIA708_YES) } Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 2); Element_Offset+=2; //Filled if (!Streams[Parser_Pos]->IsFilled && Streams[Parser_Pos]->Parser->Status[IsFilled]) { if (Count_Get(Stream_General)==0) Accept("CDP"); Streams_Count++; if (Streams_Count==3) Fill("CDP"); Streams[Parser_Pos]->IsFilled=true; } } else Skip_XX(2, "Data"); Element_End0(); } else Skip_XX(2, "Junk"); Element_End0(); } Element_End0(); Frame_Count++; Frame_Count_InThisBlock++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; }
//--------------------------------------------------------------------------- void File_ProRes::Read_Buffer_Continue() { //Parsing int32u Name, creatorID; int16u hdrSize, version, frameWidth, frameHeight; int8u chrominance_factor, frame_type, primaries, transf_func, colorMatrix, alpha_info; bool IsOk=true, luma, chroma; Element_Begin1("Header"); Skip_B4( "Size"); Get_C4 (Name, "Name"); Element_End(); Element_Begin1("Frame header"); Get_B2 (hdrSize, "hdrSize"); Get_B2 (version, "version"); Get_C4 (creatorID, "creatorID"); Get_B2 (frameWidth, "frameWidth"); Get_B2 (frameHeight, "frameHeight"); BS_Begin(); Get_S1 (2, chrominance_factor, "chrominance factor"); Param_Info1(ProRes_chrominance_factor(chrominance_factor)); Skip_S1(2, "reserved"); Get_S1 (2, frame_type, "frame type"); Param_Info1(ProRes_frame_type_ScanType(frame_type)); Param_Info1(ProRes_frame_type_ScanOrder(frame_type)); Skip_S1(2, "reserved"); BS_End(); Skip_B1( "reserved"); Get_B1 (primaries, "primaries"); Param_Info1(Mpegv_colour_primaries(primaries)); Get_B1 (transf_func, "transf_func"); Param_Info1(Mpegv_transfer_characteristics(transf_func)); Get_B1 (colorMatrix, "colorMatrix"); Param_Info1(Mpegv_matrix_coefficients(colorMatrix)); BS_Begin(); Skip_S1(4, "src_pix_fmt"); Get_S1 (4, alpha_info, "alpha_info"); BS_End(); Skip_B1( "reserved"); BS_Begin(); Skip_S1(6, "reserved"); Get_SB (luma, "custom luma quant matrix present"); Get_SB (chroma, "custom chroma quant matrix present"); BS_End(); if (luma) Skip_XX(64, "QMatLuma"); if (chroma) Skip_XX(64, "QMatChroma"); Element_End(); if (Name==0x69637066 && Element_Offset!=8+(int32u)hdrSize) // Coherency test icpf IsOk=false; if (Name==0x69637066) // icpf { for (int8u PictureNumber=0; PictureNumber<(frame_type?2:1); PictureNumber++) { Element_Begin1("Picture layout"); int16u total_slices; vector<int16u> slices_size; Element_Begin1("Picture header"); int64u pic_hdr_End, pic_data_End; int32u pic_data_size; int8u pic_hdr_size; Get_B1 (pic_hdr_size, "pic_hdr_size"); if (pic_hdr_size<64) { Trusted_IsNot("pic_hdr_size"); Element_End(); Element_End(); return; } pic_hdr_End=Element_Offset+pic_hdr_size/8-((pic_hdr_size%8)?0:1); Get_B4 (pic_data_size, "pic_data_size"); if (pic_data_size<8) { Trusted_IsNot("pic_data_size"); Element_End(); Element_End(); return; } pic_data_End=Element_Offset+pic_data_size-5; Get_B2 (total_slices, "total_slices"); BS_Begin(); Skip_S1(4, "slice_width_factor"); Skip_S1(4, "slice_height_factor"); BS_End(); if (Element_Offset<pic_hdr_End) Skip_XX(pic_hdr_End-Element_Offset, "Unknown"); Element_End(); Element_Begin1("Slice index table"); for (int16u Pos=0; Pos<total_slices; Pos++) { int16u slice_size; Get_B2 (slice_size, "slice_size"); slices_size.push_back(slice_size); } Element_End(); for (int16u Pos=0; Pos<slices_size.size(); Pos++) { Skip_XX(slices_size[Pos], "slice data"); } if (Element_Offset<pic_data_End) Skip_XX(pic_data_End-Element_Offset, "Unknown"); Element_End(); } } bool IsZeroes=true; for (size_t Pos=(size_t)Element_Offset; Pos<(size_t)Element_Size; Pos++) if (Buffer[Buffer_Offset+Pos]) { IsZeroes=false; break; } Skip_XX(Element_Size-Element_Offset, IsZeroes?"Zeroes":"Unknown"); FILLING_BEGIN(); if (IsOk && (Name==0x69637066 || Name==0x70727266) && !Status[IsAccepted]) //icpf (all but RAW) & prrf (RAW) { Accept(); Fill(); Fill(Stream_Video, 0, Video_Format_Version, __T("Version ")+Ztring::ToZtring(version)); Fill(Stream_Video, 0, Video_Width, frameWidth); Fill(Stream_Video, 0, Video_Height, frameHeight); Fill(Stream_Video, 0, Video_Encoded_Library, ProRes_creatorID(creatorID)); Fill(Stream_Video, 0, Video_ChromaSubsampling, ProRes_chrominance_factor(chrominance_factor)); Fill(Stream_Video, 0, Video_ScanType, ProRes_frame_type_ScanType(frame_type)); Fill(Stream_Video, 0, Video_ScanOrder, ProRes_frame_type_ScanOrder(frame_type)); Fill(Stream_Video, 0, Video_colour_description_present, "Yes"); if (primaries || transf_func || colorMatrix) //Some streams have all 0 when it means unknwon, instead of assigned 2 for unknown { Fill(Stream_Video, 0, Video_colour_primaries, Mpegv_colour_primaries(primaries)); Fill(Stream_Video, 0, Video_transfer_characteristics, Mpegv_transfer_characteristics(transf_func)); Fill(Stream_Video, 0, Video_matrix_coefficients, Mpegv_matrix_coefficients(colorMatrix)); if (colorMatrix!=2) Fill(Stream_Video, 0, Video_ColorSpace, Ztring().From_UTF8(Mpegv_matrix_coefficients_ColorSpace(colorMatrix))+(alpha_info?__T("A"):__T("")), true); } else if (chrominance_factor==2) Fill(Stream_Video, 0, Video_ColorSpace, alpha_info?"YUVA":"YUV", Unlimited, true, true); //We are sure it is YUV as there is subsampling Finish(); } FILLING_ELSE(); if (!Status[IsAccepted]) Reject(); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Dpx::GenericSectionHeader_Cineon() { Element_Name("Generic section header"); //Parsing Element_Begin1("File information"); Ztring CreationDate, CreationTime; string Version; int32u Size_Header, Size_Total, Size_Generic, Size_Industry, Size_User; Skip_B4( "Magic number"); Get_X4 (Size_Header, "Offset to image data"); Get_X4 (Size_Generic, "Generic section header length"); Get_X4 (Size_Industry, "Industry specific header length"); Get_X4 (Size_User, "User-defined header length"); Get_X4 (Size_Total, "Total image file size"); Get_String(8, Version, "Version number of header format"); Skip_UTF8 (100, "FileName"); Get_UTF8 (12, CreationDate, "Creation Date"); Get_UTF8 (12, CreationTime, "Creation Time"); Skip_XX(36, "Reserved for future use"); Element_End0(); Element_Begin1("Image information"); int8u ImageElements; Info_B1(ImageOrientation, "Image orientation"); Param_Info1(DPX_Orientation[ImageOrientation>8?8:ImageOrientation]); Get_B1 (ImageElements, "Number of image elements"); Skip_B2( "Unused"); if (ImageElements>8) ImageElements=8; for(int8u ImageElement=0; ImageElement<ImageElements; ImageElement++) GenericSectionHeader_Cineon_ImageElement(); if (ImageElements!=8) Skip_XX((8-ImageElements)*28, "Padding"); Skip_BF4( "White point - x"); Skip_BF4( "White point - y"); Skip_BF4( "Red primary chromaticity - x"); Skip_BF4( "Red primary chromaticity - u"); Skip_BF4( "Green primary chromaticity - x"); Skip_BF4( "Green primary chromaticity - y"); Skip_BF4( "Blue primary chromaticity - x"); Skip_BF4( "Blue primary chromaticity - y"); Skip_UTF8(200, "Label text"); Skip_XX(28, "Reserved for future use"); Element_End0(); Element_Begin1("Image Data Format Information"); Skip_B1( "Data interleave"); Skip_B1( "Packing"); Skip_B1( "Data signed or unsigned"); Skip_B1( "Image sense"); Skip_B4( "End of line padding"); Skip_B4( "End of channel padding"); Skip_XX(20, "Reserved for future use"); Element_Begin1("Image Origination Information"); Skip_B4( "X offset"); Skip_B4( "Y offset"); Skip_UTF8 (100, "FileName"); Get_UTF8 (12, CreationDate, "Creation Date"); Get_UTF8 (12, CreationTime, "Creation Time"); Skip_UTF8(64, "Input device"); Skip_UTF8(32, "Input device model number"); Skip_UTF8(32, "Input device serial number"); Skip_BF4( "X input device pitch"); Skip_BF4( "Y input device pitch"); Skip_BF4( "Image gamma of capture device"); Skip_XX(40, "Reserved for future use"); Element_End0(); FILLING_BEGIN(); //Coherency tests if (File_Offset+Buffer_Offset+Size_Total>=Config->File_Current_Size) Size_Total=(int32u)(Config->File_Current_Size-(File_Offset+Buffer_Offset)); //The total size is bigger than the real size if (Size_Generic+Size_Industry+Size_User>Size_Header || Size_Header>Size_Total) { Reject(); return; } //Filling sizes Sizes.push_back(Size_Header); Sizes.push_back(Size_Industry); Sizes.push_back(Size_User); Sizes.push_back(Size_Header-(Size_Generic+Size_Industry+Size_User)); //Size of padding Sizes.push_back(Size_Total-Size_Header); //Size of image //Filling meta if (Frame_Count==0) { Fill(Stream_General, 0, General_Encoded_Date, CreationDate+__T(' ')+CreationTime); //ToDo: transform it in UTC Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", CreationDate+__T(' ')+CreationTime); //ToDo: transform it in UTC Fill(StreamKind_Last, StreamPos_Last, "Format", "Cineom"); if (Version.size()>2 && Version[0]=='V' && Version[1]>='0' && Version[2]<='9') Version.insert(1, "ersion "); Fill(StreamKind_Last, StreamPos_Last, "Format_Version", Version); Fill(Stream_General, 0, General_Format_Version, Version); } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Pdf::xref() { //Parsing Element_Begin1("Cross-Reference Table"); Element_Begin1("Cross-Reference Section"); string FirstLine; Skip_String(SizeOfLine(), "Object name"); Element_Begin1("Cross-Reference SubSection"); Get_String(SizeOfLine(), FirstLine, "Header"); size_t FirstLine_Space=FirstLine.find(' '); int32u Base=atoi((const char*)FirstLine.c_str()); int32u Count=0; if (FirstLine_Space!=string::npos) Count=atoi((const char*)FirstLine.c_str()+FirstLine_Space+1); if (0x10000+20*Count>Buffer_Size && File_Offset+Buffer_Size<File_Size) { // We wait for more data Buffer_Offset=0; Element_Offset=0; Element_DoNotShow(); Element_End0(); Element_End0(); Element_End0(); Element_WaitForMoreData(); return; } while (Element_Offset<Element_Size && (Buffer[Buffer_Offset+(size_t)Element_Offset]=='\r' || Buffer[Buffer_Offset+(size_t)Element_Offset]=='\n')) Element_Offset++; const int8u* Buffer_Temp=Buffer+Buffer_Offset+(size_t)Element_Offset+17; for (int32u Pos=0; Pos<Count; ++Pos) { if (*Buffer_Temp=='n') { char atoi_buf[18]; atoi_buf[17]=0; memcpy(atoi_buf,(const char*)Buffer_Temp-17,17); const int32u Offset=(int32u)atoi(atoi_buf); Objects[Base+Pos].Offset=Offset; //Offsets[Offset]=Base+Pos; Offsets.push_back(Offset); } Buffer_Temp+=20; if (Pos>100) Element_Offset+=20; else { Skip_String(18, "Entry"); Param_Info1(Base+Pos); Element_Offset+=2; //Skipping spaces at end and line return } } Element_End0(); Element_End0(); Element_End0(); if (File_Offset+Buffer_Offset>Offsets_Max) Offsets_Max=(int32u)(File_Offset+Buffer_Offset); }