diff mbox series

[FFmpeg-devel,2/2] avcodec/ac3dec: export downmix info side data only when no downmix is done by the decoder

Message ID 20230112222326.22018-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/ac3dec: don't export Matrix Encoding side data when no such info is coded | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

James Almer Jan. 12, 2023, 10:23 p.m. UTC
Same as with Matrix Encoding, add a check to ensure the decoder is not
doing a downmix of its own.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/ac3dec.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 7a84f3c85d..722a1028b7 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1824,7 +1824,11 @@  skip:
         return ret;
 
     /* AVDownmixInfo */
-    if ((downmix_info = av_downmix_info_update_side_data(frame))) {
+    if (s->channel_mode == (s->output_mode & ~AC3_OUTPUT_LFEON)) {
+        downmix_info = av_downmix_info_update_side_data(frame);
+        if (!downmix_info)
+            return AVERROR(ENOMEM);
+
         switch (s->preferred_downmix) {
         case AC3_DMIXMOD_LTRT:
             downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT;
@@ -1847,8 +1851,7 @@  skip:
             downmix_info->lfe_mix_level       = gain_levels_lfe[s->lfe_mix_level];
         else
             downmix_info->lfe_mix_level       = 0.0; // -inf dB
-    } else
-        return AVERROR(ENOMEM);
+    }
 
     *got_frame_ptr = 1;