From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 859304786E for ; Sun, 26 Nov 2023 05:01:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F277A68CF0A; Sun, 26 Nov 2023 07:01:09 +0200 (EET) Received: from mail1.hostfission.com (mail1.hostfission.com [118.127.8.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A8EFC68CC59 for ; Sun, 26 Nov 2023 07:01:03 +0200 (EET) Received: from aeryn.lan.ktmba (office.hostfission.com [220.233.29.71]) by mail1.hostfission.com (Postfix) with ESMTPS id 560911E8ED9; Sun, 26 Nov 2023 16:01:02 +1100 (AEDT) Received: by aeryn.lan.ktmba (Postfix, from userid 1000) id 1ECA52E064F; Sun, 26 Nov 2023 16:01:02 +1100 (AEDT) To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Nov 2023 16:01:00 +1100 Message-Id: <20231126050100.1686194-1-geoff@hostfission.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavcodec/mlpdec: add missing correction to ch_layout when downmixing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Geoffrey McRae via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Geoffrey McRae Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This fixes corrupted audio for applications relying on ch_layout when codec downmixing is active. Signed-off-by: Geoffrey McRae --- 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".