[FFmpeg-devel] [Patch] Behaviour of liba52 decoder

Michael Niedermayer michaelni
Thu Jan 10 18:34:04 CET 2008


On Thu, Jan 10, 2008 at 02:00:24PM +0100, Thorsten Jordan wrote:
> Ivo schrieb:
> > On Thursday 10 January 2008 13:24, Thorsten Jordan wrote:
> >> Michael Niedermayer schrieb:
> >>> Hi
> >>>
> >> as this is my first longer patch, please be patient with me ;)
> >> i hope indentation is correct.
> > 
> > I have no knowledge of how to interface to liba52, but by just looking at 
> > the patch I notice a lot of lines being only indented differently. Those 
> > should not change in the initial patch. They can be reindented for cosmetic 
> > reasons afterwards. e.g.
> [...]
> > -}
> yes you are right. and i don't know if my error handling is ok that way
> 
> here is a second version that reused original lines as good as i can.
> result may look weird, but...

[...]
> +    if (!buf || buf_size < HEADER_SIZE) {

unless CODEC_CAP_DELAY is set buf cannot be NULL


> +        av_log(avctx, AV_LOG_ERROR, "Error decoding frame, not enough bytes for header\n");
> +        return -1;
> +    }
> +                len = s->a52_syncinfo(buf, &s->flags, &sample_rate, &bit_rate);
>                  if (len == 0) {
...
> +                    av_log(avctx, AV_LOG_ERROR, "Error decoding frame, no sync byte at begin\n");
> +                    return -1;
> +                }
>                      /* update codec info */
>                      avctx->sample_rate = sample_rate;
>                      s->channels = ac3_channels[s->flags & 7];
> @@ -194,18 +180,10 @@
>                          avctx->channels = s->channels;
>                      }
>                      avctx->bit_rate = bit_rate;
...
> +    if (buf_size < len) {
> +        av_log(avctx, AV_LOG_ERROR, "Error decoding frame, not enough bytes\n");
> +        return -1;
> +    }

Please move this check before setting anything like the sample_rate.
A packet of the wrong size is not convincing in terms of carring correct
sample_rate, channels, ... information


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

Thouse who are best at talking, realize last or never when they are wrong.
-------------- 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/20080110/d2839060/attachment.pgp>



More information about the ffmpeg-devel mailing list