From ee62378f91c3cfcc028e771b8bc998b4490cc8a1 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Thu, 28 Jun 2007 21:26:21 +0000 Subject: [PATCH] limit vertical motion vectors to +/-512, since some decoders actually depend on that limit. git-svn-id: svn://svn.videolan.org/x264/trunk@663 df754926-b1dd-0310-bc7b-ec298dee348c --- encoder/analyse.c | 7 +++++-- encoder/encoder.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/encoder/analyse.c b/encoder/analyse.c index 6dfca9bf..b4795638 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -224,7 +224,10 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp ) { int i, j; int i_fmv_range = 4 * h->param.analyse.i_mv_range; - int i_fpel_border = 5; // 3 for hex search, 2 for subpel, ignores subme7 & bime + // limit motion search to a slightly smaller range than the theoretical limit, + // since the search may go a few iterations past its given range + int i_fpel_border = 5; // umh unconditional radius + int i_spel_border = 8; // 1.5 for subpel_satd, 1.5 for subpel_rd, 2 for bime, round up /* Calculate max allowed MV range */ #define CLIP_FMV(mv) x264_clip3( mv, -i_fmv_range, i_fmv_range ) @@ -262,7 +265,7 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp ) h->mb.mv_min[1] = 4*( -16*mb_y - 24 ); h->mb.mv_max[1] = 4*( 16*( mb_height - mb_y - 1 ) + 24 ); - h->mb.mv_min_spel[1] = CLIP_FMV( h->mb.mv_min[1] ); + h->mb.mv_min_spel[1] = x264_clip3( h->mb.mv_min[1], X264_MAX(4*(-512+i_spel_border), -i_fmv_range), i_fmv_range ); h->mb.mv_max_spel[1] = CLIP_FMV( h->mb.mv_max[1] ); h->mb.mv_max_spel[1] = X264_MIN( h->mb.mv_max_spel[1], thread_mvy_range*4 ); h->mb.mv_min_fpel[1] = (h->mb.mv_min_spel[1]>>2) + i_fpel_border; diff --git a/encoder/encoder.c b/encoder/encoder.c index 82c904ba..9723da63 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -493,7 +493,7 @@ static int x264_validate_parameters( x264_t *h ) if( h->param.analyse.i_mv_range <= 0 ) h->param.analyse.i_mv_range = l->mv_range; else - h->param.analyse.i_mv_range = x264_clip3(h->param.analyse.i_mv_range, 32, 2048); + h->param.analyse.i_mv_range = x264_clip3(h->param.analyse.i_mv_range, 32, 512); if( h->param.analyse.i_direct_8x8_inference < 0 ) h->param.analyse.i_direct_8x8_inference = l->direct8x8; } -- 2.40.0