diff options
author | James Almer <jamrial@gmail.com> | 2025-01-15 22:19:54 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2025-01-19 15:14:18 -0300 |
commit | bb033e69107b5baad5fcec63bd8cd0b6908a2041 (patch) | |
tree | 217824ba69743eb057b01e2f9dba8910865081ce | |
parent | 4563cf95caeaa1f1bcb263b1ef6bb16932357903 (diff) | |
download | ffmpeg-bb033e69107b5baad5fcec63bd8cd0b6908a2041.tar.gz |
avcodec/ac3dec: only export matrix encoding and downmix info side data when necessary
Don't export a matrix encoding side data when there's none signaled.
And if downmixing was handled by the decoder itself, then the downmix info does
not apply to the frame.
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavcodec/ac3dec.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index eb5cfd9818..ff8cbfb0b4 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1500,7 +1500,6 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, uint8_t extended_channel_map[EAC3_MAX_CHANNELS]; const SHORTFLOAT *output[AC3_MAX_CHANNELS]; enum AVMatrixEncoding matrix_encoding; - AVDownmixInfo *downmix_info; uint64_t mask; s->superframe_size = 0; @@ -1827,11 +1826,16 @@ skip: break; } } - if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0) + if (matrix_encoding != AV_MATRIX_ENCODING_NONE && + (ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0) return ret; /* AVDownmixInfo */ - if ((downmix_info = av_downmix_info_update_side_data(frame))) { + if ( (s->channel_mode > AC3_CHMODE_STEREO) && + ((s->output_mode & ~AC3_OUTPUT_LFEON) > AC3_CHMODE_STEREO)) { + AVDownmixInfo *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 +1858,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; |