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

Unified · Split

libavcodec/ac3dec.c+8−5
@@ -1500,7 +1500,6 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1499 unmodified lines
1500 uint8_t extended_channel_map[EAC3_MAX_CHANNELS];1500 uint8_t extended_channel_map[EAC3_MAX_CHANNELS];
1501 const SHORTFLOAT *output[AC3_MAX_CHANNELS];1501 const SHORTFLOAT *output[AC3_MAX_CHANNELS];
1502 enum AVMatrixEncoding matrix_encoding;1502 enum AVMatrixEncoding matrix_encoding;
1503 AVDownmixInfo *downmix_info;
1504 uint64_t mask;1503 uint64_t mask;
1505 1504
1506 s->superframe_size = 0;1505 s->superframe_size = 0;
@@ -1827,11 +1826,16 @@ skip: · 320 unmodified lines
1827 break;1826 break;
1828 }1827 }
1829 }1828 }
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)
1831 return ret;1831 return ret;
1832 1832
1833 /* AVDownmixInfo */1833 /* 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);
1835 switch (s->preferred_downmix) {1839 switch (s->preferred_downmix) {
1836 case AC3_DMIXMOD_LTRT:1840 case AC3_DMIXMOD_LTRT:
1837 downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT;1841 downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT;
@@ -1854,8 +1858,7 @@ skip: · 16 unmodified lines
1854 downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level];1858 downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level];
1855 else1859 else
1856 downmix_info->lfe_mix_level = 0.0; // -inf dB1860 downmix_info->lfe_mix_level = 0.0; // -inf dB
1857 } else1861 }
1858 return AVERROR(ENOMEM);
1859 1862
1860 *got_frame_ptr = 1;1863 *got_frame_ptr = 1;
1861 1864

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