From patchwork Tue Nov 10 10:47:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23526 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C02C144AA20 for ; Tue, 10 Nov 2020 13:00:27 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4674E68BED0; Tue, 10 Nov 2020 12:50:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14A7C68BE67 for ; Tue, 10 Nov 2020 12:50:06 +0200 (EET) Received: by mail-wr1-f45.google.com with SMTP id 23so12138616wrc.8 for ; Tue, 10 Nov 2020 02:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=EDL9yS+/+r5jDgX1IRg5wptub/SMj+KE/0qS8IzN9Zg=; b=vKpdhyBeUGa40pleSBBKk+fopboAT/11ZOMLVn1YZRXDTVgLcYbFmW6i5HqNSg0juz 47UkgYWnMgXMIdiTTT+0D1b2UgMca1SW1FwVkGtRTl1fbdfYmKb24SVtTCd2qKDj8IkR ZK3+8TVPBRgfk7ScwxylvSX1q5DbAJL+hOJLISyrimV+jtEE1rxY7vvM4ixrPrSa1BFk upBRt1RKauZrn6i9Z92+Bj+E8lYU9vHCQFVPDOK9TGHucJPz5MNzOtEpl14fT8/Uan/i Fd6QJsm36v+sPJbxrBvDIS0jXA8rSAznLpgafcFHSfpYpdMwy9KZLSspbtR5FpXlE6F8 rNsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=EDL9yS+/+r5jDgX1IRg5wptub/SMj+KE/0qS8IzN9Zg=; b=DeTedh7FF/6evKB1m6frMxoHZJg483jg3YvzEdeTuUiWzo2bjurwBBDsdWKKPVZE/6 w2oDfLZR9L4dYlFwCqdXryqqtzyHzw6PSwFXfg1fyEDakJdh7sz4Kw8+IlNpUA5Ift0D ntKXLEyvDOziF7lCuFiVEDbiLH8odU4cUmBjUBhDPWXBIg2/Op16jlKB8T7vQwhcGvya KyfUbs7d8bP2kigLvvCromMDqjQGh5AxS/JP+bbjcvjAsFX/2MWnq+MiPdPaqVnN2xSK uuuPp5noT10/KwvEgfs1jnCTARb59AbkW2QwOVEwdhQak/Pk1MIKfZpJrMOExqJTHsS3 WVjw== X-Gm-Message-State: AOAM532kcXxtpyBD/p635rTk+h9GLGmm/aHdw4wTXnT02dJZKmmIDdhX xyoC8e12s0KRF3gkuPLacJZ25tqEA7s= X-Google-Smtp-Source: ABdhPJwAxj3OtJ41VMheBOj5C8yIpfrsCVp0QfqQ8/H50pXtHLPPXkRNWzCeXwBm2IZKaBNDnX+lww== X-Received: by 2002:a05:6000:1006:: with SMTP id a6mr14304158wrx.367.1605005404865; Tue, 10 Nov 2020 02:50:04 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id l24sm2572543wmi.7.2020.11.10.02.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:50:04 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:47:42 +0100 Message-Id: <20201110104851.321029-46-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> References: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 045/114] avcodec/mpc8: Avoid code duplication when initializing VLCs X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Up until now, VLCs that were part of an array of VLCs were often not initialized in a loop, but separately. The probable reason for this was that these VLCs differed slightly in the parameters to be used for them (i.e. the number of codes or the number of bits to be used differs), so that one would have to provide these parameters e.g. via arrays. Yet these problems have actually largely been solved by now: The length information is contained in a run-length encoded form that is the same for all VLCs and both the number of codes as well as the number of bits to use for each VLC can be easily derived from them. There is just one problem to be solved: When the underlying tables have a different number of elements, putting them into an array of arrays would be wasteful; using an array of pointers to the arrays would also be wasteful. Therefore this commit combines the tables into bigger tables. (Given that all the length tables have the same layout this applies only to the symbols tables.) Finally, the array containing the offset of the VLC's buffer in the big buffer has also been removed. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc8.c | 90 +++++---------- libavcodec/mpc8huff.h | 257 +++++++++++++++--------------------------- 2 files changed, 121 insertions(+), 226 deletions(-) diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 4863ec0953..e945d3d200 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -86,33 +86,38 @@ static int mpc8_get_mask(GetBitContext *gb, int size, int t) return mask; } -static const uint16_t vlc_offsets[13] = { - 0, 640, 1184, 1748, 2298, 2426, 2490, 3002, 3258, 3786, 4298, 4876, 5388 -}; - -static av_cold void build_vlc(VLC *vlc, +static av_cold void build_vlc(VLC *vlc, unsigned *buf_offset, const uint8_t codes_counts[16], - const uint8_t syms[], int offset) + const uint8_t **syms, int offset) { + static VLC_TYPE vlc_buf[9296][2]; uint8_t len[MPC8_MAX_VLC_SIZE]; + const uint8_t *old_syms = *syms; unsigned num = 0; + vlc->table = &vlc_buf[*buf_offset]; + vlc->table_allocated = FF_ARRAY_ELEMS(vlc_buf) - *buf_offset; + for (int i = 16; i > 0; i--) for (unsigned tmp = num + codes_counts[i - 1]; num < tmp; num++) len[num] = i; + *syms += num; ff_init_vlc_from_lengths(vlc, FFMIN(len[0], 9), num, len, 1, - syms, 1, 1, offset, INIT_VLC_USE_NEW_STATIC); + old_syms, 1, 1, offset, INIT_VLC_USE_NEW_STATIC); + *buf_offset += vlc->table_size; } static av_cold int mpc8_decode_init(AVCodecContext * avctx) { - int i; + int i, offset = 0; MPCContext *c = avctx->priv_data; GetBitContext gb; static int vlc_initialized = 0; + const uint8_t *q_syms = mpc8_q_syms, *bands_syms = mpc8_bands_syms; + const uint8_t *res_syms = mpc8_res_syms, *scfi_syms = mpc8_scfi_syms; + const uint8_t *dscf_syms = mpc8_dscf_syms; int channels; - static VLC_TYPE codes_table[5388][2]; if(avctx->extradata_size < 2){ av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size); @@ -147,65 +152,24 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) if(vlc_initialized) return 0; av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); -#define INIT_VLC(vlc, bits, len_counts, symbols, offset, static_size) \ - do { \ - static VLC_TYPE table[static_size][2]; \ - (vlc)->table = table; \ - (vlc)->table_allocated = static_size; \ - build_vlc(vlc, len_counts, symbols, offset); \ - } while (0) - + build_vlc(&band_vlc, &offset, mpc8_bands_len_counts, &bands_syms, 0); - INIT_VLC(&band_vlc, MPC8_BANDS_BITS, - mpc8_bands_len_counts, mpc8_bands_syms, 0, 542); + build_vlc(&q1_vlc, &offset, mpc8_q1_len_counts, &q_syms, 0); + build_vlc(&q9up_vlc, &offset, mpc8_q9up_len_counts, &q_syms, 0); - INIT_VLC(&q1_vlc, MPC8_Q1_BITS, - mpc8_q1_len_counts, mpc8_q1_syms, 0, 520); - INIT_VLC(&q9up_vlc, MPC8_Q9UP_BITS, - mpc8_q9up_len_counts, mpc8_q9up_syms, 0, 524); - - INIT_VLC(&scfi_vlc[0], MPC8_SCFI0_BITS, - mpc8_scfi_len_counts[0], mpc8_scfi0_syms, 0, 1 << MPC8_SCFI0_BITS); - INIT_VLC(&scfi_vlc[1], MPC8_SCFI1_BITS, - mpc8_scfi_len_counts[1], mpc8_scfi1_syms, 0, 1 << MPC8_SCFI1_BITS); + for(i = 0; i < 2; i++){ + build_vlc(&scfi_vlc[i], &offset, mpc8_scfi_len_counts[i], &scfi_syms, 0); - INIT_VLC(&dscf_vlc[0], MPC8_DSCF0_BITS, - mpc8_dscf_len_counts[0], mpc8_dscf0_syms, 0, 560); - INIT_VLC(&dscf_vlc[1], MPC8_DSCF1_BITS, - mpc8_dscf_len_counts[1], mpc8_dscf1_syms, 0, 598); + build_vlc(&dscf_vlc[i], &offset, mpc8_dscf_len_counts[i], &dscf_syms, 0); - INIT_VLC(&q3_vlc[0], MPC8_Q3_BITS, - mpc8_q3_len_counts, mpc8_q3_syms, MPC8_Q3_OFFSET, 512); - INIT_VLC(&q3_vlc[1], MPC8_Q4_BITS, - mpc8_q4_len_counts, mpc8_q4_syms, MPC8_Q4_OFFSET, 516); + build_vlc(&res_vlc[i], &offset, mpc8_res_len_counts[i], &res_syms, 0); - for(i = 0; i < 2; i++){ - res_vlc[i].table = &codes_table[vlc_offsets[0+i]]; - res_vlc[i].table_allocated = vlc_offsets[1+i] - vlc_offsets[0+i]; - build_vlc(&res_vlc[i], - mpc8_res_len_counts[i], mpc8_res_syms[i], 0); - - q2_vlc[i].table = &codes_table[vlc_offsets[2+i]]; - q2_vlc[i].table_allocated = vlc_offsets[3+i] - vlc_offsets[2+i]; - build_vlc(&q2_vlc[i], - mpc8_q2_len_counts[i], mpc8_q2_syms[i], 0); - - quant_vlc[0][i].table = &codes_table[vlc_offsets[4+i]]; - quant_vlc[0][i].table_allocated = vlc_offsets[5+i] - vlc_offsets[4+i]; - build_vlc(&quant_vlc[0][i], - mpc8_q5_len_counts[i], mpc8_q5_syms[i], MPC8_Q5_OFFSET); - quant_vlc[1][i].table = &codes_table[vlc_offsets[6+i]]; - quant_vlc[1][i].table_allocated = vlc_offsets[7+i] - vlc_offsets[6+i]; - build_vlc(&quant_vlc[1][i], - mpc8_q6_len_counts[i], mpc8_q6_syms[i], MPC8_Q6_OFFSET); - quant_vlc[2][i].table = &codes_table[vlc_offsets[8+i]]; - quant_vlc[2][i].table_allocated = vlc_offsets[9+i] - vlc_offsets[8+i]; - build_vlc(&quant_vlc[2][i], - mpc8_q7_len_counts[i], mpc8_q7_syms[i], MPC8_Q7_OFFSET); - quant_vlc[3][i].table = &codes_table[vlc_offsets[10+i]]; - quant_vlc[3][i].table_allocated = vlc_offsets[11+i] - vlc_offsets[10+i]; - build_vlc(&quant_vlc[3][i], - mpc8_q8_len_counts[i], mpc8_q8_syms[i], MPC8_Q8_OFFSET); + build_vlc(&q2_vlc[i], &offset, mpc8_q2_len_counts[i], &q_syms, 0); + build_vlc(&q3_vlc[i], &offset, mpc8_q34_len_counts[i], + &q_syms, -48 - 16 * i); + for (int j = 0; j < 4; j++) + build_vlc(&quant_vlc[j][i], &offset, mpc8_q5_8_len_counts[i][j], + &q_syms, -((8 << j) - 1)); } vlc_initialized = 1; diff --git a/libavcodec/mpc8huff.h b/libavcodec/mpc8huff.h index 8838751fd6..51997df3ed 100644 --- a/libavcodec/mpc8huff.h +++ b/libavcodec/mpc8huff.h @@ -37,18 +37,11 @@ static const uint8_t mpc8_bands_len_counts[16] = { 1, 1, 1, 0, 2, 2, 1, 3, 2, 3, 4, 11, 2, 0, 0, 0 }; -#define MPC8_SCFI0_SIZE 4 -#define MPC8_SCFI0_BITS 3 - -static const uint8_t mpc8_scfi0_syms[MPC8_SCFI0_SIZE] = { - 0, 1, 3, 2 -}; - -#define MPC8_SCFI1_SIZE 16 -#define MPC8_SCFI1_BITS 7 - -static const uint8_t mpc8_scfi1_syms[MPC8_SCFI1_SIZE] = { - 1, 4, 0, 2, 3, 8, 12, 5, 6, 7, 9, 13, 11, 14, 10, 15 +static const uint8_t mpc8_scfi_syms[] = { + /* SCFI[0] VLC symbols - 4 entries */ + 0, 1, 3, 2, + /* SCFI[1] VLC symbols - 16 entries */ + 1, 4, 0, 2, 3, 8, 12, 5, 6, 7, 9, 13, 11, 14, 10, 15 }; static const uint8_t mpc8_scfi_len_counts[2][16] = { @@ -56,20 +49,16 @@ static const uint8_t mpc8_scfi_len_counts[2][16] = { { 0, 2, 2, 0, 5, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, }; -#define MPC8_DSCF0_SIZE 64 #define MPC8_DSCF0_BITS 9 +#define MPC8_DSCF1_BITS 9 -static const uint8_t mpc8_dscf0_syms[MPC8_DSCF0_SIZE] = { +static const uint8_t mpc8_dscf_syms[] = { + /* DSCF[0] VLC symbols - 64 entries */ 58, 59, 60, 61, 62, 63, 55, 56, 57, 0, 1, 2, 53, 54, 3, 4, 5, 50, 51, 52, 6, 7, 8, 9, 10, 31, 47, 48, 49, 11, 12, 13, 14, 44, 45, 46, 15, 16, 17, 18, 41, 42, 43, 19, 20, 21, 22, 40, 23, 24, 38, 39, 25, 28, 37, 26, 27, 29, 30, 32, 36, 33, 34, 35, -}; - -#define MPC8_DSCF1_SIZE 65 -#define MPC8_DSCF1_BITS 9 - -static const uint8_t mpc8_dscf1_syms[MPC8_DSCF1_SIZE] = { + /* DSCF[1] VLC symbols - 65 entries */ 0, 59, 60, 61, 62, 63, 1, 2, 56, 57, 58, 3, 4, 5, 53, 54, 55, 6, 7, 8, 9, 49, 50, 51, 52, 64, 10, 11, 12, 13, 46, 47, 48, 14, 15, 16, 17, 43, 44, 45, 18, 19, 20, 41, 42, 21, 22, 39, 40, 23, 24, 38, 25, 37, 26, 35, 36, @@ -81,16 +70,13 @@ static const uint8_t mpc8_dscf_len_counts[2][16] = { { 0, 0, 5, 3, 3, 2, 3, 4, 5, 7, 7, 9, 6, 5, 6, 0 }, }; -#define MPC8_RES_SIZE 17 #define MPC8_RES_BITS 9 -static const uint8_t mpc8_res_syms[2][MPC8_RES_SIZE] = { - { +static const uint8_t mpc8_res_syms[] = { + /* RES[0] VLC symbols - 17 entries */ 13, 14, 12, 11, 10, 9, 8, 7, 6, 15, 5, 4, 3, 2, 16, 1, 0, - }, - { + /* RES[1] VLC symbols - 17 entries */ 8, 9, 10, 11, 7, 12, 6, 13, 5, 4, 14, 3, 15, 2, 0, 1, 16, - } }; static const uint8_t mpc8_res_len_counts[2][16] = { @@ -98,21 +84,53 @@ static const uint8_t mpc8_res_len_counts[2][16] = { { 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 0, 0 }, }; -#define MPC8_Q1_SIZE 19 #define MPC8_Q1_BITS 9 -static const uint8_t mpc8_q1_syms[MPC8_Q1_SIZE] = { - 17, 18, 16, 15, 14, 13, 12, 0, 11, 1, 2, 8, 9, 10, 3, 4, 5, 6, 7, -}; - static const uint8_t mpc8_q1_len_counts[16] = { 0, 0, 5, 5, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0 }; -#define MPC8_Q9UP_SIZE 256 #define MPC8_Q9UP_BITS 9 -static const uint8_t mpc8_q9up_syms[MPC8_Q9UP_SIZE] = { +static const uint8_t mpc8_q9up_len_counts[16] = { + 0, 0, 0, 0, 0, 2, 38, 134, 71, 9, 2, 0, 0, 0, 0, 0 +}; + +#define MPC8_Q2_BITS 9 + +static const uint8_t mpc8_q2_len_counts[2][16] = { + { 0, 0, 1, 6, 0, 17, 9, 24, 24, 9, 27, 4, 4, 0, 0, 0 }, + { 0, 0, 0, 1, 16, 10, 6, 48, 9, 27, 4, 4, 0, 0, 0, 0 }, +}; + +#define MPC8_Q3_BITS 9 +#define MPC8_Q4_BITS 9 + +static const uint8_t mpc8_q34_len_counts[2][16] = { + { 0, 0, 1, 6, 6, 11, 13, 8, 4, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 12, 23, 14, 19, 8, 4, 0, 0, 0, 0, 0, 0 }, +}; + +static const uint8_t mpc8_q5_8_len_counts[2][4][16] = { + { /* Q5[0], Q6[0], Q7[0], Q8[0] */ + { 0, 1, 4, 2, 2, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 2, 4, 3, 7, 2, 4, 8, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 2, 2, 4, 6, 10, 10, 12, 16, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 2, 1, 3, 8, 8, 15, 24, 42, 17, 6, 0, 0, 0, 0 }, + }, + { /* Q5[1], Q6[1], Q7[1], Q8[1] */ + { 0, 0, 5, 4, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 11, 6, 4, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 20, 15, 10, 14, 4, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 26, 55, 38, 8, 0, 0, 0, 0, 0, 0, 0 }, + } +}; + +static const uint8_t mpc8_q_syms[] = { + /* Q1 VLC symbols - 19 entries */ + 17, 18, 16, 15, 14, 13, 12, 0, 11, 1, 2, 8, 9, 10, 3, + 4, 5, 6, 7, + /* Q9UP VLC symbols - 256 entries */ 254, 255, 0, 1, 2, 3, 4, 250, 251, 252, 253, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, @@ -131,17 +149,7 @@ static const uint8_t mpc8_q9up_syms[MPC8_Q9UP_SIZE] = { 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 127, 128, -}; - -static const uint8_t mpc8_q9up_len_counts[16] = { - 0, 0, 0, 0, 0, 2, 38, 134, 71, 9, 2, 0, 0, 0, 0, 0 -}; - -#define MPC8_Q2_SIZE 125 -#define MPC8_Q2_BITS 9 - -static const uint8_t mpc8_q2_syms[2][MPC8_Q2_SIZE] = { -{ + /* Q2[0] VLC symbols - 125 entries */ 4, 24, 100, 120, 0, 20, 104, 124, 1, 3, 5, 9, 10, 14, 15, 19, 21, 23, 25, 29, 45, 49, 75, 79, 95, 99, 101, 103, 105, 109, 114, 115, 119, 121, 123, 2, 22, 50, 54, 70, 74, 102, 110, 122, 6, @@ -151,8 +159,34 @@ static const uint8_t mpc8_q2_syms[2][MPC8_Q2_SIZE] = { 113, 117, 12, 33, 43, 52, 60, 64, 72, 91, 112, 31, 32, 36, 38, 41, 42, 56, 58, 66, 68, 81, 82, 83, 86, 88, 92, 93, 37, 57, 61, 63, 67, 87, 62, -}, -{ + /* Q3 VLC symbols - 49 entries */ + 13, 3, 109, 99, 14, 2, 29, 19, 93, 83, 110, 98, 15, 0, 1, + 18, 45, 35, 61, 51, 77, 67, 111, 96, 97, 30, 31, 17, 46, 34, + 78, 66, 94, 95, 81, 82, 16, 33, 62, 50, 79, 80, 47, 32, 63, + 49, 64, 65, 48, + /* Q5[0] VLC symbols - 15 entries */ + 0, 1, 13, 14, 2, 12, 3, 11, 4, 10, 5, 6, 8, 9, 7, + /* Q6[0] VLC symbols - 31 entries */ + 0, 1, 2, 3, 27, 28, 29, 30, 4, 5, 25, 26, 6, 24, 7, + 8, 9, 20, 21, 22, 23, 10, 11, 19, 12, 13, 17, 18, 14, 16, + 15, + /* Q7[0] VLC symbols - 63 entries */ + 0, 1, 2, 5, 6, 7, 8, 9, 53, 54, 55, 56, 57, 60, 61, + 62, 3, 4, 10, 11, 12, 13, 49, 50, 51, 52, 58, 59, 14, 15, + 16, 17, 18, 43, 45, 46, 47, 48, 19, 20, 21, 22, 23, 39, 40, + 41, 42, 44, 24, 25, 26, 36, 37, 38, 27, 28, 34, 35, 29, 33, + 30, 32, 31, + /* Q8[0] VLC symbols - 127 entries */ + 11, 12, 111, 113, 114, 115, 0, 1, 13, 14, 15, 16, 17, 18, 19, + 21, 104, 105, 107, 108, 109, 110, 112, 2, 3, 4, 5, 6, 8, 10, + 20, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 92, + 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 106, 116, 117, 120, 121, + 122, 123, 124, 125, 126, 7, 9, 30, 36, 37, 38, 39, 40, 41, 42, + 43, 45, 83, 84, 85, 86, 87, 88, 89, 90, 91, 94, 118, 119, 44, + 46, 47, 48, 49, 50, 51, 75, 76, 77, 78, 79, 80, 81, 82, 52, + 53, 54, 55, 71, 72, 73, 74, 56, 57, 58, 59, 67, 68, 69, 70, + 60, 65, 66, 61, 62, 64, 63, + /* Q2[1] VLC symbols - 125 entries */ 4, 24, 100, 120, 0, 20, 104, 124, 1, 3, 5, 9, 10, 15, 19, 21, 23, 25, 29, 45, 49, 75, 79, 95, 99, 101, 102, 103, 105, 109, 114, 115, 119, 121, 123, 2, 14, 22, 50, 54, 70, 74, 110, 122, 6, @@ -162,123 +196,26 @@ static const uint8_t mpc8_q2_syms[2][MPC8_Q2_SIZE] = { 117, 118, 12, 52, 60, 64, 72, 112, 31, 33, 36, 41, 43, 81, 83, 88, 91, 93, 32, 37, 38, 42, 56, 57, 58, 61, 63, 66, 67, 68, 82, 86, 87, 92, 62, -} -}; - -static const uint8_t mpc8_q2_len_counts[2][16] = { - { 0, 0, 1, 6, 0, 17, 9, 24, 24, 9, 27, 4, 4, 0, 0, 0 }, - { 0, 0, 0, 1, 16, 10, 6, 48, 9, 27, 4, 4, 0, 0, 0, 0 }, -}; - -#define MPC8_Q3_SIZE 49 -#define MPC8_Q3_BITS 9 -#define MPC8_Q3_OFFSET -48 - -static const uint8_t mpc8_q3_len_counts[16] = { - 0, 0, 1, 6, 6, 11, 13, 8, 4, 0, 0, 0, 0, 0, 0, 0 -}; -static const uint8_t mpc8_q3_syms[MPC8_Q3_SIZE] = { - 13, 3, 109, 99, 14, 2, 29, 19, 93, 83, 110, 98, 15, 0, 1, - 18, 45, 35, 61, 51, 77, 67, 111, 96, 97, 30, 31, 17, 46, 34, - 78, 66, 94, 95, 81, 82, 16, 33, 62, 50, 79, 80, 47, 32, 63, - 49, 64, 65, 48, -}; - -#define MPC8_Q4_SIZE 81 -#define MPC8_Q4_BITS 9 -#define MPC8_Q4_OFFSET -64 - -static const uint8_t mpc8_q4_len_counts[16] = { - 0, 0, 0, 1, 12, 23, 14, 19, 8, 4, 0, 0, 0, 0, 0, 0 -}; -static const uint8_t mpc8_q4_syms[MPC8_Q4_SIZE] = { + /* Q4 VLC symbols - 81 entries */ 12, 4, 140, 132, 13, 3, 28, 20, 124, 116, 141, 131, 14, 1, 2, 29, 19, 44, 36, 60, 52, 92, 84, 108, 100, 125, 115, 142, 143, 129, 130, 15, 0, 30, 18, 45, 35, 76, 68, 109, 99, 126, 127, 114, 128, 31, 16, 17, 46, 47, 33, 34, 61, 62, 50, 51, 77, 67, 93, 94, 82, 83, 110, 111, 97, 98, 112, 113, 32, 63, 48, 49, 78, 79, 65, 66, 95, 80, 81, 96, 64, -}; - -#define MPC8_Q5_SIZE 15 -#define MPC8_Q5_BITS 7 -#define MPC8_Q5_OFFSET -7 - -static const uint8_t mpc8_q5_syms[2][MPC8_Q5_SIZE] = { -{ - 0, 1, 13, 14, 2, 12, 3, 11, 4, 10, 5, 6, 8, 9, 7, -}, -{ - 0, 1, 13, 14, 2, 12, 3, 4, 10, 11, 5, 6, 7, 8, 9, -} -}; - -static const uint8_t mpc8_q5_len_counts[2][16] = { - { 0, 1, 4, 2, 2, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 5, 4, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -#define MPC8_Q6_SIZE 31 -#define MPC8_Q6_BITS 9 -#define MPC8_Q6_OFFSET -15 - -static const uint8_t mpc8_q6_syms[2][MPC8_Q6_SIZE] = { -{ - 0, 1, 2, 3, 27, 28, 29, 30, 4, 5, 25, 26, 6, 24, 7, 8, 9, 20, 21, - 22, 23, 10, 11, 19, 12, 13, 17, 18, 14, 16, 15, -}, -{ - 0, 1, 29, 30, 2, 3, 4, 26, 27, 28, 5, 6, 24, 25, 7, 8, 9, 21, 22, - 23, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -} -}; - -static const uint8_t mpc8_q6_len_counts[2][16] = { - { 0, 1, 2, 4, 3, 7, 2, 4, 8, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 11, 6, 4, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -#define MPC8_Q7_SIZE 63 -#define MPC8_Q7_BITS 9 -#define MPC8_Q7_OFFSET -31 - -static const uint8_t mpc8_q7_syms[2][MPC8_Q7_SIZE] = { -{ - 0, 1, 2, 5, 6, 7, 8, 9, 53, 54, 55, 56, 57, 60, 61, 62, 3, 4, 10, - 11, 12, 13, 49, 50, 51, 52, 58, 59, 14, 15, 16, 17, 18, 43, 45, 46, 47, 48, - 19, 20, 21, 22, 23, 39, 40, 41, 42, 44, 24, 25, 26, 36, 37, 38, 27, 28, 34, - 35, 29, 33, 30, 32, 31, -}, -{ - 0, 1, 61, 62, 2, 3, 4, 5, 6, 7, 8, 54, 55, 56, 57, 58, 59, 60, 9, - 10, 11, 12, 13, 49, 50, 51, 52, 53, 14, 15, 16, 17, 18, 19, 20, 21, 42, 43, - 44, 45, 46, 47, 48, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, -} -}; - -static const uint8_t mpc8_q7_len_counts[2][MPC8_Q7_SIZE] = { - { 0, 1, 2, 2, 4, 6, 10, 10, 12, 16, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 20, 15, 10, 14, 4, 0, 0, 0, 0, 0, 0, 0 }, -}; - -#define MPC8_Q8_SIZE 127 -#define MPC8_Q8_BITS 9 -#define MPC8_Q8_OFFSET -63 - -static const uint8_t mpc8_q8_syms[2][MPC8_Q8_SIZE] = { -{ - 11, 12, 111, 113, 114, 115, 0, 1, 13, 14, 15, 16, 17, 18, 19, - 21, 104, 105, 107, 108, 109, 110, 112, 2, 3, 4, 5, 6, 8, 10, - 20, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 92, - 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 106, 116, 117, 120, 121, - 122, 123, 124, 125, 126, 7, 9, 30, 36, 37, 38, 39, 40, 41, 42, - 43, 45, 83, 84, 85, 86, 87, 88, 89, 90, 91, 94, 118, 119, 44, - 46, 47, 48, 49, 50, 51, 75, 76, 77, 78, 79, 80, 81, 82, 52, - 53, 54, 55, 71, 72, 73, 74, 56, 57, 58, 59, 67, 68, 69, 70, - 60, 65, 66, 61, 62, 64, 63, -}, -{ + /* Q5[1] VLC symbols - 15 entries */ + 0, 1, 13, 14, 2, 12, 3, 4, 10, 11, 5, 6, 7, 8, 9, + /* Q6[1] VLC symbols - 31 entries */ + 0, 1, 29, 30, 2, 3, 4, 26, 27, 28, 5, 6, 24, 25, 7, + 8, 9, 21, 22, 23, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, + /* Q7[1] VLC symbols - 63 entries */ + 0, 1, 61, 62, 2, 3, 4, 5, 6, 7, 8, 54, 55, 56, 57, + 58, 59, 60, 9, 10, 11, 12, 13, 49, 50, 51, 52, 53, 14, 15, + 16, 17, 18, 19, 20, 21, 42, 43, 44, 45, 46, 47, 48, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, + /* Q8[1] VLC symbols - 127 entries */ 0, 1, 2, 3, 123, 124, 125, 126, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, @@ -288,12 +225,6 @@ static const uint8_t mpc8_q8_syms[2][MPC8_Q8_SIZE] = { 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, -} -}; - -static const uint8_t mpc8_q8_len_counts[2][16] = { - { 0, 1, 2, 1, 3, 8, 8, 15, 24, 42, 17, 6, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 26, 55, 38, 8, 0, 0, 0, 0, 0, 0, 0 }, }; #endif /* AVCODEC_MPC8HUFF_H */