[FFmpeg-devel] [PATCH] h264/aac in flv

Michael Niedermayer michaelni
Mon May 5 21:02:24 CEST 2008


On Mon, May 05, 2008 at 05:27:59PM +0200, Baptiste Coudurier wrote:
> Michael Niedermayer wrote:
> > On Mon, May 05, 2008 at 03:54:29PM +0200, Baptiste Coudurier wrote:
> >> Hi guys,
> >>
> >> $subject, 2 patches, I'll commit pts/dts renaming seperately.
> >>
> >> Specs: http://www.adobe.com/devnet/flv/
> > [...]
> >> +static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
> >> +{
> >> +    av_free(st->codec->extradata);
> >> +    st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
> > 
> > I think the addition can overflow
> 
> Humm, size is on 24bit (get_be24). Can it still overflow ?

no, sorry, i looked at the wrong size ...
that reminds me why using the same local variable name several times is bad

    size = get_be24(s->pb);
    ...
    if(!url_is_streamed(s->pb) && s->duration==AV_NOPTS_VALUE){
        int size;
        const int pos= url_ftell(s->pb);
        const int fsize= url_fsize(s->pb);
        url_fseek(s->pb, fsize-4, SEEK_SET);
        size= get_be32(s->pb);
        ...



> 
> > [...]
> > 
> >> +            if (type == 0) {
> >> +                if ((ret = flv_get_extradata(s, st, size - 1)) < 0)
> >> +                    return ret;
> >> +                goto retry;
> >> +            }
> >> +        }
> >>      }else{
> >>          size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK);
> >> +        if (st->codec->codec_id == CODEC_ID_H264) {
> >> +            int type = get_byte(s->pb);
> >> +            pkt->pts = dts + get_be24(s->pb);
> > 
> >> +            if (type == 0) {
> >> +                if ((ret = flv_get_extradata(s, st, size - 1)) < 0)
> >> +                    return ret;
> >> +                goto retry;
> >> +            }
> > 
> > code duplication
> 
> Patch updated.
[...]
> @@ -369,6 +385,19 @@
>          size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK);
>      }
>  
> +    if (st->codec->codec_id == CODEC_ID_AAC ||
> +        st->codec->codec_id == CODEC_ID_H264) {
> +        int type = get_byte(s->pb);
> +        size--;
> +        if (st->codec->codec_id == CODEC_ID_H264)
> +            pkt->pts = dts + get_be24(s->pb);
> +        if (type == 0) {
> +            if ((ret = flv_get_extradata(s, st, size - 1)) < 0)
> +                return ret;
> +            goto retry;
> +        }
> +    }

Are multiple type 0 packets allowed? extradata must be strictly global and
must never change. Maybe these could be passed like normal packets? In which
case that problem would disapear.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080505/1b8ff23c/attachment.pgp>



More information about the ffmpeg-devel mailing list