src/video/SDL_yuv_sw.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1644 8a858076f39d
child 1668 4da1ee79c9af
     1.1 --- a/src/video/SDL_yuv_sw.c	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/src/video/SDL_yuv_sw.c	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -91,103 +91,104 @@
     1.4  
     1.5  /* The functions used to manipulate software video overlays */
     1.6  static struct private_yuvhwfuncs sw_yuvfuncs = {
     1.7 -	SDL_LockYUV_SW,
     1.8 -	SDL_UnlockYUV_SW,
     1.9 -	SDL_DisplayYUV_SW,
    1.10 -	SDL_FreeYUV_SW
    1.11 +    SDL_LockYUV_SW,
    1.12 +    SDL_UnlockYUV_SW,
    1.13 +    SDL_DisplayYUV_SW,
    1.14 +    SDL_FreeYUV_SW
    1.15  };
    1.16  
    1.17  /* RGB conversion lookup tables */
    1.18 -struct private_yuvhwdata {
    1.19 -	SDL_Surface *stretch;
    1.20 -	SDL_Surface *display;
    1.21 -	Uint8 *pixels;
    1.22 -	int *colortab;
    1.23 -	Uint32 *rgb_2_pix;
    1.24 -	void (*Display1X)(int *colortab, Uint32 *rgb_2_pix,
    1.25 -                          unsigned char *lum, unsigned char *cr,
    1.26 -                          unsigned char *cb, unsigned char *out,
    1.27 -                          int rows, int cols, int mod );
    1.28 -	void (*Display2X)(int *colortab, Uint32 *rgb_2_pix,
    1.29 -	                  unsigned char *lum, unsigned char *cr,
    1.30 -                          unsigned char *cb, unsigned char *out,
    1.31 -                          int rows, int cols, int mod );
    1.32 +struct private_yuvhwdata
    1.33 +{
    1.34 +    SDL_Surface *stretch;
    1.35 +    SDL_Surface *display;
    1.36 +    Uint8 *pixels;
    1.37 +    int *colortab;
    1.38 +    Uint32 *rgb_2_pix;
    1.39 +    void (*Display1X) (int *colortab, Uint32 * rgb_2_pix,
    1.40 +                       unsigned char *lum, unsigned char *cr,
    1.41 +                       unsigned char *cb, unsigned char *out,
    1.42 +                       int rows, int cols, int mod);
    1.43 +    void (*Display2X) (int *colortab, Uint32 * rgb_2_pix,
    1.44 +                       unsigned char *lum, unsigned char *cr,
    1.45 +                       unsigned char *cb, unsigned char *out,
    1.46 +                       int rows, int cols, int mod);
    1.47  
    1.48 -	/* These are just so we don't have to allocate them separately */
    1.49 -	Uint16 pitches[3];
    1.50 -	Uint8 *planes[3];
    1.51 +    /* These are just so we don't have to allocate them separately */
    1.52 +    Uint16 pitches[3];
    1.53 +    Uint8 *planes[3];
    1.54  };
    1.55  
    1.56  
    1.57  /* The colorspace conversion functions */
    1.58  
    1.59 -#if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES*/
    1.60 -extern void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
    1.61 +#if 0                           /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */
    1.62 +extern void Color565DitherYV12MMX1X (int *colortab, Uint32 * rgb_2_pix,
    1.63                                       unsigned char *lum, unsigned char *cr,
    1.64                                       unsigned char *cb, unsigned char *out,
    1.65 -                                     int rows, int cols, int mod );
    1.66 -extern void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
    1.67 +                                     int rows, int cols, int mod);
    1.68 +extern void ColorRGBDitherYV12MMX1X (int *colortab, Uint32 * rgb_2_pix,
    1.69                                       unsigned char *lum, unsigned char *cr,
    1.70                                       unsigned char *cb, unsigned char *out,
    1.71 -                                     int rows, int cols, int mod );
    1.72 -#endif 
    1.73 +                                     int rows, int cols, int mod);
    1.74 +#endif
    1.75  
    1.76 -static void Color16DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix,
    1.77 -                                    unsigned char *lum, unsigned char *cr,
    1.78 -                                    unsigned char *cb, unsigned char *out,
    1.79 -                                    int rows, int cols, int mod )
    1.80 +static void
    1.81 +Color16DitherYV12Mod1X (int *colortab, Uint32 * rgb_2_pix,
    1.82 +                        unsigned char *lum, unsigned char *cr,
    1.83 +                        unsigned char *cb, unsigned char *out,
    1.84 +                        int rows, int cols, int mod)
    1.85  {
    1.86 -    unsigned short* row1;
    1.87 -    unsigned short* row2;
    1.88 -    unsigned char* lum2;
    1.89 +    unsigned short *row1;
    1.90 +    unsigned short *row2;
    1.91 +    unsigned char *lum2;
    1.92      int x, y;
    1.93      int cr_r;
    1.94      int crb_g;
    1.95      int cb_b;
    1.96      int cols_2 = cols / 2;
    1.97  
    1.98 -    row1 = (unsigned short*) out;
    1.99 +    row1 = (unsigned short *) out;
   1.100      row2 = row1 + cols + mod;
   1.101      lum2 = lum + cols;
   1.102  
   1.103      mod += cols + mod;
   1.104  
   1.105      y = rows / 2;
   1.106 -    while( y-- )
   1.107 -    {
   1.108 +    while (y--) {
   1.109          x = cols_2;
   1.110 -        while( x-- )
   1.111 -        {
   1.112 +        while (x--) {
   1.113              register int L;
   1.114  
   1.115 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.116 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.117 -                               + colortab[ *cb + 2*256 ];
   1.118 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.119 -            ++cr; ++cb;
   1.120 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.121 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.122 +                + colortab[*cb + 2 * 256];
   1.123 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.124 +            ++cr;
   1.125 +            ++cb;
   1.126  
   1.127              L = *lum++;
   1.128 -            *row1++ = (unsigned short)(rgb_2_pix[ L + cr_r ] |
   1.129 -                                       rgb_2_pix[ L + crb_g ] |
   1.130 -                                       rgb_2_pix[ L + cb_b ]);
   1.131 +            *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
   1.132 +                                        rgb_2_pix[L + crb_g] |
   1.133 +                                        rgb_2_pix[L + cb_b]);
   1.134  
   1.135              L = *lum++;
   1.136 -            *row1++ = (unsigned short)(rgb_2_pix[ L + cr_r ] |
   1.137 -                                       rgb_2_pix[ L + crb_g ] |
   1.138 -                                       rgb_2_pix[ L + cb_b ]);
   1.139 +            *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
   1.140 +                                        rgb_2_pix[L + crb_g] |
   1.141 +                                        rgb_2_pix[L + cb_b]);
   1.142  
   1.143  
   1.144              /* Now, do second row.  */
   1.145  
   1.146              L = *lum2++;
   1.147 -            *row2++ = (unsigned short)(rgb_2_pix[ L + cr_r ] |
   1.148 -                                       rgb_2_pix[ L + crb_g ] |
   1.149 -                                       rgb_2_pix[ L + cb_b ]);
   1.150 +            *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
   1.151 +                                        rgb_2_pix[L + crb_g] |
   1.152 +                                        rgb_2_pix[L + cb_b]);
   1.153  
   1.154              L = *lum2++;
   1.155 -            *row2++ = (unsigned short)(rgb_2_pix[ L + cr_r ] |
   1.156 -                                       rgb_2_pix[ L + crb_g ] |
   1.157 -                                       rgb_2_pix[ L + cb_b ]);
   1.158 +            *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
   1.159 +                                        rgb_2_pix[L + crb_g] |
   1.160 +                                        rgb_2_pix[L + cb_b]);
   1.161          }
   1.162  
   1.163          /*
   1.164 @@ -195,22 +196,23 @@
   1.165           * to the ++'s above),but they need to be at the start
   1.166           * of the line after that.
   1.167           */
   1.168 -        lum  += cols;
   1.169 +        lum += cols;
   1.170          lum2 += cols;
   1.171          row1 += mod;
   1.172          row2 += mod;
   1.173      }
   1.174  }
   1.175  
   1.176 -static void Color24DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix,
   1.177 -                                    unsigned char *lum, unsigned char *cr,
   1.178 -                                    unsigned char *cb, unsigned char *out,
   1.179 -                                    int rows, int cols, int mod )
   1.180 +static void
   1.181 +Color24DitherYV12Mod1X (int *colortab, Uint32 * rgb_2_pix,
   1.182 +                        unsigned char *lum, unsigned char *cr,
   1.183 +                        unsigned char *cb, unsigned char *out,
   1.184 +                        int rows, int cols, int mod)
   1.185  {
   1.186      unsigned int value;
   1.187 -    unsigned char* row1;
   1.188 -    unsigned char* row2;
   1.189 -    unsigned char* lum2;
   1.190 +    unsigned char *row1;
   1.191 +    unsigned char *row2;
   1.192 +    unsigned char *lum2;
   1.193      int x, y;
   1.194      int cr_r;
   1.195      int crb_g;
   1.196 @@ -218,59 +220,54 @@
   1.197      int cols_2 = cols / 2;
   1.198  
   1.199      row1 = out;
   1.200 -    row2 = row1 + cols*3 + mod*3;
   1.201 +    row2 = row1 + cols * 3 + mod * 3;
   1.202      lum2 = lum + cols;
   1.203  
   1.204      mod += cols + mod;
   1.205      mod *= 3;
   1.206  
   1.207      y = rows / 2;
   1.208 -    while( y-- )
   1.209 -    {
   1.210 +    while (y--) {
   1.211          x = cols_2;
   1.212 -        while( x-- )
   1.213 -        {
   1.214 +        while (x--) {
   1.215              register int L;
   1.216  
   1.217 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.218 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.219 -                               + colortab[ *cb + 2*256 ];
   1.220 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.221 -            ++cr; ++cb;
   1.222 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.223 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.224 +                + colortab[*cb + 2 * 256];
   1.225 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.226 +            ++cr;
   1.227 +            ++cb;
   1.228  
   1.229              L = *lum++;
   1.230 -            value = (rgb_2_pix[ L + cr_r ] |
   1.231 -                     rgb_2_pix[ L + crb_g ] |
   1.232 -                     rgb_2_pix[ L + cb_b ]);
   1.233 -            *row1++ = (value      ) & 0xFF;
   1.234 -            *row1++ = (value >>  8) & 0xFF;
   1.235 +            value = (rgb_2_pix[L + cr_r] |
   1.236 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.237 +            *row1++ = (value) & 0xFF;
   1.238 +            *row1++ = (value >> 8) & 0xFF;
   1.239              *row1++ = (value >> 16) & 0xFF;
   1.240  
   1.241              L = *lum++;
   1.242 -            value = (rgb_2_pix[ L + cr_r ] |
   1.243 -                     rgb_2_pix[ L + crb_g ] |
   1.244 -                     rgb_2_pix[ L + cb_b ]);
   1.245 -            *row1++ = (value      ) & 0xFF;
   1.246 -            *row1++ = (value >>  8) & 0xFF;
   1.247 +            value = (rgb_2_pix[L + cr_r] |
   1.248 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.249 +            *row1++ = (value) & 0xFF;
   1.250 +            *row1++ = (value >> 8) & 0xFF;
   1.251              *row1++ = (value >> 16) & 0xFF;
   1.252  
   1.253  
   1.254              /* Now, do second row.  */
   1.255  
   1.256              L = *lum2++;
   1.257 -            value = (rgb_2_pix[ L + cr_r ] |
   1.258 -                     rgb_2_pix[ L + crb_g ] |
   1.259 -                     rgb_2_pix[ L + cb_b ]);
   1.260 -            *row2++ = (value      ) & 0xFF;
   1.261 -            *row2++ = (value >>  8) & 0xFF;
   1.262 +            value = (rgb_2_pix[L + cr_r] |
   1.263 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.264 +            *row2++ = (value) & 0xFF;
   1.265 +            *row2++ = (value >> 8) & 0xFF;
   1.266              *row2++ = (value >> 16) & 0xFF;
   1.267  
   1.268              L = *lum2++;
   1.269 -            value = (rgb_2_pix[ L + cr_r ] |
   1.270 -                     rgb_2_pix[ L + crb_g ] |
   1.271 -                     rgb_2_pix[ L + cb_b ]);
   1.272 -            *row2++ = (value      ) & 0xFF;
   1.273 -            *row2++ = (value >>  8) & 0xFF;
   1.274 +            value = (rgb_2_pix[L + cr_r] |
   1.275 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.276 +            *row2++ = (value) & 0xFF;
   1.277 +            *row2++ = (value >> 8) & 0xFF;
   1.278              *row2++ = (value >> 16) & 0xFF;
   1.279          }
   1.280  
   1.281 @@ -279,69 +276,65 @@
   1.282           * to the ++'s above),but they need to be at the start
   1.283           * of the line after that.
   1.284           */
   1.285 -        lum  += cols;
   1.286 +        lum += cols;
   1.287          lum2 += cols;
   1.288          row1 += mod;
   1.289          row2 += mod;
   1.290      }
   1.291  }
   1.292  
   1.293 -static void Color32DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix,
   1.294 -                                    unsigned char *lum, unsigned char *cr,
   1.295 -                                    unsigned char *cb, unsigned char *out,
   1.296 -                                    int rows, int cols, int mod )
   1.297 +static void
   1.298 +Color32DitherYV12Mod1X (int *colortab, Uint32 * rgb_2_pix,
   1.299 +                        unsigned char *lum, unsigned char *cr,
   1.300 +                        unsigned char *cb, unsigned char *out,
   1.301 +                        int rows, int cols, int mod)
   1.302  {
   1.303 -    unsigned int* row1;
   1.304 -    unsigned int* row2;
   1.305 -    unsigned char* lum2;
   1.306 +    unsigned int *row1;
   1.307 +    unsigned int *row2;
   1.308 +    unsigned char *lum2;
   1.309      int x, y;
   1.310      int cr_r;
   1.311      int crb_g;
   1.312      int cb_b;
   1.313      int cols_2 = cols / 2;
   1.314  
   1.315 -    row1 = (unsigned int*) out;
   1.316 +    row1 = (unsigned int *) out;
   1.317      row2 = row1 + cols + mod;
   1.318      lum2 = lum + cols;
   1.319  
   1.320      mod += cols + mod;
   1.321  
   1.322      y = rows / 2;
   1.323 -    while( y-- )
   1.324 -    {
   1.325 +    while (y--) {
   1.326          x = cols_2;
   1.327 -        while( x-- )
   1.328 -        {
   1.329 +        while (x--) {
   1.330              register int L;
   1.331  
   1.332 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.333 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.334 -                               + colortab[ *cb + 2*256 ];
   1.335 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.336 -            ++cr; ++cb;
   1.337 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.338 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.339 +                + colortab[*cb + 2 * 256];
   1.340 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.341 +            ++cr;
   1.342 +            ++cb;
   1.343  
   1.344              L = *lum++;
   1.345 -            *row1++ = (rgb_2_pix[ L + cr_r ] |
   1.346 -                       rgb_2_pix[ L + crb_g ] |
   1.347 -                       rgb_2_pix[ L + cb_b ]);
   1.348 +            *row1++ = (rgb_2_pix[L + cr_r] |
   1.349 +                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.350  
   1.351              L = *lum++;
   1.352 -            *row1++ = (rgb_2_pix[ L + cr_r ] |
   1.353 -                       rgb_2_pix[ L + crb_g ] |
   1.354 -                       rgb_2_pix[ L + cb_b ]);
   1.355 +            *row1++ = (rgb_2_pix[L + cr_r] |
   1.356 +                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.357  
   1.358  
   1.359              /* Now, do second row.  */
   1.360  
   1.361              L = *lum2++;
   1.362 -            *row2++ = (rgb_2_pix[ L + cr_r ] |
   1.363 -                       rgb_2_pix[ L + crb_g ] |
   1.364 -                       rgb_2_pix[ L + cb_b ]);
   1.365 +            *row2++ = (rgb_2_pix[L + cr_r] |
   1.366 +                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.367  
   1.368              L = *lum2++;
   1.369 -            *row2++ = (rgb_2_pix[ L + cr_r ] |
   1.370 -                       rgb_2_pix[ L + crb_g ] |
   1.371 -                       rgb_2_pix[ L + cb_b ]);
   1.372 +            *row2++ = (rgb_2_pix[L + cr_r] |
   1.373 +                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.374          }
   1.375  
   1.376          /*
   1.377 @@ -349,7 +342,7 @@
   1.378           * to the ++'s above),but they need to be at the start
   1.379           * of the line after that.
   1.380           */
   1.381 -        lum  += cols;
   1.382 +        lum += cols;
   1.383          lum2 += cols;
   1.384          row1 += mod;
   1.385          row2 += mod;
   1.386 @@ -361,15 +354,16 @@
   1.387   * 16 bits replicated in the upper 16. This means I can write ints and get
   1.388   * the horisontal doubling for free (almost).
   1.389   */
   1.390 -static void Color16DitherYV12Mod2X( int *colortab, Uint32 *rgb_2_pix,
   1.391 -                                    unsigned char *lum, unsigned char *cr,
   1.392 -                                    unsigned char *cb, unsigned char *out,
   1.393 -                                    int rows, int cols, int mod )
   1.394 +static void
   1.395 +Color16DitherYV12Mod2X (int *colortab, Uint32 * rgb_2_pix,
   1.396 +                        unsigned char *lum, unsigned char *cr,
   1.397 +                        unsigned char *cb, unsigned char *out,
   1.398 +                        int rows, int cols, int mod)
   1.399  {
   1.400 -    unsigned int* row1 = (unsigned int*) out;
   1.401 -    const int next_row = cols+(mod/2);
   1.402 -    unsigned int* row2 = row1 + 2*next_row;
   1.403 -    unsigned char* lum2;
   1.404 +    unsigned int *row1 = (unsigned int *) out;
   1.405 +    const int next_row = cols + (mod / 2);
   1.406 +    unsigned int *row2 = row1 + 2 * next_row;
   1.407 +    unsigned char *lum2;
   1.408      int x, y;
   1.409      int cr_r;
   1.410      int crb_g;
   1.411 @@ -378,47 +372,46 @@
   1.412  
   1.413      lum2 = lum + cols;
   1.414  
   1.415 -    mod = (next_row * 3) + (mod/2);
   1.416 +    mod = (next_row * 3) + (mod / 2);
   1.417  
   1.418      y = rows / 2;
   1.419 -    while( y-- )
   1.420 -    {
   1.421 +    while (y--) {
   1.422          x = cols_2;
   1.423 -        while( x-- )
   1.424 -        {
   1.425 +        while (x--) {
   1.426              register int L;
   1.427  
   1.428 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.429 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.430 -                               + colortab[ *cb + 2*256 ];
   1.431 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.432 -            ++cr; ++cb;
   1.433 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.434 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.435 +                + colortab[*cb + 2 * 256];
   1.436 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.437 +            ++cr;
   1.438 +            ++cb;
   1.439  
   1.440              L = *lum++;
   1.441 -            row1[0] = row1[next_row] = (rgb_2_pix[ L + cr_r ] |
   1.442 -                                        rgb_2_pix[ L + crb_g ] |
   1.443 -                                        rgb_2_pix[ L + cb_b ]);
   1.444 +            row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
   1.445 +                                        rgb_2_pix[L + crb_g] |
   1.446 +                                        rgb_2_pix[L + cb_b]);
   1.447              row1++;
   1.448  
   1.449              L = *lum++;
   1.450 -            row1[0] = row1[next_row] = (rgb_2_pix[ L + cr_r ] |
   1.451 -                                        rgb_2_pix[ L + crb_g ] |
   1.452 -                                        rgb_2_pix[ L + cb_b ]);
   1.453 +            row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
   1.454 +                                        rgb_2_pix[L + crb_g] |
   1.455 +                                        rgb_2_pix[L + cb_b]);
   1.456              row1++;
   1.457  
   1.458  
   1.459              /* Now, do second row. */
   1.460  
   1.461              L = *lum2++;
   1.462 -            row2[0] = row2[next_row] = (rgb_2_pix[ L + cr_r ] |
   1.463 -                                        rgb_2_pix[ L + crb_g ] |
   1.464 -                                        rgb_2_pix[ L + cb_b ]);
   1.465 +            row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
   1.466 +                                        rgb_2_pix[L + crb_g] |
   1.467 +                                        rgb_2_pix[L + cb_b]);
   1.468              row2++;
   1.469  
   1.470              L = *lum2++;
   1.471 -            row2[0] = row2[next_row] = (rgb_2_pix[ L + cr_r ] |
   1.472 -                                        rgb_2_pix[ L + crb_g ] |
   1.473 -                                        rgb_2_pix[ L + cb_b ]);
   1.474 +            row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
   1.475 +                                        rgb_2_pix[L + crb_g] |
   1.476 +                                        rgb_2_pix[L + cb_b]);
   1.477              row2++;
   1.478          }
   1.479  
   1.480 @@ -427,23 +420,24 @@
   1.481           * to the ++'s above),but they need to be at the start
   1.482           * of the line after that.
   1.483           */
   1.484 -        lum  += cols;
   1.485 +        lum += cols;
   1.486          lum2 += cols;
   1.487          row1 += mod;
   1.488          row2 += mod;
   1.489      }
   1.490  }
   1.491  
   1.492 -static void Color24DitherYV12Mod2X( int *colortab, Uint32 *rgb_2_pix,
   1.493 -                                    unsigned char *lum, unsigned char *cr,
   1.494 -                                    unsigned char *cb, unsigned char *out,
   1.495 -                                    int rows, int cols, int mod )
   1.496 +static void
   1.497 +Color24DitherYV12Mod2X (int *colortab, Uint32 * rgb_2_pix,
   1.498 +                        unsigned char *lum, unsigned char *cr,
   1.499 +                        unsigned char *cb, unsigned char *out,
   1.500 +                        int rows, int cols, int mod)
   1.501  {
   1.502      unsigned int value;
   1.503 -    unsigned char* row1 = out;
   1.504 -    const int next_row = (cols*2 + mod) * 3;
   1.505 -    unsigned char* row2 = row1 + 2*next_row;
   1.506 -    unsigned char* lum2;
   1.507 +    unsigned char *row1 = out;
   1.508 +    const int next_row = (cols * 2 + mod) * 3;
   1.509 +    unsigned char *row2 = row1 + 2 * next_row;
   1.510 +    unsigned char *lum2;
   1.511      int x, y;
   1.512      int cr_r;
   1.513      int crb_g;
   1.514 @@ -452,72 +446,67 @@
   1.515  
   1.516      lum2 = lum + cols;
   1.517  
   1.518 -    mod = next_row*3 + mod*3;
   1.519 +    mod = next_row * 3 + mod * 3;
   1.520  
   1.521      y = rows / 2;
   1.522 -    while( y-- )
   1.523 -    {
   1.524 +    while (y--) {
   1.525          x = cols_2;
   1.526 -        while( x-- )
   1.527 -        {
   1.528 +        while (x--) {
   1.529              register int L;
   1.530  
   1.531 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.532 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.533 -                               + colortab[ *cb + 2*256 ];
   1.534 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.535 -            ++cr; ++cb;
   1.536 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.537 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.538 +                + colortab[*cb + 2 * 256];
   1.539 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.540 +            ++cr;
   1.541 +            ++cb;
   1.542  
   1.543              L = *lum++;
   1.544 -            value = (rgb_2_pix[ L + cr_r ] |
   1.545 -                     rgb_2_pix[ L + crb_g ] |
   1.546 -                     rgb_2_pix[ L + cb_b ]);
   1.547 -            row1[0+0] = row1[3+0] = row1[next_row+0] = row1[next_row+3+0] =
   1.548 -                     (value      ) & 0xFF;
   1.549 -            row1[0+1] = row1[3+1] = row1[next_row+1] = row1[next_row+3+1] =
   1.550 -                     (value >>  8) & 0xFF;
   1.551 -            row1[0+2] = row1[3+2] = row1[next_row+2] = row1[next_row+3+2] =
   1.552 -                     (value >> 16) & 0xFF;
   1.553 -            row1 += 2*3;
   1.554 +            value = (rgb_2_pix[L + cr_r] |
   1.555 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.556 +            row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
   1.557 +                row1[next_row + 3 + 0] = (value) & 0xFF;
   1.558 +            row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
   1.559 +                row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
   1.560 +            row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
   1.561 +                row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
   1.562 +            row1 += 2 * 3;
   1.563  
   1.564              L = *lum++;
   1.565 -            value = (rgb_2_pix[ L + cr_r ] |
   1.566 -                     rgb_2_pix[ L + crb_g ] |
   1.567 -                     rgb_2_pix[ L + cb_b ]);
   1.568 -            row1[0+0] = row1[3+0] = row1[next_row+0] = row1[next_row+3+0] =
   1.569 -                     (value      ) & 0xFF;
   1.570 -            row1[0+1] = row1[3+1] = row1[next_row+1] = row1[next_row+3+1] =
   1.571 -                     (value >>  8) & 0xFF;
   1.572 -            row1[0+2] = row1[3+2] = row1[next_row+2] = row1[next_row+3+2] =
   1.573 -                     (value >> 16) & 0xFF;
   1.574 -            row1 += 2*3;
   1.575 +            value = (rgb_2_pix[L + cr_r] |
   1.576 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.577 +            row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
   1.578 +                row1[next_row + 3 + 0] = (value) & 0xFF;
   1.579 +            row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
   1.580 +                row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
   1.581 +            row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
   1.582 +                row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
   1.583 +            row1 += 2 * 3;
   1.584  
   1.585  
   1.586              /* Now, do second row. */
   1.587  
   1.588              L = *lum2++;
   1.589 -            value = (rgb_2_pix[ L + cr_r ] |
   1.590 -                     rgb_2_pix[ L + crb_g ] |
   1.591 -                     rgb_2_pix[ L + cb_b ]);
   1.592 -            row2[0+0] = row2[3+0] = row2[next_row+0] = row2[next_row+3+0] =
   1.593 -                     (value      ) & 0xFF;
   1.594 -            row2[0+1] = row2[3+1] = row2[next_row+1] = row2[next_row+3+1] =
   1.595 -                     (value >>  8) & 0xFF;
   1.596 -            row2[0+2] = row2[3+2] = row2[next_row+2] = row2[next_row+3+2] =
   1.597 -                     (value >> 16) & 0xFF;
   1.598 -            row2 += 2*3;
   1.599 +            value = (rgb_2_pix[L + cr_r] |
   1.600 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.601 +            row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
   1.602 +                row2[next_row + 3 + 0] = (value) & 0xFF;
   1.603 +            row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
   1.604 +                row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
   1.605 +            row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
   1.606 +                row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
   1.607 +            row2 += 2 * 3;
   1.608  
   1.609              L = *lum2++;
   1.610 -            value = (rgb_2_pix[ L + cr_r ] |
   1.611 -                     rgb_2_pix[ L + crb_g ] |
   1.612 -                     rgb_2_pix[ L + cb_b ]);
   1.613 -            row2[0+0] = row2[3+0] = row2[next_row+0] = row2[next_row+3+0] =
   1.614 -                     (value      ) & 0xFF;
   1.615 -            row2[0+1] = row2[3+1] = row2[next_row+1] = row2[next_row+3+1] =
   1.616 -                     (value >>  8) & 0xFF;
   1.617 -            row2[0+2] = row2[3+2] = row2[next_row+2] = row2[next_row+3+2] =
   1.618 -                     (value >> 16) & 0xFF;
   1.619 -            row2 += 2*3;
   1.620 +            value = (rgb_2_pix[L + cr_r] |
   1.621 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.622 +            row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
   1.623 +                row2[next_row + 3 + 0] = (value) & 0xFF;
   1.624 +            row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
   1.625 +                row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
   1.626 +            row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
   1.627 +                row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
   1.628 +            row2 += 2 * 3;
   1.629          }
   1.630  
   1.631          /*
   1.632 @@ -525,22 +514,23 @@
   1.633           * to the ++'s above),but they need to be at the start
   1.634           * of the line after that.
   1.635           */
   1.636 -        lum  += cols;
   1.637 +        lum += cols;
   1.638          lum2 += cols;
   1.639          row1 += mod;
   1.640          row2 += mod;
   1.641      }
   1.642  }
   1.643  
   1.644 -static void Color32DitherYV12Mod2X( int *colortab, Uint32 *rgb_2_pix,
   1.645 -                                    unsigned char *lum, unsigned char *cr,
   1.646 -                                    unsigned char *cb, unsigned char *out,
   1.647 -                                    int rows, int cols, int mod )
   1.648 +static void
   1.649 +Color32DitherYV12Mod2X (int *colortab, Uint32 * rgb_2_pix,
   1.650 +                        unsigned char *lum, unsigned char *cr,
   1.651 +                        unsigned char *cb, unsigned char *out,
   1.652 +                        int rows, int cols, int mod)
   1.653  {
   1.654 -    unsigned int* row1 = (unsigned int*) out;
   1.655 -    const int next_row = cols*2+mod;
   1.656 -    unsigned int* row2 = row1 + 2*next_row;
   1.657 -    unsigned char* lum2;
   1.658 +    unsigned int *row1 = (unsigned int *) out;
   1.659 +    const int next_row = cols * 2 + mod;
   1.660 +    unsigned int *row2 = row1 + 2 * next_row;
   1.661 +    unsigned char *lum2;
   1.662      int x, y;
   1.663      int cr_r;
   1.664      int crb_g;
   1.665 @@ -552,48 +542,43 @@
   1.666      mod = (next_row * 3) + mod;
   1.667  
   1.668      y = rows / 2;
   1.669 -    while( y-- )
   1.670 -    {
   1.671 +    while (y--) {
   1.672          x = cols_2;
   1.673 -        while( x-- )
   1.674 -        {
   1.675 +        while (x--) {
   1.676              register int L;
   1.677  
   1.678 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.679 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.680 -                               + colortab[ *cb + 2*256 ];
   1.681 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.682 -            ++cr; ++cb;
   1.683 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.684 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.685 +                + colortab[*cb + 2 * 256];
   1.686 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.687 +            ++cr;
   1.688 +            ++cb;
   1.689  
   1.690              L = *lum++;
   1.691 -            row1[0] = row1[1] = row1[next_row] = row1[next_row+1] =
   1.692 -                                       (rgb_2_pix[ L + cr_r ] |
   1.693 -                                        rgb_2_pix[ L + crb_g ] |
   1.694 -                                        rgb_2_pix[ L + cb_b ]);
   1.695 +            row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
   1.696 +                (rgb_2_pix[L + cr_r] |
   1.697 +                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.698              row1 += 2;
   1.699  
   1.700              L = *lum++;
   1.701 -            row1[0] = row1[1] = row1[next_row] = row1[next_row+1] =
   1.702 -                                       (rgb_2_pix[ L + cr_r ] |
   1.703 -                                        rgb_2_pix[ L + crb_g ] |
   1.704 -                                        rgb_2_pix[ L + cb_b ]);
   1.705 +            row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
   1.706 +                (rgb_2_pix[L + cr_r] |
   1.707 +                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.708              row1 += 2;
   1.709  
   1.710  
   1.711              /* Now, do second row. */
   1.712  
   1.713              L = *lum2++;
   1.714 -            row2[0] = row2[1] = row2[next_row] = row2[next_row+1] =
   1.715 -                                       (rgb_2_pix[ L + cr_r ] |
   1.716 -                                        rgb_2_pix[ L + crb_g ] |
   1.717 -                                        rgb_2_pix[ L + cb_b ]);
   1.718 +            row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
   1.719 +                (rgb_2_pix[L + cr_r] |
   1.720 +                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.721              row2 += 2;
   1.722  
   1.723              L = *lum2++;
   1.724 -            row2[0] = row2[1] = row2[next_row] = row2[next_row+1] =
   1.725 -                                       (rgb_2_pix[ L + cr_r ] |
   1.726 -                                        rgb_2_pix[ L + crb_g ] |
   1.727 -                                        rgb_2_pix[ L + cb_b ]);
   1.728 +            row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
   1.729 +                (rgb_2_pix[L + cr_r] |
   1.730 +                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.731              row2 += 2;
   1.732          }
   1.733  
   1.734 @@ -602,50 +587,52 @@
   1.735           * to the ++'s above),but they need to be at the start
   1.736           * of the line after that.
   1.737           */
   1.738 -        lum  += cols;
   1.739 +        lum += cols;
   1.740          lum2 += cols;
   1.741          row1 += mod;
   1.742          row2 += mod;
   1.743      }
   1.744  }
   1.745  
   1.746 -static void Color16DitherYUY2Mod1X( int *colortab, Uint32 *rgb_2_pix,
   1.747 -                                    unsigned char *lum, unsigned char *cr,
   1.748 -                                    unsigned char *cb, unsigned char *out,
   1.749 -                                    int rows, int cols, int mod )
   1.750 +static void
   1.751 +Color16DitherYUY2Mod1X (int *colortab, Uint32 * rgb_2_pix,
   1.752 +                        unsigned char *lum, unsigned char *cr,
   1.753 +                        unsigned char *cb, unsigned char *out,
   1.754 +                        int rows, int cols, int mod)
   1.755  {
   1.756 -    unsigned short* row;
   1.757 +    unsigned short *row;
   1.758      int x, y;
   1.759      int cr_r;
   1.760      int crb_g;
   1.761      int cb_b;
   1.762      int cols_2 = cols / 2;
   1.763  
   1.764 -    row = (unsigned short*) out;
   1.765 +    row = (unsigned short *) out;
   1.766  
   1.767      y = rows;
   1.768 -    while( y-- )
   1.769 -    {
   1.770 +    while (y--) {
   1.771          x = cols_2;
   1.772 -        while( x-- )
   1.773 -        {
   1.774 +        while (x--) {
   1.775              register int L;
   1.776  
   1.777 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.778 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.779 -                               + colortab[ *cb + 2*256 ];
   1.780 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.781 -            cr += 4; cb += 4;
   1.782 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.783 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.784 +                + colortab[*cb + 2 * 256];
   1.785 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.786 +            cr += 4;
   1.787 +            cb += 4;
   1.788  
   1.789 -            L = *lum; lum += 2;
   1.790 -            *row++ = (unsigned short)(rgb_2_pix[ L + cr_r ] |
   1.791 -                                      rgb_2_pix[ L + crb_g ] |
   1.792 -                                      rgb_2_pix[ L + cb_b ]);
   1.793 +            L = *lum;
   1.794 +            lum += 2;
   1.795 +            *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
   1.796 +                                       rgb_2_pix[L + crb_g] |
   1.797 +                                       rgb_2_pix[L + cb_b]);
   1.798  
   1.799 -            L = *lum; lum += 2;
   1.800 -            *row++ = (unsigned short)(rgb_2_pix[ L + cr_r ] |
   1.801 -                                      rgb_2_pix[ L + crb_g ] |
   1.802 -                                      rgb_2_pix[ L + cb_b ]);
   1.803 +            L = *lum;
   1.804 +            lum += 2;
   1.805 +            *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
   1.806 +                                       rgb_2_pix[L + crb_g] |
   1.807 +                                       rgb_2_pix[L + cb_b]);
   1.808  
   1.809          }
   1.810  
   1.811 @@ -653,49 +640,49 @@
   1.812      }
   1.813  }
   1.814  
   1.815 -static void Color24DitherYUY2Mod1X( int *colortab, Uint32 *rgb_2_pix,
   1.816 -                                    unsigned char *lum, unsigned char *cr,
   1.817 -                                    unsigned char *cb, unsigned char *out,
   1.818 -                                    int rows, int cols, int mod )
   1.819 +static void
   1.820 +Color24DitherYUY2Mod1X (int *colortab, Uint32 * rgb_2_pix,
   1.821 +                        unsigned char *lum, unsigned char *cr,
   1.822 +                        unsigned char *cb, unsigned char *out,
   1.823 +                        int rows, int cols, int mod)
   1.824  {
   1.825      unsigned int value;
   1.826 -    unsigned char* row;
   1.827 +    unsigned char *row;
   1.828      int x, y;
   1.829      int cr_r;
   1.830      int crb_g;
   1.831      int cb_b;
   1.832      int cols_2 = cols / 2;
   1.833  
   1.834 -    row = (unsigned char*) out;
   1.835 +    row = (unsigned char *) out;
   1.836      mod *= 3;
   1.837      y = rows;
   1.838 -    while( y-- )
   1.839 -    {
   1.840 +    while (y--) {
   1.841          x = cols_2;
   1.842 -        while( x-- )
   1.843 -        {
   1.844 +        while (x--) {
   1.845              register int L;
   1.846  
   1.847 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.848 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.849 -                               + colortab[ *cb + 2*256 ];
   1.850 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.851 -            cr += 4; cb += 4;
   1.852 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.853 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.854 +                + colortab[*cb + 2 * 256];
   1.855 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.856 +            cr += 4;
   1.857 +            cb += 4;
   1.858  
   1.859 -            L = *lum; lum += 2;
   1.860 -            value = (rgb_2_pix[ L + cr_r ] |
   1.861 -                     rgb_2_pix[ L + crb_g ] |
   1.862 -                     rgb_2_pix[ L + cb_b ]);
   1.863 -            *row++ = (value      ) & 0xFF;
   1.864 -            *row++ = (value >>  8) & 0xFF;
   1.865 +            L = *lum;
   1.866 +            lum += 2;
   1.867 +            value = (rgb_2_pix[L + cr_r] |
   1.868 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.869 +            *row++ = (value) & 0xFF;
   1.870 +            *row++ = (value >> 8) & 0xFF;
   1.871              *row++ = (value >> 16) & 0xFF;
   1.872  
   1.873 -            L = *lum; lum += 2;
   1.874 -            value = (rgb_2_pix[ L + cr_r ] |
   1.875 -                     rgb_2_pix[ L + crb_g ] |
   1.876 -                     rgb_2_pix[ L + cb_b ]);
   1.877 -            *row++ = (value      ) & 0xFF;
   1.878 -            *row++ = (value >>  8) & 0xFF;
   1.879 +            L = *lum;
   1.880 +            lum += 2;
   1.881 +            value = (rgb_2_pix[L + cr_r] |
   1.882 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.883 +            *row++ = (value) & 0xFF;
   1.884 +            *row++ = (value >> 8) & 0xFF;
   1.885              *row++ = (value >> 16) & 0xFF;
   1.886  
   1.887          }
   1.888 @@ -703,42 +690,42 @@
   1.889      }
   1.890  }
   1.891  
   1.892 -static void Color32DitherYUY2Mod1X( int *colortab, Uint32 *rgb_2_pix,
   1.893 -                                    unsigned char *lum, unsigned char *cr,
   1.894 -                                    unsigned char *cb, unsigned char *out,
   1.895 -                                    int rows, int cols, int mod )
   1.896 +static void
   1.897 +Color32DitherYUY2Mod1X (int *colortab, Uint32 * rgb_2_pix,
   1.898 +                        unsigned char *lum, unsigned char *cr,
   1.899 +                        unsigned char *cb, unsigned char *out,
   1.900 +                        int rows, int cols, int mod)
   1.901  {
   1.902 -    unsigned int* row;
   1.903 +    unsigned int *row;
   1.904      int x, y;
   1.905      int cr_r;
   1.906      int crb_g;
   1.907      int cb_b;
   1.908      int cols_2 = cols / 2;
   1.909  
   1.910 -    row = (unsigned int*) out;
   1.911 +    row = (unsigned int *) out;
   1.912      y = rows;
   1.913 -    while( y-- )
   1.914 -    {
   1.915 +    while (y--) {
   1.916          x = cols_2;
   1.917 -        while( x-- )
   1.918 -        {
   1.919 +        while (x--) {
   1.920              register int L;
   1.921  
   1.922 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.923 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.924 -                               + colortab[ *cb + 2*256 ];
   1.925 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.926 -            cr += 4; cb += 4;
   1.927 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.928 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.929 +                + colortab[*cb + 2 * 256];
   1.930 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.931 +            cr += 4;
   1.932 +            cb += 4;
   1.933  
   1.934 -            L = *lum; lum += 2;
   1.935 -            *row++ = (rgb_2_pix[ L + cr_r ] |
   1.936 -                       rgb_2_pix[ L + crb_g ] |
   1.937 -                       rgb_2_pix[ L + cb_b ]);
   1.938 +            L = *lum;
   1.939 +            lum += 2;
   1.940 +            *row++ = (rgb_2_pix[L + cr_r] |
   1.941 +                      rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.942  
   1.943 -            L = *lum; lum += 2;
   1.944 -            *row++ = (rgb_2_pix[ L + cr_r ] |
   1.945 -                       rgb_2_pix[ L + crb_g ] |
   1.946 -                       rgb_2_pix[ L + cb_b ]);
   1.947 +            L = *lum;
   1.948 +            lum += 2;
   1.949 +            *row++ = (rgb_2_pix[L + cr_r] |
   1.950 +                      rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
   1.951  
   1.952  
   1.953          }
   1.954 @@ -751,13 +738,14 @@
   1.955   * 16 bits replicated in the upper 16. This means I can write ints and get
   1.956   * the horisontal doubling for free (almost).
   1.957   */
   1.958 -static void Color16DitherYUY2Mod2X( int *colortab, Uint32 *rgb_2_pix,
   1.959 -                                    unsigned char *lum, unsigned char *cr,
   1.960 -                                    unsigned char *cb, unsigned char *out,
   1.961 -                                    int rows, int cols, int mod )
   1.962 +static void
   1.963 +Color16DitherYUY2Mod2X (int *colortab, Uint32 * rgb_2_pix,
   1.964 +                        unsigned char *lum, unsigned char *cr,
   1.965 +                        unsigned char *cb, unsigned char *out,
   1.966 +                        int rows, int cols, int mod)
   1.967  {
   1.968 -    unsigned int* row = (unsigned int*) out;
   1.969 -    const int next_row = cols+(mod/2);
   1.970 +    unsigned int *row = (unsigned int *) out;
   1.971 +    const int next_row = cols + (mod / 2);
   1.972      int x, y;
   1.973      int cr_r;
   1.974      int crb_g;
   1.975 @@ -765,29 +753,30 @@
   1.976      int cols_2 = cols / 2;
   1.977  
   1.978      y = rows;
   1.979 -    while( y-- )
   1.980 -    {
   1.981 +    while (y--) {
   1.982          x = cols_2;
   1.983 -        while( x-- )
   1.984 -        {
   1.985 +        while (x--) {
   1.986              register int L;
   1.987  
   1.988 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
   1.989 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
   1.990 -                               + colortab[ *cb + 2*256 ];
   1.991 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
   1.992 -            cr += 4; cb += 4;
   1.993 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
   1.994 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
   1.995 +                + colortab[*cb + 2 * 256];
   1.996 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
   1.997 +            cr += 4;
   1.998 +            cb += 4;
   1.999  
  1.1000 -            L = *lum; lum += 2;
  1.1001 -            row[0] = row[next_row] = (rgb_2_pix[ L + cr_r ] |
  1.1002 -                                        rgb_2_pix[ L + crb_g ] |
  1.1003 -                                        rgb_2_pix[ L + cb_b ]);
  1.1004 +            L = *lum;
  1.1005 +            lum += 2;
  1.1006 +            row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
  1.1007 +                                      rgb_2_pix[L + crb_g] |
  1.1008 +                                      rgb_2_pix[L + cb_b]);
  1.1009              row++;
  1.1010  
  1.1011 -            L = *lum; lum += 2;
  1.1012 -            row[0] = row[next_row] = (rgb_2_pix[ L + cr_r ] |
  1.1013 -                                        rgb_2_pix[ L + crb_g ] |
  1.1014 -                                        rgb_2_pix[ L + cb_b ]);
  1.1015 +            L = *lum;
  1.1016 +            lum += 2;
  1.1017 +            row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
  1.1018 +                                      rgb_2_pix[L + crb_g] |
  1.1019 +                                      rgb_2_pix[L + cb_b]);
  1.1020              row++;
  1.1021  
  1.1022          }
  1.1023 @@ -795,101 +784,101 @@
  1.1024      }
  1.1025  }
  1.1026  
  1.1027 -static void Color24DitherYUY2Mod2X( int *colortab, Uint32 *rgb_2_pix,
  1.1028 -                                    unsigned char *lum, unsigned char *cr,
  1.1029 -                                    unsigned char *cb, unsigned char *out,
  1.1030 -                                    int rows, int cols, int mod )
  1.1031 +static void
  1.1032 +Color24DitherYUY2Mod2X (int *colortab, Uint32 * rgb_2_pix,
  1.1033 +                        unsigned char *lum, unsigned char *cr,
  1.1034 +                        unsigned char *cb, unsigned char *out,
  1.1035 +                        int rows, int cols, int mod)
  1.1036  {
  1.1037      unsigned int value;
  1.1038 -    unsigned char* row = out;
  1.1039 -    const int next_row = (cols*2 + mod) * 3;
  1.1040 +    unsigned char *row = out;
  1.1041 +    const int next_row = (cols * 2 + mod) * 3;
  1.1042      int x, y;
  1.1043      int cr_r;
  1.1044      int crb_g;
  1.1045      int cb_b;
  1.1046      int cols_2 = cols / 2;
  1.1047      y = rows;
  1.1048 -    while( y-- )
  1.1049 -    {
  1.1050 +    while (y--) {
  1.1051          x = cols_2;
  1.1052 -        while( x-- )
  1.1053 -        {
  1.1054 +        while (x--) {
  1.1055              register int L;
  1.1056  
  1.1057 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
  1.1058 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
  1.1059 -                               + colortab[ *cb + 2*256 ];
  1.1060 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
  1.1061 -            cr += 4; cb += 4;
  1.1062 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
  1.1063 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
  1.1064 +                + colortab[*cb + 2 * 256];
  1.1065 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
  1.1066 +            cr += 4;
  1.1067 +            cb += 4;
  1.1068  
  1.1069 -            L = *lum; lum += 2;
  1.1070 -            value = (rgb_2_pix[ L + cr_r ] |
  1.1071 -                     rgb_2_pix[ L + crb_g ] |
  1.1072 -                     rgb_2_pix[ L + cb_b ]);
  1.1073 -            row[0+0] = row[3+0] = row[next_row+0] = row[next_row+3+0] =
  1.1074 -                     (value      ) & 0xFF;
  1.1075 -            row[0+1] = row[3+1] = row[next_row+1] = row[next_row+3+1] =
  1.1076 -                     (value >>  8) & 0xFF;
  1.1077 -            row[0+2] = row[3+2] = row[next_row+2] = row[next_row+3+2] =
  1.1078 -                     (value >> 16) & 0xFF;
  1.1079 -            row += 2*3;
  1.1080 +            L = *lum;
  1.1081 +            lum += 2;
  1.1082 +            value = (rgb_2_pix[L + cr_r] |
  1.1083 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
  1.1084 +            row[0 + 0] = row[3 + 0] = row[next_row + 0] =
  1.1085 +                row[next_row + 3 + 0] = (value) & 0xFF;
  1.1086 +            row[0 + 1] = row[3 + 1] = row[next_row + 1] =
  1.1087 +                row[next_row + 3 + 1] = (value >> 8) & 0xFF;
  1.1088 +            row[0 + 2] = row[3 + 2] = row[next_row + 2] =
  1.1089 +                row[next_row + 3 + 2] = (value >> 16) & 0xFF;
  1.1090 +            row += 2 * 3;
  1.1091  
  1.1092 -            L = *lum; lum += 2;
  1.1093 -            value = (rgb_2_pix[ L + cr_r ] |
  1.1094 -                     rgb_2_pix[ L + crb_g ] |
  1.1095 -                     rgb_2_pix[ L + cb_b ]);
  1.1096 -            row[0+0] = row[3+0] = row[next_row+0] = row[next_row+3+0] =
  1.1097 -                     (value      ) & 0xFF;
  1.1098 -            row[0+1] = row[3+1] = row[next_row+1] = row[next_row+3+1] =
  1.1099 -                     (value >>  8) & 0xFF;
  1.1100 -            row[0+2] = row[3+2] = row[next_row+2] = row[next_row+3+2] =
  1.1101 -                     (value >> 16) & 0xFF;
  1.1102 -            row += 2*3;
  1.1103 +            L = *lum;
  1.1104 +            lum += 2;
  1.1105 +            value = (rgb_2_pix[L + cr_r] |
  1.1106 +                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
  1.1107 +            row[0 + 0] = row[3 + 0] = row[next_row + 0] =
  1.1108 +                row[next_row + 3 + 0] = (value) & 0xFF;
  1.1109 +            row[0 + 1] = row[3 + 1] = row[next_row + 1] =
  1.1110 +                row[next_row + 3 + 1] = (value >> 8) & 0xFF;
  1.1111 +            row[0 + 2] = row[3 + 2] = row[next_row + 2] =
  1.1112 +                row[next_row + 3 + 2] = (value >> 16) & 0xFF;
  1.1113 +            row += 2 * 3;
  1.1114  
  1.1115          }
  1.1116          row += next_row;
  1.1117      }
  1.1118  }
  1.1119  
  1.1120 -static void Color32DitherYUY2Mod2X( int *colortab, Uint32 *rgb_2_pix,
  1.1121 -                                    unsigned char *lum, unsigned char *cr,
  1.1122 -                                    unsigned char *cb, unsigned char *out,
  1.1123 -                                    int rows, int cols, int mod )
  1.1124 +static void
  1.1125 +Color32DitherYUY2Mod2X (int *colortab, Uint32 * rgb_2_pix,
  1.1126 +                        unsigned char *lum, unsigned char *cr,
  1.1127 +                        unsigned char *cb, unsigned char *out,
  1.1128 +                        int rows, int cols, int mod)
  1.1129  {
  1.1130 -    unsigned int* row = (unsigned int*) out;
  1.1131 -    const int next_row = cols*2+mod;
  1.1132 +    unsigned int *row = (unsigned int *) out;
  1.1133 +    const int next_row = cols * 2 + mod;
  1.1134      int x, y;
  1.1135      int cr_r;
  1.1136      int crb_g;
  1.1137      int cb_b;
  1.1138      int cols_2 = cols / 2;
  1.1139 -    mod+=mod;
  1.1140 +    mod += mod;
  1.1141      y = rows;
  1.1142 -    while( y-- )
  1.1143 -    {
  1.1144 +    while (y--) {
  1.1145          x = cols_2;
  1.1146 -        while( x-- )
  1.1147 -        {
  1.1148 +        while (x--) {
  1.1149              register int L;
  1.1150  
  1.1151 -            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
  1.1152 -            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
  1.1153 -                               + colortab[ *cb + 2*256 ];
  1.1154 -            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
  1.1155 -            cr += 4; cb += 4;
  1.1156 +            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
  1.1157 +            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
  1.1158 +                + colortab[*cb + 2 * 256];
  1.1159 +            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
  1.1160 +            cr += 4;
  1.1161 +            cb += 4;
  1.1162  
  1.1163 -            L = *lum; lum += 2;
  1.1164 -            row[0] = row[1] = row[next_row] = row[next_row+1] =
  1.1165 -                                       (rgb_2_pix[ L + cr_r ] |
  1.1166 -                                        rgb_2_pix[ L + crb_g ] |
  1.1167 -                                        rgb_2_pix[ L + cb_b ]);
  1.1168 +            L = *lum;
  1.1169 +            lum += 2;
  1.1170 +            row[0] = row[1] = row[next_row] = row[next_row + 1] =
  1.1171 +                (rgb_2_pix[L + cr_r] |
  1.1172 +                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
  1.1173              row += 2;
  1.1174  
  1.1175 -            L = *lum; lum += 2;
  1.1176 -            row[0] = row[1] = row[next_row] = row[next_row+1] =
  1.1177 -                                       (rgb_2_pix[ L + cr_r ] |
  1.1178 -                                        rgb_2_pix[ L + crb_g ] |
  1.1179 -                                        rgb_2_pix[ L + cb_b ]);
  1.1180 +            L = *lum;
  1.1181 +            lum += 2;
  1.1182 +            row[0] = row[1] = row[next_row] = row[next_row + 1] =
  1.1183 +                (rgb_2_pix[L + cr_r] |
  1.1184 +                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
  1.1185              row += 2;
  1.1186  
  1.1187  
  1.1188 @@ -903,396 +892,411 @@
  1.1189   * How many 1 bits are there in the Uint32.
  1.1190   * Low performance, do not call often.
  1.1191   */
  1.1192 -static int number_of_bits_set( Uint32 a )
  1.1193 +static int
  1.1194 +number_of_bits_set (Uint32 a)
  1.1195  {
  1.1196 -    if(!a) return 0;
  1.1197 -    if(a & 1) return 1 + number_of_bits_set(a >> 1);
  1.1198 -    return(number_of_bits_set(a >> 1));
  1.1199 +    if (!a)
  1.1200 +        return 0;
  1.1201 +    if (a & 1)
  1.1202 +        return 1 + number_of_bits_set (a >> 1);
  1.1203 +    return (number_of_bits_set (a >> 1));
  1.1204  }
  1.1205  
  1.1206  /*
  1.1207   * How many 0 bits are there at least significant end of Uint32.
  1.1208   * Low performance, do not call often.
  1.1209   */
  1.1210 -static int free_bits_at_bottom( Uint32 a )
  1.1211 +static int
  1.1212 +free_bits_at_bottom (Uint32 a)
  1.1213  {
  1.1214 -      /* assume char is 8 bits */
  1.1215 -    if(!a) return sizeof(Uint32) * 8;
  1.1216 -    if(((Sint32)a) & 1l) return 0;
  1.1217 -    return 1 + free_bits_at_bottom ( a >> 1);
  1.1218 +    /* assume char is 8 bits */
  1.1219 +    if (!a)
  1.1220 +        return sizeof (Uint32) * 8;
  1.1221 +    if (((Sint32) a) & 1l)
  1.1222 +        return 0;
  1.1223 +    return 1 + free_bits_at_bottom (a >> 1);
  1.1224  }
  1.1225  
  1.1226  
  1.1227 -SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
  1.1228 +SDL_Overlay *
  1.1229 +SDL_CreateYUV_SW (_THIS, int width, int height, Uint32 format,
  1.1230 +                  SDL_Surface * display)
  1.1231  {
  1.1232 -	SDL_Overlay *overlay;
  1.1233 -	struct private_yuvhwdata *swdata;
  1.1234 -	int *Cr_r_tab;
  1.1235 -	int *Cr_g_tab;
  1.1236 -	int *Cb_g_tab;
  1.1237 -	int *Cb_b_tab;
  1.1238 -	Uint32 *r_2_pix_alloc;
  1.1239 -	Uint32 *g_2_pix_alloc;
  1.1240 -	Uint32 *b_2_pix_alloc;
  1.1241 -	int i;
  1.1242 -	int CR, CB;
  1.1243 -	Uint32 Rmask, Gmask, Bmask;
  1.1244 +    SDL_Overlay *overlay;
  1.1245 +    struct private_yuvhwdata *swdata;
  1.1246 +    int *Cr_r_tab;
  1.1247 +    int *Cr_g_tab;
  1.1248 +    int *Cb_g_tab;
  1.1249 +    int *Cb_b_tab;
  1.1250 +    Uint32 *r_2_pix_alloc;
  1.1251 +    Uint32 *g_2_pix_alloc;
  1.1252 +    Uint32 *b_2_pix_alloc;
  1.1253 +    int i;
  1.1254 +    int CR, CB;
  1.1255 +    Uint32 Rmask, Gmask, Bmask;
  1.1256  
  1.1257 -	/* Only RGB packed pixel conversion supported */
  1.1258 -	if ( (display->format->BytesPerPixel != 2) &&
  1.1259 -	     (display->format->BytesPerPixel != 3) &&
  1.1260 -	     (display->format->BytesPerPixel != 4) ) {
  1.1261 -		SDL_SetError("Can't use YUV data on non 16/24/32 bit surfaces");
  1.1262 -		return(NULL);
  1.1263 -	}
  1.1264 +    /* Only RGB packed pixel conversion supported */
  1.1265 +    if ((display->format->BytesPerPixel != 2) &&
  1.1266 +        (display->format->BytesPerPixel != 3) &&
  1.1267 +        (display->format->BytesPerPixel != 4)) {
  1.1268 +        SDL_SetError ("Can't use YUV data on non 16/24/32 bit surfaces");
  1.1269 +        return (NULL);
  1.1270 +    }
  1.1271  
  1.1272 -	/* Verify that we support the format */
  1.1273 -	switch (format) {
  1.1274 -	    case SDL_YV12_OVERLAY:
  1.1275 -	    case SDL_IYUV_OVERLAY:
  1.1276 -	    case SDL_YUY2_OVERLAY:
  1.1277 -	    case SDL_UYVY_OVERLAY:
  1.1278 -	    case SDL_YVYU_OVERLAY:
  1.1279 -		break;
  1.1280 -	    default:
  1.1281 -		SDL_SetError("Unsupported YUV format");
  1.1282 -		return(NULL);
  1.1283 -	}
  1.1284 +    /* Verify that we support the format */
  1.1285 +    switch (format) {
  1.1286 +    case SDL_YV12_OVERLAY:
  1.1287 +    case SDL_IYUV_OVERLAY:
  1.1288 +    case SDL_YUY2_OVERLAY:
  1.1289 +    case SDL_UYVY_OVERLAY:
  1.1290 +    case SDL_YVYU_OVERLAY:
  1.1291 +        break;
  1.1292 +    default:
  1.1293 +        SDL_SetError ("Unsupported YUV format");
  1.1294 +        return (NULL);
  1.1295 +    }
  1.1296  
  1.1297 -	/* Create the overlay structure */
  1.1298 -	overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay);
  1.1299 -	if ( overlay == NULL ) {
  1.1300 -		SDL_OutOfMemory();
  1.1301 -		return(NULL);
  1.1302 -	}
  1.1303 -	SDL_memset(overlay, 0, (sizeof *overlay));
  1.1304 +    /* Create the overlay structure */
  1.1305 +    overlay = (SDL_Overlay *) SDL_malloc (sizeof *overlay);
  1.1306 +    if (overlay == NULL) {
  1.1307 +        SDL_OutOfMemory ();
  1.1308 +        return (NULL);
  1.1309 +    }
  1.1310 +    SDL_memset (overlay, 0, (sizeof *overlay));
  1.1311  
  1.1312 -	/* Fill in the basic members */
  1.1313 -	overlay->format = format;
  1.1314 -	overlay->w = width;
  1.1315 -	overlay->h = height;
  1.1316 +    /* Fill in the basic members */
  1.1317 +    overlay->format = format;
  1.1318 +    overlay->w = width;
  1.1319 +    overlay->h = height;
  1.1320  
  1.1321 -	/* Set up the YUV surface function structure */
  1.1322 -	overlay->hwfuncs = &sw_yuvfuncs;
  1.1323 +    /* Set up the YUV surface function structure */
  1.1324 +    overlay->hwfuncs = &sw_yuvfuncs;
  1.1325  
  1.1326 -	/* Create the pixel data and lookup tables */
  1.1327 -	swdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *swdata);
  1.1328 -	overlay->hwdata = swdata;
  1.1329 -	if ( swdata == NULL ) {
  1.1330 -		SDL_OutOfMemory();
  1.1331 -		SDL_FreeYUVOverlay(overlay);
  1.1332 -		return(NULL);
  1.1333 -	}
  1.1334 -	swdata->stretch = NULL;
  1.1335 -	swdata->display = display;
  1.1336 -	swdata->pixels = (Uint8 *) SDL_malloc(width*height*2);
  1.1337 -	swdata->colortab = (int *)SDL_malloc(4*256*sizeof(int));
  1.1338 -	Cr_r_tab = &swdata->colortab[0*256];
  1.1339 -	Cr_g_tab = &swdata->colortab[1*256];
  1.1340 -	Cb_g_tab = &swdata->colortab[2*256];
  1.1341 -	Cb_b_tab = &swdata->colortab[3*256];
  1.1342 -	swdata->rgb_2_pix = (Uint32 *)SDL_malloc(3*768*sizeof(Uint32));
  1.1343 -	r_2_pix_alloc = &swdata->rgb_2_pix[0*768];
  1.1344 -	g_2_pix_alloc = &swdata->rgb_2_pix[1*768];
  1.1345 -	b_2_pix_alloc = &swdata->rgb_2_pix[2*768];
  1.1346 -	if ( ! swdata->pixels || ! swdata->colortab || ! swdata->rgb_2_pix ) {
  1.1347 -		SDL_OutOfMemory();
  1.1348 -		SDL_FreeYUVOverlay(overlay);
  1.1349 -		return(NULL);
  1.1350 -	}
  1.1351 +    /* Create the pixel data and lookup tables */
  1.1352 +    swdata = (struct private_yuvhwdata *) SDL_malloc (sizeof *swdata);
  1.1353 +    overlay->hwdata = swdata;
  1.1354 +    if (swdata == NULL) {
  1.1355 +        SDL_OutOfMemory ();
  1.1356 +        SDL_FreeYUVOverlay (overlay);
  1.1357 +        return (NULL);
  1.1358 +    }
  1.1359 +    swdata->stretch = NULL;
  1.1360 +    swdata->display = display;
  1.1361 +    swdata->pixels = (Uint8 *) SDL_malloc (width * height * 2);
  1.1362 +    swdata->colortab = (int *) SDL_malloc (4 * 256 * sizeof (int));
  1.1363 +    Cr_r_tab = &swdata->colortab[0 * 256];
  1.1364 +    Cr_g_tab = &swdata->colortab[1 * 256];
  1.1365 +    Cb_g_tab = &swdata->colortab[2 * 256];
  1.1366 +    Cb_b_tab = &swdata->colortab[3 * 256];
  1.1367 +    swdata->rgb_2_pix = (Uint32 *) SDL_malloc (3 * 768 * sizeof (Uint32));
  1.1368 +    r_2_pix_alloc = &swdata->rgb_2_pix[0 * 768];
  1.1369 +    g_2_pix_alloc = &swdata->rgb_2_pix[1 * 768];
  1.1370 +    b_2_pix_alloc = &swdata->rgb_2_pix[2 * 768];
  1.1371 +    if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) {
  1.1372 +        SDL_OutOfMemory ();
  1.1373 +        SDL_FreeYUVOverlay (overlay);
  1.1374 +        return (NULL);
  1.1375 +    }
  1.1376  
  1.1377 -	/* Generate the tables for the display surface */
  1.1378 -	for (i=0; i<256; i++) {
  1.1379 -		/* Gamma correction (luminescence table) and chroma correction
  1.1380 -		   would be done here.  See the Berkeley mpeg_play sources.
  1.1381 -		*/
  1.1382 -		CB = CR = (i-128);
  1.1383 -		Cr_r_tab[i] = (int) ( (0.419/0.299) * CR);
  1.1384 -		Cr_g_tab[i] = (int) (-(0.299/0.419) * CR);
  1.1385 -		Cb_g_tab[i] = (int) (-(0.114/0.331) * CB); 
  1.1386 -		Cb_b_tab[i] = (int) ( (0.587/0.331) * CB);
  1.1387 -	}
  1.1388 +    /* Generate the tables for the display surface */
  1.1389 +    for (i = 0; i < 256; i++) {
  1.1390 +        /* Gamma correction (luminescence table) and chroma correction
  1.1391 +           would be done here.  See the Berkeley mpeg_play sources.
  1.1392 +         */
  1.1393 +        CB = CR = (i - 128);
  1.1394 +        Cr_r_tab[i] = (int) ((0.419 / 0.299) * CR);
  1.1395 +        Cr_g_tab[i] = (int) (-(0.299 / 0.419) * CR);
  1.1396 +        Cb_g_tab[i] = (int) (-(0.114 / 0.331) * CB);
  1.1397 +        Cb_b_tab[i] = (int) ((0.587 / 0.331) * CB);
  1.1398 +    }
  1.1399  
  1.1400 -	/* 
  1.1401 -	 * Set up entries 0-255 in rgb-to-pixel value tables.
  1.1402 -	 */
  1.1403 -	Rmask = display->format->Rmask;
  1.1404 -	Gmask = display->format->Gmask;
  1.1405 -	Bmask = display->format->Bmask;
  1.1406 -	for ( i=0; i<256; ++i ) {
  1.1407 -		r_2_pix_alloc[i+256] = i >> (8 - number_of_bits_set(Rmask));
  1.1408 -		r_2_pix_alloc[i+256] <<= free_bits_at_bottom(Rmask);
  1.1409 -		g_2_pix_alloc[i+256] = i >> (8 - number_of_bits_set(Gmask));
  1.1410 -		g_2_pix_alloc[i+256] <<= free_bits_at_bottom(Gmask);
  1.1411 -		b_2_pix_alloc[i+256] = i >> (8 - number_of_bits_set(Bmask));
  1.1412 -		b_2_pix_alloc[i+256] <<= free_bits_at_bottom(Bmask);
  1.1413 -	}
  1.1414 +    /* 
  1.1415 +     * Set up entries 0-255 in rgb-to-pixel value tables.
  1.1416 +     */
  1.1417 +    Rmask = display->format->Rmask;
  1.1418 +    Gmask = display->format->Gmask;
  1.1419 +    Bmask = display->format->Bmask;
  1.1420 +    for (i = 0; i < 256; ++i) {
  1.1421 +        r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (Rmask));
  1.1422 +        r_2_pix_alloc[i + 256] <<= free_bits_at_bottom (Rmask);
  1.1423 +        g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (Gmask));
  1.1424 +        g_2_pix_alloc[i + 256] <<= free_bits_at_bottom (Gmask);
  1.1425 +        b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (Bmask));
  1.1426 +        b_2_pix_alloc[i + 256] <<= free_bits_at_bottom (Bmask);
  1.1427 +    }
  1.1428  
  1.1429 -	/*
  1.1430 -	 * If we have 16-bit output depth, then we double the value
  1.1431 -	 * in the top word. This means that we can write out both
  1.1432 -	 * pixels in the pixel doubling mode with one op. It is 
  1.1433 -	 * harmless in the normal case as storing a 32-bit value
  1.1434 -	 * through a short pointer will lose the top bits anyway.
  1.1435 -	 */
  1.1436 -	if( display->format->BytesPerPixel == 2 ) {
  1.1437 -		for ( i=0; i<256; ++i ) {
  1.1438 -			r_2_pix_alloc[i+256] |= (r_2_pix_alloc[i+256]) << 16;
  1.1439 -			g_2_pix_alloc[i+256] |= (g_2_pix_alloc[i+256]) << 16;
  1.1440 -			b_2_pix_alloc[i+256] |= (b_2_pix_alloc[i+256]) << 16;
  1.1441 -		}
  1.1442 -	}
  1.1443 +    /*
  1.1444 +     * If we have 16-bit output depth, then we double the value
  1.1445 +     * in the top word. This means that we can write out both
  1.1446 +     * pixels in the pixel doubling mode with one op. It is 
  1.1447 +     * harmless in the normal case as storing a 32-bit value
  1.1448 +     * through a short pointer will lose the top bits anyway.
  1.1449 +     */
  1.1450 +    if (display->format->BytesPerPixel == 2) {
  1.1451 +        for (i = 0; i < 256; ++i) {
  1.1452 +            r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;
  1.1453 +            g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;
  1.1454 +            b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;
  1.1455 +        }
  1.1456 +    }
  1.1457  
  1.1458 -	/*
  1.1459 -	 * Spread out the values we have to the rest of the array so that
  1.1460 -	 * we do not need to check for overflow.
  1.1461 -	 */
  1.1462 -	for ( i=0; i<256; ++i ) {
  1.1463 -		r_2_pix_alloc[i] = r_2_pix_alloc[256];
  1.1464 -		r_2_pix_alloc[i+512] = r_2_pix_alloc[511];
  1.1465 -		g_2_pix_alloc[i] = g_2_pix_alloc[256];
  1.1466 -		g_2_pix_alloc[i+512] = g_2_pix_alloc[511];
  1.1467 -		b_2_pix_alloc[i] = b_2_pix_alloc[256];
  1.1468 -		b_2_pix_alloc[i+512] = b_2_pix_alloc[511];
  1.1469 -	}
  1.1470 +    /*
  1.1471 +     * Spread out the values we have to the rest of the array so that
  1.1472 +     * we do not need to check for overflow.
  1.1473 +     */
  1.1474 +    for (i = 0; i < 256; ++i) {
  1.1475 +        r_2_pix_alloc[i] = r_2_pix_alloc[256];
  1.1476 +        r_2_pix_alloc[i + 512] = r_2_pix_alloc[511];
  1.1477 +        g_2_pix_alloc[i] = g_2_pix_alloc[256];
  1.1478 +        g_2_pix_alloc[i + 512] = g_2_pix_alloc[511];
  1.1479 +        b_2_pix_alloc[i] = b_2_pix_alloc[256];
  1.1480 +        b_2_pix_alloc[i + 512] = b_2_pix_alloc[511];
  1.1481 +    }
  1.1482  
  1.1483 -	/* You have chosen wisely... */
  1.1484 -	switch (format) {
  1.1485 -	    case SDL_YV12_OVERLAY:
  1.1486 -	    case SDL_IYUV_OVERLAY:
  1.1487 -		if ( display->format->BytesPerPixel == 2 ) {
  1.1488 -#if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES*/
  1.1489 -			/* inline assembly functions */
  1.1490 -			if ( SDL_HasMMX() && (Rmask == 0xF800) &&
  1.1491 -			                     (Gmask == 0x07E0) &&
  1.1492 -				             (Bmask == 0x001F) &&
  1.1493 -			                     (width & 15) == 0) {
  1.1494 +    /* You have chosen wisely... */
  1.1495 +    switch (format) {
  1.1496 +    case SDL_YV12_OVERLAY:
  1.1497 +    case SDL_IYUV_OVERLAY:
  1.1498 +        if (display->format->BytesPerPixel == 2) {
  1.1499 +#if 0                           /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */
  1.1500 +            /* inline assembly functions */
  1.1501 +            if (SDL_HasMMX () && (Rmask == 0xF800) &&
  1.1502 +                (Gmask == 0x07E0) && (Bmask == 0x001F) && (width & 15) == 0) {
  1.1503  /*printf("Using MMX 16-bit 565 dither\n");*/
  1.1504 -				swdata->Display1X = Color565DitherYV12MMX1X;
  1.1505 -			} else {
  1.1506 +                swdata->Display1X = Color565DitherYV12MMX1X;
  1.1507 +            } else {
  1.1508  /*printf("Using C 16-bit dither\n");*/
  1.1509 -				swdata->Display1X = Color16DitherYV12Mod1X;
  1.1510 -			}
  1.1511 +                swdata->Display1X = Color16DitherYV12Mod1X;
  1.1512 +            }
  1.1513  #else
  1.1514 -			swdata->Display1X = Color16DitherYV12Mod1X;
  1.1515 +            swdata->Display1X = Color16DitherYV12Mod1X;
  1.1516  #endif
  1.1517 -			swdata->Display2X = Color16DitherYV12Mod2X;
  1.1518 -		}
  1.1519 -		if ( display->format->BytesPerPixel == 3 ) {
  1.1520 -			swdata->Display1X = Color24DitherYV12Mod1X;
  1.1521 -			swdata->Display2X = Color24DitherYV12Mod2X;
  1.1522 -		}
  1.1523 -		if ( display->format->BytesPerPixel == 4 ) {
  1.1524 -#if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES*/
  1.1525 -			/* inline assembly functions */
  1.1526 -			if ( SDL_HasMMX() && (Rmask == 0x00FF0000) &&
  1.1527 -			                     (Gmask == 0x0000FF00) &&
  1.1528 -				             (Bmask == 0x000000FF) && 
  1.1529 -			                     (width & 15) == 0) {
  1.1530 +            swdata->Display2X = Color16DitherYV12Mod2X;
  1.1531 +        }
  1.1532 +        if (display->format->BytesPerPixel == 3) {
  1.1533 +            swdata->Display1X = Color24DitherYV12Mod1X;
  1.1534 +            swdata->Display2X = Color24DitherYV12Mod2X;
  1.1535 +        }
  1.1536 +        if (display->format->BytesPerPixel == 4) {
  1.1537 +#if 0                           /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */
  1.1538 +            /* inline assembly functions */
  1.1539 +            if (SDL_HasMMX () && (Rmask == 0x00FF0000) &&
  1.1540 +                (Gmask == 0x0000FF00) &&
  1.1541 +                (Bmask == 0x000000FF) && (width & 15) == 0) {
  1.1542  /*printf("Using MMX 32-bit dither\n");*/
  1.1543 -				swdata->Display1X = ColorRGBDitherYV12MMX1X;
  1.1544 -			} else {
  1.1545 +                swdata->Display1X = ColorRGBDitherYV12MMX1X;
  1.1546 +            } else {
  1.1547  /*printf("Using C 32-bit dither\n");*/
  1.1548 -				swdata->Display1X = Color32DitherYV12Mod1X;
  1.1549 -			}
  1.1550 +                swdata->Display1X = Color32DitherYV12Mod1X;
  1.1551 +            }
  1.1552  #else
  1.1553 -			swdata->Display1X = Color32DitherYV12Mod1X;
  1.1554 +            swdata->Display1X = Color32DitherYV12Mod1X;
  1.1555  #endif
  1.1556 -			swdata->Display2X = Color32DitherYV12Mod2X;
  1.1557 -		}
  1.1558 -		break;
  1.1559 -	    case SDL_YUY2_OVERLAY:
  1.1560 -	    case SDL_UYVY_OVERLAY:
  1.1561 -	    case SDL_YVYU_OVERLAY:
  1.1562 -		if ( display->format->BytesPerPixel == 2 ) {
  1.1563 -			swdata->Display1X = Color16DitherYUY2Mod1X;
  1.1564 -			swdata->Display2X = Color16DitherYUY2Mod2X;
  1.1565 -		}
  1.1566 -		if ( display->format->BytesPerPixel == 3 ) {
  1.1567 -			swdata->Display1X = Color24DitherYUY2Mod1X;
  1.1568 -			swdata->Display2X = Color24DitherYUY2Mod2X;
  1.1569 -		}
  1.1570 -		if ( display->format->BytesPerPixel == 4 ) {
  1.1571 -			swdata->Display1X = Color32DitherYUY2Mod1X;
  1.1572 -			swdata->Display2X = Color32DitherYUY2Mod2X;
  1.1573 -		}
  1.1574 -		break;
  1.1575 -	    default:
  1.1576 -		/* We should never get here (caught above) */
  1.1577 -		break;
  1.1578 -	}
  1.1579 +            swdata->Display2X = Color32DitherYV12Mod2X;
  1.1580 +        }
  1.1581 +        break;
  1.1582 +    case SDL_YUY2_OVERLAY:
  1.1583 +    case SDL_UYVY_OVERLAY:
  1.1584 +    case SDL_YVYU_OVERLAY:
  1.1585 +        if (display->format->BytesPerPixel == 2) {
  1.1586 +            swdata->Display1X = Color16DitherYUY2Mod1X;
  1.1587 +            swdata->Display2X = Color16DitherYUY2Mod2X;
  1.1588 +        }
  1.1589 +        if (display->format->BytesPerPixel == 3) {
  1.1590 +            swdata->Display1X = Color24DitherYUY2Mod1X;
  1.1591 +            swdata->Display2X = Color24DitherYUY2Mod2X;
  1.1592 +        }
  1.1593 +        if (display->format->BytesPerPixel == 4) {
  1.1594 +            swdata->Display1X = Color32DitherYUY2Mod1X;
  1.1595 +            swdata->Display2X = Color32DitherYUY2Mod2X;
  1.1596 +        }
  1.1597 +        break;
  1.1598 +    default:
  1.1599 +        /* We should never get here (caught above) */
  1.1600 +        break;
  1.1601 +    }
  1.1602  
  1.1603 -	/* Find the pitch and offset values for the overlay */
  1.1604 -	overlay->pitches = swdata->pitches;
  1.1605 -	overlay->pixels = swdata->planes;
  1.1606 -	switch (format) {
  1.1607 -	    case SDL_YV12_OVERLAY:
  1.1608 -	    case SDL_IYUV_OVERLAY:
  1.1609 -		overlay->pitches[0] = overlay->w;
  1.1610 -		overlay->pitches[1] = overlay->pitches[0] / 2;
  1.1611 -		overlay->pitches[2] = overlay->pitches[0] / 2;
  1.1612 -	        overlay->pixels[0] = swdata->pixels;
  1.1613 -	        overlay->pixels[1] = overlay->pixels[0] +
  1.1614 -		                     overlay->pitches[0] * overlay->h;
  1.1615 -	        overlay->pixels[2] = overlay->pixels[1] +
  1.1616 -		                     overlay->pitches[1] * overlay->h / 2;
  1.1617 -		overlay->planes = 3;
  1.1618 -		break;
  1.1619 -	    case SDL_YUY2_OVERLAY:
  1.1620 -	    case SDL_UYVY_OVERLAY:
  1.1621 -	    case SDL_YVYU_OVERLAY:
  1.1622 -		overlay->pitches[0] = overlay->w*2;
  1.1623 -	        overlay->pixels[0] = swdata->pixels;
  1.1624 -		overlay->planes = 1;
  1.1625 -		break;
  1.1626 -	    default:
  1.1627 -		/* We should never get here (caught above) */
  1.1628 -		break;
  1.1629 -	}
  1.1630 +    /* Find the pitch and offset values for the overlay */
  1.1631 +    overlay->pitches = swdata->pitches;
  1.1632 +    overlay->pixels = swdata->planes;
  1.1633 +    switch (format) {
  1.1634 +    case SDL_YV12_OVERLAY:
  1.1635 +    case SDL_IYUV_OVERLAY:
  1.1636 +        overlay->pitches[0] = overlay->w;
  1.1637 +        overlay->pitches[1] = overlay->pitches[0] / 2;
  1.1638 +        overlay->pitches[2] = overlay->pitches[0] / 2;
  1.1639 +        overlay->pixels[0] = swdata->pixels;
  1.1640 +        overlay->pixels[1] = overlay->pixels[0] +
  1.1641 +            overlay->pitches[0] * overlay->h;
  1.1642 +        overlay->pixels[2] = overlay->pixels[1] +
  1.1643 +            overlay->pitches[1] * overlay->h / 2;
  1.1644 +        overlay->planes = 3;
  1.1645 +        break;
  1.1646 +    case SDL_YUY2_OVERLAY:
  1.1647 +    case SDL_UYVY_OVERLAY:
  1.1648 +    case SDL_YVYU_OVERLAY:
  1.1649 +        overlay->pitches[0] = overlay->w * 2;
  1.1650 +        overlay->pixels[0] = swdata->pixels;
  1.1651 +        overlay->planes = 1;
  1.1652 +        break;
  1.1653 +    default:
  1.1654 +        /* We should never get here (caught above) */
  1.1655 +        break;
  1.1656 +    }
  1.1657  
  1.1658 -	/* We're all done.. */
  1.1659 -	return(overlay);
  1.1660 +    /* We're all done.. */
  1.1661 +    return (overlay);
  1.1662  }
  1.1663  
  1.1664 -int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay)
  1.1665 +int
  1.1666 +SDL_LockYUV_SW (_THIS, SDL_Overlay * overlay)
  1.1667  {
  1.1668 -	return(0);
  1.1669 +    return (0);
  1.1670  }
  1.1671  
  1.1672 -void SDL_UnlockYUV_SW(_THIS, SDL_Overlay *overlay)
  1.1673 +void
  1.1674 +SDL_UnlockYUV_SW (_THIS, SDL_Overlay * overlay)
  1.1675  {
  1.1676 -	return;
  1.1677 +    return;
  1.1678  }
  1.1679  
  1.1680 -int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst)
  1.1681 +int
  1.1682 +SDL_DisplayYUV_SW (_THIS, SDL_Overlay * overlay, SDL_Rect * src,
  1.1683 +                   SDL_Rect * dst)
  1.1684  {
  1.1685 -	struct private_yuvhwdata *swdata;
  1.1686 -	int stretch;
  1.1687 -	int scale_2x;
  1.1688 -	SDL_Surface *display;
  1.1689 -	Uint8 *lum, *Cr, *Cb;
  1.1690 -	Uint8 *dstp;
  1.1691 -	int mod;
  1.1692 +    struct private_yuvhwdata *swdata;
  1.1693 +    int stretch;
  1.1694 +    int scale_2x;
  1.1695 +    SDL_Surface *display;
  1.1696 +    Uint8 *lum, *Cr, *Cb;
  1.1697 +    Uint8 *dstp;
  1.1698 +    int mod;
  1.1699  
  1.1700 -	swdata = overlay->hwdata;
  1.1701 -	stretch = 0;
  1.1702 -	scale_2x = 0;
  1.1703 -	if ( src->x || src->y || src->w < overlay->w || src->h < overlay->h ) {
  1.1704 -		/* The source rectangle has been clipped.
  1.1705 -		   Using a scratch surface is easier than adding clipped
  1.1706 -		   source support to all the blitters, plus that would
  1.1707 -		   slow them down in the general unclipped case.
  1.1708 -		*/
  1.1709 -		stretch = 1;
  1.1710 -	} else if ( (src->w != dst->w) || (src->h != dst->h) ) {
  1.1711 -		if ( (dst->w == 2*src->w) &&
  1.1712 -		     (dst->h == 2*src->h) ) {
  1.1713 -			scale_2x = 1;
  1.1714 -		} else {
  1.1715 -			stretch = 1;
  1.1716 -		}
  1.1717 -	}
  1.1718 -	if ( stretch ) {
  1.1719 -		if ( ! swdata->stretch ) {
  1.1720 -			display = swdata->display;
  1.1721 -			swdata->stretch = SDL_CreateRGBSurface(
  1.1722 -				SDL_SWSURFACE,
  1.1723 -				overlay->w, overlay->h,
  1.1724 -				display->format->BitsPerPixel,
  1.1725 -				display->format->Rmask,
  1.1726 -				display->format->Gmask,
  1.1727 -				display->format->Bmask, 0);
  1.1728 -			if ( ! swdata->stretch ) {
  1.1729 -				return(-1);
  1.1730 -			}
  1.1731 -		}
  1.1732 -		display = swdata->stretch;
  1.1733 -	} else {
  1.1734 -		display = swdata->display;
  1.1735 -	}
  1.1736 -	switch (overlay->format) {
  1.1737 -	    case SDL_YV12_OVERLAY:
  1.1738 -		lum = overlay->pixels[0];
  1.1739 -		Cr =  overlay->pixels[1];
  1.1740 -		Cb =  overlay->pixels[2];
  1.1741 -		break;
  1.1742 -	    case SDL_IYUV_OVERLAY:
  1.1743 -		lum = overlay->pixels[0];
  1.1744 -		Cr =  overlay->pixels[2];
  1.1745 -		Cb =  overlay->pixels[1];
  1.1746 -		break;
  1.1747 -	    case SDL_YUY2_OVERLAY:
  1.1748 -		lum = overlay->pixels[0];
  1.1749 -		Cr = lum + 3;
  1.1750 -		Cb = lum + 1;
  1.1751 -		break;
  1.1752 -	    case SDL_UYVY_OVERLAY:
  1.1753 -		lum = overlay->pixels[0]+1;
  1.1754 -		Cr = lum + 1;
  1.1755 -		Cb = lum - 1;
  1.1756 -		break;
  1.1757 -	    case SDL_YVYU_OVERLAY:
  1.1758 -		lum = overlay->pixels[0];
  1.1759 -		Cr = lum + 1;
  1.1760 -		Cb = lum + 3;
  1.1761 -		break;
  1.1762 -	    default:
  1.1763 -		SDL_SetError("Unsupported YUV format in blit");
  1.1764 -		return(-1);
  1.1765 -	}
  1.1766 -	if ( SDL_MUSTLOCK(display) ) {
  1.1767 -        	if ( SDL_LockSurface(display) < 0 ) {
  1.1768 -			return(-1);
  1.1769 -		}
  1.1770 -	}
  1.1771 -	if ( stretch ) {
  1.1772 -		dstp = (Uint8 *)swdata->stretch->pixels;
  1.1773 -	} else {
  1.1774 -		dstp = (Uint8 *)display->pixels
  1.1775 -			+ dst->x * display->format->BytesPerPixel
  1.1776 -			+ dst->y * display->pitch;
  1.1777 -	}
  1.1778 -	mod = (display->pitch / display->format->BytesPerPixel);
  1.1779 +    swdata = overlay->hwdata;
  1.1780 +    stretch = 0;
  1.1781 +    scale_2x = 0;
  1.1782 +    if (src->x || src->y || src->w < overlay->w || src->h < overlay->h) {
  1.1783 +        /* The source rectangle has been clipped.
  1.1784 +           Using a scratch surface is easier than adding clipped
  1.1785 +           source support to all the blitters, plus that would
  1.1786 +           slow them down in the general unclipped case.
  1.1787 +         */
  1.1788 +        stretch = 1;
  1.1789 +    } else if ((src->w != dst->w) || (src->h != dst->h)) {
  1.1790 +        if ((dst->w == 2 * src->w) && (dst->h == 2 * src->h)) {
  1.1791 +            scale_2x = 1;
  1.1792 +        } else {
  1.1793 +            stretch = 1;
  1.1794 +        }
  1.1795 +    }
  1.1796 +    if (stretch) {
  1.1797 +        if (!swdata->stretch) {
  1.1798 +            display = swdata->display;
  1.1799 +            swdata->stretch = SDL_CreateRGBSurface (SDL_SWSURFACE,
  1.1800 +                                                    overlay->w,
  1.1801 +                                                    overlay->h,
  1.1802 +                                                    display->format->
  1.1803 +                                                    BitsPerPixel,
  1.1804 +                                                    display->format->
  1.1805 +                                                    Rmask,
  1.1806 +                                                    display->format->
  1.1807 +                                                    Gmask,
  1.1808 +                                                    display->format->
  1.1809 +                                                    Bmask, 0);
  1.1810 +            if (!swdata->stretch) {
  1.1811 +                return (-1);
  1.1812 +            }
  1.1813 +        }
  1.1814 +        display = swdata->stretch;
  1.1815 +    } else {
  1.1816 +        display = swdata->display;
  1.1817 +    }
  1.1818 +    switch (overlay->format) {
  1.1819 +    case SDL_YV12_OVERLAY:
  1.1820 +        lum = overlay->pixels[0];
  1.1821 +        Cr = overlay->pixels[1];
  1.1822 +        Cb = overlay->pixels[2];
  1.1823 +        break;
  1.1824 +    case SDL_IYUV_OVERLAY:
  1.1825 +        lum = overlay->pixels[0];
  1.1826 +        Cr = overlay->pixels[2];
  1.1827 +        Cb = overlay->pixels[1];
  1.1828 +        break;
  1.1829 +    case SDL_YUY2_OVERLAY:
  1.1830 +        lum = overlay->pixels[0];
  1.1831 +        Cr = lum + 3;
  1.1832 +        Cb = lum + 1;
  1.1833 +        break;
  1.1834 +    case SDL_UYVY_OVERLAY:
  1.1835 +        lum = overlay->pixels[0] + 1;
  1.1836 +        Cr = lum + 1;
  1.1837 +        Cb = lum - 1;
  1.1838 +        break;
  1.1839 +    case SDL_YVYU_OVERLAY:
  1.1840 +        lum = overlay->pixels[0];
  1.1841 +        Cr = lum + 1;
  1.1842 +        Cb = lum + 3;
  1.1843 +        break;
  1.1844 +    default:
  1.1845 +        SDL_SetError ("Unsupported YUV format in blit");
  1.1846 +        return (-1);
  1.1847 +    }
  1.1848 +    if (SDL_MUSTLOCK (display)) {
  1.1849 +        if (SDL_LockSurface (display) < 0) {
  1.1850 +            return (-1);
  1.1851 +        }
  1.1852 +    }
  1.1853 +    if (stretch) {
  1.1854 +        dstp = (Uint8 *) swdata->stretch->pixels;
  1.1855 +    } else {
  1.1856 +        dstp = (Uint8 *) display->pixels
  1.1857 +            + dst->x * display->format->BytesPerPixel
  1.1858 +            + dst->y * display->pitch;
  1.1859 +    }
  1.1860 +    mod = (display->pitch / display->format->BytesPerPixel);
  1.1861  
  1.1862 -	if ( scale_2x ) {
  1.1863 -		mod -= (overlay->w * 2);
  1.1864 -		swdata->Display2X(swdata->colortab, swdata->rgb_2_pix,
  1.1865 -		                  lum, Cr, Cb, dstp, overlay->h, overlay->w, mod);
  1.1866 -	} else {
  1.1867 -		mod -= overlay->w;
  1.1868 -		swdata->Display1X(swdata->colortab, swdata->rgb_2_pix,
  1.1869 -		                  lum, Cr, Cb, dstp, overlay->h, overlay->w, mod);
  1.1870 -	}
  1.1871 -	if ( SDL_MUSTLOCK(display) ) {
  1.1872 -		SDL_UnlockSurface(display);
  1.1873 -	}
  1.1874 -	if ( stretch ) {
  1.1875 -		display = swdata->display;
  1.1876 -		SDL_SoftStretch(swdata->stretch, src, display, dst);
  1.1877 -	}
  1.1878 -	SDL_UpdateRects(display, 1, dst);
  1.1879 +    if (scale_2x) {
  1.1880 +        mod -= (overlay->w * 2);
  1.1881 +        swdata->Display2X (swdata->colortab, swdata->rgb_2_pix,
  1.1882 +                           lum, Cr, Cb, dstp, overlay->h, overlay->w, mod);
  1.1883 +    } else {
  1.1884 +        mod -= overlay->w;
  1.1885 +        swdata->Display1X (swdata->colortab, swdata->rgb_2_pix,
  1.1886 +                           lum, Cr, Cb, dstp, overlay->h, overlay->w, mod);
  1.1887 +    }
  1.1888 +    if (SDL_MUSTLOCK (display)) {
  1.1889 +        SDL_UnlockSurface (display);
  1.1890 +    }
  1.1891 +    if (stretch) {
  1.1892 +        display = swdata->display;
  1.1893 +        SDL_SoftStretch (swdata->stretch, src, display, dst);
  1.1894 +    }
  1.1895 +    SDL_UpdateRects (display, 1, dst);
  1.1896  
  1.1897 -	return(0);
  1.1898 +    return (0);
  1.1899  }
  1.1900  
  1.1901 -void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay)
  1.1902 +void
  1.1903 +SDL_FreeYUV_SW (_THIS, SDL_Overlay * overlay)
  1.1904  {
  1.1905 -	struct private_yuvhwdata *swdata;
  1.1906 +    struct private_yuvhwdata *swdata;
  1.1907  
  1.1908 -	swdata = overlay->hwdata;
  1.1909 -	if ( swdata ) {
  1.1910 -		if ( swdata->stretch ) {
  1.1911 -			SDL_FreeSurface(swdata->stretch);
  1.1912 -		}
  1.1913 -		if ( swdata->pixels ) {
  1.1914 -			SDL_free(swdata->pixels);
  1.1915 -		}
  1.1916 -		if ( swdata->colortab ) {
  1.1917 -			SDL_free(swdata->colortab);
  1.1918 -		}
  1.1919 -		if ( swdata->rgb_2_pix ) {
  1.1920 -			SDL_free(swdata->rgb_2_pix);
  1.1921 -		}
  1.1922 -		SDL_free(swdata);
  1.1923 -	}
  1.1924 +    swdata = overlay->hwdata;
  1.1925 +    if (swdata) {
  1.1926 +        if (swdata->stretch) {
  1.1927 +            SDL_FreeSurface (swdata->stretch);
  1.1928 +        }
  1.1929 +        if (swdata->pixels) {
  1.1930 +            SDL_free (swdata->pixels);
  1.1931 +        }
  1.1932 +        if (swdata->colortab) {
  1.1933 +            SDL_free (swdata->colortab);
  1.1934 +        }
  1.1935 +        if (swdata->rgb_2_pix) {
  1.1936 +            SDL_free (swdata->rgb_2_pix);
  1.1937 +        }
  1.1938 +        SDL_free (swdata);
  1.1939 +    }
  1.1940  }
  1.1941 +
  1.1942 +/* vi: set ts=4 sw=4 expandtab: */