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 517744492C for ; Tue, 1 Nov 2022 00:07:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E1CA768BE20; Tue, 1 Nov 2022 02:07:39 +0200 (EET) Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 08DBE68BD4C for ; Tue, 1 Nov 2022 02:07:33 +0200 (EET) Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-13bd19c3b68so15206879fac.7 for ; Mon, 31 Oct 2022 17:07:32 -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=1M1ExYQ9h5Y+RUrMUvOMCcNWH4Qg7E+M/AliJkwqxY8=; b=hsCj4EQqK1aoGnzNu7Ekh51Ov+J646Vm3Izz8EenwenjkoqhC/2NeJ07eJx/oboXJy jAHaszVtuPpOwI1wRbQy1fwHRd1s67s/fEluinjODDNxBY8NUUyu7L3qG5xSmKExSvXZ 51gXoqf543PkrpV5JRQaUO/foFJz8CpzLK5wc3pPM4qimQ1oudyaQnEC30Z/YHeohOiw 4pW3d0rMC4lHfdUERg1XBBi1Fu1+zDT2Ba/dA8Y7u965YdJTEERccMq1iNFcgWIVZAwa 93cGPNcesUFXtnf5xe3lv/T7E0dofzIWBB7q8+edDWciriGztLSqQ3PJUCfwg4YjYDlI mP1g== 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=1M1ExYQ9h5Y+RUrMUvOMCcNWH4Qg7E+M/AliJkwqxY8=; b=jtzIHfbNoUYkheYpRz+XV2Ili8/feeC2HkXkjv6Kpo4lbb1G36WLYkZIym1qsw9FcT rb8cW6pWevFaBlX7r+5kRedcILh6kMURIniB9gqpilPZcPbpZi5XHJnxLRjM9QwPnJKw z9fXfHf7XrEgjUSPvO9RpuG2hZreMr49AXXdvu+Agyp+YNkDTJWZJi+Z1lIUFMseOjV+ 8OFNMB7ceHRsZyVv8ymXptTTwkfPnTmzX06S8NhiQruoJ1US5CS2mZqeEZdmmoDPM0mq ezrUHp4h+TfL8sBNCCoywvqyxnsf0Z197PNBYZZkr23B9IKygjNeWuXGUlLxfFfNKcf8 WCIA== X-Gm-Message-State: ACrzQf0TjnEmEweiIoU4gWvvASUHdWE9GheLRXswlagQNzQX4gE8Vx3K lUoZ3RSYWeu+9DSO64ftHJ4q0uVZHfo= X-Google-Smtp-Source: AMsMyM6/t557/9dQXWZghRZQt+As8cKgXeF8FgvdxTGK/uihF7Rrg2KaHy3SlXmanHXe5dmnfvM9Xw== X-Received: by 2002:a05:6870:40cb:b0:131:4fec:3c7d with SMTP id l11-20020a05687040cb00b001314fec3c7dmr18902852oal.147.1667261251040; Mon, 31 Oct 2022 17:07:31 -0700 (PDT) Received: from localhost.localdomain ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id q16-20020a056870e61000b00136c20b1c59sm3748142oag.43.2022.10.31.17.07.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 17:07:30 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Oct 2022 21:06:27 -0300 Message-Id: <20221101000627.8454-1-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3] 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 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: 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 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c index ee71645a3c..2bc023cb23 100644 --- a/libavcodec/atrac3plusdec.c +++ b/libavcodec/atrac3plusdec.c @@ -48,6 +48,17 @@ #include "atrac.h" #include "atrac3plus.h" +static const 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, 6, 3, }, + { 0, 1, 2, 4, 5, 6, 7, 3, }, +}; + typedef struct ATRAC3PContext { GetBitContext gb; AVFloatDSPContext *fdsp; @@ -65,6 +76,7 @@ typedef struct ATRAC3PContext { int num_channel_blocks; ///< number of channel blocks uint8_t channel_blocks[5]; ///< channel configuration descriptor + const uint8_t *channel_map; ///< channel layout map } ATRAC3PContext; static av_cold int atrac3p_decode_close(AVCodecContext *avctx) @@ -143,6 +155,8 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, return AVERROR_INVALIDDATA; } + ctx->channel_map = channel_map[channels - 1]; + return 0; } @@ -378,7 +392,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[ctx->channel_map[out_ch_index + i]], ctx->outp_buf[i], ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p)); ch_block++; -- 2.38.1 _______________________________________________ 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".