aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Aimar <fenrir@videolan.org>2011-09-26 23:37:30 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-01 20:38:43 +0200
commit9851184d304c85b6863dd3a7553e81f4cba32cfa (patch)
treecaee487c9fa7289fdc45e833aa8ccc9d4339366e
parent9770127cd8b16053b23a3f9fa693f23e18f410c6 (diff)
downloadffmpeg-9851184d304c85b6863dd3a7553e81f4cba32cfa.tar.gz
Reset internal state on corrupted blocks in wavpack decoder.
wavpack_decode_block() supposes that it is called back with the exact same buffer unless it has returned with an error. With multi-channels files, wavpack_decode_frame() was breaking this assumption. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit c2a016ad4d9c29285813ba5806189e63e063e0fb)
-rw-r--r--libavcodec/wavpack.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index a785b90046..28e866356d 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -1173,6 +1173,15 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
return samplecount * bpp;
}
+static void wavpack_decode_flush(AVCodecContext *avctx)
+{
+ WavpackContext *s = avctx->priv_data;
+ int i;
+
+ for (i = 0; i < s->fdec_num; i++)
+ wv_reset_saved_context(s->fdec[i]);
+}
+
static int wavpack_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
@@ -1205,11 +1214,14 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
if(frame_size < 0 || frame_size > buf_size){
av_log(avctx, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n",
s->block, frame_size, buf_size);
+ wavpack_decode_flush(avctx);
return -1;
}
if((samplecount = wavpack_decode_block(avctx, s->block, data,
- data_size, buf, frame_size)) < 0)
+ data_size, buf, frame_size)) < 0) {
+ wavpack_decode_flush(avctx);
return -1;
+ }
s->block++;
buf += frame_size; buf_size -= frame_size;
}