util: improve SMPTE color LUT accuracy
authorGeert Uytterhoeven <geert@linux-m68k.org>
Thu, 30 Jun 2022 13:16:23 +0000 (15:16 +0200)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Tue, 24 Oct 2023 07:43:30 +0000 (09:43 +0200)
Fill in the LSB when converting color components from 8-bit to 16-bit.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
  - Add Reviewed-by,

v4:
  - No changes,

v3:
  - Add Acked-by,

v2:
  - New.

tests/util/pattern.c

index bd0989e..7d4f661 100644 (file)
@@ -646,9 +646,9 @@ void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut)
        memset(lut, 0, size * sizeof(struct drm_color_lut));
 
 #define FILL_COLOR(idx, r, g, b) \
-       lut[idx].red = (r) << 8; \
-       lut[idx].green = (g) << 8; \
-       lut[idx].blue = (b) << 8
+       lut[idx].red = (r) * 0x101; \
+       lut[idx].green = (g) * 0x101; \
+       lut[idx].blue = (b) * 0x101
 
        FILL_COLOR( 0, 192, 192, 192);  /* grey */
        FILL_COLOR( 1, 192, 192, 0  );  /* yellow */