From patchwork Wed Jul 1 23:40:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yatendra Singh X-Patchwork-Id: 20771 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 ABF8B44BCD3 for ; Thu, 2 Jul 2020 03:07:55 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7495568A821; Thu, 2 Jul 2020 03:07:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vk1-f193.google.com (mail-vk1-f193.google.com [209.85.221.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DAA486881F5 for ; Thu, 2 Jul 2020 03:07:48 +0300 (EEST) Received: by mail-vk1-f193.google.com with SMTP id h190so5898763vkh.6 for ; Wed, 01 Jul 2020 17:07:48 -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:mime-version :content-transfer-encoding; bh=xNaMPiy/RxGyHtZAfTTaHmUpwoNqEaWi7iOGU3fM49s=; b=aPlZcapRj5a9SCIzUqgYjVTct7JWsThFZ5xQnBpTaiYlkn4g7Bw0V2LXTbbvVNlh/U M0SOMHHZsWFH3TBJrlN7MFygeRqIwIFTGC6G6D2lu1pzXy0KjTMGsO5/HOIL44cGpjSX qQJIvuTqE4yHk4CSfmIw9/2dEP7wPTGmz8TYihuj2Or9RgzvX4nE07DVAjqtoHroHgky 8lsQpVBMjOqWE0r3WymgaLr7xrEVgvNZecW6WRummWT1vlBoS3rLzHLNFl1OxWkpdJO+ hxWZkIEUOaG8VYEmdClsfM3hExl/WpZsJ4NqBf8Iwybr322jflZrNRqBQXUdAgyV2nvd KbLQ== 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:mime-version :content-transfer-encoding; bh=xNaMPiy/RxGyHtZAfTTaHmUpwoNqEaWi7iOGU3fM49s=; b=rm4yjgUTe0Az0lr5rnO+NBEPjNZI9iJ0D/xnNyLVC2KKUfp4l9ltZ7GHIRnO0YnfOz gAFkwG3gqRSDl/hw/OJh7BeEHWiZp6Zxiq9QPD1pwNWEax6ABdpw6TNChd+oE3Axxp2E 310SKgPy9pQ+5hMIe6X3Fzs51Q0NeMhWRz65CJLyCMLykMOLSgwg696Qa05o9Z0aNJoc 7bRuOtsmJXAShFEOeYhxkKVHTl24Kveh7eJiFeSnOLg0V+FA6h7cYNV0vo2q9HLiEa91 ODNCQFZAIU6dHhEHcwnIN25+4YHxjompWW8Su50TjbC78ITVJwyxygj8OW93ExU9l1LB HCqw== X-Gm-Message-State: AOAM530Ogqu+88m5r+J1DNS5nKI2SwD0L9PeH+aKucyHWGc3rFXFnLHI sDmzT1up1+a1SmZ0HIrj/dNGAgKUodg= X-Google-Smtp-Source: ABdhPJyUQFhC+cFj5ESv5W3lO9lGqgR5xRYxHEFyi+OFsIE1WNA4cCHrmUeC1oGjbG8KnOONlB0A6g== X-Received: by 2002:a62:7714:: with SMTP id s20mr24594982pfc.270.1593646881263; Wed, 01 Jul 2020 16:41:21 -0700 (PDT) Received: from localhost.localdomain ([223.225.17.69]) by smtp.gmail.com with ESMTPSA id oc6sm6678867pjb.43.2020.07.01.16.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 16:41:20 -0700 (PDT) From: Yatendra Singh To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Jul 2020 05:10:54 +0530 Message-Id: <20200701234055.5676-1-yatendra1999luffy@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [ffmpeg-devel][GSoC][PATCH 1/2] libavfilter/vf_colorconstancy.c : Cleanup code for new filter 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: Yatendra Singh Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Yatendra Singh --- libavfilter/vf_colorconstancy.c | 46 ++++++++++----------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c index eae62204b5..d974317a48 100644 --- a/libavfilter/vf_colorconstancy.c +++ b/libavfilter/vf_colorconstancy.c @@ -552,32 +552,6 @@ static void normalize_light(double *light) } } -/** - * Redirects to corresponding algorithm estimation function and performs normalization - * after estimation. - * - * @param ctx the filter context. - * @param in frame to perfrom estimation on. - * - * @return 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure. - */ -static int illumination_estimation(AVFilterContext *ctx, AVFrame *in) -{ - ColorConstancyContext *s = ctx->priv; - int ret; - - ret = filter_grey_edge(ctx, in); - - av_log(ctx, AV_LOG_DEBUG, "Estimated illumination= %f %f %f\n", - s->white[0], s->white[1], s->white[2]); - normalize_light(s->white); - av_log(ctx, AV_LOG_DEBUG, "Estimated illumination after normalization= %f %f %f\n", - s->white[0], s->white[1], s->white[2]); - - return ret; -} - /** * Performs simple correction via diagonal transformation model. * @@ -682,12 +656,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) int ret; int direct = 0; - ret = illumination_estimation(ctx, in); - if (ret) { - av_frame_free(&in); - return ret; - } - if (av_frame_is_writable(in)) { direct = 1; out = in; @@ -699,7 +667,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } av_frame_copy_props(out, in); } - chromatic_adaptation(ctx, in, out); + + if (!strcmp(ctx->filter->name, GREY_EDGE)) { + ColorConstancyContext *s = ctx->priv; + ret = filter_grey_edge(ctx, in); + + normalize_light(s->white); + + if (ret) { + av_frame_free(&in); + return ret; + } + chromatic_adaptation(ctx, in, out); + } if (!direct) av_frame_free(&in);