1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

libavcodec: Reduce the size of some arrays

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.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2019-06-19 04:39:47 +02:00 committed by James Almer
parent 91f5950f83
commit a1a8815220
10 changed files with 23 additions and 23 deletions

View File

@ -60,11 +60,11 @@ typedef struct A64Context {
} A64Context; } A64Context;
/* gray gradient */ /* 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 */ /* other possible gradients - to be tested */
//static const int mc_colors[5]={0x0,0x8,0xa,0xf,0x7}; //static const uint8_t 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,0x9,0x8,0xa,0x3};
static void to_meta_with_crop(AVCodecContext *avctx, static void to_meta_with_crop(AVCodecContext *avctx,
const AVFrame *p, int *dest) const AVFrame *p, int *dest)

View File

@ -652,7 +652,7 @@ void ff_ac3_process_exponents(AC3EncodeContext *s)
*/ */
static void count_frame_bits_fixed(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 blk;
int frame_bits; int frame_bits;

View File

@ -57,7 +57,7 @@
*/ */
/* These are for CD-ROM XA ADPCM */ /* 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 }, { 0, 0 },
{ 60, 0 }, { 60, 0 },
{ 115, -52 }, { 115, -52 },
@ -65,7 +65,7 @@ static const int xa_adpcm_table[5][2] = {
{ 122, -60 } { 122, -60 }
}; };
static const int ea_adpcm_table[] = { static const int16_t ea_adpcm_table[] = {
0, 240, 460, 392, 0, 240, 460, 392,
0, 0, -208, -220, 0, 0, -208, -220,
0, 1, 3, 4, 0, 1, 3, 4,
@ -74,7 +74,7 @@ static const int ea_adpcm_table[] = {
}; };
// padded to zero where table size is less then 16 // 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 }, /*2*/ { -1, 2 },
/*3*/ { -1, -1, 2, 4 }, /*3*/ { -1, -1, 2, 4 },
/*4*/ { -1, -1, -1, -1, 2, 4, 6, 8 }, /*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; ADPCMDecodeContext *c = avctx->priv_data;
GetBitContext gb; GetBitContext gb;
const int *table; const int8_t *table;
int k0, signmask, nb_bits, count; int k0, signmask, nb_bits, count;
int size = buf_size*8; int size = buf_size*8;
int i; int i;

View File

@ -42,9 +42,9 @@ enum AICBands {
NUM_BANDS 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] = { static const uint8_t aic_quant_matrix[64] = {
8, 16, 19, 22, 22, 26, 26, 27, 8, 16, 19, 22, 22, 26, 26, 27,

View File

@ -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; 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 uint8_t 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_codes[4] = { 3, 5, 8, 8 };
static const uint8_t * const wl_bits[4] = { static const uint8_t * const wl_bits[4] = {
atrac3p_wl_huff_bits1, atrac3p_wl_huff_bits2, atrac3p_wl_huff_bits1, atrac3p_wl_huff_bits2,
atrac3p_wl_huff_bits3, atrac3p_wl_huff_bits4 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 atrac3p_wl_huff_xlat1, atrac3p_wl_huff_xlat2, NULL, NULL
}; };
static const int ct_nb_bits[4] = { 3, 4, 4, 4 }; static const uint8_t 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_codes[4] = { 4, 8, 8, 8 };
static const uint8_t * const ct_bits[4] = { static const uint8_t * const ct_bits[4] = {
atrac3p_ct_huff_bits1, atrac3p_ct_huff_bits2, atrac3p_ct_huff_bits1, atrac3p_ct_huff_bits2,
atrac3p_ct_huff_bits2, atrac3p_ct_huff_bits3 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 NULL, NULL, atrac3p_ct_huff_xlat1, NULL
}; };
static const int sf_nb_bits[8] = { 9, 9, 9, 9, 6, 6, 7, 7 }; static const uint8_t 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_codes[8] = { 64, 64, 64, 64, 16, 16, 16, 16 };
static const uint8_t * const sf_bits[8] = { static const uint8_t * const sf_bits[8] = {
atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits2, atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits2,
atrac3p_sf_huff_bits3, atrac3p_sf_huff_bits4, atrac3p_sf_huff_bits4, atrac3p_sf_huff_bits3, atrac3p_sf_huff_bits4, atrac3p_sf_huff_bits4,

View File

@ -248,7 +248,7 @@ void ff_atrac3p_generate_tones(Atrac3pChanUnitCtx *ch_unit, AVFloatDSPContext *f
out[i] += wavreg1[i] + wavreg2[i]; 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 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. */ /** 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 0, 8, 12, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
}; };

View File

@ -241,7 +241,7 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b,
ATRAC9ChannelData *c, GetBitContext *gb, ATRAC9ChannelData *c, GetBitContext *gb,
int channel_idx, int first_in_pkt) 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)]; const int mode = mode_map[channel_idx][get_bits(gb, 2)];
memset(c->scalefactors, 0, sizeof(c->scalefactors)); memset(c->scalefactors, 0, sizeof(c->scalefactors));

View File

@ -650,7 +650,7 @@ static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw,
} }
if (sps->vui.pic_struct_present_flag) { 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 1, 1, 1, 2, 2, 3, 3, 2, 3
}; };
int i; int i;

View File

@ -206,8 +206,8 @@ static int FUNC(quantization_params)(CodedBitstreamContext *ctx, RWContext *rw,
static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw, static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw,
VP9RawFrameHeader *current) VP9RawFrameHeader *current)
{ {
static const int segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 }; static const uint8_t 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_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 };
int err, i, j; int err, i, j;

View File

@ -353,7 +353,7 @@ static av_always_inline int inv_recenter_nonneg(int v, int m)
// differential forward probability updates // differential forward probability updates
static int update_prob(VP56RangeCoder *c, int p) 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, 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, 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, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,