I was going through the code, and I realized that I have made a mistake. I have corrected the code, and attached the corresponding patch.
From 2ebd299b55a34914d5549f21d264e8cb7f5f605d Mon Sep 17 00:00:00 2001 From: Arwa Arif <arwaarif1...@gmail.com> Date: Mon, 9 Mar 2015 19:50:32 +0530 Subject: [PATCH] Fix the wrong parsing style in vf_eq
blah --- libavfilter/vf_eq.c | 33 ++++++++++++++++----------------- libavfilter/vf_eq.h | 34 ++++++++-------------------------- 2 files changed, 24 insertions(+), 43 deletions(-) diff --git a/libavfilter/vf_eq.c b/libavfilter/vf_eq.c index 980e9ca..816c734 100644 --- a/libavfilter/vf_eq.c +++ b/libavfilter/vf_eq.c @@ -111,16 +111,16 @@ static void check_values(EQParameters *param, EQContext *eq) static void set_contrast(EQContext *eq) { - eq->var_values[VAR_CONTRAST] = av_clipf(av_expr_eval(eq->contrast_pexpr, eq->var_values, eq),-2.0, 2.0); - eq->param[0].contrast = eq->var_values[VAR_CONTRAST]; + eq->contrast = av_clipf(av_expr_eval(eq->contrast_pexpr, NULL, eq),-2.0, 2.0); + eq->param[0].contrast = eq->contrast; eq->param[0].lut_clean = 0; check_values(&eq->param[0], eq); } static void set_brightness(EQContext *eq) { - eq->var_values[VAR_BRIGHTNESS] = av_clipf(av_expr_eval(eq->brightness_pexpr, eq->var_values, eq), -1.0, 1.0); - eq->param[0].brightness = eq->var_values[VAR_BRIGHTNESS]; + eq->brightness = av_clipf(av_expr_eval(eq->brightness_pexpr, NULL, eq), -1.0, 1.0); + eq->param[0].brightness = eq->brightness; eq->param[0].lut_clean = 0; check_values(&eq->param[0], eq); } @@ -129,18 +129,18 @@ static void set_gamma(EQContext *eq) { int i; - eq->var_values[VAR_GAMMA] = av_clipf(av_expr_eval(eq->gamma_pexpr, eq->var_values, eq), 0.1, 10.0); - eq->var_values[VAR_GAMMA_R] = av_clipf(av_expr_eval(eq->gamma_r_pexpr, eq->var_values, eq), 0.1, 10.0); - eq->var_values[VAR_GAMMA_G] = av_clipf(av_expr_eval(eq->gamma_g_pexpr, eq->var_values, eq), 0.1, 10.0); - eq->var_values[VAR_GAMMA_B] = av_clipf(av_expr_eval(eq->gamma_b_pexpr, eq->var_values, eq), 0.1, 10.0); - eq->var_values[VAR_GAMMA_WEIGHT] = av_clipf(av_expr_eval(eq->gamma_weight_pexpr, eq->var_values, eq), 0.0, 1.0); + eq->gamma = av_clipf(av_expr_eval(eq->gamma_pexpr, NULL, eq), 0.1, 10.0); + eq->gamma_r = av_clipf(av_expr_eval(eq->gamma_r_pexpr, NULL, eq), 0.1, 10.0); + eq->gamma_g = av_clipf(av_expr_eval(eq->gamma_g_pexpr, NULL, eq), 0.1, 10.0); + eq->gamma_b = av_clipf(av_expr_eval(eq->gamma_b_pexpr, NULL, eq), 0.1, 10.0); + eq->gamma_weight = av_clipf(av_expr_eval(eq->gamma_weight_pexpr, NULL, eq), 0.0, 1.0); - eq->param[0].gamma = eq->var_values[VAR_GAMMA] * eq->var_values[VAR_GAMMA_G]; - eq->param[1].gamma = sqrt(eq->var_values[VAR_GAMMA_B] / eq->var_values[VAR_GAMMA_G]); - eq->param[2].gamma = sqrt(eq->var_values[VAR_GAMMA_R] / eq->var_values[VAR_GAMMA_G]); + eq->param[0].gamma = eq->gamma * eq->gamma_g; + eq->param[1].gamma = sqrt(eq->gamma_b / eq->gamma_g); + eq->param[2].gamma = sqrt(eq->gamma_r / eq->gamma_g); for (i = 0; i < 3; i++) { - eq->param[i].gamma_weight = eq->var_values[VAR_GAMMA_WEIGHT]; + eq->param[i].gamma_weight = eq->gamma_weight; eq->param[i].lut_clean = 0; check_values(&eq->param[i], eq); } @@ -150,10 +150,10 @@ static void set_saturation(EQContext *eq) { int i; - eq->var_values[VAR_SATURATION] = av_clipf(av_expr_eval(eq->saturation_pexpr, eq->var_values, eq), 0.0, 3.0); + eq->saturation = av_clipf(av_expr_eval(eq->saturation_pexpr, NULL, eq), 0.0, 3.0); for (i = 1; i < 3; i++) { - eq->param[i].contrast = eq->var_values[VAR_SATURATION]; + eq->param[i].contrast = eq->saturation; eq->param[i].lut_clean = 0; check_values(&eq->param[i], eq); } @@ -166,8 +166,7 @@ static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void * if (*pexpr) old = *pexpr; - ret = av_expr_parse(pexpr, expr, var_names, - NULL, NULL, NULL, NULL, 0, log_ctx); + ret = av_expr_parse(pexpr, expr, NULL, NULL, NULL, NULL, NULL, 0, log_ctx); if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s' for %s\n", diff --git a/libavfilter/vf_eq.h b/libavfilter/vf_eq.h index fe9c09c..f036664 100644 --- a/libavfilter/vf_eq.h +++ b/libavfilter/vf_eq.h @@ -28,30 +28,6 @@ #include "avfilter.h" #include "libavutil/eval.h" -static const char * const var_names[] = { - "contrast", - "brightness", - "saturation", - "gamma", - "gamma_weight", - "gamma_r", - "gamma_g", - "gamma_b", - NULL -}; - -enum var_name { - VAR_CONTRAST , - VAR_BRIGHTNESS , - VAR_SATURATION , - VAR_GAMMA , - VAR_GAMMA_WEIGHT , - VAR_GAMMA_R , - VAR_GAMMA_G , - VAR_GAMMA_B , - VAR_VARS_NB , -}; - typedef struct EQParameters { void (*adjust)(struct EQParameters *eq, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h); @@ -70,29 +46,35 @@ typedef struct { char *contrast_expr; AVExpr *contrast_pexpr; + double contrast; char *brightness_expr; AVExpr *brightness_pexpr; + double brightness; char *saturation_expr; AVExpr *saturation_pexpr; + double saturation; char *gamma_expr; AVExpr *gamma_pexpr; + double gamma; char *gamma_weight_expr; AVExpr *gamma_weight_pexpr; + double gamma_weight; char *gamma_r_expr; AVExpr *gamma_r_pexpr; + double gamma_r; char *gamma_g_expr; AVExpr *gamma_g_pexpr; + double gamma_g; char *gamma_b_expr; AVExpr *gamma_b_pexpr; - - double var_values[VAR_VARS_NB]; + double gamma_b; void (*process)(struct EQParameters *par, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h); -- 1.7.9.5
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel