From patchwork Mon Nov 23 19:37:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24012 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 6E2A944B5B8 for ; Mon, 23 Nov 2020 21:42:16 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A4D3968BC52; Mon, 23 Nov 2020 21:38:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE9DB68BB73 for ; Mon, 23 Nov 2020 21:38:33 +0200 (EET) Received: by mail-wr1-f46.google.com with SMTP id 64so6385204wra.11 for ; Mon, 23 Nov 2020 11:38:33 -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=WBtSOpdcZ8z/lzzF844+vhWInQCHDMIgJfe6NYPHGe0=; b=dztcsB+VKgazn/z0olTE636Bv6x6T92PxbJ3nwnx+IIjD7cl5YmOx4YaRg8aWCxM+5 mCeTmhUK47QcG/4bg0UQ1BJR0KSzFdjjBjxejnapWDIrb+knFn5GLxZF32rB+PkeYyYx AxWcDMtLfr1sZE9ZMX4bH11cgYprqCw2LbnBLCo1y7VAoeXCDuMx4TAAwvrAoSW9IFnv OpLv4p80iwMSu7uvHryRpc7c0VBx28+zt7gSBvIYC8Nc0/83mziwj4sgqA7iNdr3Y2Hq kNZFMMfi4kbwtyfHpdIG/jc8zLTq31EPptDF7ZSPLrNVm4VzRp/ZhO9Zfjt07m0XiqRA qchw== 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=WBtSOpdcZ8z/lzzF844+vhWInQCHDMIgJfe6NYPHGe0=; b=iNIMzJryZ7/Tz0bPLWzjQYw6vw7jRxm4BVzQsy/+XSB1vg7HLyXBfaGN2m4lscYkCo xozR5XOWm42PG+utjhqi6PtJmE+WriOyIqchPdkA2wUHwaNKpai3q9Nh6TCfl8KbzSx7 RdEhx3udzUyrcUX5+tB8Q7z9tzPGdDMr7kIi/AWuOJDAAZs5kF0uJmP4Qb80i+NT5KMH 0uKkUEbv5t6ghVA8LjP/zRhNo/gExTEX29exj3BpE8+728Yp62505TYUHJmH//Pchxc7 ZY+BXPvF6qB/y6Yynw1F1bWi7cKZIwhOyb0uB/XuITi/aq95bHcCJTg0lIxB7RD+2GCU dCiA== X-Gm-Message-State: AOAM532mkZHn2Hknv6aaDQga0sbRdoFJzAk/0vxIbrQY/9PyEzxTMZj/ FHzURRWIhKq1Wk8iuHe6PXpKm5N3CSnkDA== X-Google-Smtp-Source: ABdhPJyNRymP44DrAT8l+u6Hffm4ZIrV9OWmWgUmW08oGtz2k1tpWKcpTzAKVdq1TcR7S7/asrhS/w== X-Received: by 2002:a5d:4b81:: with SMTP id b1mr1340771wrt.372.1606160312742; Mon, 23 Nov 2020 11:38:32 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id e6sm564086wme.27.2020.11.23.11.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:38:32 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Nov 2020 20:37:38 +0100 Message-Id: <20201123193739.1249300-28-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> References: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 190/191] avcodec/wmadec: Reduce the size of tables used to initialize VLC 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" By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one can replace a table of codes of type uint16_t by a table of symbols of type uint8_t, saving space. Signed-off-by: Andreas Rheinhardt --- libavcodec/wma.h | 3 +-- libavcodec/wmadata.h | 20 ++++++++------------ libavcodec/wmadec.c | 6 +++--- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/libavcodec/wma.h b/libavcodec/wma.h index c7fcf5047c..7935bcdb31 100644 --- a/libavcodec/wma.h +++ b/libavcodec/wma.h @@ -139,8 +139,7 @@ typedef struct WMACodecContext { #endif /* TRACE */ } WMACodecContext; -extern const uint16_t ff_wma_hgain_huffcodes[37]; -extern const uint8_t ff_wma_hgain_huffbits[37]; +extern const uint8_t ff_wma_hgain_hufftab[37][2]; extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16]; extern const uint32_t ff_aac_scalefactor_code[121]; extern const uint8_t ff_aac_scalefactor_bits[121]; diff --git a/libavcodec/wmadata.h b/libavcodec/wmadata.h index 641cb1813c..ca485a5663 100644 --- a/libavcodec/wmadata.h +++ b/libavcodec/wmadata.h @@ -51,18 +51,14 @@ static const uint8_t exponent_band_44100[3][25] = { { 17, 4, 8, 8, 4, 12, 12, 8, 8, 24, 16, 20, 24, 32, 40, 60, 80, 152, }, }; -const uint16_t ff_wma_hgain_huffcodes[37] = { - 0x00003, 0x002e7, 0x00001, 0x005cd, 0x0005d, 0x005c9, 0x0005e, 0x00003, - 0x00016, 0x0000b, 0x00001, 0x00006, 0x00001, 0x00006, 0x00004, 0x00005, - 0x00004, 0x00007, 0x00003, 0x00007, 0x00004, 0x0000a, 0x0000a, 0x00002, - 0x00003, 0x00000, 0x00005, 0x00002, 0x0005f, 0x00004, 0x00003, 0x00002, - 0x005c8, 0x000b8, 0x005ca, 0x005cb, 0x005cc, -}; - -const uint8_t ff_wma_hgain_huffbits[37] = { - 10, 12, 10, 13, 9, 13, 9, 8, 7, 5, 5, 4, 4, 3, 3, 3, - 4, 3, 4, 4, 5, 5, 6, 8, 7, 10, 8, 10, 9, 8, 9, 9, - 13, 10, 13, 13, 13, +const uint8_t ff_wma_hgain_hufftab[37][2] = { + { 25, 10 }, { 2, 10 }, { 27, 10 }, { 0, 10 }, { 31, 9 }, { 30, 9 }, + { 23, 8 }, { 7, 8 }, { 29, 8 }, { 26, 8 }, { 24, 7 }, { 10, 5 }, + { 12, 4 }, { 20, 5 }, { 22, 6 }, { 8, 7 }, { 33, 10 }, { 32, 13 }, + { 5, 13 }, { 34, 13 }, { 35, 13 }, { 36, 13 }, { 3, 13 }, { 1, 12 }, + { 4, 9 }, { 6, 9 }, { 28, 9 }, { 18, 4 }, { 16, 4 }, { 21, 5 }, + { 9, 5 }, { 11, 4 }, { 19, 4 }, { 14, 3 }, { 15, 3 }, { 13, 3 }, + { 17, 3 }, }; const float ff_wma_lsp_codebook[NB_LSP_COEFS][16] = { diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 8504d8d6c4..2b9499eba7 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -110,9 +110,9 @@ static av_cold int wma_decode_init(AVCodecContext *avctx) ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0 / 32768.0); if (s->use_noise_coding) { - init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits), - ff_wma_hgain_huffbits, 1, 1, - ff_wma_hgain_huffcodes, 2, 2, 0); + ff_init_vlc_from_lengths(&s->hgain_vlc, HGAINVLCBITS, FF_ARRAY_ELEMS(ff_wma_hgain_hufftab), + &ff_wma_hgain_hufftab[0][1], 2, + &ff_wma_hgain_hufftab[0][0], 2, 1, 0, 0, avctx); } if (s->use_exp_vlc)