[FFmpeg-devel,3/4] lavfi/procamp_vaapi: fix the green output issue.

Submitted by Jun Zhao on Jan. 23, 2018, 4:33 a.m.

Details

Message ID f6d9a0ca-4dd9-f740-eada-9d8e7466aec2@gmail.com
State New
Headers show

Commit Message

Jun Zhao Jan. 23, 2018, 4:33 a.m.
From ccfaaee784b2d2d25f3f71eda1e39a368d7611f5 Mon Sep 17 00:00:00 2001
From: Jun Zhao <jun.zhao@intel.com>
Date: Tue, 23 Jan 2018 11:26:54 +0800
Subject: [PATCH 3/4] lavfi/procamp_vaapi: fix the green output issue.

Fix the green output issue when use procamp_vaapi without any
arguments, and fix the typo.

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
---
 libavfilter/vf_procamp_vaapi.c | 81 +++++++++++++++++++-----------------------
 1 file changed, 36 insertions(+), 45 deletions(-)

Comments

Carl Eugen Hoyos Jan. 23, 2018, 11:52 p.m.
2018-01-23 5:33 GMT+01:00 Jun Zhao <mypopydev@gmail.com>:

> -        procamp_params[i].type   = VAProcFilterColorBalance;

> +    procamp_params[i].type   = VAProcFilterColorBalance;

Please split this patch, so that functional change and re-indentation
of a large block do not happen in the same patch: This not only
makes reviewing easier, it also simplifies understanding the
patch at a later time.

While there, I suggest you post one patch to change the typos
in all files without non-typo changes.

Carl Eugen
Jun Zhao Jan. 24, 2018, 12:31 a.m.
On 2018/1/24 7:52, Carl Eugen Hoyos wrote:
> 2018-01-23 5:33 GMT+01:00 Jun Zhao <mypopydev@gmail.com>:
>
>> -        procamp_params[i].type   = VAProcFilterColorBalance;
>> +    procamp_params[i].type   = VAProcFilterColorBalance;
> Please split this patch, so that functional change and re-indentation
> of a large block do not happen in the same patch: This not only
> makes reviewing easier, it also simplifies understanding the
> patch at a later time.
>
> While there, I suggest you post one patch to change the typos
> in all files without non-typo changes.
Thanks the suggestion and comments, carl, will submit V2 follow.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
index 10f9a6ba0c..f692a52f51 100644
--- a/libavfilter/vf_procamp_vaapi.c
+++ b/libavfilter/vf_procamp_vaapi.c
@@ -44,10 +44,8 @@ 
 #define SATURATION_MAX       10.0F
 #define SATURATION_DEFAULT    1.0F
 
