Lines Matching +full:test +full:. +full:rgb
3 * Jakob Bornecrantz <jakob@tungstengraphics.com>
5 * Jesse Barnes <jesse.barnes@intel.com>
15 * all copies or substantial portions of the Software.
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * IN THE SOFTWARE.
26 #include <stdint.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
31 #include <drm_fourcc.h>
34 #include <cairo.h>
35 #include <math.h>
38 #include "common.h"
39 #include "format.h"
40 #include "pattern.h"
60 { .y = MAKE_YUV_601_Y(r, g, b), \
61 .u = MAKE_YUV_601_U(r, g, b), \
62 .v = MAKE_YUV_601_V(r, g, b) }
69 /* Fill the low bits with the high bits. */ in shiftcolor8()
82 /* Fill the low bits with the high bits. */ in shiftcolor10()
101 #define MAKE_RGBA10(rgb, r, g, b, a) \ argument
102 (shiftcolor10(&(rgb)->red, (r)) | \
103 shiftcolor10(&(rgb)->green, (g)) | \
104 shiftcolor10(&(rgb)->blue, (b)) | \
105 shiftcolor10(&(rgb)->alpha, (a)))
107 #define MAKE_RGBA(rgb, r, g, b, a) \ argument
108 (shiftcolor8(&(rgb)->red, (r)) | \
109 shiftcolor8(&(rgb)->green, (g)) | \
110 shiftcolor8(&(rgb)->blue, (b)) | \
111 shiftcolor8(&(rgb)->alpha, (a)))
113 #define MAKE_RGB24(rgb, r, g, b) \ argument
114 { .value = MAKE_RGBA(rgb, r, g, b, 0) }
119 * result to fp16 with round-to-zero.
121 * Copied from mesa:src/util/half_float.c
125 /* Zero or subnormal. Set the mantissa to (v << 8) and return. */ in uint16_div_64k_to_half()
138 * = 1.X * 2^(15-n-16) in uint16_div_64k_to_half()
139 * = 1.X * 2^(14-n - 15) in uint16_div_64k_to_half()
147 #define MAKE_RGBA8FP16(rgb, r, g, b, a) \ argument
148 (shiftcolor16(&(rgb)->red, uint16_div_64k_to_half((r) << 8)) | \
149 shiftcolor16(&(rgb)->green, uint16_div_64k_to_half((g) << 8)) | \
150 shiftcolor16(&(rgb)->blue, uint16_div_64k_to_half((b) << 8)) | \
151 shiftcolor16(&(rgb)->alpha, uint16_div_64k_to_half((a) << 8)))
153 #define MAKE_RGBA10FP16(rgb, r, g, b, a) \ argument
154 (shiftcolor16(&(rgb)->red, uint16_div_64k_to_half((r) << 6)) | \
155 shiftcolor16(&(rgb)->green, uint16_div_64k_to_half((g) << 6)) | \
156 shiftcolor16(&(rgb)->blue, uint16_div_64k_to_half((b) << 6)) | \
157 shiftcolor16(&(rgb)->alpha, uint16_div_64k_to_half((a) << 6)))
201 y_mem[x] = colors_top[x * 7 / width].y; in fill_smpte_yuv_planar()
207 y_mem[x] = colors_middle[x * 7 / width].y; in fill_smpte_yuv_planar()
213 y_mem[x] = colors_bottom[x * 4 / (width * 5 / 7)].y; in fill_smpte_yuv_planar()
216 / (width / 7) + 4].y; in fill_smpte_yuv_planar()
218 y_mem[x] = colors_bottom[7].y; in fill_smpte_yuv_planar()
225 u_mem[x*cs/xsub] = colors_top[x * 7 / width].u; in fill_smpte_yuv_planar()
226 v_mem[x*cs/xsub] = colors_top[x * 7 / width].v; in fill_smpte_yuv_planar()
234 u_mem[x*cs/xsub] = colors_middle[x * 7 / width].u; in fill_smpte_yuv_planar()
235 v_mem[x*cs/xsub] = colors_middle[x * 7 / width].v; in fill_smpte_yuv_planar()
244 colors_bottom[x * 4 / (width * 5 / 7)].u; in fill_smpte_yuv_planar()
246 colors_bottom[x * 4 / (width * 5 / 7)].v; in fill_smpte_yuv_planar()
250 3 / (width / 7) + 4].u; in fill_smpte_yuv_planar()
252 3 / (width / 7) + 4].v; in fill_smpte_yuv_planar()
255 u_mem[x*cs/xsub] = colors_bottom[7].u; in fill_smpte_yuv_planar()
256 v_mem[x*cs/xsub] = colors_bottom[7].v; in fill_smpte_yuv_planar()
305 y_mem[2*x] = colors_top[x * 7 / width].y; in fill_smpte_yuv_packed()
311 y_mem[2*x] = colors_middle[x * 7 / width].y; in fill_smpte_yuv_packed()
317 y_mem[2*x] = colors_bottom[x * 4 / (width * 5 / 7)].y; in fill_smpte_yuv_packed()
320 / (width / 7) + 4].y; in fill_smpte_yuv_packed()
322 y_mem[2*x] = colors_bottom[7].y; in fill_smpte_yuv_packed()
329 c_mem[2*x+u] = colors_top[x * 7 / width].u; in fill_smpte_yuv_packed()
330 c_mem[2*x+v] = colors_top[x * 7 / width].v; in fill_smpte_yuv_packed()
337 c_mem[2*x+u] = colors_middle[x * 7 / width].u; in fill_smpte_yuv_packed()
338 c_mem[2*x+v] = colors_middle[x * 7 / width].v; in fill_smpte_yuv_packed()
345 c_mem[2*x+u] = colors_bottom[x * 4 / (width * 5 / 7)].u; in fill_smpte_yuv_packed()
346 c_mem[2*x+v] = colors_bottom[x * 4 / (width * 5 / 7)].v; in fill_smpte_yuv_packed()
350 3 / (width / 7) + 4].u; in fill_smpte_yuv_packed()
352 3 / (width / 7) + 4].v; in fill_smpte_yuv_packed()
355 c_mem[2*x+u] = colors_bottom[7].u; in fill_smpte_yuv_packed()
356 c_mem[2*x+v] = colors_bottom[7].v; in fill_smpte_yuv_packed()
362 static void fill_smpte_rgb16(const struct util_rgb_info *rgb, void *mem, in fill_smpte_rgb16() argument
367 MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */ in fill_smpte_rgb16()
368 MAKE_RGBA(rgb, 192, 192, 0, 255), /* yellow */ in fill_smpte_rgb16()
369 MAKE_RGBA(rgb, 0, 192, 192, 255), /* cyan */ in fill_smpte_rgb16()
370 MAKE_RGBA(rgb, 0, 192, 0, 255), /* green */ in fill_smpte_rgb16()
371 MAKE_RGBA(rgb, 192, 0, 192, 255), /* magenta */ in fill_smpte_rgb16()
372 MAKE_RGBA(rgb, 192, 0, 0, 255), /* red */ in fill_smpte_rgb16()
373 MAKE_RGBA(rgb, 0, 0, 192, 255), /* blue */ in fill_smpte_rgb16()
376 MAKE_RGBA(rgb, 0, 0, 192, 127), /* blue */ in fill_smpte_rgb16()
377 MAKE_RGBA(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb16()
378 MAKE_RGBA(rgb, 192, 0, 192, 127), /* magenta */ in fill_smpte_rgb16()
379 MAKE_RGBA(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb16()
380 MAKE_RGBA(rgb, 0, 192, 192, 127), /* cyan */ in fill_smpte_rgb16()
381 MAKE_RGBA(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb16()
382 MAKE_RGBA(rgb, 192, 192, 192, 127), /* grey */ in fill_smpte_rgb16()
385 MAKE_RGBA(rgb, 0, 33, 76, 255), /* in-phase */ in fill_smpte_rgb16()
386 MAKE_RGBA(rgb, 255, 255, 255, 255), /* super white */ in fill_smpte_rgb16()
387 MAKE_RGBA(rgb, 50, 0, 106, 255), /* quadrature */ in fill_smpte_rgb16()
388 MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ in fill_smpte_rgb16()
389 MAKE_RGBA(rgb, 9, 9, 9, 255), /* 3.5% */ in fill_smpte_rgb16()
390 MAKE_RGBA(rgb, 19, 19, 19, 255), /* 7.5% */ in fill_smpte_rgb16()
391 MAKE_RGBA(rgb, 29, 29, 29, 255), /* 11.5% */ in fill_smpte_rgb16()
392 MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ in fill_smpte_rgb16()
423 static void fill_smpte_rgb24(const struct util_rgb_info *rgb, void *mem, in fill_smpte_rgb24() argument
428 MAKE_RGB24(rgb, 192, 192, 192), /* grey */ in fill_smpte_rgb24()
429 MAKE_RGB24(rgb, 192, 192, 0), /* yellow */ in fill_smpte_rgb24()
430 MAKE_RGB24(rgb, 0, 192, 192), /* cyan */ in fill_smpte_rgb24()
431 MAKE_RGB24(rgb, 0, 192, 0), /* green */ in fill_smpte_rgb24()
432 MAKE_RGB24(rgb, 192, 0, 192), /* magenta */ in fill_smpte_rgb24()
433 MAKE_RGB24(rgb, 192, 0, 0), /* red */ in fill_smpte_rgb24()
434 MAKE_RGB24(rgb, 0, 0, 192), /* blue */ in fill_smpte_rgb24()
437 MAKE_RGB24(rgb, 0, 0, 192), /* blue */ in fill_smpte_rgb24()
438 MAKE_RGB24(rgb, 19, 19, 19), /* black */ in fill_smpte_rgb24()
439 MAKE_RGB24(rgb, 192, 0, 192), /* magenta */ in fill_smpte_rgb24()
440 MAKE_RGB24(rgb, 19, 19, 19), /* black */ in fill_smpte_rgb24()
441 MAKE_RGB24(rgb, 0, 192, 192), /* cyan */ in fill_smpte_rgb24()
442 MAKE_RGB24(rgb, 19, 19, 19), /* black */ in fill_smpte_rgb24()
443 MAKE_RGB24(rgb, 192, 192, 192), /* grey */ in fill_smpte_rgb24()
446 MAKE_RGB24(rgb, 0, 33, 76), /* in-phase */ in fill_smpte_rgb24()
447 MAKE_RGB24(rgb, 255, 255, 255), /* super white */ in fill_smpte_rgb24()
448 MAKE_RGB24(rgb, 50, 0, 106), /* quadrature */ in fill_smpte_rgb24()
449 MAKE_RGB24(rgb, 19, 19, 19), /* black */ in fill_smpte_rgb24()
450 MAKE_RGB24(rgb, 9, 9, 9), /* 3.5% */ in fill_smpte_rgb24()
451 MAKE_RGB24(rgb, 19, 19, 19), /* 7.5% */ in fill_smpte_rgb24()
452 MAKE_RGB24(rgb, 29, 29, 29), /* 11.5% */ in fill_smpte_rgb24()
453 MAKE_RGB24(rgb, 19, 19, 19), /* black */ in fill_smpte_rgb24()
486 static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem, in fill_smpte_rgb32() argument
491 MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */ in fill_smpte_rgb32()
492 MAKE_RGBA(rgb, 192, 192, 0, 255), /* yellow */ in fill_smpte_rgb32()
493 MAKE_RGBA(rgb, 0, 192, 192, 255), /* cyan */ in fill_smpte_rgb32()
494 MAKE_RGBA(rgb, 0, 192, 0, 255), /* green */ in fill_smpte_rgb32()
495 MAKE_RGBA(rgb, 192, 0, 192, 255), /* magenta */ in fill_smpte_rgb32()
496 MAKE_RGBA(rgb, 192, 0, 0, 255), /* red */ in fill_smpte_rgb32()
497 MAKE_RGBA(rgb, 0, 0, 192, 255), /* blue */ in fill_smpte_rgb32()
500 MAKE_RGBA(rgb, 0, 0, 192, 127), /* blue */ in fill_smpte_rgb32()
501 MAKE_RGBA(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb32()
502 MAKE_RGBA(rgb, 192, 0, 192, 127), /* magenta */ in fill_smpte_rgb32()
503 MAKE_RGBA(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb32()
504 MAKE_RGBA(rgb, 0, 192, 192, 127), /* cyan */ in fill_smpte_rgb32()
505 MAKE_RGBA(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb32()
506 MAKE_RGBA(rgb, 192, 192, 192, 127), /* grey */ in fill_smpte_rgb32()
509 MAKE_RGBA(rgb, 0, 33, 76, 255), /* in-phase */ in fill_smpte_rgb32()
510 MAKE_RGBA(rgb, 255, 255, 255, 255), /* super white */ in fill_smpte_rgb32()
511 MAKE_RGBA(rgb, 50, 0, 106, 255), /* quadrature */ in fill_smpte_rgb32()
512 MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ in fill_smpte_rgb32()
513 MAKE_RGBA(rgb, 9, 9, 9, 255), /* 3.5% */ in fill_smpte_rgb32()
514 MAKE_RGBA(rgb, 19, 19, 19, 255), /* 7.5% */ in fill_smpte_rgb32()
515 MAKE_RGBA(rgb, 29, 29, 29, 255), /* 11.5% */ in fill_smpte_rgb32()
516 MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ in fill_smpte_rgb32()
547 static void fill_smpte_rgb16fp(const struct util_rgb_info *rgb, void *mem, in fill_smpte_rgb16fp() argument
552 MAKE_RGBA8FP16(rgb, 192, 192, 192, 255),/* grey */ in fill_smpte_rgb16fp()
553 MAKE_RGBA8FP16(rgb, 192, 192, 0, 255), /* yellow */ in fill_smpte_rgb16fp()
554 MAKE_RGBA8FP16(rgb, 0, 192, 192, 255), /* cyan */ in fill_smpte_rgb16fp()
555 MAKE_RGBA8FP16(rgb, 0, 192, 0, 255), /* green */ in fill_smpte_rgb16fp()
556 MAKE_RGBA8FP16(rgb, 192, 0, 192, 255), /* magenta */ in fill_smpte_rgb16fp()
557 MAKE_RGBA8FP16(rgb, 192, 0, 0, 255), /* red */ in fill_smpte_rgb16fp()
558 MAKE_RGBA8FP16(rgb, 0, 0, 192, 255), /* blue */ in fill_smpte_rgb16fp()
561 MAKE_RGBA8FP16(rgb, 0, 0, 192, 127), /* blue */ in fill_smpte_rgb16fp()
562 MAKE_RGBA8FP16(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb16fp()
563 MAKE_RGBA8FP16(rgb, 192, 0, 192, 127), /* magenta */ in fill_smpte_rgb16fp()
564 MAKE_RGBA8FP16(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb16fp()
565 MAKE_RGBA8FP16(rgb, 0, 192, 192, 127), /* cyan */ in fill_smpte_rgb16fp()
566 MAKE_RGBA8FP16(rgb, 19, 19, 19, 127), /* black */ in fill_smpte_rgb16fp()
567 MAKE_RGBA8FP16(rgb, 192, 192, 192, 127),/* grey */ in fill_smpte_rgb16fp()
570 MAKE_RGBA8FP16(rgb, 0, 33, 76, 255), /* in-phase */ in fill_smpte_rgb16fp()
571 MAKE_RGBA8FP16(rgb, 255, 255, 255, 255),/* super white */ in fill_smpte_rgb16fp()
572 MAKE_RGBA8FP16(rgb, 50, 0, 106, 255), /* quadrature */ in fill_smpte_rgb16fp()
573 MAKE_RGBA8FP16(rgb, 19, 19, 19, 255), /* black */ in fill_smpte_rgb16fp()
574 MAKE_RGBA8FP16(rgb, 9, 9, 9, 255), /* 3.5% */ in fill_smpte_rgb16fp()
575 MAKE_RGBA8FP16(rgb, 19, 19, 19, 255), /* 7.5% */ in fill_smpte_rgb16fp()
576 MAKE_RGBA8FP16(rgb, 29, 29, 29, 255), /* 11.5% */ in fill_smpte_rgb16fp()
577 MAKE_RGBA8FP16(rgb, 19, 19, 19, 255), /* black */ in fill_smpte_rgb16fp()
649 lut[idx].red = (r) << 8; \ in util_smpte_c8_gamma()
650 lut[idx].green = (g) << 8; \ in util_smpte_c8_gamma()
651 lut[idx].blue = (b) << 8 in util_smpte_c8_gamma()
701 u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1; in fill_smpte()
702 v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1; in fill_smpte()
732 return fill_smpte_rgb16(&info->rgb, planes[0], in fill_smpte()
737 return fill_smpte_rgb24(&info->rgb, planes[0], in fill_smpte()
755 return fill_smpte_rgb32(&info->rgb, planes[0], in fill_smpte()
762 return fill_smpte_rgb16fp(&info->rgb, planes[0], in fill_smpte()
767 /* swap these for big endian.. */
857 uint32_t rgb32 = 0x00130502 * (d.quot >> 6) in fill_tiles_yuv_planar()
858 + 0x000a1120 * (d.rem >> 6); in fill_tiles_yuv_planar()
863 y_mem[x] = color.y; in fill_tiles_yuv_planar()
864 u_mem[x/xsub*cs] = color.u; in fill_tiles_yuv_planar()
865 v_mem[x/xsub*cs] = color.v; in fill_tiles_yuv_planar()
891 uint32_t rgb32 = 0x00130502 * (d.quot >> 6) in fill_tiles_yuv_packed()
892 + 0x000a1120 * (d.rem >> 6); in fill_tiles_yuv_packed()
897 y_mem[2*x] = color.y; in fill_tiles_yuv_packed()
898 c_mem[2*x+u] = color.u; in fill_tiles_yuv_packed()
899 y_mem[2*x+2] = color.y; in fill_tiles_yuv_packed()
900 c_mem[2*x+v] = color.v; in fill_tiles_yuv_packed()
912 const struct util_rgb_info *rgb = &info->rgb; in fill_tiles_rgb16() local
919 uint32_t rgb32 = 0x00130502 * (d.quot >> 6) in fill_tiles_rgb16()
920 + 0x000a1120 * (d.rem >> 6); in fill_tiles_rgb16()
922 MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff, in fill_tiles_rgb16()
938 const struct util_rgb_info *rgb = &info->rgb; in fill_tiles_rgb24() local
944 uint32_t rgb32 = 0x00130502 * (d.quot >> 6) in fill_tiles_rgb24()
945 + 0x000a1120 * (d.rem >> 6); in fill_tiles_rgb24()
947 MAKE_RGB24(rgb, (rgb32 >> 16) & 0xff, in fill_tiles_rgb24()
960 const struct util_rgb_info *rgb = &info->rgb; in fill_tiles_rgb32() local
967 uint32_t rgb32 = 0x00130502 * (d.quot >> 6) in fill_tiles_rgb32()
968 + 0x000a1120 * (d.rem >> 6); in fill_tiles_rgb32()
971 MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff, in fill_tiles_rgb32()
987 const struct util_rgb_info *rgb = &info->rgb; in fill_tiles_rgb16fp() local
994 uint32_t rgb32 = 0x00130502 * (d.quot >> 6) in fill_tiles_rgb16fp()
995 + 0x000a1120 * (d.rem >> 6); in fill_tiles_rgb16fp()
998 MAKE_RGBA8FP16(rgb, (rgb32 >> 16) & 0xff, in fill_tiles_rgb16fp()
1026 u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1; in fill_tiles()
1027 v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1; in fill_tiles()
1110 static void fill_gradient_rgb32(const struct util_rgb_info *rgb, in fill_gradient_rgb32() argument
1121 uint32_t value = MAKE_RGBA10(rgb, j & 0x3ff, j & 0x3ff, j & 0x3ff, 0); in fill_gradient_rgb32()
1131 uint32_t value = MAKE_RGBA10(rgb, j & 0x3fc, j & 0x3fc, j & 0x3fc, 0); in fill_gradient_rgb32()
1138 static void fill_gradient_rgb16fp(const struct util_rgb_info *rgb, in fill_gradient_rgb16fp() argument
1149 uint64_t value = MAKE_RGBA10FP16(rgb, j & 0x3ff, j & 0x3ff, j & 0x3ff, 0); in fill_gradient_rgb16fp()
1159 uint64_t value = MAKE_RGBA10FP16(rgb, j & 0x3fc, j & 0x3fc, j & 0x3fc, 0); in fill_gradient_rgb16fp()
1167 * into two halves. The top half has 10bpc precision, the bottom half
1168 * has 8bpc precision. When using with a 10bpc fb format, there are 3
1171 * - Pixel data is encoded as 8bpc to the display, no dithering. This
1172 * would lead to the top and bottom halves looking identical.
1174 * - Pixel data is encoded as 8bpc to the display, with dithering. This
1176 * but the top half would look a little speck-y due to the dithering.
1179 * the display is able to show this level of depth). This should
1181 * from the bottom half.
1184 * to distinguish even higher bpc precisions.
1188 * wide for each gradient color. Otherwise the difference may be a bit
1189 * hard to notice.
1212 return fill_gradient_rgb32(&info->rgb, planes[0], in fill_gradient()
1219 return fill_gradient_rgb16fp(&info->rgb, planes[0], in fill_gradient()
1225 * util_fill_pattern - Fill a buffer with a test pattern
1227 * @pattern: Test pattern
1233 * Fill the buffers with the test pattern specified by the pattern parameter.
1234 * Supported formats vary depending on the selected pattern.
1260 printf("Error: unsupported test pattern %u.\n", pattern); in util_fill_pattern()
1280 printf("Error: unsupported test pattern %s.\n", name); in util_pattern_enum()