* [FFmpeg-devel] [PATCH] libavcodec/mlpdec: add missing correction to ch_layout when downmixing
@ 2023-11-26 5:01 Geoffrey McRae via ffmpeg-devel
2023-11-26 13:19 ` James Almer
0 siblings, 1 reply; 2+ messages in thread
From: Geoffrey McRae via ffmpeg-devel @ 2023-11-26 5:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Geoffrey McRae
This fixes corrupted audio for applications relying on ch_layout when
codec downmixing is active.
Signed-off-by: Geoffrey McRae <geoff@hostfission.com>
---
libavcodec/mlpdec.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
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;
--
2.39.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/mlpdec: add missing correction to ch_layout when downmixing
2023-11-26 5:01 [FFmpeg-devel] [PATCH] libavcodec/mlpdec: add missing correction to ch_layout when downmixing Geoffrey McRae via ffmpeg-devel
@ 2023-11-26 13:19 ` James Almer
0 siblings, 0 replies; 2+ messages in thread
From: James Almer @ 2023-11-26 13:19 UTC (permalink / raw)
To: ffmpeg-devel
On 11/26/2023 2:01 AM, Geoffrey McRae via ffmpeg-devel wrote:
> This fixes corrupted audio for applications relying on ch_layout when
> codec downmixing is active.
>
> Signed-off-by: Geoffrey McRae <geoff@hostfission.com>
> ---
> libavcodec/mlpdec.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> 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;
Applied, thanks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-26 13:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-26 5:01 [FFmpeg-devel] [PATCH] libavcodec/mlpdec: add missing correction to ch_layout when downmixing Geoffrey McRae via ffmpeg-devel
2023-11-26 13:19 ` James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git