From patchwork Mon Jun 13 22:03:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36204 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp728910pzb; Mon, 13 Jun 2022 15:04:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDMJVcBVTWrSW7Q7u6/7nj6jirJjTk5FybbEzLvBj5A57jzCxXL4IGaDnGw5EtQylUESAU X-Received: by 2002:a17:906:40c4:b0:70a:5d82:4e68 with SMTP id a4-20020a17090640c400b0070a5d824e68mr1692564ejk.172.1655157848236; Mon, 13 Jun 2022 15:04:08 -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 m12-20020a17090677cc00b006ff70e15efdsi8421426ejn.858.2022.06.13.15.04.06; Mon, 13 Jun 2022 15:04:08 -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=HUllc0Nt; 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 0AF0368B5EF; Tue, 14 Jun 2022 01:04:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-oln040092064041.outbound.protection.outlook.com [40.92.64.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6E31468B1E6 for ; Tue, 14 Jun 2022 01:03:56 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DFgFSihzpW3Agz3tDawahSD/p9qDBEAtmEZyy98mPOFLnO0AKUm7Ol/wgojRUtVqFUf6sSVNFunp43cDZlyxhROCoWvzFtKLJFDhcJZ8bA3S1G738pxplj9rDieGX5WdWP68Ttf0j8iNZY3/1gnaOpz5kIkxYsxX/t56AS1vtw2BnRZ5G88mR6CV2vRxJ76IQWhuZHmL7E1l59zk6XOEu4HQnVWtCKlJJWnJgkc3QXGZ5HAEWHfYaIV+z94X0lKiSMiZbcKp+v4FrJNeXZ1s0Kv74FFYsHTRzf+TCcgBvf5FTgsHmSn0KubJ04zeVyO/bKf3clyBA8imLKZd5CsZsg== 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=L9suKxvZFqcPvPokqORJZPoAzMTWgKEQ/9DJvV9xM6s=; b=Ggx2VVRtRik5J/FbwPCSrtqjBRy/hSo+brwQHZqniSaSRCSW2NJqQMmCgYD2hmXMs/8MXS40Cle5zgiKS2oDb00ANiwv+uC5nxU/jxWVkgzWDq061yen9zsEXnLEI+S3qNtFbnhjuHWX15cXLiqETnCGnHd7gBz/WbK3TZCo3zKZYQtnlKc6ZDmwOYA+jEZ/5lxqSWm2Gm51YX2CjcVWgHrToPE8lCHJgXFhhZWkRgSmAesZEIqcoleKD7kwuQvbgnPVIAtfhTeq7diCU4BNNQ4lbwP+YRbKKhxK1G6NSp4Gp4Zy1Po/0U/rtHTOt2KaorNOS1gUWn0sSTwMGaKaKw== 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=L9suKxvZFqcPvPokqORJZPoAzMTWgKEQ/9DJvV9xM6s=; b=HUllc0NtzUnIQln2rc+6cehnWuv1ggGmxsJYK98zTHIOtxow/VbyVgUcE+gGp4WdiMoS+a4IjqUuz+J00C3Ga3S4/0QkB86Ap3FuYRQ5vJ56MBbmgi6YVvlU3lwpM00Pt82He/aDSYkKPD1XGrNsVhwXtUIwxO2yXb7z5yNBggz7vk0BdzcyMT8PIhkh7ndaidHYuBP0EtgBs6HXtTqcUYGiQoL6E2d5XgXn3EGCmGov4CF+ZwD8FtFhrXPcuOBHmuiBYUiHuPoPF1ph/dlcq1fFPIFlfPMHfcJEaoredNkvRqxl8MGQE2w0EEicMWcOoX3aFAxDWadMHrtKjjcXvQ== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by DU0PR01MB10282.eurprd01.prod.exchangelabs.com (2603:10a6:10:316::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.20; Mon, 13 Jun 2022 22:03:54 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5332.021; Mon, 13 Jun 2022 22:03:54 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 14 Jun 2022 00:03:46 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [xTMFPpWKrbzd1pYDKXY6fm4l6MZOe8j3] X-ClientProxiedBy: ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220613220346.754928-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0ecce0b-bde3-42aa-4524-08da4d889aff X-MS-Exchange-SLBlob-MailProps: 3tYrFWTD79Aosg2PaDD2YItEfKZm57YpnVJFoaYV4ZTeiwiTym9z8/V+9qYQ/x3bNpGjnxkI9JtHGh1lc9CmQ3o/D9E1ybjoUAIqlQrpiid3bEiEVHzNolDv0miL0dfIw6vONhBIwCPKOU6YtrvrDm1Jns8x/VvoO6jjbhmMkMig6yi+fw+KP5bv7Vnw1pfZZY4MngRiWDBzCTh/8hrroYc2GEqu2z57PUEMEAE3F40crL590o1VlanBAHPBOu8JPIug+87/Aca2oUlKRrpCLUY/vCAqun8F9XMLLxXgrQU5hyEG5TEVmlwJMd2wVZUuV7WXoriqTnL8VF7Gkkusfg3uqLxljKQLE9iIOQim5yW1OgfSERF/W0JG1XW2GGNbPBpul7+Xp5NWlQPif74+YCKy9O0WoDYkju3g9nr09DzFxYQalltthNmpHbyeGUDv/91r/SMDBDhbCqeB9w5Dycl6MKze+HDU4lRO8WDe1C/cuKg2mBlg5aQttsxIOl3WP3SyR1Fnyhe8dCbepF7Zsx8MfyJ01/R67pDmHZTQjSgWugfkgHUUOYkHNZcQ6wNu4oIg0H8Z5bfhzkolf1SERZDuh1+Z8jlWaPs93jTy3Z/wqgRtksxAXgDquVlwT+G0YbYxvbB0qsPgw2IJgjVYZhGFVY+cV+0du1H97JL+RHnBzeMAG9p+NQasXOYbt//QzZH4Zj/ePVptNQX0z3kxIJNjNgLCVzncjAiUQW0lui7HdkbbtgCCSv0DtJ/fiOGfBjeqs82v20txQ88h6RwTNKNSF7r3/MlO X-MS-TrafficTypeDiagnostic: DU0PR01MB10282:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +7GHFpQOP5PFGpnJ1mW84jBKL0e/d20nBzLum04RwFL2Q4714RXCK/iMuKKmDXN6CjocbgxBdFbI+fcvyP8d0TBgT8v8NXqu5y8o3hmsZIphoSPZPcI2rygtGpl1hET0x+oTCL6FBld8JOFKRLmFdorUDBFVsA0QIo+BK8PEbV/VRt0E5l3bo9IBWLpg/6/06M9yXWkoeby3DMvp0EHRnpFhAfCHQCjBwPG4OfB0h8bpoUp6lW9v5YKX4j/nA5vsOjBNPPCd767F27W7A1RZlhrYKQ7wF44Jo3JecjTdG+D4STj2mrnj9fYv4+j05hOzvPA0UgVk3ofoO5iRM7kWiQxC+j1DL9bo1HYN7qa9oKVPIGm0vC+x5gI9KX+jJKzb2HpCqLFjnxPf9Nc6HE29Ydq3A9n38FhLWmYhV+rzgmekuyj3GbybC95ttu0FoLp63XPi1W4bjk8zKjJHwy73Zz5iHMtbvDAplth1OcSEeSP9nmZjf3Cp+EFr95/wbmwEEuqy0RCxLuxpM1hZi/clAd8zq1w21FyuY13xF+Uo3OPZh9bzoonYPfxVbt5O+EJr8zfs7dK6aNFeCBCQq3NVBA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hqxBxPMzd7RlvzMMITCZiUCOtzqejzQmUvd92zBFMlL21BqAEdrIjM3+JjXZdZwuWan36ZzLioqzqCJd6RB5Wn6Zm5HCJ6CxCQUJ93cBz+Q02bQaZWP9zf7PJOQQZxGTQlwGJTZsAdixj7U8pFghpf+EUJitquQYriaKvMMA18i7L2A5hrhHGDuc/2UdWG3XKj9oyVdsQyI7w3Ue6p8TcS4VltTMLIPa7zliVbb3yAnrw2CSuhuWSIHsh+poYhI5BMHdXotaA0aMeiy+LroEsoV5v7z7cNgJredqCPBXjbTOHtfe0hx0V7nrmZv6Kyk48E6wV5JzOlGPzy7P1hEFQr32GAUci1V1+OxzcOO9786xadlOgSNxbbY14u5VJNV1QTSI1nZKrsiD/CSu0yxB0yoe94snD9E+smCeF+nGMWSeKRF51KZ1J0GKrvWqVnCL+FS2bNvWp8YXcGOC9EBcTf+Srt452bLg8ntuy97un8fUFLUTlEe7rpRGjMrLFJsSF3fWkmVrZY6l3QGX0tZi4mT/Ipm8Y3PG8ohzj+nTHU8d1BIG0E1dfQ4VJEhfkWA+lgqts+gpB0rDONgIbWdsyuzt2UjX/c81xBHEDvClrPxGpn3+jSvCxPJ1O+zPDVZV9ppH0s5vaORM+6usHOUl0+vFj9OMb3UQzv+9GLDaFZrq0CaBCLJDcJifvUZOJt80ZIODYQcvFcL4d0CY00fTJzmcx6tjhJoGnEsZ6qvyT0KblJ1boWNVgPgt2yS1zytAo/IvqioBreIqRWPnzYFBPQ+uMVbH1ILHWvljctIriKPzrWTta43+DNOuhlnAk/eVLDMu5pNBj/9EhaTbJcRa2BVIy6jyZ1E/fDZt069nJ+pz3jl+QX/kPY+jkfijhpnnWiR1h+bUMDJujXp4oKOJ+cp9FlAZRur/5M9b/9Fiq5/PS+stTVJD9tF0qJGHgtl9sFVvGH+Td2ah6Ge+Kkl3Go84+m7OZ1ZtICvqTUVpKeRNePNlVN+vXxPn6OSnctE8omGvKNoeJT/sKIUEV5rx3fA49sZPvYufUNpozpB8pFLpxETfiV90MYiI/F9qdtsYVLI6fzYbmp2YjRgvJJoGoZhT0UPGiyMcSXb5T8oA6qduSjH3A+MR7SEX0zfxFWHJxzF/hSQdSMxGz1iFTnqk7fgJOKL4T3eY3JKaonj0Jy5yvArt84A3iVGy1bXl73YPHhSV0HmKSc9ovRV+3HLX9bo2DYkE57uPzteibrrG+VF85JKFpQFLD2roiYHzCw0lfR3oXz4DnQRDBHcMGgTNNxTb2tG5QkXb4aJ4ppsq//9VljXfSkI5/vcgEArMduhJDxzpJBUGHdahLNvzI8PPq5U4akmL011GsJ1zjhSiJzP0TS4UxpaXBDFy85zxBg7i8XRoL9s3EUc6q1nfhCwrabHhH0pFSEUDsAHi/ecOT0etP09jEgHREygu8ynwNZow2zL4/OhSzMdwxLp1AeHHxw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0ecce0b-bde3-42aa-4524-08da4d889aff X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2022 22:03:54.5314 (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: DU0PR01MB10282 Subject: [FFmpeg-devel] [PATCH] avcodec/vlc: Use structure instead of VLC_TYPE array as VLC element 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: EtpeW7OiItJW In C, qualifiers for arrays are broken: const VLC_TYPE (*foo)[2] is a pointer to an array of two const VLC_TYPE elements and unfortunately this is not compatible with a pointer to a const array of two VLC_TYPE, because the latter does not exist as array types are never qualified (the qualifier applies to the base type instead). This is the reason why get_vlc2() doesn't accept a const VLC table despite not modifying the table at all, as there is no automatic conversion from VLC_TYPE (*)[2] to const VLC_TYPE (*)[2]. Fix this by using a structure VLCElem for the VLC table. This also has the advantage of making it clear which element is which. Signed-off-by: Andreas Rheinhardt --- libavcodec/4xm.c | 2 +- libavcodec/aacdec_template.c | 6 +++--- libavcodec/aacps_common.c | 2 +- libavcodec/aacsbr_template.c | 4 ++-- libavcodec/asvdec.c | 6 +++--- libavcodec/atrac3.c | 4 ++-- libavcodec/atrac3plus.c | 2 +- libavcodec/atrac9dec.c | 2 +- libavcodec/bink.c | 2 +- libavcodec/cfhddata.c | 8 ++++---- libavcodec/clearvideo.c | 2 +- libavcodec/dcahuff.c | 2 +- libavcodec/dvdec.c | 6 +++--- libavcodec/faxcompr.c | 4 ++-- libavcodec/get_bits.h | 24 ++++++++++++------------ libavcodec/h264_cavlc.c | 16 ++++++++-------- libavcodec/huffyuvdec.c | 20 ++++++++++---------- libavcodec/imc.c | 2 +- libavcodec/intrax8.c | 2 +- libavcodec/ivi.c | 2 +- libavcodec/mlpdec.c | 2 +- libavcodec/mobiclip.c | 2 +- libavcodec/mpc7.c | 2 +- libavcodec/mpc8.c | 2 +- libavcodec/mpeg12.c | 6 +++--- libavcodec/mpeg4videodec.c | 2 +- libavcodec/mpegaudiodec_common.c | 6 +++--- libavcodec/msmpeg4dec.c | 2 +- libavcodec/mss4.c | 2 +- libavcodec/qdm2_tablegen.c | 2 +- libavcodec/qdm2_tablegen.h | 2 +- libavcodec/qdmc.c | 2 +- libavcodec/rl.c | 6 +++--- libavcodec/rv10.c | 10 +++++----- libavcodec/rv34.c | 2 +- libavcodec/rv40.c | 4 ++-- libavcodec/svq1dec.c | 2 +- libavcodec/tableprint_vlc.h | 17 ++++++++--------- libavcodec/tscc2.c | 2 +- libavcodec/vc1.c | 2 +- libavcodec/vlc.c | 26 +++++++++++++------------- libavcodec/vlc.h | 13 +++++++++---- libavcodec/vp3.c | 2 +- 43 files changed, 120 insertions(+), 116 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 3fb3568afd..7b88631a6b 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -250,7 +250,7 @@ static void idct(int16_t block[64]) static av_cold void init_vlcs(void) { - static VLC_TYPE table[2][4][32][2]; + static VLCElem table[2][4][32]; int i, j; for (i = 0; i < 2; i++) { diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 463bf92fc0..70382c3175 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1221,8 +1221,8 @@ static void aacdec_init(AACContext *ac); static av_cold void aac_static_table_init(void) { - static VLC_TYPE vlc_buf[304 + 270 + 550 + 300 + 328 + - 294 + 306 + 268 + 510 + 366 + 462][2]; + static VLCElem vlc_buf[304 + 270 + 550 + 300 + 328 + + 294 + 306 + 268 + 510 + 366 + 462]; for (unsigned i = 0, offset = 0; i < 11; i++) { vlc_spectral[i].table = &vlc_buf[offset]; vlc_spectral[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset; @@ -1821,7 +1821,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], #if !USE_FIXED const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; #endif /* !USE_FIXED */ - VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; + const VLCElem *vlc_tab = vlc_spectral[cbt_m1].table; OPEN_READER(re, gb); switch (cbt_m1 >> 1) { diff --git a/libavcodec/aacps_common.c b/libavcodec/aacps_common.c index 8653b871ca..c388d5b9bc 100644 --- a/libavcodec/aacps_common.c +++ b/libavcodec/aacps_common.c @@ -78,7 +78,7 @@ static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSCom int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \ { \ int b, num = ps->nr_ ## PAR ## _par; \ - VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \ + const VLCElem *vlc_table = vlc_ps[table_idx].table; \ if (dt) { \ int e_prev = e ? e - 1 : ps->num_env_old - 1; \ e_prev = FFMAX(e_prev, 0); \ diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c index 774f12e77a..87791d8791 100644 --- a/libavcodec/aacsbr_template.c +++ b/libavcodec/aacsbr_template.c @@ -811,7 +811,7 @@ static int read_sbr_envelope(AACContext *ac, SpectralBandReplication *sbr, GetBi { int bits; int i, j, k; - VLC_TYPE (*t_huff)[2], (*f_huff)[2]; + const VLCElem *t_huff, *f_huff; int t_lav, f_lav; const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; const int odd = sbr->n[1] & 1; @@ -899,7 +899,7 @@ static int read_sbr_noise(AACContext *ac, SpectralBandReplication *sbr, GetBitCo SBRData *ch_data, int ch) { int i, j; - VLC_TYPE (*t_huff)[2], (*f_huff)[2]; + const VLCElem *t_huff, *f_huff; int t_lav, f_lav; int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c index 5b2c71be82..57ba4c5b5e 100644 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@ -78,7 +78,7 @@ static inline int asv1_get_level(GetBitContext *gb) } // get_vlc2() is big-endian in this file -static inline int asv2_get_vlc2(GetBitContext *gb, VLC_TYPE (*table)[2], int bits) +static inline int asv2_get_vlc2(GetBitContext *gb, const VLCElem *table, int bits) { unsigned int index; int code, n; @@ -87,8 +87,8 @@ static inline int asv2_get_vlc2(GetBitContext *gb, VLC_TYPE (*table)[2], int bit UPDATE_CACHE_LE(re, gb); index = SHOW_UBITS_LE(re, gb, bits); - code = table[index][0]; - n = table[index][1]; + code = table[index].sym; + n = table[index].len; LAST_SKIP_BITS(re, gb, n); CLOSE_READER(re, gb); diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 97f59438e1..d5f6fea4d4 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -122,7 +122,7 @@ typedef struct ATRAC3Context { } ATRAC3Context; static DECLARE_ALIGNED(32, float, mdct_window)[MDCT_SIZE]; -static VLC_TYPE atrac3_vlc_table[7 * 1 << ATRAC3_VLC_BITS][2]; +static VLCElem atrac3_vlc_table[7 * 1 << ATRAC3_VLC_BITS]; static VLC spectral_coeff_tab[7]; /** @@ -852,7 +852,7 @@ static int atrac3al_decode_frame(AVCodecContext *avctx, AVFrame *frame, static av_cold void atrac3_init_static_data(void) { - VLC_TYPE (*table)[2] = atrac3_vlc_table; + VLCElem *table = atrac3_vlc_table; const uint8_t (*hufftabs)[2] = atrac3_hufftabs; int i; diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c index 3a0a0d5f36..a0836f1178 100644 --- a/libavcodec/atrac3plus.c +++ b/libavcodec/atrac3plus.c @@ -31,7 +31,7 @@ #include "atrac3plus.h" #include "atrac3plus_data.h" -static VLC_TYPE tables_data[154276][2]; +static VLCElem tables_data[154276]; static VLC wl_vlc_tabs[4]; static VLC sf_vlc_tabs[8]; static VLC ct_vlc_tabs[4]; diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index d9ad03140c..6c1f0d1759 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -844,7 +844,7 @@ static av_cold void atrac9_init_vlc(VLC *vlc, int nb_bits, int nb_codes, const uint8_t (**tab)[2], unsigned *buf_offset, int offset) { - static VLC_TYPE vlc_buf[24812][2]; + static VLCElem vlc_buf[24812]; vlc->table = &vlc_buf[*buf_offset]; vlc->table_allocated = FF_ARRAY_ELEMS(vlc_buf) - *buf_offset; diff --git a/libavcodec/bink.c b/libavcodec/bink.c index ce740ad275..ae2c65f19f 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1314,7 +1314,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, static av_cold void bink_init_vlcs(void) { for (int i = 0, offset = 0; i < 16; i++) { - static VLC_TYPE table[976][2]; + static VLCElem table[976]; const int maxbits = bink_tree_lens[i][15]; bink_trees[i].table = table + offset; bink_trees[i].table_allocated = 1 << maxbits; diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 5df68d4b3c..55c8004bdd 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -308,8 +308,8 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) if (ret < 0) return ret; for (i = 0; i < s->vlc_9.table_size; i++) { - int code = s->vlc_9.table[i][0]; - int len = s->vlc_9.table[i][1]; + int code = s->vlc_9.table[i].sym; + int len = s->vlc_9.table[i].len; int level, run; if (len < 0) { // more bits needed @@ -351,8 +351,8 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) av_assert0(s->vlc_18.table_size == 4572); for (i = 0; i < s->vlc_18.table_size; i++) { - int code = s->vlc_18.table[i][0]; - int len = s->vlc_18.table[i][1]; + int code = s->vlc_18.table[i].sym; + int len = s->vlc_18.table[i].len; int level, run; if (len < 0) { // more bits needed diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 37283d4ddd..075c6e9461 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.c @@ -84,7 +84,7 @@ typedef struct CLVContext { static VLC dc_vlc, ac_vlc; static LevelCodes lev[4 + 3 + 3]; // 0..3: Y, 4..6: U, 7..9: V -static VLC_TYPE vlc_buf[16716][2]; +static VLCElem vlc_buf[16716]; static inline int decode_block(CLVContext *ctx, int16_t *blk, int has_ac, int ac_quant) diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index fa36735c0b..8d5541f9d0 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -1264,7 +1264,7 @@ VLC ff_dca_vlc_rsd; av_cold void ff_dca_init_vlcs(void) { - static VLC_TYPE dca_table[30214][2]; + static VLCElem dca_table[30214]; int i, j, k = 0; #define DCA_INIT_VLC(vlc, a, b, c, d) \ diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index a0bae6f57e..d6f073058c 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -137,7 +137,7 @@ static RL_VLC_ELEM dv_rl_vlc[1664]; static void dv_init_static(void) { - VLC_TYPE vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)][2] = { 0 }; + VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 }; VLC dv_vlc = { .table = vlc_buf, .table_allocated = FF_ARRAY_ELEMS(vlc_buf) }; uint16_t new_dv_vlc_bits[NB_DV_VLC * 2]; uint8_t new_dv_vlc_len[NB_DV_VLC * 2]; @@ -171,8 +171,8 @@ static void dv_init_static(void) av_assert1(dv_vlc.table_size == 1664); for (int i = 0; i < dv_vlc.table_size; i++) { - int code = dv_vlc.table[i][0]; - int len = dv_vlc.table[i][1]; + int code = dv_vlc.table[i].sym; + int len = dv_vlc.table[i].len; int level, run; if (len < 0) { // more bits needed diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c index b283831dae..d9dec3fcb8 100644 --- a/libavcodec/faxcompr.c +++ b/libavcodec/faxcompr.c @@ -99,8 +99,8 @@ static VLC ccitt_vlc[2], ccitt_group3_2d_vlc; static av_cold void ccitt_unpack_init(void) { - static VLC_TYPE code_table1[528][2]; - static VLC_TYPE code_table2[648][2]; + static VLCElem code_table1[528]; + static VLCElem code_table2[648]; int i; ccitt_vlc[0].table = code_table1; diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index d4e9276da1..16f8af5107 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -710,8 +710,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) unsigned int index; \ \ index = SHOW_UBITS(name, gb, bits); \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ \ if (max_depth > 1 && n < 0) { \ LAST_SKIP_BITS(name, gb, bits); \ @@ -720,8 +720,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) nb_bits = -n; \ \ index = SHOW_UBITS(name, gb, nb_bits) + code; \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ if (max_depth > 2 && n < 0) { \ LAST_SKIP_BITS(name, gb, nb_bits); \ UPDATE_CACHE(name, gb); \ @@ -729,8 +729,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) nb_bits = -n; \ \ index = SHOW_UBITS(name, gb, nb_bits) + code; \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ } \ } \ SKIP_BITS(name, gb, n); \ @@ -775,15 +775,15 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) /* Return the LUT element for the given bitstream configuration. */ static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits, - VLC_TYPE (*table)[2]) + const VLCElem *table) { unsigned idx; *nb_bits = -*n; idx = show_bits(s, *nb_bits) + code; - *n = table[idx][1]; + *n = table[idx].len; - return table[idx][0]; + return table[idx].sym; } /** @@ -795,14 +795,14 @@ static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits, * = (max_vlc_length + bits - 1) / bits * @returns the code parsed or -1 if no vlc matches */ -static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], +static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth) { #if CACHED_BITSTREAM_READER int nb_bits; unsigned idx = show_bits(s, bits); - int code = table[idx][0]; - int n = table[idx][1]; + int code = table[idx].sym; + int n = table[idx].len; if (max_depth > 1 && n < 0) { skip_remaining(s, bits); diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 9191df0303..d061a5953b 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -235,35 +235,35 @@ static const uint8_t run_bits[7][16]={ }; static VLC coeff_token_vlc[4]; -static VLC_TYPE coeff_token_vlc_tables[520+332+280+256][2]; +static VLCElem coeff_token_vlc_tables[520+332+280+256]; static const int coeff_token_vlc_tables_size[4]={520,332,280,256}; static VLC chroma_dc_coeff_token_vlc; -static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2]; +static VLCElem chroma_dc_coeff_token_vlc_table[256]; static const int chroma_dc_coeff_token_vlc_table_size = 256; static VLC chroma422_dc_coeff_token_vlc; -static VLC_TYPE chroma422_dc_coeff_token_vlc_table[8192][2]; +static VLCElem chroma422_dc_coeff_token_vlc_table[8192]; static const int chroma422_dc_coeff_token_vlc_table_size = 8192; static VLC total_zeros_vlc[15+1]; -static VLC_TYPE total_zeros_vlc_tables[15][512][2]; +static VLCElem total_zeros_vlc_tables[15][512]; static const int total_zeros_vlc_tables_size = 512; static VLC chroma_dc_total_zeros_vlc[3+1]; -static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2]; +static VLCElem chroma_dc_total_zeros_vlc_tables[3][8]; static const int chroma_dc_total_zeros_vlc_tables_size = 8; static VLC chroma422_dc_total_zeros_vlc[7+1]; -static VLC_TYPE chroma422_dc_total_zeros_vlc_tables[7][32][2]; +static VLCElem chroma422_dc_total_zeros_vlc_tables[7][32]; static const int chroma422_dc_total_zeros_vlc_tables_size = 32; static VLC run_vlc[6+1]; -static VLC_TYPE run_vlc_tables[6][8][2]; +static VLCElem run_vlc_tables[6][8]; static const int run_vlc_tables_size = 8; static VLC run7_vlc; -static VLC_TYPE run7_vlc_table[96][2]; +static VLCElem run7_vlc_table[96]; static const int run7_vlc_table_size = 96; #define LEVEL_TAB_BITS 8 diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 07fa11e37a..acc4aafdc2 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -566,24 +566,24 @@ static av_cold int decode_init(AVCodecContext *avctx) /** Subset of GET_VLC for use in hand-roller VLC code */ #define VLC_INTERN(dst, table, gb, name, bits, max_depth) \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ if (max_depth > 1 && n < 0) { \ LAST_SKIP_BITS(name, gb, bits); \ UPDATE_CACHE(name, gb); \ \ nb_bits = -n; \ index = SHOW_UBITS(name, gb, nb_bits) + code; \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ if (max_depth > 2 && n < 0) { \ LAST_SKIP_BITS(name, gb, nb_bits); \ UPDATE_CACHE(name, gb); \ \ nb_bits = -n; \ index = SHOW_UBITS(name, gb, nb_bits) + code; \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ } \ } \ dst = code; \ @@ -594,7 +594,7 @@ static av_cold int decode_init(AVCodecContext *avctx) bits, max_depth, OP) \ do { \ unsigned int index = SHOW_UBITS(name, gb, bits); \ - int code, n = dtable[index][1]; \ + int code, n = dtable[index].len; \ \ if (n<=0) { \ int nb_bits; \ @@ -604,7 +604,7 @@ static av_cold int decode_init(AVCodecContext *avctx) index = SHOW_UBITS(name, gb, bits); \ VLC_INTERN(dst1, table2, gb, name, bits, max_depth); \ } else { \ - code = dtable[index][0]; \ + code = dtable[index].sym; \ OP(dst0, dst1, code); \ LAST_SKIP_BITS(name, gb, n); \ } \ @@ -752,10 +752,10 @@ static av_always_inline void decode_bgr_1(HYuvContext *s, int count, UPDATE_CACHE(re, &s->gb); index = SHOW_UBITS(re, &s->gb, VLC_BITS); - n = s->vlc[4].table[index][1]; + n = s->vlc[4].table[index].len; if (n>0) { - code = s->vlc[4].table[index][0]; + code = s->vlc[4].table[index].sym; *(uint32_t *) &s->temp[0][4 * i] = s->pix_bgr_map[code]; LAST_SKIP_BITS(re, &s->gb, n); } else { diff --git a/libavcodec/imc.c b/libavcodec/imc.c index ee12cd913f..94b9ac674c 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -118,7 +118,7 @@ static VLC huffman_vlc[4][4]; #define IMC_VLC_BITS 9 #define VLC_TABLES_SIZE 9512 -static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2]; +static VLCElem vlc_tables[VLC_TABLES_SIZE]; static inline double freq2bark(double freq) { diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index 0bd0db29c4..73b8aeea78 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -52,7 +52,7 @@ static VLC j_orient_vlc[2][4]; // [quant], [select] static av_cold void x8_init_vlc(VLC *vlc, int nb_bits, int nb_codes, int *offset, const uint8_t table[][2]) { - static VLC_TYPE vlc_buf[VLC_BUFFER_SIZE][2]; + static VLCElem vlc_buf[VLC_BUFFER_SIZE]; vlc->table = &vlc_buf[*offset]; vlc->table_allocated = VLC_BUFFER_SIZE - *offset; diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c index 48fcf9bfd8..6577fa335f 100644 --- a/libavcodec/ivi.c +++ b/libavcodec/ivi.c @@ -161,7 +161,7 @@ static int ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag) static av_cold void ivi_init_static_vlc(void) { int i; - static VLC_TYPE table_data[8192 * 16][2]; + static VLCElem table_data[8192 * 16]; for (i = 0; i < 8; i++) { ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192; diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index c5d8f5bde8..caf35dca0e 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -220,7 +220,7 @@ static VLC huff_vlc[3]; static av_cold void init_static(void) { for (int i = 0; i < 3; i++) { - static VLC_TYPE vlc_buf[3 * VLC_STATIC_SIZE][2]; + static VLCElem vlc_buf[3 * VLC_STATIC_SIZE]; huff_vlc[i].table = &vlc_buf[i * VLC_STATIC_SIZE]; huff_vlc[i].table_allocated = VLC_STATIC_SIZE; init_vlc(&huff_vlc[i], VLC_BITS, 18, diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index 2d09bc1f72..dcf788c630 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -288,7 +288,7 @@ static av_cold void mobiclip_init_static(void) syms1, sizeof(*syms1), sizeof(*syms1), 0, 0, 1 << MOBI_RL_VLC_BITS); for (int i = 0; i < 2; i++) { - static VLC_TYPE vlc_buf[2 * 16 << MOBI_MV_VLC_BITS][2]; + static VLCElem vlc_buf[2 * 16 << MOBI_MV_VLC_BITS]; for (int j = 0; j < 16; j++) { mv_vlc[i][j].table = &vlc_buf[(16 * i + j) << MOBI_MV_VLC_BITS]; mv_vlc[i][j].table_allocated = 1 << MOBI_MV_VLC_BITS; diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 1b722714f0..837507ba5f 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -44,7 +44,7 @@ static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2]; static av_cold void mpc7_init_static(void) { - static VLC_TYPE quant_tables[7224][2]; + static VLCElem quant_tables[7224]; const uint8_t *raw_quant_table = mpc7_quant_vlcs; INIT_VLC_STATIC_FROM_LENGTHS(&scfi_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 7903e5df8a..9d084e1664 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -92,7 +92,7 @@ static av_cold void build_vlc(VLC *vlc, unsigned *buf_offset, const uint8_t codes_counts[16], const uint8_t **syms, int offset) { - static VLC_TYPE vlc_buf[9296][2]; + static VLCElem vlc_buf[9296]; uint8_t len[MPC8_MAX_VLC_SIZE]; unsigned num = 0; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 622cdfd299..d78e25a777 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -66,14 +66,14 @@ static const uint8_t table_mb_btype[11][2] = { av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags) { int i; - VLC_TYPE table[680][2] = {{0}}; + VLCElem table[680] = { 0 }; VLC vlc = { .table = table, .table_allocated = static_size }; av_assert0(static_size <= FF_ARRAY_ELEMS(table)); init_vlc(&vlc, TEX_VLC_BITS, rl->n + 2, &rl->table_vlc[0][1], 4, 2, &rl->table_vlc[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | flags); for (i = 0; i < vlc.table_size; i++) { - int code = vlc.table[i][0]; - int len = vlc.table[i][1]; + int code = vlc.table[i].sym; + int len = vlc.table[i].len; int level, run; if (len == 0) { // illegal code diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index e2bde73639..220d415c6f 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3588,7 +3588,7 @@ static av_cold void mpeg4_init_static(void) 0, 0, 528); for (unsigned i = 0, offset = 0; i < 12; i++) { - static VLC_TYPE vlc_buf[6498][2]; + static VLCElem vlc_buf[6498]; studio_intra_tab[i].table = &vlc_buf[offset]; studio_intra_tab[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset; diff --git a/libavcodec/mpegaudiodec_common.c b/libavcodec/mpegaudiodec_common.c index ed2de8adbb..71fc2e7c81 100644 --- a/libavcodec/mpegaudiodec_common.c +++ b/libavcodec/mpegaudiodec_common.c @@ -65,10 +65,10 @@ const uint8_t ff_lsf_nsf_table[6][3][4] = { /* mpegaudio layer 3 huffman tables */ VLC ff_huff_vlc[16]; -static VLC_TYPE huff_vlc_tables[128 + 128 + 128 + 130 + 128 + 154 + 166 + 142 + - 204 + 190 + 170 + 542 + 460 + 662 + 414][2]; +static VLCElem huff_vlc_tables[128 + 128 + 128 + 130 + 128 + 154 + 166 + 142 + + 204 + 190 + 170 + 542 + 460 + 662 + 414]; VLC ff_huff_quad_vlc[2]; -static VLC_TYPE huff_quad_vlc_tables[64 + 16][2]; +static VLCElem huff_quad_vlc_tables[64 + 16]; static const uint8_t mpa_hufflens[] = { /* Huffman table 1 - 4 entries */ diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index a03e43f88c..abebeffc7c 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -348,7 +348,7 @@ static av_cold void msmpeg4_decode_init_static(void) &ff_v2_mb_type[0][0], 2, 1, 128); for (unsigned i = 0, offset = 0; i < 4; i++) { - static VLC_TYPE vlc_buf[1636 + 2648 + 1532 + 2488][2]; + static VLCElem vlc_buf[1636 + 2648 + 1532 + 2488]; ff_mb_non_intra_vlc[i].table = &vlc_buf[offset]; ff_mb_non_intra_vlc[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset; init_vlc(&ff_mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128, diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c index be73e52a91..9f3c4a593d 100644 --- a/libavcodec/mss4.c +++ b/libavcodec/mss4.c @@ -100,7 +100,7 @@ static VLC vec_entry_vlc[2]; static av_cold void mss4_init_vlc(VLC *vlc, unsigned *offset, const uint8_t *lens, const uint8_t *syms) { - static VLC_TYPE vlc_buf[2146][2]; + static VLCElem vlc_buf[2146]; uint8_t bits[MAX_ENTRIES]; int i, j; int idx = 0; diff --git a/libavcodec/qdm2_tablegen.c b/libavcodec/qdm2_tablegen.c index e19b49b235..932da0c50b 100644 --- a/libavcodec/qdm2_tablegen.c +++ b/libavcodec/qdm2_tablegen.c @@ -42,7 +42,7 @@ int main(void) qdm2_init_vlc(); - WRITE_2D_ARRAY("static const", VLC_TYPE, qdm2_table); + WRITE_VLC_TABLE("static const", qdm2_table); WRITE_VLC_TYPE("static const", vlc_tab_level, qdm2_table); WRITE_VLC_TYPE("static const", vlc_tab_diff, qdm2_table); WRITE_VLC_TYPE("static const", vlc_tab_run, qdm2_table); diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index ca47fea2dc..a68ea8599b 100644 --- a/libavcodec/qdm2_tablegen.h +++ b/libavcodec/qdm2_tablegen.h @@ -109,7 +109,7 @@ static VLC vlc_tab_type30; static VLC vlc_tab_type34; static VLC vlc_tab_fft_tone_offset[5]; -static VLC_TYPE qdm2_table[3838][2]; +static VLCElem qdm2_table[3838]; static av_cold void build_vlc(VLC *vlc, int nb_bits, int nb_codes, unsigned *offset, const uint8_t tab[][2]) diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index 7c069a8012..f24e94b187 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @@ -169,7 +169,7 @@ static av_cold void qdmc_init_static_data(void) int i; for (unsigned i = 0, offset = 0; i < FF_ARRAY_ELEMS(vtable); i++) { - static VLC_TYPE vlc_buffer[13698][2]; + static VLCElem vlc_buffer[13698]; vtable[i].table = &vlc_buffer[offset]; vtable[i].table_allocated = FF_ARRAY_ELEMS(vlc_buffer) - offset; ff_init_vlc_from_lengths(&vtable[i], huff_bits[i], huff_sizes[i], diff --git a/libavcodec/rl.c b/libavcodec/rl.c index 4ce003ccf4..645a5362f7 100644 --- a/libavcodec/rl.c +++ b/libavcodec/rl.c @@ -62,7 +62,7 @@ av_cold void ff_rl_init(RLTable *rl, av_cold void ff_rl_init_vlc(RLTable *rl, unsigned static_size) { int i, q; - VLC_TYPE table[1500][2] = {{0}}; + VLCElem table[1500] = { 0 }; VLC vlc = { .table = table, .table_allocated = static_size }; av_assert0(static_size <= FF_ARRAY_ELEMS(table)); init_vlc(&vlc, 9, rl->n + 1, &rl->table_vlc[0][1], 4, 2, &rl->table_vlc[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC); @@ -79,8 +79,8 @@ av_cold void ff_rl_init_vlc(RLTable *rl, unsigned static_size) qadd = 0; } for (i = 0; i < vlc.table_size; i++) { - int code = vlc.table[i][0]; - int len = vlc.table[i][1]; + int code = vlc.table[i].sym; + int len = vlc.table[i].len; int level, run; if (len == 0) { // illegal code diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 8f8a755ac3..e394a63a2b 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -340,7 +340,7 @@ static av_cold void rv10_build_vlc(VLC *vlc, const uint16_t len_count[15], static av_cold void rv10_init_static(void) { - static VLC_TYPE table[1472 + 992][2]; + static VLCElem table[1472 + 992]; rv_dc_lum.table = table; rv_dc_lum.table_allocated = 1472; @@ -349,8 +349,8 @@ static av_cold void rv10_init_static(void) for (int i = 0; i < 1 << (DC_VLC_BITS - 7 /* Length of skip prefix */); i++) { /* All codes beginning with 0x7F have the same length and value. * Modifying the table directly saves us the useless subtables. */ - rv_dc_lum.table[(0x7F << (DC_VLC_BITS - 7)) + i][0] = 255; - rv_dc_lum.table[(0x7F << (DC_VLC_BITS - 7)) + i][1] = 18; + rv_dc_lum.table[(0x7F << (DC_VLC_BITS - 7)) + i].sym = 255; + rv_dc_lum.table[(0x7F << (DC_VLC_BITS - 7)) + i].len = 18; } rv_dc_chrom.table = &table[1472]; rv_dc_chrom.table_allocated = 992; @@ -358,8 +358,8 @@ static av_cold void rv10_init_static(void) rv_sym_run_len, FF_ARRAY_ELEMS(rv_sym_run_len) - 2); for (int i = 0; i < 1 << (DC_VLC_BITS - 9 /* Length of skip prefix */); i++) { /* Same as above. */ - rv_dc_chrom.table[(0x1FE << (DC_VLC_BITS - 9)) + i][0] = 255; - rv_dc_chrom.table[(0x1FE << (DC_VLC_BITS - 9)) + i][1] = 18; + rv_dc_chrom.table[(0x1FE << (DC_VLC_BITS - 9)) + i].sym = 255; + rv_dc_chrom.table[(0x1FE << (DC_VLC_BITS - 9)) + i].len = 18; } ff_h263_decode_init_vlc(); } diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 3494c0c579..5f3b7d31cd 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -81,7 +81,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type); * @{ */ -static VLC_TYPE table_data[117592][2]; +static VLCElem table_data[117592]; /** * Generate VLC from codeword lengths. diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index b15f3cddfc..b9469819f7 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -47,7 +47,7 @@ static VLC ptype_vlc[NUM_PTYPE_VLCS], btype_vlc[NUM_BTYPE_VLCS]; static av_cold void rv40_init_table(VLC *vlc, unsigned *offset, int nb_bits, int nb_codes, const uint8_t (*tab)[2]) { - static VLC_TYPE vlc_buf[11776][2]; + static VLCElem vlc_buf[11776]; vlc->table = &vlc_buf[*offset]; vlc->table_allocated = 1 << nb_bits; @@ -64,7 +64,7 @@ static av_cold void rv40_init_table(VLC *vlc, unsigned *offset, int nb_bits, static av_cold void rv40_init_tables(void) { int i, offset = 0; - static VLC_TYPE aic_mode2_table[11814][2]; + static VLCElem aic_mode2_table[11814]; rv40_init_table(&aic_top_vlc, &offset, AIC_TOP_BITS, AIC_TOP_SIZE, rv40_aic_top_vlc_tab); diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index 7cd623ff18..6fb50575bf 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -777,7 +777,7 @@ static av_cold void svq1_static_init(void) for (int i = 0, offset = 0; i < 6; i++) { static const uint8_t sizes[2][6] = { { 14, 10, 14, 18, 16, 18 }, { 10, 10, 14, 14, 14, 16 } }; - static VLC_TYPE table[168][2]; + static VLCElem table[168]; svq1_intra_multistage[i].table = &table[offset]; svq1_intra_multistage[i].table_allocated = sizes[0][i]; offset += sizes[0][i]; diff --git a/libavcodec/tableprint_vlc.h b/libavcodec/tableprint_vlc.h index d53ae5799f..b97c1f9cfb 100644 --- a/libavcodec/tableprint_vlc.h +++ b/libavcodec/tableprint_vlc.h @@ -39,23 +39,22 @@ #include "libavutil/reverse.c" #include "vlc.c" -#define REPLACE_DEFINE2(type) write_##type##_array -#define REPLACE_DEFINE(type) REPLACE_DEFINE2(type) -static void write_VLC_TYPE_array(const VLC_TYPE *p, int s) { - REPLACE_DEFINE(VLC_TYPE)(p, s); -} - -WRITE_2D_FUNC(VLC_TYPE) +// The following will have to be modified if VLCBaseType changes. +WRITE_1D_FUNC_ARGV(VLCElem, 3, "{ .sym =%5" PRId16 ", .len =%2"PRIi16 " }", + data[i].sym, data[i].len) -static void write_vlc_type(const VLC *vlc, VLC_TYPE (*base_table)[2], const char *base_table_name) +static void write_vlc_type(const VLC *vlc, const VLCElem *base_table, const char *base_table_name) { printf(" .bits = %i,\n", vlc->bits); // Unfortunately need to cast away const currently - printf(" .table = (VLC_TYPE (*)[2])(%s + 0x%x),\n", base_table_name, (int)(vlc->table - base_table)); + printf(" .table = (VLCElem *)(%s + 0x%x),\n", base_table_name, (int)(vlc->table - base_table)); printf(" .table_size = 0x%x,\n", vlc->table_size); printf(" .table_allocated = 0x%x,\n", vlc->table_allocated); } +#define WRITE_VLC_TABLE(prefix, name) \ + WRITE_ARRAY(prefix, VLCElem, name) + #define WRITE_VLC_TYPE(prefix, name, base_table) \ do { \ printf(prefix" VLC "#name" = {\n"); \ diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c index 136f1f76d9..f6950fbbb6 100644 --- a/libavcodec/tscc2.c +++ b/libavcodec/tscc2.c @@ -57,7 +57,7 @@ static av_cold void tscc2_init_vlc(VLC *vlc, int *offset, int nb_codes, const uint8_t *lens, const void *syms, int sym_length) { - static VLC_TYPE vlc_buf[15442][2]; + static VLCElem vlc_buf[15442]; vlc->table = &vlc_buf[*offset]; vlc->table_allocated = FF_ARRAY_ELEMS(vlc_buf) - *offset; diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index fa028a5784..1070b8ca90 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -1584,7 +1584,7 @@ static const uint16_t vlc_offs[] = { static av_cold void vc1_init_static(void) { - static VLC_TYPE vlc_table[32372][2]; + static VLCElem vlc_table[32372]; INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23, ff_vc1_bfraction_bits, 1, 1, diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c index 1a9bd8e6d2..96f2b28c7e 100644 --- a/libavcodec/vlc.c +++ b/libavcodec/vlc.c @@ -65,13 +65,13 @@ static int alloc_table(VLC *vlc, int size, int use_static) if (use_static) abort(); // cannot do anything, init_vlc() is used with too little memory vlc->table_allocated += (1 << vlc->bits); - vlc->table = av_realloc_f(vlc->table, vlc->table_allocated, sizeof(VLC_TYPE) * 2); + vlc->table = av_realloc_f(vlc->table, vlc->table_allocated, sizeof(*vlc->table)); if (!vlc->table) { vlc->table_allocated = 0; vlc->table_size = 0; return AVERROR(ENOMEM); } - memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(VLC_TYPE) * 2 << vlc->bits); + memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(*vlc->table) << vlc->bits); } return index; } @@ -88,7 +88,7 @@ static av_always_inline uint32_t bitswap_32(uint32_t x) typedef struct VLCcode { uint8_t bits; - VLC_TYPE symbol; + VLCBaseType symbol; /** codeword, with the first bit-to-be-read in the msb * (even if intended for a little-endian bitstream reader) */ uint32_t code; @@ -138,7 +138,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, VLCcode *codes, int flags) { int table_size, table_index; - VLC_TYPE (*table)[2]; + VLCElem *table; if (table_nb_bits > 30) return AVERROR(EINVAL); @@ -166,15 +166,15 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, inc = 1 << n; } for (int k = 0; k < nb; k++) { - int bits = table[j][1]; - int oldsym = table[j][0]; + int bits = table[j].len; + int oldsym = table[j].sym; ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); if ((bits || oldsym) && (bits != n || oldsym != symbol)) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return AVERROR_INVALIDDATA; } - table[j][1] = n; //bits - table[j][0] = symbol; + table[j].len = n; + table[j].sym = symbol; j += inc; } } else { @@ -200,7 +200,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, } subtable_bits = FFMIN(subtable_bits, table_nb_bits); j = (flags & INIT_VLC_OUTPUT_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; - table[j][1] = -subtable_bits; + table[j].len = -subtable_bits; ff_dlog(NULL, "%4x: n=%d (subtable)\n", j, codes[i].bits + table_nb_bits); index = build_table(vlc, subtable_bits, k-i, codes+i, flags); @@ -208,8 +208,8 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, return index; /* note: realloc has been done, so reload tables */ table = &vlc->table[table_index]; - table[j][0] = index; //code - if (table[j][0] != index) { + table[j].sym = index; + if (table[j].sym != index) { avpriv_request_sample(NULL, "strange codes"); return AVERROR_PATCHWELCOME; } @@ -218,8 +218,8 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, } for (int i = 0; i < table_size; i++) { - if (table[i][1] == 0) //bits - table[i][0] = -1; //codes + if (table[i].len == 0) + table[i].sym = -1; } return table_index; diff --git a/libavcodec/vlc.h b/libavcodec/vlc.h index 6879c3ca6a..e63c484755 100644 --- a/libavcodec/vlc.h +++ b/libavcodec/vlc.h @@ -21,11 +21,16 @@ #include -#define VLC_TYPE int16_t +// When changing this, be sure to also update tableprint_vlc.h accordingly. +typedef int16_t VLCBaseType; + +typedef struct VLCElem { + VLCBaseType sym, len; +} VLCElem; typedef struct VLC { int bits; - VLC_TYPE (*table)[2]; ///< code, bits + VLCElem *table; int table_size, table_allocated; } VLC; @@ -98,7 +103,7 @@ void ff_free_vlc(VLC *vlc); #define INIT_CUSTOM_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, \ h, i, j, flags, static_size) \ do { \ - static VLC_TYPE table[static_size][2]; \ + static VLCElem table[static_size]; \ (vlc)->table = table; \ (vlc)->table_allocated = static_size; \ ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \ @@ -127,7 +132,7 @@ void ff_free_vlc(VLC *vlc); symbols, symbols_wrap, symbols_size, \ offset, flags, static_size) \ do { \ - static VLC_TYPE table[static_size][2]; \ + static VLCElem table[static_size]; \ (vlc)->table = table; \ (vlc)->table_allocated = static_size; \ ff_init_vlc_from_lengths(vlc, bits, nb_codes, lens, len_wrap, \ diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 1a745331f4..8ca1b0dfe3 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1197,7 +1197,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb, /* local references to structure members to avoid repeated dereferences */ int *coded_fragment_list = s->coded_fragment_list[plane]; Vp3Fragment *all_fragments = s->all_fragments; - VLC_TYPE(*vlc_table)[2] = table->table; + const VLCElem *vlc_table = table->table; if (num_coeffs < 0) { av_log(s->avctx, AV_LOG_ERROR,