From patchwork Fri Sep 20 03:08:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15172 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 CD8DF449CD6 for ; Fri, 20 Sep 2019 06:15:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B9D8F6880E4; Fri, 20 Sep 2019 06:15:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3CB356880DF for ; Fri, 20 Sep 2019 06:15:29 +0300 (EEST) Received: by mail-pl1-f195.google.com with SMTP id f19so2535533plr.3 for ; Thu, 19 Sep 2019 20:15:29 -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=9GutefnE9KCh/DeUdNEjvfuoz3LfheUOVkixKQZhXws=; b=EDdgqbXXlvctwH3/4MSMI1YCCXWispU0YKDxhPDMkraBWvCFN3hODAveWTqPdH1DHa 7dosDfHUbHyVEi9OXOzf91dxo+gZutL1j7XQV99ktCRQnfYwCij1T3GhsS9mYYW9yjmU 5Qvn4BSWiWrxXuCjjeEF/ylPMtCowvLwAlmIKX5BDcJ4Ebodyxd6UbPVVhC0jCFyiWye tfYUDsHmzItIn2WPE/cTUgJJuPJxKkZ/NxkdVACl4g2bLa+r+XzLSjpo4gCPYfuocs70 64bHslW1jPcRMLb9CrYXxFTITpw1DxwkRHRXxPjJWe+ydK0S0CQyS6/S3ghB9pvgl5Kb 9ykQ== 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=9GutefnE9KCh/DeUdNEjvfuoz3LfheUOVkixKQZhXws=; b=oYX73yrPZhAK5LvciXdmmaHvUrsO1kKPr5YllMZqioB1Aw6qUiiDd/QkwSkwZDEmSw JmhJfahc9j8TsmO40q4fa6V19hDyUySQpceoOEMLnwYQjLr3R6ZfDIc0lWLSyNqJIQiu aYgax7SYcee1p3d2pJBH1n5PPZwkK88p0ZyNbmYmBVuTlseIc9iNJrB6IK0a1GYKm9P8 GBZYBaJpJEte+s6GVYGf6Cm/Jv7RkpigoauVQ94V1VI+i6RMz1j2LemoRnvprXM/PSZW lqqYcW1EFOe62kblOmihUGngFDj3ormKIU9iD0qmwiqG2WbX/O1yWLK/2T92BcRYng9a TBCA== X-Gm-Message-State: APjAAAX4toygnzBhjIJu2W50a7ywr8MF41gXo1rt3a5+MHkU6yjMryQ8 T34RVPRSQo524dhRpFwu39DEu8Z1 X-Google-Smtp-Source: APXvYqwoKeldDXkHJWTq748WfhM/Kx2hdjEiQ4YP5VDET1f+yDELHqsXQhVBRpqsrgifCaGH7eqwaw== X-Received: by 2002:a17:902:aa43:: with SMTP id c3mr13411063plr.11.1568948928628; Thu, 19 Sep 2019 20:08:48 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id e9sm289956pgs.86.2019.09.19.20.08.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Sep 2019 20:08:48 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Sep 2019 11:08:34 +0800 Message-Id: <20190920030836.4532-1-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190912233301.17664-1-lance.lmwang@gmail.com> References: <20190912233301.17664-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 1/3] avfilter/vf_minterpolate: correct the mafd calculation 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_minterpolate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index b0bb238ade..fc8054b710 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -185,6 +185,7 @@ typedef struct MIContext { int64_t out_pts; int b_width, b_height, b_count; int log2_mb_size; + int bitdepth; int scd_method; int scene_changed; @@ -343,6 +344,7 @@ static int config_input(AVFilterLink *inlink) mi_ctx->log2_chroma_h = desc->log2_chroma_h; mi_ctx->log2_chroma_w = desc->log2_chroma_w; + mi_ctx->bitdepth = desc->comp[0].depth; mi_ctx->nb_planes = av_pix_fmt_count_planes(inlink->format); @@ -383,7 +385,7 @@ static int config_input(AVFilterLink *inlink) } if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { - mi_ctx->sad = ff_scene_sad_get_fn(8); + mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth == 8 ? 8 : 16); if (!mi_ctx->sad) return AVERROR(EINVAL); } @@ -836,7 +838,7 @@ static int detect_scene_change(MIContext *mi_ctx) 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); + mafd = (double) sad * 100.0 / (me_ctx->height * me_ctx->width) / (1 << mi_ctx->bitdepth); diff = fabs(mafd - mi_ctx->prev_mafd); ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); mi_ctx->prev_mafd = mafd;