[FFmpeg-devel] [PATCH] gxf only read valid audio samples

Reimar Döffinger Reimar.Doeffinger
Wed Sep 24 08:33:59 CEST 2008


Hello,
it's been a long time since I read the spec, so I might be wrong in
details but I still think most applies..

On Tue, Sep 23, 2008 at 06:00:40PM -0700, Baptiste Coudurier wrote:
> -        // NOTE: there is also data length information in the
> -        // field information, it might be better to take this into account
> -        // as well.
> +        if (st->codec->codec_id == CODEC_ID_PCM_S24LE ||
> +            st->codec->codec_id == CODEC_ID_PCM_S16LE) {
> +            int first = field_info >> 16;
> +            int last  = field_info & 0xffff;
> +            int bps = av_get_bits_per_sample(st->codec->codec_id)>>3;
> +            pkt_len = last*bps;
> +            if (first) {
> +                url_fskip(pb, first*bps);
> +                pkt_len -= first*bps;
> +            }

This should do something half-sane for first > last

> +            skip = (32768-last)*bps;

This should be the original pkt_len minus the new pkt_len and what we
already skipped.
Also IMO the original pkt_len should take priority in case
last*bps > original packet length.
I guess a easy way would be to just ignore field info (preferably with
an error message) if first > last or last * bps > pkt_len.
Btw. I am not sure "last" is such a good name, since at least the way
you use it, it is the sample after the last, so "num_samples" (or
something better if you find one).

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list