ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb,

                           AVStream *st, RMStream *rst, int codec_data_size)

{

    unsigned int v;

    int size;

    int64_t codec_pos;

    int ret;



    avpriv_set_pts_info(st, 64, 1, 1000);

    codec_pos = avio_tell(pb);

    v = avio_rb32(pb);

    if (v == MKTAG(0xfd, 'a', 'r', '.')) {

        /* ra type header */

        if (rm_read_audio_stream_info(s, pb, st, rst, 0))

            return -1;

    } else if (v == MKBETAG('L', 'S', 'D', ':')) {

        avio_seek(pb, -4, SEEK_CUR);

        if ((ret = rm_read_extradata(pb, st->codec, codec_data_size)) < 0)

            return ret;



        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;

        st->codec->codec_tag  = AV_RL32(st->codec->extradata);

        st->codec->codec_id   = ff_codec_get_id(ff_rm_codec_tags,

                                                st->codec->codec_tag);

    } else {

        int fps;

        if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) {

        fail1:

            av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");

            goto skip;

        }

        st->codec->codec_tag = avio_rl32(pb);

        st->codec->codec_id  = ff_codec_get_id(ff_rm_codec_tags,

                                               st->codec->codec_tag);

//        av_log(s, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));

        if (st->codec->codec_id == CODEC_ID_NONE)

            goto fail1;

        st->codec->width  = avio_rb16(pb);

        st->codec->height = avio_rb16(pb);

        avio_skip(pb, 2); // looks like bits per sample

        avio_skip(pb, 4); // always zero?

        st->codec->codec_type = AVMEDIA_TYPE_VIDEO;

        st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;

        fps = avio_rb32(pb);



        if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)

            return ret;



        av_reduce(&st->r_frame_rate.den, &st->r_frame_rate.num,

                  0x10000, fps, (1 << 30) - 1);

        st->avg_frame_rate = st->r_frame_rate;

    }



skip:

    /* skip codec info */

    size = avio_tell(pb) - codec_pos;

    avio_skip(pb, codec_data_size - size);



    return 0;

}

ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb,

                           AVStream *st, RMStream *rst, int codec_data_size)

{

    unsigned int v;

    int size;

    int64_t codec_pos;

    int ret;



    avpriv_set_pts_info(st, 64, 1, 1000);

    codec_pos = avio_tell(pb);

    v = avio_rb32(pb);

    if (v == MKTAG(0xfd, 'a', 'r', '.')) {

        

        if (rm_read_audio_stream_info(s, pb, st, rst, 0))

            return -1;

    } else if (v == MKBETAG('L', 'S', 'D', ':')) {

        avio_seek(pb, -4, SEEK_CUR);

        if ((ret = rm_read_extradata(pb, st->codec, codec_data_size)) < 0)

            return ret;



        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;

        st->codec->codec_tag  = AV_RL32(st->codec->extradata);

        st->codec->codec_id   = ff_codec_get_id(ff_rm_codec_tags,

                                                st->codec->codec_tag);

    } else {

        int fps;

        if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) {

        fail1:

            av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");

            goto skip;

        }

        st->codec->codec_tag = avio_rl32(pb);

        st->codec->codec_id  = ff_codec_get_id(ff_rm_codec_tags,

                                               st->codec->codec_tag);



        if (st->codec->codec_id == CODEC_ID_NONE)

            goto fail1;

        st->codec->width  = avio_rb16(pb);

        st->codec->height = avio_rb16(pb);

        avio_skip(pb, 2); 

        avio_skip(pb, 4); 

        st->codec->codec_type = AVMEDIA_TYPE_VIDEO;

        st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;

        fps = avio_rb32(pb);



        if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)

            return ret;



        av_reduce(&st->r_frame_rate.den, &st->r_frame_rate.num,

                  0x10000, fps, (1 << 30) - 1);

        st->avg_frame_rate = st->r_frame_rate;

    }



