From: Loren Merritt Date: Thu, 27 Jan 2005 11:33:14 +0000 (+0000) Subject: Fix clipping of mvs in probe_pskip. (Previously it mixed up fullpel with qpel.) This... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c16119a2ccf2dff2328628dd9ded4681f5502c38;p=libx264 Fix clipping of mvs in probe_pskip. (Previously it mixed up fullpel with qpel.) This should eliminate the black blocks that sometimes appeared in high motion, low detail scenes. git-svn-id: svn://svn.videolan.org/x264/trunk@108 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/common/macroblock.c b/common/macroblock.c index a2f176fc..44a4f5f7 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -347,6 +347,10 @@ void x264_mb_predict_mv_pskip( x264_t *h, int mv[2] ) { x264_mb_predict_mv_16x16( h, 0, 0, mv ); } + + /* FIXME: ensure that mvp doesn't extend past picture edge + padding. + * we can't just clip the mv here, since the original value may be + * needed for predicting other mvs. */ } static int x264_mb_predict_mv_direct16x16_temporal( x264_t *h ) diff --git a/encoder/macroblock.c b/encoder/macroblock.c index d07f0402..2aec1eb7 100644 --- a/encoder/macroblock.c +++ b/encoder/macroblock.c @@ -799,19 +799,12 @@ int x264_macroblock_probe_skip( x264_t *h, int b_bidir ) /* Get the MV */ x264_mb_predict_mv_pskip( h, mvp ); - /* Special case, need to clip the vector */ - n = 16 * h->mb.i_mb_x + mvp[0]; - if( n < -24 ) - mvp[0] = -24 - 16*h->mb.i_mb_x; - else if( n > 16 * h->sps->i_mb_width + 24 ) - mvp[0] = 16 * ( h->sps->i_mb_width - h->mb.i_mb_x ) + 24; - - n = 16 * h->mb.i_mb_y + mvp[1]; - if( n < -24 ) - mvp[1] = -24 - 16*h->mb.i_mb_y; - else if( n > 16 * h->sps->i_mb_height + 8 ) - mvp[1] = 16 * ( h->sps->i_mb_height - h->mb.i_mb_y ) + 8; - + mvp[0] = x264_clip3( mvp[0], + 4*( -16*h->mb.i_mb_x - 24 ), + 4*( 16*( h->sps->i_mb_width - h->mb.i_mb_x ) + 8 ) ); + mvp[1] = x264_clip3( mvp[1], + 4*( -16*h->mb.i_mb_y - 24 ), + 4*( 16*( h->sps->i_mb_height - h->mb.i_mb_y ) + 8 ) ); /* Motion compensation */ h->mc[MC_LUMA]( h->mb.pic.p_fref[0][0][0], h->mb.pic.i_stride[0],