-#define EPSILON               0.00001F
-
 typedef struct ProcampVAAPIContext {
-    VAAPIVPPContext vpp_ctx; // must be the first fileld
+    VAAPIVPPContext vpp_ctx; // must be the first field
 
     float bright;
     float hue;
@@ -65,11 +63,6 @@  static float map(float x, float in_min, float in_max, float out_min, float out_m
     return (float)output;
 }
 
-static int fequal(float a, float b)
-{
-    return fabs(a-b) < EPSILON;
-}
-
 static int procamp_vaapi_build_filter_params(AVFilterContext *avctx)
 {
     VAAPIVPPContext *vpp_ctx = avctx->priv;
@@ -93,41 +86,37 @@  static int procamp_vaapi_build_filter_params(AVFilterContext *avctx)
         return AVERROR(EIO);
     }
 
-    if (!fequal(ctx->bright, BRIGHTNESS_DEFAULT)) {
-        procamp_params[i].type   = VAProcFilterColorBalance;
-        procamp_params[i].attrib = VAProcColorBalanceBrightness;
-        procamp_params[i].value  = map(ctx->bright, BRIGHTNESS_MIN, BRIGHTNESS_MAX,
-                                       procamp_caps[VAProcColorBalanceBrightness-1].range.min_value,
-                                       procamp_caps[VAProcColorBalanceBrightness-1].range.max_value);
-        i++;
-    }
-
-    if (!fequal(ctx->contrast, CONTRAST_DEFAULT)) {
-        procamp_params[i].type   = VAProcFilterColorBalance;
-        procamp_params[i].attrib = VAProcColorBalanceContrast;
-        procamp_params[i].value  = map(ctx->contrast, CONTRAST_MIN, CONTRAST_MAX,
-                                       procamp_caps[VAProcColorBalanceContrast-1].range.min_value,
-                                       procamp_caps[VAProcColorBalanceContrast-1].range.max_value);
-        i++;
-    }
-
-    if (!fequal(ctx->hue, HUE_DEFAULT)) {
-        procamp_params[i].type   = VAProcFilterColorBalance;
-        procamp_params[i].attrib = VAProcColorBalanceHue;
-        procamp_params[i].value  = map(ctx->hue, HUE_MIN, HUE_MAX,
-                                       procamp_caps[VAProcColorBalanceHue-1].range.min_value,
-                                       procamp_caps[VAProcColorBalanceHue-1].range.max_value);
-        i++;
-    }
-
-    if (!fequal(ctx->saturation, SATURATION_DEFAULT)) {
-        procamp_params[i].type   = VAProcFilterColorBalance;
-        procamp_params[i].attrib = VAProcColorBalanceSaturation;
-        procamp_params[i].value  = map(ctx->saturation, SATURATION_MIN, SATURATION_MAX,
-                                       procamp_caps[VAProcColorBalanceSaturation-1].range.min_value,
-                                       procamp_caps[VAProcColorBalanceSaturation-1].range.max_value);
-        i++;
-    }
+    /* brightness */
+    procamp_params[i].type   = VAProcFilterColorBalance;
+    procamp_params[i].attrib = VAProcColorBalanceBrightness;
+    procamp_params[i].value  = map(ctx->bright, BRIGHTNESS_MIN, BRIGHTNESS_MAX,
+                                   procamp_caps[VAProcColorBalanceBrightness-1].range.min_value,
+                                   procamp_caps[VAProcColorBalanceBrightness-1].range.max_value);
+    i++;
+
+    /* contrast */
+    procamp_params[i].type   = VAProcFilterColorBalance;
+    procamp_params[i].attrib = VAProcColorBalanceContrast;
+    procamp_params[i].value  = map(ctx->contrast, CONTRAST_MIN, CONTRAST_MAX,
+                                   procamp_caps[VAProcColorBalanceContrast-1].range.min_value,
+                                   procamp_caps[VAProcColorBalanceContrast-1].range.max_value);
+    i++;
+
+    /* hue */
+    procamp_params[i].type   = VAProcFilterColorBalance;
+    procamp_params[i].attrib = VAProcColorBalanceHue;
+    procamp_params[i].value  = map(ctx->hue, HUE_MIN, HUE_MAX,
+                                   procamp_caps[VAProcColorBalanceHue-1].range.min_value,
+                                   procamp_caps[VAProcColorBalanceHue-1].range.max_value);
+    i++;
+
+    /* saturation */
+    procamp_params[i].type   = VAProcFilterColorBalance;
+    procamp_params[i].attrib = VAProcColorBalanceSaturation;
+    procamp_params[i].value  = map(ctx->saturation, SATURATION_MIN, SATURATION_MAX,
+                                   procamp_caps[VAProcColorBalanceSaturation-1].range.min_value,
+                                   procamp_caps[VAProcColorBalanceSaturation-1].range.max_value);
+    i++;
 
     return ff_vaapi_vpp_make_param_buffers(avctx,
                                            VAProcFilterParameterBufferType,
@@ -188,8 +177,10 @@  static int procamp_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame
     params.pipeline_flags = 0;
     params.filter_flags = VA_FRAME_PICTURE;
 
-    params.filters     = &vpp_ctx->filter_buffers[0];
-    params.num_filters = 1;
+    if (vpp_ctx->nb_filter_buffers) {
+        params.filters     = &vpp_ctx->filter_buffers[0];
+        params.num_filters = vpp_ctx->nb_filter_buffers;
+    }
 
     err = ff_vaapi_vpp_render_picture(avctx, &params, output_surface);
     if (err < 0)