[x264-devel] commit: Tweaks and cosmetics in me.c (Jason Garrett-Glaser )
git version control
git at videolan.org
Wed Jun 11 02:42:41 CEST 2008
x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Tue Jun 10 18:34:46 2008 -0600| [a95ecfdf6b5bf7b9ecb23901f68a3f6f89fa55b8]
Tweaks and cosmetics in me.c
Use write-combining for predictor checking and other tweaks.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=a95ecfdf6b5bf7b9ecb23901f68a3f6f89fa55b8
---
common/macroblock.c | 3 +++
encoder/me.c | 32 ++++++++++++++++++--------------
2 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/common/macroblock.c b/common/macroblock.c
index d640664..182b5e0 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -547,6 +547,9 @@ void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t mvc[
#undef SET_TMVP
}
+ if(i == 0)
+ *(uint32_t*)mvc[i] = 0;
+
*i_mvc = i;
}
diff --git a/encoder/me.c b/encoder/me.c
index 81f2f00..276f543 100644
--- a/encoder/me.c
+++ b/encoder/me.c
@@ -163,7 +163,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
uint8_t *p_fref = m->p_fref[0];
DECLARE_ALIGNED_16( uint8_t pix[16*16] );
- int i, j;
+ int i = 0, j;
int dir;
int costs[6];
@@ -187,17 +187,17 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
if( h->mb.i_subpel_refine >= 3 )
{
COST_MV_HPEL( bmx, bmy );
- for( i = 0; i < i_mvc; i++ )
+ uint32_t bmv = pack16to32_mask(bmx,bmy);
+ do
{
- int mx = mvc[i][0];
- int my = mvc[i][1];
- if( (mx | my) && ((mx-bmx) | (my-bmy)) )
+ if( *(uint32_t*)mvc[i] && (bmv - *(uint32_t*)mvc[i]) )
{
- mx = x264_clip3( mx, mv_x_min*4, mv_x_max*4 );
- my = x264_clip3( my, mv_y_min*4, mv_y_max*4 );
+ int mx = x264_clip3( mvc[i][0], mv_x_min*4, mv_x_max*4 );
+ int my = x264_clip3( mvc[i][1], mv_y_min*4, mv_y_max*4 );
COST_MV_HPEL( mx, my );
}
- }
+ i++;
+ } while( i < i_mvc );
bmx = ( bpred_mx + 2 ) >> 2;
bmy = ( bpred_my + 2 ) >> 2;
COST_MV( bmx, bmy );
@@ -206,10 +206,14 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
{
/* check the MVP */
COST_MV( pmx, pmy );
- /* I don't know why this helps */
- bcost -= BITS_MVD(bmx,bmy);
-
- for( i = 0; i < i_mvc; i++ )
+ /* Because we are rounding the predicted motion vector to fullpel, there will be
+ * an extra MV cost in 15 out of 16 cases. However, when the predicted MV is
+ * chosen as the best predictor, it is often the case that the subpel search will
+ * result in a vector at or next to the predicted motion vector. Therefore, it is
+ * sensible to remove the cost of the MV from the rounded MVP to avoid unfairly
+ * biasing against use of the predicted motion vector. */
+ bcost -= BITS_MVD( pmx, pmy );
+ do
{
int mx = (mvc[i][0] + 2) >> 2;
int my = (mvc[i][1] + 2) >> 2;
@@ -219,9 +223,9 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
my = x264_clip3( my, mv_y_min, mv_y_max );
COST_MV( mx, my );
}
- }
+ i++;
+ } while( i < i_mvc );
}
-
COST_MV( 0, 0 );
switch( h->mb.i_me_method )
More information about the x264-devel
mailing list