[x264-devel] commit: Split up analyse_init (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Sun Mar 28 04:44:30 CEST 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Mon Mar 15 00:01:57 2010 -0700| [ae92e7f589f5832078cf6ecfa510d41b1f6b3301] | committer: Jason Garrett-Glaser 

Split up analyse_init
Save some time by avoiding some unnecessary inits and moving other parts to per-thread init.

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

 common/macroblock.c |   10 ++++++++++
 encoder/analyse.c   |   42 +++++++++++++-----------------------------
 2 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/common/macroblock.c b/common/macroblock.c
index ec43caf..d2e92db 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -860,6 +860,16 @@ void x264_macroblock_slice_init( x264_t *h )
 
 void x264_macroblock_thread_init( x264_t *h )
 {
+    h->mb.i_me_method = h->param.analyse.i_me_method;
+    h->mb.i_subpel_refine = h->param.analyse.i_subpel_refine;
+    if( h->sh.i_type == SLICE_TYPE_B && (h->mb.i_subpel_refine == 6 || h->mb.i_subpel_refine == 8) )
+        h->mb.i_subpel_refine--;
+    h->mb.b_chroma_me = h->param.analyse.b_chroma_me && h->sh.i_type == SLICE_TYPE_P
+                        && h->mb.i_subpel_refine >= 5;
+    h->mb.b_dct_decimate = h->sh.i_type == SLICE_TYPE_B ||
+                          (h->param.analyse.b_dct_decimate && h->sh.i_type != SLICE_TYPE_I);
+
+
     /* fdec:      fenc:
      * yyyyyyy
      * yYYYY      YYYY
diff --git a/encoder/analyse.c b/encoder/analyse.c
index eef7b23..03a2d5c 100644
--- a/encoder/analyse.c
+++ b/encoder/analyse.c
@@ -345,7 +345,6 @@ static void x264_mb_analyse_init_qp( x264_t *h, x264_mb_analysis_t *a, int i_qp
     h->mb.i_psy_rd_lambda = a->i_lambda;
     /* Adjusting chroma lambda based on QP offset hurts PSNR but improves visual quality. */
     h->mb.i_chroma_lambda2_offset = h->param.analyse.b_psy ? x264_chroma_lambda2_offset_tab[h->mb.i_qp-h->mb.i_chroma_qp+12] : 256;
-
 }
 
 static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
@@ -359,15 +358,6 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
 
     x264_mb_analyse_init_qp( h, a, i_qp );
 
-    h->mb.i_me_method = h->param.analyse.i_me_method;
-    h->mb.i_subpel_refine = h->param.analyse.i_subpel_refine;
-    if( h->sh.i_type == SLICE_TYPE_B && (h->mb.i_subpel_refine == 6 || h->mb.i_subpel_refine == 8) )
-        h->mb.i_subpel_refine--;
-    h->mb.b_chroma_me = h->param.analyse.b_chroma_me && h->sh.i_type == SLICE_TYPE_P
-                        && h->mb.i_subpel_refine >= 5;
-    h->mb.b_dct_decimate = h->sh.i_type == SLICE_TYPE_B ||
-                          (h->param.analyse.b_dct_decimate && h->sh.i_type != SLICE_TYPE_I);
-
     h->mb.b_transform_8x8 = 0;
     h->mb.b_noise_reduction = 0;
 
@@ -452,31 +442,18 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
 
         a->l0.me16x16.cost =
         a->l0.i_rd16x16    =
-        a->l0.i_cost8x8    = COST_MAX;
-
-        for( i = 0; i < 4; i++ )
-        {
-            a->l0.i_cost4x4[i] =
-            a->l0.i_cost8x4[i] =
-            a->l0.i_cost4x8[i] = COST_MAX;
-        }
-
+        a->l0.i_cost8x8    =
         a->l0.i_cost16x8   =
         a->l0.i_cost8x16   = COST_MAX;
         if( h->sh.i_type == SLICE_TYPE_B )
         {
             a->l1.me16x16.cost =
             a->l1.i_rd16x16    =
-            a->l1.i_cost8x8    = COST_MAX;
-
-            for( i = 0; i < 4; i++ )
-            {
-                a->l1.i_cost4x4[i] =
-                a->l1.i_cost8x4[i] =
-                a->l1.i_cost4x8[i] =
-                a->i_cost8x8direct[i] = COST_MAX;
-            }
-
+            a->l1.i_cost8x8    =
+            a->i_cost8x8direct[0] =
+            a->i_cost8x8direct[1] =
+            a->i_cost8x8direct[2] =
+            a->i_cost8x8direct[3] =
             a->l1.i_cost16x8   =
             a->l1.i_cost8x16   =
             a->i_rd16x16bi     =
@@ -490,6 +467,13 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
             a->i_cost16x8bi    =
             a->i_cost8x16bi    = COST_MAX;
         }
+        else if( h->param.analyse.inter & X264_ANALYSE_PSUB8x8 )
+            for( i = 0; i < 4; i++ )
+            {
+                a->l0.i_cost4x4[i] =
+                a->l0.i_cost8x4[i] =
+                a->l0.i_cost4x8[i] = COST_MAX;
+            }
 
         /* Fast intra decision */
         if( h->mb.i_mb_xy - h->sh.i_first_mb > 4 )



More information about the x264-devel mailing list