[x264-devel] How to get the mv clip range in x264?

Jason Garrett-Glaser darkshikari at gmail.com
Mon Mar 22 03:07:00 CET 2010


On Sun, Mar 21, 2010 at 6:52 PM, SiPing Tao <anhuitsp at mail.ustc.edu.cn> wrote:
> Dear experts,
>
> The following x264 code makes me confuesed:
>
>        // 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 = 6; // umh: 1 for diamond, 2 for octagon, 2 for hpel
>
>        /* Calculate max allowed MV range */
>        #define CLIP_FMV(mv) x264_clip3( mv, -i_fmv_range, i_fmv_range-1 )
>        h->mb.mv_min[0] = 4*( -16*h->mb.i_mb_x - 24 );
>        h->mb.mv_max[0] = 4*( 16*( h->sps->i_mb_width - h->mb.i_mb_x - 1 ) + 24 );
>        h->mb.mv_min_spel[0] = CLIP_FMV( h->mb.mv_min[0] );
>        h->mb.mv_max_spel[0] = CLIP_FMV( h->mb.mv_max[0] );
>        h->mb.mv_min_fpel[0] = (h->mb.mv_min_spel[0]>>2) + i_fpel_border;
>        h->mb.mv_max_fpel[0] = (h->mb.mv_max_spel[0]>>2) - i_fpel_border;
>
> First, why set i_fpel_border = 6? I don't understand the comments "// umh: 1 for diamond, 2 for octagon, 2 for hpel". As I understand, sub-pixel interolation will use 3 extra pixels at edge most, I think i_fpel_border = 3 is OK.

Some of the motion search methods may search a (predictable) distance
beyond the limit.

> Second, h->mb.mv_min[0] = 4*( -16*h->mb.i_mb_x - 24 ), why use 24? The padding length is 32, and DIA will iterate 16 times at most, so I think it should be h->mb.mv_min[0] = 4*( -16*h->mb.i_mb_x - 16 ).

The limitation has nothing to do with DIA.  DIA checks the MV range at
each iteration.

Dark Shikari


More information about the x264-devel mailing list