Example #1
0
//---------------------------------------------------------------------------
void File_Nut::stream()
{
    Element_Name("stream");

    //Parsing
    int64u stream_class, fourcc_length, codec_specific_data_length;
    Skip_VS(                                                    "stream_id");
    Get_VS (stream_class,                                       "stream_class");
    Get_VS (fourcc_length,                                      "fourcc length");
    switch (fourcc_length)
    {
        case 2 : Skip_C2(                                       "fourcc"); break;
        case 4 : Skip_C4(                                       "fourcc"); break;
        default: Skip_XX(fourcc_length,                         "fourcc");
    }
    Skip_VS(                                                    "time_base_id");
    Skip_VS(                                                    "msb_pts_shift");
    Skip_VS(                                                    "max_pts_distance");
    Skip_VS(                                                    "decode_delay");
    Skip_VS(                                                    "stream_flags");
    Get_VS (codec_specific_data_length,                         "codec_specific_data length");
    Skip_XX(codec_specific_data_length,                         "codec_specific_data");
    switch (stream_class)
    {
        case 0 : //video
            {
                Skip_VS(                                        "width");
                Skip_VS(                                        "height");
                Skip_VS(                                        "sample_width");
                Skip_VS(                                        "sample_height");
                Skip_VS(                                        "colorspace_type");
            }
            break;
        case 1 : //audio
            {
                Skip_VS(                                         "samplerate_num");
                Skip_VS(                                         "samplerate_denom");
                Skip_VS(                                         "channel_count");
            }
            break;
        case 2 : //subtitles
            {
            }
            break;
        case 3 : //userdata
            {
            }
            break;
        default: ;
    }

    if (Element_Offset!=Element_Size)
        Skip_XX(Element_Size - Element_Offset,                  "Data");
}
Example #2
0
//---------------------------------------------------------------------------
void File_Nut::Header_Parse()
{
    //Parsing
    int8u  N;
    Peek_B1(N);
    if (N==0x4E) //'N'
    {
        //Header
        int64u startcode, forward_ptr;
        Get_B8(startcode,                                       "startcode");
        Get_VS(forward_ptr,                                     "forward_ptr");
        if (forward_ptr>4096)
            Skip_B4(                                            "header_checksum");

        Header_Fill_Code(startcode, Ztring().From_Number(startcode, 16)); //Quick filling for CC8 with text
        Header_Fill_Size(Element_Offset+forward_ptr); //4 for cheksum

    }
    else
    {
        //Frame
        Header_Fill_Code(0, "Frame");
        Header_Fill_Size(0);
        Finish();
    }
}
//---------------------------------------------------------------------------
void File_MpcSv8::SH()
{
    //Parsing
    int64u SampleCount;
    int8u  Version, SampleFrequency, ChannelCount;
    bool   MidSideStereo;
    Skip_B4(                                                    "CRC32");
    Get_B1 (Version,                                            "Version");
    Get_VS (SampleCount,                                        "Sample count");
    Skip_VS(                                                    "Beginning silence");
    BS_Begin();
    Get_S1 (3, SampleFrequency,                                 "Sample frequency"); Param_Info(Mpc_SampleFreq[SampleFrequency]);
    Skip_S1(5,                                                  "Max used bands");
    Get_S1 (4, ChannelCount,                                    "Channel count");
    Get_SB (   MidSideStereo,                                   "Mid side stereo used");
    Skip_S1(3,                                                  "Audio block frames");
    BS_End();

    //Filling
    FILLING_BEGIN();
        Fill(Stream_Audio, 0, Audio_SamplingRate, Mpc_SampleFreq[SampleFrequency]);
        if (SampleCount)
        {
            Fill(Stream_Audio, 0, Audio_SamplingCount, SampleCount);
            Fill(Stream_Audio, 0, Audio_Duration, SampleCount*1000/Mpc_SampleFreq[SampleFrequency]);
            Fill(Stream_Audio, 0, Audio_BitRate, File_Size*8*Mpc_SampleFreq[SampleFrequency]/SampleCount); //Should be more precise...
        }
        Fill(Stream_Audio, 0, Audio_Resolution, 16); //MPC support only 16 bits
    FILLING_END();
}
Example #4
0
//---------------------------------------------------------------------------
void File_Bpg::Read_Buffer_Continue()
{
    //Parsing
    Ztring Version;
    int64u Width, Height;
    int8u  pixelformat, BitsDepth, ColorSpace;
    bool   Alpha1_flag, Alpha2_flag, ReservedZeros, limited_range_flag, ExtensionPresentFlag;
    Element_Begin1("File header");
    Skip_C4(                                                    "Magic"); // File Magic
    BS_Begin();
        Get_S1 (3, pixelformat,                                 "pixel_format"); Param_Info1(Bpg_Pixel_format(pixelformat));
        Get_SB (Alpha1_flag,                                    "Alpha1 Present Flag");
        Get_S1 (4, BitsDepth,                                   "bit_depth_minus_8");

        Get_S1(4, ColorSpace,                                   "color_space"); Param_Info1(Bpg_ColorSpace(ColorSpace)); Param_Info1(Bpg_colour_primaries(ColorSpace));
        Get_SB (ExtensionPresentFlag,                           "Extension Present Flag");
        Get_SB (Alpha2_flag,                                    "Alpha2 Present Flag");
        Get_SB (limited_range_flag,                             "limited_range_flag");
        Get_SB (ReservedZeros,                                  "Reserved");
    BS_End();

    Get_VS(Width,                                               "Picture Width");
    Get_VS(Height,                                              "Picture Height");


    Element_End0();

    FILLING_BEGIN();
        Accept("BPG");

        Stream_Prepare(Stream_Image);
        Fill(Stream_Image, 0, Image_Width, Width);
        Fill(Stream_Image, 0, Image_Height, Height);
        Fill(Stream_Image, 0, Image_Format, __T("BPG"));
        Fill(Stream_Image, 0, Image_ChromaSubsampling, Bpg_Pixel_format(pixelformat));
        Fill(Stream_Image, 0, Image_ColorSpace, Bpg_ColorSpace(ColorSpace));
        Fill(Stream_Image, 0, Image_colour_primaries, Bpg_colour_primaries(ColorSpace));
        Fill(Stream_Image, 0, Image_BitDepth, BitsDepth + 8);
        Fill(Stream_Image, 0, Image_Codec, __T("BPG"));
    FILLING_END();

    Finish("BPG");
}
//---------------------------------------------------------------------------
void File_MpcSv8::Header_Parse()
{
    //Parsing
    int64u Size;
    int16u Key;
    Get_C2 (Key,                                                "Key");
    Get_VS (Size,                                               "Size");

    //Filling
    Header_Fill_Code(Key, Ztring().From_CC4(Key<<16)); //Quick filling for CC2 with text
    Header_Fill_Size(Key==Elements::AP?Element_Offset:Size); //We don't need the data of audio packet, and we will stop here...
}
Example #6
0
//---------------------------------------------------------------------------
void File_Nut::main()
{
    Element_Name("main");

    //Parsing
    int64u time_base_count;
    Skip_VS(                                                    "version");
    Skip_VS(                                                    "stream_count");
    Skip_VS(                                                    "max_distance");
    Get_VS (time_base_count,                                    "time_base_count");
    for(int64u i=0; i<time_base_count; i++)
    {
        Skip_VS(                                                "time_base_num");
        Skip_VS(                                                "time_base_denom");
        //time_base[i]= time_base_num/time_base_denom
    }
    int64u tmp_mul=1, tmp_stream=0;
    int64s tmp_pts=0;
    for(int16u i=0; i<256;)
    {
        int64u tmp_fields, tmp_size, tmp_res, count;
        Skip_VS(                                                "tmp_flag");
        Get_VS (tmp_fields,                                     "tmp_fields");
        if(tmp_fields>0)
            Skip_VS(                                            "tmp_pts"); //TODO: signed
        if(tmp_fields>1)
            Skip_VS(                                            "tmp_mul");
        if(tmp_fields>2)
            Skip_VS(                                            "tmp_stream");
        if(tmp_fields>3)
            Get_VS (tmp_size,                                   "tmp_size");
        else
            tmp_size=0;
        if(tmp_fields>4)
            Get_VS (tmp_res,                                    "tmp_res");
        else
            tmp_res=0;
        if(tmp_fields>5)
            Get_VS(count,                                       "count");
        else
            count=tmp_mul-tmp_size;
        for(int64u j=6; j<tmp_fields; j++)
            Skip_VS(                                            "tmp_reserved[i]");

        for(int64u j=0; j<count && i<256; j++, i++)
        {
            if (i == 'N')
            {
                //flags[i]= FLAG_INVALID;
                j--;
                continue;
            }
            //flags[i]= tmp_flag;
            //stream_id[i]= tmp_stream;
            //data_size_mul[i]= tmp_mul;
            //data_size_lsb[i]= tmp_size + j;
            //pts_delta[i]= tmp_pts;
            //reserved_count[i]= tmp_res;
        }
    }
}