[FFmpeg-devel] [PATCH 2/2] avcodec/ac3dec: only export downmixinfo side data when necessary

James Almer jamrial at gmail.com
Thu Jan 16 03:20:12 EET 2025


If downmixing was handled by the decoder itself, then this side data does not apply
to the frame.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/ac3dec.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index eb5cfd9818..3b6c8b1f52 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1831,7 +1831,10 @@ skip:
         return ret;
 
     /* AVDownmixInfo */
-    if ((downmix_info = av_downmix_info_update_side_data(frame))) {
+    if ((s->output_mode != AC3_CHMODE_STEREO) && (s->output_mode != AC3_CHMODE_MONO)) {
+        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;
@@ -1854,8 +1857,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;
 
-- 
2.48.1



More information about the ffmpeg-devel mailing list