//--------------------------------------------------------------------------- void File_Sdp::Header_Parse() { //Parsing int8u Length, FormatCode; Skip_B2( "Identifier"); Get_B1 (Length, "Length"); Get_B1 (FormatCode, "Format Code"); for (int8u Pos=0; Pos<5; Pos++) { FieldLines[Pos]=0; #if MEDIAINFO_TRACE Element_Begin1("Field/Line"); BS_Begin(); Info_SB( Field, "Field Number"); Info_S1(2, Reserved, "Reserved"); Info_S1(5, Line, "Line Number"); BS_End(); FieldLines[Pos]=((Field?1:0)<<7) |(Reserved<<5) | Line; //Removing field information ((Field?1:0)<<7) | if (FieldLines[Pos]) { Element_Info1(Field?2:1); Element_Info1(Line); } else Element_Info1("None"); Element_End0(); #else //MEDIAINFO_TRACE Get_B1(FieldLines[Pos], "Field/Line"); FieldLines[Pos]&=0x7F; //Removing field information #endif //MEDIAINFO_TRACE } Header_Fill_Size(3+Length); }
//--------------------------------------------------------------------------- void File_Aac::Read_Buffer_Continue_raw_data_block() { if (Frame_Count>Frame_Count_Valid) { Skip_XX(Element_Size, "Data"); return; //Parsing completely only the 1st frame } BS_Begin(); raw_data_block(); BS_End(); if (FrameIsAlwaysComplete && Element_Offset<Element_Size) Skip_XX(Element_Size-Element_Offset, "Unknown"); FILLING_BEGIN(); //Counting Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; Element_Info1(Ztring::ToZtring(Frame_Count)); //Filling if (!Status[IsAccepted]) File__Analyze::Accept(); if (Frame_Count>=Frame_Count_Valid) { //No more need data if (Mode==Mode_LATM) File__Analyze::Accept(); File__Analyze::Finish(); } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Flac::PICTURE() { //Parsing int32u PictureType, MimeType_Size, Description_Size, Data_Size; Ztring MimeType, Description; Get_B4 (PictureType, "Picture type"); Element_Info1(Id3v2_PictureType((int8u)PictureType)); Get_B4 (MimeType_Size, "MIME type size"); Get_Local(MimeType_Size, MimeType, "MIME type"); Get_B4 (Description_Size, "Description size"); Get_UTF8(Description_Size, Description, "Description"); Skip_B4( "Width"); Skip_B4( "Height"); Skip_B4( "Color depth"); Skip_B4( "Number of colors used"); Get_B4 (Data_Size, "Data size"); if (Element_Offset+Data_Size>Element_Size) return; //There is a problem std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset+Element_Offset)), Data_Size); std::string Data_Base64(Base64::encode(Data_Raw)); Skip_XX(Element_Size-Element_Offset, "Data"); //Filling Fill(Stream_General, 0, General_Cover, "Yes"); Fill(Stream_General, 0, General_Cover_Description, Description); Fill(Stream_General, 0, General_Cover_Type, Id3v2_PictureType((int8u)PictureType)); Fill(Stream_General, 0, General_Cover_Mime, MimeType); Fill(Stream_General, 0, General_Cover_Data, Data_Base64); }
//--------------------------------------------------------------------------- void File_Pdf::Object_Root() { Element_Info1("Document Catalog"); //Parsing string Key; Ztring Value; while (Element_Offset<Element_Size) { if (Get_Next(Key, Value)) { for (;;) { Get_Next(Key, Value); if (Key.empty()) break; else if (Key=="Metadata") { int32u ObjectNumber=Value.To_int32u(); Objects[ObjectNumber].Type=Type_Metadata; Objects[ObjectNumber].TopObject=Objects_Current->first; Objects[Objects_Current->first].Bottoms.push_back(ObjectNumber); Param_Info1(__T("Metadata is at offset 0x"+Ztring().From_Number(Objects[ObjectNumber].Offset))); } } continue; } if (Key.empty()) break; } }
//--------------------------------------------------------------------------- void File_Pdf::Object_Info() { Element_Info1("Info"); //Parsing string Key; Ztring Value; while (Element_Offset<Element_Size) { if (Get_Next(Key, Value)) { for (;;) { Get_Next(Key, Value); if (Key.empty()) break; } continue; } if (Key.empty()) break; } }
void File_Bmp::BitmapCoreHeader(int8u Version) { #if MEDIAINFO_TRACE switch (Version) { case 1 : Element_Info1("OS/2 1.x BITMAPCOREHEADER"); break; case 2 : Element_Info1("OS/2 2.x BITMAPCOREHEADER"); break; default: Element_Info1("OS/2 ? BITMAPCOREHEADER"); } #endif //MEDIAINFO_TRACE //Parsing int16u Width, Height, BitsPerPixel; Skip_L4( "Size"); Get_L2 (Width, "Width"); Get_L2 (Height, "Height"); Skip_L2( "Color planes"); Get_L2 (BitsPerPixel, "Bits per pixel"); FILLING_BEGIN(); if (BitsPerPixel<8) BitsPerPixel=8; //It is a palette Fill(Stream_Image, 0, Image_Width, Width); Fill(Stream_Image, 0, Image_Height, Height); Fill(Stream_Image, 0, Image_BitDepth, BitsPerPixel); Fill(Stream_Image, 0, Image_ColorSpace, "RGB"); FILLING_END(); if (Version>1) //V2 additional fields for information only { Skip_L4( "Compression"); Skip_L4( "ImageDataSize"); Skip_L4( "XResolution"); Skip_L4( "YResolution"); Skip_L4( "ColorsUsed"); Skip_L4( "ColorsImportant"); Skip_L2( "Units"); Skip_L2( "Reserved"); Skip_L2( "Recording"); Skip_L2( "Rendering"); Skip_L4( "Size1"); Skip_L4( "Size2"); Skip_L4( "ColorEncoding"); Skip_L4( "Identifier"); } }
//--------------------------------------------------------------------------- void File_Ibi::UInteger_Info() { switch (Element_Size) { case 1 : { Info_B1(Data, "Data"); Element_Info1(Data); return; } case 2 : { Info_B2(Data, "Data"); Element_Info1(Data); return; } case 3 : { Info_B3(Data, "Data"); Element_Info1(Data); return; } case 4 : { Info_B4(Data, "Data"); Element_Info1(Data); return; } case 5 : { Info_B5(Data, "Data"); Element_Info1(Data); return; } case 6 : { Info_B6(Data, "Data"); Element_Info1(Data); return; } case 7 : { Info_B7(Data, "Data"); Element_Info1(Data); return; } case 8 : { Info_B8(Data, "Data"); Element_Info1(Data); return; } case 16: { Info_B16(Data, "Data"); Element_Info1(Data); return; } default : Skip_XX(Element_Size, "Data"); } }
//--------------------------------------------------------------------------- int64u File_Ibi::UInteger_Get() { switch (Element_Size) { case 1 : { int8u Data; Get_B1 (Data, "Data"); Element_Info1(Data); return Data; } case 2 : { int16u Data; Get_B2 (Data, "Data"); Element_Info1(Data); return Data; } case 3 : { int32u Data; Get_B3 (Data, "Data"); Element_Info1(Data); return Data; } case 4 : { int32u Data; Get_B4 (Data, "Data"); Element_Info1(Data); return Data; } case 5 : { int64u Data; Get_B5 (Data, "Data"); Element_Info1(Data); return Data; } case 6 : { int64u Data; Get_B6 (Data, "Data"); Element_Info1(Data); return Data; } case 7 : { int64u Data; Get_B7 (Data, "Data"); Element_Info1(Data); return Data; } case 8 : { int64u Data; Get_B8 (Data, "Data"); Element_Info1(Data); return Data; } default : Skip_XX(Element_Size, "Data"); return 0; } }
//--------------------------------------------------------------------------- void File_Amr::Data_Parse() { Element_Info1(Frame_Number); //Parsing Skip_XX(Element_Size, "Data"); FILLING_BEGIN(); Frame_Number++; FrameTypes[FrameType]++; if (Frame_Number>=32) Finish("AMR"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Pdf::Data_Parse() { Element_Name("Object"); string Line; Get_String(SizeOfLine(), Line, "Header"); size_t Space_Pos=Line.find(' '); int32u ObjectNumber=Ztring().From_UTF8(Line.substr(0, Space_Pos)).To_int32u(); Element_Info1(ObjectNumber); objects::iterator Object=Objects.find(ObjectNumber); if (Object==Objects.end()) Skip_XX(Element_Size-Element_Offset, "Data"); else switch(Object->second.Type) { case Type_Root : Object_Root(); break; case Type_Info : Object_Info(); break; case Type_Metadata : Object_Metadata(); break; default : Skip_XX(Element_Size-Element_Offset, "Data"); } for (;;) { if (Objects_Current==Objects.end()) break; Objects_Current->second.BottomPos++; if (Objects_Current->second.BottomPos>=Objects_Current->second.Bottoms.size()) { if (Objects_Current->first==(int32u)-1) { //No more to parse Objects_Current=Objects.end(); Objects.clear(); Finish(); break; } Objects_Current=Objects.find(Objects_Current->second.TopObject); continue; } Objects_Current=Objects.find(Objects_Current->second.Bottoms[Objects_Current->second.BottomPos]); GoTo(Objects_Current->second.Offset); break; } }
//--------------------------------------------------------------------------- void File_Pdf::Object_Metadata() { Element_Info1("Metadata"); //Parsing string Key; Ztring Value; int32u Length=0; while (Element_Offset<Element_Size) { if (Get_Next(Key, Value)) { for (;;) { Get_Next(Key, Value); if (Key.empty()) break; else if (Key=="Length") { Length=Value.To_int32u(); } } continue; } if (Key.empty()) break; else if (Key=="stream") { //Removig end of lines if (Element_Offset<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset]=='\r') Element_Offset++; if (Element_Offset<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset]=='\n') Element_Offset++; #ifndef MEDIAINFO_TINYXML2_NO File_Xmp MI; Open_Buffer_Init(&MI, Length); Open_Buffer_Continue(&MI, Buffer+Buffer_Offset+(size_t)Element_Offset, Length); Skip_XX(Length, "Stream, Data"); Open_Buffer_Finalize(&MI); Merge(MI, Stream_General, 0, 0); #endif //MEDIAINFO_TINYXML2_NO } } }
//--------------------------------------------------------------------------- void File_Vc3::Data_Parse() { //Parsing if (Status[IsFilled]) { Skip_XX(Element_Size, "Data"); } else { Element_Info1(Frame_Count+1); HeaderPrefix(); CodingControlA(); Skip_XX(16, "Reserved"); ImageGeometry(); Skip_XX( 5, "Reserved"); CompressionID(); CodingControlB(); Skip_XX( 3, "Reserved"); TimeCode(); Skip_XX(640-Element_Offset, "ToDo"); Skip_XX(Element_Size-Element_Offset, "Data"); } FILLING_BEGIN(); Data_ToParse-=Buffer_Size-(size_t)Buffer_Offset; Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (FrameRate) { FrameInfo.PTS=FrameInfo.DTS+=float64_int64s(1000000000/FrameRate); FrameInfo.DUR=float64_int64s(1000000000/FrameRate); } else { FrameInfo.PTS=FrameInfo.DTS=FrameInfo.DUR=(int64u)-1; } if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid) { Fill("VC-3"); if (!IsSub && Config->ParseSpeed<1) Finish("VC-1"); } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Ibi::Ebml_DocType() { Element_Name("DocType"); //Parsing Ztring Data; Get_Local(Element_Size, Data, "Data"); Element_Info1(Data); //Filling FILLING_BEGIN(); if (Data==__T("MediaInfo Index")) Accept("Ibi"); else { Reject("Ibi"); return; } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Dirac::picture() { //Parsing Skip_XX(Element_Size, "Data"); FILLING_BEGIN(); //Counting if (File_Offset+Buffer_Offset+Element_Size==File_Size) Frame_Count_Valid=Frame_Count; //Finalize frames in case of there are less than Frame_Count_Valid frames //Name Element_Info1(Ztring::ToZtring(Frame_Count)); //Filling only if not already done Frame_Count++; Frame_Count_InThisBlock++; if (Frame_Count>=Frame_Count_Valid && Count_Get(Stream_Video)==0) { NextCode_Clear(); Accept("Dirac"); Finish("Dirac"); } 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_Bmp::BitmapInfoHeader(int8u Version) { #if MEDIAINFO_TRACE switch (Version) { case 1 : Element_Info1("BITMAPINFOHEADER"); break; case 2 : Element_Info1("BITMAPV2INFOHEADER"); break; case 3 : Element_Info1("BITMAPV3INFOHEADER"); break; case 4 : Element_Info1("BITMAPV4HEADER"); break; case 5 : Element_Info1("BITMAPV5HEADER"); break; default: Element_Info1("BITMAPV?HEADER"); } #endif //MEDIAINFO_TRACE //Parsing int32u Width, Height, CompressionMethod; int16u BitsPerPixel; Skip_L4( "Size"); Get_L4 (Width, "Width"); Get_L4 (Height, "Height"); Skip_L2( "Color planes"); Get_L2 (BitsPerPixel, "Bits per pixel"); Get_L4 (CompressionMethod, "Compression method"); Param_Info1(Bmp_CompressionMethod(CompressionMethod)); Skip_L4( "Image size"); Skip_L4( "Horizontal resolution"); Skip_L4( "Vertical resolution"); Skip_L4( "Number of colors in the color palette"); Skip_L4( "Number of important colors used"); FILLING_BEGIN(); if (BitsPerPixel<8) BitsPerPixel=8; //It is a palette Fill(Stream_Image, 0, Image_Width, Width); Fill(Stream_Image, 0, Image_Height, Height); Fill(Stream_Image, 0, Image_BitDepth, BitsPerPixel); Fill(Stream_Image, 0, Image_Format, Bmp_CompressionMethod(CompressionMethod)); Fill(Stream_Image, 0, Image_Codec, Bmp_CompressionMethod(CompressionMethod)); Fill(Stream_Image, 0, Image_ColorSpace, "RGB"); FILLING_END(); if (Version>1) { Skip_L4( "Red Channel bit mask"); Skip_L4( "Green Channel bit mask"); Skip_L4( "Blue Channel bit mask"); if (Version>2) { Skip_L4( "Alpha Channel bit mask"); if (Version>3) { Skip_L4( "Color Space endpoints"); Skip_L4( "Color Space endpoints"); Skip_L4( "Color Space endpoints"); Skip_L4( "Color Space endpoints"); Skip_L4( "Color Space endpoints"); Skip_L4( "Color Space endpoints"); Skip_L4( "Color Space endpoints"); Skip_L4( "Red Gamma"); Skip_L4( "Green Gamma"); Skip_L4( "Blue Gamma"); if (Version>4) { Skip_L4( "Intent"); Skip_L4( "ProfileData"); Skip_L4( "ProfileSize"); Skip_L4( "Reserved"); } } } } }
//--------------------------------------------------------------------------- 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 || (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(); } } }
//--------------------------------------------------------------------------- // Packet "B3" or "B6" void File_AvsV::picture_start() { //Counting if (File_Offset+Buffer_Offset+Element_Size==File_Size) Frame_Count_Valid=Frame_Count; //Finalize frames in case of there are less than Frame_Count_Valid frames Frame_Count++; //Name Element_Name("picture_start"); Element_Info1(Ztring::ToZtring(Frame_Count)); Element_Info1C((Element_Code==0xB3), __T("I")); //Parsing int8u picture_coding_type=(int8u)-1; bool time_code_flag, progressive_frame, picture_structure=true, top_field_first, repeat_first_field, skip_mode_flag=false, loop_filter_disable; Skip_B2( "bbv_delay"); BS_Begin(); if (Element_Code==0xB3) //Only I { Get_SB ( time_code_flag, "time_code_flag"); if (time_code_flag) { Skip_SB( "time_code_dropframe"); Skip_S1(5, "time_code_hours"); Skip_S1(6, "time_code_minutes"); Skip_S1(6, "time_code_seconds"); Skip_S1(6, "time_code_pictures"); } } if (Element_Code==0xB6) //Only P or B { Get_S1 ( 2, picture_coding_type, "picture_coding_type"); Element_Info1(AvsV_picture_coding_type[picture_coding_type]); } Skip_S1( 8, "picture_distance"); if (low_delay) Skip_UE( "bbv_check_times"); Get_SB ( progressive_frame, "progressive_frame"); if (!progressive_frame) { Get_SB( picture_structure, "picture_structure"); if (Element_Code==0xB6) //Only P or B { if (picture_structure) Skip_SB( "advanced_pred_mode_disable"); } } Get_SB ( top_field_first, "top_field_first"); Get_SB ( repeat_first_field, "repeat_first_field"); Skip_SB( "fixed_picture_qp"); Skip_S1( 6, "picture_qp"); if (Element_Code==0xB3) //Only I { if (!progressive_frame && !picture_structure) Get_SB( skip_mode_flag, "skip_mode_flag"); } if (Element_Code==0xB6) //Only P or B { if (picture_coding_type!=2 || !picture_structure) Skip_SB( "picture_reference_flag"); } Skip_SB( "reserved"); Skip_SB( "reserved"); Skip_SB( "reserved"); Skip_SB( "reserved"); if (Element_Code==0xB6) //Only P or B { Get_SB( skip_mode_flag, "skip_mode_flag"); } Get_SB ( loop_filter_disable, "loop_filter_disable"); if (!loop_filter_disable) { bool loop_filter_parameter_flag; Get_SB ( loop_filter_parameter_flag, "loop_filter_parameter_flag"); if (loop_filter_parameter_flag) { Skip_SE( "alpha_c_offset"); Skip_SE( "beta_offset"); } } BS_End(); if (Element_Size-Element_Offset) Skip_XX(Element_Size-Element_Offset, "Unknown"); FILLING_BEGIN(); if (progressive_frame==false) { if (picture_structure==true) //Frame { if (top_field_first) Interlaced_Top++; else Interlaced_Bottom++; } } else progressive_frame_Count++; //NextCode NextCode_Test(); NextCode_Clear(); for (int8u Pos=0x00; Pos<=0xAF; Pos++) NextCode_Add(Pos); //slice NextCode_Add(0xB0); //video_sequence_start NextCode_Add(0xB3); //picture_start NextCode_Add(0xB6); //picture_start //Autorisation of other streams for (int8u Pos=0x00; Pos<=0xAF; Pos++) Streams[Pos].Searching_Payload=true; //slice //Filling only if not already done if (Frame_Count>=Frame_Count_Valid && Count_Get(Stream_Video)==0) { //No need of more Accept("AVS Video"); Finish("AVS Video"); } FILLING_END(); }
//--------------------------------------------------------------------------- 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(); }
//--------------------------------------------------------------------------- void File_Ogg::Data_Parse() { //Counting Frame_Count++; //If first chunk of a stream stream& Stream_Item=Stream[Element_Code]; //[+] FlylinkDC++ Team if (Stream_Item.Parser==NULL) { if (Parsing_End) return; //Maybe multitracks concatained, not supported Stream_Item.Parser=new File_Ogg_SubElement; Open_Buffer_Init(Stream_Item.Parser); ((File_Ogg_SubElement*)Stream_Item.Parser)->InAnotherContainer=IsSub; StreamsToDo++; } ((File_Ogg_SubElement*)Stream_Item.Parser)->MultipleStreams=Stream.size()>1; //has no sens for the first init, must check allways //Parsing File_Ogg_SubElement* Parser=(File_Ogg_SubElement*)Stream_Item.Parser; if (Stream_Item.SearchingPayload) //For each chunk for (size_t Chunk_Sizes_Pos=0; Chunk_Sizes_Pos<Chunk_Sizes.size(); Chunk_Sizes_Pos++) { //Info if (!continued) Peek_L1(packet_type); //Only for information Element_Info1(Ztring::ToZtring(packet_type, 16)); Element_Info1C((continued), "Continue"); //Parsing if (continued || Parser->File_Offset!=Parser->File_Size) Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, Chunk_Sizes[Chunk_Sizes_Pos]); if (Chunk_Sizes_Pos<Chunk_Sizes.size()-1 || (Chunk_Sizes_Pos==Chunk_Sizes.size()-1 && Chunk_Sizes_Finished)) { Open_Buffer_Continue(Parser, Buffer+Buffer_Offset, 0); //Purge old datas } Element_Offset+=Chunk_Sizes[Chunk_Sizes_Pos]; continued=false; //If there is another chunk, this can not be a continued chunk if (Parser->File_GoTo!=(int64u)-1) Chunk_Sizes_Pos=Chunk_Sizes.size(); if (!Status[IsAccepted] && Parser->Status[IsAccepted]) Accept("OGG"); if (Parser->Status[IsFinished] || (Element_Offset==Element_Size && eos)) { StreamsToDo--; Stream_Item.SearchingPayload=false; break; } } else Skip_XX(Element_Size, "Data"); //End of stream if (!Parsing_End && (StreamsToDo==0 || File_Offset+Buffer_Offset+Element_Offset>256*1024)) { if (IsSub) Finish("OGG"); else GoToFromEnd(256*1024, "OGG"); std::map<int64u, stream>::iterator Stream_Temp=Stream.begin(); if (File_GoTo!=(int64u)-1) while (Stream_Temp!=Stream.end()) { Stream_Temp->second.absolute_granule_position=0; ++Stream_Temp; } Parsing_End=true; } Element_Show(); }
//--------------------------------------------------------------------------- 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 (MediaInfoLib::Config.ParseSpeed_Get()<1) Finish(); } 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; } }
//--------------------------------------------------------------------------- // 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_Info1(AvsV_extension_start_code_identifier[extension_start_code_identifier]); Element_Info1(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_Info1(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_Info1(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_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_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 = 0, compSubsX = 0, compSubsY = 0; 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_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_Jpeg::Data_Parse() { #define CASE_INFO(_NAME, _DETAIL) \ case Elements::_NAME : Element_Info1(#_NAME); Element_Info1(_DETAIL); _NAME(); break; //Parsing if (SOS_SOD_Parsed) { Skip_XX(Element_Size, "Data"); SOS_SOD_Parsed=false; return; } switch (Element_Code) { CASE_INFO(TEM , "TEM"); CASE_INFO(SOC , "Start of codestream"); //JPEG 2000 CASE_INFO(SIZ , "Image and tile size"); //JPEG 2000 CASE_INFO(COD , "Coding style default"); //JPEG 2000 CASE_INFO(COC , "Coding style component"); //JPEG 2000 CASE_INFO(TLM , "Tile-part lengths, main header"); //JPEG 2000 CASE_INFO(PLM , "Packet length, main header"); //JPEG 2000 CASE_INFO(PLT , "Packet length, tile-part header"); //JPEG 2000 CASE_INFO(QCD , "Quantization default"); //JPEG 2000 CASE_INFO(QCC , "Quantization component "); //JPEG 2000 CASE_INFO(RGN , "Region-of-interest"); //JPEG 2000 CASE_INFO(PPM , "Packed packet headers, main header"); //JPEG 2000 CASE_INFO(PPT , "Packed packet headers, tile-part header"); //JPEG 2000 CASE_INFO(CME , "Comment and extension"); //JPEG 2000 CASE_INFO(SOT , "Start of tile-part"); //JPEG 2000 CASE_INFO(SOP , "Start of packet"); //JPEG 2000 CASE_INFO(EPH , "End of packet header"); //JPEG 2000 CASE_INFO(SOD , "Start of data"); //JPEG 2000 CASE_INFO(S0F0, "Baseline DCT (Huffman)"); CASE_INFO(S0F1, "Extended sequential DCT (Huffman)"); CASE_INFO(S0F2, "Progressive DCT (Huffman)"); CASE_INFO(S0F3, "Lossless (sequential) (Huffman)"); CASE_INFO(DHT , "Define Huffman Tables"); CASE_INFO(S0F5, "Differential sequential DCT (Huffman)"); CASE_INFO(S0F6, "Differential progressive DCT (Huffman)"); CASE_INFO(S0F7, "Differential lossless (sequential) (Huffman)"); CASE_INFO(JPG , "Reserved for JPEG extensions"); CASE_INFO(S0F9, "Extended sequential DCT (Arithmetic)"); CASE_INFO(S0FA, "Progressive DCT (Arithmetic)"); CASE_INFO(S0FB, "Lossless (sequential) (Arithmetic)"); CASE_INFO(DAC , "Define Arithmetic Coding"); CASE_INFO(S0FD, "Differential sequential DCT (Arithmetic)"); CASE_INFO(S0FE, "Differential progressive DCT (Arithmetic)"); CASE_INFO(S0FF, "Differential lossless (sequential) (Arithmetic)"); CASE_INFO(RST0, "Restart Interval Termination 0"); CASE_INFO(RST1, "Restart Interval Termination 1"); CASE_INFO(RST2, "Restart Interval Termination 2"); CASE_INFO(RST3, "Restart Interval Termination 3"); CASE_INFO(RST4, "Restart Interval Termination 4"); CASE_INFO(RST5, "Restart Interval Termination 5"); CASE_INFO(RST6, "Restart Interval Termination 6"); CASE_INFO(RST7, "Restart Interval Termination 7"); CASE_INFO(SOI , "Start Of Image"); CASE_INFO(EOI , "End Of Image"); //Is EOC (End of codestream) in JPEG 2000 CASE_INFO(SOS , "Start Of Scan"); CASE_INFO(DQT , "Define Quantization Tables"); CASE_INFO(DNL , "Define Number of Lines"); CASE_INFO(DRI , "Define Restart Interval"); CASE_INFO(DHP , "Define Hierarchical Progression"); CASE_INFO(EXP , "Expand Reference Components"); CASE_INFO(APP0, "Application-specific marker 0"); CASE_INFO(APP1, "Application-specific marker 1"); CASE_INFO(APP2, "Application-specific marker 2"); CASE_INFO(APP3, "Application-specific marker 3"); CASE_INFO(APP4, "Application-specific marker 4"); CASE_INFO(APP5, "Application-specific marker 5"); CASE_INFO(APP6, "Application-specific marker 6"); CASE_INFO(APP7, "Application-specific marker 7"); CASE_INFO(APP8, "Application-specific marker 8"); CASE_INFO(APP9, "Application-specific marker 9"); CASE_INFO(APPA, "Application-specific marker 10"); CASE_INFO(APPB, "Application-specific marker 11"); CASE_INFO(APPC, "Application-specific marker 12"); CASE_INFO(APPD, "Application-specific marker 13"); CASE_INFO(APPE, "Application-specific marker 14"); CASE_INFO(APPF, "Application-specific marker 15"); CASE_INFO(JPG0, "JPG"); CASE_INFO(JPG1, "JPG"); CASE_INFO(JPG2, "JPG"); CASE_INFO(JPG3, "JPG"); CASE_INFO(JPG4, "JPG"); CASE_INFO(JPG5, "JPG"); CASE_INFO(JPG6, "JPG"); CASE_INFO(JPG7, "JPG"); CASE_INFO(JPG8, "JPG"); CASE_INFO(JPG9, "JPG"); CASE_INFO(JPGA, "JPG"); CASE_INFO(JPGB, "JPG"); CASE_INFO(JPGC, "JPG"); CASE_INFO(JPGD, "JPG"); CASE_INFO(COM , "Comment"); default : Element_Info1("Reserved"); Skip_XX(Element_Size, "Data"); } }
//--------------------------------------------------------------------------- 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 Unknown_Length; int16u Audio_Count; Element_Begin1("Header"); Skip_B1( "Magic"); Skip_Local(16, "Magic"); Skip_L2( "0x0500"); Skip_L1( "Unknown"); Skip_L1( "0x5A"); Skip_L2( "0x0001"); Skip_L2( "0x0004"); Skip_L2( "0x0000"); Skip_L4( "Unknown"); Skip_L2( "0x035A"); Skip_L2( "0x6400"); Skip_L2( "0x0000"); Skip_L2( "0x0300"); Skip_L2( "0x0000"); 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"); Get_L4 (Format_Length, "Format length"); Get_UTF8(Format_Length, Format, "Format"); if (Format!=__T("Pro Tools Session File")) { Element_End(); Reject("Ptx"); return; } Skip_L2( "0x0006"); Get_L4 (Platform_Length, "Platform length"); Skip_UTF8(Platform_Length, "Platform"); Skip_L4( "0x00000000"); Skip_L4( "0x00085A05"); Skip_L4( "Unknown"); Skip_L4( "0x00002067"); Skip_L4( "0x002A0000"); Skip_L4( "Unknown"); Skip_L4( "Unknown"); Skip_L4( "Unknown"); 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( "0x0000002A"); Skip_L4( "Unknown"); Skip_L4( "Unknown"); 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"); Skip_L4( "Unknown"); Skip_L4( "Unknown"); Skip_L4( "0x00000000"); Skip_L4( "Unknown"); Skip_L4( "0x00000101"); Skip_L4( "0x00055A00"); Skip_L4( "Unknown"); Skip_L4( "0x00012519"); Skip_L4( "0x00000000"); Skip_L4( "0x00000000"); Skip_L4( "0x00000001"); Skip_L2( "0x0003"); Element_End(); Get_L2 (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_L4( "0x00000000"); Get_L4 (Unknown_Length, "Name length"); Info_UTF8(Unknown_Length, Name, "Name"); Skip_L2( "0x0000"); Skip_L4( "0x00000000"); Skip_L4( "0x0000002A"); Skip_L4( "Unknown (same 1/2/3)"); Skip_L4( "Unknown (same 1/2/3)"); Info_L1(Number, "Ordered number"); Element_Info1(Number); Element_Info1(Name); Element_End(); Names.push_back(Name); } Element_End(); Skip_L2( "0x0000"); Element_Begin1("Audio tracks list 2"); for (int16u Pos=0; Pos<Audio_Count; Pos++) { Element_Begin1("Name"); int32u Size; Skip_L3( "0x00025A"); Get_L4 (Size, "Size"); Skip_L4( "0x0000251A"); Get_L4 (Unknown_Length, "Name length"); Info_UTF8(Unknown_Length, Name, "Name"); Skip_L2( "0x0000"); Skip_L4( "0x00000000"); Skip_L4( "0x0000002A"); Skip_L4( "Unknown (same 1/2/3)"); Skip_L4( "Unknown (same 1/2/3)"); Info_L1(Number, "Ordered number"); Element_Info1(Number); Skip_L4( "0x00000000"); Element_Info1(Name); if (Unknown_Length+31!=Size) { Reject(); return; } Element_End(); } Element_End(); Get_L2 (Audio_Count, "Audio count"); if (4*Audio_Count>Element_Size) { Reject(); return; } Skip_L2( "0x00"); Element_Begin1("Audio tracks list 3"); for (int16u Pos=0; Pos<Audio_Count; Pos++) { Element_Begin1("Name"); int32u Size; Skip_L3( "0x00025A"); Get_L4 (Size, "Size"); Skip_L4( "0x0000251A"); Get_L4 (Unknown_Length, "Name length"); Info_UTF8(Unknown_Length, Name, "Name"); Skip_L2( "0x0000"); Skip_L4( "0x00000000"); Skip_L4( "0x0000002A"); Skip_L4( "Unknown (same 1/2/3)"); Skip_L4( "Unknown (same 1/2/3)"); Info_L1(Number, "Ordered number"); Element_Info1(Number); Skip_L4( "0x00000000"); Element_Info1(Name); if (Unknown_Length+31!=Size) { Reject(); return; } Element_End(); } Element_End(); Skip_L2( "0x0000"); Skip_L2( "0x0018"); Skip_L4( "0x00000001"); Skip_L2( "0x0018"); Skip_L4( "0x00000001"); Skip_L2( "0x0001"); Skip_L3( "0x00095A"); Get_L4 (Unknown_Length, "Opaque length"); Skip_XX(Unknown_Length, "Opaque"); Skip_L3( "0x00045A"); Skip_L4( "0x00000016"); Skip_L4( "0x06002026"); Skip_L4( "0x00000000"); Skip_L2( "0x0000"); Skip_L4( "Unknown"); Skip_L4( "Unknown"); Skip_L4( "0x00000000"); Skip_L3( "0x00025A"); Skip_L4( "0x00000015"); Skip_L4( "0x075A2032"); Skip_L4( "0x00000C00"); Skip_L4( "0x01204200"); Skip_L4( "0x01000000"); Skip_L4( "Unknown"); Skip_L4( "0x00025A00"); Skip_L4( "Unknown"); Skip_L4( "Unknown"); Skip_L4( "0x015A0000"); Skip_L4( "Unknown"); Skip_L4( "Unknown"); 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"); Element_Begin1("File names"); size_t Pos_Offset=0; for (int32u Pos=0; Pos<FileName_Count; Pos++) { Ztring Name; int32u Name_Length, Purpose; Element_Begin1("File names"); Skip_L1( "0x0002"); Skip_L4( "Ordered number except WAV files and -1"); Get_L4 (Name_Length, "Name length"); Get_UTF8(Name_Length, Name, "Name"); Element_Name(Name); Get_C4 (Purpose, "Purpose (e.g. EVAW for .wav files)"); Element_End(); switch (Purpose) { case 0x45564157: if (Pos-Pos_Offset<Names.size() && (Name.find(Names[Pos-Pos_Offset])==0 || Name.find(Names[Pos-Pos_Offset]+__T(".wav"))+5==Name.size())) { File__ReferenceFilesHelper::reference ReferenceFile; ReferenceFile.StreamKind=Stream_Audio; ReferenceFile.FileNames.push_back(Directory+PathSeparator+Name); ReferenceFiles->References.push_back(ReferenceFile); } else if (ReferenceFiles->References.empty()) Pos_Offset++; default: ; } } Element_End(); Skip_XX(Element_Size-Element_Offset, "Unknown"); FILLING_BEGIN(); Accept("Ptx"); //Could be Ptf (former formatn 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); FILLING_END(); }
//--------------------------------------------------------------------------- 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*(Interlaced?2:1)); 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_Tiff::GetValueOffsetu(ifditem &IfdItem) { ZtringList &Info=Infos[IfdItem.Tag]; Info.clear(); Info.Separator_Set(0, __T(" / ")); const char* Name=Tiff_Tag_Name(IfdItem.Tag); if (IfdItem.Count>=10) { //Too many data, we don't currently need it and we skip it Skip_XX(Element_Size-(Element_Offset+4), Name); Info.clear(); return; } switch (IfdItem.Type) { case 1: /* 8-bit unsigned integer. */ for (int16u Pos=0; Pos<IfdItem.Count; Pos++) { int8u Ret8; #if MEDIAINFO_TRACE if (LittleEndian) Get_L1 (Ret8, Name); else Get_B1 (Ret8, Name); Element_Info1(Ztring::ToZtring(Ret8)); #else //MEDIAINFO_TRACE if (Element_Offset+1>Element_Size) { Trusted_IsNot(); break; } if (LittleEndian) Ret8=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset); else Ret8=BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset++; #endif //MEDIAINFO_TRACE Info.push_back(Ztring::ToZtring(Ret8)); } break; case 3: /* 16-bit (2-byte) unsigned integer. */ for (int16u Pos=0; Pos<IfdItem.Count; Pos++) { int16u Ret16; #if MEDIAINFO_TRACE if (LittleEndian) Get_L2 (Ret16, Name); else Get_B2 (Ret16, Name); switch (IfdItem.Tag) { case Tiff_Tag::Compression : Element_Info1(Tiff_Compression(Ret16)); break; case Tiff_Tag::PhotometricInterpretation : Element_Info1(Tiff_PhotometricInterpretation(Ret16)); break; default : Element_Info1(Ztring::ToZtring(Ret16)); } #else //MEDIAINFO_TRACE if (Element_Offset+2>Element_Size) { Trusted_IsNot(); break; } if (LittleEndian) Ret16=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset); else Ret16=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=2; #endif //MEDIAINFO_TRACE Info.push_back(Ztring::ToZtring(Ret16)); } break; case 4: /* 32-bit (4-byte) unsigned integer */ for (int16u Pos=0; Pos<IfdItem.Count; Pos++) { int32u Ret32; #if MEDIAINFO_TRACE if (LittleEndian) Get_L4 (Ret32, Name); else Get_B4 (Ret32, Name); Element_Info1(Ztring::ToZtring(Ret32)); #else //MEDIAINFO_TRACE if (Element_Offset+4>Element_Size) { Trusted_IsNot(); break; } if (LittleEndian) Ret32=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); else Ret32=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=4; #endif //MEDIAINFO_TRACE Info.push_back(Ztring::ToZtring(Ret32)); } break; default: //Unknown { if (LittleEndian) Skip_L4( Name); else Skip_B4( Name); Info.clear(); //We actually do not know the type } } }