//--------------------------------------------------------------------------- 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_Exr::dataWindow () { //Parsing int32u xMin, yMin, xMax, yMax; Get_L4 (xMin, "xMin"); Get_L4 (yMin, "yMin"); Get_L4 (xMax, "xMax"); Get_L4 (yMax, "yMax"); }
//--------------------------------------------------------------------------- // 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_Bmp::Read_Buffer_Continue() { //Parsing int32u Size, DIB_Size, Offset; Element_Begin1("File header"); Skip_C2( "Magic"); Get_L4 (Size, "Size"); Skip_L2( "Reserved"); Skip_L2( "Reserved"); Get_L4 (Offset, "Offset of data"); Element_End0(); FILLING_BEGIN(); if (Size!=(int32u)-1 && Size!=File_Size) { Reject("BMP"); return; } Accept("BMP"); Fill(Stream_General, 0, General_Format, "Bitmap"); Stream_Prepare(Stream_Image); FILLING_END(); Element_Begin1("DIB header"); Peek_L4 (DIB_Size); switch (DIB_Size) { case 12 : BitmapCoreHeader(1); break; case 40 : BitmapInfoHeader(1); break; case 52 : BitmapInfoHeader(2); break; case 56 : BitmapInfoHeader(3); break; case 64 : BitmapCoreHeader(2); break; case 108 : BitmapInfoHeader(4); break; case 124 : BitmapInfoHeader(5); break; default : if (DIB_Size>124) { BitmapInfoHeader((int8u)-1); //Future versions of BitmapInfoHeader (OS/2 is abandonned) Skip_XX(14+124-Element_Offset, "Unknown"); } } Element_End0(); if (Element_Offset<Offset) Skip_XX(Offset-Element_Offset, "Other header data"); Skip_XX(File_Size-Offset, "Image data"); //No need of more Finish("BMP"); }
//--------------------------------------------------------------------------- void File_Bmp::Read_Buffer_Continue() { //Parsing int32u Size, DIB_Size, Offset; Element_Begin("File header", 14); Skip_C2( "Magic"); Get_L4 (Size, "Size"); Skip_L2( "Reserved"); Skip_L2( "Reserved"); Get_L4 (Offset, "Offset of data"); Element_End(); FILLING_BEGIN(); if (Size!=File_Size) { Reject("BMP"); return; } Accept("BMP"); Fill(Stream_General, 0, General_Format, "Bitmap"); Stream_Prepare(Stream_Image); FILLING_END(); Element_Begin("DIB header"); Peek_L4 (DIB_Size); switch (DIB_Size) { case 12 : Skip_XX(DIB_Size-4, "OS/2 v1 header"); break; case 40 : BitmapInfoHeader(); break; case 52 : Skip_XX(DIB_Size-4, "BitmapV2Header"); break; case 56 : Skip_XX(DIB_Size-4, "BitmapV3Header"); break; case 64 : Skip_XX(DIB_Size-4, "OS/2 v2 header"); break; case 108 : BitmapV4Header(); break; case 124 : Skip_XX(DIB_Size-4, "BitmapV5Header"); break; default : Skip_XX(DIB_Size-4, "Unknown header"); ; } Element_End(); Skip_XX(Offset-Element_Offset, "Color palette"); Skip_XX(Element_Size-Offset, "Bitmap data"); //No need of more Finish("BMP"); }
//--------------------------------------------------------------------------- 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::displayWindow () { //Parsing int32u xMin, yMin, xMax, yMax; Get_L4 (xMin, "xMin"); Get_L4 (yMin, "yMin"); Get_L4 (xMax, "xMax"); Get_L4 (yMax, "yMax"); //Filling if (Frame_Count==1) { Fill(StreamKind_Last, 0, "Width", xMax-xMin+1); Fill(StreamKind_Last, 0, "Height", yMax-yMin+1); } }
//--------------------------------------------------------------------------- void File_Dpx::Get_X4(int32u &Info, const char* Name) { if (LittleEndian) Get_L4 (Info, Name); else Get_B4 (Info, Name); }
//--------------------------------------------------------------------------- void File_Exr::Header_Parse() { //Header if (CC4(Buffer+Buffer_Offset)==0x762F3101) //"v/1"+1 { //Filling Header_Fill_Code(0, "File header"); Header_Fill_Size(12); return; } //Image data if (name_End==0) { //Filling Header_Fill_Code(0, "Image data"); Header_Fill_Size(ImageData_End-(File_Offset+Buffer_Offset)); return; } int32u size; Get_String(name_End, name, "name"); Element_Offset++; //Null byte Get_String(type_End, type, "type"); Element_Offset++; //Null byte Get_L4 (size, "size"); //Filling Header_Fill_Code(0, Ztring().From_Local(name.c_str())); Header_Fill_Size(name_End+1+type_End+1+4+size); }
//--------------------------------------------------------------------------- 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_Celt::Comment() { Element_Name("Comment?"); while (Element_Offset<Element_Size) { Ztring value; int32u size; Get_L4(size, "size"); if (size) Get_Local(size, value, "value"); //Filling if (value.find(__T("CELT "))!=std::string::npos) { Ztring Version=value.SubString(__T("CELT "), __T(" (")); Fill(Stream_Audio, 0, Audio_Encoded_Library, __T("CELT ")+Version); Fill(Stream_Audio, 0, Audio_Encoded_Library_Name, __T("CELT")); Fill(Stream_Audio, 0, Audio_Encoded_Library_Version, Version); } else if (!value.empty()) Fill(Stream_Audio, 0, "Comment", value); } Finish("CELT"); }
bool File_Zip::end_of_central_directory() { if (Element_Offset+22>Element_Size) //end_of_central_directory up to relative offset of .ZIP file comment length included return false; //Not enough data //Retrieving complete local_file_header size int16u zip_comment_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+20); if (Element_Offset+22+zip_comment_length>Element_Size) //end_of_central_directory all included return false; //Not enough data //Parsing int32u offset; Element_Begin1("End of central directory"); Skip_C4( "end of central dir signature"); Skip_L2( "number of this disk"); Skip_L2( "number of the disk");// with the start of the central directory Skip_L2( "total number of entries on this disk");// in the central directory Skip_L2( "total number of entries");// in the central directory Skip_L4( "size of the central directory"); Get_L4 (offset, "offset of start of central directory");// with respect to the starting disk number Skip_L2( "zip file comment length"); Skip_XX(zip_comment_length, "zip file comment"); Element_End0(); //Going to first central directory (once) if (!end_of_central_directory_IsParsed) { end_of_central_directory_IsParsed=true; GoTo(offset); } return true; }
//--------------------------------------------------------------------------- void File_Pmp::FileHeader_Parse() { //Parsing int32u version, video_format=0, nb_frames=0, video_width=0, video_height=0, time_base_num=0, time_base_den=0, audio_format=0, sample_rate=0, channels=0; Skip_C4( "Signature"); Get_L4 (version, "Version"); if (version==1) { Get_L4 (video_format, "video_format"); Get_L4 (nb_frames, "number of frames"); Get_L4 (video_width, "video_width"); Get_L4 (video_height, "video_height"); Get_L4 (time_base_num, "time_base_num"); Get_L4 (time_base_den, "time_base_den"); Skip_L4( "number of audio streams"); Get_L4 (audio_format, "audio_format"); Get_L4 (channels, "channels"); Skip_L4( "unknown"); Get_L4 (sample_rate, "sample_rate"); } FILLING_BEGIN(); Accept("PMP"); Fill(Stream_General, 0, General_Format, "PMP"); if (version==1) { Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_Format, Pmp_video_format(video_format)); Fill(Stream_Video, 0, Video_FrameCount, nb_frames); Fill(Stream_Video, 0, Video_Width, video_width); Fill(Stream_Video, 0, Video_Height, video_height); Fill(Stream_Video, 0, Video_FrameRate, (float)time_base_den / 100); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, Pmp_audio_format(audio_format)); Fill(Stream_Audio, 0, Audio_Channel_s_, channels); Fill(Stream_Audio, 0, Audio_SamplingRate, sample_rate); } //No more need data Finish("PMP"); 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_Ps2Audio::SShd() { Element_Begin1("SShd (Header)"); //Parsing int32u Size, Format, SamplingRate, Channels; Skip_C4( "ID"); Get_L4 (Size, "Size"); if (Size!=0x18) { Trusted_IsNot("Bad size"); return; } Get_L4 (Format, "Format"); Get_L4 (SamplingRate, "Sampling rate"); Get_L4 (Channels, "Channels"); Skip_L4( "Bytes per channel"); Skip_L4( "Reserved"); Skip_L4( "Reserved"); Element_End0(); FILLING_BEGIN(); Accept("PS2 Audio"); BitRate=SamplingRate*Channels*16; //Always 16 bits Stream_Prepare(Stream_Audio); Ztring FormatS; switch(Format) { case 0x00000001 : FormatS=__T("PCM"); break; case 0x00000010 : FormatS=__T("ADPCM"); break; default : ; } Fill(Stream_Audio, 0, Audio_Format, FormatS); Fill(Stream_Audio, 0, Audio_Codec, FormatS); Fill(Stream_Audio, 0, Audio_MuxingMode, "PS2"); Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate); Fill(Stream_Audio, 0, Audio_Channel_s_, Channels); Fill(Stream_Audio, 0, Audio_BitRate, BitRate); FILLING_END(); }
//--------------------------------------------------------------------------- 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_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_ApeTag::Header_Parse() { //Testing if begin or end of tags if (CC8(Buffer+Buffer_Offset)==0x4150455441474558LL) //"APETAGEX" { //Filling Header_Fill_Code((int64u)-1, "File Footer"); Header_Fill_Size(0x20); return; } //Parsing Ztring Value; int32u Flags, Length; Get_L4 (Length, "Length"); Get_L4 (Flags, "Flags"); Skip_Flags(Flags, 0, "Read Only"); Skip_Flags(Flags, 1, "Binary"); Skip_Flags(Flags, 2, "Locator of external stored information"); Skip_Flags(Flags, 29, "Is the header"); Skip_Flags(Flags, 30, "Contains a footer"); Skip_Flags(Flags, 31, "Contains a header"); size_t Pos=(size_t)Element_Offset; for (; Pos<Element_Size; Pos++) if (Buffer[Buffer_Offset+Pos]==0x00) break; if (Pos==Element_Size) { Element_WaitForMoreData(); return; } Get_String(Pos-Element_Offset, Key, "Key"); Skip_L1( "0x00"); //Filling Header_Fill_Code(0, Key.c_str()); Header_Fill_Size(Element_Offset+Length); }
//--------------------------------------------------------------------------- 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_Celt::Identification() { Element_Name("Identification"); //Parsing Ztring celt_version; int32u Celt_version_id, sample_rate, nb_channels; Skip_Local(8, "celt_codec_id"); Get_Local(20, celt_version, "celt_version"); Get_L4 (Celt_version_id, "celt_version_id"); Skip_L4( "header_size"); Get_L4 (sample_rate, "rate"); Get_L4 (nb_channels, "nb_channels"); Skip_L4( "frame_size"); Skip_L4( "overlap"); Skip_L4( "bytes_per_packet"); Skip_L4( "extra_headers"); //Filling FILLING_BEGIN() Accept("CELT"); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "CELT"); Fill(Stream_Audio, 0, Audio_Codec, "CELT"); if (!celt_version.empty()) { //Fill(Stream_Audio, 0, Audio_Encoded_Library, celt_version); //Need more info about hte different possibilities, in the meanwhile trusting more the comment part Fill(Stream_Audio, 0, Audio_SamplingRate, sample_rate); Fill(Stream_Audio, 0, Audio_Channel_s_, nb_channels); } FILLING_END(); //Filling Identification_Done=true; }
//--------------------------------------------------------------------------- void File_ApeTag::HeaderFooter() { //Parsing int32u Flags; Skip_C8( "Preamble"); Skip_L4( "Version"); Skip_L4( "Size"); Skip_L4( "Count"); Get_L4 (Flags, "Flags"); Skip_Flags(Flags, 0, "Read Only"); Skip_Flags(Flags, 1, "Binary"); Skip_Flags(Flags, 2, "Locator of external stored information"); Skip_Flags(Flags, 29, "Is the header"); Skip_Flags(Flags, 30, "Contains a footer"); Skip_Flags(Flags, 31, "Contains a header"); Skip_L8( "Reserved"); }
//--------------------------------------------------------------------------- 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_Tak::STREAMINFO() { //Parsing int32u num_samples_hi, samplerate; int8u num_samples_lo, framesizecode, samplesize; bool channels; Skip_L1 ( "unknown"); BS_Begin(); Get_S1 ( 2, num_samples_lo, "num_samples (lo)"); Get_S1 ( 3, framesizecode, "framesizecode"); Skip_S1( 2, "unknown"); BS_End(); Get_L4 (num_samples_hi, "num_samples (hi)"); Param_Info2((((int64u)num_samples_hi)<<2 | num_samples_lo), " samples"); Get_L3 (samplerate, "samplerate"); Param_Info2((samplerate/16)+6000, " Hz"); BS_Begin(); Skip_S1( 4, "unknown"); Get_SB ( channels, "channels"); Param_Info1(channels?"Stereo":"Mono"); Get_S1 ( 2, samplesize, "samplesize"); Param_Info1(Tak_samplesize[samplesize]); Skip_SB( "unknown"); BS_End(); Skip_L3( "crc"); FILLING_BEGIN() //Coherency if (samplerate==0) return; //Computing int64u Samples=((int64u)num_samples_hi)<<2 | num_samples_lo; int32u SamplingRate=(samplerate/16)+6000; //Filling File__Tags_Helper::Accept("TAK"); File__Tags_Helper::Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "TAK"); Fill(Stream_Audio, 0, Audio_Codec, "TAK"); Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate); Fill(Stream_Audio, 0, Audio_Channel_s_, channels?2:1); if (Tak_samplesize[samplesize]) Fill(Stream_Audio, 0, Audio_BitDepth, Tak_samplesize[samplesize]); Fill(Stream_Audio, 0, Audio_Duration, Samples*1000/SamplingRate); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Speex::Comment() { Element_Name("Comment?"); while (Element_Offset<Element_Size) { Ztring value; int32u size; Get_L4(size, "size"); if (size) Get_Local(size, value, "value"); //Filling if (!value.empty()) Fill(Stream_Audio, 0, "Comment", value); } Finish("Speex"); }
//--------------------------------------------------------------------------- void File_Wvpk::Header_Parse() { //Specific cases if (FromMKV) { Header_Fill_Size(Element_Size); Header_Fill_Code(0, "Block"); return; } //Parsing int32u ckSize; Skip_C4( "ckID"); Get_L4 (ckSize, "ckSize"); //Filling Header_Fill_Size(8+ckSize); Header_Fill_Code(0, "Block"); }
//--------------------------------------------------------------------------- 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_Speex::Identification() { Element_Name("Identification"); //Parsing Ztring speex_version; int32u Speex_version_id, header_size, rate, nb_channels, bitrate, vbr; Skip_Local(8, "speex_string"); Get_Local(20, speex_version, "speex_version"); Get_L4 (Speex_version_id, "Speex_version_id"); if (Speex_version_id==1) { Get_L4 (header_size, "header_size"); Get_L4 (rate, "rate"); Skip_L4( "mode"); Skip_L4( "mode_bitstream_version"); Get_L4 (nb_channels, "nb_channels"); Get_L4 (bitrate, "bitrate"); Skip_L4( "frame_size"); Get_L4 (vbr, "vbr"); Skip_L4( "frames_per_packet"); Skip_L4( "extra_headers"); Skip_L4( "reserved1"); Skip_L4( "reserved2"); if (header_size<Element_Size) Skip_XX(Element_Size-header_size, "Unknown"); //Filling FILLING_BEGIN() Accept("Speex"); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "Speex"); Fill(Stream_Audio, 0, Audio_Codec, "Speex"); if (Speex_version_id==1) { if (!speex_version.empty()) Fill(Stream_Audio, 0, Audio_Encoded_Library, speex_version); Fill(Stream_Audio, 0, Audio_SamplingRate, rate); Fill(Stream_Audio, 0, Audio_Channel_s_, nb_channels); if (bitrate!=(int32u)-1) Fill(Stream_Audio, 0, Audio_BitRate, bitrate); Fill(Stream_Audio, 0, Audio_BitRate_Mode, vbr?"VBR":"CBR"); } FILLING_END(); } //Filling Identification_Done=true; }
//--------------------------------------------------------------------------- void File_Dpg::FileHeader_Parse() { //Parsing int32u FrameCount, FrameRate, SamplingRate; Skip_C4( "Signature"); Get_L4 (FrameCount, "Frame count"); Get_L4 (FrameRate, "Frame rate"); Param_Info2(FrameRate/0x100, " fps"); Get_L4 (SamplingRate, "Sampling rate"); Skip_L4( "0x00000000"); Get_L4 (Audio_Offset, "Audio Offset"); Get_L4 (Audio_Size, "Audio Size"); Get_L4 (Video_Offset, "Video Offset"); Get_L4 (Video_Size, "Video Size"); FILLING_BEGIN(); Accept("DPG"); Fill(Stream_General, 0, General_Format, "DPG"); Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_FrameRate, (float)(FrameRate/0x100), 3); Fill(Stream_Video, 0, Video_FrameCount, FrameCount); Fill(Stream_Video, 0, Video_StreamSize, Video_Size); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate); Fill(Stream_Audio, 0, Audio_StreamSize, Audio_Size); //Positionning #if defined(MEDIAINFO_MPEGA_YES) Parser=new File_Mpega(); Open_Buffer_Init(Parser); GoTo(Audio_Offset, "DPG"); #elif defined(MEDIAINFO_MPEGV_YES) Audio_Size=0; Parser=new File_Mpegv(); Open_Buffer_Init(Parser); GoTo(Video_Offset, "DPG"); #else Finish("DPG"); #endif FILLING_END(); }
//--------------------------------------------------------------------------- void File_Exr::Header_Parse() { //Image data if (name_End==0) { //Filling Header_Fill_Code(0, "Image data"); Header_Fill_Size(ImageData_End-(File_Offset+Buffer_Offset)); return; } int32u size; Get_String(name_End, name, "name"); Element_Offset++; //Null byte Get_String(type_End, type, "type"); Element_Offset++; //Null byte Get_L4 (size, "size"); //Filling Header_Fill_Code(0, Ztring().From_ISO_8859_1(name.c_str())); Header_Fill_Size(name_End+1+type_End+1+4+size); }
//--------------------------------------------------------------------------- void File_Ps2Audio::SSbd() { if (Count_Get(Stream_Audio)!=1) { Trusted_IsNot("Element should not be here"); return; } Element_Begin1("SSbd (Body)"); int32u Size; Skip_C4( "ID"); Get_L4 (Size, "Size"); Skip_XX(Element_Size-Element_Offset, "Data (Partial)"); Element_End0(); FILLING_BEGIN(); Fill(Stream_Audio, 0, Audio_StreamSize, Size); if (BitRate) Fill(Stream_Audio, 0, Audio_Duration, ((int64u)Size)*1000*8/BitRate); Finish("PS2 Audio"); FILLING_END(); }