Esempio n. 1
0
//---------------------------------------------------------------------------
// Packet "B3" or "B6"
void File_AvsV::picture_start()
{
    //Counting
    if (File_Offset+Buffer_Offset+Element_Size==File_Size)
        Frame_Count_Valid=Frame_Count; //Finalize frames in case of there are less than Frame_Count_Valid frames
    Frame_Count++;

    //Name
    Element_Name("picture_start");
    Element_Info1(Ztring::ToZtring(Frame_Count));
    Element_Info1C((Element_Code==0xB3), __T("I"));

    //Parsing
    int8u picture_coding_type=(int8u)-1;
    bool time_code_flag, progressive_frame, picture_structure=true, top_field_first, repeat_first_field, skip_mode_flag=false, loop_filter_disable;
    Skip_B2(                                                    "bbv_delay");
    BS_Begin();
    if (Element_Code==0xB3) //Only I
    {
        Get_SB (    time_code_flag,                             "time_code_flag");
        if (time_code_flag)
        {
            Skip_SB(                                            "time_code_dropframe");
            Skip_S1(5,                                          "time_code_hours");
            Skip_S1(6,                                          "time_code_minutes");
            Skip_S1(6,                                          "time_code_seconds");
            Skip_S1(6,                                          "time_code_pictures");
        }
    }
    if (Element_Code==0xB6) //Only P or B
    {
        Get_S1 ( 2, picture_coding_type,                        "picture_coding_type"); Element_Info1(AvsV_picture_coding_type[picture_coding_type]);
    }
    Skip_S1( 8,                                                 "picture_distance");
    if (low_delay)
        Skip_UE(                                                "bbv_check_times");
    Get_SB (    progressive_frame,                              "progressive_frame");
    if (!progressive_frame)
    {
        Get_SB(    picture_structure,                           "picture_structure");
        if (Element_Code==0xB6) //Only P or B
        {
            if (picture_structure)
                Skip_SB(                                        "advanced_pred_mode_disable");
        }
    }
    Get_SB (    top_field_first,                                "top_field_first");
    Get_SB (    repeat_first_field,                             "repeat_first_field");
    Skip_SB(                                                    "fixed_picture_qp");
    Skip_S1( 6,                                                 "picture_qp");
    if (Element_Code==0xB3) //Only I
    {
        if (!progressive_frame && !picture_structure)
            Get_SB(    skip_mode_flag,                          "skip_mode_flag");
    }
    if (Element_Code==0xB6) //Only P or B
    {
        if (picture_coding_type!=2 || !picture_structure)
            Skip_SB(                                            "picture_reference_flag");
    }
    Skip_SB(                                                    "reserved");
    Skip_SB(                                                    "reserved");
    Skip_SB(                                                    "reserved");
    Skip_SB(                                                    "reserved");
    if (Element_Code==0xB6) //Only P or B
    {
        Get_SB(    skip_mode_flag,                              "skip_mode_flag");
    }
    Get_SB (    loop_filter_disable,                            "loop_filter_disable");
    if (!loop_filter_disable)
    {
        bool loop_filter_parameter_flag;
        Get_SB (    loop_filter_parameter_flag,                 "loop_filter_parameter_flag");
        if (loop_filter_parameter_flag)
        {
            Skip_SE(                                            "alpha_c_offset");
            Skip_SE(                                            "beta_offset");
        }
    }
    BS_End();

    if (Element_Size-Element_Offset)
        Skip_XX(Element_Size-Element_Offset,                    "Unknown");

    FILLING_BEGIN();
        if (progressive_frame==false)
        {
            if (picture_structure==true)           //Frame
            {
                if (top_field_first)
                    Interlaced_Top++;
                else
                    Interlaced_Bottom++;
            }
        }
        else
            progressive_frame_Count++;

        //NextCode
        NextCode_Test();
        NextCode_Clear();
        for (int8u Pos=0x00; Pos<=0xAF; Pos++)
            NextCode_Add(Pos); //slice
        NextCode_Add(0xB0); //video_sequence_start
        NextCode_Add(0xB3); //picture_start
        NextCode_Add(0xB6); //picture_start

        //Autorisation of other streams
        for (int8u Pos=0x00; Pos<=0xAF; Pos++)
            Streams[Pos].Searching_Payload=true; //slice

        //Filling only if not already done
        if (Frame_Count>=Frame_Count_Valid && Count_Get(Stream_Video)==0)
        {
            //No need of more
            Accept("AVS Video");
            Finish("AVS Video");
        }
    FILLING_END();
}
Esempio n. 2
0
//---------------------------------------------------------------------------
void File_Flic::FileHeader_Parse()
{
    //Parsing
    int32u DelayBetweenFrames;
    int16u Type, Frames, Width, Height, BitsPerPixel, AspectX=0, AspectY=0;
    Skip_L4(                                                    "Size of FLIC including this header");
    Get_L2 (Type,                                               "File type");
    Get_L2 (Frames,                                             "Number of frames in first segment");
    Get_L2 (Width,                                              "Width");
    Get_L2 (Height,                                             "Height");
    Get_L2 (BitsPerPixel,                                       "Bits per pixel");
    Skip_L2(                                                    "Flags");
    Get_L4 (DelayBetweenFrames,                                 "Delay between frames");
    if (Type!=0xAF11)
    {
        Skip_L2(                                                "Reserved");
        Skip_L4(                                                "Date of Creation)");
        Skip_L4(                                                "Serial number or compiler id");
        Skip_L4(                                                "Date of FLIC update");
        Skip_L4(                                                "Serial number");
        Get_L2 (AspectX,                                        "Width of square rectangle");
        Get_L2 (AspectY,                                        "Height of square rectangle");
    }
    else
        Skip_XX(22,                                             "Reserved");
    Skip_L2(                                                    "EGI: flags for specific EGI extensions");
    Skip_L2(                                                    "EGI: key-image frequency");
    Skip_L2(                                                    "EGI: total number of frames (segments)");
    Skip_L4(                                                    "EGI: maximum chunk size (uncompressed)");
    Skip_L2(                                                    "EGI: max. number of regions in a CHK_REGION chunk");
    Skip_L2(                                                    "EGI: number of transparent levels");
    if (Type!=0xAF11)
    {
        Skip_XX(24,                                             "Reserved");
        Skip_L4(                                                "Offset to frame 1");
        Skip_L4(                                                "Offset to frame 2");
        Skip_XX(40,                                             "Reserved");
    }
    else
        Skip_XX(72,                                             "Reserved");

    //Filling
    FILLING_BEGIN();
        switch (Type)
        {
            case 0xAF11 :
            case 0xAF12 :
            case 0xAF30 :
            case 0xAF31 :
            case 0xAF44 :
                            break;
            default     :
                            Reject("FLIC");
                            return;
        }

        //Filling
        Accept("FLIC");

        Fill(Stream_General, 0, General_Format, "FLIC");

        Stream_Prepare(Stream_Video);
        if (Type==0xAF11)
        {
            Fill(Stream_Video, 0, Video_Format, "FLI");
            Fill(Stream_Video, 0, Video_Codec, "FLI");
            if (DelayBetweenFrames)
            {
                Fill(Stream_Video, StreamPos_Last, Video_FrameRate, 1000.0/(DelayBetweenFrames*70)); //multiple of 1/70 per frame
                Fill(Stream_Video, 0, Video_Duration, Frames*DelayBetweenFrames*70);
            }
        }
        else
        {
            Fill(Stream_Video, 0, Video_Format, "FLC");
            Fill(Stream_Video, 0, Video_Codec, "FLC");
            if (DelayBetweenFrames)
            {
                Fill(Stream_Video, StreamPos_Last, Video_FrameRate, 1000.0/DelayBetweenFrames); //ms per frame
                Fill(Stream_Video, 0, Video_Duration, Frames*DelayBetweenFrames);
            }
            if (AspectY>0)
                Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, AspectX/AspectY, 3, true);
        }
        Fill(Stream_Video, 0, Video_FrameCount, Frames);
        Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
        Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
        Fill(Stream_Video, 0, Video_BitDepth, (BitsPerPixel%3)?BitsPerPixel:(BitsPerPixel/3), 10, true); //If not a multiple of 3, the total resolution is filled
        //No more need data
        Finish("FLIC");
    FILLING_END();
}
Esempio n. 3
0
//---------------------------------------------------------------------------
void File_DvbSubtitle::CLUT_definition_segment()
{
    Element_Name("CLUT definition segment");

    Skip_XX(Element_Size,                                       "Data");
}
Esempio n. 4
0
//---------------------------------------------------------------------------
void File_Jpeg::QCD()
{
    //Parsing
    Skip_B1(                                                    "Sqcd - Style");
    Skip_XX(Element_Size-Element_Offset,                        "QCD data");
}
Esempio n. 5
0
//---------------------------------------------------------------------------
void File_Dirac::Reserved()
{
    Element_Name("Reserved");

    Skip_XX(Element_Size,                                       "Unknown");
}
//---------------------------------------------------------------------------
void File_DvbSubtitle::reserved_for_future_use()
{
    Element_Name("reserved for future use");

    Skip_XX(Element_Size,                                       "Data");
}
//---------------------------------------------------------------------------
void File_DvbSubtitle::private_data()
{
    Element_Name("private data");

    Skip_XX(Element_Size,                                       "Data");
}
Esempio n. 8
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();

}
Esempio n. 9
0
//---------------------------------------------------------------------------
void File_Ivf::FileHeader_Parse()
{
    //Parsing
    int32u frame_rate_num, frame_rate_den, frame_count, fourcc;
    int16u version, header_size, width, height;

    Skip_C4 (                                                   "Signature");
    Get_L2 (version,                                            "Version");
    if (version==0)
    {
        Get_L2 (header_size,                                    "Header Size");
        if (header_size>=32)
        {
            Get_C4 (fourcc,                                     "Fourcc");
            Get_L2 (width,                                      "Width");
            Get_L2 (height,                                     "Height");
            Get_L4 (frame_rate_num,                             "FrameRate Numerator");
            Get_L4 (frame_rate_den,                             "FrameRate Denominator");
            Get_L4 (frame_count,                                "Frame Count");
            Skip_L4(                                            "Unused");
            if (header_size-32)
                Skip_XX(header_size-32,                         "Unknown");
        }
        else
        {
            fourcc=0x00000000;
            width=0;
            height=0;
            frame_rate_num=0;
            frame_rate_den=0;
            frame_count=0;
        }
    }
    else
    {
        header_size=0;
        fourcc=0x00000000;
        width=0;
        height=0;
        frame_rate_num=0;
        frame_rate_den=0;
        frame_count=0;
    }

    FILLING_BEGIN();
        Accept("IVF");

        Fill(Stream_General, 0, General_Format, "IVF");

        if (version==0 && header_size>=32)
        {
            Stream_Prepare(Stream_Video);
            CodecID_Fill(Ztring().From_CC4(fourcc), Stream_Video, 0, InfoCodecID_Format_Riff);
            Fill(Stream_Video, 0, Video_FrameRate, (float)frame_rate_num / frame_rate_den);
            Fill(Stream_Video, 0, Video_FrameCount, frame_count);
            Fill(Stream_Video, 0, Video_Width, width);
            Fill(Stream_Video, 0, Video_Height, height);
            Fill(Stream_Video, 0, Video_StreamSize, File_Size-header_size-12*frame_count); //Overhead is 12 byte per frame
        }

        //No more need data
        Finish("IVF");
    FILLING_END();
}
Esempio n. 10
0
//---------------------------------------------------------------------------
// Packet "0D"
void File_Vc1::FrameHeader()
{
    //Counting
    if (File_Offset+Buffer_Offset+Element_Size==File_Size)
        Frame_Count_Valid=Frame_Count; //Finalize frames in case of there are less than Frame_Count_Valid frames
    Frame_Count++;
    Frame_Count_InThisBlock++;

    //Name
    Element_Name("FrameHeader");
    Element_Info(Ztring(_T("Frame ")+Ztring::ToZtring(Frame_Count)));

    //Parsing
    BS_Begin();
    int8u ptype;
    if (profile==3) //Advanced
    {
        int8u PictureFormat=0; //Default=Progressive frame
        if (interlace)
        {
            bool fcm_1;
            Get_SB (   fcm_1,                                   "fcm_1");
            if (fcm_1)
            {
                bool fcm_2;
                Get_SB (   fcm_2,                               "fcm_2");
                PictureFormat=fcm_2?2:1; //Interlaced Field : Interlaced Frame
            }
        }
        Param_Info(Vc1_PictureFormat[PictureFormat]);
        PictureFormat_Count[PictureFormat]++;

        if (PictureFormat==2) //Interlaced Field
        {
            int8u ptype_;
            Get_S1 ( 3, ptype_,                                 "ptype");
            if (ptype_<5)
            {
                Param_Info(Vc1_Type[Vc1_FieldTypeTable[ptype_][0]]); Element_Info(Vc1_Type[Vc1_FieldTypeTable[ptype_][0]]); //First field
                Param_Info(Vc1_Type[Vc1_FieldTypeTable[ptype_][1]]); Element_Info(Vc1_Type[Vc1_FieldTypeTable[ptype_][1]]); //Second field
                ptype=Vc1_FieldTypeTable[ptype_][0]; //Saving the ptype from the first field
            }
            else
            {
                Trusted_IsNot("ptype is out of range");
                ptype=0; //Error
            }
        }
        else
        {
            int32u ptype_;
            Get_VL (Vc1_ptype, ptype_,                          "ptype"); if (ptype_<5) {Param_Info(Vc1_Type[(size_t)ptype_]); Element_Info(Vc1_Type[(size_t)ptype_]);}
            ptype=(int8u)ptype_;
        }

        if (ptype!=4) //!=Skipping
        {
            if (tfcntrflag)
            {
                Skip_S1( 8,                                     "tfcntr - frame counter");
            }
        }

        if (interlace && !psf)
        {
            bool tff=true, rff=false;
            if (pulldown)
            {
                Get_SB (tff,                                    "tff - top field first");
                Get_SB (rff,                                    "rff - repeat first field");
                if (tff)
                    Interlaced_Top++;
                else
                    Interlaced_Bottom++;

                if (TemporalReference.size()<30)
                {
                    if (ptype!=2 && ptype!=3  //if not B and BI-frame
                     && !TemporalReference_Waiting.empty()) //We must have 2 I or P pictures to be sure not having B picture later
                    {
                        //We have 2 I or P pictures
                        for (size_t Pos=1; Pos<TemporalReference_Waiting.size(); Pos++) //All B frames (not the first frame, which is I or P)
                        {
                            TemporalReference_Offset++;
                            TemporalReference[TemporalReference_Offset]=TemporalReference_Waiting[Pos];
                        }
                        TemporalReference_Offset++;
                        TemporalReference[TemporalReference_Offset]=TemporalReference_Waiting[0];
                        TemporalReference_Waiting.clear();
                    }

                    //We must wait for having another I or P picture
                    temporalreference Temp;
                    Temp.top_field_first=tff;
                    Temp.repeat_first_field=rff;
                    TemporalReference_Waiting.push_back(Temp);
                }

            }
        }
        else
        {
            int8u rptfrm=0;
            if (pulldown)
            {
                Get_S1 ( 2, rptfrm,                             "rptfrm - repeate frame");
            }
        }

        /*
        if (panscan_flag)
        {
            //TODO
        }

        if (ptype!=4) //!=Skipping
        {
                bool rndctrl;
            Get_SB(    rndctrl,                                 "rndctrl - rounding control");
            if (rndctrl && (ptype==0 || ptype==3)) //I or BI type
                Trusted_IsNot("Should not be true!");

            if (interlace)
                Skip_SB(                                        "uvsamp - uv sampling mode");

            if (finterpflag && PictureFormat==0) //Progressive frame
                Skip_SB(                                        "interrpfrm");

            if (PictureFormat!=1) //!=Interlaced frame
            {
                if (ptype==2 //Type B
                 || (ptype==3 && PictureFormat==2)) //Type BI and Interlaced field
                    Skip_VL(Vc1_bfraction,                      "bfraction");
            }
        }
        */
    }
    BS_End();
    if (Element_Size-Element_Offset)
        Skip_XX(Element_Size-Element_Offset,                    "Data");

    FILLING_BEGIN();
        //NextCode
        NextCode_Test();
        NextCode_Clear();
        NextCode_Add(0x0D);
        NextCode_Add(0x0F);

        //Filling only if not already done
        if (!IsFilled && Frame_Count>=Frame_Count_Valid)
            FrameHeader_Fill();

        //Autorisation of other streams
        Streams[0x0D].Searching_Payload=true;
        Streams[0x0F].Searching_Payload=true;
    FILLING_END();
}
Esempio n. 11
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_Begin1("Block Header");
    if (!FromMKV)
        Get_L2 (version,                                        "version");
    if (version/0x100==0x4)
    {
        while (Element_Offset<Element_Size)
        {
            int32u total_samples=(int32u)-1, block_index=(int32u)-1, block_samples=0, flags, blocksize=(int32u)-1;
            bool initial_block=true, final_block=true;
            if (!FromMKV)
            {
                Skip_L1(                                            "track_no");
                Skip_L1(                                            "index_no");
                Get_L4 (total_samples,                              "total_samples");
                Get_L4 (block_index,                                "block_index");
            }
            if (!FromMKV || Element_Offset==0)
                Get_L4 (block_samples,                              "block_samples");
            if (block_samples!=0) //empty frames have other values empty
            {
                if (!FromMKV)
                {
                    if (block_index==0) //Only the frame with block_index==0
                        total_samples_FirstFrame=total_samples; //Note: total_samples is not trustable for a cutted file
                    if (Frame_Count==1)
                        block_index_FirstFrame=block_index; //Save the block_index of the first block
                    block_index_LastFrame=block_index;
                    block_samples_LastFrame=block_samples;
                }
                Get_L4 (flags,                                      "flags");
                    Get_Flags (flags,  0, resolution0,              "resolution0");
                    Get_Flags (flags,  1, resolution1,              "resolution1");
                    Get_Flags (flags,  2, mono,                     "mono");
                    Get_Flags (flags,  3, hybrid,                   "hybrid");
                    Get_Flags (flags,  4, joint_stereo,             "joint stereo");
                    Get_Flags (flags,  5, cross_channel_decorrelation, "cross-channel decorrelation");
                    Skip_Flags(flags,  6,                           "hybrid noise shaping");
                    Skip_Flags(flags,  7,                           "floating point data");
                    Skip_Flags(flags,  8,                           "extended size integers");
                    Skip_Flags(flags,  9,                           "hybrid mode parameters control bitrate");
                    Skip_Flags(flags, 10,                           "hybrid noise balanced between channels");
                    Get_Flags (flags, 11, initial_block,            "initial block in sequence");
                    Get_Flags (flags, 12, final_block,              "final block in sequence");
                    Skip_Flags(flags, 13,                           "amount of data left-shift after decode");
                    Skip_Flags(flags, 14,                           "amount of data left-shift after decode");
                    Skip_Flags(flags, 15,                           "amount of data left-shift after decode");
                    Skip_Flags(flags, 16,                           "amount of data left-shift after decode");
                    Skip_Flags(flags, 17,                           "amount of data left-shift after decode");
                    Skip_Flags(flags, 18,                           "maximum magnitude of decoded data");
                    Skip_Flags(flags, 19,                           "maximum magnitude of decoded data");
                    Skip_Flags(flags, 20,                           "maximum magnitude of decoded data");
                    Skip_Flags(flags, 21,                           "maximum magnitude of decoded data");
                    Skip_Flags(flags, 22,                           "maximum magnitude of decoded data");
                    Skip_Flags(flags, 23,                           "sampling rate");
                    Skip_Flags(flags, 24,                           "sampling rate");
                    Skip_Flags(flags, 25,                           "sampling rate");
                    Skip_Flags(flags, 26,                           "sampling rate"); SamplingRate=(int8u)(((flags>>23)&0xF)); Param_Info1(Wvpk_SamplingRate[SamplingRate]);
                    Skip_Flags(flags, 27,                           "reserved");
                    Skip_Flags(flags, 28,                           "reserved");
                    Skip_Flags(flags, 29,                           "use IIR for negative hybrid noise shaping");
                    Skip_Flags(flags, 30,                           "false stereo");
                    Skip_Flags(flags, 31,                           "reserved");
            }
            else
            {
                Skip_L4(                                            "flags (empty)");

                //Counting
                Frame_Count--; //This is not a real frame
            }
            Skip_L4(                                                "crc");
            Element_End0();

            int64u End=Element_Size;
            if (FromMKV && !(initial_block && final_block))
            {
                Get_L4 (blocksize,                                  "blocksize");
                End=Element_Offset+blocksize;
                if (End>=Element_Size)
                    End=Element_Size;
            }

            //Sub-block
            int8u id;
            while (Element_Offset<End)
            {
                Element_Begin0();
                int32u word_size;
                bool large, odd_size;
                BS_Begin();
                Get_SB (large,                                      "large");
                Get_SB (odd_size,                                   "odd_size");
                Get_S1 (6, id,                                      "id"); Element_Info1(Wvpk_id(id));
                BS_End();
                if (large)
                {
                    Get_L3 (word_size,                              "word_size");
                }
                else
                {
                    int8u word_size1;
                    Get_L1 (word_size1,                             "word_size");
                    word_size=word_size1;
                }
                if (word_size==0 && odd_size)
                    Size=0; //Problem!
                else
                    Size=word_size*2-(odd_size?1:0);
                Element_Name(Ztring().From_CC1(id));
                switch (id)
                {
                    case 0x07 : id_07(); break;
                    case 0x0D : id_0D(); break;
                    case 0x25 : id_25(); break;
                    default   : if (word_size)
                                    Skip_XX(Size,                   "data");
                }
                if (odd_size)
                    Skip_XX(1,                                      "padding");
                Element_End0();
            }
        }
    }
