From 4b4f8eb89bfc033a1bc52684636c7f4f8c314345 Mon Sep 17 00:00:00 2001 From: Henrik Gramner Date: Mon, 10 May 2010 23:27:36 +0200 Subject: [PATCH] Shrink even more constant arrays --- common/arm/mc-c.c | 4 ++-- common/mc.c | 4 ++-- common/ppc/mc.c | 4 ++-- common/set.c | 10 +++++----- common/x86/mc-c.c | 4 ++-- encoder/encoder.c | 4 ++-- encoder/me.c | 2 +- encoder/set.c | 14 +++++--------- 8 files changed, 21 insertions(+), 25 deletions(-) diff --git a/common/arm/mc-c.c b/common/arm/mc-c.c index 0a7b734b..d294eff4 100644 --- a/common/arm/mc-c.c +++ b/common/arm/mc-c.c @@ -112,8 +112,8 @@ static void (* const x264_mc_copy_wtab_neon[5])( uint8_t *, int, uint8_t *, int, x264_mc_copy_w16_neon, }; -static const int hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; -static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; +static const uint8_t hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; +static const uint8_t hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; static void mc_luma_neon( uint8_t *dst, int i_dst_stride, uint8_t *src[4], int i_src_stride, diff --git a/common/mc.c b/common/mc.c index ada8bdc0..e0dc6599 100644 --- a/common/mc.c +++ b/common/mc.c @@ -203,8 +203,8 @@ static void hpel_filter( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *s } } -static const int hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; -static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; +static const uint8_t hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; +static const uint8_t hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; static void mc_luma( uint8_t *dst, int i_dst_stride, uint8_t *src[4], int i_src_stride, diff --git a/common/ppc/mc.c b/common/ppc/mc.c index 26b81f8e..83c60b10 100644 --- a/common/ppc/mc.c +++ b/common/ppc/mc.c @@ -37,8 +37,8 @@ typedef void (*pf_mc_t)( uint8_t *src, int i_src, uint8_t *dst, int i_dst, int i_height ); -static const int hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; -static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; +static const uint8_t hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; +static const uint8_t hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; static inline int x264_tapfilter( uint8_t *pix, int i_pix_next ) diff --git a/common/set.c b/common/set.c index 50d42137..16cff8ef 100644 --- a/common/set.c +++ b/common/set.c @@ -23,7 +23,7 @@ #define SHIFT(x,s) ((s)<=0 ? (x)<<-(s) : ((x)+(1<<((s)-1)))>>(s)) #define DIV(n,d) (((n) + ((d)>>1)) / (d)) -static const int dequant4_scale[6][3] = +static const uint8_t dequant4_scale[6][3] = { { 10, 13, 16 }, { 11, 14, 18 }, @@ -32,7 +32,7 @@ static const int dequant4_scale[6][3] = { 16, 20, 25 }, { 18, 23, 29 } }; -static const int quant4_scale[6][3] = +static const uint16_t quant4_scale[6][3] = { { 13107, 8066, 5243 }, { 11916, 7490, 4660 }, @@ -42,11 +42,11 @@ static const int quant4_scale[6][3] = { 7282, 4559, 2893 }, }; -static const int quant8_scan[16] = +static const uint8_t quant8_scan[16] = { 0,3,4,3, 3,1,5,1, 4,5,2,5, 3,1,5,1 }; -static const int dequant8_scale[6][6] = +static const uint8_t dequant8_scale[6][6] = { { 20, 18, 32, 19, 25, 24 }, { 22, 19, 35, 21, 28, 26 }, @@ -55,7 +55,7 @@ static const int dequant8_scale[6][6] = { 32, 28, 51, 30, 40, 38 }, { 36, 32, 58, 34, 46, 43 }, }; -static const int quant8_scale[6][6] = +static const uint16_t quant8_scale[6][6] = { { 13107, 11428, 20972, 12222, 16777, 15481 }, { 11916, 10826, 19174, 11058, 14980, 14290 }, diff --git a/common/x86/mc-c.c b/common/x86/mc-c.c index 6d386f6f..f641cffb 100644 --- a/common/x86/mc-c.c +++ b/common/x86/mc-c.c @@ -228,8 +228,8 @@ static void x264_weight_cache_ssse3( x264_t *h, x264_weight_t *w ) } } -static const int hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; -static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; +static const uint8_t hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; +static const uint8_t hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; #define MC_LUMA(name,instr1,instr2)\ static void mc_luma_##name( uint8_t *dst, int i_dst_stride,\ diff --git a/encoder/encoder.c b/encoder/encoder.c index b4dbfadd..a71dce21 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -2816,8 +2816,8 @@ void x264_encoder_close ( x264_t *h ) /* Slices used and PSNR */ for( int i = 0; i < 5; i++ ) { - static const int slice_order[] = { SLICE_TYPE_I, SLICE_TYPE_SI, SLICE_TYPE_P, SLICE_TYPE_SP, SLICE_TYPE_B }; - static const char *slice_name[] = { "P", "B", "I", "SP", "SI" }; + static const uint8_t slice_order[] = { SLICE_TYPE_I, SLICE_TYPE_SI, SLICE_TYPE_P, SLICE_TYPE_SP, SLICE_TYPE_B }; + static const char * const slice_name[] = { "P", "B", "I", "SP", "SI" }; int i_slice = slice_order[i]; if( h->stat.i_frame_count[i_slice] > 0 ) diff --git a/encoder/me.c b/encoder/me.c index 5e113f0a..a35da532 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -484,7 +484,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int i = 1; do { - static const int hex4[16][2] = { + static const int8_t hex4[16][2] = { { 0,-4}, { 0, 4}, {-2,-3}, { 2,-3}, {-4,-2}, { 4,-2}, {-4,-1}, { 4,-1}, {-4, 0}, { 4, 0}, {-4, 1}, { 4, 1}, diff --git a/encoder/set.c b/encoder/set.c index e3a071c3..ce52a4b0 100644 --- a/encoder/set.c +++ b/encoder/set.c @@ -315,26 +315,22 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps ) if( sps->vui.b_aspect_ratio_info_present ) { int i; - static const struct { int w, h; int sar; } sar[] = + static const struct { uint8_t w, h, sar; } sar[] = { { 1, 1, 1 }, { 12, 11, 2 }, { 10, 11, 3 }, { 16, 11, 4 }, { 40, 33, 5 }, { 24, 11, 6 }, { 20, 11, 7 }, { 32, 11, 8 }, { 80, 33, 9 }, { 18, 11, 10}, { 15, 11, 11}, { 64, 33, 12}, - { 160,99, 13}, { 0, 0, -1 } + { 160,99, 13}, { 0, 0, 255 } }; - for( i = 0; sar[i].sar != -1; i++ ) + for( i = 0; sar[i].sar != 255; i++ ) { if( sar[i].w == sps->vui.i_sar_width && sar[i].h == sps->vui.i_sar_height ) break; } - if( sar[i].sar != -1 ) + bs_write( s, 8, sar[i].sar ); + if( sar[i].sar == 255 ) /* aspect_ratio_idc (extended) */ { - bs_write( s, 8, sar[i].sar ); - } - else - { - bs_write( s, 8, 255); /* aspect_ratio_idc (extended) */ bs_write( s, 16, sps->vui.i_sar_width ); bs_write( s, 16, sps->vui.i_sar_height ); } -- 2.47.3