diff mbox series

[FFmpeg-devel] avcodec/mlpdec: update matrix encoding only if it changed

Message ID 20210906175834.17313-1-onemda@gmail.com
State Accepted
Commit 114634a51a7ca2ea4d375d62eba55123ce2262d5
Headers show
Series [FFmpeg-devel] avcodec/mlpdec: update matrix encoding only if it changed | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Paul B Mahol Sept. 6, 2021, 5:58 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/mlpdec.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 4320cb4524..408ba80cd4 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -73,6 +73,7 @@  typedef struct SubStream {
     uint64_t    mask;
     /// The matrix encoding mode for this substream
     enum AVMatrixEncoding matrix_encoding;
+    enum AVMatrixEncoding prev_matrix_encoding;
 
     /// Channel coding parameters for channels in the substream
     ChannelParams channel_params[MAX_CHANNELS];
@@ -1121,8 +1122,12 @@  static int output_data(MLPDecodeContext *m, unsigned int substr,
                                                     is32);
 
     /* Update matrix encoding side data */
-    if ((ret = ff_side_data_update_matrix_encoding(frame, s->matrix_encoding)) < 0)
-        return ret;
+    if (s->matrix_encoding != s->prev_matrix_encoding) {
+        if ((ret = ff_side_data_update_matrix_encoding(frame, s->matrix_encoding)) < 0)
+            return ret;
+
+        s->prev_matrix_encoding = s->matrix_encoding;
+    }
 
     *got_frame_ptr = 1;
 
@@ -1351,6 +1356,7 @@  static void mlp_decode_flush(AVCodecContext *avctx)
         SubStream *s = &m->substream[substr];
 
         s->lossless_check_data = 0xffffffff;
+        s->prev_matrix_encoding = 0;
     }
 }