aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorGeoffrey McRae <geoff@hostfission.com>2023-11-26 16:01:00 +1100
committerJames Almer <jamrial@gmail.com>2023-11-26 10:18:33 -0300
commit93b5d9030b1f22feb3d8ff242f638d5e0009ce3a (patch)
tree3144e693595295bd86c234b365cfc5be70775f7c /libavcodec
parenta8677bcc8f2f9561be070cb9412c5a2be9e5be7f (diff)
downloadffmpeg-93b5d9030b1f22feb3d8ff242f638d5e0009ce3a.tar.gz
libavcodec/mlpdec: add missing correction to ch_layout when downmixing
This fixes corrupted audio for applications relying on ch_layout when codec downmixing is active. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mlpdec.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index f1524b95a6..18e0f47864 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -306,6 +306,23 @@ FF_DISABLE_DEPRECATION_WARNINGS
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
+
+ if (m->downmix_layout.nb_channels) {
+ if (!av_channel_layout_compare(&m->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO) ||
+ !av_channel_layout_compare(&m->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX)) {
+ av_channel_layout_uninit(&avctx->ch_layout);
+ avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
+ } else if (!av_channel_layout_compare(&m->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0)) {
+ av_channel_layout_uninit(&avctx->ch_layout);
+ avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0;
+ } else if (!av_channel_layout_compare(&m->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1)) {
+ av_channel_layout_uninit(&avctx->ch_layout);
+ avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1;
+ }
+ else
+ av_log(avctx, AV_LOG_WARNING, "Invalid downmix layout\n");
+ }
+
ff_thread_once(&init_static_once, init_static);
return 0;