]> granicus.if.org Git - libx264/commitdiff
limit vertical motion vectors to +/-512, since some decoders actually depend on that...
authorLoren Merritt <pengvado@videolan.org>
Thu, 28 Jun 2007 21:26:21 +0000 (21:26 +0000)
committerLoren Merritt <pengvado@videolan.org>
Thu, 28 Jun 2007 21:26:21 +0000 (21:26 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@663 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/analyse.c
encoder/encoder.c

index 6dfca9bf00c835d3aaa6f21a456f8848bbb39463..b4795638490f84df054020cb7de0f3db3d933204 100644 (file)
@@ -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;
index 82c904bad5a02f0e91ceb97626274ac769fbb929..9723da63e57d44fe1a72d2c346374548f695e826 100644 (file)
@@ -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;
     }