[x264-devel] commit: Add faster mv0 special case for macroblock-tree ( Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Sun Apr 11 06:50:32 CEST 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Fri Apr  9 18:13:22 2010 -0700| [825e3a9c1d185328f426340d118cb7359d1aca4b] | committer: Jason Garrett-Glaser 

Add faster mv0 special case for macroblock-tree
Improves performance on low-motion video.

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

 encoder/slicetype.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index 7377a6d..120a38a 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -686,12 +686,24 @@ static void x264_macroblock_tree_propagate( x264_t *h, x264_frame_t **frames, in
                 for( int list = 0; list < 2; list++ )
                     if( (lists_used >> list)&1 )
                     {
+#define CLIP_ADD(s,x) (s) = X264_MIN((s)+(x),(1<<16)-1)
+                        int listamount = propagate_amount;
+                        /* Apply bipred weighting. */
+                        if( lists_used == 3 )
+                            listamount = (listamount * bipred_weights[list] + 32) >> 6;
+
+                        /* Early termination for simple case of mv0. */
+                        if( !M32( mvs[list][mb_index] ) )
+                        {
+                            CLIP_ADD( ref_costs[list][mb_index], listamount );
+                            continue;
+                        }
+
                         int x = mvs[list][mb_index][0];
                         int y = mvs[list][mb_index][1];
-                        int listamount = propagate_amount;
                         int mbx = (x>>5)+h->mb.i_mb_x;
                         int mby = (y>>5)+h->mb.i_mb_y;
-                        int idx0 = mbx + mby*h->mb.i_mb_stride;
+                        int idx0 = mbx + mby * h->mb.i_mb_stride;
                         int idx1 = idx0 + 1;
                         int idx2 = idx0 + h->mb.i_mb_stride;
                         int idx3 = idx0 + h->mb.i_mb_stride + 1;
@@ -702,12 +714,6 @@ static void x264_macroblock_tree_propagate( x264_t *h, x264_frame_t **frames, in
                         int idx2weight = y*(32-x);
                         int idx3weight = y*x;
 
-                        /* Apply bipred weighting. */
-                        if( lists_used == 3 )
-                            listamount = (listamount * bipred_weights[list] + 32) >> 6;
-
-#define CLIP_ADD(s,x) (s) = X264_MIN((s)+(x),(1<<16)-1)
-
                         /* We could just clip the MVs, but pixels that lie outside the frame probably shouldn't
                          * be counted. */
                         if( mbx < h->sps->i_mb_width-1 && mby < h->sps->i_mb_height-1 && mbx >= 0 && mby >= 0 )



More information about the x264-devel mailing list