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]); + } return sad; } diff --git a/libavfilter/motion_estimation.h b/libavfilter/motion_estimation.h index 6ae29dd..9f7710b 100644 --- a/libavfilter/motion_estimation.h +++ b/libavfilter/motion_estimation.h @@ -22,6 +22,7 @@ #define AVFILTER_MOTION_ESTIMATION_H #include "libavutil/avutil.h" +#include "libavutil/pixelutils.h" #define AV_ME_METHOD_ESA 1 #define AV_ME_METHOD_TSS 2 @@ -59,6 +60,7 @@ typedef struct AVMotionEstContext { uint64_t (*get_cost)(struct AVMotionEstContext *me_ctx, int x_mb, int y_mb, int mv_x, int mv_y); + av_pixelutils_sad_fn sad; } AVMotionEstContext; void ff_me_init_context(AVMotionEstContext *me_ctx, int mb_size, int search_param, -- 1.7.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel