From c0b1b1af1cc30fe9ae7ad46e5c1ccd7640ceb889 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sat, 1 Dec 2007 02:58:34 +0000 Subject: [PATCH] avoid a division in umh. patch by Dark Shikari. git-svn-id: svn://svn.videolan.org/x264/trunk@703 df754926-b1dd-0310-bc7b-ec298dee348c --- encoder/me.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/encoder/me.c b/encoder/me.c index 9adcc6cb..59128147 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -355,6 +355,7 @@ me_hex2: }; int mvd; int sad_ctx, mvd_ctx; + int denom = 1; if( i_mvc == 1 ) { @@ -371,26 +372,25 @@ me_hex2: /* calculate the degree of agreement between predictors. */ /* in 16x16, mvc includes all the neighbors used to make mvp, * so don't count mvp separately. */ - int i_denom = i_mvc - 1; + denom = i_mvc - 1; mvd = 0; if( i_pixel != PIXEL_16x16 ) { mvd = abs( m->mvp[0] - mvc[0][0] ) + abs( m->mvp[1] - mvc[0][1] ); - i_denom++; + denom++; } for( i = 0; i < i_mvc-1; i++ ) mvd += abs( mvc[i][0] - mvc[i+1][0] ) + abs( mvc[i][1] - mvc[i+1][1] ); - mvd /= i_denom; //FIXME idiv } sad_ctx = SAD_THRESH(1000) ? 0 : SAD_THRESH(2000) ? 1 : SAD_THRESH(4000) ? 2 : 3; - mvd_ctx = mvd < 10 ? 0 - : mvd < 20 ? 1 - : mvd < 40 ? 2 : 3; + mvd_ctx = mvd < 10*denom ? 0 + : mvd < 20*denom ? 1 + : mvd < 40*denom ? 2 : 3; i_me_range = i_me_range * range_mul[mvd_ctx][sad_ctx] / 4; } -- 2.47.3