Removed SDL_bool in favor of plain bool
We require stdbool.h in the build environment, so we might as well use the plain bool type. If your environment doesn't have stdbool.h, this simple replacement will suffice: typedef signed char bool;
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#define MAX_YUV_SURFACE_SIZE(W, H, P) ((H + 1) * ((W + 1) + P) * 4)
|
||||
|
||||
/* Return true if the YUV format is packed pixels */
|
||||
static SDL_bool is_packed_yuv_format(Uint32 format)
|
||||
static bool is_packed_yuv_format(Uint32 format)
|
||||
{
|
||||
return format == SDL_PIXELFORMAT_YUY2 || format == SDL_PIXELFORMAT_UYVY || format == SDL_PIXELFORMAT_YVYU;
|
||||
}
|
||||
@@ -65,21 +65,21 @@ static SDL_Surface *generate_test_pattern(int pattern_size)
|
||||
return pattern;
|
||||
}
|
||||
|
||||
static SDL_bool verify_yuv_data(Uint32 format, SDL_Colorspace colorspace, const Uint8 *yuv, int yuv_pitch, SDL_Surface *surface, int tolerance)
|
||||
static bool verify_yuv_data(Uint32 format, SDL_Colorspace colorspace, const Uint8 *yuv, int yuv_pitch, SDL_Surface *surface, int tolerance)
|
||||
{
|
||||
const int size = (surface->h * surface->pitch);
|
||||
Uint8 *rgb;
|
||||
SDL_bool result = SDL_FALSE;
|
||||
bool result = false;
|
||||
|
||||
rgb = (Uint8 *)SDL_malloc(size);
|
||||
if (!rgb) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory");
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SDL_ConvertPixelsAndColorspace(surface->w, surface->h, format, colorspace, 0, yuv, yuv_pitch, surface->format, SDL_COLORSPACE_SRGB, 0, rgb, surface->pitch)) {
|
||||
int x, y;
|
||||
result = SDL_TRUE;
|
||||
result = true;
|
||||
for (y = 0; y < surface->h; ++y) {
|
||||
const Uint8 *actual = rgb + y * surface->pitch;
|
||||
const Uint8 *expected = (const Uint8 *)surface->pixels + y * surface->pitch;
|
||||
@@ -90,7 +90,7 @@ static SDL_bool verify_yuv_data(Uint32 format, SDL_Colorspace colorspace, const
|
||||
int distance = (deltaR * deltaR + deltaG * deltaG + deltaB * deltaB);
|
||||
if (distance > tolerance) {
|
||||
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);
|
||||
result = SDL_FALSE;
|
||||
result = false;
|
||||
}
|
||||
actual += 3;
|
||||
expected += 3;
|
||||
@@ -243,34 +243,34 @@ int main(int argc, char **argv)
|
||||
{
|
||||
struct
|
||||
{
|
||||
SDL_bool enable_intrinsics;
|
||||
bool enable_intrinsics;
|
||||
int pattern_size;
|
||||
int extra_pitch;
|
||||
} automated_test_params[] = {
|
||||
/* Test: single pixel */
|
||||
{ SDL_FALSE, 1, 0 },
|
||||
{ false, 1, 0 },
|
||||
/* Test: even width and height */
|
||||
{ SDL_FALSE, 2, 0 },
|
||||
{ SDL_FALSE, 4, 0 },
|
||||
{ false, 2, 0 },
|
||||
{ false, 4, 0 },
|
||||
/* Test: odd width and height */
|
||||
{ SDL_FALSE, 1, 0 },
|
||||
{ SDL_FALSE, 3, 0 },
|
||||
{ false, 1, 0 },
|
||||
{ false, 3, 0 },
|
||||
/* Test: even width and height, extra pitch */
|
||||
{ SDL_FALSE, 2, 3 },
|
||||
{ SDL_FALSE, 4, 3 },
|
||||
{ false, 2, 3 },
|
||||
{ false, 4, 3 },
|
||||
/* Test: odd width and height, extra pitch */
|
||||
{ SDL_FALSE, 1, 3 },
|
||||
{ SDL_FALSE, 3, 3 },
|
||||
{ false, 1, 3 },
|
||||
{ false, 3, 3 },
|
||||
/* Test: even width and height with intrinsics */
|
||||
{ SDL_TRUE, 32, 0 },
|
||||
{ true, 32, 0 },
|
||||
/* Test: odd width and height with intrinsics */
|
||||
{ SDL_TRUE, 33, 0 },
|
||||
{ SDL_TRUE, 37, 0 },
|
||||
{ true, 33, 0 },
|
||||
{ true, 37, 0 },
|
||||
/* Test: even width and height with intrinsics, extra pitch */
|
||||
{ SDL_TRUE, 32, 3 },
|
||||
{ true, 32, 3 },
|
||||
/* Test: odd width and height with intrinsics, extra pitch */
|
||||
{ SDL_TRUE, 33, 3 },
|
||||
{ SDL_TRUE, 37, 3 },
|
||||
{ true, 33, 3 },
|
||||
{ true, 37, 3 },
|
||||
};
|
||||
char *filename = NULL;
|
||||
SDL_Surface *original;
|
||||
@@ -289,14 +289,14 @@ int main(int argc, char **argv)
|
||||
Uint32 rgb_format = SDL_PIXELFORMAT_RGBX8888;
|
||||
SDL_Colorspace rgb_colorspace = SDL_COLORSPACE_SRGB;
|
||||
SDL_PropertiesID props;
|
||||
SDL_bool monochrome = SDL_FALSE;
|
||||
bool monochrome = false;
|
||||
int luminance = 100;
|
||||
int current = 0;
|
||||
int pitch;
|
||||
Uint8 *raw_yuv;
|
||||
Uint64 then, now;
|
||||
int i, iterations = 100;
|
||||
SDL_bool should_run_automated_tests = SDL_FALSE;
|
||||
bool should_run_automated_tests = false;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
@@ -369,13 +369,13 @@ int main(int argc, char **argv)
|
||||
rgb_format = SDL_PIXELFORMAT_BGRA8888;
|
||||
consumed = 1;
|
||||
} else if (SDL_strcmp(argv[i], "--monochrome") == 0) {
|
||||
monochrome = SDL_TRUE;
|
||||
monochrome = true;
|
||||
consumed = 1;
|
||||
} else if (SDL_strcmp(argv[i], "--luminance") == 0 && argv[i+1]) {
|
||||
luminance = SDL_atoi(argv[i+1]);
|
||||
consumed = 2;
|
||||
} else if (SDL_strcmp(argv[i], "--automated") == 0) {
|
||||
should_run_automated_tests = SDL_TRUE;
|
||||
should_run_automated_tests = true;
|
||||
consumed = 1;
|
||||
} else if (!filename) {
|
||||
filename = argv[i];
|
||||
|
||||
Reference in New Issue
Block a user