Go to the documentation of this file.
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);
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define SDL_RenderPresent
#define SDL_GetPixelFormatName
A collection of pixels used in software blitting.
#define SDL_ConvertSurfaceFormat
@ SDL_PIXELFORMAT_RGBX8888
#define SDL_WINDOWPOS_UNDEFINED
#define MAX_YUV_SURFACE_SIZE(W, H, P)
int main(int argc, char **argv)
The type used to identify a window.
@ SDL_YUV_CONVERSION_JPEG
static int run_automated_tests(int pattern_size, int extra_pitch)
#define SDL_CreateTextureFromSurface
#define SDL_UpdateTexture
GLint GLint GLint GLint GLint x
EGLSurface EGLNativeWindowType * window
int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s)
Draw a string in the currently set font.
@ SDL_LOG_CATEGORY_APPLICATION
static SDL_bool verify_yuv_data(Uint32 format, const Uint8 *yuv, int yuv_pitch, SDL_Surface *surface)
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
#define SDL_SetYUVConversionMode
@ SDL_PIXELFORMAT_ARGB8888
#define SDL_LoadBMP(file)
static SDL_Surface * generate_test_pattern(int pattern_size)
GLint GLint GLint GLint GLint GLint y
#define SDL_arraysize(array)
GLsizei GLsizei GLfloat distance
static SDL_Renderer * renderer
@ SDL_PIXELFORMAT_RGBA8888
int CalculateYUVPitch(Uint32 format, int width)
#define SDL_SetRenderDrawColor
@ SDL_PIXELFORMAT_BGRA8888
#define SDL_ConvertPixels
#define SDL_GetYUVConversionModeForResolution
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)
SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
@ SDL_YUV_CONVERSION_BT709
#define SDL_CreateRenderer
@ SDL_TEXTUREACCESS_STREAMING
@ SDL_PIXELFORMAT_ABGR8888
static SDL_bool is_packed_yuv_format(Uint32 format)
#define SDL_CreateRGBSurfaceWithFormat
#define SDL_CreateTexture
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)
@ SDL_YUV_CONVERSION_BT601
@ SDL_YUV_CONVERSION_AUTOMATIC