[FFmpeg-devel] [PATCH 2/2] wmavoice: don't error out if we're skipping more bits than available.
Ronald S. Bultje
rsbultje at gmail.com
Fri Dec 16 15:19:45 EET 2016
This reverts 2a4700a4f03280fa8ba4fc0f8a9987bb550f0d1e and implements it
correctly so streams actually decode the way the encoder intended them
to.
---
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
} else
skip_bits_long(gb, s->spillover_nbits); // resync
}
@@ -1926,13 +1920,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
int cnt = get_bits_count(gb);
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(res, avpkt->size);
} else if ((s->sframe_cache_size = pos) > 0) {
/* rewind bit reader to start of last (incomplete) superframe... */
init_get_bits(gb, avpkt->data, size << 3);
--
2.8.1
More information about the ffmpeg-devel
mailing list