예제 #1
0
//---------------------------------------------------------------------------
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_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();
}
예제 #3
0
//---------------------------------------------------------------------------
// 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_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();
}
예제 #5
0
파일: File_Tga.cpp 프로젝트: 3F/FlightSDCpp
//---------------------------------------------------------------------------
void File_Tga::Tga_File_Footer()
{
    if (Version==1)
        return; //No footer

    Element_Begin1("Image/color Map Data");
    Skip_L4(                                                    "Extension Area Offset");
    Skip_L4(                                                    "Developer Directory Offset");
    Skip_Local(16,                                              "Signature");
    Skip_Local( 1,                                              "Reserved Character");
    Skip_L1(                                                    "Binary Zero String Terminator");
    Element_End0();
}
예제 #6
0
파일: File_La.cpp 프로젝트: AeonAxan/mpc-hc
//---------------------------------------------------------------------------
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();
}
예제 #7
0
//---------------------------------------------------------------------------
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();
}
예제 #8
0
//---------------------------------------------------------------------------
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();
}
예제 #9
0
//---------------------------------------------------------------------------
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();
}
예제 #10
0
//---------------------------------------------------------------------------
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();
}
예제 #11
0
//---------------------------------------------------------------------------
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);
}
예제 #12
0
//---------------------------------------------------------------------------
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();
            }
        }
    }
예제 #13
0
//---------------------------------------------------------------------------
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();
    }
}
예제 #14
0
void File_Exr::channels()
{
    //Parsing
    std::vector<Exr_channel> ChannelList;
    while (Element_Offset+1<Element_Size)
    {
        Element_Begin1("channel");

        //Name
        size_t name_Size=0;
        while (Element_Offset+name_Size<Element_Size)
        {
            if (!Buffer[Buffer_Offset+(size_t)Element_Offset+name_Size])
                break;
            name_Size++;
        }
        name_End++;

        Exr_channel Channel;
        Get_String(name_Size, Channel.name,                 "name"); Element_Info1(Channel.name);
        Element_Offset++; //Null byte
        Skip_L4(                                            "pixel type");
        Skip_L1(                                            "pLinear");
        Skip_B3(                                            "reserved");
        Get_L4 (Channel.xSampling,                          "xSampling");
        Get_L4 (Channel.ySampling,                          "ySampling");
        ChannelList.push_back(Channel);

        Element_End0();
    }

    //Color space
    /* TODO: not finished
    bool HasAlpha=false;
    string ColorSpace, ChromaSubsampling;
    if (!ChannelList.empty() && ChannelList[0].name=="A")
    {
        HasAlpha=true;
        ChannelList.erase(ChannelList.begin());
    }
    if (ChannelList.size()==1 && ChannelList[0].name=="Y")
    {
        ColorSpace="Y";
    }
    else if (ChannelList.size()==3 && ChannelList[0].name=="V" && ChannelList[1].name=="U" && ChannelList[2].name=="Y")
    {
        ColorSpace="YUV";

        //Chroma subsampling
        if (ChannelList[2].xSampling==1 && ChannelList[2].xSampling==1 && ChannelList[0].xSampling==ChannelList[1].xSampling && ChannelList[0].ySampling==ChannelList[1].ySampling)
        {
            switch (ChannelList[0].xSampling)
            {
                case 1 :
                        switch (ChannelList[0].ySampling)
                        {
                            case 1 : ChromaSubsampling="4:4:4"; break;
                            default: ;
                        }
                        break;
                case 2 :
                        switch (ChannelList[0].ySampling)
                        {
                            case 1 : ChromaSubsampling="4:2:2"; break;
                            case 2 : ChromaSubsampling="4:2:0"; break;
                            default: ;
                        }
                        break;
                case 4 :
                        switch (ChannelList[0].ySampling)
                        {
                            case 1 : ChromaSubsampling="4:1:1"; break;
                            case 2 : ChromaSubsampling="4:1:0"; break;
                            default: ;
                        }
                        break;
                default: ;
            }
        }
    }
    else if (ChannelList.size()==3 && ChannelList[0].name=="B" && ChannelList[1].name=="G" && ChannelList[2].name=="R")
    {
        ColorSpace="RGB";
    }
    else
    {
        //TODO
    }
    if (!ColorSpace.empty())
    {
        if (HasAlpha)
            ColorSpace+='A';
        Fill(StreamKind_Last, 0, "ColorSpace", ColorSpace);
    }
    if (!ChromaSubsampling.empty())
        Fill(StreamKind_Last, 0, "ChromaSubsampling", ChromaSubsampling);
    */
}
예제 #15
0
//---------------------------------------------------------------------------
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();

}
예제 #16
0
//---------------------------------------------------------------------------
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();
}
예제 #17
0
//---------------------------------------------------------------------------
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();
}
예제 #18
0
//---------------------------------------------------------------------------
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();
}
예제 #19
0
//---------------------------------------------------------------------------
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
}
예제 #20
0
//---------------------------------------------------------------------------
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_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
}