skip:

    

    size = avio_tell(pb) - codec_pos;

    avio_skip(pb, codec_data_size - size);



    return 0;

}

        av_reduce(&st->r_frame_rate.den, &st->r_frame_rate.num,         st->avg_frame_rate = st->r_frame_rate;
FUNC_0 (AVFormatContext *VAR_0, AVIOContext *VAR_1,

                           AVStream *VAR_2, RMStream *VAR_3, int VAR_4)

{

    unsigned int VAR_5;

    int VAR_6;

    int64_t codec_pos;

    int VAR_7;



    avpriv_set_pts_info(VAR_2, 64, 1, 1000);

    codec_pos = avio_tell(VAR_1);

    VAR_5 = avio_rb32(VAR_1);

    if (VAR_5 == MKTAG(0xfd, 'a', 'r', '.')) {

        

        if (rm_read_audio_stream_info(VAR_0, VAR_1, VAR_2, VAR_3, 0))

            return -1;

    } else if (VAR_5 == MKBETAG('L', 'S', 'D', ':')) {

        avio_seek(VAR_1, -4, SEEK_CUR);

        if ((VAR_7 = rm_read_extradata(VAR_1, VAR_2->codec, VAR_4)) < 0)

            return VAR_7;



        VAR_2->codec->codec_type = AVMEDIA_TYPE_AUDIO;

        VAR_2->codec->codec_tag  = AV_RL32(VAR_2->codec->extradata);

        VAR_2->codec->codec_id   = ff_codec_get_id(ff_rm_codec_tags,

                                                VAR_2->codec->codec_tag);

    } else {

        int VAR_8;

        if (avio_rl32(VAR_1) != MKTAG('V', 'I', 'D', 'O')) {

        fail1:

            av_log(VAR_2->codec, AV_LOG_ERROR, "Unsupported video codec\n");

            goto skip;

        }

        VAR_2->codec->codec_tag = avio_rl32(VAR_1);

        VAR_2->codec->codec_id  = ff_codec_get_id(ff_rm_codec_tags,

                                               VAR_2->codec->codec_tag);



        if (VAR_2->codec->codec_id == CODEC_ID_NONE)

            goto fail1;

        VAR_2->codec->width  = avio_rb16(VAR_1);

        VAR_2->codec->height = avio_rb16(VAR_1);

        avio_skip(VAR_1, 2); 

        avio_skip(VAR_1, 4); 

        VAR_2->codec->codec_type = AVMEDIA_TYPE_VIDEO;

        VAR_2->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;

        VAR_8 = avio_rb32(VAR_1);



        if ((VAR_7 = rm_read_extradata(VAR_1, VAR_2->codec, VAR_4 - (avio_tell(VAR_1) - codec_pos))) < 0)

            return VAR_7;



        av_reduce(&VAR_2->r_frame_rate.den, &VAR_2->r_frame_rate.num,

                  0x10000, VAR_8, (1 << 30) - 1);

        VAR_2->avg_frame_rate = VAR_2->r_frame_rate;

    }



skip:

    

    VAR_6 = avio_tell(VAR_1) - codec_pos;

    avio_skip(VAR_1, VAR_4 - VAR_6);



    return 0;

}

FUNC_0 (AVFormatContext *VAR_0, AVIOContext *VAR_1,
AVStream *VAR_2, RMStream *VAR_3, int VAR_4)
{ unsigned int VAR_5; int VAR_6; int64_t codec_pos; int VAR_7; avpriv_set_pts_info(VAR_2, 64, 1, 1000); codec_pos = avio_tell(VAR_1); VAR_5 = avio_rb32(VAR_1); if (VAR_5 == MKTAG(0xfd, 'a', 'r', '.')) { if (rm_read_audio_stream_info(VAR_0, VAR_1, VAR_2, VAR_3, 0))
return -1; } else if (VAR_5 == MKBETAG('L', 'S', 'D', ':')) { avio_seek(VAR_1, -4, SEEK_CUR); if ((VAR_7 = rm_read_extradata(VAR_1, VAR_2->codec, VAR_4)) < 0)
return VAR_7; VAR_2->codec->codec_type = AVMEDIA_TYPE_AUDIO; VAR_2->codec->codec_tag  = AV_RL32(VAR_2->codec->extradata); VAR_2->codec->codec_id   = ff_codec_get_id(ff_rm_codec_tags,
VAR_2->codec->codec_tag); } else { int VAR_8; if (avio_rl32(VAR_1) != MKTAG('V', 'I', 'D', 'O')) { fail1:
av_log(VAR_2->codec, AV_LOG_ERROR, "Unsupported video codec\n"); goto skip; } VAR_2->codec->codec_tag = avio_rl32(VAR_1); VAR_2->codec->codec_id  = ff_codec_get_id(ff_rm_codec_tags,
VAR_2->codec->codec_tag); if (VAR_2->codec->codec_id == CODEC_ID_NONE)
goto fail1; VAR_2->codec->width  = avio_rb16(VAR_1); VAR_2->codec->height = avio_rb16(VAR_1); avio_skip(VAR_1, 2); avio_skip(VAR_1, 4); VAR_2->codec->codec_type = AVMEDIA_TYPE_VIDEO; VAR_2->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; VAR_8 = avio_rb32(VAR_1); if ((VAR_7 = rm_read_extradata(VAR_1, VAR_2->codec, VAR_4 - (avio_tell(VAR_1) - codec_pos))) < 0)
return VAR_7; av_reduce(&VAR_2->r_frame_rate.den, &VAR_2->r_frame_rate.num,
0x10000, VAR_8, (1 << 30) - 1); VAR_2->avg_frame_rate = VAR_2->r_frame_rate; } skip:
VAR_6 = avio_tell(VAR_1) - codec_pos; avio_skip(VAR_1, VAR_4 - VAR_6); return 0; }