[FFmpeg-devel] [PATCH 2/2] wmavoice: don't error out if we're skipping more bits than available.

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Tue Dec 20 00:45:46 EET 2016


On 16.12.2016 14:19, Ronald S. Bultje wrote:
> This reverts 2a4700a4f03280fa8ba4fc0f8a9987bb550f0d1e and implements it
> correctly so streams actually decode the way the encoder intended them
> to.

Why is it correct?
Is this behavior defined in a specification or reference decoder?

> ---
>  libavcodec/wmavoice.c | 20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
> index 0f29bdd..f1b5369 100644
> --- a/libavcodec/wmavoice.c
> +++ b/libavcodec/wmavoice.c
> @@ -1900,16 +1900,10 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
>                      cnt += s->spillover_nbits;
>                      s->skip_bits_next = cnt & 7;
>                      res = cnt >> 3;
> -                    if (res > avpkt->size) {
> -                        av_log(ctx, AV_LOG_ERROR,
> -                               "Trying to skip %d bytes in packet of size %d\n",
> -                               res, avpkt->size);
> -                        return AVERROR_INVALIDDATA;
> -                    }
> -                    return res;
> +                    return FFMIN(avpkt->size, res);
>                  } else
> -                    skip_bits_long (gb, s->spillover_nbits - cnt +
> -                                    get_bits_count(gb)); // resync
> +                    skip_bits_long(gb, s->spillover_nbits - cnt +
> +                                   get_bits_count(gb)); // resync

Please do cosmetic changes in a separate commit.

Best regards,
Andreas


More information about the ffmpeg-devel mailing list