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 BCF3A448BA for ; Sun, 30 Oct 2022 19:30:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EC5CD68BCA6; Sun, 30 Oct 2022 21:30:42 +0200 (EET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073086.outbound.protection.outlook.com [40.92.73.86]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A7E468B0F2 for ; Sun, 30 Oct 2022 21:30:37 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xhb7gvwJIdqqC219jBsflogfqZwfD8bBot5IbCeRdkzgcIhSBzOG0szhlWDIKCVOGMNDW1y7Z776flEBJyei2fXKvX7u92tVsFYiVxuKbaKz4DR2Qw5w2zD7QYmz/A/NnEKCpONX0//ZilowGdE2spiGzoHcfnmZM9QNTRlqafakvlHMa2hp5+SCoPwSesgG2qtZ1SsRU58Fs1bS+Xl3YwKhcEi3y0p4elUJTm1HF/X7jf0jHuN7n/M08Nhtc3OeRjEMpIOK9uvD5a/PvdpWkZizlfNzK6pXIqk1YXusCoQz93RgU1v4S1Ax5so3WubhGScH/iv9b8yumg6r2gFi4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u1DKfaDAaLP5C1yDkgy36iygcNIrprw03Ymsw2Kplp8=; b=S7+dxvgkl9JoTuZ/SC+G7CZw0WSwgBqXHOVO9sB9ETYONxNaqxVQatX1QmKfALQIH/V4RqU/CSyt/EbJ6UGDsMvhFNNr4kg0EOD5Mfp0XdUWKFIPQesCIXYXKM8Xdg5uAX0h0Lwpauf5mqfyk14uMUgQ6uG7y8XDpyQb19xB29QJaeQGI/Fy7y1MBZ2W5Qnuburv/qLhKsJd3SgYPUp3rpSKgz2DxjUuVf2iC/vd9EbR7/weLGdMXvKegxKVIpYR17rG2oUEMFNtk4Zs0Qh+A8F84/3xMMDvmdfnil1TjPQEvt3HiciKfLlU7kY46urM3p7b1HWEFU61P1icxpjpHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u1DKfaDAaLP5C1yDkgy36iygcNIrprw03Ymsw2Kplp8=; b=gkHmdrp75OoU7ucCwa5Wof/crDjrrgvQ6qqP/oZi5DwemsUcgimfopYHwSQ50J2M90saDowRyKSMYaaFYpWH0FPOrIUbWfUWQJOau5iwQsHXpIf/Ar+ohiEOOdFyGbg/GJAEM423DDTbPFoR8OEdYAlp3NtDmj8+zArJOxaWK4jBExyb8DLx9LAoa6nyh3xP5++TSXOBlVAxFm1Q0BKUfxgUWvBOr8+KeQvfyUof8HT0QtG5//p0aapW5qRVa9O94LQBuLgK4Pe4cHL6k3m42rH7rXYK81svqR6c83jaoXVzZ30ZmYnAogqbAtI88kpragZoj+klBm3YqUViegk8NQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0100.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:173::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.16; Sun, 30 Oct 2022 19:30:34 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::739a:8740:19c5:925c]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::739a:8740:19c5:925c%5]) with mapi id 15.20.5769.019; Sun, 30 Oct 2022 19:30:34 +0000 Message-ID: Date: Sun, 30 Oct 2022 20:30:46 +0100 To: ffmpeg-devel@ffmpeg.org References: <20221027164940.46118-1-jamrial@gmail.com> Content-Language: en-US From: Andreas Rheinhardt In-Reply-To: <20221027164940.46118-1-jamrial@gmail.com> X-TMN: [MPEDN3EZQk+0sy714Kgh9bvMPJeNiZaOCNaHRVJQk70=] X-ClientProxiedBy: FR0P281CA0048.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::10) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <545f2950-f3db-8841-b06d-a62053a2a32b@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0100:EE_ X-MS-Office365-Filtering-Correlation-Id: 80cb98e9-3c23-4758-0559-08dabaad3755 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kzW6xkg4ZEwQP0MnttzvFuoQoE4CmQQm7rTd45ohxa+USrSqN4q/fMfhsX9Dcchn5jun462VZ3k+b7+7hqKp/ommAgTBMrwWPjjtxLH2fDpehDeJzWAmZd5qtjQMqDl+HuUgMat5SzEWwmHiE9fM93e5jpZhm34oK3ZkCJKEKYqOVXu9mWVpadL/aqk0WSDXzDT+n4C778axxGyBpm15fr1yj1XsSrj6NXVtE3ePDYCn4wah7/E7jwvxG5OOFABZIg6sPqkQ9KmDXtv1oNzXI20wGgAEJtHwNEtlolFgvJdIT23wrCMF4XiqmagIHRD7IWC4qTiTK4x8cZ4EWr63wKdAmDZJb78bnnC9X4T2wfYcPvqknOcJ07m59nvRTDy4HRRb3j/YwSI3Jn141TDu2PK54Pl1CCCo6v8i4Ty4E3gvJ1jR7SVKH6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5YaHMzV3VDMnMyNElkVEgvQmZsT1RjSk8yMFRNanlo?= =?utf-8?B?eTFKb2JJb1JUcmpBZWtsVUlMOThYaWlqU2E2bHQvdWlRaVpzYmZ0RjlkdlJu?= =?utf-8?B?elo3VjdqNVJ1VThadGNxTTk1STFTRWQwWDgveU5KN0lPM0ZQQTNlUzdFVFlj?= =?utf-8?B?cFJsKzJXN3ZOZ1c3OVoxQkZsSWV3REVkZm11anVPV3hNZ0FnaVB5M29lazZ1?= =?utf-8?Q?Sr93Mop+c/zNhADJk1eVb97hzvOCB4Bc416fWvv?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80cb98e9-3c23-4758-0559-08dabaad3755 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2022 19:30:34.8804 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0100 Subject: Re: [FFmpeg-devel] [PATCH] 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: James Almer: > 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 > --- > 6.1 and 7.1 untested, but much like 5.1 they were wrong before this change. > > libavcodec/atrac3plusdec.c | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c > index ee71645a3c..8c3d20af76 100644 > --- a/libavcodec/atrac3plusdec.c > +++ b/libavcodec/atrac3plusdec.c > @@ -65,6 +65,7 @@ typedef struct ATRAC3PContext { > > int num_channel_blocks; ///< number of channel blocks > uint8_t channel_blocks[5]; ///< channel configuration descriptor > + AVChannelLayout coded_ch_layout; ///< order of channels as coded in the bitstream > } ATRAC3PContext; > > static av_cold int atrac3p_decode_close(AVCodecContext *avctx) > @@ -74,6 +75,8 @@ static av_cold int atrac3p_decode_close(AVCodecContext *avctx) > av_freep(&ctx->ch_units); > av_freep(&ctx->fdsp); > > + av_channel_layout_uninit(&ctx->coded_ch_layout); > + > ff_mdct_end(&ctx->mdct_ctx); > ff_mdct_end(&ctx->ipqf_dct_ctx); > > @@ -84,6 +87,7 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, > AVCodecContext *avctx) > { > int channels = avctx->ch_layout.nb_channels; > + int ret; > memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks)); > > av_channel_layout_uninit(&avctx->ch_layout); > @@ -92,17 +96,20 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, > avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; > ctx->num_channel_blocks = 1; > ctx->channel_blocks[0] = CH_UNIT_MONO; > + ctx->coded_ch_layout = avctx->ch_layout; > break; > case 2: > avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; > ctx->num_channel_blocks = 1; > ctx->channel_blocks[0] = CH_UNIT_STEREO; > + ctx->coded_ch_layout = avctx->ch_layout; > break; > case 3: > avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND; > ctx->num_channel_blocks = 2; > ctx->channel_blocks[0] = CH_UNIT_STEREO; > ctx->channel_blocks[1] = CH_UNIT_MONO; > + ctx->coded_ch_layout = avctx->ch_layout; > break; > case 4: > avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0; > @@ -110,6 +117,7 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, > ctx->channel_blocks[0] = CH_UNIT_STEREO; > ctx->channel_blocks[1] = CH_UNIT_MONO; > ctx->channel_blocks[2] = CH_UNIT_MONO; > + ctx->coded_ch_layout = avctx->ch_layout; > break; > case 6: > avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK; > @@ -118,6 +126,9 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, > ctx->channel_blocks[1] = CH_UNIT_MONO; > ctx->channel_blocks[2] = CH_UNIT_STEREO; > ctx->channel_blocks[3] = CH_UNIT_MONO; > + ret = av_channel_layout_from_string(&ctx->coded_ch_layout, "FL+FR+FC+BL+BR+LFE"); > + if (ret < 0) > + return ret; > break; > case 7: > avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_BACK; > @@ -127,6 +138,9 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, > ctx->channel_blocks[2] = CH_UNIT_STEREO; > ctx->channel_blocks[3] = CH_UNIT_MONO; > ctx->channel_blocks[4] = CH_UNIT_MONO; > + ret = av_channel_layout_from_string(&ctx->coded_ch_layout, "FL+FR+FC+BL+BR+BC+LFE"); > + if (ret < 0) > + return ret; > break; > case 8: > avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1; > @@ -136,6 +150,9 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, > ctx->channel_blocks[2] = CH_UNIT_STEREO; > ctx->channel_blocks[3] = CH_UNIT_STEREO; > ctx->channel_blocks[4] = CH_UNIT_MONO; > + ret = av_channel_layout_from_string(&ctx->coded_ch_layout, "FL+FR+FC+BL+BR+SL+SR+LFE"); > + if (ret < 0) > + return ret; > break; > default: > av_log(avctx, AV_LOG_ERROR, > @@ -377,10 +394,12 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame, > reconstruct_frame(ctx, &ctx->ch_units[ch_block], > channels_to_process, avctx); > > - for (i = 0; i < channels_to_process; i++) > - memcpy(samples_p[out_ch_index + i], ctx->outp_buf[i], > + for (i = 0; i < channels_to_process; i++) { > + enum AVChannel ch = av_channel_layout_channel_from_index(&ctx->coded_ch_layout, out_ch_index + i); > + int idx = av_channel_layout_index_from_channel(&frame->ch_layout, ch); > + memcpy(samples_p[idx], ctx->outp_buf[i], > ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p)); > - > + } > ch_block++; > out_ch_index += channels_to_process; > } Wouldn't it be simpler to just use a hardcoded array like { 0, 1, 2, 4, 5, 6, 3 } for 6.1 (and other arrays for the other layouts) instead of using the channel layout API to do it (after all, the order of channels in enum AVChannel won't change)? This would avoid the allocations inherent in av_channel_layout_from_string() as well as the function calls in atrac3p_decode_frame(). Apart from that, setting a channel layout via assignment is forbidden (yes, i know it is safe here, because you are just copying an explicit layout once more). - Andreas _______________________________________________ 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".