[x264-devel] commit: More accurate refcost for p8x8 CAVLC (Jason Garrett-Glaser )

git version control git at videolan.org
Sat Dec 13 01:10:38 CET 2008


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu Dec 11 17:31:52 2008 -0800| [ad2c84f76f9fbb4f360caeb87df824beab023bbf] | committer: Jason Garrett-Glaser 

More accurate refcost for p8x8 CAVLC
Slightly better quality, especially in non-RD mode, with CAVLC.

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

 encoder/analyse.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/encoder/analyse.c b/encoder/analyse.c
index 68c26df..8457c38 100644
--- a/encoder/analyse.c
+++ b/encoder/analyse.c
@@ -1176,6 +1176,10 @@ static void x264_mb_analyse_inter_p8x8_mixed_ref( x264_t *h, x264_mb_analysis_t
 
     a->l0.i_cost8x8 = a->l0.me8x8[0].cost + a->l0.me8x8[1].cost +
                       a->l0.me8x8[2].cost + a->l0.me8x8[3].cost;
+    /* P_8x8 ref0 has no ref cost */
+    if( !h->param.b_cabac && !(a->l0.me8x8[0].i_ref | a->l0.me8x8[1].i_ref |
+                               a->l0.me8x8[2].i_ref | a->l0.me8x8[3].i_ref) )
+        a->l0.i_cost8x8 -= REF_COST( 0, 0 ) * 4;
     h->mb.i_sub_partition[0] = h->mb.i_sub_partition[1] =
     h->mb.i_sub_partition[2] = h->mb.i_sub_partition[3] = D_L0_8x8;
 }
@@ -1183,7 +1187,7 @@ static void x264_mb_analyse_inter_p8x8_mixed_ref( x264_t *h, x264_mb_analysis_t
 static void x264_mb_analyse_inter_p8x8( x264_t *h, x264_mb_analysis_t *a )
 {
     const int i_ref = a->l0.me16x16.i_ref;
-    const int i_ref_cost = REF_COST( 0, i_ref );
+    const int i_ref_cost = h->param.b_cabac || i_ref ? REF_COST( 0, i_ref ) : 0;
     uint8_t  **p_fref = h->mb.pic.p_fref[0][i_ref];
     uint8_t  **p_fenc = h->mb.pic.p_fenc;
     int i_mvc;
@@ -1222,11 +1226,12 @@ static void x264_mb_analyse_inter_p8x8( x264_t *h, x264_mb_analysis_t *a )
         m->cost += a->i_lambda * i_sub_mb_p_cost_table[D_L0_8x8];
     }
 
+    a->l0.i_cost8x8 = a->l0.me8x8[0].cost + a->l0.me8x8[1].cost +
+                      a->l0.me8x8[2].cost + a->l0.me8x8[3].cost;
     /* theoretically this should include 4*ref_cost,
      * but 3 seems a better approximation of cabac. */
-    a->l0.i_cost8x8 = a->l0.me8x8[0].cost + a->l0.me8x8[1].cost +
-                      a->l0.me8x8[2].cost + a->l0.me8x8[3].cost -
-                      REF_COST( 0, a->l0.me16x16.i_ref );
+    if( h->param.b_cabac )
+        a->l0.i_cost8x8 -= i_ref_cost;
     h->mb.i_sub_partition[0] = h->mb.i_sub_partition[1] =
     h->mb.i_sub_partition[2] = h->mb.i_sub_partition[3] = D_L0_8x8;
 }



More information about the x264-devel mailing list