]> granicus.if.org Git - libx264/commitdiff
less 64bit math: 12% faster trellis
authorLoren Merritt <pengvado@videolan.org>
Wed, 4 Jan 2006 03:43:15 +0000 (03:43 +0000)
committerLoren Merritt <pengvado@videolan.org>
Wed, 4 Jan 2006 03:43:15 +0000 (03:43 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@395 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/rdo.c

index c596271eebec772c1bdd13af1d933f07260cf4d8..f74d539c7966ef30b652a22fdcaa0e95d820391b 100644 (file)
@@ -295,9 +295,8 @@ static void quant_trellis_cabac( x264_t *h, int16_t *dct,
         // that are better left coded, especially at QP > 40.
         for( abs_level = q; abs_level >= q-1; abs_level-- )
         {
-            int u = (unquant_mf[zigzag[i]] * abs_level + 128) >> 8;
-            int64_t d = i_coef - u;
-            uint64_t ssd = d*d * coef_weight[i];
+            int d = i_coef - ((unquant_mf[zigzag[i]] * abs_level + 128) >> 8);
+            uint64_t ssd = (int64_t)d*d * coef_weight[i];
 
             for( j = 0; j < 8; j++ )
             {
@@ -309,7 +308,7 @@ static void quant_trellis_cabac( x264_t *h, int16_t *dct,
                 /* code the proposed level, and count how much entropy it would take */
                 if( abs_level || node_ctx )
                 {
-                    uint64_t f8_bits = cost_sig[ abs_level != 0 ];
+                    unsigned f8_bits = cost_sig[ abs_level != 0 ];
                     if( abs_level )
                     {
                         const int i_prefix = X264_MIN( abs_level - 1, 14 );
@@ -330,7 +329,7 @@ static void quant_trellis_cabac( x264_t *h, int16_t *dct,
                             node_ctx = coeff_abs_level_transition[0][node_ctx];
                         }
                     }
-                    n.score += f8_bits * i_lambda2 >> ( CABAC_SIZE_BITS - LAMBDA_BITS );
+                    n.score += (uint64_t)f8_bits * i_lambda2 >> ( CABAC_SIZE_BITS - LAMBDA_BITS );
                 }
 
                 n.score += ssd;