History

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.

James Almer committed 1 year ago

Commit bb033e61 parent 4563cf91 file · +8 −5Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/ac3dec.c+8−5
@@ -1500,7 +1500,6 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1499 unmodified lines
15001500 uint8_t extended_channel_map[EAC3_MAX_CHANNELS];
15011501 const SHORTFLOAT *output[AC3_MAX_CHANNELS];
15021502 enum AVMatrixEncoding matrix_encoding;
1503− AVDownmixInfo *downmix_info;
15041503 uint64_t mask;
15051504
15061505 s->superframe_size = 0;
@@ -1827,11 +1826,16 @@ skip: · 320 unmodified lines
18271826 break;
18281827 }
18291828 }
1830− if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0)
1829+ if (matrix_encoding != AV_MATRIX_ENCODING_NONE &&
1830+ (ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0)
18311831 return ret;
18321832
18331833 /* AVDownmixInfo */
1834− if ((downmix_info = av_downmix_info_update_side_data(frame))) {
1834+ if ( (s->channel_mode > AC3_CHMODE_STEREO) &&
1835+ ((s->output_mode & ~AC3_OUTPUT_LFEON) > AC3_CHMODE_STEREO)) {
1836+ AVDownmixInfo *downmix_info = av_downmix_info_update_side_data(frame);
1837+ if (!downmix_info)
1838+ return AVERROR(ENOMEM);
18351839 switch (s->preferred_downmix) {
18361840 case AC3_DMIXMOD_LTRT:
18371841 downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT;
@@ -1854,8 +1858,7 @@ skip: · 16 unmodified lines
18541858 downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level];
18551859 else
18561860 downmix_info->lfe_mix_level = 0.0; // -inf dB
1857− } else
1858− return AVERROR(ENOMEM);
1861+ }
18591862
18601863 *got_frame_ptr = 1;
18611864

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t