diff options
author | Jakub Stachowski <qbast@go2.pl> | 2016-04-10 21:33:56 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2016-04-10 21:33:56 +0200 |
commit | 60b75186b2c878b6257b43c8fcc0b1356ada218e (patch) | |
tree | c7562ac6bb0d5d9cece6714c81b88bb883c90eaa | |
parent | 571aa7d25edc414c3da9253af8b80508c5275b4b (diff) | |
download | ffmpeg-60b75186b2c878b6257b43c8fcc0b1356ada218e.tar.gz |
avcodec/wmalosslessdec: do not discard last frame
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavcodec/wmalosslessdec.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 8a5ffb86a5..c41eb6ced6 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -1043,6 +1043,9 @@ static int decode_frame(WmallDecodeCtx *s) if (get_bits1(gb)) { skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); ff_dlog(s->avctx, "end skip: %i\n", skip); + s->frame->nb_samples -= skip; + if (s->frame->nb_samples <= 0) + return AVERROR_INVALIDDATA; } } @@ -1163,7 +1166,11 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, s->frame->nb_samples = 0; - if (s->packet_done || s->packet_loss) { + if (!buf_size && s->num_saved_bits > get_bits_count(&s->gb)) { + s->packet_done = 0; + if (!decode_frame(s)) + s->num_saved_bits = 0; + } else if (s->packet_done || s->packet_loss) { s->packet_done = 0; if (!buf_size) @@ -1264,7 +1271,7 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, s->packet_offset = get_bits_count(gb) & 7; - return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; + return (s->packet_loss) ? AVERROR_INVALIDDATA : buf_size ? get_bits_count(gb) >> 3 : 0; } static void flush(AVCodecContext *avctx) |