From dcfc3df5d17801e159abf3919c153ce3744830b6 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 24 Jul 2014 14:37:54 +0200 Subject: [PATCH] v4l2-ctl: fix csc colorbar color pre-calculation Colors not belonging to the CSC colorbar should just be accepted as is. The contrast color for the CSC colorbar should be suitable for CSC conversion as well. Signed-off-by: Hans Verkuil --- utils/v4l2-ctl/vivid-tpg.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/utils/v4l2-ctl/vivid-tpg.c b/utils/v4l2-ctl/vivid-tpg.c index 41fc196..d051eaf 100644 --- a/utils/v4l2-ctl/vivid-tpg.c +++ b/utils/v4l2-ctl/vivid-tpg.c @@ -467,7 +467,7 @@ static void precalculate_color(struct tpg_data *tpg, int k) r = g = b = k - TPG_COLOR_RAMP; } - if (tpg->pattern == TPG_PAT_CSC_COLORBAR) { + if (tpg->pattern == TPG_PAT_CSC_COLORBAR && col <= TPG_COLOR_CSC_BLACK) { r = tpg_csc_colors[tpg->colorspace][col].r; g = tpg_csc_colors[tpg->colorspace][col].g; b = tpg_csc_colors[tpg->colorspace][col].b; @@ -876,12 +876,23 @@ static void tpg_calculate_square_border(struct tpg_data *tpg) static void tpg_precalculate_line(struct tpg_data *tpg) { - enum tpg_color contrast = tpg->pattern == TPG_PAT_GREEN ? - TPG_COLOR_100_RED : TPG_COLOR_100_GREEN; + enum tpg_color contrast; unsigned pat; unsigned p; unsigned x; + switch (tpg->pattern) { + case TPG_PAT_GREEN: + contrast = TPG_COLOR_100_RED; + break; + case TPG_PAT_CSC_COLORBAR: + contrast = TPG_COLOR_CSC_GREEN; + break; + default: + contrast = TPG_COLOR_100_GREEN; + break; + } + for (pat = 0; pat < tpg_get_pat_lines(tpg); pat++) { /* Coarse scaling with Bresenham */ unsigned int_part = tpg->src_width / tpg->scaled_width; -- 2.7.4