[FFmpeg-cvslog] r22773 - trunk/libavcodec/motion_est.c

Michael Niedermayer michaelni
Fri Apr 2 14:20:08 CEST 2010


On Fri, Apr 02, 2010 at 04:42:49AM -0700, Jason Garrett-Glaser wrote:
> On Fri, Apr 2, 2010 at 4:06 AM, michael <subversion at mplayerhq.hu> wrote:
> > Author: michael
> > Date: Fri Apr ?2 13:06:29 2010
> > New Revision: 22773
> >
> > Log:
> > Reduce the size of the bidir refine hashtable from 4096 to 256 and
> > change the hash function to something more sane and simple.
> > about 1/3 faster, no meassureable change in psnr or size and i gues
> > its even same md5 with my test file but i forgot testing that.
> 
> x264 uses a bitfield (one bit per slot) for [8][8][8] instead of
> [8][8][8][8], which should be enough to provide these gains without
> introducing costly multiplies.
> 
> Maybe try that instead?

isnt faster, patch below, if anyone is interrested

Index: libavcodec/motion_est.c
===================================================================
--- libavcodec/motion_est.c	(revision 22773)
+++ libavcodec/motion_est.c	(working copy)
@@ -1475,13 +1475,16 @@
     const int ymin= c->ymin<<shift;
     const int xmax= c->xmax<<shift;
     const int ymax= c->ymax<<shift;
-    uint8_t map[256];
+    uint8_t map[512];
 
     memset(map,0,sizeof(map));
-#define BIDIR_MAP(fx,fy,bx,by) \
-    map[((motion_fx+fx)+17*(motion_fy+fy)+63*(motion_bx+bx)+117*(motion_by+by))&255]
-    BIDIR_MAP(0,0,0,0) = 1;
 
+#define SET_BIDIR_MAP(fx,fy,bx,by) \
+     map[((motion_fx+fx)+8*(motion_fy+fy)+64*(motion_bx+bx))&511] |= 1<<((motion_by+by)&7);
+#define GET_BIDIR_MAP(fx,fy,bx,by) \
+    (map[((motion_fx+fx)+8*(motion_fy+fy)+64*(motion_bx+bx))&511] &( 1<<((motion_by+by)&7)))
+    SET_BIDIR_MAP(0,0,0,0);
+
     fbmin= check_bidir_mv(s, motion_fx, motion_fy,
                           motion_bx, motion_by,
                           pred_fx, pred_fy,
@@ -1491,10 +1494,10 @@
     if(s->avctx->bidir_refine){
         int score, end;
 #define CHECK_BIDIR(fx,fy,bx,by)\
-    if( !BIDIR_MAP(fx,fy,bx,by)\
+    if( !GET_BIDIR_MAP(fx,fy,bx,by)\
        &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
        &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
-        BIDIR_MAP(fx,fy,bx,by) = 1;\
+        SET_BIDIR_MAP(fx,fy,bx,by)\
         score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\
         if(score < fbmin){\
             fbmin= score;\


> 
> Also, I hereby LGPL the memzero_aligned_mmx and memzero_aligned_sse
> functions in x264 if you want to use those for faster zeroing of the
> hashtable.  They're utterly trivial though.

we have a clear_block() that could be used

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20100402/c6b10b78/attachment.pgp>



More information about the ffmpeg-cvslog mailing list