From patchwork Wed Jun 19 02:39:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13608 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 CE8C5448A0A for ; Wed, 19 Jun 2019 05:47:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A9DAA689A87; Wed, 19 Jun 2019 05:47:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 291AC689A30 for ; Wed, 19 Jun 2019 05:47:37 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id v14so1606448wrr.4 for ; Tue, 18 Jun 2019 19:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+wLvZEwJoqxKwgf6/mk3qcnBfYLPQcd5NRNtcdYwOeY=; b=F2ER0hxtBVprbnVZnoo+gQsGtJ3r76qC1oJJI1lr7f1RmyMsYkzdr+S/tMCiMjiwwo zD9B3GkEGogy9QUqLMJqjTHZd39MkaSJpQlKcRN5zVP0ljpnMp/9v9/gGLJFpfzJiqdG 4Jg8WXaMGtkvurBob/B8SmmRz+pare3b/fmgQMOLOPyMirKub3VAjzgMSN3FYoN3Cbb8 pVLrXKOlVPV0VPnjKdhZ76vCeyzhwR4EU1ykqiVwYKLs4R+M9lwGwAlw5ue4YTM4dMaW bU60FbuVzDxQBAyoufNtC7EYtS7Hn//uODqIsI6SuueQS/uS/pAD5239epJjUmD+LIae r3Eg== 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:mime-version :content-transfer-encoding; bh=+wLvZEwJoqxKwgf6/mk3qcnBfYLPQcd5NRNtcdYwOeY=; b=Odk5t3pilqVpANAEuPBnSFeYXP+a+4b88oWTVmhozP1Z4tn42hK4HXQorAkKPAJd6P C+nvrfM4yjXlxz9qT77Zj2Hg69bQ2tYM6D8ZIdz8AJL8sf+C2YHL2oMtuwbccqPa1Ky2 pQwAaszW4XNgTbozTQIjGNBkJTsqrIoVa0is+Y5r7kaRgNXxK2v8pRLTO4sPeR+OwF3m 6UPoqxwajt8JGQ6dXQ1V0J5xz4/jhhOu+HONsBJ8g2rcP4MTVPjQmbxPbgyuq7DXRZWj tanYnuvRvuIob+d7YEQfRcR1RXO75cyoTR1cLBNPQ+Q2Pr86pwYlIKAbrn7DbEf2iHCk zrag== X-Gm-Message-State: APjAAAUp/Q3wOT8J5GCuCDOvoKlhOCgltUVTFKHVPdKAzTnhbsDTsQa5 3eBuoKjSHzN1zP/WgssltJrS6F9s X-Google-Smtp-Source: APXvYqzX0zT5jBeKlkp7QazPfBKnNKc17XPLI9dNTUNc3/t9yc1NjUvqMqNfzKlFA3Zb2lsgk5PEhw== X-Received: by 2002:adf:fe4e:: with SMTP id m14mr15755611wrs.21.1560912060283; Tue, 18 Jun 2019 19:41:00 -0700 (PDT) Received: from localhost.localdomain (ipbcc063db.dynamic.kabel-deutschland.de. [188.192.99.219]) by smtp.gmail.com with ESMTPSA id k82sm34351wma.15.2019.06.18.19.40.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 19:40:59 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jun 2019 04:39:47 +0200 Message-Id: <20190619023947.15222-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavcodec: Reduce the size of some arrays 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" This commit uses smaller types for some static const arrays to reduce their size in case the entries can be represented in the smaller type. The biggest savings came from inv_map_table in vp9.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/a64multienc.c | 6 +++--- libavcodec/ac3enc.c | 2 +- libavcodec/adpcm.c | 8 ++++---- libavcodec/aic.c | 4 ++-- libavcodec/atrac3plus.c | 12 ++++++------ libavcodec/atrac3plusdsp.c | 4 ++-- libavcodec/atrac9dec.c | 2 +- libavcodec/cbs_h264_syntax_template.c | 2 +- libavcodec/cbs_vp9_syntax_template.c | 4 ++-- libavcodec/vp9.c | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 91aac0933f..38f25020f5 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -60,11 +60,11 @@ typedef struct A64Context { } A64Context; /* gray gradient */ -static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1}; +static const uint8_t mc_colors[5]={0x0,0xb,0xc,0xf,0x1}; /* other possible gradients - to be tested */ -//static const int mc_colors[5]={0x0,0x8,0xa,0xf,0x7}; -//static const int mc_colors[5]={0x0,0x9,0x8,0xa,0x3}; +//static const uint8_t mc_colors[5]={0x0,0x8,0xa,0xf,0x7}; +//static const uint8_t mc_colors[5]={0x0,0x9,0x8,0xa,0x3}; static void to_meta_with_crop(AVCodecContext *avctx, const AVFrame *p, int *dest) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index e7e18af92d..f1c95ce877 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -652,7 +652,7 @@ void ff_ac3_process_exponents(AC3EncodeContext *s) */ static void count_frame_bits_fixed(AC3EncodeContext *s) { - static const int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 }; + static const uint8_t frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 }; int blk; int frame_bits; diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index ede0130bf1..e194764374 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -57,7 +57,7 @@ */ /* These are for CD-ROM XA ADPCM */ -static const int xa_adpcm_table[5][2] = { +static const int8_t xa_adpcm_table[5][2] = { { 0, 0 }, { 60, 0 }, { 115, -52 }, @@ -65,7 +65,7 @@ static const int xa_adpcm_table[5][2] = { { 122, -60 } }; -static const int ea_adpcm_table[] = { +static const int16_t ea_adpcm_table[] = { 0, 240, 460, 392, 0, 0, -208, -220, 0, 1, 3, 4, @@ -74,7 +74,7 @@ static const int ea_adpcm_table[] = { }; // padded to zero where table size is less then 16 -static const int swf_index_tables[4][16] = { +static const int8_t swf_index_tables[4][16] = { /*2*/ { -1, 2 }, /*3*/ { -1, -1, 2, 4 }, /*4*/ { -1, -1, -1, -1, 2, 4, 6, 8 }, @@ -484,7 +484,7 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ { ADPCMDecodeContext *c = avctx->priv_data; GetBitContext gb; - const int *table; + const int8_t *table; int k0, signmask, nb_bits, count; int size = buf_size*8; int i; diff --git a/libavcodec/aic.c b/libavcodec/aic.c index dc28c83661..956d71fcff 100644 --- a/libavcodec/aic.c +++ b/libavcodec/aic.c @@ -42,9 +42,9 @@ enum AICBands { NUM_BANDS }; -static const int aic_num_band_coeffs[NUM_BANDS] = { 64, 32, 192, 96 }; +static const uint8_t aic_num_band_coeffs[NUM_BANDS] = { 64, 32, 192, 96 }; -static const int aic_band_off[NUM_BANDS] = { 0, 64, 96, 288 }; +static const uint16_t aic_band_off[NUM_BANDS] = { 0, 64, 96, 288 }; static const uint8_t aic_quant_matrix[64] = { 8, 16, 19, 22, 22, 26, 26, 27, diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c index 3e3bba801b..9f964efb4d 100644 --- a/libavcodec/atrac3plus.c +++ b/libavcodec/atrac3plus.c @@ -81,8 +81,8 @@ av_cold void ff_atrac3p_init_vlcs(void) { int i, wl_vlc_offs, ct_vlc_offs, sf_vlc_offs, tab_offset; - static const int wl_nb_bits[4] = { 2, 3, 5, 5 }; - static const int wl_nb_codes[4] = { 3, 5, 8, 8 }; + static const uint8_t wl_nb_bits[4] = { 2, 3, 5, 5 }; + static const uint8_t wl_nb_codes[4] = { 3, 5, 8, 8 }; static const uint8_t * const wl_bits[4] = { atrac3p_wl_huff_bits1, atrac3p_wl_huff_bits2, atrac3p_wl_huff_bits3, atrac3p_wl_huff_bits4 @@ -95,8 +95,8 @@ av_cold void ff_atrac3p_init_vlcs(void) atrac3p_wl_huff_xlat1, atrac3p_wl_huff_xlat2, NULL, NULL }; - static const int ct_nb_bits[4] = { 3, 4, 4, 4 }; - static const int ct_nb_codes[4] = { 4, 8, 8, 8 }; + static const uint8_t ct_nb_bits[4] = { 3, 4, 4, 4 }; + static const uint8_t ct_nb_codes[4] = { 4, 8, 8, 8 }; static const uint8_t * const ct_bits[4] = { atrac3p_ct_huff_bits1, atrac3p_ct_huff_bits2, atrac3p_ct_huff_bits2, atrac3p_ct_huff_bits3 @@ -109,8 +109,8 @@ av_cold void ff_atrac3p_init_vlcs(void) NULL, NULL, atrac3p_ct_huff_xlat1, NULL }; - static const int sf_nb_bits[8] = { 9, 9, 9, 9, 6, 6, 7, 7 }; - static const int sf_nb_codes[8] = { 64, 64, 64, 64, 16, 16, 16, 16 }; + static const uint8_t sf_nb_bits[8] = { 9, 9, 9, 9, 6, 6, 7, 7 }; + static const uint8_t sf_nb_codes[8] = { 64, 64, 64, 64, 16, 16, 16, 16 }; static const uint8_t * const sf_bits[8] = { atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits2, atrac3p_sf_huff_bits3, atrac3p_sf_huff_bits4, atrac3p_sf_huff_bits4, diff --git a/libavcodec/atrac3plusdsp.c b/libavcodec/atrac3plusdsp.c index 96aa402c2b..ca3154e133 100644 --- a/libavcodec/atrac3plusdsp.c +++ b/libavcodec/atrac3plusdsp.c @@ -248,7 +248,7 @@ void ff_atrac3p_generate_tones(Atrac3pChanUnitCtx *ch_unit, AVFloatDSPContext *f out[i] += wavreg1[i] + wavreg2[i]; } -static const int subband_to_powgrp[ATRAC3P_SUBBANDS] = { +static const uint8_t subband_to_powgrp[ATRAC3P_SUBBANDS] = { 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4 }; @@ -411,7 +411,7 @@ static const float pwc_levs[16] = { }; /** Map subband number to quant unit number. */ -static const int subband_to_qu[17] = { +static const uint8_t subband_to_qu[17] = { 0, 8, 12, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }; diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index 805d46f3b8..894c70c7fc 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -241,7 +241,7 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, ATRAC9ChannelData *c, GetBitContext *gb, int channel_idx, int first_in_pkt) { - static const int mode_map[2][4] = { { 0, 1, 2, 3 }, { 0, 2, 3, 4 } }; + static const uint8_t mode_map[2][4] = { { 0, 1, 2, 3 }, { 0, 2, 3, 4 } }; const int mode = mode_map[channel_idx][get_bits(gb, 2)]; memset(c->scalefactors, 0, sizeof(c->scalefactors)); diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index cdacd79fc4..26be6e590f 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -650,7 +650,7 @@ static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw, } if (sps->vui.pic_struct_present_flag) { - static const int num_clock_ts[9] = { + static const uint8_t num_clock_ts[9] = { 1, 1, 1, 2, 2, 3, 3, 2, 3 }; int i; diff --git a/libavcodec/cbs_vp9_syntax_template.c b/libavcodec/cbs_vp9_syntax_template.c index 898cede329..125eb02589 100644 --- a/libavcodec/cbs_vp9_syntax_template.c +++ b/libavcodec/cbs_vp9_syntax_template.c @@ -206,8 +206,8 @@ static int FUNC(quantization_params)(CodedBitstreamContext *ctx, RWContext *rw, static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw, VP9RawFrameHeader *current) { - static const int segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 }; - static const int segmentation_feature_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 }; + static const uint8_t segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 }; + static const uint8_t segmentation_feature_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 }; int err, i, j; diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index acf3ffc9e7..f16462b1e9 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -353,7 +353,7 @@ static av_always_inline int inv_recenter_nonneg(int v, int m) // differential forward probability updates static int update_prob(VP56RangeCoder *c, int p) { - static const int inv_map_table[255] = { + static const uint8_t inv_map_table[255] = { 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, 189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,