[FFmpeg-devel] [PATCH/v3.3] rm.h/rmdec.c changes to allow rtsp

Michael Niedermayer michaelni
Sat Jul 21 23:38:39 CEST 2007


Hi

On Sat, Jul 21, 2007 at 04:03:40PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> attached patch splits packet parsing, cache retrieval and mdpr header
> parsing out into separate functions and exports them for use in rtsp later
> on.

is there a signficant amount of code which will be needed for demuxing rm but
but not rtsp or the other way around, if so they should not be in the same
file so either compilation can be skiped


[...]
> +int
> +ff_rm_read_mdpr_codecdata (ByteIOContext *pb, AVFormatContext *s,
> +                           RMContext     *rm, AVStream        *st,
> +                           int            read_all)
> +{
> +    unsigned int v;
> +    int codec_data_size, res = -1;
> +    int64_t codec_pos;
> +
> +    codec_data_size = get_be32(pb);
> +    codec_pos = url_ftell(pb);
> +    v = get_be32(pb);
> +    if (v == MKTAG(0xfd, 'a', 'r', '.')) {
> +        /* ra type header */
> +        if (rm_read_audio_stream_info(pb, s, rm, st, 0))
> +            goto fail;
> +    } else {
> +        int fps, fps2;
> +        if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
> +        fail1:
> +            av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
> +            goto fail;
> +        }
> +        st->codec->codec_tag = get_le32(pb);
> +//        av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
> +        if (   st->codec->codec_tag != MKTAG('R', 'V', '1', '0')
> +            && st->codec->codec_tag != MKTAG('R', 'V', '2', '0')
> +            && st->codec->codec_tag != MKTAG('R', 'V', '3', '0')
> +            && st->codec->codec_tag != MKTAG('R', 'V', '4', '0'))
> +            goto fail1;
> +        st->codec->width = get_be16(pb);
> +        st->codec->height = get_be16(pb);
> +        st->codec->time_base.num= 1;
> +        fps= get_be16(pb);
> +        st->codec->codec_type = CODEC_TYPE_VIDEO;
> +        get_be32(pb);
> +        fps2= get_be16(pb);
> +        get_be16(pb);
> +
> +        st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
> +
> +        if(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
> +            //check is redundant as get_buffer() will catch this
> +            av_log(s, AV_LOG_ERROR, "st->codec->extradata_size too large\n");
> +            goto fail;
> +        }
> +        st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
> +        get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
> +
> +//        av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
> +        st->codec->time_base.den = fps * st->codec->time_base.num;
> +        switch(((uint8_t*)st->codec->extradata)[4]>>4){
> +        case 1: st->codec->codec_id = CODEC_ID_RV10; break;
> +        case 2: st->codec->codec_id = CODEC_ID_RV20; break;
> +        case 3: st->codec->codec_id = CODEC_ID_RV30; break;
> +        case 4: st->codec->codec_id = CODEC_ID_RV40; break;
> +        default: goto fail1;
> +        }
> +    }
> +
> +    res = 0;
> +fail:
> +    if (read_all) {
> +        /* skip codec info */
> +        int size = url_ftell(pb) - codec_pos;
> +        url_fskip(pb, codec_data_size - size);
> +    }
> +    return res;
> +}

this fail code is new which makes this a patch mixing function movement/split
with functional changes


[...]
> -            codec_data_size = get_be32(pb);
> -            codec_pos = url_ftell(pb);
>              st->codec->codec_type = CODEC_TYPE_DATA;
>              av_set_pts_info(st, 64, 1, 1000);
> -
> -            v = get_be32(pb);
> -            if (v == MKTAG(0xfd, 'a', 'r', '.')) {
> -                /* ra type header */
> -                if (rm_read_audio_stream_info(s, st, 0))
> -                    return -1;
> -            } else {
> -                int fps, fps2;
> -                if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070721/299deb64/attachment.pgp>



More information about the ffmpeg-devel mailing list