diff mbox series

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

Message ID 20200701234055.5676-1-yatendra1999luffy@gmail.com
State New
Headers show
Series [FFmpeg-devel,ffmpeg-devel,GSoC,1/2] libavfilter/vf_colorconstancy.c : Cleanup code for new filter
Related show

Checks

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

Commit Message

Yatendra Singh July 1, 2020, 11:40 p.m. UTC
Signed-off-by: Yatendra Singh <yatendra1999luffy@gmail.com>
---
 libavfilter/vf_colorconstancy.c | 46 ++++++++++-----------------------
 1 file changed, 13 insertions(+), 33 deletions(-)
diff mbox series

Patch

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);