From patchwork Thu Jun 17 02:31:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 28435 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp202425iol; Wed, 16 Jun 2021 19:37:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzToahO+ziuP9/G4wlwGFl8xA5Rie7sF/YsC5o2Bgye8ZYyz+Vcf3BZkAkA2+++6DW2jRE0 X-Received: by 2002:a50:d64a:: with SMTP id c10mr3485699edj.199.1623897478323; Wed, 16 Jun 2021 19:37:58 -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 d24si3937767ejo.430.2021.06.16.19.37.58; Wed, 16 Jun 2021 19:37:58 -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=ndhsh0sj; 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 5DBAC689B8C; Thu, 17 Jun 2021 05:33:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073081.outbound.protection.outlook.com [40.92.73.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E8253689B7F for ; Thu, 17 Jun 2021 05:33:26 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nc6KxYK/6uuHbWDIW0QiYAZdbYKxskKGBWwzCwvPh4UQ7sPqWsFBSE7dB9mTtXsYU3/YMKGsREtOwSfFbq7BepKxE/Gl0gSOPhwCZMg3B0z1+bn2vbktAmnGJ8UvxC9TYIMoV53+USgbP5LQWFzGV5imVsFWTX1bs/E0kxG5OAiDYFdIOgIZBGN5/AeJMWtDMBm/j9OeTOhSPKBouLC3y8S0grJ/WLSDyU0tT9I+DZI0RKiXfdJiDBkK7OcxhxyB4gTR3k9xuGWhaFGRfbO/BwX7YIE6b/5e+0KmHlUQU3R1e8qnO+F1V8ZH4CpwsE0ZrMaOimGThtMSNl/f559I+A== 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=UYWtTCkJCb18fhkHXqS1A1qW0j1CjY6UR3hCs9GLLzU=; b=lLXFV8MWxeL3W53EDEnoa7+RiOG9h0Yd/0pTKkBkT7XbphYGKDfdz9XgUyYmPky4VzqnFpMgBX9h/r9vMzxBHqy6YLLoM5ew71UM20xrGxAaEyK6auDJ928wq0BGFvy+35U1a4Mg7F7hrjIl4vUcg52Pzkng5BFETsHWIA8AswDiUYXhv6ocMVbseqBehnK/WpcXqdYICE4kIjZNVNTga5ipB1I1VGQYWPH5DHX12ExO5Nj+Otlz+Wdj0sjLa8cp+rRsbB5hBO3RZMKmsqHHBU86HsXrBwu1ahsYAPA/+oA3GgD7DvLjaZkL1mGNVHG50bAEDs7v7AVn5kAtMzlirQ== 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=UYWtTCkJCb18fhkHXqS1A1qW0j1CjY6UR3hCs9GLLzU=; b=ndhsh0sj5z/K4YQfaVL+oNfXRN+PE9gg4LsXJJ0nr6sWED89HuzzI+O7bvy7XcOFWzpTws5e3Jtu5BGmSADW+5iuyIN3lm/rxCVFJDxCYjiGLtVQVhfUzR7ty2+EEZQpQFINKZBp5N1xDbuhg6ax8UYzZYn1w0NzZXeR4ZV29u0HKpGXUTyHtDnRfVF7k+O66ZnI98Edz4ER5Q9kN4INDTRLNCU+PPleLZ69sEUpCSjvAhPAXCbj89bzI5LCT4LaSzlyJq0NiyaHoOJxgdYPnf3LlLK8MlSA0yfBCZzTbixmY7LiluxWxp8h1ZDbR2aRriP1YggA0pqWdVNhnmMliA== Received: from HE1EUR04FT053.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::4a) by HE1EUR04HT004.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.16; Thu, 17 Jun 2021 02:33:24 +0000 Received: from VI1PR0301MB2159.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::4b) by HE1EUR04FT053.mail.protection.outlook.com (2a01:111:e400:7e0d::298) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.16 via Frontend Transport; Thu, 17 Jun 2021 02:33:24 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:EDBADE0224003C63742009AC57D08AEFB7A0AE548341F714975F289C17E778C6; UpperCasedChecksum:5E3B31E8AFDA9DFFF638AAAF3C04C0CA640EAD8E1E8AB79C308579F09567951C; SizeAsReceived:7576; Count:48 Received: from VI1PR0301MB2159.eurprd03.prod.outlook.com ([fe80::d9b:66ba:63ad:967b]) by VI1PR0301MB2159.eurprd03.prod.outlook.com ([fe80::d9b:66ba:63ad:967b%5]) with mapi id 15.20.4242.019; Thu, 17 Jun 2021 02:33:24 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 04:31:51 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [aEz7c6oFIxCD7PBFfuPrIKForlTWRR3y] X-ClientProxiedBy: AM0PR04CA0115.eurprd04.prod.outlook.com (2603:10a6:208:55::20) To VI1PR0301MB2159.eurprd03.prod.outlook.com (2603:10a6:800:26::20) X-Microsoft-Original-Message-ID: <20210617023202.1318312-29-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.97.82) by AM0PR04CA0115.eurprd04.prod.outlook.com (2603:10a6:208:55::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.16 via Frontend Transport; Thu, 17 Jun 2021 02:33:24 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c65525c4-d453-4dac-3eaa-08d9313847d5 X-MS-Exchange-SLBlob-MailProps: pt8ZUcDWjMV3HWGlskmlUsL8gpBzaNHih4rXU3LMvZ5RcZ76XNDTN04u7/RVD7cLEpeuTRq4iGyl3BpKKy2HgzwCPrYV2rp+Y2VYTPM+xhfL9HGuZa8+pXgUCw/RgdEx7VUiatqEdig4SBnPdhM9/HqPyV3JoLozFphUpieixH3f8pknh+V5hKUVbUilys1UYivVRQmc/ZAe3N7DyqcOx4ghXiIAChxSMiulKVjKlv+HTn2dly3vAawzA2nEw8f3xhjlD6etKfPZqqK9/E9tNKOnVhemZDG6clY4PVEh3lDJ6sort7ZGLW91aA7rCjEuATvJI8w3PYtqG3eOwfaBhjqQsHq1VX1S34e8u94e3yLBTnG70aqqDViapxLWQ8c4sMFpqITC3VsbLDpMlcRW1snentojBbCtnd7RlabNQuBJcpYNtEjTMrZa5vu7IeWorgWsQOmybktYrKn+cJqqsIt5AZ7QQVluoaj5qzPeBtEwMw2VXNxUx1J3unQpxcQr5sn/Yoc+u6jHPcxuDlnzTBmuK7INS4pp8xyPlMT/eOGqSrvr8jsBxBGL7t9Hbe87ceuJrEgCOFZ7jGLNXhKSWa2owYQZR4DXBhXQUMBnfgxBiCGMm175brjlCWsB93GOO1Ve8xCFDHjiZr89G+pXh8UeDq8U3kLrhR+gglHONiIVhDbPcZKA84ZZwyyZK9LvQkVkAzj6Z8cP/+f5WmJy63z1clg/uXMYejEB7kGxubj1m7A6Q9uTYjIGJMyB6E/o5Wn8FbaVtN3eS2AmKknlYsYBZAZLKbozenW898uT1+DOUoE5k+KyWMmWllk0uVvOPaNscVT5BxO/++ibigBjXvFpOEtYtZd9/j9vLdfWwxdLwKwN+kwoM7O9lQRT4es/vYw5elAaoGkGmEWUzl7n8BjFdsabc11ApwKziHIdumX4ATGRI/JYY63zqp1UnGqU X-MS-TrafficTypeDiagnostic: HE1EUR04HT004: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E+P6Ma2vQNW4pvkXVB/SBjzDzs4yWps+m00TxePiXuOjSO7UNb5nLdE4CaBChcWmMmYnClXWi5MzDlUWG6wILbc1Cw75TM8TXZvFFlmikyzqjmcb0rAWkVnxFya7XcRR5Ft2kIb56hszcA+PcZKkqE1vs9ZUx0Pi4LCzOU18siw9bpnvjCsoD0KCdRv4achm8bdT9MPaiymlp3rIPusmWXukfkAkrtUbxkAmQHIV+N+zBtRYT6ibWVgu9Zr/CpMqjVT/tby8qx8quIoD91vGDU75NN1l0ieMLJ9dasdC/2/WHahLbLneZSNv+n/2AcIAfAovwjTwiChLPZoZh023U2KiulS4AKIJHrdbDpCN9mph8XPGiJe+5NXwW+Q+jnwp6pEFfq4G8RS5HhlXgVLmLH2Gp8ANtoVjqloF8pKDs0yBT9XDIOg21zPepew9PzGjjABFozNoySJKlNOmoK9aHA== X-MS-Exchange-AntiSpam-MessageData: y7MDm4x1ZceacD53iEd/PVMB/0sr2w8L63YB3wUTWr3kmzc79Pshk1QdYZdEWNEtur2ZPArpuORLOugQESeH4+zoRJNavXMgwR5ZJOF4Vjx3+WBOaeEDOtzVSdSeQGp/78F4h7j5ZxBlZz4gmOw+mA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c65525c4-d453-4dac-3eaa-08d9313847d5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2021 02:33:24.5771 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT053.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT004 Subject: [FFmpeg-devel] [PATCH 30/41] avcodec/adpcm: Disable dead code 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: aGQArgObNnx3 This change ensures that the linker can drop adpcm_data.o if no decoder that actually uses anything from there is enabled. Signed-off-by: Andreas Rheinhardt --- libavcodec/adpcm.c | 212 +++++++++++++++++++++++---------------------- 1 file changed, 108 insertions(+), 104 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 15aea639dc..171b059409 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -61,6 +61,18 @@ * readstr http://www.geocities.co.jp/Playtown/2004/ */ +#define CASE_0(codec_id, ...) +#define CASE_1(codec_id, ...) \ + case codec_id: \ + { __VA_ARGS__ } \ + break; +#define CASE_2(enabled, codec_id, ...) \ + CASE_ ## enabled(codec_id, __VA_ARGS__) +#define CASE_3(config, codec_id, ...) \ + CASE_2(config, codec_id, __VA_ARGS__) +#define CASE(codec, ...) \ + CASE_3(CONFIG_ ## codec ## _DECODER, AV_CODEC_ID_ ## codec, __VA_ARGS__) + /* These are for CD-ROM XA ADPCM */ static const int8_t xa_adpcm_table[5][2] = { { 0, 0 }, @@ -821,8 +833,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, buf_size = FFMIN(buf_size, avctx->block_align); nb_samples = (buf_size - 4 * ch) * 2 / ch; break; - case AV_CODEC_ID_ADPCM_IMA_WAV: - { + CASE(ADPCM_IMA_WAV, int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2]; int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2]; if (avctx->block_align > 0) @@ -830,8 +841,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, if (buf_size < 4 * ch) return AVERROR_INVALIDDATA; nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples; - break; - } + ) /* End of CASE */ case AV_CODEC_ID_ADPCM_MS: if (avctx->block_align > 0) buf_size = FFMIN(buf_size, avctx->block_align); @@ -955,7 +965,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, st = avctx->channels == 2 ? 1 : 0; switch(avctx->codec->id) { - case AV_CODEC_ID_ADPCM_IMA_QT: + CASE(ADPCM_IMA_QT, /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples). Channel data is interleaved per-chunk. */ for (int channel = 0; channel < avctx->channels; channel++) { @@ -995,8 +1005,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, samples[m + 1] = adpcm_ima_qt_expand_nibble(cs, byte >> 4 ); } } - break; - case AV_CODEC_ID_ADPCM_IMA_WAV: + ) /* End of CASE */ + CASE(ADPCM_IMA_WAV, for (int i = 0; i < avctx->channels; i++) { ADPCMChannelStatus *cs = &(c->status[i]); cs->predictor = samples_p[i][0] = sign_extend(bytestream2_get_le16u(&gb), 16); @@ -1046,8 +1056,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } } - break; - case AV_CODEC_ID_ADPCM_4XM: + ) /* End of CASE */ + CASE(ADPCM_4XM, for (int i = 0; i < avctx->channels; i++) c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); @@ -1069,8 +1079,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(cs, v >> 4 , 4); } } - break; - case AV_CODEC_ID_ADPCM_AGM: + ) /* End of CASE */ + CASE(ADPCM_AGM, for (int i = 0; i < avctx->channels; i++) c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); for (int i = 0; i < avctx->channels; i++) @@ -1081,9 +1091,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_agm_expand_nibble(&c->status[0], v & 0xF); *samples++ = adpcm_agm_expand_nibble(&c->status[st], v >> 4 ); } - break; - case AV_CODEC_ID_ADPCM_MS: - { + ) /* End of CASE */ + CASE(ADPCM_MS, int block_predictor; if (avctx->channels > 2) { @@ -1147,9 +1156,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ms_expand_nibble(&c->status[st], byte & 0x0F); } } - break; - } - case AV_CODEC_ID_ADPCM_MTAF: + ) /* End of CASE */ + CASE(ADPCM_MTAF, for (int channel = 0; channel < avctx->channels; channel += 2) { bytestream2_skipu(&gb, 4); c->status[channel ].step = bytestream2_get_le16u(&gb) & 0x1f; @@ -1169,8 +1177,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, samples_p[channel + 1][n + 1] = adpcm_mtaf_expand_nibble(&c->status[channel + 1], v >> 4 ); } } - break; - case AV_CODEC_ID_ADPCM_IMA_DK4: + ) /* End of CASE */ + CASE(ADPCM_IMA_DK4, for (int channel = 0; channel < avctx->channels; channel++) { ADPCMChannelStatus *cs = &c->status[channel]; cs->predictor = *samples++ = sign_extend(bytestream2_get_le16u(&gb), 16); @@ -1186,9 +1194,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); } - break; - case AV_CODEC_ID_ADPCM_IMA_DK3: - { + ) /* End of CASE */ + + /* DK3 ADPCM support macro */ +#define DK3_GET_NEXT_NIBBLE() \ + if (decode_top_nibble_next) { \ + nibble = last_byte >> 4; \ + decode_top_nibble_next = 0; \ + } else { \ + last_byte = bytestream2_get_byteu(&gb); \ + nibble = last_byte & 0x0F; \ + decode_top_nibble_next = 1; \ + } + CASE(ADPCM_IMA_DK3, int last_byte = 0; int nibble; int decode_top_nibble_next = 0; @@ -1208,17 +1226,6 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, /* sign extend the predictors */ diff_channel = c->status[1].predictor; - /* DK3 ADPCM support macro */ -#define DK3_GET_NEXT_NIBBLE() \ - if (decode_top_nibble_next) { \ - nibble = last_byte >> 4; \ - decode_top_nibble_next = 0; \ - } else { \ - last_byte = bytestream2_get_byteu(&gb); \ - nibble = last_byte & 0x0F; \ - decode_top_nibble_next = 1; \ - } - while (samples < samples_end) { /* for this algorithm, c->status[0] is the sum channel and @@ -1249,9 +1256,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, if ((bytestream2_tell(&gb) & 1)) bytestream2_skip(&gb, 1); - break; - } - case AV_CODEC_ID_ADPCM_IMA_ISS: + ) /* End of CASE */ + CASE(ADPCM_IMA_ISS, for (int channel = 0; channel < avctx->channels; channel++) { ADPCMChannelStatus *cs = &c->status[channel]; cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); @@ -1277,8 +1283,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3); } - break; - case AV_CODEC_ID_ADPCM_IMA_MOFLEX: + ) /* End of CASE */ + CASE(ADPCM_IMA_MOFLEX, for (int channel = 0; channel < avctx->channels; channel++) { ADPCMChannelStatus *cs = &c->status[channel]; cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); @@ -1300,8 +1306,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } } - break; - case AV_CODEC_ID_ADPCM_IMA_DAT4: + ) /* End of CASE */ + CASE(ADPCM_IMA_DAT4, for (int channel = 0; channel < avctx->channels; channel++) { ADPCMChannelStatus *cs = &c->status[channel]; samples = samples_p[channel]; @@ -1312,22 +1318,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(cs, v & 0x0F, 3); } } - break; - case AV_CODEC_ID_ADPCM_IMA_APC: + ) /* End of CASE */ + CASE(ADPCM_IMA_APC, for (int n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); } - break; - case AV_CODEC_ID_ADPCM_IMA_SSI: + ) /* End of CASE */ + CASE(ADPCM_IMA_SSI, for (int n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0], v >> 4 ); *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0x0F); } - break; - case AV_CODEC_ID_ADPCM_IMA_APM: + ) /* End of CASE */ + CASE(ADPCM_IMA_APM, for (int n = nb_samples / 2; n > 0; n--) { for (int channel = 0; channel < avctx->channels; channel++) { int v = bytestream2_get_byteu(&gb); @@ -1336,8 +1342,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } samples += avctx->channels; } - break; - case AV_CODEC_ID_ADPCM_IMA_ALP: + ) /* End of CASE */ + CASE(ADPCM_IMA_ALP, for (int n = nb_samples / 2; n > 0; n--) { for (int channel = 0; channel < avctx->channels; channel++) { int v = bytestream2_get_byteu(&gb); @@ -1346,8 +1352,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } samples += avctx->channels; } - break; - case AV_CODEC_ID_ADPCM_IMA_CUNNING: + ) /* End of CASE */ + CASE(ADPCM_IMA_CUNNING, for (int channel = 0; channel < avctx->channels; channel++) { int16_t *smp = samples_p[channel]; for (int n = 0; n < nb_samples / 2; n++) { @@ -1356,15 +1362,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v >> 4); } } - break; - case AV_CODEC_ID_ADPCM_IMA_OKI: + ) /* End of CASE */ + CASE(ADPCM_IMA_OKI, for (int n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_oki_expand_nibble(&c->status[0], v >> 4 ); *samples++ = adpcm_ima_oki_expand_nibble(&c->status[st], v & 0x0F); } - break; - case AV_CODEC_ID_ADPCM_IMA_RAD: + ) /* End of CASE */ + CASE(ADPCM_IMA_RAD, for (int channel = 0; channel < avctx->channels; channel++) { ADPCMChannelStatus *cs = &c->status[channel]; cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); @@ -1388,8 +1394,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[channel], byte[channel] >> 4 , 3); } } - break; - case AV_CODEC_ID_ADPCM_IMA_WS: + ) /* End of CASE */ + CASE(ADPCM_IMA_WS, if (c->vqa_version == 3) { for (int channel = 0; channel < avctx->channels; channel++) { int16_t *smp = samples_p[channel]; @@ -1411,9 +1417,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } bytestream2_seek(&gb, 0, SEEK_END); - break; - case AV_CODEC_ID_ADPCM_XA: - { + ) /* End of CASE */ + CASE(ADPCM_XA, int16_t *out0 = samples_p[0]; int16_t *out1 = samples_p[1]; int samples_per_block = 28 * (3 - avctx->channels) * 4; @@ -1433,9 +1438,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, if (bytes_remaining > 0) { bytestream2_skip(&gb, bytes_remaining); } - break; - } - case AV_CODEC_ID_ADPCM_IMA_EA_EACS: + ) /* End of CASE */ + CASE(ADPCM_IMA_EA_EACS, for (int i = 0; i <= st; i++) { c->status[i].step_index = bytestream2_get_le32u(&gb); if (c->status[i].step_index > 88u) { @@ -1455,16 +1459,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 3); } - break; - case AV_CODEC_ID_ADPCM_IMA_EA_SEAD: + ) /* End of CASE */ + CASE(ADPCM_IMA_EA_SEAD, for (int n = nb_samples >> (1 - st); n > 0; n--) { int byte = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 6); *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 6); } - break; - case AV_CODEC_ID_ADPCM_EA: - { + ) /* End of CASE */ + CASE(ADPCM_EA, int previous_left_sample, previous_right_sample; int current_left_sample, current_right_sample; int next_left_sample, next_right_sample; @@ -1515,11 +1518,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } bytestream2_skip(&gb, 2); // Skip terminating 0x0000 - - break; - } - case AV_CODEC_ID_ADPCM_EA_MAXIS_XA: - { + ) /* End of CASE */ + CASE(ADPCM_EA_MAXIS_XA, int coeff[2][2], shift[2]; for (int channel = 0; channel < avctx->channels; channel++) { @@ -1546,8 +1546,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } bytestream2_seek(&gb, 0, SEEK_END); - break; - } + ) /* End of CASE */ +#if CONFIG_ADPCM_EA_R1_DECODER || CONFIG_ADPCM_EA_R2_DECODER || CONFIG_ADPCM_EA_R3_DECODER case AV_CODEC_ID_ADPCM_EA_R1: case AV_CODEC_ID_ADPCM_EA_R2: case AV_CODEC_ID_ADPCM_EA_R3: { @@ -1630,7 +1630,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, bytestream2_seek(&gb, 0, SEEK_END); break; } - case AV_CODEC_ID_ADPCM_EA_XAS: +#endif /* CONFIG_ADPCM_EA_Rx_DECODER */ + CASE(ADPCM_EA_XAS, for (int channel=0; channel < avctx->channels; channel++) { int coeff[2][4], shift[4]; int16_t *s = samples_p[channel]; @@ -1661,8 +1662,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } } - break; - case AV_CODEC_ID_ADPCM_IMA_ACORN: + ) /* End of CASE */ + CASE(ADPCM_IMA_ACORN, for (int channel = 0; channel < avctx->channels; channel++) { ADPCMChannelStatus *cs = &c->status[channel]; cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); @@ -1678,8 +1679,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte >> 4, 3); } - break; - case AV_CODEC_ID_ADPCM_IMA_AMV: + ) /* End of CASE */ + CASE(ADPCM_IMA_AMV, av_assert0(avctx->channels == 1); /* @@ -1718,8 +1719,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, av_log(avctx, AV_LOG_WARNING, "Sample will be skipped.\n"); } } - break; - case AV_CODEC_ID_ADPCM_IMA_SMJPEG: + ) /* End of CASE */ + CASE(ADPCM_IMA_SMJPEG, for (int i = 0; i < avctx->channels; i++) { c->status[i].predictor = sign_extend(bytestream2_get_be16u(&gb), 16); c->status[i].step_index = bytestream2_get_byteu(&gb); @@ -1737,14 +1738,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4 ); *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf); } - break; - case AV_CODEC_ID_ADPCM_CT: + ) /* End of CASE */ + CASE(ADPCM_CT, for (int n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 ); *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F); } - break; + ) /* End of CASE */ +#if CONFIG_ADPCM_SBPRO_2_DECODER || CONFIG_ADPCMSBPRO_3_DECODER || \ + CONFIG_ADPCM_SBPRO_4_DECODER case AV_CODEC_ID_ADPCM_SBPRO_4: case AV_CODEC_ID_ADPCM_SBPRO_3: case AV_CODEC_ID_ADPCM_SBPRO_2: @@ -1788,18 +1791,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } break; - case AV_CODEC_ID_ADPCM_SWF: +#endif /* CONFIG_ADPCM_SBPRO_x_DECODER */ + CASE(ADPCM_SWF, adpcm_swf_decode(avctx, buf, buf_size, samples); bytestream2_seek(&gb, 0, SEEK_END); - break; - case AV_CODEC_ID_ADPCM_YAMAHA: + ) /* End of CASE */ + CASE(ADPCM_YAMAHA, for (int n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F); *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 ); } - break; - case AV_CODEC_ID_ADPCM_AICA: + ) /* End of CASE */ + CASE(ADPCM_AICA, for (int channel = 0; channel < avctx->channels; channel++) { samples = samples_p[channel]; for (int n = nb_samples >> 1; n > 0; n--) { @@ -1808,9 +1812,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_yamaha_expand_nibble(&c->status[channel], v >> 4 ); } } - break; - case AV_CODEC_ID_ADPCM_AFC: - { + ) /* End of CASE */ + CASE(ADPCM_AFC, int samples_per_block; int blocks; @@ -1860,8 +1863,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } bytestream2_seek(&gb, 0, SEEK_END); - break; - } + ) /* End of CASE */ +#if CONFIG_ADPCM_THP_DECODER || CONFIG_ADPCM_THP_LE_DECODER case AV_CODEC_ID_ADPCM_THP: case AV_CODEC_ID_ADPCM_THP_LE: { @@ -1933,7 +1936,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; } - case AV_CODEC_ID_ADPCM_DTK: +#endif /* CONFIG_ADPCM_THP(_LE)_DECODER */ + CASE(ADPCM_DTK, for (int channel = 0; channel < avctx->channels; channel++) { samples = samples_p[channel]; @@ -1980,8 +1984,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, if (!channel) bytestream2_seek(&gb, 0, SEEK_SET); } - break; - case AV_CODEC_ID_ADPCM_PSX: + ) /* End of CASE */ + CASE(ADPCM_PSX, for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * avctx->channels); block++) { int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * avctx->channels) / (16 * avctx->channels); for (int channel = 0; channel < avctx->channels; channel++) { @@ -2021,8 +2025,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } } - break; - case AV_CODEC_ID_ADPCM_ARGO: + ) /* End of CASE */ + CASE(ADPCM_ARGO, /* * The format of each block: * uint8_t left_control; @@ -2058,14 +2062,14 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } } - break; - case AV_CODEC_ID_ADPCM_ZORK: + ) /* End of CASE */ + CASE(ADPCM_ZORK, for (int n = 0; n < nb_samples * avctx->channels; n++) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_zork_expand_nibble(&c->status[n % avctx->channels], v); } - break; - case AV_CODEC_ID_ADPCM_IMA_MTF: + ) /* End of CASE */ + CASE(ADPCM_IMA_MTF, for (int n = nb_samples / 2; n > 0; n--) { for (int channel = 0; channel < avctx->channels; channel++) { int v = bytestream2_get_byteu(&gb); @@ -2074,7 +2078,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } samples += avctx->channels; } - break; + ) /* End of CASE */ default: av_assert0(0); // unsupported codec_id should not happen }