From patchwork Sun Dec 10 22:11:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 6689 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp2079056jah; Sun, 10 Dec 2017 14:12:20 -0800 (PST) X-Google-Smtp-Source: ACJfBoteTLxlli6GmUbjz/6H7NfMhV2Y7Wb8Pc/gX85OhQwXv0oSHNWAHirOUGjGu57e2xy9Kaak X-Received: by 10.223.157.137 with SMTP id p9mr1251306wre.92.1512943939951; Sun, 10 Dec 2017 14:12:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512943939; cv=none; d=google.com; s=arc-20160816; b=GdhXkELgY6SQrVJugKzFyUGHAP1aBbI9iI2g9KTENB8osB+n2oXMWCOSdOrfhRwTUI whnUhCRnuCTiQeNOjut1Ig2pXH1Y2AX5W+7AJuDXnFGIODcfxsWudIl2E1UwGV7cFl+F 4EWb0LuwTU0RBzc0j50uZtinZa7PUtPJZ+hmotWV0ysCFHJ1SXrDFLjLFyzZldqjej7k PgCihu8MtQkS4/4ZBFSK9YXRoKxmF3GULSA7Rmjrtu3X56CE8rOca3FmX0Oiai86pgpW 9P2jTzz3bG3e2dENXgwCimPQhOFNCqb1YqJZwiDYMH5RSbcB0Jffsufv1NYtFdby5X5b ca5w== 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:delivered-to:arc-authentication-results; bh=7JrZxLqVAap5htNxyyhVBzsKFisFx6SJkTzwl5zSWBU=; b=PLGIITqPyTpCBbPtGjo3ezK4SHr/qm2y6ipqY8LqEa7x4nPf5vCv7ZykBZP2qxCYIm bHIX6Ei0FHhhnQN+vRaMylqmiA2cqn9i6WSQxVXzUkJkpvpVfDhL/Q6DXZpGeqtQFuTE AcIEDZTvAj8JIS8JGQn9DXQQ34UdJwJ6uCh+LsTzHFvnHNuCJoasfusenyk/y7GM4OPj S908zKULuOquBqGcP1dvE312xPW5uv6xvyWHZaVP46RNfN+akDsc0xi9G+tOsufSS4B6 xU2TX/CjTOvvlpl5lDRCN26ZIrxRMY7DW/ozCttHCmERKVNbkavZjbWOfQmq2ZQh96g+ I5KQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q10si9638146wrg.238.2017.12.10.14.12.19; Sun, 10 Dec 2017 14:12:19 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0431368A6C2; Mon, 11 Dec 2017 00:11:41 +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 B193268A6A9 for ; Mon, 11 Dec 2017 00:11:33 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0F799E181B; Sun, 10 Dec 2017 23:11:41 +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 PidybS4Yeu1W; Sun, 10 Dec 2017 23:11:39 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A0D06E183D; Sun, 10 Dec 2017 23:11:38 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Dec 2017 23:11:20 +0100 Message-Id: <20171210221122.15674-5-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171210221122.15674-1-cus@passwd.hu> References: <20171210221122.15674-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 5/7] avfilter/vf_framerate: fix scene change detection score 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" - normalize score to [0..100] instead of [0..85] - change the default score to 8.2 to roughly keep existing behaviour - take into account bit depth - do not truncate to integer Signed-off-by: Marton Balint --- doc/filters.texi | 2 +- libavfilter/vf_framerate.c | 4 ++-- tests/ref/fate/filter-framerate-12bit-down | 2 +- tests/ref/fate/filter-framerate-12bit-up | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 3346438231..10bd80d5c2 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8933,7 +8933,7 @@ Specify the level at which a scene change is detected as a value between 0 and 100 to indicate a new scene; a low value reflects a low probability for the current frame to introduce a new scene, while a higher value means the current frame is more likely to be one. -The default is @code{7}. +The default is @code{8.2}. @item flags Specify flags influencing the filter process. diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index 1cad2305ad..dd106f8e5b 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -88,7 +88,7 @@ static const AVOption framerate_options[] = { {"interp_start", "point to start linear interpolation", OFFSET(interp_start), AV_OPT_TYPE_INT, {.i64=15}, 0, 255, V|F }, {"interp_end", "point to end linear interpolation", OFFSET(interp_end), AV_OPT_TYPE_INT, {.i64=240}, 0, 255, V|F }, - {"scene", "scene change level", OFFSET(scene_score), AV_OPT_TYPE_DOUBLE, {.dbl=7.0}, 0, INT_MAX, V|F }, + {"scene", "scene change level", OFFSET(scene_score), AV_OPT_TYPE_DOUBLE, {.dbl=8.2}, 0, INT_MAX, V|F }, {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=1}, 0, INT_MAX, V|F, "flags" }, {"scene_change_detect", "enable scene change detection", 0, AV_OPT_TYPE_CONST, {.i64=FRAMERATE_FLAG_SCD}, INT_MIN, INT_MAX, V|F, "flags" }, @@ -183,7 +183,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next else sad = scene_sad16(s, (const uint16_t*)crnt->data[0], crnt->linesize[0] >> 1, (const uint16_t*)next->data[0], next->linesize[0] >> 1, crnt->height); - mafd = sad / (crnt->height * crnt->width * 3); + mafd = (double)sad * 100.0 / (crnt->height * crnt->width) / (1 << s->bitdepth); diff = fabs(mafd - s->prev_mafd); ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); s->prev_mafd = mafd; diff --git a/tests/ref/fate/filter-framerate-12bit-down b/tests/ref/fate/filter-framerate-12bit-down index 7a5a7b8e14..0a9aea0ce1 100644 --- a/tests/ref/fate/filter-framerate-12bit-down +++ b/tests/ref/fate/filter-framerate-12bit-down @@ -4,7 +4,7 @@ #dimensions 0: 320x240 #sar 0: 1/1 0, 0, 0, 1, 307200, 0xb49cf016 -0, 1, 1, 1, 307200, 0xfe025c7f +0, 1, 1, 1, 307200, 0xc3be6971 0, 2, 2, 1, 307200, 0x4d458da1 0, 3, 3, 1, 307200, 0x35d4d8ea 0, 4, 4, 1, 307200, 0x88f88697 diff --git a/tests/ref/fate/filter-framerate-12bit-up b/tests/ref/fate/filter-framerate-12bit-up index 8f57e6d066..8f5f95b275 100644 --- a/tests/ref/fate/filter-framerate-12bit-up +++ b/tests/ref/fate/filter-framerate-12bit-up @@ -4,7 +4,7 @@ #dimensions 0: 320x240 #sar 0: 1/1 0, 0, 0, 1, 307200, 0xb49cf016 -0, 1, 1, 1, 307200, 0xc74259b4 +0, 1, 1, 1, 307200, 0x59cb92c7 0, 2, 2, 1, 307200, 0xe4ca172c 0, 3, 3, 1, 307200, 0x5378b13c 0, 4, 4, 1, 307200, 0x2a7d4840