From patchwork Mon Oct 31 20:28:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 39091 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8e01:b0:a3:a294:714c with SMTP id y1csp1138098pzj; Mon, 31 Oct 2022 13:29:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4tTM1qr9O+jtvc/IsJAZnKaTCz60JO4ZbdF8If0Gdc3k9LXLjXO+98Gx1wBVnUpEyzvkXd X-Received: by 2002:a17:907:160e:b0:791:8ae7:4fb8 with SMTP id hb14-20020a170907160e00b007918ae74fb8mr15019898ejc.271.1667248153113; Mon, 31 Oct 2022 13:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667248153; cv=none; d=google.com; s=arc-20160816; b=iRFx6z6AmwNY70pQ9E5/adbJ+1s+T4A3kXbkr3/R6FkQqR/ampHvHAeJ2HnYupf0Z0 6s1EtAoFCPMk9/l5RjzlaGJNWGvM8ZLjK5LFfYyVLs7rWDl+rCpR/hBBSiRp1kw5YGhn olp88y+kI/z1fqAOGOahgsXAgiZ3iCDwas/DxF6XQDim4yo35/iY+5VRjRa4G+VzTGrr nKPK8Aldrb0b1lWHnfBHjcuaZxrGxbRj3B2Tkgmmc76ZaDzVQYx/80J57bTxBgB6S/G5 qtMhkC6jwANrGtB/qCBABOYj9ccHdKEauM9nyzYxfplWPCflRbPgYxmnP5V/gSAPnQB2 N+6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=RQzPo4DRmv6P/r2XNl2zvCoPR0ZEm9yn2omoQZd5LOo=; b=sgVXkpyhfb87EIFXClSPHUjcHKOIx0+JKyYUgOnbdcq0U4odaALpua9374T5B7En04 HdfjZrJ0rZM3r7hus/ISDOF01SXbxLPmANAEf+iZcKoRs5VZFWzCWD/YKTuO9gLN48lS 6DDYuA4iiFjdVQ3mpIPf/03wf61ULg1zqQeqiP5MmyeNZua9W+zngDca/hxCxUZEKfkd WwdNI/OaGpoQrrjFFbTANumIlJEzhIVc8gOvYMlUs9erFAJ3K4lpKdH5rLMsDoV4cvfa taBEjC3LxLlh0+1I87MsJ5KoFkx8NOp4ri9yGA/jp1HOH69dcvFPtJ9uLTGBLp3gKHpm 5W8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=T0cfTf1A; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sg9-20020a170907a40900b0078db8bac984si9021758ejc.830.2022.10.31.13.29.12; Mon, 31 Oct 2022 13:29:13 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=T0cfTf1A; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4FAEC68BE07; Mon, 31 Oct 2022 22:29:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8F38968BD55 for ; Mon, 31 Oct 2022 22:29:03 +0200 (EET) Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-13ae8117023so14719434fac.9 for ; Mon, 31 Oct 2022 13:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HGgXbOQNEWLkxBCZX5C/+PkmJF+Rv9tAWQmgfnYzHyY=; b=T0cfTf1AOBJcWX2qAA5jEBjmu4BFXMd8SbfOfpHU2daQfAjnGYkR9PtelwHHs/3bDv yUX6tiT7jGWGxP/AfmrCRgo6pYOgvrGklo2NyzoGu2pKQ1zB9cbL2tPw1OGxc7lfMYPs bMIDo72G8cpQcaXJorpSR9+0J/G/slozQSQ/eCZqSyAVucSdTa3EN1D0MHo6SmrWf9cq 4Vt7JmcdvZSKKwgvJwlwgP/edHlXta+GfaUB+2+4gDpi1LgeF8peE6m4ruRPc9qJZ3AB H7Tn7fUJwoiF354HN5NSoPH9QjwrkO5Fz0Fds5Hqc6iMrGFNe84UOnrqhk7vljuDssQi uNlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HGgXbOQNEWLkxBCZX5C/+PkmJF+Rv9tAWQmgfnYzHyY=; b=kml12AreM3GPBmdvSD2maxWihsnSmEAQeat3BnccuvY45tv9w9whW2Z3alGxR/f7le 9o0++5E3IOSVWwtmEoJVxqB/YTz6/fntQqN3hDdHSWMIP0ClqfiV367LWWLcG+SyfWfy zy7TIv6q4VVeYBYdGKcUQI9VupdvTvPHjZ1qp3oSa+OBGqjgpKRZ6RiwePHOxxw77lW1 6PnC4b1PWpUAr3ALJocy/aROSlfS07MfV0gS9OIZZIgrR4fsJ5QFMTdqYdOkuMQrSAPB kh5lyDOttbxq/hc9FxTED+uIkeivdktMepzxYHEiRvDAFNth6qhCOXxBR1JAkrV6y3/A Gh+A== X-Gm-Message-State: ACrzQf0455wwQMfwFiNy/oYigLMq98TNFrM+tGtxJP7T8NI+IFlHDAtr owhPKYc+fuQdIE/1TYGKQ5bU9wMSTAQ= X-Received: by 2002:a05:6870:2189:b0:132:ad52:d092 with SMTP id l9-20020a056870218900b00132ad52d092mr2460oae.202.1667248141745; Mon, 31 Oct 2022 13:29:01 -0700 (PDT) Received: from localhost.localdomain ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id e8-20020a544f08000000b00354b575424csm2695007oiy.29.2022.10.31.13.29.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 13:29:01 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Oct 2022 17:28:45 -0300 Message-Id: <20221031202845.1860-1-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/atrac3plus: reorder channels to match the output layout 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: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mqAES5bt3StP The order in which the channels are coded in the bitstream do not always follow the native, bitmask-based order of channels both signaled by the WAV container and forced by this same decoder. This is the case with layouts containing an LFE channel, as it's always coded last. Fixes ticket #9964. Signed-off-by: James Almer --- libavcodec/atrac3plusdec.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c index ee71645a3c..9e12f21930 100644 --- a/libavcodec/atrac3plusdec.c +++ b/libavcodec/atrac3plusdec.c @@ -48,6 +48,17 @@ #include "atrac.h" #include "atrac3plus.h" +static uint8_t channel_map[8][8] = { + { 0, }, + { 0, 1, }, + { 0, 1, 2, }, + { 0, 1, 2, 3, }, + { 0, }, + { 0, 1, 2, 4, 5, 3, }, + { 0, 1, 2, 4, 5, 8, 3, }, + { 0, 1, 2, 4, 5, 9, 10, 3, }, +}; + typedef struct ATRAC3PContext { GetBitContext gb; AVFloatDSPContext *fdsp; @@ -378,7 +389,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame, channels_to_process, avctx); for (i = 0; i < channels_to_process; i++) - memcpy(samples_p[out_ch_index + i], ctx->outp_buf[i], + memcpy(samples_p[channel_map[frame->ch_layout.nb_channels - 1][out_ch_index + i]], ctx->outp_buf[i], ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p)); ch_block++;