From patchwork Sat Sep 14 03:37:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15067 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 89A6D44A37E for ; Sat, 14 Sep 2019 06:38:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 66F0F688336; Sat, 14 Sep 2019 06:38:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6B91C6881D7 for ; Sat, 14 Sep 2019 06:38:22 +0300 (EEST) Received: by mail-pf1-f196.google.com with SMTP id q10so19267890pfl.0 for ; Fri, 13 Sep 2019 20:38:22 -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=r2BW312zSQwnRyt/KfHd6Lyyqwv9Ij1jp+hZ1G856H0=; b=Lwo1cTHnoWfGfReqBESYi5JKtVbbekwEaDwCScmGUcIoEF1ZO3Z0V+/+nNldK9oJ27 C1aKIQ8+A7tY0dp29neEK1x6rF7zj4p5D0Gdo/+QqWUgMTOZYtCzqkTOEY1oILpZ8oSQ DfjgYU8iT1euJMrA4ymH2WBFl+HOeoNv0wwHl5oeiTESUIKZOvtRcHlbpfOhrFuGajQ7 IeeKKhTYRS7NIHWJDqUOZLVpeNXP8kw41UAvDelOLcCptHLoBBuUBnP0uxxUfxtSSu9u M3GoJuWapXr/6T9CfcMB78R1uZBEOQG2wQQx8MQayYru9yDFTGD9ZTZOs/HkoV4fyL88 nYFw== 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=r2BW312zSQwnRyt/KfHd6Lyyqwv9Ij1jp+hZ1G856H0=; b=nP67mm1ghfqowvNEy2bYv3GheeJoFr7UTTRHysvaGlFNPEMZpT28Fd5W+a+bDX0cK/ hcZwLlnGG1K/UsosHH2NYLCBGILgCJaY5ZMF43J/bA48OvhW+VOJxkfuE1hjuP8cumYJ pGyvDtmH3SoctN9tqGjJGDRQHiZgG37LbsI8fK8SSW510bMlMRXf5PlJP5g2Ew7rl+e4 FVh+nW6zGWNbGHE9bFyJb4HFGQPvX/imctD38EXzdT3koEU3mCQbLZrWhHyXJ5mCK02m 2fulJypAtlJqOfQVlgMT92FBToinSSQzyCO58hftsmCxW7PdEy81AFvInaEho+Q6G+30 8gwg== X-Gm-Message-State: APjAAAU8UvRO7kWkFnifjCqHkm3nNUkRF57qr4zExdLV50eaImeHLFY4 kHLyIHLuTwXR1HbUz859dvq6ndFE X-Google-Smtp-Source: APXvYqwf3nub2mS8USFJ1afDYIIccdihwkx2RL6uHaDcuEKn0L75K+yGKhKxK/NTS8wjF0JrCSDdhg== X-Received: by 2002:a17:90a:1996:: with SMTP id 22mr9149475pji.17.1568432300164; Fri, 13 Sep 2019 20:38:20 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id u11sm21614392pfm.113.2019.09.13.20.38.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 20:38:19 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 14 Sep 2019 11:37:29 +0800 Message-Id: <20190914033731.19613-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 v2 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 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;