Module: libav
Branch: release/0.7
Commit: d646cce15f140730f288c1a38a79dc7232b31e69

Author:    Laurent Aimar <[email protected]>
Committer: Reinhard Tartler <[email protected]>
Date:      Mon Sep 26 22:18:29 2011 +0000

wavpack: Reset internal state on corrupted blocks

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: Janne Grunau <[email protected]>
(cherry picked from commit 2c6cf1394096d08396faadc6e7c0b404fd6df006)

Signed-off-by: Anton Khirnov <[email protected]>

---

 libavcodec/wavpack.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 155633f..43e1918 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;
     }

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to