[FFmpeg-devel] [PATCH 3/3] lavfi/motion_estimation: use pixelutils API for sad.
Zhao Jun
mypopydev at gmail.com
Wed Jul 11 05:11:10 EEST 2018
On Wed, Jul 11, 2018 at 8:31 AM Michael Niedermayer
<michael at niedermayer.cc> wrote:
>
> 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 <mypopydev at 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
Thanks the suggestion, will move the check in ff_me_init_context to
avoid the check per call in ff_me_cmp_sad
>
> [...]
> --
> 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
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list