From patchwork Thu Sep 12 23:33:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15051 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 B1094449FE6 for ; Fri, 13 Sep 2019 02:33:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9A35268817E; Fri, 13 Sep 2019 02:33:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93851688176 for ; Fri, 13 Sep 2019 02:33:08 +0300 (EEST) Received: by mail-pg1-f195.google.com with SMTP id u72so14253601pgb.10 for ; Thu, 12 Sep 2019 16:33:08 -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; bh=r2BW312zSQwnRyt/KfHd6Lyyqwv9Ij1jp+hZ1G856H0=; b=jXbWcaG4BaCojdv115nDky8sb2+D94dBBxLHhnghog7YWr4Z++yCqrrk9zhcQhKsr4 bY+Et7QEUIJzTJtkoI20I1/F5c6jqGrSJQ2qD5A+5J6NHRTTMZLkidtOS6Iq0/0Nz5WT L6F4W/Xwx/LGC0P5FCt5C/IOza08rIp+JDlqQ66MjRer84cQWnIyJQ+e9kGcYAj2Z3lk g3MyeHLHXrgFUziX2tFwpZ5TOjlMcN5pZ5nRLXO1lWZLokZ7j4kA74zzXGbW1kbyHftL NuigrRx+IhgimY4ZbchIp5yv6QACGgxY7kUx3NaWGraAgfDiKick2JeEp0zy6VKL/jt8 eMYQ== 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; bh=r2BW312zSQwnRyt/KfHd6Lyyqwv9Ij1jp+hZ1G856H0=; b=StUbP2FPqsWZJocVNg2t6KFeoYQS4HPl9sVmCddBQXarIrPNfc5AojFHkzfHYokgpk VR8IM+kv0BKMqTOO+AN9zn2QjdaHJa1HK0FEaQhId1j+rdOIwGmm4n/YMeTqPKjMtypU ZGk7KStzOtfWpGlmXAI1nIwaqxIVn0QEND2Rpq2DW/bpUdZuqRlHJuJ0ui50H3/QjhnV +mVYUGig9dQcHfdryZFIEi/BjwneLao41zEh/GtYvt34+eGvmIfAz6jseHKpRA8DiNk1 AzRuC2vjmKq/dtvBg0/aLjgE1FbwL+UA6hPytbDMXci5ZE5iniBFRVW70dvmayhvioTl 9EbA== X-Gm-Message-State: APjAAAW9TnXnz5WC1pNaoOG/7M7NoOqqaMQ3SPVcVZeSrYx3swIG3pKo WMbGalnzDBaO436Q7tUhfpCYHAub X-Google-Smtp-Source: APXvYqwz70XmQYRB+/pfTsyC/kHjGb8P5EhUoYFsSZprjFPTsRpEqqXmEc2roPRbWQ6QC3riEAa5pA== X-Received: by 2002:a63:2349:: with SMTP id u9mr37450245pgm.214.1568331186832; Thu, 12 Sep 2019 16:33:06 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id c14sm364736pjr.20.2019.09.12.16.33.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 16:33:06 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 13 Sep 2019 07:33:01 +0800 Message-Id: <20190912233301.17664-1-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [FFmpeg-devel] [PATCH v1] 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 b0bb238..fc8054b 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;