22#define MAX_YUV_SURFACE_SIZE(W, H, P) (H*4*(W+P+1)/2)
41 const int thickness = 2;
45 for (
i = 0;
i < thickness; ++
i) {
56 for (
x = 1*thickness;
x <
pattern->w;
x += 2*thickness) {
57 for (
i = 0;
i < thickness; ++
i) {
76 const int tolerance = 20;
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);
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) {
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) {
362 original->
w, original->
h,
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);
#define SDL_RenderPresent
#define SDL_SetRenderDrawColor
#define SDL_CreateTextureFromSurface
#define SDL_CreateTexture
#define SDL_GetYUVConversionModeForResolution
#define SDL_GetPixelFormatName
#define SDL_SetYUVConversionMode
#define SDL_CreateRenderer
#define SDL_UpdateTexture
#define SDL_ConvertSurfaceFormat
#define SDL_CreateRGBSurfaceWithFormat
#define SDL_ConvertPixels
@ SDL_LOG_CATEGORY_APPLICATION
GLint GLint GLint GLint GLint GLint y
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLsizei GLsizei GLfloat distance
@ SDL_PIXELFORMAT_RGBA8888
@ SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_BGRA8888
@ SDL_PIXELFORMAT_ARGB8888
@ SDL_PIXELFORMAT_RGBX8888
@ SDL_TEXTUREACCESS_STREAMING
#define SDL_arraysize(array)
@ SDL_YUV_CONVERSION_BT601
@ SDL_YUV_CONVERSION_JPEG
@ SDL_YUV_CONVERSION_BT709
@ SDL_YUV_CONVERSION_AUTOMATIC
#define SDL_LoadBMP(file)
int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s)
Draw a string in the currently set font.
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
#define SDL_WINDOWPOS_UNDEFINED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
EGLSurface EGLNativeWindowType * window
A collection of pixels used in software blitting.
The type used to identify a window.
static SDL_Renderer * renderer
static SDL_Surface * generate_test_pattern(int pattern_size)
static SDL_bool is_packed_yuv_format(Uint32 format)
int main(int argc, char **argv)
static int run_automated_tests(int pattern_size, int extra_pitch)
#define MAX_YUV_SURFACE_SIZE(W, H, P)
static SDL_bool verify_yuv_data(Uint32 format, const Uint8 *yuv, int yuv_pitch, SDL_Surface *surface)
int CalculateYUVPitch(Uint32 format, int width)
SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)