From patchwork Tue Jul 10 22:37:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 9668 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp4175452jad; Tue, 10 Jul 2018 15:38:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeUZgSC7cK32NJYXNcwvETGyjHjOB90UqxX7CE086XxezCE5TVam95IXuOUI96msN/YVlhW X-Received: by 2002:a1c:9546:: with SMTP id x67-v6mr15194288wmd.25.1531262287475; Tue, 10 Jul 2018 15:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531262287; cv=none; d=google.com; s=arc-20160816; b=EoQcXklNW+W8ts0qKlPt0nQBZSR/uPoBKmeCLxyZvwFAR4nXX/KXy7KYdRDKSZGkGm Pchbj4aPzxDp2CuUJSu6azFmeuqtPGLu68ZC7ndgti4XgiFgNO2AUDDUA839/zM3K6aP /SW9RENw77ZGVmyghK5d6AWDLGdL3zP4S/Fd2sGxxARTf2u4QD0EisY1iD9CGG+s/uWY wh6djO4IUz0n6qXJRW4em50tXrNW8KEAACNmFBaQ+A0u1nnWdkKGAPa+DCLPVHqsNrw7 nmpf6hGWp7YJlnIROUCqHNCM3m/mxrnQf0xc6zovyyxoMjwCINpqBLiWDdoh4iDGbIzW XtRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=FGBAYPNzOsFTDtwOgQdo5O/M9pySwW3U65oDl3Sj93U=; b=S12E+Qw1QWmH5SZtbtw9pcKpL66mw50PvFCO0HjPCrTwPhcj+HBlv4qoc9LzmpP8DR eYZLoouxGe7pvKq9F5XdhhlKsajzfA2zAj763VJBlD1XFnqRsjJz85YH+uySlfKXEGVy LiTW5/aD9tkg9h7UsiaaetoZZGthAc+wFcAkZtdYChELemHmNcnYUXYAuAUH24YcC5yO b9FrS8T2Erz2Zu7b4Z2QMmXj4GR1HpwJ5EO8q7A2PhL+sZBgsb+K8o50B8n+w/Gvweed +mkVW4BHVkDYc2w74tu2k3tj9PF7ujjNvELaD3bOwbubXTRclnaxBoZ99Z59hEJNQ8LD rDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ZFKHcOPu; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l15-v6si16043954wrn.212.2018.07.10.15.38.07; Tue, 10 Jul 2018 15:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ZFKHcOPu; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 00BA568A56F; Wed, 11 Jul 2018 01:37:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f49.google.com (mail-pl0-f49.google.com [209.85.160.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3C80A689FF7 for ; Wed, 11 Jul 2018 01:37:45 +0300 (EEST) Received: by mail-pl0-f49.google.com with SMTP id s24-v6so8239646plq.6 for ; Tue, 10 Jul 2018 15:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TSylPE78FKanS851DTV6lAmt3FoETDSaTp8RSz1DwgA=; b=ZFKHcOPuN6KU/U7mxOWjVfhrV9kmGrAqyw9xn0GWsBMXCXsRJRZ5nAPs+PgAp28Ohi 6skRI6C7PUx/NvBXKhaVRmBMrRhCsMvJeE2zA6D7au0x3vfLHOvQwgfXxC5iQKK4nL81 bLLMQZrkQMnqfw7IeWY28q1xpTqwsyR6Ryjvre8g2IUXxF7iL3oTpwJN35uS3MR0N4lf 4T2mTrYrNv2oC+W0+EY3HGAOGYwkyiDQPU6YxRgnAlHheC+xLwaCX4r0A/WRzJiZTSrg rZkkW5KECQ047xY+jEvCZo7D9CDpYZaMuCHRiB3tslXfptvsdIuidTeh7jaov9sW/HXP 3HhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TSylPE78FKanS851DTV6lAmt3FoETDSaTp8RSz1DwgA=; b=i3ctqNd48i+5y8I8e2hR0mNnQbEFoFG10BZ8nJ7CkkEk15yICeMUshcHbKNRswY6ot 41xb/TDI/iX4S9TY/4UULWtQ1t5CXip90HZ6VjFQLGdgjZf2JVt6CalWs6MLKoh0Yrgw hnkHKeJkBnrda8pOXc5SOf0YHlGiqrlTp0REf+14OslrvHj6nR7lsyZQmbeO/6UJVokC ONbsqZiwh6g9n9kJwlWazeL5UkGAi3MxTM3Kme/STlVQRo7fnVZQ+KR6YHfisiqkAez4 rGqooqiAtwjjBVz8vRIIvNSgXX7yu7qIg8CweP9T6cjSLMryvF83BQoh2bZrsXYJj2AM fFlg== X-Gm-Message-State: APt69E2TTNa9vmMXiHRvuuJcbYSxGHbCxYHGWnYzrNjXUnXBDGSofV+s y9SHEophydue8izIlVgXtH1863kMLL8= X-Received: by 2002:a17:902:3303:: with SMTP id a3-v6mr26396759plc.209.1531262271214; Tue, 10 Jul 2018 15:37:51 -0700 (PDT) Received: from localhost.localdomain ([47.90.47.25]) by smtp.gmail.com with ESMTPSA id i6-v6sm27675943pfo.107.2018.07.10.15.37.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 15:37:50 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Jul 2018 06:37:37 +0800 Message-Id: <1531262257-4660-3-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1531262257-4660-1-git-send-email-mypopydev@gmail.com> References: <1531262257-4660-1-git-send-email-mypopydev@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/3] lavfi/motion_estimation: use pixelutils API for sad. 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: Jun Zhao MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" use pixelutils API for sad in motion estimation. Signed-off-by: Jun Zhao --- 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,