[FFmpeg-cvslog] avcodec/adpcm_zork: reset state in flush callback

Zane van Iperen git at videolan.org
Thu Mar 25 05:03:56 EET 2021


ffmpeg | branch: master | Zane van Iperen <zane at zanevaniperen.com> | Tue Mar 23 20:52:16 2021 +1000| [95280cf3e795c18175f7e5ca8bb05ef40abb6c42] | committer: Zane van Iperen

avcodec/adpcm_zork: reset state in flush callback

Signed-off-by: Zane van Iperen <zane at zanevaniperen.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=95280cf3e795c18175f7e5ca8bb05ef40abb6c42
---

 libavcodec/adpcm.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 5c28b745b9..b145622f4f 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -2077,13 +2077,6 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
         }
         break;
     case AV_CODEC_ID_ADPCM_ZORK:
-        if (!c->has_status) {
-            for (channel = 0; channel < avctx->channels; channel++) {
-                c->status[channel].predictor  = 0;
-                c->status[channel].step_index = 0;
-            }
-            c->has_status = 1;
-        }
         for (n = 0; n < nb_samples * avctx->channels; n++) {
             int v = bytestream2_get_byteu(&gb);
             *samples++ = adpcm_zork_expand_nibble(&c->status[n % avctx->channels], v);
@@ -2121,7 +2114,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
 static void adpcm_flush(AVCodecContext *avctx)
 {
     ADPCMDecodeContext *c = avctx->priv_data;
-    c->has_status = 0;
+
+    switch(avctx->codec_id) {
+    case AV_CODEC_ID_ADPCM_ZORK:
+        for (int channel = 0; channel < avctx->channels; channel++) {
+            c->status[channel].predictor  = 0;
+            c->status[channel].step_index = 0;
+        }
+        break;
+
+    default:
+        /* Other codecs may want to handle this during decoding. */
+        c->has_status = 0;
+        return;
+    }
+
+    c->has_status = 1;
 }
 
 



More information about the ffmpeg-cvslog mailing list