]> git.sesse.net Git - x264/commitdiff
compute chroma_qp only once per mb
authorLoren Merritt <pengvado@videolan.org>
Sun, 29 Oct 2006 05:48:57 +0000 (05:48 +0000)
committerLoren Merritt <pengvado@videolan.org>
Sun, 29 Oct 2006 05:48:57 +0000 (05:48 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@596 df754926-b1dd-0310-bc7b-ec298dee348c

common/common.h
encoder/analyse.c
encoder/macroblock.c
encoder/rdo.c

index 8c0cf1379b4f482dc32ac6d2e9e354d7af3e5483..c823d3da695a2679db2525ba0c5c08ef6e840ea0 100644 (file)
@@ -506,6 +506,7 @@ struct x264_t
 
         /* */
         int     i_qp;       /* current qp */
+        int     i_chroma_qp;
         int     i_last_qp;  /* last qp */
         int     i_last_dqp; /* last delta qp */
         int     b_variable_qp; /* whether qp is allowed to vary per macroblock */
index b5d9ea01a38f73b261d826e72881eec8c6fa47c4..b3ded41a268164f321edaf03716f1053daffd468 100644 (file)
@@ -194,6 +194,7 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
 
     /* conduct the analysis using this lamda and QP */
     a->i_qp = h->mb.i_qp = i_qp;
+    h->mb.i_chroma_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )];
     a->i_lambda = i_qp0_cost_table[i_qp];
     a->i_lambda2 = i_qp0_cost2_table[i_qp];
     a->b_mbrd = h->param.analyse.i_subpel_refine >= 6 &&
@@ -864,8 +865,7 @@ static void x264_intra_rd_refine( x264_t *h, x264_mb_analysis_t *a )
 
         if( i_max > 0 )
         {
-            int i_qp_chroma = i_chroma_qp_table[x264_clip3( h->mb.i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )];
-            int i_chroma_lambda = i_qp0_cost2_table[i_qp_chroma];
+            int i_chroma_lambda = i_qp0_cost2_table[h->mb.i_chroma_qp];
             /* the previous thing encoded was x264_intra_rd(), so the pixels and
              * coefs for the current chroma mode are still around, so we only
              * have to recount the bits. */
index f970983a06cbe246c2a46369a461afba4c311c53..0b06a7f7dfadd791265af14444bd460c42f15c90 100644 (file)
@@ -571,7 +571,6 @@ void x264_macroblock_encode( x264_t *h )
     }
 
     /* encode chroma */
-    i_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )];
     if( IS_INTRA( h->mb.i_type ) )
     {
         const int i_mode = h->mb.i_chroma_pred_mode;
@@ -580,7 +579,7 @@ void x264_macroblock_encode( x264_t *h )
     }
 
     /* encode the 8x8 blocks */
-    x264_mb_encode_8x8_chroma( h, !IS_INTRA( h->mb.i_type ), i_qp );
+    x264_mb_encode_8x8_chroma( h, !IS_INTRA( h->mb.i_type ), h->mb.i_chroma_qp );
 
     /* coded block pattern and non_zero_count */
     h->mb.i_cbp_luma = 0x00;
@@ -707,7 +706,7 @@ int x264_macroblock_probe_skip( x264_t *h, int b_bidir )
     }
 
     /* encode chroma */
-    i_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )];
+    i_qp = h->mb.i_chroma_qp;
 
     for( ch = 0; ch < 2; ch++ )
     {
@@ -875,7 +874,7 @@ void x264_macroblock_encode_p8x8( x264_t *h, int i8 )
         }
     }
 
-    i_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )];
+    i_qp = h->mb.i_chroma_qp;
 
     for( ch = 0; ch < 2; ch++ )
     {
index 36326dac37a01cc18245f0a5f1fb9131f1c4ccc8..3c827cb7da9d1a0925f9c559aa0920377bf5f9e3 100644 (file)
@@ -183,7 +183,7 @@ int x264_rd_cost_i8x8_chroma( x264_t *h, int i_lambda2, int i_mode, int b_dct )
     int i_ssd, i_bits;
 
     if( b_dct )
-        x264_mb_encode_8x8_chroma( h, 0, h->mb.i_qp );
+        x264_mb_encode_8x8_chroma( h, 0, h->mb.i_chroma_qp );
     i_ssd = ssd_plane( h, PIXEL_8x8, 1, 0, 0 ) +
             ssd_plane( h, PIXEL_8x8, 2, 0, 0 );