MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / generate_test_pattern

Function generate_test_pattern

deps/SDL2/test/testyuv.c:34–72  ·  view source on GitHub ↗

Create a surface with a good pattern for verifying YUV conversion */

Source from the content-addressed store, hash-verified

32
33/* Create a surface with a good pattern for verifying YUV conversion */
34static SDL_Surface *generate_test_pattern(int pattern_size)
35{
36 SDL_Surface *pattern = SDL_CreateRGBSurfaceWithFormat(0, pattern_size, pattern_size, 0, SDL_PIXELFORMAT_RGB24);
37
38 if (pattern) {
39 int i, x, y;
40 Uint8 *p, c;
41 const int thickness = 2; /* Important so 2x2 blocks of color are the same, to avoid Cr/Cb interpolation over pixels */
42
43 /* R, G, B in alternating horizontal bands */
44 for (y = 0; y < pattern->h; y += thickness) {
45 for (i = 0; i < thickness; ++i) {
46 p = (Uint8 *)pattern->pixels + (y + i) * pattern->pitch + ((y/thickness) % 3);
47 for (x = 0; x < pattern->w; ++x) {
48 *p = 0xFF;
49 p += 3;
50 }
51 }
52 }
53
54 /* Black and white in alternating vertical bands */
55 c = 0xFF;
56 for (x = 1*thickness; x < pattern->w; x += 2*thickness) {
57 for (i = 0; i < thickness; ++i) {
58 p = (Uint8 *)pattern->pixels + (x + i)*3;
59 for (y = 0; y < pattern->h; ++y) {
60 SDL_memset(p, c, 3);
61 p += pattern->pitch;
62 }
63 }
64 if (c) {
65 c = 0x00;
66 } else {
67 c = 0xFF;
68 }
69 }
70 }
71 return pattern;
72}
73
74static SDL_bool verify_yuv_data(Uint32 format, const Uint8 *yuv, int yuv_pitch, SDL_Surface *surface)
75{

Callers 1

run_automated_testsFunction · 0.85

Calls 2

SDL_memsetFunction · 0.85

Tested by

no test coverage detected