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