//--------------------------------------------------------------------------- void File_Ico::FileHeader_Parse() { //Parsing Skip_L2( "Reserved"); Get_L2 (Type, "Type"); Get_L2 (Count, "Count"); }
//--------------------------------------------------------------------------- void File_MpcSv8::RG() { //Parsing int16u TitleGain, AlbumGain; Skip_B1( "Version"); Get_L2 (TitleGain, "Title gain"); Param_Info(((float32)((int16s)TitleGain))/1000, 2, " dB"); Skip_L2( "Title peak"); Get_L2 (AlbumGain, "Album gain"); Param_Info(((float32)((int16s)TitleGain))/1000, 2, " dB"); Skip_L2( "Album peak"); }
//--------------------------------------------------------------------------- void File_La::FileHeader_Parse() { //Parsing Ztring Major, Minor; int32u SampleRate, Samples, BytesPerSecond, UnCompSize, WAVEChunk, FmtSize, FmtChunk, CRC32; int16u RawFormat, Channels, BytesPerSample, BitsPerSample; Skip_Local(2, "signature"); Get_Local (1, Major, "major_version"); Get_Local (1, Minor, "minor_version"); Get_L4 (UnCompSize, "uncompressed_size"); Get_L4 (WAVEChunk, "chunk"); Skip_L4( "fmt_size"); Get_L4 (FmtChunk, "fmt_chunk"); Get_L4 (FmtSize, "fmt_size"); Get_L2 (RawFormat, "raw_format"); Get_L2 (Channels, "channels"); Param_Info2(Channels, " channel(s)"); Get_L4 (SampleRate, "sample_rate"); Get_L4 (BytesPerSecond, "bytes_per_second"); Get_L2 (BytesPerSample, "bytes_per_sample"); Get_L2 (BitsPerSample, "bits_per_sample"); Get_L4 (Samples, "samples"); Skip_L1( "flags"); Get_L4 (CRC32, "crc"); FILLING_BEGIN() if (SampleRate==0) return; Duration=((int64u)Samples/Channels)*1000/SampleRate; // Seems that it's samples per channels otherwise Duration is doubled ??!! if (Duration==0) return; UncompressedSize=(Samples)*Channels*(BitsPerSample/8); if (UncompressedSize==0) return; File__Tags_Helper::Accept("LA"); Fill(Stream_General, 0, General_Format_Version, Major+__T('.')+Minor); File__Tags_Helper::Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "LA"); Fill(Stream_Audio, 0, Audio_Codec, "LA"); Fill(Stream_Audio, 0, Audio_Format_Version, Major+__T('.')+Minor); Fill(Stream_Audio, 0, Audio_BitDepth, BitsPerSample); Fill(Stream_Audio, 0, Audio_Channel_s_, Channels); Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate); Fill(Stream_Audio, 0, Audio_Duration, Duration); //No more need data File__Tags_Helper::Finish("LA"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Dpx::Get_X2(int16u &Info, const char* Name) { if (LittleEndian) Get_L2 (Info, Name); else Get_B2 (Info, Name); }
//--------------------------------------------------------------------------- void Riff_AVI__hdrl_strl_indx::Read_Internal () { //Filling Global->AVI__hdrl_strl_indx_Pointers.insert(this); //Reading Read_Internal_ReadAllInBuffer(); //Parsing int32u Entry_Count, ChunkId; int16u LongsPerEntry; int8u IndexType, IndexSubType; Get_L2 (LongsPerEntry); Get_L1 (IndexSubType); Get_L1 (IndexType); Get_L4 (Entry_Count); Get_C4 (ChunkId); //Integrity if (LongsPerEntry!=4 || (IndexSubType&0xFE) || IndexType!=0x00 || 24+Entry_Count*16>Chunk.Content.Size) throw exception_valid("hdrl_strl_indx form is not supported"); //Parsing Skip_XX(12); //Reserved for (int32u Pos=0; Pos<Entry_Count; Pos++) { int64u Offset; Get_L8 (Offset); Skip_XX(8); //Size + Duration //Filling Global->AVI__hdrl_strl_indx_In_Position_Indexes_List.push_back(Offset); Global->AVI__movi___ix_WithFields[ChunkId]=(IndexSubType&0x01)?true:false; } }
bool File_Zip::Zip64_end_of_central_directory_record() { if (Element_Offset+12>Element_Size) //Zip64_end_of_central_directory_record return false; //Not enough data //Retrieving complete Zip64_end_of_central_directory_record size int64u size_of_Zip64_end_of_central_directory_record=LittleEndian2int64u(Buffer+(size_t)Element_Offset+4); if (Element_Offset+12+size_of_Zip64_end_of_central_directory_record>Element_Size) //end_of_central_directory all included return false; //Not enough data //Parsing //~ int32u offset; int16u version_made_by; Element_Begin1("Zip64 End of central directory record"); Skip_C4( "Zip64 end of central dir signature"); Skip_L8( "size of zip64 end of central directory record"); 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"); Skip_L4( "number of this disk"); Skip_L4( "number of the disk");// with the start of the central directory Skip_L8( "total number of entries on this disk");// in the central directory Skip_L8( "total number of entries");// in the central directory Skip_L8( "size of the central directory"); Skip_L8( "offset of start of central directory"); // with respect to the starting disk number Skip_XX(size_of_Zip64_end_of_central_directory_record-44, "zip64 extensible data sector"); Element_End0(); return true; }
//--------------------------------------------------------------------------- void File_Bmp::BitmapInfoHeader() { //Parsing Element_Begin("Bitmap Info header", 40); 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_Info(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"); Element_End(); FILLING_BEGIN(); 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)); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Pcx::Read_Buffer_Continue() { //Parsing int16u XMin, YMin, XMax, YMax, HorDPI, VertDPI, BytesPerLine, PaletteType, HScrSize, VScrSize; int8u Manufacturer, Version, EncodingScheme, BitsPerPixel, ColorPlanes; Get_L1 (Manufacturer, "Manufacturer"); Get_L1 (Version, "Version"); // 0,2,3,4,5 Get_L1 (EncodingScheme, "EncodingScheme"); // RLE=1 Get_L1 (BitsPerPixel, "Bits Per Pixel"); // 1,4,8,24 Get_L2 (XMin, "Left margin of image"); Get_L2 (YMin, "Upper margin of image"); Get_L2 (XMax, "Right margin of image"); Get_L2 (YMax, "Lower margin of image"); Get_L2 (HorDPI, "Horizontal Resolution"); Get_L2 (VertDPI, "Vertical Resolution"); Skip_XX(48, "Palette"); Skip_L1( "Reserved"); Get_L1 (ColorPlanes, "ColorPlanes"); Get_L2 (BytesPerLine, "BytesPerLine"); Get_L2 (PaletteType, "PaletteType"); Get_L2 (HScrSize, "Horizontal Screen Size"); Get_L2 (VScrSize, "Vertical Screen Size"); Skip_XX(56, "Filler"); FILLING_BEGIN(); //Integrity tests if (XMax<=XMin || YMax<=YMin || BytesPerLine<XMax-XMin) { Reject("PCX"); return; } Accept("PCX"); Stream_Prepare(Stream_Image); Fill(Stream_Image, 0, Image_Format, "PCX"); Fill(Stream_Image, 0, Image_Format_Version, Pcx_VersionInfo(Version)); Fill(Stream_Image, 0, Image_Width, XMax-XMin); Fill(Stream_Image, 0, Image_Height, YMax-YMin); Fill(Stream_Image, 0, Image_BitDepth, BitsPerPixel); Fill(Stream_Image, 0, "DPI", Ztring::ToZtring(VertDPI) + __T(" x ") + Ztring::ToZtring(HorDPI)); Finish("PCX"); FILLING_END(); }
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_Kate::Identification() { Element_Name("Identification"); //Parsing Ztring Language, Category; int16u Width, Height; int8u VersionMajor, VersionMinor, NumHeaders, TextEncoding; Skip_B1 ( "Signature"); Skip_Local(7, "Signature"); Skip_L1( "Reserved"); Get_L1 (VersionMajor, "version major"); Get_L1 (VersionMinor, "version minor"); Get_L1 (NumHeaders, "num headers"); Get_L1 (TextEncoding, "text encoding"); Skip_L1( "directionality"); Skip_L1( "Reserved"); Skip_L1( "granule shift"); Skip_L4( "Reserved"); Get_L2 (Width, "cw sh + canvas width"); Get_L2 (Height, "ch sh + canvas height"); /* BS_Begin(); Skip_BS( 4, "cw sh"); Get_BS (12, Width, "canvas width"); Skip_BS( 4, "ch sh"); Get_BS (12, Height, "canvas height"); BS_End(); */ Skip_L4( "granule rate numerator"); Skip_L4( "granule rate denominator"); Get_UTF8(16, Language, "Language"); Get_UTF8(16, Category, "Category"); FILLING_BEGIN(); Accept("Kate"); Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, Text_Format, "Kate"); Fill(Stream_Text, 0, Text_Codec, "Kate"); Fill(Stream_Text, 0, Text_Language, Language); Fill(Stream_Text, 0, Text_Language_More, Kate_Category(Category)); Finish("Kate"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Elf::Read_Buffer_Continue() { //Parsing int32u version4=(int32u)-1; int16u type=(int16u)-1, machine=(int16u)-1; int8u classs, data, version1, osabi, abiversion; Skip_C4( "magic"); Get_L1 (classs, "class"); Get_L1 (data, "data"); Get_L1 (version1, "version"); Get_L1 (osabi, "osabi"); Param_Info1(Elf_osabi(osabi)); Get_L1 (abiversion, "abiversion"); Skip_XX(7, "reserved"); if (data==1) //LE { Get_L2 (type, "type"); Param_Info1(Elf_type(type)); Get_L2 (machine, "machine"); Param_Info1(Elf_machine(machine)); Get_L4 (version4, "version"); } if (data==2) //BE { Get_B2 (type, "type"); Param_Info1(Elf_type(type)); Get_B2 (machine, "machine"); Param_Info1(Elf_machine(machine)); Get_B4 (version4, "version"); } Skip_XX(Element_Size-Element_Offset, "Data"); FILLING_BEGIN(); if (version4!=(int32u)-1 && version1!=version4) { Reject("ELF"); return; } Accept("ELF"); Fill(Stream_General, 0, General_Format, "ELF"); if (type!=(int16u)-1) Fill(Stream_General, 0, General_Format_Profile, Elf_type(type)); if (machine!=(int16u)-1) Fill(Stream_General, 0, General_Format_Profile, Elf_machine(machine)); //No need of more Finish("ELF"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Rar::Header_Parse() { //Config HIGH_PACK_SIZE=0; PACK_SIZE=0; //Parsing int16u HEAD_SIZE; Skip_L2( "HEAD_CRC"); //CRC of total block or block part Get_L1 (HEAD_TYPE, "HEAD_TYPE"); //Block type Get_L2 (HEAD_FLAGS, "HEAD_FLAGS"); Header_Parse_Flags(); Get_L2 (HEAD_SIZE, "HEAD_SIZE"); Header_Parse_Content(); Skip_XX(HEAD_SIZE-(size_t)Element_Offset, "REST OF HEADER"); //Filling Header_Fill_Size(HEAD_SIZE+HIGH_PACK_SIZE*0x100000000LL+PACK_SIZE); Header_Fill_Code(HEAD_TYPE, Rar_HEADER_TYPE(HEAD_TYPE)); }
//--------------------------------------------------------------------------- // file header void File_Rar::Header_Parse_Content_74() { int16u name_size; int8u HOST_OS, METHOD, UNP_VER; Get_L4 (PACK_SIZE, "PACK_SIZE"); //Compressed file size Skip_L4( "UNP_SIZE"); //Uncompressed file size Get_L1 (HOST_OS, "HOST_OS"); Param_Info1((HOST_OS<6?Rar_host_os[HOST_OS]:"Unknown")); Skip_L4( "FILE_CRC"); Skip_L4( "FTIME"); //Date and time in standard MS DOS format Get_L1 (UNP_VER, "UNP_VER"); Param_Info1(Rar_version_number(UNP_VER)); //RAR version needed to extract file Get_L1 (METHOD, "METHOD"); Param_Info1(((METHOD>=0x30)&&(METHOD<0x36)?Rar_packing_method[METHOD-0x30]:"Unknown")); Get_L2 (name_size, "NAME_SIZE"); //File name size Skip_L4( "ATTR"); //File attributes if(high_fields) { Get_L4 (HIGH_PACK_SIZE, "HIGH_PACK_SIZE"); //High 4 bytes of 64 bit value of compressed file size. Skip_L4( "HIGH_UNP_SIZE"); //High 4 bytes of 64 bit value of uncompressed file size. } else HIGH_PACK_SIZE=0; if (usual_or_utf8) { //Must test the content before reading, looking fore zero byte if (Element_Offset+name_size>Element_Size) { Skip_XX(Element_Size-Element_Offset, "Error"); return; } int64u ZeroPos=0; while (ZeroPos<name_size) { if (Buffer[Buffer_Offset+(size_t)(Element_Offset+ZeroPos)]==0) break; //Found ZeroPos++; } if (ZeroPos==name_size) Skip_UTF8(name_size, "FILE_NAME"); else { Skip_Local(ZeroPos, "FILE_NAME"); //Up to ZeroPos Skip_L1( "Zero"); Skip_UTF16L(name_size-(ZeroPos+1), "FILE_NAME"); //Spec is not precise, "Unicode" without encoding format (character size, endianess), because RAR is from Windows, we hope this is the format from Windows (UTF-16 Little Endian) } } else Skip_Local(name_size, "FILE_NAME"); if (salt) Skip_L8( "SALT"); //if(exttime) //Skip_XX("EXT_TIME"); //Which size? }
//--------------------------------------------------------------------------- void File_Tga::Tga_File_Header() { //Parsing Element_Begin1("Tga File Header"); Get_L1 (ID_Length, "ID Length"); Get_L1 (Color_Map_Type, "Color Map Type"); Get_L1 (Image_Type, "Image Type"); Param_Info1(Tga_Image_Type_Compression(Image_Type)); Element_End0(); Element_Begin1("Color Map Specification"); Get_L2 (First_Entry_Index, "First Entry Index"); Get_L2 (Color_map_Length, "Color map Length"); Get_L1 (Color_map_Entry_Size, "Color map Entry Size"); Element_End0(); Element_Begin1("Image Specification"); Skip_L2( "X-origin of Image"); Skip_L2( "Y-origin of Image"); Get_L2 (Image_Width_, "Image Width"); Get_L2 (Image_Height_, "Image Height"); Get_L1 (Pixel_Depth, "Pixel Depth"); Get_L1 (Image_Descriptor, "Image Descriptor"); Element_End0(); }
//--------------------------------------------------------------------------- void File_Tak::SEEKTABLE() { //Parsing int16u num_seekpoints; Get_L2 (num_seekpoints, "num_seekpoints"); Skip_L1 ( "unknown"); Skip_L1 ( "seek interval"); Element_Begin1("seekpoints"); for (int16u Pos=0; Pos<num_seekpoints; Pos++) Skip_L5 ( "seekpoint"); Element_End0(); Skip_L3( "crc"); }
//--------------------------------------------------------------------------- void File_Cmml::Identification() { Element_Name("Identification"); //Parsing int16u VersionMajor, VersionMinor; Skip_Local(8, "Signature"); Get_L2 (VersionMajor, "version major"); Get_L2 (VersionMinor, "version minor"); Skip_L8( "granule rate numerator"); Skip_L8( "granule rate denominator"); Skip_L1( "granule shift"); FILLING_BEGIN(); Stream_Prepare(Stream_General); Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, Text_Format, "CMML"); Fill(Stream_Text, 0, Text_Codec, "CMML"); Accept("CMML"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Tta::FileHeader_Parse() { //Parsing int32u SampleRate, Samples, CRC32; int16u AudioFormat, Channels, BitsPerSample; Skip_C4( "Signature"); Get_L2 (AudioFormat, "AudioFormat"); Get_L2 (Channels, "NumChannels"); Get_L2 (BitsPerSample, "BitsPerSample"); Get_L4 (SampleRate, "SampleRate"); Get_L4 (Samples, "DataLength"); Get_L4 (CRC32, "CRC32"); FILLING_BEGIN(); if (SampleRate==0) return; Duration=((int64u)Samples)*1000/SampleRate; if (Duration==0) return; UncompressedSize=((int64u)Samples)*Channels*(BitsPerSample/8); if (UncompressedSize==0) return; //Filling data File__Tags_Helper::Accept("TTA"); File__Tags_Helper::Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "TTA"); Fill(Stream_Audio, 0, Audio_Codec, "TTA "); Fill(Stream_Audio, 0, Audio_BitDepth, BitsPerSample); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SampleRate); Fill(Stream_Audio, 0, Audio_Duration, Duration); FILLING_END(); //No more need data File__Tags_Helper::Finish("TTA"); }
//--------------------------------------------------------------------------- void File_Gif::Read_Buffer_Continue() { //Parsing Ztring Version; int16u Width, Height; int8u BackgroundColorIndex, PixelAspectRatio, Resolution, GCT_Size; bool GCT_Flag, Sort; Skip_Local(3, "Header"); Get_Local (3, Version, "Version"); Get_L2 (Width, "Logical Screen Width"); Get_L2 (Height, "Logical Screen Height"); BS_Begin(); Get_SB ( GCT_Flag, "Global Color Table Flag"); Get_S1 (3, Resolution, "Color Resolution"); Get_SB ( Sort, "Sort Flag to Global Color Table"); Get_S1 (3, GCT_Size, "Size of Global Color Table"); Param_Info(Ztring::ToZtring((int16u)pow(2.0, 1+GCT_Size))); BS_End(); Get_L1 (BackgroundColorIndex, "Background Color Index"); Get_L1 (PixelAspectRatio, "Pixel Aspect Ratio"); if (GCT_Flag) Skip_XX((int16u)pow(2.0, 1+GCT_Size)*3, "Global Color Table"); Element_End(); FILLING_BEGIN(); Accept("GIF"); Stream_Prepare(Stream_Image); Fill(Stream_Image, 0, Image_Width, Width); Fill(Stream_Image, 0, Image_Height, Height); Fill(Stream_Image, 0, Image_Format, _T("GIF")); Fill(Stream_Image, 0, Image_Format_Profile, Version); Fill(Stream_Image, 0, Image_Codec, _T("GIF")+Version); Finish("GIF"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_ExtendedModule::Read_Buffer_Continue() { //Parsing Ztring ModuleName, TrackerName; int32u HeaderSize; int16u Length, Channels, Patterns, Instruments, Flags, Tempo, BPM; int8u VersionMinor, VersionMajor; Skip_String(17, "Signature"); Get_Local(20, ModuleName, "Module name"); Skip_L1( "0x1A"); Get_Local(20, TrackerName, "Tracker name"); Get_L1 (VersionMinor, "Version (minor)"); Get_L1 (VersionMajor, "Version (major)"); Get_L4 (HeaderSize, "Header size"); Get_L2 (Length, "Song Length"); Skip_L2( "Restart position"); Get_L2 (Channels, "Number of channels"); Get_L2 (Patterns, "Number of patterns"); Get_L2 (Instruments, "Number of instruments"); Get_L2 (Flags, "Flags"); Get_L2 (Tempo, "Tempo"); Get_L2 (BPM, "BPM"); Skip_XX(256, "Pattern order table"); FILLING_BEGIN(); Accept("Extended Module"); Fill(Stream_General, 0, General_Format, "Extended Module"); Fill(Stream_General, 0, General_Format_Version, Ztring::ToZtring(VersionMajor)+__T(".")+Ztring::ToZtring(VersionMinor/10)+Ztring::ToZtring(VersionMinor%10)); Fill(Stream_General, 0, General_Track, ModuleName.Trim(__T(' '))); Fill(Stream_General, 0, General_Encoded_Application, TrackerName.Trim(__T(' '))); Fill(Stream_General, 0, "Tempo", Tempo); Fill(Stream_General, 0, "BPM", BPM); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, "Sampler, Channels", Channels); Fill(Stream_Audio, 0, "Sampler, Patterns", Patterns); Fill(Stream_Audio, 0, "Sampler, Instruments", Instruments); //No more need data Finish("Extended Module"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Ico::Data_Parse() { //Parsing int32u Size, Offset; int16u BitsPerPixel; int8u Width, Height; Get_L1 (Width, "Width"); Get_L1 (Height, "Height"); Skip_L1( "Colour count"); Skip_L1( "Reserved"); Skip_L2( Type==1?"Colour planes":"X hotspot"); Get_L2 (BitsPerPixel, Type==1?"Bits per pixel":"Y hotspot"); Get_L4 (Size, "Size of the bitmap data"); Get_L4 (Offset, "Offset of the bitmap data"); FILLING_BEGIN_PRECISE(); stream Stream; Stream.Width=Width; Stream.Height=Height; Stream.BitsPerPixel=BitsPerPixel; Stream.Size=Size; Stream.Offset=Offset; Streams.push_back(Stream); IcoDataSize+=Size; if (Offset>File_Size || File_Offset+Buffer_Offset+Element_Size+IcoDataSize>File_Size) Reject("ICO"); Count--; if (Count==0) { if (File_Offset+Buffer_Offset+Element_Size+IcoDataSize!=File_Size) Reject("ICO"); else { Accept("ICO"); Finish("ICO"); } } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Flic::FileHeader_Parse() { //Parsing int32u DelayBetweenFrames; int16u Type, Frames, Width, Height, BitsPerPixel, AspectX=0, AspectY=0; Skip_L4( "Size of FLIC including this header"); Get_L2 (Type, "File type"); Get_L2 (Frames, "Number of frames in first segment"); Get_L2 (Width, "Width"); Get_L2 (Height, "Height"); Get_L2 (BitsPerPixel, "Bits per pixel"); Skip_L2( "Flags"); Get_L4 (DelayBetweenFrames, "Delay between frames"); if (Type!=0xAF11) { Skip_L2( "Reserved"); Skip_L4( "Date of Creation)"); Skip_L4( "Serial number or compiler id"); Skip_L4( "Date of FLIC update"); Skip_L4( "Serial number"); Get_L2 (AspectX, "Width of square rectangle"); Get_L2 (AspectY, "Height of square rectangle"); } else Skip_XX(22, "Reserved"); Skip_L2( "EGI: flags for specific EGI extensions"); Skip_L2( "EGI: key-image frequency"); Skip_L2( "EGI: total number of frames (segments)"); Skip_L4( "EGI: maximum chunk size (uncompressed)"); Skip_L2( "EGI: max. number of regions in a CHK_REGION chunk"); Skip_L2( "EGI: number of transparent levels"); if (Type!=0xAF11) { Skip_XX(24, "Reserved"); Skip_L4( "Offset to frame 1"); Skip_L4( "Offset to frame 2"); Skip_XX(40, "Reserved"); } else Skip_XX(72, "Reserved"); //Filling FILLING_BEGIN(); switch (Type) { case 0xAF11 : case 0xAF12 : case 0xAF30 : case 0xAF31 : case 0xAF44 : break; default : Reject("FLIC"); return; } //Filling Accept("FLIC"); Fill(Stream_General, 0, General_Format, "FLIC"); Stream_Prepare(Stream_Video); if (Type==0xAF11) { Fill(Stream_Video, 0, Video_Format, "FLI"); Fill(Stream_Video, 0, Video_Codec, "FLI"); if (DelayBetweenFrames) { Fill(Stream_Video, StreamPos_Last, Video_FrameRate, 1000.0/(DelayBetweenFrames*70)); //multiple of 1/70 per frame Fill(Stream_Video, 0, Video_Duration, Frames*DelayBetweenFrames*70); } } else { Fill(Stream_Video, 0, Video_Format, "FLC"); Fill(Stream_Video, 0, Video_Codec, "FLC"); if (DelayBetweenFrames) { Fill(Stream_Video, StreamPos_Last, Video_FrameRate, 1000.0/DelayBetweenFrames); //ms per frame Fill(Stream_Video, 0, Video_Duration, Frames*DelayBetweenFrames); } if (AspectY>0) Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, AspectX/AspectY, 3, true); } Fill(Stream_Video, 0, Video_FrameCount, Frames); Fill(Stream_Video, StreamPos_Last, Video_Width, Width); Fill(Stream_Video, StreamPos_Last, Video_Height, Height); Fill(Stream_Video, 0, Video_BitDepth, (BitsPerPixel%3)?BitsPerPixel:(BitsPerPixel/3), 10, true); //If not a multiple of 3, the total resolution is filled //No more need data Finish("FLIC"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Mz::FileHeader_Parse() { //Parsing int32u lfanew; int16u magic; Element_Begin("MZ"); Get_C2 (magic, "magic"); if (magic!=0x4D5A) //"MZ" { Finished(); return; } Skip_L2( "cblp"); Skip_L2( "cp"); Skip_L2( "crlc"); Skip_L2( "cparhdr"); Skip_L2( "minalloc"); Skip_L2( "maxalloc"); Skip_L2( "ss"); Skip_L2( "sp"); Skip_L2( "csum"); Skip_L2( "ip"); Skip_L2( "cs"); Skip_L2( "lsarlc"); Skip_L2( "ovno"); Skip_L2( "res"); Skip_L2( "res"); Skip_L2( "res"); Skip_L2( "res"); Skip_L2( "oemid"); Skip_L2( "oeminfo"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Get_L4 (lfanew, "lfanew"); //Computing if (lfanew>Element_Offset) { Skip_XX(lfanew-Element_Offset, "MZ data"); Element_End(); } if (Element_Offset>lfanew) { Element_End(); Element_Offset=lfanew; //Multi usage off the first bytes } //Parsing int32u Signature, TimeDateStamp=0; int16u Machine=0, Characteristics=0; Peek_B4(Signature); if (Signature==0x50450000) //"PE" { Element_Begin("PE"); Skip_C4( "Header"); Get_L2 (Machine, "Machine"); Param_Info(Mz_Machine(Machine)); Skip_L2( "NumberOfSections"); Get_L4 (TimeDateStamp, "TimeDateStamp"); Param_Info(Ztring().Date_From_Seconds_1970(TimeDateStamp)); Skip_L4( "PointerToSymbolTable"); Skip_L4( "NumberOfSymbols"); Skip_L2( "SizeOfOptionalHeader"); Get_L2 (Characteristics, "Characteristics"); Element_End("PE"); } //Filling Stream_Prepare(Stream_General); Fill(Stream_General, 0, General_Format, "MZ"); if (Characteristics&0x2000) Fill(Stream_General, 0, General_Format_Profile, "DLL"); else if (Characteristics&0x0002) Fill(Stream_General, 0, General_Format_Profile, "Executable"); Fill(Stream_General, 0, General_Format_Profile, Mz_Machine(Machine)); if (TimeDateStamp) Fill(Stream_General, 0, General_Encoded_Date, Ztring().Date_From_Seconds_1970(TimeDateStamp)); //No need of more Finished(); }
//--------------------------------------------------------------------------- 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_Begin("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_Info(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_End(); 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_Begin(); 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_Info(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_End(); } } }
//--------------------------------------------------------------------------- void File_Ape::FileHeader_Parse() { //Parsing int32u SampleRate=0, TotalFrames=0, FinalFrameSamples=0, SamplesPerFrame=0, SeekElements; int16u Version, CompressionLevel=0, Flags=0, Channels=0, Resolution=0; bool Resolution8=false, Resolution24=false, no_wav_header; Skip_C4( "Identifier"); Get_L2 (Version, "Version"); if (Version<3980) //<3.98 { Get_L2 (CompressionLevel, "CompressionLevel"); Param_Info(Ape_Codec_Settings(CompressionLevel)); Get_L2 (Flags, "FormatFlags"); Get_Flags (Flags, 0, Resolution8, "8-bit"); Skip_Flags(Flags, 1, "crc-32"); Skip_Flags(Flags, 2, "peak_level"); Get_Flags (Flags, 3, Resolution24, "24-bit"); Skip_Flags(Flags, 4, "seek_elements"); Get_Flags (Flags, 5, no_wav_header, "no_wav_header"); if (Resolution8) Resolution=8; else if (Resolution24) Resolution=24; else Resolution=16; Get_L2 (Channels, "Channels"); Get_L4 (SampleRate, "SampleRate"); Skip_L4( "WavHeaderDataBytes"); Skip_L4( "WavTerminatingBytes"); Get_L4 (TotalFrames, "TotalFrames"); Get_L4 (FinalFrameSamples, "FinalFrameSamples"); SamplesPerFrame=Ape_SamplesPerFrame(Version, CompressionLevel); Skip_L4( "PeakLevel"); Get_L4 (SeekElements, "SeekElements"); if (!no_wav_header) Skip_XX(44, "RIFF header"); Skip_XX(SeekElements*4, "Seek table"); } else { Skip_L2( "Version_High"); Skip_L4( "DescriptorBytes"); Skip_L4( "HeaderBytes"); Skip_L4( "SeekTableBytes"); Skip_L4( "WavHeaderDataBytes"); Skip_L4( "APEFrameDataBytes"); Skip_L4( "APEFrameDataBytesHigh"); Skip_L4( "WavTerminatingDataBytes"); Skip_L16( "FileMD5"); Get_L2 (CompressionLevel, "CompressionLevel"); Param_Info(Ape_Codec_Settings(CompressionLevel)); Get_L2 (Flags, "FormatFlags"); Get_L4 (SamplesPerFrame, "BlocksPerFrame"); Get_L4 (FinalFrameSamples, "FinalFrameBlocks"); Get_L4 (TotalFrames, "TotalFrames"); Get_L2 (Resolution, "BitsPerSample"); Get_L2 (Channels, "Channels"); Get_L4 (SampleRate, "SampleRate"); } FILLING_BEGIN(); //Coherancy int32u Samples=(TotalFrames-1)*SamplesPerFrame+FinalFrameSamples; if (Samples==0 || SampleRate==0 || Channels==0 || Resolution==0) { File__Tags_Helper::Reject("APE"); return; } //Filling File__Tags_Helper::Accept("APE"); File__Tags_Helper::Streams_Fill(); Duration=((int64u)Samples)*1000/SampleRate; UncompressedSize=Samples*Channels*(Resolution/8); File__Tags_Helper::Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "Monkey's Audio"); Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, Ape_Codec_Settings(CompressionLevel)); Fill(Stream_Audio, 0, Audio_Codec, "APE"); Fill(Stream_Audio, 0, Audio_BitDepth, Resolution); Fill(Stream_Audio, 0, Audio_Channel_s_, Channels); Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate); Fill(Stream_Audio, 0, Audio_Duration, Duration); //No more need data File__Tags_Helper::Finish("APE"); FILLING_END(); }
//--------------------------------------------------------------------------- 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_Begin("Block Header"); if (!FromMKV) Get_L2 (version, "version"); if (version/0x100==0x4) { int32u total_samples, block_index, block_samples, flags; if (!FromMKV) { Skip_L1( "track_no"); Skip_L1( "index_no"); Get_L4 (total_samples, "total_samples"); Get_L4 (block_index, "block_index"); } 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"); Skip_Flags(flags, 11, "initial block in sequence"); Skip_Flags(flags, 12, "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_Info(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 {
//--------------------------------------------------------------------------- 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_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_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_Mpc::FileHeader_Parse() { //Parsing Element_Begin("SV7 header", 21); 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_Info(Mpc_Profile[Profile]); Get_S1 (2, Link, "Link"); Param_Info(Mpc_Link[Link]); Get_S1 (2, SampleFreq, "SampleFreq"); Param_Info(Mpc_SampleFreq[SampleFreq]); Skip_SB( "IntensityStereo"); Skip_SB( "MidSideStereo"); Skip_S1(6, "MaxBand"); BS_End(); Skip_L2( "TitlePeak"); Get_L2 (TitleGain, "TitleGain"); Param_Info(((float32)((int16s)TitleGain))/1000, 2, " dB"); Skip_L2( "AlbumPeak"); Get_L2 (AlbumGain, "AlbumGain"); Param_Info(((float32)((int16s)TitleGain))/1000, 2, " dB"); 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_Info(Encoder); Element_End(); 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_Resolution, 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_Mz::Read_Buffer_Continue() { //Parsing int32u lfanew; Element_Begin1("MZ"); Skip_C2( "magic"); Skip_L2( "cblp"); Skip_L2( "cp"); Skip_L2( "crlc"); Skip_L2( "cparhdr"); Skip_L2( "minalloc"); Skip_L2( "maxalloc"); Skip_L2( "ss"); Skip_L2( "sp"); Skip_L2( "csum"); Skip_L2( "ip"); Skip_L2( "cs"); Skip_L2( "lsarlc"); Skip_L2( "ovno"); Skip_L2( "res"); Skip_L2( "res"); Skip_L2( "res"); Skip_L2( "res"); Skip_L2( "oemid"); Skip_L2( "oeminfo"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Skip_L2( "res2"); Get_L4 (lfanew, "lfanew"); //Computing if (lfanew>Element_Offset) { Skip_XX(lfanew-Element_Offset, "MZ data"); Element_End0(); } if (Element_Offset>lfanew) { Element_End0(); Element_Offset=lfanew; //Multi usage off the first bytes } //Parsing int32u Signature, TimeDateStamp=0; int16u Machine=0, Characteristics=0; Peek_B4(Signature); if (Signature==0x50450000) //"PE" { Element_Begin1("PE"); Skip_C4( "Header"); Get_L2 (Machine, "Machine"); Param_Info1(Mz_Machine(Machine)); Skip_L2( "NumberOfSections"); Get_L4 (TimeDateStamp, "TimeDateStamp"); Param_Info1(Ztring().Date_From_Seconds_1970(TimeDateStamp)); Skip_L4( "PointerToSymbolTable"); Skip_L4( "NumberOfSymbols"); Skip_L2( "SizeOfOptionalHeader"); Get_L2 (Characteristics, "Characteristics"); Element_End0(); } FILLING_BEGIN(); Accept("MZ"); Fill(Stream_General, 0, General_Format, "MZ"); if (Characteristics&0x2000) Fill(Stream_General, 0, General_Format_Profile, "DLL"); else if (Characteristics&0x0002) Fill(Stream_General, 0, General_Format_Profile, "Executable"); Fill(Stream_General, 0, General_Format_Profile, Mz_Machine(Machine)); if (TimeDateStamp) Fill(Stream_General, 0, General_Encoded_Date, Ztring().Date_From_Seconds_1970(TimeDateStamp)); //No more need data Finish("MZ"); FILLING_END(); }