[x264-devel] commit: Fix two warnings + some minor optimizations (Jason Garrett-Glaser )

git version control git at videolan.org
Sun Oct 25 20:06:08 CET 2009


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu Oct 22 22:38:32 2009 -0700| [b89ca0413c5a7114111ba0c76bcd7e52eb0ede93] | committer: Jason Garrett-Glaser 

Fix two warnings + some minor optimizations

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

 common/common.h     |    4 ++--
 common/macroblock.c |   12 ++++++------
 encoder/analyse.c   |   16 ++++++++--------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/common/common.h b/common/common.h
index 12e1c26..ec61e14 100644
--- a/common/common.h
+++ b/common/common.h
@@ -619,8 +619,8 @@ struct x264_t
         int16_t dist_scale_factor[16][2];
         int16_t bipred_weight[32][4];
         /* maps fref1[0]'s ref indices into the current list0 */
-        int8_t  map_col_to_list0_buf[2]; // for negative indices
-        int8_t  map_col_to_list0[16];
+#define map_col_to_list0(col) h->mb.map_col_to_list0[col+2]
+        int8_t  map_col_to_list0[18];
     } mb;
 
     /* rate control encoding only */
diff --git a/common/macroblock.c b/common/macroblock.c
index ec26ff0..b6d9b31 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -173,7 +173,7 @@ static int x264_mb_predict_mv_direct16x16_temporal( x264_t *h )
     int i_mb_4x4 = 16 * h->mb.i_mb_stride * h->mb.i_mb_y + 4 * h->mb.i_mb_x;
     int i_mb_8x8 =  4 * h->mb.i_mb_stride * h->mb.i_mb_y + 2 * h->mb.i_mb_x;
     int i8;
-    const int type_col = h->fref1[0]->mb_type[ h->mb.i_mb_xy ];
+    const int type_col = h->fref1[0]->mb_type[h->mb.i_mb_xy];
 
     x264_macroblock_cache_ref( h, 0, 0, 4, 4, 1, 0 );
 
@@ -190,7 +190,7 @@ static int x264_mb_predict_mv_direct16x16_temporal( x264_t *h )
         const int x8 = i8%2;
         const int y8 = i8/2;
         const int i_part_8x8 = i_mb_8x8 + x8 + y8 * h->mb.i_b8_stride;
-        const int i_ref = h->mb.map_col_to_list0[ h->fref1[0]->ref[0][ i_part_8x8 ] ];
+        const int i_ref = map_col_to_list0(h->fref1[0]->ref[0][i_part_8x8]);
 
         if( i_ref >= 0 )
         {
@@ -793,16 +793,16 @@ void x264_macroblock_slice_init( x264_t *h )
         for( i = 0; i < h->i_ref1; i++ )
             h->fdec->ref_poc[1][i] = h->fref1[i]->i_poc;
 
-        h->mb.map_col_to_list0[-1] = -1;
-        h->mb.map_col_to_list0[-2] = -2;
+        map_col_to_list0(-1) = -1;
+        map_col_to_list0(-2) = -2;
         for( i = 0; i < h->fref1[0]->i_ref[0]; i++ )
         {
             int poc = h->fref1[0]->ref_poc[0][i];
-            h->mb.map_col_to_list0[i] = -2;
+            map_col_to_list0(i) = -2;
             for( j = 0; j < h->i_ref0; j++ )
                 if( h->fref0[j]->i_poc == poc )
                 {
-                    h->mb.map_col_to_list0[i] = j;
+                    map_col_to_list0(i) = j;
                     break;
                 }
         }
diff --git a/encoder/analyse.c b/encoder/analyse.c
index 559e777..c2a4e1b 100644
--- a/encoder/analyse.c
+++ b/encoder/analyse.c
@@ -819,8 +819,9 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_
                 else
                     h->predict_8x8[i_mode]( p_dst_by, edge );
 
-                i_satd = sa8d( p_dst_by, FDEC_STRIDE, p_src_by, FENC_STRIDE )
-                       + a->i_lambda * (i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) ? 1 : 4);
+                i_satd = sa8d( p_dst_by, FDEC_STRIDE, p_src_by, FENC_STRIDE ) + a->i_lambda * 4;
+                if( i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) )
+                    i_satd -= a->i_lambda * 3;
 
                 COPY2_IF_LT( i_best, i_satd, a->i_predict8x8[idx], i_mode );
                 a->i_satd_i8x8_dir[i_mode][idx] = i_satd;
@@ -895,8 +896,7 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_
                 h->pixf.intra_mbcmp_x3_4x4( p_src_by, p_dst_by, satd );
                 satd[i_pred_mode] -= 3 * a->i_lambda;
                 for( i=2; i>=0; i-- )
-                    COPY2_IF_LT( i_best, satd[i] + 4 * a->i_lambda,
-                                 a->i_predict4x4[idx], i );
+                    COPY2_IF_LT( i_best, satd[i], a->i_predict4x4[idx], i );
                 i = 3;
             }
             else
@@ -911,13 +911,13 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_
                 else
                     h->predict_4x4[i_mode]( p_dst_by );
 
-                i_satd = h->pixf.mbcmp[PIXEL_4x4]( p_dst_by, FDEC_STRIDE,
-                                                   p_src_by, FENC_STRIDE )
-                       + a->i_lambda * (i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) ? 1 : 4);
+                i_satd = h->pixf.mbcmp[PIXEL_4x4]( p_dst_by, FDEC_STRIDE, p_src_by, FENC_STRIDE );
+                if( i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) )
+                    i_satd -= a->i_lambda * 3;
 
                 COPY2_IF_LT( i_best, i_satd, a->i_predict4x4[idx], i_mode );
             }
-            i_cost += i_best;
+            i_cost += i_best + 4 * a->i_lambda;
 
             if( i_cost > i_satd_thresh || idx == 15 )
                 break;



More information about the x264-devel mailing list