From patchwork Sun Nov 4 12:06:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 10918 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 101A644CB0E for ; Sun, 4 Nov 2018 14:06:18 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 83FF768A89D; Sun, 4 Nov 2018 14:05:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4D73068A899 for ; Sun, 4 Nov 2018 14:05:43 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C8DFBE06C3; Sun, 4 Nov 2018 13:06:16 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dq0DzC_6UBZ3; Sun, 4 Nov 2018 13:06:16 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B795BE15B9; Sun, 4 Nov 2018 13:06:15 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Nov 2018 13:06:06 +0100 Message-Id: <20181104120606.4177-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20181104120606.4177-1-cus@passwd.hu> References: <20181104120606.4177-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/3] avfilter/vf_minterpolate: use common scene sad functions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- configure | 1 + libavfilter/vf_minterpolate.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/configure b/configure index f352ea121c..5eac2c92f3 100755 --- a/configure +++ b/configure @@ -3412,6 +3412,7 @@ mcdeint_filter_deps="avcodec gpl" movie_filter_deps="avcodec avformat" mpdecimate_filter_deps="gpl" mpdecimate_filter_select="pixelutils" +minterpolate_filter_select="scene_sad" mptestsrc_filter_deps="gpl" negate_filter_deps="lut_filter" nnedi_filter_deps="gpl" diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index c6a5e63f90..532f5ed235 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -26,11 +26,11 @@ #include "libavutil/motion_vector.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" -#include "libavutil/pixelutils.h" #include "avfilter.h" #include "formats.h" #include "internal.h" #include "video.h" +#include "scene_sad.h" #define ME_MODE_BIDIR 0 #define ME_MODE_BILAT 1 @@ -188,7 +188,7 @@ typedef struct MIContext { int scd_method; int scene_changed; - av_pixelutils_sad_fn sad; + ff_scene_sad_fn sad; double prev_mafd; double scd_threshold; @@ -383,7 +383,7 @@ static int config_input(AVFilterLink *inlink) } if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { - mi_ctx->sad = av_pixelutils_get_sad_fn(3, 3, 2, mi_ctx); + mi_ctx->sad = ff_scene_sad_get_fn(8); if (!mi_ctx->sad) return AVERROR(EINVAL); } @@ -827,18 +827,15 @@ static int detect_scene_change(MIContext *mi_ctx) { AVMotionEstContext *me_ctx = &mi_ctx->me_ctx; int x, y; - int linesize = me_ctx->linesize; uint8_t *p1 = mi_ctx->frames[1].avf->data[0]; + ptrdiff_t linesize1 = mi_ctx->frames[1].avf->linesize[0]; uint8_t *p2 = mi_ctx->frames[2].avf->data[0]; + ptrdiff_t linesize2 = mi_ctx->frames[2].avf->linesize[0]; if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { double ret = 0, mafd, diff; - int64_t sad; - - for (sad = y = 0; y < me_ctx->height; y += 8) - for (x = 0; x < linesize; x += 8) - sad += mi_ctx->sad(p1 + x + y * linesize, linesize, p2 + x + y * linesize, linesize); - + uint64_t sad; + mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad); emms_c(); mafd = (double) sad / (me_ctx->height * me_ctx->width * 3); diff = fabs(mafd - mi_ctx->prev_mafd);