On Wed, Jul 11, 2018 at 06:37:37AM +0800, Jun Zhao wrote:
> use pixelutils API for sad in motion estimation.
> 
> Signed-off-by: Jun Zhao <mypopy...@gmail.com>
> ---
>  libavfilter/motion_estimation.c |   12 +++++++++---
>  libavfilter/motion_estimation.h |    2 ++
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/motion_estimation.c b/libavfilter/motion_estimation.c
> index 0f9ba21..8ccd879 100644
> --- a/libavfilter/motion_estimation.c
> +++ b/libavfilter/motion_estimation.c
> @@ -54,6 +54,8 @@ void ff_me_init_context(AVMotionEstContext *me_ctx, int 
> mb_size, int search_para
>      me_ctx->x_max = x_max;
>      me_ctx->y_min = y_min;
>      me_ctx->y_max = y_max;
> +
> +    me_ctx->sad = av_pixelutils_get_sad_fn(av_ceil_log2_c(mb_size), 
> av_ceil_log2_c(mb_size), 0, NULL);
>  }
>  
>  uint64_t ff_me_cmp_sad(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int 
> x_mv, int y_mv)
> @@ -67,9 +69,13 @@ uint64_t ff_me_cmp_sad(AVMotionEstContext *me_ctx, int 
> x_mb, int y_mb, int x_mv,
>      data_ref += y_mv * linesize;
>      data_cur += y_mb * linesize;
>  
> -    for (j = 0; j < me_ctx->mb_size; j++)
> -        for (i = 0; i < me_ctx->mb_size; i++)
> -            sad += FFABS(data_ref[x_mv + i + j * linesize] - data_cur[x_mb + 
> i + j * linesize]);
> +    if (me_ctx->sad) {
> +        sad = me_ctx->sad(data_ref+x_mv, linesize, data_cur+x_mb, linesize);
> +    } else {
> +        for (j = 0; j < me_ctx->mb_size; j++)
> +            for (i = 0; i < me_ctx->mb_size; i++)
> +                sad += FFABS(data_ref[x_mv + i + j * linesize] - 
> data_cur[x_mb + i + j * linesize]);
> +    }
>  

The function pointers which point to ff_me_cmp_sad() should point to SIMD
code in the optimized case.
there should be no check per call

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to