From patchwork Fri May 14 03:43:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 27741 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp83388iof; Thu, 13 May 2021 20:43:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiRQoGPTFBLasFe5Sy/HcRFmQcctsR4MEjZoeX3dpf16QG/rrxaqa8FJLs19vTq+ERvOKl X-Received: by 2002:a05:6402:438d:: with SMTP id o13mr34061249edc.324.1620963819997; Thu, 13 May 2021 20:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620963819; cv=none; d=google.com; s=arc-20160816; b=RyTyB06gX0s2Sq2+dt8eDqmknLUcPY5jbfFbo9RbZTvNiP0wVz0vaVfwShnphYg9mb HwVg+HVWR5hBsovL4pjzGMOrJ9E5zzPvFQSJ70DvaSVfyQQh/qWnsR7tbxwK5KgEv2O+ Vq6CrFJzXGJC9QuoYr2jAZf4fLrCgbolVgQgi2t3+2mIIGHnzopq0tXiQSniMtEpe4S1 v4Xvncp1LwWSXqHz0A+33UfPZ9w5ehqCHlRuWf34v8CrZrYap4aJZsv71hWlGA3YwkCL vibaOK4bze+UbnPaeiEanPzlf7l3qdv9ElDlAtMj9XDj4epUUoVfu3ylJaMYWq5WoIMz 0QEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=mllLT4rrtHEJQVHJxrEF3HIpJOPPIEKYWaunQeHA9Nw=; b=Mx6D8h4HSBf4mFUxmV2wrMV78w8Dpur9xChwB7VkdhsBkyG4wbL6p3pW4MGaZcmoCX ry7piOxdIIMZtbmMs7subAgEcItqUjTtRxqL0xGO/dGHxYUiGb7eQVMzXw1eRaSNDBHf /nfkj3L3H8MyPrHzeVhbBJiZzzE+1ZZo/RuRIrlE335gSj90rCMPv+mJg4M4fUgdONaV 4xtlXInZvRG3YV1zDQQ2s23QRnVtpI4elgZ/EHI02MI182JGPE8Ir6OJuEdVPHkv+ha1 HqGwPY9T16hzPPnu+0lGaFlYf6MUvF9ksZ0gc6awVrZ2b7R8cwr2waOdO7MlqZaQOHg8 UDjw== 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 da5si4506853edb.538.2021.05.13.20.43.39; Thu, 13 May 2021 20:43:39 -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; 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 4E8296880B0; Fri, 14 May 2021 06:43:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A33168035C for ; Fri, 14 May 2021 06:43:28 +0300 (EEST) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4FhDrv2v57zQjXt for ; Fri, 14 May 2021 05:43:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id ij1nUey0ooyW for ; Fri, 14 May 2021 05:43:23 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 May 2021 09:13:10 +0530 Message-Id: <20210514034310.1570-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 7.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: 53A3415F8 X-Rspamd-UID: 291d5d Subject: [FFmpeg-devel] [PATCH] avfilter/guided: simplify subsampling assignment. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: shMdEay9mmSg Reduce option ranges to effective values. --- Will reindent after this is applied. libavfilter/vf_guided.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index e7c689e7be..88bae5ab19 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -61,10 +61,10 @@ typedef struct GuidedContext { static const AVOption guided_options[] = { { "radius", "set the box radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64 = 3 }, 1, 20, FLAGS }, { "eps", "set the regularization parameter (with square)", OFFSET(eps), AV_OPT_TYPE_FLOAT, {.dbl = 0.01 }, 0.0, 1, FLAGS }, - { "mode", "set filtering mode (0: basic mode; 1: fast mode)", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = BASIC}, 0, NB_MODES - 1, FLAGS, "mode" }, + { "mode", "set filtering mode (0: basic mode; 1: fast mode)", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = BASIC}, BASIC, NB_MODES - 1, FLAGS, "mode" }, { "basic", "basic guided filter", 0, AV_OPT_TYPE_CONST, {.i64 = BASIC}, 0, 0, FLAGS, "mode" }, { "fast", "fast guided filter", 0, AV_OPT_TYPE_CONST, {.i64 = FAST }, 0, 0, FLAGS, "mode" }, - { "sub", "subsampling ratio", OFFSET(sub), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, 64, FLAGS }, + { "sub", "subsampling ratio for fast mode", OFFSET(sub), AV_OPT_TYPE_INT, {.i64 = 4 }, 2, 64, FLAGS }, { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=1 }, 0, 0xF, FLAGS }, { NULL } }; @@ -160,24 +160,14 @@ static int config_input(AVFilterLink *inlink) } if (s->mode == BASIC) { - if (s->sub != 1) { - av_log(ctx, AV_LOG_WARNING, "Subsampling ratio is 1 in basic mode.\n"); - s->sub = 1; - } + s->sub = 1; } else if (s->mode == FAST) { - if (s->sub == 1) { - av_log(ctx, AV_LOG_WARNING, "Subsampling ratio is larger than 1 in fast mode.\n"); - s->sub = 4; - } - if (s->radius >= s->sub) - s->radius = s->radius / s->sub; - else { - s->radius = 1; - } - } - else { - return AVERROR_BUG; + if (s->radius >= s->sub) + s->radius = s->radius / s->sub; + else { + s->radius = 1; + } } s->depth = desc->comp[0].depth;