Esempio n. 12
0
//---------------------------------------------------------------------------
void File_ProRes::Read_Buffer_Continue()
{
    //Parsing
    int32u  Name, creatorID;
    int16u  hdrSize, version, frameWidth, frameHeight;
    int8u   chrominance_factor, frame_type, primaries, transf_func, colorMatrix, alpha_info;
    bool    IsOk=true, luma, chroma;
    Element_Begin1("Header");
        Skip_B4(                                                "Size");
        Get_C4 (Name,                                           "Name");
    Element_End();
    Element_Begin1("Frame header");
        Get_B2 (hdrSize,                                        "hdrSize");
        Get_B2 (version,                                        "version");
        Get_C4 (creatorID,                                      "creatorID");
        Get_B2 (frameWidth,                                     "frameWidth");
        Get_B2 (frameHeight,                                    "frameHeight");
        BS_Begin();
        Get_S1 (2, chrominance_factor,                          "chrominance factor"); Param_Info1(ProRes_chrominance_factor(chrominance_factor));
        Skip_S1(2,                                              "reserved");
        Get_S1 (2, frame_type,                                  "frame type"); Param_Info1(ProRes_frame_type_ScanType(frame_type)); Param_Info1(ProRes_frame_type_ScanOrder(frame_type));
        Skip_S1(2,                                              "reserved");
        BS_End();
        Skip_B1(                                                "reserved");
        Get_B1 (primaries,                                      "primaries"); Param_Info1(Mpegv_colour_primaries(primaries));
        Get_B1 (transf_func,                                    "transf_func"); Param_Info1(Mpegv_transfer_characteristics(transf_func));
        Get_B1 (colorMatrix,                                    "colorMatrix"); Param_Info1(Mpegv_matrix_coefficients(colorMatrix));
        BS_Begin();
        Skip_S1(4,                                              "src_pix_fmt");
        Get_S1 (4, alpha_info,                                  "alpha_info");
        BS_End();
        Skip_B1(                                                "reserved");
        BS_Begin();
        Skip_S1(6,                                              "reserved");
        Get_SB (luma,                                           "custom luma quant matrix present");
        Get_SB (chroma,                                         "custom chroma quant matrix present");
        BS_End();
        if (luma)
            Skip_XX(64,                                         "QMatLuma");
        if (chroma)
            Skip_XX(64,                                         "QMatChroma");
    Element_End();
    if (Name==0x69637066 && Element_Offset!=8+(int32u)hdrSize) // Coherency test icpf
        IsOk=false;
    if (Name==0x69637066) // icpf
    {
    for (int8u PictureNumber=0; PictureNumber<(frame_type?2:1); PictureNumber++)
    {
        Element_Begin1("Picture layout");
            int16u total_slices;
            vector<int16u> slices_size;
            Element_Begin1("Picture header");
                int64u pic_hdr_End, pic_data_End;
                int32u pic_data_size;
                int8u pic_hdr_size;
                Get_B1 (pic_hdr_size,                               "pic_hdr_size");
                if (pic_hdr_size<64)
                {
                    Trusted_IsNot("pic_hdr_size");
                    Element_End();
                    Element_End();
                    return;
                }
                pic_hdr_End=Element_Offset+pic_hdr_size/8-((pic_hdr_size%8)?0:1);
                Get_B4 (pic_data_size,                              "pic_data_size");
                if (pic_data_size<8)
                {
                    Trusted_IsNot("pic_data_size");
                    Element_End();
                    Element_End();
                    return;
                }
                pic_data_End=Element_Offset+pic_data_size-5;
                Get_B2 (total_slices,                               "total_slices");
                BS_Begin();
                Skip_S1(4,                                          "slice_width_factor");
                Skip_S1(4,                                          "slice_height_factor");
                BS_End();
                if (Element_Offset<pic_hdr_End)
                    Skip_XX(pic_hdr_End-Element_Offset,             "Unknown");
            Element_End();
            Element_Begin1("Slice index table");
                for (int16u Pos=0; Pos<total_slices; Pos++)
                {
                    int16u slice_size;
                    Get_B2 (slice_size,                             "slice_size");
                    slices_size.push_back(slice_size);
                }
            Element_End();
            for (int16u Pos=0; Pos<slices_size.size(); Pos++)
            {
                Skip_XX(slices_size[Pos],                           "slice data");
            }
            if (Element_Offset<pic_data_End)
                Skip_XX(pic_data_End-Element_Offset,                "Unknown");
        Element_End();
    }
    }
    bool IsZeroes=true;
    for (size_t Pos=(size_t)Element_Offset; Pos<(size_t)Element_Size; Pos++)
        if (Buffer[Buffer_Offset+Pos])
        {
            IsZeroes=false;
            break;
        }
    Skip_XX(Element_Size-Element_Offset,                        IsZeroes?"Zeroes":"Unknown");

    FILLING_BEGIN();
        if (IsOk && (Name==0x69637066 || Name==0x70727266) && !Status[IsAccepted]) //icpf (all but RAW) & prrf (RAW)
        {
            Accept();
            Fill();

            Fill(Stream_Video, 0, Video_Format_Version, __T("Version ")+Ztring::ToZtring(version));
            Fill(Stream_Video, 0, Video_Width, frameWidth);
            Fill(Stream_Video, 0, Video_Height, frameHeight);
            Fill(Stream_Video, 0, Video_Encoded_Library, ProRes_creatorID(creatorID));
            Fill(Stream_Video, 0, Video_ChromaSubsampling, ProRes_chrominance_factor(chrominance_factor));
            Fill(Stream_Video, 0, Video_ScanType, ProRes_frame_type_ScanType(frame_type));
            Fill(Stream_Video, 0, Video_ScanOrder, ProRes_frame_type_ScanOrder(frame_type));
            Fill(Stream_Video, 0, Video_colour_description_present, "Yes");
            if (primaries || transf_func || colorMatrix) //Some streams have all 0 when it means unknwon, instead of assigned 2 for unknown
            {
                Fill(Stream_Video, 0, Video_colour_primaries, Mpegv_colour_primaries(primaries));
                Fill(Stream_Video, 0, Video_transfer_characteristics, Mpegv_transfer_characteristics(transf_func));
                Fill(Stream_Video, 0, Video_matrix_coefficients, Mpegv_matrix_coefficients(colorMatrix));
                if (colorMatrix!=2)
                    Fill(Stream_Video, 0, Video_ColorSpace, Ztring().From_UTF8(Mpegv_matrix_coefficients_ColorSpace(colorMatrix))+(alpha_info?__T("A"):__T("")), true);
            }
            else if (chrominance_factor==2)
                Fill(Stream_Video, 0, Video_ColorSpace, alpha_info?"YUVA":"YUV", Unlimited, true, true); //We are sure it is YUV as there is subsampling

            Finish();
        }
    FILLING_ELSE();
        if (!Status[IsAccepted])
            Reject();
    FILLING_END();
}
Esempio n. 13
0
//---------------------------------------------------------------------------
void File_Unknown::Read_Buffer_Continue()
{
    Skip_XX(Element_Size,                                       "Unknown");
}
Esempio n. 14
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();
}
Esempio n. 15
0
//---------------------------------------------------------------------------
void File_H263::Data_Parse()
{
    //Parsing
    int8u Temporal_Reference_Temp;
    BS_Begin();
    Skip_S3(22,                                                 "Picture Start Code (PSC)");
    Get_S1 ( 8, Temporal_Reference_Temp,                        "Temporal Reference (TR)");
    if (!Temporal_Reference_IsValid)
    {
        Temporal_Reference=Temporal_Reference_Temp;
        Temporal_Reference_IsValid=true;
    }
    else
        Temporal_Reference++;
    if (Temporal_Reference_Temp!=Temporal_Reference)
    {
        Trusted_IsNot("Out of Order");
        Open_Buffer_Unsynch();
        return;
    }
    Element_Begin1("Type Information (PTYPE)");
        Mark_1();
        Mark_0();
        Skip_SB(                                                "Split screen indicator");
        Skip_SB(                                                "Document camera indicator");
        Skip_SB(                                                "Full Picture Freeze Release");
        Get_S1 (3, Source_Format,                               "Source Format"); Param_Info1(H263_Source_Format[Source_Format]);
        if (Source_Format!=7)
        {
            Skip_SB(                                            "Picture Coding Type");
            Skip_SB(                                            "Unrestricted Motion Vector mode");
            Skip_SB(                                            "Syntax-based Arithmetic Coding mode");
            Skip_SB(                                            "Advanced Prediction mode");
            Skip_SB(                                            "PB-frames mode");
        }
    Element_End0();
    if (Source_Format==7) // Extended PTYPE
    {
        Element_Begin1("Plus PTYPE (PLUSPTYPE)");
            int8u Ufep, PixelAspectRatioCode=0, Width=0, Height=0;
            Get_S1 ( 3, Ufep,                                   "Update Full Extended PTYPE (UFEP)");
            switch (Ufep)
            {
                case 0  :
                            break;
                case 1  :
                            Element_Begin1("Optional Part of PLUSPTYPE (OPPTYPE)");
                            Get_S1 (3, Source_Format,           "Source Format"); Param_Info1(H263_Source_Format[Source_Format]);
                            Skip_SB(                            "Custom PCF");
                            Skip_SB(                            "Unrestricted Motion Vector (UMV) mode");
                            Skip_SB(                            "Syntax-based Arithmetic Coding (SAC) mode");
                            Skip_SB(                            "Advanced Prediction (AP) mode");
                            Skip_SB(                            "Advanced INTRA Coding (AIC) mode");
                            Skip_SB(                            "Deblocking Filter (DF) mode");
                            Skip_SB(                            "Slice Structured (SS) mode");
                            Skip_SB(                            "Reference Picture Selection (RPS) mode");
                            Skip_SB(                            "Independent Segment Decoding (ISD) mode");
                            Skip_SB(                            "Alternative INTER VLC (AIV) mode");
                            Skip_SB(                            "Modified Quantization (MQ) mode");
                            Mark_1();
                            Mark_0();
                            Mark_0();
                            Mark_0();
                            Element_End0();
                            break;
                default :
                            BS_End();
                            Skip_XX(Element_Size-Element_Offset, "Unknown");
                            return; //TODO: frame count...
            }
            Element_Begin1("mandatory part of PLUSPTYPE when PLUSPTYPE present (MPPTYPE)");
                Skip_S1(3,                                      "Picture Type Code");
                Skip_SB(                                        "Reference Picture Resampling (RPR) mode");
                Skip_SB(                                        "Reduced-Resolution Update (RRU) mode");
                Skip_SB(                                        "Rounding Type (RTYPE)");
                Mark_0();
                Mark_0();
                Mark_1();
            Element_End0();
        Element_End0();
        Skip_SB(                                                "CPM");
        Skip_S1(2,                                              "PSBI");
        Element_Begin1("Custom Picture Format (CPFMT)");
            Get_S1 (4, PixelAspectRatioCode,                    "Pixel Aspect Ratio Code");
            Get_S1 (4, Width,                                   "Picture Width Indication");
            Width++; Width<<=2; Param_Info2(Width, " pixels");
            Mark_1();
            Get_S1 (4, Height,                                  "Picture Height Indication");
            Height<<=2; Param_Info2(Height, " pixels");
        Element_End0();
        if (PixelAspectRatioCode==0xF)
        {
            Element_Begin1("Extended Pixel Aspect Ratio (EPAR)");
            Get_S1 (8, PAR_W,                                   "PAR Width");
            Get_S1 (8, PAR_H,                                   "PAR Height");
            Element_End0();
        }
        else
        {
            PAR_W=H263_PAR_W[PixelAspectRatioCode];
            PAR_H=H263_PAR_H[PixelAspectRatioCode];
        }
    }
    BS_End();
    Skip_XX(Element_Size-Element_Offset,                        "Other data");

    FILLING_BEGIN();
        Element_Info1(Frame_Count);
        Frame_Count++;

        //Filling
        if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid)
        {
            Accept("H.263");
            Finish("H.263");
        }
    FILLING_END();
}
Esempio n. 16
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();
}
Esempio n. 17
0
//---------------------------------------------------------------------------
void File_DvbSubtitle::display_definition_segment()
{
    Element_Name("display definition segment");

    Skip_XX(Element_Size,                                       "Data");
}
Esempio n. 18
0
//---------------------------------------------------------------------------
void File_ChannelGrouping::Read_Buffer_Continue()
{
    //Handling of multiple frames in one block
    if (Buffer_Size-Buffer_Offset_AlreadyInCommon==0)
    {
        if (Common->Parser && Common->Parser->Buffer_Size)
            Open_Buffer_Continue(Common->Parser, Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, 0);
        Element_WaitForMoreData();
        return;
    }

    //If basic PCM is already detected
    if (Common->IsPcm)
    {
        if (Buffer_Size==Buffer_Offset_AlreadyInCommon)
        {
            Element_WaitForMoreData();
            return;
        }
        Buffer_Offset_AlreadyInCommon=0;

        #if MEDIAINFO_DEMUX
            Demux_Level=2; //Container
            Demux_Offset=Buffer_Size;
            FrameInfo.PTS=FrameInfo.DTS;
            if (IsPcm_Frame_Count)
                FrameInfo.DUR*=IsPcm_Frame_Count+1;
            Demux_UnpacketizeContainer_Demux();
        #endif //MEDIAINFO_DEMUX

        Skip_XX(Element_Size,                                   "Data");

        if (IsPcm_Frame_Count)
        {
            Frame_Count+=IsPcm_Frame_Count;
            IsPcm_Frame_Count=0;
        }
        Frame_Count++;

        if (!Status[IsFilled])
        {
            Finish();
        }

        return;
    }
    else if (Buffer_Size && Buffer_Size>Buffer_Offset_AlreadyInCommon && !Common->IsAes3)
        IsPcm_Frame_Count++;

    //Demux
    #if MEDIAINFO_DEMUX
        if (Demux_UnpacketizeContainer)
        {
            Common->Parser->Demux_UnpacketizeContainer=true;
            Common->Parser->Demux_Level=2; //Container
            Demux_Level=4; //Intermediate
        }
        Demux(Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, Common->MergedChannel.Buffer_Size-Common->MergedChannel.Buffer_Offset, ContentType_MainStream);
    #endif //MEDIAINFO_EVENTS

    //Copying to Channel buffer
    if (Common->Channels[Channel_Pos]->Buffer_Size+Buffer_Size-Buffer_Offset_AlreadyInCommon>Common->Channels[Channel_Pos]->Buffer_Size_Max)
        Common->Channels[Channel_Pos]->resize(Common->Channels[Channel_Pos]->Buffer_Size+Buffer_Size-Buffer_Offset_AlreadyInCommon);
    memcpy(Common->Channels[Channel_Pos]->Buffer+Common->Channels[Channel_Pos]->Buffer_Size, Buffer+Buffer_Offset_AlreadyInCommon, Buffer_Size-Buffer_Offset_AlreadyInCommon);
    Common->Channels[Channel_Pos]->Buffer_Size+=Buffer_Size-Buffer_Offset_AlreadyInCommon;
    if (!Common->IsAes3)
        Buffer_Offset_AlreadyInCommon=Buffer_Size;
    else
        Buffer_Offset_AlreadyInCommon=0;
    Common->Channel_Current++;
    if (Common->Channel_Current>=Channel_Total)
        Common->Channel_Current=0;

    //Copying to merged channel
    size_t Minimum=(size_t)-1;
    for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
        if (Minimum>Common->Channels[Pos]->Buffer_Size-Common->Channels[Pos]->Buffer_Offset)
            Minimum=Common->Channels[Pos]->Buffer_Size-Common->Channels[Pos]->Buffer_Offset;
    while (Minimum>=ByteDepth)
    {
        for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
        {
            if (Common->MergedChannel.Buffer_Size+Minimum>Common->MergedChannel.Buffer_Size_Max)
                Common->MergedChannel.resize(Common->MergedChannel.Buffer_Size+Minimum);
            memcpy(Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Size, Common->Channels[Pos]->Buffer+Common->Channels[Pos]->Buffer_Offset, ByteDepth);
            Common->Channels[Pos]->Buffer_Offset+=ByteDepth;
            Common->MergedChannel.Buffer_Size+=ByteDepth;
        }
        Minimum-=ByteDepth;
    }

    if (Common->MergedChannel.Buffer_Size-Common->MergedChannel.Buffer_Offset)
    {
        if (FrameInfo_Next.DTS!=(int64u)-1)
            Common->Parser->FrameInfo=FrameInfo_Next; //AES3 parse has its own buffer management
        else
            Common->Parser->FrameInfo=FrameInfo;
        Open_Buffer_Continue(Common->Parser, Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, Common->MergedChannel.Buffer_Size-Common->MergedChannel.Buffer_Offset);
        Common->MergedChannel.Buffer_Offset=Common->MergedChannel.Buffer_Size;
    }

    if (!Common->IsAes3)
    {
        if (!Status[IsFilled] && Common->Parser->Status[IsAccepted])
        {
            if (Common->Parser->Get(Stream_Audio, 0, Audio_Format)==_T("PCM"))
                Common->IsPcm=true;
            else
            {
                Common->IsAes3=true;
                if (Common->Channel_Master==(size_t)-1)
                    Common->Channel_Master=Channel_Pos;
                Buffer_Offset_AlreadyInCommon=0;
                Fill();
            }
        }
        else if (Common->MergedChannel.Buffer_Size==0 && IsPcm_Frame_Count>=2)
            Common->IsPcm=true;
    }

    if (Common->IsAes3)
        Buffer_Offset=Buffer_Size;
    else
        Element_WaitForMoreData();

    if (Common->Parser->Status[IsFinished])
        Finish();

    //Optimize buffer
    for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
        Common->Channels[Pos]->optimize();
    Common->MergedChannel.optimize();
}
Esempio n. 19
0
//---------------------------------------------------------------------------
void File_DvbSubtitle::end_of_display_set_segment()
{
    Element_Name("end of display set segment");

    Skip_XX(Element_Size,                                       "Data");
}
Esempio n. 20
0
//---------------------------------------------------------------------------
void File_Ogg::Data_Parse()
{
    //Counting
    Frame_Count++;

    //If first chunk of a stream
    stream& Stream_Item=Stream[Element_Code]; //[+] FlylinkDC++ Team
    if (Stream_Item.Parser==NULL)
    {
        if (Parsing_End)
            return; //Maybe multitracks concatained, not supported
        Stream_Item.Parser=new File_Ogg_SubElement;
        Open_Buffer_Init(Stream_Item.Parser);
        ((File_Ogg_SubElement*)Stream_Item.Parser)->InAnotherContainer=IsSub;
        StreamsToDo++;
    }
    ((File_Ogg_SubElement*)Stream_Item.Parser)->MultipleStreams=Stream.size()>1; //has no sens for the first init, must check allways

    //Parsing
    File_Ogg_SubElement* Parser=(File_Ogg_SubElement*)Stream_Item.Parser;
    if (Stream_Item.SearchingPayload)
        //For each chunk
        for (size_t Chunk_Sizes_Pos=0; Chunk_Sizes_Pos<Chunk_Sizes.size(); Chunk_Sizes_Pos++)
        {
            //Info
            if (!continued)
                Peek_L1(packet_type); //Only for information
            Element_Info1(Ztring::ToZtring(packet_type, 16));
            Element_Info1C((continued), "Continue");

            //Parsing
            if (continued || Parser->File_Offset!=Parser->File_Size)
                Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, Chunk_Sizes[Chunk_Sizes_Pos]);
            if (Chunk_Sizes_Pos<Chunk_Sizes.size()-1
             || (Chunk_Sizes_Pos==Chunk_Sizes.size()-1 && Chunk_Sizes_Finished))
            {
                Open_Buffer_Continue(Parser, Buffer+Buffer_Offset, 0); //Purge old datas
            }

            Element_Offset+=Chunk_Sizes[Chunk_Sizes_Pos];
            continued=false; //If there is another chunk, this can not be a continued chunk
            if (Parser->File_GoTo!=(int64u)-1)
                Chunk_Sizes_Pos=Chunk_Sizes.size();

            if (!Status[IsAccepted] && Parser->Status[IsAccepted])
                Accept("OGG");
            if (Parser->Status[IsFinished] || (Element_Offset==Element_Size && eos))
            {
                StreamsToDo--;
                Stream_Item.SearchingPayload=false;
                break;
            }
        }
    else
        Skip_XX(Element_Size,                                   "Data");

    //End of stream
    if (!Parsing_End &&
        (StreamsToDo==0 || File_Offset+Buffer_Offset+Element_Offset>256*1024))
    {
        if (IsSub)
            Finish("OGG");
        else
            GoToFromEnd(256*1024, "OGG");
        std::map<int64u, stream>::iterator Stream_Temp=Stream.begin();
        if (File_GoTo!=(int64u)-1)
            while (Stream_Temp!=Stream.end())
            {
                Stream_Temp->second.absolute_granule_position=0;
                ++Stream_Temp;
            }
        Parsing_End=true;
    }

    Element_Show();
}
Esempio n. 21
0
//---------------------------------------------------------------------------
void File_Jpeg::Data_Parse()
{
    #define CASE_INFO(_NAME, _DETAIL) \
        case Elements::_NAME : Element_Info1(#_NAME); Element_Info1(_DETAIL); _NAME(); break;

    //Parsing
    if (SOS_SOD_Parsed)
    {
        Skip_XX(Element_Size,                                   "Data");
        SOS_SOD_Parsed=false;
        return;
    }
    switch (Element_Code)
    {
        CASE_INFO(TEM ,                                         "TEM");
        CASE_INFO(SOC ,                                         "Start of codestream"); //JPEG 2000
        CASE_INFO(SIZ ,                                         "Image and tile size"); //JPEG 2000
        CASE_INFO(COD ,                                         "Coding style default"); //JPEG 2000
        CASE_INFO(COC ,                                         "Coding style component"); //JPEG 2000
        CASE_INFO(TLM ,                                         "Tile-part lengths, main header"); //JPEG 2000
        CASE_INFO(PLM ,                                         "Packet length, main header"); //JPEG 2000
        CASE_INFO(PLT ,                                         "Packet length, tile-part header"); //JPEG 2000
        CASE_INFO(QCD ,                                         "Quantization default"); //JPEG 2000
        CASE_INFO(QCC ,                                         "Quantization component "); //JPEG 2000
        CASE_INFO(RGN ,                                         "Region-of-interest"); //JPEG 2000
        CASE_INFO(PPM ,                                         "Packed packet headers, main header"); //JPEG 2000
        CASE_INFO(PPT ,                                         "Packed packet headers, tile-part header"); //JPEG 2000
        CASE_INFO(CME ,                                         "Comment and extension"); //JPEG 2000
        CASE_INFO(SOT ,                                         "Start of tile-part"); //JPEG 2000
        CASE_INFO(SOP ,                                         "Start of packet"); //JPEG 2000
        CASE_INFO(EPH ,                                         "End of packet header"); //JPEG 2000
        CASE_INFO(SOD ,                                         "Start of data"); //JPEG 2000
        CASE_INFO(S0F0,                                         "Baseline DCT (Huffman)");
        CASE_INFO(S0F1,                                         "Extended sequential DCT (Huffman)");
        CASE_INFO(S0F2,                                         "Progressive DCT (Huffman)");
        CASE_INFO(S0F3,                                         "Lossless (sequential) (Huffman)");
        CASE_INFO(DHT ,                                         "Define Huffman Tables");
        CASE_INFO(S0F5,                                         "Differential sequential DCT (Huffman)");
        CASE_INFO(S0F6,                                         "Differential progressive DCT (Huffman)");
        CASE_INFO(S0F7,                                         "Differential lossless (sequential) (Huffman)");
        CASE_INFO(JPG ,                                         "Reserved for JPEG extensions");
        CASE_INFO(S0F9,                                         "Extended sequential DCT (Arithmetic)");
        CASE_INFO(S0FA,                                         "Progressive DCT (Arithmetic)");
        CASE_INFO(S0FB,                                         "Lossless (sequential) (Arithmetic)");
        CASE_INFO(DAC ,                                         "Define Arithmetic Coding");
        CASE_INFO(S0FD,                                         "Differential sequential DCT (Arithmetic)");
        CASE_INFO(S0FE,                                         "Differential progressive DCT (Arithmetic)");
        CASE_INFO(S0FF,                                         "Differential lossless (sequential) (Arithmetic)");
        CASE_INFO(RST0,                                         "Restart Interval Termination 0");
        CASE_INFO(RST1,                                         "Restart Interval Termination 1");
        CASE_INFO(RST2,                                         "Restart Interval Termination 2");
        CASE_INFO(RST3,                                         "Restart Interval Termination 3");
        CASE_INFO(RST4,                                         "Restart Interval Termination 4");
        CASE_INFO(RST5,                                         "Restart Interval Termination 5");
        CASE_INFO(RST6,                                         "Restart Interval Termination 6");
        CASE_INFO(RST7,                                         "Restart Interval Termination 7");
        CASE_INFO(SOI ,                                         "Start Of Image");
        CASE_INFO(EOI ,                                         "End Of Image"); //Is EOC (End of codestream) in JPEG 2000
        CASE_INFO(SOS ,                                         "Start Of Scan");
        CASE_INFO(DQT ,                                         "Define Quantization Tables");
        CASE_INFO(DNL ,                                         "Define Number of Lines");
        CASE_INFO(DRI ,                                         "Define Restart Interval");
        CASE_INFO(DHP ,                                         "Define Hierarchical Progression");
        CASE_INFO(EXP ,                                         "Expand Reference Components");
        CASE_INFO(APP0,                                         "Application-specific marker 0");
        CASE_INFO(APP1,                                         "Application-specific marker 1");
        CASE_INFO(APP2,                                         "Application-specific marker 2");
        CASE_INFO(APP3,                                         "Application-specific marker 3");
        CASE_INFO(APP4,                                         "Application-specific marker 4");
        CASE_INFO(APP5,                                         "Application-specific marker 5");
        CASE_INFO(APP6,                                         "Application-specific marker 6");
        CASE_INFO(APP7,                                         "Application-specific marker 7");
        CASE_INFO(APP8,                                         "Application-specific marker 8");
        CASE_INFO(APP9,                                         "Application-specific marker 9");
        CASE_INFO(APPA,                                         "Application-specific marker 10");
        CASE_INFO(APPB,                                         "Application-specific marker 11");
        CASE_INFO(APPC,                                         "Application-specific marker 12");
        CASE_INFO(APPD,                                         "Application-specific marker 13");
        CASE_INFO(APPE,                                         "Application-specific marker 14");
        CASE_INFO(APPF,                                         "Application-specific marker 15");
        CASE_INFO(JPG0,                                         "JPG");
        CASE_INFO(JPG1,                                         "JPG");
        CASE_INFO(JPG2,                                         "JPG");
        CASE_INFO(JPG3,                                         "JPG");
        CASE_INFO(JPG4,                                         "JPG");
        CASE_INFO(JPG5,                                         "JPG");
        CASE_INFO(JPG6,                                         "JPG");
        CASE_INFO(JPG7,                                         "JPG");
        CASE_INFO(JPG8,                                         "JPG");
        CASE_INFO(JPG9,                                         "JPG");
        CASE_INFO(JPGA,                                         "JPG");
        CASE_INFO(JPGB,                                         "JPG");
        CASE_INFO(JPGC,                                         "JPG");
        CASE_INFO(JPGD,                                         "JPG");
        CASE_INFO(COM ,                                         "Comment");
        default : Element_Info1("Reserved");
                  Skip_XX(Element_Size,                         "Data");
    }
}
Esempio n. 22
0
//---------------------------------------------------------------------------
void File_Umf::Read_Buffer_Continue()
{
    //Parsing
    int32u Tracks, Segments;
    Element_Begin("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_End();

    Element_Begin("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_End();

    for (int32u Pos=0; Pos<Tracks; Pos++)
    {
        Element_Begin("Track description");
        Skip_C1(                                                "Track information - Track type");
        Skip_C1(                                                "Track information - Track logical number");
        Skip_L2(                                                "Number of segments on this track");
        Element_End();

        if (Element_Offset==Element_Size)
            break;
    }

    for (int32u Pos=0; Pos<Segments; Pos++)
    {
        Element_Begin("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
                Skip_L4(                                                "Color difference format");
                Skip_L4(                                                "GoP structure");
                Skip_L4(                                                "Frame/field structure");
                Skip_L4(                                                "Target I-pictures per GoP");
                Skip_L4(                                                "Target P-pictures per I-picture");
                Skip_L4(                                                "Target B-pictures per P-picture or I-picture");
                Skip_L4(                                                "MPEG video attributes");
                Skip_L4(                                                "Reserved");
                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;
            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_End();

        if (Element_Offset==Element_Size)
            break;
    }

    while (Element_Offset<Element_Size)
    {
        Element_Begin("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_End();
    }
}
Esempio n. 23
0
//---------------------------------------------------------------------------
// Packet "00"
void File_Dirac::Sequence_header()
{
    Element_Name("Sequence header");

    //Parsing
    int32u version_major, version_minor, profile, level, base_video_format;
    BS_Begin();
    Get_UI(version_major,                                       "version major");
    Get_UI(version_minor,                                       "version minor");
    Get_UI(profile,                                             "profile");
    Get_UI(level,                                               "level");

    if (version_major<=2)
    {
        Get_UI(base_video_format,                               "base video format"); //Param_Info(Dirac_base_video_format(base_video_format));
        Dirac_base_video_format(base_video_format, frame_width, frame_height, chroma_format, source_sampling,
                                clean_width, clean_height, clean_left_offset, clean_top_offset,
                                frame_rate, pixel_aspect_ratio);
        TEST_SB_SKIP(                                           "custom dimensions flag");
            Get_UI (frame_width,                                "frame width");
            Get_UI (frame_height,                               "frame height");
        TEST_SB_END();
        TEST_SB_SKIP(                                           "custom chroma format flag");
            Get_UI (chroma_format,                              "chroma format"); Param_Info(Dirac_chroma_format(chroma_format));
        TEST_SB_END();
        TEST_SB_SKIP(                                           "custom scan format flag");
            Get_UI (source_sampling,                            "source sampling"); Param_Info(Dirac_source_sampling(source_sampling));
        TEST_SB_END();
        TEST_SB_SKIP(                                           "frame rate flag");
            int32u frame_rate_index;
            Get_UI (frame_rate_index,                           "index"); Param_Info(Dirac_frame_rate(frame_rate_index));
            if (frame_rate_index==0)
            {
                int32u frame_rate_numer, frame_rate_denom;
                Get_UI (frame_rate_numer,                       "frame rate numer");
                Get_UI (frame_rate_denom,                       "frame rate denom");
                frame_rate=((float32)frame_rate_numer)/((float32)frame_rate_denom);
            }
            else
                frame_rate=Dirac_frame_rate(frame_rate_index);
        TEST_SB_END();
        TEST_SB_SKIP(                                           "pixel aspect ratio flag");
            int32u pixel_aspect_ratio_index;
            Get_UI (pixel_aspect_ratio_index,                   "index"); Param_Info(Dirac_pixel_aspect_ratio(pixel_aspect_ratio_index));
            if (pixel_aspect_ratio_index==0)
            {
                int32u pixel_aspect_ratio_numer, pixel_aspect_ratio_denom;
                Get_UI (pixel_aspect_ratio_numer,               "pixel aspect ratio numer");
                Get_UI (pixel_aspect_ratio_denom,               "pixel aspect ratio denom");
                pixel_aspect_ratio=((float32)pixel_aspect_ratio_numer)/((float32)pixel_aspect_ratio_denom);
            }
            else
                pixel_aspect_ratio=Dirac_pixel_aspect_ratio(pixel_aspect_ratio_index);
        TEST_SB_END();
        TESTELSE_SB_SKIP(                                       "custom clean area flag");
            Get_UI (clean_width,                                "clean width");
            Get_UI (clean_height,                               "clean height");
            Get_UI (clean_left_offset,                          "clean left offset");
            Get_UI (clean_top_offset,                           "clean top offset");
        TESTELSE_SB_ELSE(                                       "custom clean area flag");
            clean_width=frame_width;
            clean_height=frame_height;
        TESTELSE_SB_END();
        TEST_SB_SKIP(                                           "custom signal range flag");
            int32u custom_signal_range_index;
            Get_UI(custom_signal_range_index,                   "index");
            if (custom_signal_range_index==0)
            {
                Skip_UI(                                        "luma offset");
                Skip_UI(                                        "luma excursion");
                Skip_UI(                                        "chroma offset");
                Skip_UI(                                        "chroma excursion");
            }
        TEST_SB_END();
        TEST_SB_SKIP(                                           "custom colour spec flag");
            int32u custom_colour_spec_index;
            Get_UI(custom_colour_spec_index,                    "index");
            if (custom_colour_spec_index==0)
            {
                TEST_SB_SKIP(                                   "custom colour primaries flag");
                    Skip_UI(                                    "custom colour primaries index");
                TEST_SB_END();
                TEST_SB_SKIP(                                   "colour matrix flag");
                    Skip_UI(                                    "colour matrix index");
                TEST_SB_END();
                TEST_SB_SKIP(                                   "custom transfer function flag");
                    Skip_UI(                                    "custom transfer function index");
                TEST_SB_END();
            }
        TEST_SB_END();
        Info_UI(picture_coding_mode,                            "picture coding mode"); Param_Info(Dirac_picture_coding_mode(picture_coding_mode));
    }
    else
    {
        Skip_XX(Element_Size-Element_Offset,                    "Unknown");
    }

    FILLING_BEGIN();
        //Autorisation of other streams
        Stream[0x10].Searching_Payload=true; //End_of_Sequence
        Stream[0x20].Searching_Payload=true; //Auxiliary_data
        Stream[0x30].Searching_Payload=true; //Padding_data
        Stream[0x0C].Searching_Payload=true; //Intra_Reference_Picture
        Stream[0x08].Searching_Payload=true; //Intra_Non_Reference_Picture
        Stream[0x4C].Searching_Payload=true; //Intra_Reference_Picture_No
        Stream[0x48].Searching_Payload=true; //Intra_Non_Reference_Picture_No
        Stream[0x0D].Searching_Payload=true; //Inter_Reference_Picture_1
        Stream[0x0E].Searching_Payload=true; //Inter_Reference_Picture_2
        Stream[0x09].Searching_Payload=true; //Inter_Non_Reference_Picture_1
        Stream[0x0A].Searching_Payload=true; //Inter_Non_Reference_Picture_2
        Stream[0xCC].Searching_Payload=true; //Reference_Picture_Low
        Stream[0xC8].Searching_Payload=true; //Intra_Non_Reference_Picture_Low
    FILLING_END();
}
Esempio n. 24
0
//---------------------------------------------------------------------------
void File_Mz::Read_Buffer_Continue()
{
    //Parsing
    int32u lfanew;
    Element_Begin("MZ");
    Skip_C2(                                                    "magic");
    Skip_L2(                                                    "cblp");
    Skip_L2(                                                    "cp");
    Skip_L2(                                                    "crlc");
    Skip_L2(                                                    "cparhdr");
    Skip_L2(                                                    "minalloc");
    Skip_L2(                                                    "maxalloc");
    Skip_L2(                                                    "ss");
    Skip_L2(                                                    "sp");
    Skip_L2(                                                    "csum");
    Skip_L2(                                                    "ip");
    Skip_L2(                                                    "cs");
    Skip_L2(                                                    "lsarlc");
    Skip_L2(                                                    "ovno");
    Skip_L2(                                                    "res");
    Skip_L2(                                                    "res");
    Skip_L2(                                                    "res");
    Skip_L2(                                                    "res");
    Skip_L2(                                                    "oemid");
    Skip_L2(                                                    "oeminfo");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Skip_L2(                                                    "res2");
    Get_L4 (lfanew,                                             "lfanew");

    //Computing
    if (lfanew>Element_Offset)
    {
        Skip_XX(lfanew-Element_Offset,                          "MZ data");
        Element_End();
    }
    if (Element_Offset>lfanew)
    {
        Element_End();
        Element_Offset=lfanew; //Multi usage off the first bytes
    }

    //Parsing
    int32u Signature, TimeDateStamp=0;
    int16u Machine=0, Characteristics=0;
    Peek_B4(Signature);
    if (Signature==0x50450000) //"PE"
    {
        Element_Begin("PE");
        Skip_C4(                                                "Header");
        Get_L2 (Machine,                                        "Machine"); Param_Info(Mz_Machine(Machine));
        Skip_L2(                                                "NumberOfSections");
        Get_L4 (TimeDateStamp,                                  "TimeDateStamp"); Param_Info(Ztring().Date_From_Seconds_1970(TimeDateStamp));
        Skip_L4(                                                "PointerToSymbolTable");
        Skip_L4(                                                "NumberOfSymbols");
        Skip_L2(                                                "SizeOfOptionalHeader");
        Get_L2 (Characteristics,                                "Characteristics");
        Element_End("PE");
    }

    FILLING_BEGIN();
        Stream_Prepare(Stream_General);
        Fill(Stream_General, 0, General_Format, "MZ");
        if (Characteristics&0x2000)
            Fill(Stream_General, 0, General_Format_Profile, "DLL");
        else if (Characteristics&0x0002)
            Fill(Stream_General, 0, General_Format_Profile, "Executable");
        Fill(Stream_General, 0, General_Format_Profile, Mz_Machine(Machine));
        if (TimeDateStamp)
            Fill(Stream_General, 0, General_Encoded_Date, Ztring().Date_From_Seconds_1970(TimeDateStamp));

        //No need of more
        Accept("MZ");
        Finish("MZ");
    FILLING_END();
}
//---------------------------------------------------------------------------
void File_Ape::FileHeader_Parse()
{
    //Parsing
    int32u SampleRate=0, TotalFrames=0, FinalFrameSamples=0, SamplesPerFrame=0, SeekElements;
    int16u Version, CompressionLevel=0, Flags=0, Channels=0, Resolution=0;
    bool Resolution8=false, Resolution24=false, no_wav_header;
    Skip_C4(                                                    "Identifier");
    Get_L2 (Version,                                            "Version");
    if (Version<3980) //<3.98
    {
        Get_L2 (CompressionLevel,                               "CompressionLevel"); Param_Info(Ape_Codec_Settings(CompressionLevel));
        Get_L2 (Flags,                                          "FormatFlags");
            Get_Flags (Flags, 0, Resolution8,                   "8-bit");
            Skip_Flags(Flags, 1,                                "crc-32");
            Skip_Flags(Flags, 2,                                "peak_level");
            Get_Flags (Flags, 3, Resolution24,                  "24-bit");
            Skip_Flags(Flags, 4,                                "seek_elements");
            Get_Flags (Flags, 5, no_wav_header,                 "no_wav_header");
        if (Resolution8)
            Resolution=8;
        else if (Resolution24)
            Resolution=24;
        else
            Resolution=16;
        Get_L2 (Channels,                                       "Channels");
        Get_L4 (SampleRate,                                     "SampleRate");
        Skip_L4(                                                "WavHeaderDataBytes");
        Skip_L4(                                                "WavTerminatingBytes");
        Get_L4 (TotalFrames,                                    "TotalFrames");
        Get_L4 (FinalFrameSamples,                              "FinalFrameSamples");
        SamplesPerFrame=Ape_SamplesPerFrame(Version, CompressionLevel);
        Skip_L4(                                                "PeakLevel");
        Get_L4 (SeekElements,                                   "SeekElements");
        if (!no_wav_header)
            Skip_XX(44,                                         "RIFF header");
        Skip_XX(SeekElements*4,                                 "Seek table");
    }
    else
    {
        Skip_L2(                                                "Version_High");
        Skip_L4(                                                "DescriptorBytes");
        Skip_L4(                                                "HeaderBytes");
        Skip_L4(                                                "SeekTableBytes");
        Skip_L4(                                                "WavHeaderDataBytes");
        Skip_L4(                                                "APEFrameDataBytes");
        Skip_L4(                                                "APEFrameDataBytesHigh");
        Skip_L4(                                                "WavTerminatingDataBytes");
        Skip_L16(                                               "FileMD5");
        Get_L2 (CompressionLevel,                               "CompressionLevel"); Param_Info(Ape_Codec_Settings(CompressionLevel));
        Get_L2 (Flags,                                          "FormatFlags");
        Get_L4 (SamplesPerFrame,                                "BlocksPerFrame");
        Get_L4 (FinalFrameSamples,                              "FinalFrameBlocks");
        Get_L4 (TotalFrames,                                    "TotalFrames");
        Get_L2 (Resolution,                                     "BitsPerSample");
        Get_L2 (Channels,                                       "Channels");
        Get_L4 (SampleRate,                                     "SampleRate");
    }

    FILLING_BEGIN();
        //Coherancy
        int32u Samples=(TotalFrames-1)*SamplesPerFrame+FinalFrameSamples;
        if (Samples==0 || SampleRate==0 || Channels==0 || Resolution==0)
        {
            File__Tags_Helper::Reject("APE");
            return;
        }

        //Filling
        File__Tags_Helper::Accept("APE");
        File__Tags_Helper::Streams_Fill();

        Duration=((int64u)Samples)*1000/SampleRate;
        UncompressedSize=Samples*Channels*(Resolution/8);

        File__Tags_Helper::Stream_Prepare(Stream_Audio);
        Fill(Stream_Audio, 0, Audio_Format, "Monkey's Audio");
        Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, Ape_Codec_Settings(CompressionLevel));
        Fill(Stream_Audio, 0, Audio_Codec, "APE");
        Fill(Stream_Audio, 0, Audio_BitDepth, Resolution);
        Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
        Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate);
        Fill(Stream_Audio, 0, Audio_Duration, Duration);

        //No more need data
        File__Tags_Helper::Finish("APE");
    FILLING_END();
}
Esempio n. 26
0
//---------------------------------------------------------------------------
void File_AfdBarData::bar_data()
{
    //Parsing
    Element_Begin1("bar_data");
    bool   top_bar_flag, bottom_bar_flag, left_bar_flag, right_bar_flag;
    BS_Begin();
    Get_SB (top_bar_flag,                                       "top_bar_flag");
    Get_SB (bottom_bar_flag,                                    "bottom_bar_flag");
    Get_SB (left_bar_flag,                                      "left_bar_flag");
    Get_SB (right_bar_flag,                                     "right_bar_flag");
    if (Format==Format_S2016_3)
    {
        Mark_0_NoTrustError();
        Mark_0_NoTrustError();
        Mark_0_NoTrustError();
        Mark_0_NoTrustError();
    }
    else
    {
        Mark_1_NoTrustError();
        Mark_1_NoTrustError();
        Mark_1_NoTrustError();
        Mark_1_NoTrustError();
    }
    if (top_bar_flag)
    {
        Mark_1();
        Mark_1();
        Get_S2 (14, line_number_end_of_top_bar,                 "line_number_end_of_top_bar");
    }
    if (bottom_bar_flag)
    {
        Mark_1();
        Mark_1();
        Get_S2 (14, line_number_start_of_bottom_bar,            "line_number_start_of_bottom_bar");
    }
    if (left_bar_flag)
    {
        Mark_1();
        Mark_1();
        Get_S2 (14, pixel_number_end_of_left_bar,               "pixel_number_end_of_left_bar");
    }
    if (right_bar_flag)
    {
        Mark_1();
        Mark_1();
        Get_S2 (14, pixel_number_start_of_right_bar,            "pixel_number_start_of_right_bar");
    }
    if (!top_bar_flag && !bottom_bar_flag && !left_bar_flag && !right_bar_flag)
    {
        Mark_1_NoTrustError();
        Mark_1_NoTrustError();
        Skip_S2(14,                                             "reserved");
        Mark_1_NoTrustError();
        Mark_1_NoTrustError();
        Skip_S2(14,                                             "reserved");
    }
    BS_End();
    Element_End0();

    if (Format==Format_A53_4_DTG1)
    {
        BS_Begin();
        Mark_1();
        Mark_1();
        Mark_1();
        Mark_1();
        Mark_1();
        Mark_1();
        Mark_1();
        Mark_1();
        BS_End();

        if (Element_Size-Element_Offset)
            Skip_XX(Element_Size-Element_Offset,                "additional_bar_data");
    }
}
Esempio n. 27
0
//---------------------------------------------------------------------------
void File_Gxf_TimeCode::Read_Buffer_Continue()
{
    int8u Validity[504];

    if (!IsAtc)
    {
        if (Element_Size!=4096)
        {
            Skip_XX(Element_Size,                                   "Data");
            return;
        }

        //Reading bitmap first (validity of first byte is at the end)
        Element_Offset=504*8;
        Element_Begin1("Validity");
        BS_Begin_LE(); //is Little Endian
        for (size_t Pos=0; Pos<504; Pos++)
        {
            bool Validity_Bit;
            Get_TB (Validity_Bit,                                   "Bit");
            Validity[Pos]=Validity_Bit?1:0;
        }
        BS_End_LE();
        Skip_B1(                                                    "Pad");
        Element_End0();
    }

    //Parsing
    Element_Offset=0;
    for (size_t Pos=0; Pos<(IsAtc?(size_t)1:(size_t)504); Pos++)
    {
        if (IsAtc || Validity[Pos])
        {
            Element_Begin1("TimeCode");
            int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens;
            bool  DropFrame;
            int8u DBB1=0, DBB2=0;
            if (IsAtc)
            {
                bool Temp;
                BS_Begin();

                Get_S1 (4, Frames_Units,                            "Frames (Units)");
                Get_SB (   Temp,                                    "DBB1_0"); if (Temp) DBB1|=(1<<0);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG1");
                Get_SB (   Temp,                                    "DBB1_1"); if (Temp) DBB1|=(1<<1);
                Skip_S1(3,                                          "Zero");

                Skip_SB(                                            "CF - Color fame");
                Get_SB (   DropFrame,                               "DP - Drop frame");
                Get_S1 (2, Frames_Tens,                             "Frames (Tens)");
                Get_SB (   Temp,                                    "DBB1_2"); if (Temp) DBB1|=(1<<2);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG2");
                Get_SB (   Temp,                                    "DBB1_3"); if (Temp) DBB1|=(1<<3);
                Skip_S1(3,                                          "Zero");

                Get_S1 (4, Seconds_Units,                           "Seconds (Units)");
                Get_SB (   Temp,                                    "DBB1_4"); if (Temp) DBB1|=(1<<4);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG3");
                Get_SB (   Temp,                                    "DBB1_5"); if (Temp) DBB1|=(1<<5);
                Skip_S1(3,                                          "Zero");

                Skip_SB(                                            "FM - Frame Mark");
                Get_S1 (3, Seconds_Tens,                            "Seconds (Tens)");
                Get_SB (   Temp,                                    "DBB1_6"); if (Temp) DBB1|=(1<<6);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG4");
                Get_SB (   Temp,                                    "DBB1_7"); if (Temp) DBB1|=(1<<7);
                Skip_S1(3,                                          "Zero");

                Get_S1 (4, Minutes_Units,                           "Minutes (Units)");
                Get_SB (   Temp,                                    "DBB2_0"); if (Temp) DBB2|=(1<<0);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG5");
                Get_SB (   Temp,                                    "DBB2_1"); if (Temp) DBB2|=(1<<1);
                Skip_S1(3,                                          "Zero");

                Skip_SB(                                            "BGF0");
                Get_S1 (3, Minutes_Tens,                            "Minutes (Tens)");
                Get_SB (   Temp,                                    "DBB2_2"); if (Temp) DBB2|=(1<<2);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG6");
                Get_SB (   Temp,                                    "DBB2_3"); if (Temp) DBB2|=(1<<3);
                Skip_S1(3,                                          "Zero");

                Get_S1 (4, Hours_Units,                             "Hours (Units)");
                Get_SB (   Temp,                                    "DBB2_4"); if (Temp) DBB2|=(1<<4);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG7");
                Get_SB (   Temp,                                    "DBB2_5"); if (Temp) DBB2|=(1<<5);
                Skip_S1(3,                                          "Zero");

                Skip_SB(                                            "BGF2");
                Skip_SB(                                            "BGF1");
                Get_S1 (2, Hours_Tens,                              "Hours (Tens)");
                Get_SB (   Temp,                                    "DBB2_6"); if (Temp) DBB2|=(1<<6);
                Skip_S1(3,                                          "Zero");

                Skip_S1(4,                                          "BG8");
                Get_SB (   Temp,                                    "DBB2_7"); if (Temp) DBB2|=(1<<7);
                Skip_S1(3,                                          "Zero");

                BS_End();
            }
            else
            {
                BS_Begin();

                Skip_S1(4,                                          "BG1");
                Get_S1 (4, Frames_Units,                            "Frames (Units)");

                Skip_S1(4,                                          "BG2");
                Skip_SB(                                            "CF - Color fame");
                Get_SB (   DropFrame,                               "DP - Drop frame");
                Get_S1 (2, Frames_Tens,                             "Frames (Tens)");

                Skip_S1(4,                                          "BG3");
                Get_S1 (4, Seconds_Units,                           "Seconds (Units)");

                Skip_S1(4,                                          "BG4");
                Skip_SB(                                            "FM - Frame Mark");
                Get_S1 (3, Seconds_Tens,                            "Seconds (Tens)");

                Skip_S1(4,                                          "BG5");
                Get_S1 (4, Minutes_Units,                           "Minutes (Units)");

                Skip_S1(4,                                          "BG6");
                Skip_SB(                                            "BGF0");
                Get_S1 (3, Minutes_Tens,                            "Minutes (Tens)");

                Skip_S1(4,                                          "BG7");
                Get_S1 (4, Hours_Units,                             "Hours (Units)");

                Skip_S1(4,                                          "BG8");
                Skip_SB(                                            "BGF2");
                Skip_SB(                                            "BGF1");
                Get_S1 (2, Hours_Tens,                              "Hours (Tens)");

                BS_End();
            }

            int64u TimeCode_Ms=(int64u)(Hours_Tens     *10*60*60*1000
                                      + Hours_Units       *60*60*1000
                                      + Minutes_Tens      *10*60*1000
                                      + Minutes_Units        *60*1000
                                      + Seconds_Tens         *10*1000
                                      + Seconds_Units           *1000
                                      + (Gxf_FrameRate(FrameRate_Code)==0?0:((Frames_Tens*10+Frames_Units)*1000/float64_int32s(Gxf_FrameRate(FrameRate_Code)/(Gxf_FrameRate(FrameRate_Code)>30?2:1)))));

            if (TimeCode_FirstFrame.empty())
            {
                TimeCode_FirstFrame+=('0'+Hours_Tens);
                TimeCode_FirstFrame+=('0'+Hours_Units);
                TimeCode_FirstFrame+=':';
                TimeCode_FirstFrame+=('0'+Minutes_Tens);
                TimeCode_FirstFrame+=('0'+Minutes_Units);
                TimeCode_FirstFrame+=':';
                TimeCode_FirstFrame+=('0'+Seconds_Tens);
                TimeCode_FirstFrame+=('0'+Seconds_Units);
                TimeCode_FirstFrame+=DropFrame?';':':';
                TimeCode_FirstFrame+=('0'+Frames_Tens);
                TimeCode_FirstFrame+=('0'+Frames_Units);
            }

            #if MEDIAINFO_TRACE
                string TimeCode;
                TimeCode+=('0'+Hours_Tens);
                TimeCode+=('0'+Hours_Units);
                TimeCode+=':';
                TimeCode+=('0'+Minutes_Tens);
                TimeCode+=('0'+Minutes_Units);
                TimeCode+=':';
                TimeCode+=('0'+Seconds_Tens);
                TimeCode+=('0'+Seconds_Units);
                TimeCode+=DropFrame?';':':';
                TimeCode+=('0'+Frames_Tens);
                TimeCode+=('0'+Frames_Units);
                Element_Info1(TimeCode.c_str());
            #endif //MEDIAINFO_TRACE
            if (IsAtc)
            {
                Settings=Atc_PayloadType(DBB1);
                Element_Info1(__T("PayloadType=")+Ztring().From_UTF8(Settings.c_str()));
                Element_Info1(__T("VitcLineSelect=")+Ztring::ToZtring(DBB2&0x1F));
            }
            Element_End0();

            FILLING_BEGIN();
                if (TimeCode_FirstFrame_ms==(int64u)-1)
                    TimeCode_FirstFrame_ms=TimeCode_Ms;
            FILLING_END();
        }
        else
            Skip_XX(8,                                              "Junk");
    }

    //bitmap, already parsed
    Element_Offset+=64;

    FILLING_BEGIN();
    if (!Status[IsFilled] && TimeCode_FirstFrame_ms!=(int64u)-1)
    {
        Accept();
        Fill();

        if (Config->ParseSpeed<1.0)
            Finish();
    }

    FILLING_END();
}
//---------------------------------------------------------------------------
// GASpecificConfig
void File_Mpeg4_AudioSpecificConfig::GASpecificConfig ()
{
    Element_Begin("GASpecificConfig");
    bool dependsOnCoreCoder, extensionFlag;
    Info_SB(   frameLengthFlag,                                 "frameLengthFlag"); Param_Info(frameLengthFlag==0?1024:960, " bytes");
    Get_SB (   dependsOnCoreCoder,                              "dependsOnCoreCoder");
    if (dependsOnCoreCoder)
        Skip_S2(14,                                             "coreCoderDelay");
    Get_SB (   extensionFlag,                                   "extensionFlag");
    if (channelConfiguration==0)
    {
        Element_Begin("Extension");
        int8u Channels=0, Channels_Front=0, Channels_Side=0, Channels_Back=0, Channels_LFE=0;
        int8u sf_index, num_front_channel_elements, num_side_channel_elements, num_back_channel_elements, num_lfe_channel_elements, num_assoc_data_elements, num_valid_cc_elements, comment_field_bytes;
        Skip_S1(4,                                              "element_instance_tag");
        Skip_S1(2,                                              "object_type");
        Get_S1 (4, sf_index,                                    "sf_index");
        Get_S1 (4, num_front_channel_elements,                  "num_front_channel_elements");
        Get_S1 (4, num_side_channel_elements,                   "num_side_channel_elements");
        Get_S1 (4, num_back_channel_elements,                   "num_back_channel_elements");
        Get_S1 (2, num_lfe_channel_elements,                    "num_lfe_channel_elements");
        Get_S1 (3, num_assoc_data_elements,                     "num_assoc_data_elements");
        Get_S1 (4, num_valid_cc_elements,                       "num_valid_cc_elements");
        TEST_SB_SKIP(                                           "mono_mixdown_present");
            Skip_S1(4,                                          "mono_mixdown_element_number");
        TEST_SB_END();
        TEST_SB_SKIP(                                           "stereo_mixdown_present");
            Skip_S1(4,                                          "stereo_mixdown_element_number");
        TEST_SB_END();
        TEST_SB_SKIP(                                           "matrix_mixdown_idx_present");
            Skip_S1(2,                                          "matrix_mixdown_idx");
            Skip_SB(                                            "pseudo_surround_enable");
        TEST_SB_END();
        for (int8u Pos=0; Pos<num_front_channel_elements; Pos++)
        {
            Element_Begin("Front channel");
            bool front_element_is_cpe;
            Get_SB (   front_element_is_cpe,                    "front_element_is_cpe");
            Skip_S1(4,                                          "front_element_tag_select");
            if (front_element_is_cpe)
            {
                Channels_Front+=2;
                Channels+=2;
            }
            else
            {
                Channels_Front++;
                Channels++;
            }
            Element_End();
        }
        for (int8u Pos=0; Pos<num_side_channel_elements; Pos++)
        {
            Element_Begin("Side channel");
            bool side_element_is_cpe;
            Get_SB (   side_element_is_cpe,                     "side_element_is_cpe");
            Skip_S1(4,                                          "side_element_tag_select");
            if (side_element_is_cpe)
            {
                Channels_Side+=2;
                Channels+=2;
            }
            else
            {
                Channels_Side++;
                Channels++;
            }
            Element_End();
        }
        for (int8u Pos=0; Pos<num_back_channel_elements; Pos++)
        {
            Element_Begin("Back channel");
            bool back_element_is_cpe;
            Get_SB (   back_element_is_cpe,                     "back_element_is_cpe");
            Skip_S1(4,                                          "back_element_tag_select");
            if (back_element_is_cpe)
            {
                Channels_Back+=2;
                Channels+=2;
            }
            else
            {
                Channels_Back++;
                Channels++;
            }
            Element_End();
        }
        for (int8u Pos=0; Pos<num_lfe_channel_elements; Pos++)
        {
            Element_Begin("LFE");
            Skip_S1(4,                                          "lfe_element_tag_select");
            Channels_LFE++;
            Channels++;
            Element_End();
        }
        for (int8u Pos=0; Pos<num_assoc_data_elements; Pos++)
        {
            Element_Begin("assoc_data_element");
            Skip_S1(4,                                          "assoc_data_element_tag_select");
            Element_End();
        }
        for (int8u Pos=0; Pos<num_valid_cc_elements; Pos++)
        {
            Element_Begin("valid_cc_element");
            Skip_SB(                                            "cc_element_is_ind_sw");
            Skip_S1(4,                                          "valid_cc_element_tag_select");
            Element_End();
        }
        BS_End(); //Byte align
        Get_B1 (comment_field_bytes,                            "comment_field_bytes");
        if (comment_field_bytes)
            Skip_XX(comment_field_bytes,                        "comment_field_data");
        BS_Begin(); //The stream needs continuity in the bitstream
        Element_End();

        //Filling
        Ztring Channels_Positions, Channels_Positions2;
        switch (Channels_Front)
        {
            case  0 : break;
            case  1 : Channels_Positions+=_T("Front: C"); break;
            case  2 : Channels_Positions+=_T("Front: L R"); break;
            case  3 : Channels_Positions+=_T("Front: L C R"); break;
            default : Channels_Positions+=_T("Front: "); Channels_Positions+=Ztring::ToZtring(Channels_Front); //Which config?
        }
        switch (Channels_Side)
        {
            case  0 : break;
            case  1 : Channels_Positions+=_T(", Side: C"); break;
            case  2 : Channels_Positions+=_T(", Side: L R"); break;
            case  3 : Channels_Positions+=_T(", Side: L C R"); break;
            default : Channels_Positions+=_T(", Side: "); Channels_Positions+=Ztring::ToZtring(Channels_Side); //Which config?
        }
        switch (Channels_Back)
        {
            case  0 : break;
            case  1 : Channels_Positions+=_T(", Rear: C"); break;
            case  2 : Channels_Positions+=_T(", Rear: L R"); break;
            case  3 : Channels_Positions+=_T(", Rear: L C R"); break;
            default : Channels_Positions+=_T(", Rear: "); Channels_Positions+=Ztring::ToZtring(Channels_Back); //Which config?
        }
        switch (Channels_LFE)
        {
            case  0 : break;
            case  1 : Channels_Positions+=_T(", LFE"); break;
            default : Channels_Positions+=_T(", LFE= "); Channels_Positions+=Ztring::ToZtring(Channels_LFE); //Which config?
        }
        Channels_Positions2=Ztring::ToZtring(Channels_Front)+_T('/')+
                            Ztring::ToZtring(Channels_Side)+
                            (Channels_Back?(_T('/')+Ztring::ToZtring(Channels_Back)):Ztring())+
                            (Channels_LFE? (_T('.')+Ztring::ToZtring(Channels_LFE )):Ztring());

        //Filling
        Stream_Prepare(Stream_Audio);
        Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels_Front+Channels_Side+Channels_Back+Channels_LFE);
        Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, Channels_Positions);
        Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions_String2, Channels_Positions2);
        samplingFrequency=MP4_SamplingRate[sf_index];
    }
    if (audioObjectType==06 || audioObjectType==20)
        Skip_S1(3,                                              "layerNr");
    if (extensionFlag)
    {
        bool extensionFlag3;
        if (audioObjectType==22)
        {
            Skip_S1( 5,                                         "numOfSubFrame");
            Skip_S2(11,                                         "layer_length");
        }
        if (audioObjectType==17
         || audioObjectType==19
         || audioObjectType==20
         || audioObjectType==23)
        {
            Skip_SB(                                            "aacSectionDataResilienceFlag");
            Skip_SB(                                            "aacScalefactorDataResilienceFlag");
            Skip_SB(                                            "aacSpectralDataResilienceFlag");
        }
        Get_SB (   extensionFlag3,                              "extensionFlag3");
        if (extensionFlag3)
        {
            //TODO...
        }
    }
    Element_End();
}
Esempio n. 29
0
//---------------------------------------------------------------------------
void File_DvbSubtitle::object_data_segment()
{
    Element_Name("object data segment");

    Skip_XX(Element_Size,                                       "Data");
}
Esempio n. 30
0
//---------------------------------------------------------------------------
// Packet "B5"
void File_AvsV::extension_start()
{
    Element_Name("Extension");

    //Parsing
    int8u extension_start_code_identifier;
    BS_Begin();
    Get_S1 ( 4, extension_start_code_identifier,                "extension_start_code_identifier"); Param_Info1(AvsV_extension_start_code_identifier[extension_start_code_identifier]);
    Element_Info1(AvsV_extension_start_code_identifier[extension_start_code_identifier]);

         switch (extension_start_code_identifier)
    {
        case 2  :{ //sequence_display
                    //Parsing
                    Get_S1 ( 3, video_format,                   "video_format"); Param_Info1(AvsV_video_format[video_format]);
                    Skip_SB(                                    "sample_range");
                    TEST_SB_SKIP(                               "colour_description");
                        Skip_S1( 8,                             "colour_primaries");
                        Skip_S1( 8,                             "transfer_characteristics");
                        Skip_S1( 8,                             "matrix_coefficients");
                    TEST_SB_END();
                    Get_S2 (14, display_horizontal_size,        "display_horizontal_size");
                    Mark_1 ();
                    Get_S2 (14, display_vertical_size,          "display_vertical_size");
                    Skip_SB(                                    "reserved");
                    Skip_SB(                                    "reserved");
                    BS_End();
                }
                break;
        case 4  :{ //copyright
                    //Parsing
                    Skip_SB(                                    "copyright_flag");
                    Skip_S1( 8,                                 "copyright_id");
                    Skip_SB(                                    "original_or_copy");
                    Skip_S1( 7,                                 "reserved");
                    Mark_1 ();
                    Info_S3(20, copyright_number_1,             "copyright_number_1");
                    Mark_1 ();
                    Info_S3(22, copyright_number_2,             "copyright_number_2");
                    Mark_1 ();
                    Info_S3(22, copyright_number_3,             "copyright_number_3"); Param_Info1(Ztring::ToZtring(((int64u)copyright_number_1<<44)+((int64u)copyright_number_2<<22)+(int64u)copyright_number_3, 16));
                    BS_End();
                }
                break;
        case 11 :{ //camera_parameters
                    //Parsing
                    Skip_SB(                                    "reserved");
                    Skip_S1( 7,                                 "camera_id");
                    Mark_1 ();
                    Skip_S3(22,                                 "height_of_image_device");
                    Mark_1 ();
                    Skip_S3(22,                                 "focal_length");
                    Mark_1 ();
                    Skip_S3(22,                                 "f_number");
                    Mark_1 ();
                    Skip_S3(22,                                 "vertical_angle_of_view");
                    Mark_1 ();
                    Skip_S3(16,                                 "camera_position_x_upper");
                    Mark_1 ();
                    Skip_S3(16,                                 "camera_position_x_lower");
                    Mark_1 ();
                    Skip_S3(16,                                 "camera_position_y_upper");
                    Mark_1 ();
                    Skip_S3(16,                                 "camera_position_y_lower");
                    Mark_1 ();
                    Skip_S3(16,                                 "camera_position_z_upper");
                    Mark_1 ();
                    Skip_S3(16,                                 "camera_position_z_lower");
                    Mark_1 ();
                    Skip_S3(22,                                 "camera_direction_x");
                    Mark_1 ();
                    Skip_S3(22,                                 "camera_direction_y");
                    Mark_1 ();
                    Skip_S3(22,                                 "camera_direction_z");
                    Mark_1 ();
                    Skip_S3(22,                                 "camera_plane_vertical_x");
                    Mark_1 ();
                    Skip_S3(22,                                 "camera_plane_vertical_y");
                    Mark_1 ();
                    Skip_S3(22,                                 "camera_plane_vertical_z");
                    Mark_1 ();
                    Skip_S4(32,                                 "reserved");
                    BS_End();
                }
                break;
        default:{
                    //Parsing
                    Skip_S1(4,                                  "data");
                    BS_End();
                    Skip_XX(Element_Size-Element_Offset,        "data");
                }

    }

    //Not sure, but the 3 first official files have this
    if (Element_Size-Element_Offset)
    {
        BS_Begin();
        Mark_1();
        BS_End();
    }

    FILLING_BEGIN();
        //NextCode
        NextCode_Test();
    FILLING_END();
}