//--------------------------------------------------------------------------- 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; } }
//--------------------------------------------------------------------------- void File_Tak::ENCODERINFO() { //Parsing int8u Revision, Minor, Major, Preset_hi, Preset_lo; Get_L1 (Revision, "Revision"); Get_L1 (Minor, "Minor"); Get_L1 (Major, "Major"); BS_Begin(); Get_S1 (4, Preset_hi, "Preset (hi)"); Get_S1 (4, Preset_lo, "Preset (lo)"); BS_End(); FILLING_BEGIN(); Ztring Version=Ztring::ToZtring(Major)+__T('.')+Ztring::ToZtring(Minor)+__T('.')+Ztring::ToZtring(Revision); Ztring Preset=__T("-p")+Ztring::ToZtring(Preset_lo); switch (Preset_hi) { case 0x00 : break; case 0x01 : Preset+=__T('e'); break; case 0x02 : Preset+=__T('m'); break; default : Preset+=__T('-')+Ztring::ToZtring(Preset_hi, 16); //Unknown } Fill(Stream_Audio, 0, Audio_Encoded_Library, "TAK"); Fill(Stream_Audio, 0, Audio_Encoded_Library_String, __T("TAK ")+Version); Fill(Stream_Audio, 0, Audio_Encoded_Library_Name, "TAK"); Fill(Stream_Audio, 0, Audio_Encoded_Library_Version, Version); Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, Preset); FILLING_END(); }
//--------------------------------------------------------------------------- // 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_Rkau::FileHeader_Parse() { //Parsing Ztring version; int32u SampleRate, source_bytes; int8u Channels, BitsPerSample, Quality, Flags; bool joint_stereo, streaming, vrq_lossy_mode; Skip_Local(3, "Signature"); Get_Local (1, version, "Version"); Get_L4 (source_bytes, "SourceBytes"); Get_L4 (SampleRate, "SampleRate"); Get_L1 (Channels, "Channels"); Get_L1 (BitsPerSample, "BitsPerSample"); Get_L1 (Quality, "Quality"); Get_L1 (Flags, "Flags"); Get_Flags (Flags, 0, joint_stereo, "JointStereo"); Get_Flags (Flags, 1, streaming, "Streaming"); Get_Flags (Flags, 2, vrq_lossy_mode, "VRQLossyMode"); FILLING_BEGIN(); if (SampleRate==0) return; Duration=(((int64u)source_bytes*1000)/4)/SampleRate; if (Duration==0) return; UncompressedSize=Channels*(BitsPerSample/8); if (UncompressedSize==0) return; //Filling data File__Tags_Helper::Accept("RKAU"); File__Tags_Helper::Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "RK Audio"); Fill(Stream_Audio, 0, Audio_Codec, "Rkau"); Fill(Stream_Audio, 0, Audio_Encoded_Library, __T("1.0") + version); Fill(Stream_Audio, 0, Audio_Compression_Mode, (Quality==0)?"Lossless":"Lossy"); 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); FILLING_END(); //No more needed data File__Tags_Helper::Finish("RKAU"); }
//--------------------------------------------------------------------------- void File_Exr::FileHeader_Parse() { //Parsing int32u Flags; int8u Version; bool Deep, Multipart; Skip_L4( "Magic number"); Get_L1 (Version, "Version field"); Get_L3 (Flags, "Flags"); Skip_Flags(Flags, 0, "Single tile"); Get_Flags (Flags, 1, LongName, "Long name"); Get_Flags (Flags, 2, Deep, "Non-image"); Get_Flags (Flags, 3, Multipart, "Multipart"); //Filling if (Frame_Count==0) { Fill(Stream_General, 0, General_Format_Version, __T("Version ")+Ztring::ToZtring(Version)); Fill(StreamKind_Last, 0, "Format", "EXR"); Fill(StreamKind_Last, 0, "Format_Version", __T("Version ")+Ztring::ToZtring(Version)); Fill(StreamKind_Last, 0, "Format_Profile", (Flags&0x02)?"Tile":"Line"); if (Deep) Fill(Stream_General, 0, "Deep", "Yes"); if (Multipart) Fill(Stream_General, 0, "Multipart", "Yes"); } Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; ImageData_End=Config->File_Current_Size; }
//--------------------------------------------------------------------------- void File_Lagarith::Read_Buffer_Continue() { //Parsing int8u version; Get_L1 (version, "version"); Skip_XX(Element_Size-Element_Offset, "data"); FILLING_BEGIN(); Accept(); Fill(); switch (version) { case 0x02 : case 0x04 : Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); Fill(Stream_Video, 0, Video_BitDepth, 8); break; case 0x03 : Fill(Stream_Video, 0, Video_ColorSpace, "YUV"); Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:2"); Fill(Stream_Video, 0, Video_BitDepth, 8); break; case 0x05 : Fill(Stream_Video, 0, Video_ColorSpace, "Y"); break; case 0x06 : case 0x07 : Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); break; case 0x08 : case 0x09 : Fill(Stream_Video, 0, Video_ColorSpace, "RGBA"); break; case 0x0A : case 0x0B : Fill(Stream_Video, 0, Video_ColorSpace, "YUV"); Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:0"); Fill(Stream_Video, 0, Video_BitDepth, 8); break; default : ; } FILLING_END(); Finish(); }
//--------------------------------------------------------------------------- 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_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_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_Ogg::Header_Parse() { //Parsing int64u absolute_granule_position; int32u stream_serial_number, page_sequence_no; int16u total_page_size; int8u stream_structure_version, flags, page_segments, packet_lacing_value; Skip_C4( "capture_pattern"); Get_L1 (stream_structure_version, "stream_structure_version"); Get_L1 (flags, "header_type_flag"); Get_Flags (flags, 0, continued, "continued packet"); Skip_Flags(flags, 1, "first page of logical bitstream (bos)"); Skip_Flags(flags, 2, "last page of logical bitstream (eos)"); Get_L8 (absolute_granule_position, "absolute granule position"); Get_L4 (stream_serial_number, "stream serial number"); Get_L4 (page_sequence_no, "page sequence no"); Skip_L4( "page checksum"); Get_L1 (page_segments, "page_segments"); total_page_size=0; Chunk_Sizes.clear(); Chunk_Sizes.push_back(0); for (int8u Pos=0; Pos<page_segments; Pos++) { Get_L1 (packet_lacing_value, "packet lacing value"); total_page_size+=packet_lacing_value; Chunk_Sizes[Chunk_Sizes.size()-1]+=packet_lacing_value; if (packet_lacing_value!=0xFF) { Chunk_Sizes.push_back(0); Chunk_Sizes_Finnished=true; } else Chunk_Sizes_Finnished=false; } if (Chunk_Sizes_Finnished) Chunk_Sizes.resize(Chunk_Sizes.size()-1); //Keep out the last value //Filling Header_Fill_Size(27+page_segments+total_page_size); Header_Fill_Code(stream_serial_number, Ztring::ToZtring(stream_serial_number, 16)); Stream[stream_serial_number].absolute_granule_position=absolute_granule_position; }
//--------------------------------------------------------------------------- void File_Tak::Header_Parse() { //Parsing int32u block_length; int8u block_type; Get_L1 (block_type, "Block Type"); Get_L3 (block_length, "Block Length"); //Filling Header_Fill_Code(block_type, Ztring().From_CC1(block_type)); Header_Fill_Size(Element_Offset+block_length); }
//--------------------------------------------------------------------------- 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_Fraps::Read_Buffer_Continue() { //Parsing int8u version, flags; Get_L1 (version, "version"); Skip_L2( "unknown"); Get_L1 (flags, "flags"); if (flags&0x40) Skip_L4( "unknown"); switch (version) { case 0x00 : Version0(); break; case 0x01 : Version1(); break; case 0x02 : case 0x04 : Version2(); break; default : Skip_XX(Element_Size-Element_Offset, "data"); } Finish(); }
//--------------------------------------------------------------------------- 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_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)); }
//--------------------------------------------------------------------------- void File_Exr::Header() { //Parsing int32u Flags; int8u Version; Skip_L4( "Magic number"); Get_L1 (Version, "Version field"); Get_L3 (Flags, "Flags"); //Filling if (Frame_Count==0) { Fill(Stream_General, 0, General_Format_Version, _T("Version ")+Ztring::ToZtring(Version)); Fill(StreamKind_Last, 0, "Format", "EXR"); Fill(StreamKind_Last, 0, "Format_Version", _T("Version ")+Ztring::ToZtring(Version)); Fill(StreamKind_Last, 0, "Format_Profile", (Flags&0x02)?"Tile":"Line"); } Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; ImageData_End=File_Offset+Buffer_Offset+Config->File_Sizes[Config->File_Names_Pos-1]; }
//--------------------------------------------------------------------------- void File_Exr::compression () { //Parsing int8u value; Get_L1 (value, "value"); //Filling std::string Compression; switch (value) { case 0x00 : Compression="raw"; break; case 0x01 : Compression="RLZ"; break; case 0x02 : Compression="ZIPS"; break; case 0x03 : Compression="ZIP"; break; case 0x04 : Compression="PIZ"; break; case 0x05 : Compression="PXR24"; break; case 0x06 : Compression="B44"; break; case 0x07 : Compression="B44A"; break; default : ; } if (Frame_Count==1) Fill(StreamKind_Last, 0, "Format_Compression", Compression.c_str()); }
//--------------------------------------------------------------------------- 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_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 } } }
//--------------------------------------------------------------------------- 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_Ancillary::Read_Buffer_Continue() { if (Element_Size==0) { //Clearing old data for (size_t Pos=0; Pos<Cdp_Data.size(); Pos++) delete Cdp_Data[Pos]; //Cdp_Data[0]=NULL; Cdp_Data.clear(); for (size_t Pos=0; Pos<AfdBarData_Data.size(); Pos++) delete AfdBarData_Data[Pos]; //AfdBarData_Data[0]=NULL; AfdBarData_Data.clear(); return; } //Parsing int8u DataID, SecondaryDataID, DataCount; Get_L1 (DataID, "Data ID"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 Get_L1 (SecondaryDataID, "Secondary Data ID"); Param_Info(Ancillary_DataID(DataID, SecondaryDataID)); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 Get_L1 (DataCount, "Data count"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 //Buffer int8u* Payload=new int8u[DataCount]; for(int8u Pos=0; Pos<DataCount; Pos++) { Get_L1 (Payload[Pos], "Data"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 } //Parsing if (WithChecksum) Skip_L1( "Checksum"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 Element_End(); FILLING_BEGIN(); switch (DataID) { case 0x41 : // (from SMPTE 2016-3) switch (SecondaryDataID) { case 0x05 : //Bar Data (from SMPTE 2016-3), saving data for future use #if defined(MEDIAINFO_AFDBARDATA_YES) { buffered_data* AfdBarData=new buffered_data; AfdBarData->Data=new int8u[(size_t)DataCount]; std::memcpy(AfdBarData->Data, Payload, (size_t)DataCount); AfdBarData->Size=(size_t)DataCount; AfdBarData_Data.push_back(AfdBarData); } #endif //MEDIAINFO_AFDBARDATA_YES break; default : ; ; } break; case 0x45 : // (from SMPTE 2020-1) switch (SecondaryDataID) { case 0x01 : //No association case 0x02 : //Channel pair 1/2 case 0x03 : //Channel pair 3/4 case 0x04 : //Channel pair 5/6 case 0x05 : //Channel pair 7/8 case 0x06 : //Channel pair 9/10 case 0x07 : //Channel pair 11/12 case 0x08 : //Channel pair 13/14 case 0x09 : //Channel pair 15/16 break; default : ; ; } break; case 0x61 : //Defined data services (from SMPTE 331-1) switch (SecondaryDataID) { case 0x01 : //CDP (from SMPTE 331-1), saving data for future use #if defined(MEDIAINFO_CDP_YES) { buffered_data* Cdp=new buffered_data; Cdp->Data=new int8u[(size_t)DataCount]; std::memcpy(Cdp->Data, Payload, (size_t)DataCount); Cdp->Size=(size_t)DataCount; Cdp_Data.push_back(Cdp); } #endif //MEDIAINFO_CDP_YES break; case 0x02 : //CEA-608 (from SMPTE 331-1) #if defined(MEDIAINFO_EIA608_YES) if (DataCount==3) //This must be 3-byte data { //CEA-608 in video presentation order } #endif //MEDIAINFO_EIA608_YES break; default : ; ; } break; case 0x62 : //Variable-format data services (from SMPTE 331-1) switch (SecondaryDataID) { case 0x01 : //Program description (from SMPTE 331-1), break; case 0x02 : //Data broadcast (from SMPTE 331-1) break; case 0x03 : //VBI data (from SMPTE 331-1) break; default : ; ; } break; default : ; } FILLING_END(); delete[] Payload; //Payload=NULL }
//--------------------------------------------------------------------------- void File_ImpulseTracker::Read_Buffer_Continue() { //Parsing Ztring SongName; int16u OrdNum, InsNum, SmpNum, PatNum, Flags, Special; int8u VersionMajor, VersionMinor, SoftwareVersionMajor, SoftwareVersionMinor, IS, TS; bool Stereo; Skip_B4( "Signature"); Get_Local(26, SongName, "Song name"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Get_L2 (OrdNum, "Orders count"); Get_L2 (InsNum, "Instruments count"); Get_L2 (SmpNum, "Samples count"); Get_L2 (PatNum, "Paterns count"); Get_L1 (SoftwareVersionMinor, "Cwt/v (Minor)"); Get_L1 (SoftwareVersionMajor, "Cwt/v (Major)"); Get_L1 (VersionMinor, "Cwt (Minor)"); Get_L1 (VersionMajor, "Cwt (Major)"); Get_L2 (Flags, "Flags"); Get_Flags (Flags, 0, Stereo, "Stereo"); Skip_Flags(Flags, 1, "Vol0MixOptimizations"); Skip_Flags(Flags, 2, "Use instruments/Samples"); Skip_Flags(Flags, 3, "Linear/Amiga slides"); Skip_Flags(Flags, 4, "Old/IT Effects"); Get_L2 (Special, "Special"); Skip_Flags(Special, 0, "Song Message attached"); Skip_L1( "Global volume"); Skip_L1( "Mix volume"); Get_L1 (IS, "Initial Speed"); Get_L1 (TS, "Initial Temp"); Skip_L1( "Panning separation between channels"); Skip_L1( "0"); Skip_L2( "Message Length"); Skip_L4( "Message Offset"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_XX(64, "Chnl Pan"); Skip_XX(64, "Chnl Vol"); Skip_XX(OrdNum, "Orders"); Skip_XX(InsNum*4, "Instruments"); Skip_XX(SmpNum*4, "Samples"); Skip_XX(PatNum*4, "Patterns"); FILLING_BEGIN(); Stream_Prepare(Stream_General); Fill(Stream_General, 0, General_Format, "Impulse Tracker"); Fill(Stream_General, 0, General_Format_Version, Ztring(_T("Version "))+Ztring::ToZtring(VersionMajor)+_T(".")+Ztring::ToZtring(VersionMinor/16)+Ztring::ToZtring(VersionMinor%16)); Fill(Stream_General, 0, General_Track, SongName); Fill(Stream_General, 0, General_Encoded_Application, Ztring(_T("Impulse Tracker ")+Ztring::ToZtring(SoftwareVersionMajor)+_T(".")+Ztring::ToZtring(SoftwareVersionMinor/16)+Ztring::ToZtring(SoftwareVersionMinor%16))); Fill(Stream_General, 0, "BPM", TS); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Stereo?2:1); Accept("Impulse Tracker"); Finish("Impulse Tracker"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Ogg::Header_Parse() { //Specific case if (SizedBlocks) { int16u Size; Get_B2 (Size, "Size"); Chunk_Sizes.clear(); Chunk_Sizes.push_back(Size); Header_Fill_Size(2+Size); Header_Fill_Code(0, Ztring::ToZtring(0, 16)); return; } if (XiphLacing) { if (Chunk_Sizes.empty()) { int8u CountMinus1; Get_B1 (CountMinus1, "Number of frames minus one"); int64u UsedSize=0; for (size_t Pos=0; Pos<CountMinus1; Pos++) { int32u Size=0; int8u Size8; do { Get_B1 (Size8, "Size"); Size+=Size8; } while (Size8==0xFF); Param_Info1(Size); Chunk_Sizes.push_back(Size); UsedSize+=Size; } Chunk_Sizes.push_back((size_t)(Element_Size-UsedSize-1)); } Header_Fill_Size(Element_Size); Header_Fill_Code(0, Ztring::ToZtring(0, 16)); return; } //Parsing int64u absolute_granule_position; int32u stream_serial_number, page_sequence_no; int16u total_page_size; int8u stream_structure_version, flags, page_segments, packet_lacing_value; Skip_C4( "capture_pattern"); Get_L1 (stream_structure_version, "stream_structure_version"); Get_L1 (flags, "header_type_flag"); Get_Flags (flags, 0, continued, "continued packet"); Skip_Flags(flags, 1, "first page of logical bitstream (bos)"); Get_Flags (flags, 2, eos, "last page of logical bitstream (eos)"); Get_L8 (absolute_granule_position, "absolute granule position"); Get_L4 (stream_serial_number, "stream serial number"); Get_L4 (page_sequence_no, "page sequence no"); Skip_L4( "page checksum"); Get_L1 (page_segments, "page_segments"); total_page_size=0; Chunk_Sizes.clear(); Chunk_Sizes.push_back(0); for (int8u Pos=0; Pos<page_segments; Pos++) { Get_L1 (packet_lacing_value, "packet lacing value"); total_page_size+=packet_lacing_value; Chunk_Sizes[Chunk_Sizes.size()-1]+=packet_lacing_value; if (packet_lacing_value!=0xFF) { Chunk_Sizes.push_back(0); Chunk_Sizes_Finished=true; } else Chunk_Sizes_Finished=false; } if (Chunk_Sizes_Finished) Chunk_Sizes.resize(Chunk_Sizes.size()-1); //Keep out the last value //Filling Header_Fill_Size(27+page_segments+total_page_size); Header_Fill_Code(stream_serial_number, Ztring::ToZtring(stream_serial_number, 16)); Stream[stream_serial_number].absolute_granule_position=absolute_granule_position; }
//--------------------------------------------------------------------------- void File_ScreamTracker3::Read_Buffer_Continue() { //Parsing Ztring SongName; int16u OrdNum, InsNum, PatNum, Flags, Special; int8u SoftwareVersionMajor, SoftwareVersionMinor, IS, TS; Get_Local(28, SongName, "Song name"); Skip_L1( "0x1A"); Skip_L1( "Type"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Get_L2 (OrdNum, "Orders count"); Get_L2 (InsNum, "Instruments count"); Get_L2 (PatNum, "Paterns count"); Get_L2 (Flags, "Flags"); Skip_Flags(Flags, 0, "st2vibrato"); Skip_Flags(Flags, 1, "st2tempo"); Skip_Flags(Flags, 2, "amigaslides"); Skip_Flags(Flags, 3, "0vol optimizations"); Skip_Flags(Flags, 4, "amiga limits"); Skip_Flags(Flags, 5, "enable filter/sfx with sb"); Skip_Flags(Flags, 6, "st3.00 volumeslides"); Skip_Flags(Flags, 7, "pecial custom data in file"); Get_L1 (SoftwareVersionMajor, "Cwt/v (Major)"); Get_L1 (SoftwareVersionMinor, "Cwt/v (Minor)"); Skip_L2( "File format information"); Skip_B4( "Signature"); Skip_L1( "global volume"); Get_L1 (IS, "Initial Speed"); Get_L1 (TS, "Initial Temp"); Skip_L1( "master volume"); Skip_L1( "ultra click removal"); Skip_L1( "Default channel pan positions are present"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Skip_L1( "Unknown"); Get_L2 (Special, "Special"); Skip_XX(32, "Channel settings"); Skip_XX(OrdNum, "Orders"); Skip_XX(InsNum*2, "Instruments"); Skip_XX(PatNum*2, "Patterns"); FILLING_BEGIN(); Accept("Scream Tracker 3"); Fill(Stream_General, 0, General_Format, "Scream Tracker 3"); Fill(Stream_General, 0, General_Track, SongName); if ((SoftwareVersionMajor&0xF0)==0x10) Fill(Stream_General, 0, General_Encoded_Application, Ztring(__T("Scream Tracker ")+Ztring::ToZtring(SoftwareVersionMajor)+__T(".")+Ztring::ToZtring(SoftwareVersionMinor/16)+Ztring::ToZtring(SoftwareVersionMinor%16))); Fill(Stream_General, 0, "BPM", TS); Stream_Prepare(Stream_Audio); Finish("Scream Tracker 3"); 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_Ancillary::Read_Buffer_Continue() { if (!Cdp_Data.empty() && AspectRatio && FrameRate) { ((File_Cdp*)Cdp_Parser)->AspectRatio=AspectRatio; for (size_t Pos=0; Pos<Cdp_Data.size(); Pos++) { if (Cdp_Parser->PTS_DTS_Needed) Cdp_Parser->FrameInfo.DTS=FrameInfo.DTS-(Cdp_Data.size()-Pos)*FrameInfo.DUR; Open_Buffer_Continue(Cdp_Parser, Cdp_Data[Pos]->Data, Cdp_Data[Pos]->Size); delete Cdp_Data[Pos]; //Cdp_Data[0]=NULL; } Cdp_Data.clear(); } if (Element_Size==0) { //Keeping only one, TODO: parse it without video stream for (size_t Pos=1; Pos<AfdBarData_Data.size(); Pos++) delete AfdBarData_Data[Pos]; //AfdBarData_Data[0]=NULL; if (!AfdBarData_Data.empty()) AfdBarData_Data.resize(1); return; } if (!Status[IsAccepted]) Accept(); //Parsing int8u DataID, SecondaryDataID, DataCount; Get_L1 (DataID, "Data ID"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 Get_L1 (SecondaryDataID, "Secondary Data ID"); Param_Info(Ancillary_DataID(DataID, SecondaryDataID)); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 Get_L1 (DataCount, "Data count"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 //Buffer int8u* Payload=new int8u[DataCount]; for(int8u Pos=0; Pos<DataCount; Pos++) { Get_L1 (Payload[Pos], "Data"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 } //Parsing if (WithChecksum) Skip_L1( "Checksum"); if (WithTenBit) Skip_L1( "Parity+Unused"); //even:1, odd:2 Element_End(); FILLING_BEGIN(); switch (DataID) { case 0x41 : // (from SMPTE 2016-3) switch (SecondaryDataID) { case 0x05 : //Bar Data (from SMPTE 2016-3), saving data for future use #if defined(MEDIAINFO_AFDBARDATA_YES) { buffered_data* AfdBarData=new buffered_data; AfdBarData->Data=new int8u[(size_t)DataCount]; std::memcpy(AfdBarData->Data, Payload, (size_t)DataCount); AfdBarData->Size=(size_t)DataCount; AfdBarData_Data.push_back(AfdBarData); } #endif //MEDIAINFO_AFDBARDATA_YES break; default : ; ; } break; case 0x45 : // (from SMPTE 2020-1) switch (SecondaryDataID) { case 0x01 : //No association case 0x02 : //Channel pair 1/2 case 0x03 : //Channel pair 3/4 case 0x04 : //Channel pair 5/6 case 0x05 : //Channel pair 7/8 case 0x06 : //Channel pair 9/10 case 0x07 : //Channel pair 11/12 case 0x08 : //Channel pair 13/14 case 0x09 : //Channel pair 15/16 break; default : ; ; } break; case 0x61 : //Defined data services (from SMPTE 331-1) switch (SecondaryDataID) { case 0x01 : //CDP (from SMPTE 331-1) #if defined(MEDIAINFO_CDP_YES) { if (Cdp_Parser==NULL) { Cdp_Parser=new File_Cdp; Open_Buffer_Init(Cdp_Parser); } Demux(Payload, (size_t)DataCount, ContentType_MainStream); if (AspectRatio && FrameRate) { if (!Cdp_Parser->Status[IsFinished]) { if (Cdp_Parser->PTS_DTS_Needed) Cdp_Parser->FrameInfo.DTS=FrameInfo.DTS; ((File_Cdp*)Cdp_Parser)->AspectRatio=AspectRatio; Open_Buffer_Continue(Cdp_Parser, Payload, (size_t)DataCount); } } else { //Saving data for future use buffered_data* Cdp=new buffered_data; Cdp->Data=new int8u[(size_t)DataCount]; std::memcpy(Cdp->Data, Payload, (size_t)DataCount); Cdp->Size=(size_t)DataCount; Cdp_Data.push_back(Cdp); } } #endif //MEDIAINFO_CDP_YES break; case 0x02 : //CEA-608 (from SMPTE 331-1) #if defined(MEDIAINFO_EIA608_YES) if (DataCount==3) //This must be 3-byte data { //CEA-608 in video presentation order } #endif //MEDIAINFO_EIA608_YES break; default : ; ; } break; case 0x62 : //Variable-format data services (from SMPTE 331-1) switch (SecondaryDataID) { case 0x01 : //Program description (from SMPTE 331-1), break; case 0x02 : //Data broadcast (from SMPTE 331-1) break; case 0x03 : //VBI data (from SMPTE 331-1) break; default : ; ; } break; default : ; } FILLING_END(); delete[] Payload; //Payload=NULL }
//--------------------------------------------------------------------------- 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(); }