]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] vivid: Local optimization
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Sat, 16 Jul 2016 09:34:19 +0000 (06:34 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 21 Oct 2016 17:51:23 +0000 (15:51 -0200)
Avoid duplicated clamps when possible.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c

index 7364ced09abc058f733545ce173217b1cb5dd005..ed37ae307caca1e6f1cf3a3733d10e4334ed8cd3 100644 (file)
@@ -916,14 +916,18 @@ static void precalculate_color(struct tpg_data *tpg, int k)
                if (!ycbcr_valid)
                        color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr);
 
+               y >>= 4;
+               cb >>= 4;
+               cr >>= 4;
                if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
-                       y = clamp(y, 16 << 4, 235 << 4);
-                       cb = clamp(cb, 16 << 4, 240 << 4);
-                       cr = clamp(cr, 16 << 4, 240 << 4);
+                       y = clamp(y, 16, 235);
+                       cb = clamp(cb, 16, 240);
+                       cr = clamp(cr, 16, 240);
+               } else {
+                       y = clamp(y, 1, 254);
+                       cb = clamp(cb, 1, 254);
+                       cr = clamp(cr, 1, 254);
                }
-               y = clamp(y >> 4, 1, 254);
-               cb = clamp(cb >> 4, 1, 254);
-               cr = clamp(cr >> 4, 1, 254);
                switch (tpg->fourcc) {
                case V4L2_PIX_FMT_YUV444:
                        y >>= 4;