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

Yatendra Singh yatendra1999luffy at gmail.com
Thu Jul 2 02:40:54 EEST 2020


Signed-off-by: Yatendra Singh <yatendra1999luffy at gmail.com>
---
 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);
-- 
2.20.1



More information about the ffmpeg-devel mailing list