[x264-devel] commit: Shrink some more constant arrays (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Thu May 6 07:49:21 CEST 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Fri Apr 30 13:45:50 2010 -0700| [181fc45d360ff8d586259f461fe5a21c4c37aefb] | committer: Jason Garrett-Glaser 

Shrink some more constant arrays

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=181fc45d360ff8d586259f461fe5a21c4c37aefb
---

 encoder/cabac.c |    6 +++---
 encoder/cavlc.c |    4 ++--
 encoder/me.c    |   12 ++++++------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/encoder/cabac.c b/encoder/cabac.c
index 82ced42..1086447 100644
--- a/encoder/cabac.c
+++ b/encoder/cabac.c
@@ -539,16 +539,16 @@ static const uint8_t last_coeff_flag_offset_8x8[63] = {
 // node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
 //           4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
 /* map node ctx => cabac ctx for level=1 */
-static const int coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
+static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
 /* map node ctx => cabac ctx for level>1 */
-static const int coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
+static const uint8_t coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
 static const uint8_t coeff_abs_level_transition[2][8] = {
 /* update node ctx after coding a level=1 */
     { 1, 2, 3, 3, 4, 5, 6, 7 },
 /* update node ctx after coding a level>1 */
     { 4, 4, 4, 4, 5, 6, 7, 7 }
 };
-static const int count_cat_m1[5] = {15, 14, 15, 3, 14};
+static const uint8_t count_cat_m1[5] = {15, 14, 15, 3, 14};
 
 #if !RDO_SKIP_BS
 static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBlockCat, int16_t *l )
diff --git a/encoder/cavlc.c b/encoder/cavlc.c
index a48c6f8..4b7d5dc 100644
--- a/encoder/cavlc.c
+++ b/encoder/cavlc.c
@@ -117,7 +117,7 @@ static int block_residual_write_cavlc( x264_t *h, int i_ctxBlockCat, int16_t *l,
 {
     bs_t *s = &h->out.bs;
     static const uint8_t ctz_index[8] = {3,0,1,0,2,0,1,0};
-    static const int count_cat[5] = {16, 15, 16, 4, 15};
+    static const uint8_t count_cat[5] = {16, 15, 16, 4, 15};
     x264_run_level_t runlevel;
     int i_trailing, i_total_zero, i_suffix_length;
     int i_total = 0;
@@ -172,7 +172,7 @@ static int block_residual_write_cavlc( x264_t *h, int i_ctxBlockCat, int16_t *l,
         }
     }
 
-    if( i_total < count_cat[i_ctxBlockCat] )
+    if( (uint8_t)i_total < count_cat[i_ctxBlockCat] )
     {
         if( i_ctxBlockCat == DCT_CHROMA_DC )
             bs_write_vlc( s, x264_total_zeros_dc[i_total-1][i_total_zero] );
diff --git a/encoder/me.c b/encoder/me.c
index 93f48ba..d7b2928 100644
--- a/encoder/me.c
+++ b/encoder/me.c
@@ -48,8 +48,8 @@ static const uint8_t subpel_iterations[][4] =
 /* (x-1)%6 */
 static const uint8_t mod6m1[8] = {5,0,1,2,3,4,5,0};
 /* radius 2 hexagon. repeated entries are to avoid having to compute mod6 every time. */
-static const int hex2[8][2] = {{-1,-2}, {-2,0}, {-1,2}, {1,2}, {2,0}, {1,-2}, {-1,-2}, {-2,0}};
-static const int square1[9][2] = {{0,0}, {0,-1}, {0,1}, {-1,0}, {1,0}, {-1,-1}, {-1,1}, {1,-1}, {1,1}};
+static const int8_t hex2[8][2] = {{-1,-2}, {-2,0}, {-1,2}, {1,2}, {2,0}, {1,-2}, {-1,-2}, {-2,0}};
+static const int8_t square1[9][2] = {{0,0}, {0,-1}, {0,1}, {-1,0}, {1,0}, {-1,-1}, {-1,1}, {1,-1}, {1,1}};
 
 static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_iters, int *p_halfpel_thresh, int b_refine_qpel );
 
@@ -377,7 +377,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
             /* Uneven-cross Multi-Hexagon-grid Search
              * as in JM, except with different early termination */
 
-            static const int x264_pixel_size_shift[7] = { 0, 1, 1, 2, 3, 3, 4 };
+            static const uint8_t x264_pixel_size_shift[7] = { 0, 1, 1, 2, 3, 3, 4 };
 
             int ucost1, ucost2;
             int cross_start = 1;
@@ -424,7 +424,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
                 /* range multipliers based on casual inspection of some statistics of
                  * average distance between current predictor and final mv found by ESA.
                  * these have not been tuned much by actual encoding. */
-                static const int range_mul[4][4] =
+                static const uint8_t range_mul[4][4] =
                 {
                     { 3, 3, 4, 4 },
                     { 3, 4, 4, 4 },
@@ -468,7 +468,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
                         : mvd < 20*denom ? 1
                         : mvd < 40*denom ? 2 : 3;
 
-                i_me_range = i_me_range * range_mul[mvd_ctx][sad_ctx] / 4;
+                i_me_range = i_me_range * range_mul[mvd_ctx][sad_ctx] >> 2;
             }
 
             /* FIXME if the above DIA2/OCT2/CROSS found a new mv, it has not updated omx/omy.
@@ -658,7 +658,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
                     bsad += ycost;
                 }
 
-                limit = i_me_range / 2;
+                limit = i_me_range >> 1;
                 sad_thresh = bsad*sad_thresh>>3;
                 while( nmvsad > limit*2 && sad_thresh > bsad )
                 {



More information about the x264-devel mailing list