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