diff mbox series

[FFmpeg-devel,1/2] libavfilter/vf_colorconstancy.c : Cleanup code for new filter

Message ID 20200618135256.5949-1-yatendra1999luffy@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,1/2] libavfilter/vf_colorconstancy.c : Cleanup code for new filter | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Yatendra Singh June 18, 2020, 1:52 p.m. UTC
Signed-off-by: Yatendra Singh <yatendra1999luffy@gmail.com>
---
 libavfilter/vf_colorconstancy.c | 47 ++++++++++-----------------------
 1 file changed, 14 insertions(+), 33 deletions(-)

Comments

Mina June 28, 2020, 12:21 p.m. UTC | #1
On 6/18/20 3:52 PM, Yatendra Singh wrote:
> Signed-off-by: Yatendra Singh <yatendra1999luffy@gmail.com>
> ---
>   libavfilter/vf_colorconstancy.c | 47 ++++++++++-----------------------
>   1 file changed, 14 insertions(+), 33 deletions(-)
LGTM
Moritz Barsnick June 29, 2020, 11:41 a.m. UTC | #2
On Thu, Jun 18, 2020 at 19:22:55 +0530, Yatendra Singh wrote:
> +    if(!strcmp(ctx->filter->name, GREY_EDGE))
> +    {

Code style.
  => if (! .....) {

Moritz
diff mbox series

Patch

diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index eae62204b5..d36400bd35 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,20 @@  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);