diff mbox series

[FFmpeg-devel,v2,13/27] avcodec/wavpack: Only reset DSD context upon parameter change

Message ID GV1P250MB07371963C9B80DBB6520FD738F002@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 70e79d289b42d2e895dd4bab8324d0cbadf6a9df
Headers show
Series [FFmpeg-devel,v2,01/27] avcodec/threadprogress: Add new API for frame-threaded progress | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt April 8, 2024, 8:13 p.m. UTC
The current code resets it all the time unless we are decoding
a DSD frame with identical parameters to the last frame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/wavpack.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 6fd297a002..51ac943fe7 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -1526,10 +1526,10 @@  static int wavpack_decode_block(AVCodecContext *avctx, AVFrame *frame, int block
         }
 
         /* clear DSD state if stream properties change */
-        if (new_ch_layout.nb_channels != wc->dsd_channels ||
-            av_channel_layout_compare(&new_ch_layout, &avctx->ch_layout) ||
-            new_samplerate != avctx->sample_rate    ||
-            !!got_dsd      != !!wc->dsdctx) {
+        if ((wc->dsdctx && !got_dsd) ||
+            got_dsd && (new_ch_layout.nb_channels != wc->dsd_channels ||
+                        av_channel_layout_compare(&new_ch_layout, &avctx->ch_layout) ||
+                        new_samplerate != avctx->sample_rate)) {
             ret = wv_dsd_reset(wc, got_dsd ? new_ch_layout.nb_channels : 0);
             if (ret < 0) {
                 av_log(avctx, AV_LOG_ERROR, "Error reinitializing the DSD context\n");