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