Пример #1
0
//---------------------------------------------------------------------------
void File_Amr::FileHeader_Parse()
{
    //From a container
    if (!Codec.empty())
    {
        Accept("AMR");
        Finish("AMR");
        return;
    }

    //Parsing
    int64u Signature;
    Skip_C5(                                                    "Signature (Common)");
    Peek_B8(Signature);
    if ((Signature&0xFF00000000000000LL)==0x0A00000000000000LL) //\n
    {
        IsWB=false;
        Channels=1;
    }
    else if ((Signature&0xFFFFFFFFFFFFFF00LL)==0x5F4D43312E300A00LL) //_MC1.0\n
    {
        IsWB=false;
        Channels=2; //Or more, see later
    }
    else if ((Signature&0xFFFFFF0000000000LL)==0x2D57420000000000LL) //-WB
    {
        Skip_C3(                                              "Signature (WB)");
        IsWB=true;

        Peek_B8(Signature);
        if ((Signature&0xFF00000000000000LL)==0x0A00000000000000LL) //\n
        {
            Channels=1;
        }
        else if ((Signature&0xFFFFFFFFFFFFFF00LL)==0x5F4D43312E300A00LL) //_MC1.0\n
        {
            Channels=2; //Or more, see later
        }
    }
    else
        Channels=0;
    Skip_B1(                                                    "Signature (Carriage return)");
    /*
    if (Channels==2) //Mutli-channels
    {
        BS_Begin();
        Skip_S4(28,                                             "Reserved");
        Get_S1 ( 4, Channels,                                   "Channels");
    }
    */
    Header_Size=(int8u)Element_Offset;


    FILLING_BEGIN();
        Accept("AMR");

        if (Channels!=1 || IsWB)
            Finish("AMR");
    FILLING_END();
}
Пример #2
0
//---------------------------------------------------------------------------
void File_OpenMG::FileHeader_Parse()
{
    //Parsing
    int16u Size, FrameSize=0;
    int8u  Flags, CodecID, SamplingRate_Code=0, Channels_Code=0;
    bool  JointStereo=false;
    Skip_C3(                                                    "Code");
    Get_B1 (Flags,                                              "Flags");
    Get_B2 (Size,                                               "Size");
    Skip_XX(26,                                                 "Unknown");
    Get_B1 (CodecID,                                            "Coded ID"); Param_Info1(OpenMG_CodecID_Format(CodecID));
    if (CodecID<=1) //Atrac3
    {
        BS_Begin();
        Skip_S1(7,                                              "Unknown");
        Get_SB (   JointStereo,                                 "Joint Stereo");
        Get_S1 (3, SamplingRate_Code,                           "Sampling Rate"); Param_Info2(OpenMG_SamplingRate(SamplingRate_Code), " Hz");
        Get_S1 (3, Channels_Code,                               "Channels"); Param_Info2(OpenMG_Channels(Channels_Code), " channel(s)");
        Get_S2 (10, FrameSize,                                  "Frame size");
        BS_End();
    }
    Skip_XX(Size-Element_Offset,                                "Unknown");

    FILLING_BEGIN();
        if (!Status[IsAccepted])
        {
            File__Tags_Helper::Accept();

            Fill(Stream_Audio, 0, Audio_Format, OpenMG_CodecID_Format(CodecID));
            Fill(Stream_Audio, 0, Audio_Encryption, OpenMG_CodecID_Encryption(CodecID));
            int64u StreamSize=(int64u)-1;
            if (File_Size!=(int64u)-1)
            {
                StreamSize=File_Size-(Buffer_Offset+Element_Size);
                Fill(Stream_Audio, 0, Audio_StreamSize, StreamSize);
            }
            if (CodecID<=1) // Atrac3
            {
                Fill(Stream_Audio, 0, Audio_Channel_s_, OpenMG_Channels(Channels_Code));
                Fill(Stream_Audio, 0, Audio_ChannelPositions, OpenMG_ChannelPositions(Channels_Code));
                if (Channels_Code==1 && JointStereo)
                    Fill(Stream_Audio, 0, Audio_Format_Settings_Mode, "Joint Stereo");
                Fill(Stream_Audio, 0, Audio_SamplingRate, OpenMG_SamplingRate(SamplingRate_Code));

                if (CodecID==1) //Protected
                    FrameSize++; //Not sure
                FrameSize<<=3; //8-byte  blocks
                int64u BitRate=OpenMG_SamplingRate(SamplingRate_Code)*FrameSize/256;
                Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
                if (StreamSize!=(int64u)-1 && BitRate)
                    Fill(Stream_Audio, 0, Audio_Duration, StreamSize*8*1000/BitRate);
            }
        }
    FILLING_END();
}
Пример #3
0
//---------------------------------------------------------------------------
void File_ArriRaw::Read_Buffer_Continue()
{
    //Parsing
    Skip_C4(                                                    "Signature");
    Skip_C1(                                                    "Signature");
    Skip_C3(                                                    "Signature");
    Skip_XX(File_Size-8,                                        "Data");

    FILLING_BEGIN();
        Frame_Count++;
        if (Frame_Count_NotParsedIncluded!=(int64u)-1)
            Frame_Count_NotParsedIncluded++;
        if (!Status[IsFilled])
        {
            Fill();
            if (Config->ParseSpeed<1.0)
                Finish();
        }
    FILLING_END();
}
Пример #4
0
//---------------------------------------------------------------------------
void File_Mpc::FileHeader_Parse()
{
    //Parsing
    Element_Begin("SV7 header", 21);
    Ztring Encoder;
    int32u FrameCount;
    int16u TitleGain, AlbumGain;
    int8u  Profile, Link, SampleFreq, EncoderVersion;

    Skip_C3(                                                    "Signature");
    BS_Begin();
    Skip_S1(4,                                                  "PNS");
    Skip_S1(4,                                                  "Version");
    BS_End();

    Get_L4 (FrameCount,                                         "FrameCount");

    Skip_L2(                                                    "MaxLevel");
    BS_Begin();
    Get_S1 (4, Profile,                                         "Profile"); Param_Info(Mpc_Profile[Profile]);
    Get_S1 (2, Link,                                            "Link"); Param_Info(Mpc_Link[Link]);
    Get_S1 (2, SampleFreq,                                      "SampleFreq"); Param_Info(Mpc_SampleFreq[SampleFreq]);
    Skip_SB(                                                    "IntensityStereo");
    Skip_SB(                                                    "MidSideStereo");
    Skip_S1(6,                                                  "MaxBand");
    BS_End();

    Skip_L2(                                                    "TitlePeak");
    Get_L2 (TitleGain,                                          "TitleGain"); Param_Info(((float32)((int16s)TitleGain))/1000, 2, " dB");

    Skip_L2(                                                    "AlbumPeak");
    Get_L2 (AlbumGain,                                          "AlbumGain"); Param_Info(((float32)((int16s)TitleGain))/1000, 2, " dB");

    BS_Begin();
    Skip_S2(16,                                                 "unused");
    Skip_S1( 4,                                                 "LastFrameLength (part 1)");
    Skip_SB(                                                    "FastSeekingSafe");
    Skip_S1( 3,                                                 "unused");
    Skip_SB(                                                    "TrueGapless");
    Skip_S1( 7,                                                 "LastFrameLength (part 2)");
    BS_End();

    Get_L1 (EncoderVersion,                                     "EncoderVersion");
    Encoder.From_Number(((float)EncoderVersion)/100, 2); if (EncoderVersion%10==0); else if (EncoderVersion%2==0) Encoder+=_T(" Beta"); else if (EncoderVersion%2==1) Encoder+=_T(" Alpha"); Param_Info(Encoder);

    Element_End();

    FILLING_BEGIN();
        File__Tags_Helper::Accept("Musepack SV7");

        File__Tags_Helper::Stream_Prepare(Stream_Audio);
        Fill(Stream_Audio, 0, Audio_SamplingRate, Mpc_SampleFreq[SampleFreq]);
        Fill(Stream_Audio, 0, Audio_SamplingCount, FrameCount*1152);
        Fill(Stream_Audio, 0, Audio_Format, "Musepack SV7");
        Fill(Stream_Audio, 0, Audio_Codec, "SV7");
        Fill(Stream_Audio, 0, Audio_Codec_Settings, Mpc_Profile[Profile]);
        Fill(Stream_Audio, 0, Audio_Encoded_Library, Encoder);
        Fill(Stream_Audio, 0, Audio_Resolution, 16); //MPC support only 16 bits
        Fill(Stream_Audio, 0, Audio_Duration, ((int64u)FrameCount)*1152*1000/Mpc_SampleFreq[SampleFreq]);
        if (FrameCount)
            Fill(Stream_Audio, 0, Audio_BitRate, (File_Size-25)*8*Mpc_SampleFreq[SampleFreq]/FrameCount/1152);

        //No more need data
        File__Tags_Helper::Finish("Musepack SV7");
    FILLING_END();
}
Пример #5
0
//---------------------------------------------------------------------------
void File_Id3::Read_Buffer_Continue()
{
    //Buffer size
    if (Buffer_Size<128)
        return;

    int32u Magic;
    Peek_B4(Magic);
    Ztring TitleAddition;
    Ztring ArtistAddition;
    Ztring AlbumAddition;
    Ztring GenreAddition;
    if (Magic==0x5441472B)
    {
        if (Buffer_Size<227+128)
            return;

        Skip_C4   (                                                 "ID");
        Get_Local (60, TitleAddition,                               "Title");
        Get_Local (60, ArtistAddition,                              "Artist");
        Get_Local (60, AlbumAddition,                               "Album");
        Skip_B1   (                                                 "Speed");
        Get_Local (30, GenreAddition,                               "Genre");
        Skip_Local(6,                                               "Start time"); //mmm:ss
        Skip_Local(6,                                               "End time"); //mmm:ss

        TitleAddition.TrimRight();
        ArtistAddition.TrimRight();
        AlbumAddition.TrimRight();
        GenreAddition.TrimRight();
    }

    //Parsing
    Ztring Title, Artist, Album, Year, Comment;
    int8u Track=0, Genre;
    Skip_C3   (                                                 "ID");
    Get_Local (30, Title,                                       "Title");
    Get_Local (30, Artist,                                      "Artist");
    Get_Local (30, Album,                                       "Album");
    Get_Local ( 4, Year,                                        "Year");
    Get_Local (30, Comment,                                     "Comment");
    if (Comment.size()<29) //Id3v1.1 specifications : Track number addition
    {
        Element_Offset-=2;
        int8u Zero;
        Peek_B1(Zero);
        if (Zero==0)
        {
            Skip_B1(                                            "Zero");
            Get_B1 (Track,                                      "Track");
        }
        else
            Element_Offset+=2;
    }
    Get_B1 (Genre,                                              "Genre");

    FILLING_BEGIN();
        if (TitleAddition.empty())
            Title.TrimRight();
        if (ArtistAddition.empty())
            Artist.TrimRight();
        if (AlbumAddition.empty())
            Album.TrimRight();
        Year.TrimRight();
        Comment.TrimRight();

        Accept("Id3");

        Stream_Prepare(Stream_General);
        Fill(Stream_General, 0, General_Album, Album+AlbumAddition);
        Fill(Stream_General, 0, General_Track, Title+TitleAddition);
        Fill(Stream_General, 0, General_Performer, Artist+ArtistAddition);
        Fill(Stream_General, 0, General_Comment, Comment);
        Fill(Stream_General, 0, General_Recorded_Date, Year);
        if (GenreAddition.empty())
            Fill(Stream_General, 0, General_Genre, GenreAddition);
        if (Genre && Genre!=(int8u)-1)
            Fill(Stream_General, 0, General_Genre, Genre);
        if (Track)
            Fill(Stream_General, 0, General_Track_Position, Track);

        Finish("Id3");
    FILLING_END();
}