diff -r -u x264-original/common/common.c x264-4part/common/common.c --- x264-original/common/common.c 2008-07-23 20:00:38.000000000 -0700 +++ x264-4part/common/common.c 2008-07-29 00:00:32.000000000 -0700 @@ -141,6 +141,10 @@ param->b_repeat_headers = 1; param->b_aud = 0; + + param->athresh = 75; + param->bthresh = 50; + param->cthresh = 25; } static int parse_enum( const char *arg, const char * const *names, int *dst ) @@ -554,6 +558,12 @@ p->b_repeat_headers = !atobool(value); OPT("repeat-headers") p->b_repeat_headers = atobool(value); + OPT("a-thresh") + p->athresh = atoi(value); + OPT("b-thresh") + p->bthresh = atoi(value); + OPT("c-thresh") + p->cthresh = atoi(value); else return X264_PARAM_BAD_NAME; #undef OPT diff -r -u x264-original/config.h x264-4part/config.h --- x264-original/config.h 2008-07-26 10:11:41.000000000 -0700 +++ x264-4part/config.h 2008-07-29 02:45:02.000000000 -0700 @@ -1,4 +1,4 @@ #define fseek fseeko #define ftell ftello -#define X264_VERSION " r915 14046ae" -#define X264_POINTVER "0.60.915 14046ae" +#define X264_VERSION " r915M 14046ae" +#define X264_POINTVER "0.60.915M 14046ae" diff -r -u x264-original/encoder/analyse.c x264-4part/encoder/analyse.c --- x264-original/encoder/analyse.c 2008-07-23 20:00:37.000000000 -0700 +++ x264-4part/encoder/analyse.c 2008-07-31 16:05:49.000000000 -0700 @@ -1034,6 +1034,12 @@ int *p_halfpel_thresh = /*h->mb.pic.i_fref[0]>1 ? &i_halfpel_thresh : */NULL; int i; int i_maxref = h->mb.pic.i_fref[0]-1; + int s_ref[16][2] = { { 0,INT_MAX},{ 1,INT_MAX},{ 2,INT_MAX},{ 3,INT_MAX}, + { 4,INT_MAX},{ 5,INT_MAX},{ 6,INT_MAX},{ 7,INT_MAX}, + { 8,INT_MAX},{ 9,INT_MAX},{10,INT_MAX},{11,INT_MAX}, + {12,INT_MAX},{13,INT_MAX},{14,INT_MAX},{15,INT_MAX} }; + int u_ref[16][2] = {{0}}; + int n,swapped,rtmp,ctmp; h->mb.i_partition = D_8x8; @@ -1059,31 +1065,70 @@ x264_me_t *l0m = &a->l0.me8x8[i]; const int x8 = i%2; const int y8 = i/2; + const int r_maxref = (i == 0) ? i_maxref : + (i == 1) ? ((i_maxref+1)*h->param.athresh)/100 : + (i == 2) ? ((i_maxref+1)*h->param.bthresh)/100 : + ((i_maxref+1)*h->param.cthresh)/100 ; m.i_pixel = PIXEL_8x8; m.p_cost_mv = a->p_cost_mv; LOAD_FENC( &m, p_fenc, 8*x8, 8*y8 ); l0m->cost = INT_MAX; - for( i_ref = 0; i_ref <= i_maxref; i_ref++ ) + for( i_ref = 0; i_ref <= r_maxref; i_ref++ ) { - const int i_ref_cost = REF_COST( 0, i_ref ); + const int r_ref = s_ref[i_ref][0]; + const int i_ref_cost = REF_COST( 0, r_ref ); i_halfpel_thresh -= i_ref_cost; m.i_ref_cost = i_ref_cost; - m.i_ref = i_ref; + m.i_ref = r_ref; - LOAD_HPELS( &m, h->mb.pic.p_fref[0][i_ref], 0, i_ref, 8*x8, 8*y8 ); - x264_macroblock_cache_ref( h, 2*x8, 2*y8, 2, 2, 0, i_ref ); + LOAD_HPELS( &m, h->mb.pic.p_fref[0][r_ref], 0, r_ref, 8*x8, 8*y8 ); + x264_macroblock_cache_ref( h, 2*x8, 2*y8, 2, 2, 0, r_ref ); x264_mb_predict_mv( h, 0, 4*i, 2, m.mvp ); - x264_me_search_ref( h, &m, a->l0.mvc[i_ref], i+1, p_halfpel_thresh ); + x264_me_search_ref( h, &m, a->l0.mvc[r_ref], i+1, p_halfpel_thresh ); m.cost += i_ref_cost; i_halfpel_thresh += i_ref_cost; - *(uint32_t*)a->l0.mvc[i_ref][i+1] = *(uint32_t*)m.mv; + *(uint32_t*)a->l0.mvc[r_ref][i+1] = *(uint32_t*)m.mv; if( m.cost < l0m->cost ) h->mc.memcpy_aligned( l0m, &m, sizeof(x264_me_t) ); + + u_ref[i_ref][0] = r_ref; + u_ref[i_ref][1] = m.cost; + } + + if( i != 3 ) { + /* update ref list */ + for( i_ref = 0; i_ref <= r_maxref; i_ref++ ) { + for( n = 0; n <= r_maxref; n++ ) { + if( s_ref[n][1] != INT_MAX && u_ref[i_ref][0] == s_ref[n][0] ) { + s_ref[n][1] += u_ref[i_ref][1]; + s_ref[n][1] /= 2; + } + } + } + + /* sort ref list */ + n = i_maxref; // sort all refs incase c > b || b > a + do { + swapped = 0; + n--; + for( i_ref = 0; i_ref < n; i_ref++ ) { + if( s_ref[i_ref][1] > s_ref[i_ref+1][1] ) { + rtmp = s_ref[i_ref+1][0]; + ctmp = s_ref[i_ref+1][1]; + s_ref[i_ref+1][0] = s_ref[i_ref][0]; + s_ref[i_ref+1][1] = s_ref[i_ref][1]; + s_ref[i_ref][0] = rtmp; + s_ref[i_ref][1] = ctmp; + swapped = 1; + } + } + } while ( swapped ); } + x264_macroblock_cache_mv_ptr( h, 2*x8, 2*y8, 2, 2, 0, l0m->mv ); x264_macroblock_cache_ref( h, 2*x8, 2*y8, 2, 2, 0, l0m->i_ref ); diff -r -u x264-original/x264.c x264-4part/x264.c --- x264-original/x264.c 2008-07-23 20:00:38.000000000 -0700 +++ x264-4part/x264.c 2008-07-29 00:02:59.000000000 -0700 @@ -471,6 +471,9 @@ { "transfer", required_argument, NULL, 0 }, { "colormatrix", required_argument, NULL, 0 }, { "chromaloc", required_argument, NULL, 0 }, + { "a-thresh", required_argument, NULL, 0 }, + { "b-thresh", required_argument, NULL, 0 }, + { "c-thresh", required_argument, NULL, 0 }, {0, 0, 0, 0} }; diff -r -u x264-original/x264.h x264-4part/x264.h --- x264-original/x264.h 2008-07-23 20:00:39.000000000 -0700 +++ x264-4part/x264.h 2008-07-29 00:03:31.000000000 -0700 @@ -289,6 +289,11 @@ int b_aud; /* generate access unit delimiters */ int b_repeat_headers; /* put SPS/PPS before each keyframe */ int i_sps_id; /* SPS and PPS id number */ + + /* 4part p8x8 ref search */ + int athresh; + int bthresh; + int cthresh; } x264_param_t; typedef struct { diff -r -u x264-original/x264.pc x264-4part/x264.pc --- x264-original/x264.pc 2008-07-26 10:11:41.000000000 -0700 +++ x264-4part/x264.pc 2008-07-29 02:45:02.000000000 -0700 @@ -5,6 +5,6 @@ Name: x264 Description: H.264 (MPEG4 AVC) encoder library -Version: 0.60.915 14046ae +Version: 0.60.915M 14046ae Libs: -L${exec_prefix}/lib -lx264 -lpthread Cflags: -I${prefix}/include