test/testoverlay.c
changeset 1895 c121d94672cb
parent 1439 4d3bb026cd16
child 2267 c785543d1843
     1.1 --- a/test/testoverlay.c	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/test/testoverlay.c	Mon Jul 10 21:04:37 2006 +0000
     1.3 @@ -22,22 +22,23 @@
     1.4  int w, h;
     1.5  
     1.6  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.7 -static void quit(int rc)
     1.8 +static void
     1.9 +quit(int rc)
    1.10  {
    1.11 -	SDL_Quit();
    1.12 -	exit(rc);
    1.13 +    SDL_Quit();
    1.14 +    exit(rc);
    1.15  }
    1.16  
    1.17  /* NOTE: These RGB conversion functions are not intended for speed,
    1.18           only as examples.
    1.19  */
    1.20  
    1.21 -void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
    1.22 +void
    1.23 +RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance)
    1.24  {
    1.25 -    if (monochrome)
    1.26 -    {
    1.27 -#if 1 /* these are the two formulas that I found on the FourCC site... */
    1.28 -        yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
    1.29 +    if (monochrome) {
    1.30 +#if 1                           /* these are the two formulas that I found on the FourCC site... */
    1.31 +        yuv[0] = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2];
    1.32          yuv[1] = 128;
    1.33          yuv[2] = 128;
    1.34  #else
    1.35 @@ -45,13 +46,11 @@
    1.36          yuv[1] = 128;
    1.37          yuv[2] = 128;
    1.38  #endif
    1.39 -    }
    1.40 -    else
    1.41 -    {
    1.42 -#if 1 /* these are the two formulas that I found on the FourCC site... */
    1.43 -        yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
    1.44 -        yuv[1] = (rgb[2]-yuv[0])*0.565 + 128;
    1.45 -        yuv[2] = (rgb[0]-yuv[0])*0.713 + 128;
    1.46 +    } else {
    1.47 +#if 1                           /* these are the two formulas that I found on the FourCC site... */
    1.48 +        yuv[0] = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2];
    1.49 +        yuv[1] = (rgb[2] - yuv[0]) * 0.565 + 128;
    1.50 +        yuv[2] = (rgb[0] - yuv[0]) * 0.713 + 128;
    1.51  #else
    1.52          yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
    1.53          yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
    1.54 @@ -59,536 +58,505 @@
    1.55  #endif
    1.56      }
    1.57  
    1.58 -    if (luminance!=100)
    1.59 -    {
    1.60 -        yuv[0]=yuv[0]*luminance/100;
    1.61 -        if (yuv[0]>255)
    1.62 -            yuv[0]=255;
    1.63 +    if (luminance != 100) {
    1.64 +        yuv[0] = yuv[0] * luminance / 100;
    1.65 +        if (yuv[0] > 255)
    1.66 +            yuv[0] = 255;
    1.67      }
    1.68  
    1.69      /* clamp values...if you need to, we don't seem to have a need */
    1.70      /*
    1.71 -    for(i=0;i<3;i++)
    1.72 -    {
    1.73 -        if(yuv[i]<0)
    1.74 -            yuv[i]=0;
    1.75 -        if(yuv[i]>255)
    1.76 -            yuv[i]=255;
    1.77 -    }
    1.78 -    */
    1.79 +       for(i=0;i<3;i++)
    1.80 +       {
    1.81 +       if(yuv[i]<0)
    1.82 +       yuv[i]=0;
    1.83 +       if(yuv[i]>255)
    1.84 +       yuv[i]=255;
    1.85 +       }
    1.86 +     */
    1.87  }
    1.88  
    1.89 -void ConvertRGBtoYV12(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
    1.90 +void
    1.91 +ConvertRGBtoYV12(SDL_Surface * s, SDL_Overlay * o, int monochrome,
    1.92 +                 int luminance)
    1.93  {
    1.94 -	int x,y;
    1.95 -	int yuv[3];
    1.96 -	Uint8 *p,*op[3];
    1.97 +    int x, y;
    1.98 +    int yuv[3];
    1.99 +    Uint8 *p, *op[3];
   1.100  
   1.101 -	SDL_LockSurface(s);
   1.102 -	SDL_LockYUVOverlay(o);
   1.103 +    SDL_LockSurface(s);
   1.104 +    SDL_LockYUVOverlay(o);
   1.105  
   1.106 -	/* Black initialization */
   1.107 -	/*
   1.108 -	memset(o->pixels[0],0,o->pitches[0]*o->h);
   1.109 -	memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
   1.110 -	memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
   1.111 -	*/
   1.112 +    /* Black initialization */
   1.113 +    /*
   1.114 +       memset(o->pixels[0],0,o->pitches[0]*o->h);
   1.115 +       memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
   1.116 +       memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
   1.117 +     */
   1.118  
   1.119 -	/* Convert */
   1.120 -	for(y=0; y<s->h && y<o->h; y++)
   1.121 -	{
   1.122 -		p=((Uint8 *) s->pixels)+s->pitch*y;
   1.123 -		op[0]=o->pixels[0]+o->pitches[0]*y;
   1.124 -		op[1]=o->pixels[1]+o->pitches[1]*(y/2);
   1.125 -		op[2]=o->pixels[2]+o->pitches[2]*(y/2);
   1.126 -		for(x=0; x<s->w && x<o->w; x++)
   1.127 -		{
   1.128 -			RGBtoYUV(p, yuv, monochrome, luminance);
   1.129 -			*(op[0]++)=yuv[0];
   1.130 -			if(x%2==0 && y%2==0)
   1.131 -			{
   1.132 -				*(op[1]++)=yuv[2];
   1.133 -				*(op[2]++)=yuv[1];
   1.134 -			}
   1.135 -			p+=s->format->BytesPerPixel;
   1.136 -		}
   1.137 -	}
   1.138 +    /* Convert */
   1.139 +    for (y = 0; y < s->h && y < o->h; y++) {
   1.140 +        p = ((Uint8 *) s->pixels) + s->pitch * y;
   1.141 +        op[0] = o->pixels[0] + o->pitches[0] * y;
   1.142 +        op[1] = o->pixels[1] + o->pitches[1] * (y / 2);
   1.143 +        op[2] = o->pixels[2] + o->pitches[2] * (y / 2);
   1.144 +        for (x = 0; x < s->w && x < o->w; x++) {
   1.145 +            RGBtoYUV(p, yuv, monochrome, luminance);
   1.146 +            *(op[0]++) = yuv[0];
   1.147 +            if (x % 2 == 0 && y % 2 == 0) {
   1.148 +                *(op[1]++) = yuv[2];
   1.149 +                *(op[2]++) = yuv[1];
   1.150 +            }
   1.151 +            p += s->format->BytesPerPixel;
   1.152 +        }
   1.153 +    }
   1.154  
   1.155 -	SDL_UnlockYUVOverlay(o);
   1.156 -	SDL_UnlockSurface(s);
   1.157 +    SDL_UnlockYUVOverlay(o);
   1.158 +    SDL_UnlockSurface(s);
   1.159  }
   1.160  
   1.161 -void ConvertRGBtoIYUV(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
   1.162 +void
   1.163 +ConvertRGBtoIYUV(SDL_Surface * s, SDL_Overlay * o, int monochrome,
   1.164 +                 int luminance)
   1.165  {
   1.166 -	int x,y;
   1.167 -	int yuv[3];
   1.168 -	Uint8 *p,*op[3];
   1.169 +    int x, y;
   1.170 +    int yuv[3];
   1.171 +    Uint8 *p, *op[3];
   1.172  
   1.173 -	SDL_LockSurface(s);
   1.174 -	SDL_LockYUVOverlay(o);
   1.175 +    SDL_LockSurface(s);
   1.176 +    SDL_LockYUVOverlay(o);
   1.177  
   1.178 -	/* Black initialization */
   1.179 -	/*
   1.180 -	memset(o->pixels[0],0,o->pitches[0]*o->h);
   1.181 -	memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
   1.182 -	memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
   1.183 -	*/
   1.184 +    /* Black initialization */
   1.185 +    /*
   1.186 +       memset(o->pixels[0],0,o->pitches[0]*o->h);
   1.187 +       memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
   1.188 +       memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
   1.189 +     */
   1.190  
   1.191 -	/* Convert */
   1.192 -	for(y=0; y<s->h && y<o->h; y++)
   1.193 -	{
   1.194 -		p=((Uint8 *) s->pixels)+s->pitch*y;
   1.195 -		op[0]=o->pixels[0]+o->pitches[0]*y;
   1.196 -		op[1]=o->pixels[1]+o->pitches[1]*(y/2);
   1.197 -		op[2]=o->pixels[2]+o->pitches[2]*(y/2);
   1.198 -		for(x=0; x<s->w && x<o->w; x++)
   1.199 -		{
   1.200 -			RGBtoYUV(p,yuv, monochrome, luminance);
   1.201 -			*(op[0]++)=yuv[0];
   1.202 -			if(x%2==0 && y%2==0)
   1.203 -			{
   1.204 -				*(op[1]++)=yuv[1];
   1.205 -				*(op[2]++)=yuv[2];
   1.206 -			}
   1.207 -			p+=s->format->BytesPerPixel;
   1.208 -		}
   1.209 -	}
   1.210 +    /* Convert */
   1.211 +    for (y = 0; y < s->h && y < o->h; y++) {
   1.212 +        p = ((Uint8 *) s->pixels) + s->pitch * y;
   1.213 +        op[0] = o->pixels[0] + o->pitches[0] * y;
   1.214 +        op[1] = o->pixels[1] + o->pitches[1] * (y / 2);
   1.215 +        op[2] = o->pixels[2] + o->pitches[2] * (y / 2);
   1.216 +        for (x = 0; x < s->w && x < o->w; x++) {
   1.217 +            RGBtoYUV(p, yuv, monochrome, luminance);
   1.218 +            *(op[0]++) = yuv[0];
   1.219 +            if (x % 2 == 0 && y % 2 == 0) {
   1.220 +                *(op[1]++) = yuv[1];
   1.221 +                *(op[2]++) = yuv[2];
   1.222 +            }
   1.223 +            p += s->format->BytesPerPixel;
   1.224 +        }
   1.225 +    }
   1.226  
   1.227 -	SDL_UnlockYUVOverlay(o);
   1.228 -	SDL_UnlockSurface(s);
   1.229 +    SDL_UnlockYUVOverlay(o);
   1.230 +    SDL_UnlockSurface(s);
   1.231  }
   1.232  
   1.233 -void ConvertRGBtoUYVY(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
   1.234 +void
   1.235 +ConvertRGBtoUYVY(SDL_Surface * s, SDL_Overlay * o, int monochrome,
   1.236 +                 int luminance)
   1.237  {
   1.238 -	int x,y;
   1.239 -	int yuv[3];
   1.240 -	Uint8 *p,*op;
   1.241 +    int x, y;
   1.242 +    int yuv[3];
   1.243 +    Uint8 *p, *op;
   1.244  
   1.245 -	SDL_LockSurface(s);
   1.246 -	SDL_LockYUVOverlay(o);
   1.247 +    SDL_LockSurface(s);
   1.248 +    SDL_LockYUVOverlay(o);
   1.249  
   1.250 -	for(y=0; y<s->h && y<o->h; y++)
   1.251 -	{
   1.252 -		p=((Uint8 *) s->pixels)+s->pitch*y;
   1.253 -		op=o->pixels[0]+o->pitches[0]*y;
   1.254 -		for(x=0; x<s->w && x<o->w; x++)
   1.255 -		{
   1.256 -			RGBtoYUV(p, yuv, monochrome, luminance);
   1.257 -			if(x%2==0)
   1.258 -			{
   1.259 -				*(op++)=yuv[1];
   1.260 -				*(op++)=yuv[0];
   1.261 -				*(op++)=yuv[2];
   1.262 -			}
   1.263 -			else
   1.264 -				*(op++)=yuv[0];
   1.265 +    for (y = 0; y < s->h && y < o->h; y++) {
   1.266 +        p = ((Uint8 *) s->pixels) + s->pitch * y;
   1.267 +        op = o->pixels[0] + o->pitches[0] * y;
   1.268 +        for (x = 0; x < s->w && x < o->w; x++) {
   1.269 +            RGBtoYUV(p, yuv, monochrome, luminance);
   1.270 +            if (x % 2 == 0) {
   1.271 +                *(op++) = yuv[1];
   1.272 +                *(op++) = yuv[0];
   1.273 +                *(op++) = yuv[2];
   1.274 +            } else
   1.275 +                *(op++) = yuv[0];
   1.276  
   1.277 -			p+=s->format->BytesPerPixel;
   1.278 -		}
   1.279 -	}
   1.280 +            p += s->format->BytesPerPixel;
   1.281 +        }
   1.282 +    }
   1.283  
   1.284 -	SDL_UnlockYUVOverlay(o);
   1.285 -	SDL_UnlockSurface(s);
   1.286 +    SDL_UnlockYUVOverlay(o);
   1.287 +    SDL_UnlockSurface(s);
   1.288  }
   1.289  
   1.290 -void ConvertRGBtoYVYU(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
   1.291 +void
   1.292 +ConvertRGBtoYVYU(SDL_Surface * s, SDL_Overlay * o, int monochrome,
   1.293 +                 int luminance)
   1.294  {
   1.295 -	int x,y;
   1.296 -	int yuv[3];
   1.297 -	Uint8 *p,*op;
   1.298 +    int x, y;
   1.299 +    int yuv[3];
   1.300 +    Uint8 *p, *op;
   1.301  
   1.302 -	SDL_LockSurface(s);
   1.303 -	SDL_LockYUVOverlay(o);
   1.304 +    SDL_LockSurface(s);
   1.305 +    SDL_LockYUVOverlay(o);
   1.306  
   1.307 -	for(y=0; y<s->h && y<o->h; y++)
   1.308 -	{
   1.309 -		p=((Uint8 *) s->pixels)+s->pitch*y;
   1.310 -		op=o->pixels[0]+o->pitches[0]*y;
   1.311 -		for(x=0; x<s->w && x<o->w; x++)
   1.312 -		{
   1.313 -			RGBtoYUV(p,yuv, monochrome, luminance);
   1.314 -			if(x%2==0)
   1.315 -			{
   1.316 -				*(op++)=yuv[0];
   1.317 -				*(op++)=yuv[2];
   1.318 -				op[1]=yuv[1];
   1.319 -			}
   1.320 -			else
   1.321 -			{
   1.322 -				*op=yuv[0];
   1.323 -				op+=2;
   1.324 -			}
   1.325 +    for (y = 0; y < s->h && y < o->h; y++) {
   1.326 +        p = ((Uint8 *) s->pixels) + s->pitch * y;
   1.327 +        op = o->pixels[0] + o->pitches[0] * y;
   1.328 +        for (x = 0; x < s->w && x < o->w; x++) {
   1.329 +            RGBtoYUV(p, yuv, monochrome, luminance);
   1.330 +            if (x % 2 == 0) {
   1.331 +                *(op++) = yuv[0];
   1.332 +                *(op++) = yuv[2];
   1.333 +                op[1] = yuv[1];
   1.334 +            } else {
   1.335 +                *op = yuv[0];
   1.336 +                op += 2;
   1.337 +            }
   1.338  
   1.339 -			p+=s->format->BytesPerPixel;
   1.340 -		}
   1.341 -	}
   1.342 +            p += s->format->BytesPerPixel;
   1.343 +        }
   1.344 +    }
   1.345  
   1.346 -	SDL_UnlockYUVOverlay(o);
   1.347 -	SDL_UnlockSurface(s);
   1.348 +    SDL_UnlockYUVOverlay(o);
   1.349 +    SDL_UnlockSurface(s);
   1.350  }
   1.351  
   1.352 -void ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
   1.353 +void
   1.354 +ConvertRGBtoYUY2(SDL_Surface * s, SDL_Overlay * o, int monochrome,
   1.355 +                 int luminance)
   1.356  {
   1.357 -	int x,y;
   1.358 -	int yuv[3];
   1.359 -	Uint8 *p,*op;
   1.360 +    int x, y;
   1.361 +    int yuv[3];
   1.362 +    Uint8 *p, *op;
   1.363  
   1.364 -	SDL_LockSurface(s);
   1.365 -	SDL_LockYUVOverlay(o);
   1.366 +    SDL_LockSurface(s);
   1.367 +    SDL_LockYUVOverlay(o);
   1.368  
   1.369 -	for(y=0; y<s->h && y<o->h; y++)
   1.370 -	{
   1.371 -		p=((Uint8 *) s->pixels)+s->pitch*y;
   1.372 -		op=o->pixels[0]+o->pitches[0]*y;
   1.373 -		for(x=0; x<s->w && x<o->w; x++)
   1.374 -		{
   1.375 -			RGBtoYUV(p,yuv, monochrome, luminance);
   1.376 -			if(x%2==0)
   1.377 -			{
   1.378 -				*(op++)=yuv[0];
   1.379 -				*(op++)=yuv[1];
   1.380 -				op[1]=yuv[2];
   1.381 -			}
   1.382 -			else
   1.383 -			{
   1.384 -				*op=yuv[0];
   1.385 -				op+=2;
   1.386 -			}
   1.387 +    for (y = 0; y < s->h && y < o->h; y++) {
   1.388 +        p = ((Uint8 *) s->pixels) + s->pitch * y;
   1.389 +        op = o->pixels[0] + o->pitches[0] * y;
   1.390 +        for (x = 0; x < s->w && x < o->w; x++) {
   1.391 +            RGBtoYUV(p, yuv, monochrome, luminance);
   1.392 +            if (x % 2 == 0) {
   1.393 +                *(op++) = yuv[0];
   1.394 +                *(op++) = yuv[1];
   1.395 +                op[1] = yuv[2];
   1.396 +            } else {
   1.397 +                *op = yuv[0];
   1.398 +                op += 2;
   1.399 +            }
   1.400  
   1.401 -			p+=s->format->BytesPerPixel;
   1.402 -		}
   1.403 -	}
   1.404 +            p += s->format->BytesPerPixel;
   1.405 +        }
   1.406 +    }
   1.407  
   1.408 -	SDL_UnlockYUVOverlay(o);
   1.409 -	SDL_UnlockSurface(s);
   1.410 +    SDL_UnlockYUVOverlay(o);
   1.411 +    SDL_UnlockSurface(s);
   1.412  }
   1.413  
   1.414 -void Draw()
   1.415 +void
   1.416 +Draw()
   1.417  {
   1.418 -	SDL_Rect rect;
   1.419 -	int i;
   1.420 -        int disp;
   1.421 +    SDL_Rect rect;
   1.422 +    int i;
   1.423 +    int disp;
   1.424  
   1.425 -	if(!scale)
   1.426 -	{
   1.427 -		rect.w=overlay->w;
   1.428 -		rect.h=overlay->h;
   1.429 -		for(i=0; i<h-rect.h && i<w-rect.w; i++)
   1.430 -		{
   1.431 -			rect.x=i;
   1.432 -			rect.y=i;
   1.433 -			SDL_DisplayYUVOverlay(overlay,&rect);
   1.434 -		}
   1.435 -	}
   1.436 -	else
   1.437 -	{
   1.438 -		rect.w=overlay->w/2;
   1.439 -		rect.h=overlay->h/2;
   1.440 -		rect.x=(w-rect.w)/2;
   1.441 -		rect.y=(h-rect.h)/2;
   1.442 -                disp=rect.y-1;
   1.443 -		for(i=0; i<disp; i++)
   1.444 -		{
   1.445 -                        rect.w+=2;
   1.446 -                        rect.h+=2;
   1.447 -                        rect.x--;
   1.448 -                        rect.y--;
   1.449 -			SDL_DisplayYUVOverlay(overlay,&rect);
   1.450 -		}
   1.451 -	}
   1.452 -	printf("Displayed %d times.\n",i);
   1.453 +    if (!scale) {
   1.454 +        rect.w = overlay->w;
   1.455 +        rect.h = overlay->h;
   1.456 +        for (i = 0; i < h - rect.h && i < w - rect.w; i++) {
   1.457 +            rect.x = i;
   1.458 +            rect.y = i;
   1.459 +            SDL_DisplayYUVOverlay(overlay, &rect);
   1.460 +        }
   1.461 +    } else {
   1.462 +        rect.w = overlay->w / 2;
   1.463 +        rect.h = overlay->h / 2;
   1.464 +        rect.x = (w - rect.w) / 2;
   1.465 +        rect.y = (h - rect.h) / 2;
   1.466 +        disp = rect.y - 1;
   1.467 +        for (i = 0; i < disp; i++) {
   1.468 +            rect.w += 2;
   1.469 +            rect.h += 2;
   1.470 +            rect.x--;
   1.471 +            rect.y--;
   1.472 +            SDL_DisplayYUVOverlay(overlay, &rect);
   1.473 +        }
   1.474 +    }
   1.475 +    printf("Displayed %d times.\n", i);
   1.476  }
   1.477  
   1.478 -static void PrintUsage(char *argv0)
   1.479 +static void
   1.480 +PrintUsage(char *argv0)
   1.481  {
   1.482 -	fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
   1.483 -	fprintf(stderr, "Where 'arg' is one of:\n");
   1.484 -	fprintf(stderr, "	-delay <seconds>\n");
   1.485 -	fprintf(stderr, "	-width <pixels>\n");
   1.486 -	fprintf(stderr, "	-height <pixels>\n");
   1.487 -	fprintf(stderr, "	-bpp <bits>\n");
   1.488 -	fprintf(stderr, "	-format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
   1.489 -	fprintf(stderr, "	-hw\n");
   1.490 -	fprintf(stderr, "	-flip\n");
   1.491 -	fprintf(stderr, "	-scale (test scaling features, from 50%% upto window size)\n");
   1.492 -	fprintf(stderr, "	-mono (use monochromatic RGB2YUV conversion)\n");
   1.493 -	fprintf(stderr, "	-lum <perc> (use luminance correction during RGB2YUV conversion,\n");
   1.494 -	fprintf(stderr, "	             from 0%% to unlimited, normal is 100%%)\n");
   1.495 -	fprintf(stderr, "	-help (shows this help)\n");
   1.496 -	fprintf(stderr, "	-fullscreen (test overlay in fullscreen mode)\n");
   1.497 +    fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
   1.498 +    fprintf(stderr, "Where 'arg' is one of:\n");
   1.499 +    fprintf(stderr, "	-delay <seconds>\n");
   1.500 +    fprintf(stderr, "	-width <pixels>\n");
   1.501 +    fprintf(stderr, "	-height <pixels>\n");
   1.502 +    fprintf(stderr, "	-bpp <bits>\n");
   1.503 +    fprintf(stderr,
   1.504 +            "	-format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
   1.505 +    fprintf(stderr, "	-hw\n");
   1.506 +    fprintf(stderr, "	-flip\n");
   1.507 +    fprintf(stderr,
   1.508 +            "	-scale (test scaling features, from 50%% upto window size)\n");
   1.509 +    fprintf(stderr, "	-mono (use monochromatic RGB2YUV conversion)\n");
   1.510 +    fprintf(stderr,
   1.511 +            "	-lum <perc> (use luminance correction during RGB2YUV conversion,\n");
   1.512 +    fprintf(stderr,
   1.513 +            "	             from 0%% to unlimited, normal is 100%%)\n");
   1.514 +    fprintf(stderr, "	-help (shows this help)\n");
   1.515 +    fprintf(stderr, "	-fullscreen (test overlay in fullscreen mode)\n");
   1.516  }
   1.517  
   1.518 -int main(int argc, char **argv)
   1.519 +int
   1.520 +main(int argc, char **argv)
   1.521  {
   1.522 -	char *argv0 = argv[0];
   1.523 -	int flip;
   1.524 -	int delay;
   1.525 -	int desired_bpp;
   1.526 -	Uint32 video_flags, overlay_format;
   1.527 -	char *bmpfile;
   1.528 +    char *argv0 = argv[0];
   1.529 +    int flip;
   1.530 +    int delay;
   1.531 +    int desired_bpp;
   1.532 +    Uint32 video_flags, overlay_format;
   1.533 +    char *bmpfile;
   1.534  #ifdef BENCHMARK_SDL
   1.535 -	Uint32 then, now;
   1.536 +    Uint32 then, now;
   1.537  #endif
   1.538 -	int i;
   1.539 +    int i;
   1.540  
   1.541 -	/* Set default options and check command-line */
   1.542 -	flip = 0;
   1.543 -	scale=0;
   1.544 -        monochrome=0;
   1.545 -        luminance=100;
   1.546 -	delay = 1;
   1.547 -	w = WINDOW_WIDTH;
   1.548 -	h = WINDOW_HEIGHT;
   1.549 -	desired_bpp = 0;
   1.550 -	video_flags = 0;
   1.551 -	overlay_format = SDL_YV12_OVERLAY;
   1.552 +    /* Set default options and check command-line */
   1.553 +    flip = 0;
   1.554 +    scale = 0;
   1.555 +    monochrome = 0;
   1.556 +    luminance = 100;
   1.557 +    delay = 1;
   1.558 +    w = WINDOW_WIDTH;
   1.559 +    h = WINDOW_HEIGHT;
   1.560 +    desired_bpp = 0;
   1.561 +    video_flags = 0;
   1.562 +    overlay_format = SDL_YV12_OVERLAY;
   1.563  
   1.564 -	while ( argc > 1 ) {
   1.565 -		if ( strcmp(argv[1], "-delay") == 0 ) {
   1.566 -			if ( argv[2] ) {
   1.567 -				delay = atoi(argv[2]);
   1.568 -				argv += 2;
   1.569 -				argc -= 2;
   1.570 -			} else {
   1.571 -				fprintf(stderr,
   1.572 -				"The -delay option requires an argument\n");
   1.573 -				return(1);
   1.574 -			}
   1.575 -		} else
   1.576 -		if ( strcmp(argv[1], "-width") == 0 ) {
   1.577 -			if ( argv[2] && ((w = atoi(argv[2])) > 0) ) {
   1.578 -				argv += 2;
   1.579 -				argc -= 2;
   1.580 -			} else {
   1.581 -				fprintf(stderr,
   1.582 -				"The -width option requires an argument\n");
   1.583 -				return(1);
   1.584 -			}
   1.585 -		} else
   1.586 -		if ( strcmp(argv[1], "-height") == 0 ) {
   1.587 -			if ( argv[2] && ((h = atoi(argv[2])) > 0) ) {
   1.588 -				argv += 2;
   1.589 -				argc -= 2;
   1.590 -			} else {
   1.591 -				fprintf(stderr,
   1.592 -				"The -height option requires an argument\n");
   1.593 -				return(1);
   1.594 -			}
   1.595 -		} else
   1.596 -		if ( strcmp(argv[1], "-bpp") == 0 ) {
   1.597 -			if ( argv[2] ) {
   1.598 -				desired_bpp = atoi(argv[2]);
   1.599 -				argv += 2;
   1.600 -				argc -= 2;
   1.601 -			} else {
   1.602 -				fprintf(stderr,
   1.603 -				"The -bpp option requires an argument\n");
   1.604 -				return(1);
   1.605 -			}
   1.606 -		} else
   1.607 -		if ( strcmp(argv[1], "-lum") == 0 ) {
   1.608 -			if ( argv[2] ) {
   1.609 -				luminance = atoi(argv[2]);
   1.610 -				argv += 2;
   1.611 -				argc -= 2;
   1.612 -			} else {
   1.613 -				fprintf(stderr,
   1.614 -				"The -lum option requires an argument\n");
   1.615 -				return(1);
   1.616 -			}
   1.617 -		} else
   1.618 -		if ( strcmp(argv[1], "-format") == 0 ) {
   1.619 -			if ( argv[2] ) {
   1.620 -				if(!strcmp(argv[2],"YV12"))
   1.621 -					overlay_format = SDL_YV12_OVERLAY;
   1.622 -				else if(!strcmp(argv[2],"IYUV"))
   1.623 -					overlay_format = SDL_IYUV_OVERLAY;
   1.624 -				else if(!strcmp(argv[2],"YUY2"))
   1.625 -					overlay_format = SDL_YUY2_OVERLAY;
   1.626 -				else if(!strcmp(argv[2],"UYVY"))
   1.627 -					overlay_format = SDL_UYVY_OVERLAY;
   1.628 -				else if(!strcmp(argv[2],"YVYU"))
   1.629 -					overlay_format = SDL_YVYU_OVERLAY;
   1.630 -				else
   1.631 -				{
   1.632 -					fprintf(stderr, "The -format option %s is not recognized\n",argv[2]);
   1.633 -					return(1);
   1.634 -				}
   1.635 -				argv += 2;
   1.636 -				argc -= 2;
   1.637 -			} else {
   1.638 -				fprintf(stderr,
   1.639 -				"The -format option requires an argument\n");
   1.640 -				return(1);
   1.641 -			}
   1.642 -		} else
   1.643 -		if ( strcmp(argv[1], "-hw") == 0 ) {
   1.644 -			video_flags |= SDL_HWSURFACE;
   1.645 -			argv += 1;
   1.646 -			argc -= 1;
   1.647 -		} else
   1.648 -		if ( strcmp(argv[1], "-flip") == 0 ) {
   1.649 -			video_flags |= SDL_DOUBLEBUF;
   1.650 -			argv += 1;
   1.651 -			argc -= 1;
   1.652 -		} else
   1.653 -		if ( strcmp(argv[1], "-scale") == 0 ) {
   1.654 -			scale = 1;
   1.655 -			argv += 1;
   1.656 -			argc -= 1;
   1.657 -		} else
   1.658 -		if ( strcmp(argv[1], "-mono") == 0 ) {
   1.659 -			monochrome = 1;
   1.660 -			argv += 1;
   1.661 -			argc -= 1;
   1.662 -		} else
   1.663 -		if (( strcmp(argv[1], "-help") == 0 ) || (strcmp(argv[1], "-h") == 0)) {
   1.664 -                        PrintUsage(argv0);
   1.665 -                        return(1);
   1.666 -		} else
   1.667 -		if ( strcmp(argv[1], "-fullscreen") == 0 ) {
   1.668 -			video_flags |= SDL_FULLSCREEN;
   1.669 -			argv += 1;
   1.670 -			argc -= 1;
   1.671 -		} else
   1.672 -			break;
   1.673 -	}
   1.674 -	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
   1.675 -		fprintf(stderr,
   1.676 -			"Couldn't initialize SDL: %s\n", SDL_GetError());
   1.677 -		return(1);
   1.678 -	}
   1.679 +    while (argc > 1) {
   1.680 +        if (strcmp(argv[1], "-delay") == 0) {
   1.681 +            if (argv[2]) {
   1.682 +                delay = atoi(argv[2]);
   1.683 +                argv += 2;
   1.684 +                argc -= 2;
   1.685 +            } else {
   1.686 +                fprintf(stderr, "The -delay option requires an argument\n");
   1.687 +                return (1);
   1.688 +            }
   1.689 +        } else if (strcmp(argv[1], "-width") == 0) {
   1.690 +            if (argv[2] && ((w = atoi(argv[2])) > 0)) {
   1.691 +                argv += 2;
   1.692 +                argc -= 2;
   1.693 +            } else {
   1.694 +                fprintf(stderr, "The -width option requires an argument\n");
   1.695 +                return (1);
   1.696 +            }
   1.697 +        } else if (strcmp(argv[1], "-height") == 0) {
   1.698 +            if (argv[2] && ((h = atoi(argv[2])) > 0)) {
   1.699 +                argv += 2;
   1.700 +                argc -= 2;
   1.701 +            } else {
   1.702 +                fprintf(stderr, "The -height option requires an argument\n");
   1.703 +                return (1);
   1.704 +            }
   1.705 +        } else if (strcmp(argv[1], "-bpp") == 0) {
   1.706 +            if (argv[2]) {
   1.707 +                desired_bpp = atoi(argv[2]);
   1.708 +                argv += 2;
   1.709 +                argc -= 2;
   1.710 +            } else {
   1.711 +                fprintf(stderr, "The -bpp option requires an argument\n");
   1.712 +                return (1);
   1.713 +            }
   1.714 +        } else if (strcmp(argv[1], "-lum") == 0) {
   1.715 +            if (argv[2]) {
   1.716 +                luminance = atoi(argv[2]);
   1.717 +                argv += 2;
   1.718 +                argc -= 2;
   1.719 +            } else {
   1.720 +                fprintf(stderr, "The -lum option requires an argument\n");
   1.721 +                return (1);
   1.722 +            }
   1.723 +        } else if (strcmp(argv[1], "-format") == 0) {
   1.724 +            if (argv[2]) {
   1.725 +                if (!strcmp(argv[2], "YV12"))
   1.726 +                    overlay_format = SDL_YV12_OVERLAY;
   1.727 +                else if (!strcmp(argv[2], "IYUV"))
   1.728 +                    overlay_format = SDL_IYUV_OVERLAY;
   1.729 +                else if (!strcmp(argv[2], "YUY2"))
   1.730 +                    overlay_format = SDL_YUY2_OVERLAY;
   1.731 +                else if (!strcmp(argv[2], "UYVY"))
   1.732 +                    overlay_format = SDL_UYVY_OVERLAY;
   1.733 +                else if (!strcmp(argv[2], "YVYU"))
   1.734 +                    overlay_format = SDL_YVYU_OVERLAY;
   1.735 +                else {
   1.736 +                    fprintf(stderr,
   1.737 +                            "The -format option %s is not recognized\n",
   1.738 +                            argv[2]);
   1.739 +                    return (1);
   1.740 +                }
   1.741 +                argv += 2;
   1.742 +                argc -= 2;
   1.743 +            } else {
   1.744 +                fprintf(stderr, "The -format option requires an argument\n");
   1.745 +                return (1);
   1.746 +            }
   1.747 +        } else if (strcmp(argv[1], "-hw") == 0) {
   1.748 +            video_flags |= SDL_HWSURFACE;
   1.749 +            argv += 1;
   1.750 +            argc -= 1;
   1.751 +        } else if (strcmp(argv[1], "-flip") == 0) {
   1.752 +            video_flags |= SDL_DOUBLEBUF;
   1.753 +            argv += 1;
   1.754 +            argc -= 1;
   1.755 +        } else if (strcmp(argv[1], "-scale") == 0) {
   1.756 +            scale = 1;
   1.757 +            argv += 1;
   1.758 +            argc -= 1;
   1.759 +        } else if (strcmp(argv[1], "-mono") == 0) {
   1.760 +            monochrome = 1;
   1.761 +            argv += 1;
   1.762 +            argc -= 1;
   1.763 +        } else if ((strcmp(argv[1], "-help") == 0)
   1.764 +                   || (strcmp(argv[1], "-h") == 0)) {
   1.765 +            PrintUsage(argv0);
   1.766 +            return (1);
   1.767 +        } else if (strcmp(argv[1], "-fullscreen") == 0) {
   1.768 +            video_flags |= SDL_FULLSCREEN;
   1.769 +            argv += 1;
   1.770 +            argc -= 1;
   1.771 +        } else
   1.772 +            break;
   1.773 +    }
   1.774 +    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   1.775 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   1.776 +        return (1);
   1.777 +    }
   1.778  
   1.779 -	/* Initialize the display */
   1.780 -	screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
   1.781 -	if ( screen == NULL ) {
   1.782 -		fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
   1.783 -					w, h, desired_bpp, SDL_GetError());
   1.784 -		quit(1);
   1.785 -	}
   1.786 -	printf("Set%s %dx%dx%d mode\n",
   1.787 -			screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
   1.788 -			screen->w, screen->h, screen->format->BitsPerPixel);
   1.789 -	printf("(video surface located in %s memory)\n",
   1.790 -			(screen->flags&SDL_HWSURFACE) ? "video" : "system");
   1.791 -	if ( screen->flags & SDL_DOUBLEBUF ) {
   1.792 -		printf("Double-buffering enabled\n");
   1.793 -		flip = 1;
   1.794 -	}
   1.795 +    /* Initialize the display */
   1.796 +    screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
   1.797 +    if (screen == NULL) {
   1.798 +        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
   1.799 +                w, h, desired_bpp, SDL_GetError());
   1.800 +        quit(1);
   1.801 +    }
   1.802 +    printf("Set%s %dx%dx%d mode\n",
   1.803 +           screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
   1.804 +           screen->w, screen->h, screen->format->BitsPerPixel);
   1.805 +    printf("(video surface located in %s memory)\n",
   1.806 +           (screen->flags & SDL_HWSURFACE) ? "video" : "system");
   1.807 +    if (screen->flags & SDL_DOUBLEBUF) {
   1.808 +        printf("Double-buffering enabled\n");
   1.809 +        flip = 1;
   1.810 +    }
   1.811  
   1.812 -	/* Set the window manager title bar */
   1.813 -	SDL_WM_SetCaption("SDL test overlay", "testoverlay");
   1.814 +    /* Set the window manager title bar */
   1.815 +    SDL_WM_SetCaption("SDL test overlay", "testoverlay");
   1.816  
   1.817 -	/* Load picture */
   1.818 -	bmpfile=(argv[1]?argv[1]:"sample.bmp");
   1.819 -	pic = SDL_LoadBMP(bmpfile);
   1.820 -	if ( pic == NULL ) {
   1.821 -		fprintf(stderr, "Couldn't load %s: %s\n", bmpfile,
   1.822 -							SDL_GetError());
   1.823 -		quit(1);
   1.824 -	}
   1.825 +    /* Load picture */
   1.826 +    bmpfile = (argv[1] ? argv[1] : "sample.bmp");
   1.827 +    pic = SDL_LoadBMP(bmpfile);
   1.828 +    if (pic == NULL) {
   1.829 +        fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError());
   1.830 +        quit(1);
   1.831 +    }
   1.832  
   1.833 -	/* Convert the picture to 32bits, for easy conversion */
   1.834 -	{
   1.835 -		SDL_Surface *newsurf;
   1.836 -		SDL_PixelFormat format;
   1.837 +    /* Convert the picture to 32bits, for easy conversion */
   1.838 +    {
   1.839 +        SDL_Surface *newsurf;
   1.840 +        SDL_PixelFormat format;
   1.841  
   1.842 -		format.palette=NULL;
   1.843 -		format.BitsPerPixel=32;
   1.844 -		format.BytesPerPixel=4;
   1.845 +        format.palette = NULL;
   1.846 +        format.BitsPerPixel = 32;
   1.847 +        format.BytesPerPixel = 4;
   1.848  #if SDL_BYTEORDER == SDL_LIL_ENDIAN
   1.849 -		format.Rshift=0;
   1.850 -		format.Gshift=8;
   1.851 -		format.Bshift=16;
   1.852 +        format.Rshift = 0;
   1.853 +        format.Gshift = 8;
   1.854 +        format.Bshift = 16;
   1.855  #else
   1.856 -		format.Rshift=24;
   1.857 -		format.Gshift=16;
   1.858 -		format.Bshift=8;
   1.859 +        format.Rshift = 24;
   1.860 +        format.Gshift = 16;
   1.861 +        format.Bshift = 8;
   1.862  #endif
   1.863 -		format.Ashift=0;
   1.864 -		format.Rmask=0xff<<format.Rshift;
   1.865 -		format.Gmask=0xff<<format.Gshift;
   1.866 -		format.Bmask=0xff<<format.Bshift;
   1.867 -		format.Amask=0;
   1.868 -		format.Rloss=0;
   1.869 -		format.Gloss=0;
   1.870 -		format.Bloss=0;
   1.871 -		format.Aloss=8;
   1.872 -		format.colorkey=0;
   1.873 -		format.alpha=0;
   1.874 +        format.Ashift = 0;
   1.875 +        format.Rmask = 0xff << format.Rshift;
   1.876 +        format.Gmask = 0xff << format.Gshift;
   1.877 +        format.Bmask = 0xff << format.Bshift;
   1.878 +        format.Amask = 0;
   1.879 +        format.Rloss = 0;
   1.880 +        format.Gloss = 0;
   1.881 +        format.Bloss = 0;
   1.882 +        format.Aloss = 8;
   1.883 +        format.colorkey = 0;
   1.884 +        format.alpha = 0;
   1.885  
   1.886 -		newsurf=SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
   1.887 -		if(!newsurf)
   1.888 -		{
   1.889 -			fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n",
   1.890 -							SDL_GetError());
   1.891 -			quit(1);
   1.892 -		}
   1.893 -		SDL_FreeSurface(pic);
   1.894 -		pic=newsurf;
   1.895 -	}
   1.896 -	
   1.897 -	/* Create the overlay */
   1.898 -	overlay = SDL_CreateYUVOverlay(pic->w, pic->h, overlay_format, screen);
   1.899 -	if ( overlay == NULL ) {
   1.900 -		fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
   1.901 -		quit(1);
   1.902 -	}
   1.903 -	printf("Created %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes,
   1.904 -			overlay->hw_overlay?"hardware":"software",
   1.905 -			overlay->format==SDL_YV12_OVERLAY?"YV12":
   1.906 -			overlay->format==SDL_IYUV_OVERLAY?"IYUV":
   1.907 -			overlay->format==SDL_YUY2_OVERLAY?"YUY2":
   1.908 -			overlay->format==SDL_UYVY_OVERLAY?"UYVY":
   1.909 -			overlay->format==SDL_YVYU_OVERLAY?"YVYU":
   1.910 -			"Unknown");
   1.911 -	for(i=0; i<overlay->planes; i++)
   1.912 -	{
   1.913 -		printf("  plane %d: pitch=%d\n", i, overlay->pitches[i]);
   1.914 -	}
   1.915 -	
   1.916 -	/* Convert to YUV, and draw to the overlay */
   1.917 +        newsurf = SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
   1.918 +        if (!newsurf) {
   1.919 +            fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n",
   1.920 +                    SDL_GetError());
   1.921 +            quit(1);
   1.922 +        }
   1.923 +        SDL_FreeSurface(pic);
   1.924 +        pic = newsurf;
   1.925 +    }
   1.926 +
   1.927 +    /* Create the overlay */
   1.928 +    overlay = SDL_CreateYUVOverlay(pic->w, pic->h, overlay_format, screen);
   1.929 +    if (overlay == NULL) {
   1.930 +        fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
   1.931 +        quit(1);
   1.932 +    }
   1.933 +    printf("Created %dx%dx%d %s %s overlay\n", overlay->w, overlay->h,
   1.934 +           overlay->planes, overlay->hw_overlay ? "hardware" : "software",
   1.935 +           overlay->format == SDL_YV12_OVERLAY ? "YV12" : overlay->format ==
   1.936 +           SDL_IYUV_OVERLAY ? "IYUV" : overlay->format ==
   1.937 +           SDL_YUY2_OVERLAY ? "YUY2" : overlay->format ==
   1.938 +           SDL_UYVY_OVERLAY ? "UYVY" : overlay->format ==
   1.939 +           SDL_YVYU_OVERLAY ? "YVYU" : "Unknown");
   1.940 +    for (i = 0; i < overlay->planes; i++) {
   1.941 +        printf("  plane %d: pitch=%d\n", i, overlay->pitches[i]);
   1.942 +    }
   1.943 +
   1.944 +    /* Convert to YUV, and draw to the overlay */
   1.945  #ifdef BENCHMARK_SDL
   1.946 -	then = SDL_GetTicks();
   1.947 +    then = SDL_GetTicks();
   1.948  #endif
   1.949 -	switch(overlay->format)
   1.950 -	{
   1.951 -		case SDL_YV12_OVERLAY:
   1.952 -			ConvertRGBtoYV12(pic,overlay,monochrome,luminance);
   1.953 -			break;
   1.954 -		case SDL_UYVY_OVERLAY:
   1.955 -			ConvertRGBtoUYVY(pic,overlay,monochrome,luminance);
   1.956 -			break;
   1.957 -		case SDL_YVYU_OVERLAY:
   1.958 -			ConvertRGBtoYVYU(pic,overlay,monochrome,luminance);
   1.959 -			break;
   1.960 -		case SDL_YUY2_OVERLAY:
   1.961 -			ConvertRGBtoYUY2(pic,overlay,monochrome,luminance);
   1.962 -			break;
   1.963 -		case SDL_IYUV_OVERLAY:
   1.964 -			ConvertRGBtoIYUV(pic,overlay,monochrome,luminance);
   1.965 -			break;
   1.966 -		default:
   1.967 -			printf("cannot convert RGB picture to obtained YUV format!\n");
   1.968 -			quit(1);
   1.969 -			break;
   1.970 -	}
   1.971 +    switch (overlay->format) {
   1.972 +    case SDL_YV12_OVERLAY:
   1.973 +        ConvertRGBtoYV12(pic, overlay, monochrome, luminance);
   1.974 +        break;
   1.975 +    case SDL_UYVY_OVERLAY:
   1.976 +        ConvertRGBtoUYVY(pic, overlay, monochrome, luminance);
   1.977 +        break;
   1.978 +    case SDL_YVYU_OVERLAY:
   1.979 +        ConvertRGBtoYVYU(pic, overlay, monochrome, luminance);
   1.980 +        break;
   1.981 +    case SDL_YUY2_OVERLAY:
   1.982 +        ConvertRGBtoYUY2(pic, overlay, monochrome, luminance);
   1.983 +        break;
   1.984 +    case SDL_IYUV_OVERLAY:
   1.985 +        ConvertRGBtoIYUV(pic, overlay, monochrome, luminance);
   1.986 +        break;
   1.987 +    default:
   1.988 +        printf("cannot convert RGB picture to obtained YUV format!\n");
   1.989 +        quit(1);
   1.990 +        break;
   1.991 +    }
   1.992  #ifdef BENCHMARK_SDL
   1.993 -	now = SDL_GetTicks();
   1.994 -	printf("Conversion Time: %d milliseconds\n", now-then);
   1.995 +    now = SDL_GetTicks();
   1.996 +    printf("Conversion Time: %d milliseconds\n", now - then);
   1.997  #endif
   1.998 -	
   1.999 -	/* Do all the drawing work */
  1.1000 +
  1.1001 +    /* Do all the drawing work */
  1.1002  #ifdef BENCHMARK_SDL
  1.1003 -	then = SDL_GetTicks();
  1.1004 +    then = SDL_GetTicks();
  1.1005  #endif
  1.1006 -	Draw();
  1.1007 +    Draw();
  1.1008  #ifdef BENCHMARK_SDL
  1.1009 -	now = SDL_GetTicks();
  1.1010 -	printf("Time: %d milliseconds\n", now-then);
  1.1011 +    now = SDL_GetTicks();
  1.1012 +    printf("Time: %d milliseconds\n", now - then);
  1.1013  #endif
  1.1014 -	SDL_Delay(delay*1000);
  1.1015 -	SDL_Quit();
  1.1016 -	return(0);
  1.1017 +    SDL_Delay(delay * 1000);
  1.1018 +    SDL_Quit();
  1.1019 +    return (0);
  1.1020  }
  1.1021 -