22 #define MAX_YUV_SURFACE_SIZE(W, H, P) (H*4*(W+P+1)/2)
41 const int thickness = 2;
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) {
56 for (x = 1*thickness; x < pattern->
w; x += 2*thickness) {
57 for (i = 0; i < thickness; ++
i) {
59 for (y = 0; y < pattern->
h; ++
y) {
76 const int tolerance = 20;
77 const int size = (surface->
h * surface->
pitch);
90 for (y = 0; y < surface->
h; ++
y) {
91 const Uint8 *actual = rgb + y * surface->
pitch;
93 for (x = 0; x < surface->
w; ++
x) {
94 int deltaR = (int)actual[0] - expected[0];
95 int deltaG = (int)actual[1] - expected[1];
96 int deltaB = (int)actual[2] - expected[2];
97 int distance = (deltaR * deltaR + deltaG * deltaG + deltaB * deltaB);
98 if (distance > tolerance) {
99 SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"Pixel at %d,%d was 0x%.2x,0x%.2x,0x%.2x, expected 0x%.2x,0x%.2x,0x%.2x, distance = %d\n", x, y, actual[0], actual[1], actual[2], expected[0], expected[1], expected[2], distance);
130 int yuv1_pitch, yuv2_pitch;
133 if (!pattern || !yuv1 || !yuv2) {
173 if (
SDL_ConvertPixels(pattern->
w, pattern->
h, formats[i], yuv1, yuv1_pitch, formats[j], yuv2, yuv2_pitch) < 0) {
198 if (
SDL_ConvertPixels(pattern->
w, pattern->
h, formats[i], yuv1, yuv1_pitch, formats[j], yuv1, yuv2_pitch) < 0) {
226 } automated_test_params[] = {
257 const char *titles[3] = {
"ORIGINAL",
"SOFTWARE",
"HARDWARE" };
259 const char *yuv_name;
260 const char *yuv_mode;
269 while (argv[arg] && *argv[arg] ==
'-') {
272 }
else if (
SDL_strcmp(argv[arg],
"--bt601") == 0) {
274 }
else if (
SDL_strcmp(argv[arg],
"--bt709") == 0) {
276 }
else if (
SDL_strcmp(argv[arg],
"--auto") == 0) {
278 }
else if (
SDL_strcmp(argv[arg],
"--yv12") == 0) {
280 }
else if (
SDL_strcmp(argv[arg],
"--iyuv") == 0) {
282 }
else if (
SDL_strcmp(argv[arg],
"--yuy2") == 0) {
284 }
else if (
SDL_strcmp(argv[arg],
"--uyvy") == 0) {
286 }
else if (
SDL_strcmp(argv[arg],
"--yvyu") == 0) {
288 }
else if (
SDL_strcmp(argv[arg],
"--nv12") == 0) {
290 }
else if (
SDL_strcmp(argv[arg],
"--nv21") == 0) {
292 }
else if (
SDL_strcmp(argv[arg],
"--rgb555") == 0) {
294 }
else if (
SDL_strcmp(argv[arg],
"--rgb565") == 0) {
296 }
else if (
SDL_strcmp(argv[arg],
"--rgb24") == 0) {
298 }
else if (
SDL_strcmp(argv[arg],
"--argb") == 0) {
300 }
else if (
SDL_strcmp(argv[arg],
"--abgr") == 0) {
302 }
else if (
SDL_strcmp(argv[arg],
"--rgba") == 0) {
304 }
else if (
SDL_strcmp(argv[arg],
"--bgra") == 0) {
306 }
else if (
SDL_strcmp(argv[arg],
"--automated") == 0) {
307 should_run_automated_tests =
SDL_TRUE;
309 SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"Usage: %s [--jpeg|--bt601|-bt709|--auto] [--yv12|--iyuv|--yuy2|--uyvy|--yvyu|--nv12|--nv21] [--rgb555|--rgb565|--rgb24|--argb|--abgr|--rgba|--bgra] [image_filename]\n", argv[0]);
316 if (should_run_automated_tests) {
319 automated_test_params[i].pattern_size,
320 automated_test_params[i].extra_pitch,
321 automated_test_params[i].enable_intrinsics ?
"enabled" :
"disabled");
322 if (
run_automated_tests(automated_test_params[i].pattern_size, automated_test_params[i].extra_pitch) < 0) {
330 filename = argv[arg];
332 filename =
"testyuv.bmp";
362 original->
w, original->
h,
378 if (!output[0] || !output[1] || !output[2]) {
385 if (
SDL_strncmp(yuv_name,
"SDL_PIXELFORMAT_", 16) == 0) {
400 yuv_mode =
"UNKNOWN";
422 if (event.
button.
x < (original->
w/2)) {
444 SDL_snprintf(title,
sizeof(title),
"%s %s %s", titles[current], yuv_name, yuv_mode);