From patchwork Sun Nov 26 05:01:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoffrey McRae X-Patchwork-Id: 44805 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bca6:b0:181:818d:5e7f with SMTP id fx38csp2508102pzb; Sat, 25 Nov 2023 21:01:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYdFtZVUxs1y5zLThs6wWbXZ3VV1v+P5W+kO/yA/Wbj4tqcQGgICS9EHKIAzOUI/UK4UgZ X-Received: by 2002:a17:906:b791:b0:9fe:6546:6cd2 with SMTP id dt17-20020a170906b79100b009fe65466cd2mr5135551ejb.32.1700974873938; Sat, 25 Nov 2023 21:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700974873; cv=none; d=google.com; s=arc-20160816; b=W/I+wwLOv6Z9hicReVnv7e4a200kS5cTuTZLIJ2xICir3QBvWLmfGbHE9nGBkR/FfZ TxvBJdbPYaDomL+LpJYOnlKRTc878V/UcUG7qru8B+OtfetQC0QT8lN4/7zRIMNbbfz1 qoH3iTD8JM353UyUdKjYYwzBQG4/chPkgYwhTDLruOUz0e1mNp8yCm5MmWfTaUy54iWE s5Afe1nH+FcwWaHQ7eMci7XXaQKNfDK+RhH9Qe4bmy2JV3rzXfTzeBN6RPFqMsvFvFRJ L1xi13zB8C+KugwefvHOed84fYfFPeMvFYDh2E0S6ZMm9/3CbbzY/6mp0t7e0Km5CvJ3 H3KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to :delivered-to; bh=xA3pge9iFMWYt+pVd0DmSrlZXRriFx2IKEiKVmEZZII=; fh=hNE7h42qM2XxuRTcO+7OnYPFIYww24ZCpnHAyUPDybE=; b=uDwbKAw6y42gtMCcmTax+4mOmuD3bdZziaA75DI2CkSY8wB2m7BNdv3DkvHt/QW5zy cPvUXOolIHJqg0KMgj5gnLmeDHjMw4O3jMtXORhTWN71qkyzsSnb+u+ypQadiVSTxOSo SVTbB3qRLBlj33g6Z6/2/U2mO31C3D0Bc+8vlDK7dQ4yJjE4MBLEdf/b7WEZH1njRubl Fq9TARQHrq5dVERb+vAx8ZzJWiMbNt9JAscg5roZlBVyI/xfd97NoUZQ+li3eBXpMVgG +nAmYTg1ZnM3AxMRH31EO/t+9KhiO+aFDMUSZ2F3JRc40DPUcb3MwmOA/2STGPOGgFLX uAJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u17-20020a1709063b9100b009e68dd4e1e6si3910432ejf.350.2023.11.25.21.01.13; Sat, 25 Nov 2023 21:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4309768CF2E; Sun, 26 Nov 2023 07:01:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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: , X-Patchwork-Original-From: Geoffrey McRae via ffmpeg-devel From: Geoffrey McRae Reply-To: FFmpeg development discussions and patches Cc: Geoffrey McRae Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bzaUv2O4d+DM 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;