From patchwork Sun Aug 29 21:27:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29863 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp3402570iov; Sun, 29 Aug 2021 14:29:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdh4LMCirCUmJIrlLGbYH5AjOWw3dUxgQdfp71bWQDbsJt8wfmaX7a3wAODyjWwtgU97wp X-Received: by 2002:a05:6402:d66:: with SMTP id ec38mr21430730edb.234.1630272542443; Sun, 29 Aug 2021 14:29:02 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bl3si12638264ejb.204.2021.08.29.14.29.02; Sun, 29 Aug 2021 14:29:02 -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=@outlook.com header.s=selector1 header.b=R7oPxEpo; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 61AA068A255; Mon, 30 Aug 2021 00:28:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075055.outbound.protection.outlook.com [40.92.75.55]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B1F9687F49 for ; Mon, 30 Aug 2021 00:28:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQXzkr3/c7+ZA7+lCEpBmzhf9pIcocuMOBvYqskA4/OmKr6yOA0RzV7qiLhOAUlCuITyjX32ewfqeChAFXvrdNU2I4kULVagRfKu2LVbG5PF9g5+ZXcCVF0elY11FcwbrJWsluiS2QPhnYL4wxarV9Yi0r15v34PTpPJ21dIQ5LxLMmHDZ4I4mcmaze9HtIal73MVgYuccXa3wuhCRhXNOdWDKjRWLsA/wiV6rDQe6vfxmB6WNcwyXE/GVxQk9t5o/QrFyqLvjawsKv6d9nlxJP18Y7qzl3AKDdZMlOBBZYLgQNDH17XCJDmI2d4MHBkOfOiEQ1L4vmbqQ8dgqFPmA== 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-SenderADCheck; bh=xJ7PyjKF2UTZXoZQ3xFxpkMBI6cYuoGoQdBA0licNfQ=; b=SamVob8Rwkdrql6ndHoYwBppPgrcPGeewzTF8+2v/Ven5J8jlHko4d/4+P3JwoLP90IKFepfy01VOhEx5YNJHpzxIZytMQK1qVMpiB23X0bT6jfnChZCVQ48e+GOUJQzY7QGXeI9mMS+YKCLTNrBbUpJ+HFhWtL6Jr3ytaCr7+QXhSuXb+om4YdxJc8kMLWPN6suLNILZIfqq3eWaO7EuAs0JMhDWsLMOwEGzOIsnZPqbKLHKo8ZM79Rvt2KT4oS1Mbt2YKqL5kyE0cx3LjJdXq26wOfCcneoEILgJw6VCyvc9F7YBSz/ylL75+e8A8okO09DMNMSVVo/IC+7SzOLg== 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=xJ7PyjKF2UTZXoZQ3xFxpkMBI6cYuoGoQdBA0licNfQ=; b=R7oPxEpoZmA6KDeBiQ8qs4u5iZ3rpCOLM6Ji4vcni8So3oFrAQjTRRpHKse63CdgDutAuCAsDYdqEwWEX+a+6cu1yTgoyMZDFGZy05UxnL4CwpM8V7moFXriV+CfU7k0T5wlvhrdQLfb2efueFj+vcnLNehT9qf6ZwrqyvzWY3SllywrYd3byhR77BEnJm7E9EyG2I2pVpwC7+6prg6/RJCu47CKVNcIt+4ZCHZIR95300Oc64I4PnQfbQQ3xFKwwaqUmwAr0+/WWBJSm/I3bARQcepS1YA6+Q7sARi4CQvGePwiRicaZC8kkb6Y8w8MNta+66HnyxyPDPVwkEQc7A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB5927.eurprd03.prod.outlook.com (2603:10a6:20b:e3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.23; Sun, 29 Aug 2021 21:28:09 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f8b5:1ef2:89b2:f8c5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f8b5:1ef2:89b2:f8c5%7]) with mapi id 15.20.4457.024; Sun, 29 Aug 2021 21:28:09 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 29 Aug 2021 23:27:42 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [tfNHBRYEO3ybFiRqW+PmwBdm8dJL7pOk] X-ClientProxiedBy: PR0P264CA0178.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::22) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210829212744.1505779-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.142.38) by PR0P264CA0178.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.19 via Frontend Transport; Sun, 29 Aug 2021 21:28:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9fc01e3-9248-499a-32bf-08d96b33e5d6 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNXOVIHST31EzKLNwg5cTLbyy99m4OYHHlsMWUm9Lf2fZcr/BoyUF0+KQdsOw6dAsBrpowl6fN/ZvGhgXLH0xi/sT6NUKX17Z/slu4OS62UeMzSrtunhPEqfOoOBtGhr2nTAC2dPgc3iME9IbuTl/gzAT2GZWZzGAJE4x3ZKsL5C+3UiWhs3wskVx99zpLldIxFAFZLmeFIgu3C8NEV18b1Cbc4tKHeZKnCKG51w9P3Byfq4GIqowYFsfAv72toEEf+6JsJceeIGlkh8CuJVbLjxZvmxy2jX4glQ6AW890Cewk3Lvq8K2oUAGOdiOxR12Q+Ik+y9VzA9kI7UOm9Q9k6d0QKM61rODFGugteRpIBjNPEswOUXn4rAE2BlxJ8Nv64damUMUcLWucVh9TYuSH5fs2RZ3ZdGQ1T7lZOcbkIcnWyiWg98c7QnyDLwk9zz60mdZKTjYXyHn1XOAI9mWblBhvpQcOw0uCJXq1LDIRvFJM1b2Wc1+j3bX4Xug06ZdJNoVYIIFOd4+wWD5eqpZDIES1fKLXu81wDIZgxLZm/6enNmisWcVRnZXDYsjGQDl0wLbluRss9r4fbNAxSIibAY8M/OX6kH0qH1LCZVHqqfOWFbc25tpuUmSc6RpVcxE2QfC9EABSenMq/kfvV28eSI8rMjsaBPajxb0g+m4MYRxsoNfn3hyqn0r7ZPaSWQ/39EeDlEFW8AlbIXfRbfi7dZVJRDFNBgkpU= X-MS-TrafficTypeDiagnostic: AM6PR03MB5927: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G3l9S6H9aB4c8GvR27QcJR060LsiQMTFveueCxlxd3+/0yyUeq4ukyd/0QxLmI0DqywBq0ANLXi1SkOjilitAbHZK8zklwfN3TZul8Pksa0wJF4juGmBAr/wsm/ya2ItDW+f1nHwgZ8zb/u+2b/ewP/EFZzYEcify6HWyzVJJsn/tOqmO1Hv0MV5nAGL73D5Y6W3QJnZpBySLyCpe1su8PRtmZ8Gy6bJGEI1qu+wHnbm0oR0oBnhtZFOqL2prwbeXxh0g5oU3cJf4Kr1Exh8/QgHIBxd7GqqZUjxA2wId0fQfgvvTX8QQy+06NZ8dhKqFEJa2Qf+dYL+5pmbuxMPZouUSYJHDcMInu34dDNrQAZ+PA4i3smYlcfVDm/YXNIzS6A9aQbxoJcN/AzIgrX5lPipeV+amw7Iq13oKvSAHc3SK6N/invRlR1FhMGP1pyB X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2e+AY5HhYaJIvcHAovp7h2BYCz4LXUo3p3ggPt1U0AQFjjXiKM+2Acvl+AwT9FPCyDFmMpLmnR7pTcgeqEUuifTVkGT4BX3DROHlWXHGQKVN8LEN+3wlUtEHlOtT8amLr+cdpka+SdNlWPCf3e4UOA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9fc01e3-9248-499a-32bf-08d96b33e5d6 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2021 21:28:09.5290 (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: AM6PR03MB5927 Subject: [FFmpeg-devel] [PATCH 09/11] avformat/aptxdec: Use ff_pcm_read_packet 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fm+ZEOMTX+No It automatically honours block_align and it clears the AV_PKT_FLAG_CORRUPT flag which up until now was always set for the last packet if the number of input blocks was not divisible by 256 (or equivalently: if the number of input samples was not divisible by 1024). It reads more data at once; this necessitated updates to FATE reference files. Signed-off-by: Andreas Rheinhardt --- One could easily implement seeking for this format via ff_pcm_read_seek; but it would fail miserably for damaged inputs. libavformat/Makefile | 4 ++-- libavformat/aptxdec.c | 15 +++------------ tests/ref/fate/aptx | 15 +++------------ tests/ref/fate/aptx-hd | 15 +++------------ 4 files changed, 11 insertions(+), 38 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 7e0f587b41..becf07867d 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -99,9 +99,9 @@ OBJS-$(CONFIG_APM_DEMUXER) += apm.o OBJS-$(CONFIG_APM_MUXER) += apm.o rawenc.o OBJS-$(CONFIG_APNG_DEMUXER) += apngdec.o OBJS-$(CONFIG_APNG_MUXER) += apngenc.o -OBJS-$(CONFIG_APTX_DEMUXER) += aptxdec.o +OBJS-$(CONFIG_APTX_DEMUXER) += aptxdec.o pcm.o OBJS-$(CONFIG_APTX_MUXER) += rawenc.o -OBJS-$(CONFIG_APTX_HD_DEMUXER) += aptxdec.o +OBJS-$(CONFIG_APTX_HD_DEMUXER) += aptxdec.o pcm.o OBJS-$(CONFIG_APTX_HD_MUXER) += rawenc.o OBJS-$(CONFIG_AQTITLE_DEMUXER) += aqtitledec.o subtitles.o OBJS-$(CONFIG_ARGO_ASF_DEMUXER) += argo_asf.o diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c index a5ed921e2c..2cbf9a2cb8 100644 --- a/libavformat/aptxdec.c +++ b/libavformat/aptxdec.c @@ -22,6 +22,7 @@ #include "libavutil/opt.h" #include "avformat.h" +#include "pcm.h" #define APTX_BLOCK_SIZE 4 #define APTX_PACKET_SIZE (256*APTX_BLOCK_SIZE) @@ -70,16 +71,6 @@ static int aptx_hd_read_header(AVFormatContext *s) return 0; } -static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE); -} - -static int aptx_hd_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - return av_get_packet(s->pb, pkt, APTX_HD_PACKET_SIZE); -} - static const AVOption aptx_options[] = { { "sample_rate", "", offsetof(AptXDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, @@ -99,7 +90,7 @@ const AVInputFormat ff_aptx_demuxer = { .extensions = "aptx", .priv_data_size = sizeof(AptXDemuxerContext), .read_header = aptx_read_header, - .read_packet = aptx_read_packet, + .read_packet = ff_pcm_read_packet, .flags = AVFMT_GENERIC_INDEX, .priv_class = &aptx_demuxer_class, }; @@ -112,7 +103,7 @@ const AVInputFormat ff_aptx_hd_demuxer = { .extensions = "aptxhd", .priv_data_size = sizeof(AptXDemuxerContext), .read_header = aptx_hd_read_header, - .read_packet = aptx_hd_read_packet, + .read_packet = ff_pcm_read_packet, .flags = AVFMT_GENERIC_INDEX, .priv_class = &aptx_demuxer_class, }; diff --git a/tests/ref/fate/aptx b/tests/ref/fate/aptx index ff890f6943..bf43d7612a 100644 --- a/tests/ref/fate/aptx +++ b/tests/ref/fate/aptx @@ -6,15 +6,6 @@ e36494e4eaa69dceb9746e784f928198 *tests/data/fate/aptx.aptx #sample_rate 0: 48000 #channel_layout 0: 3 #channel_layout_name 0: stereo -0, 0, 0, 1024, 4096, 0x42e145b7 -0, 1024, 1024, 1024, 4096, 0xfe24da5f -0, 2048, 2048, 1024, 4096, 0x5c9d2323 -0, 3072, 3072, 1024, 4096, 0xc7e155cf -0, 4096, 4096, 1024, 4096, 0xff114281 -0, 5120, 5120, 1024, 4096, 0xd60bb6b0 -0, 6144, 6144, 1024, 4096, 0x2beaa892 -0, 7168, 7168, 1024, 4096, 0xc74c71ca -0, 8192, 8192, 1024, 4096, 0xf49880cc -0, 9216, 9216, 1024, 4096, 0x9eae2532 -0, 10240, 10240, 1024, 4096, 0x096863b2 -0, 11264, 11264, 736, 2944, 0x533118a3 +0, 0, 0, 4096, 16384, 0x443e9917 +0, 4096, 4096, 4096, 16384, 0xc83613ab +0, 8192, 8192, 3808, 15232, 0xbf702262 diff --git a/tests/ref/fate/aptx-hd b/tests/ref/fate/aptx-hd index c924186ef8..bbb1bc090b 100644 --- a/tests/ref/fate/aptx-hd +++ b/tests/ref/fate/aptx-hd @@ -6,15 +6,6 @@ #sample_rate 0: 48000 #channel_layout 0: 3 #channel_layout_name 0: stereo -0, 0, 0, 1024, 8192, 0x85791bdb -0, 1024, 1024, 1024, 8192, 0x8db6dfa9 -0, 2048, 2048, 1024, 8192, 0x617b2190 -0, 3072, 3072, 1024, 8192, 0x733c4d71 -0, 4096, 4096, 1024, 8192, 0xb254420c -0, 5120, 5120, 1024, 8192, 0xc166b305 -0, 6144, 6144, 1024, 8192, 0x93e8a20e -0, 7168, 7168, 1024, 8192, 0xd91c6790 -0, 8192, 8192, 1024, 8192, 0xee6584ae -0, 9216, 9216, 1024, 8192, 0x74a6246d -0, 10240, 10240, 1024, 8192, 0xa20e6fb6 -0, 11264, 11264, 736, 5888, 0x06a6f058 +0, 0, 0, 4096, 32768, 0x6a926a94 +0, 4096, 4096, 4096, 32768, 0xa3dffebe +0, 8192, 8192, 3808, 30464, 0xa3560947