21 #include "../SDL_internal.h" 94 #ifdef USE_MMX_ASSEMBLY 95 extern void Color565DitherYV12MMX1X(
int *colortab,
Uint32 * rgb_2_pix,
96 unsigned char *lum,
unsigned char *cr,
97 unsigned char *cb,
unsigned char *out,
98 int rows,
int cols,
int mod);
99 extern void ColorRGBDitherYV12MMX1X(
int *colortab,
Uint32 * rgb_2_pix,
100 unsigned char *lum,
unsigned char *cr,
101 unsigned char *cb,
unsigned char *out,
102 int rows,
int cols,
int mod);
107 unsigned char *lum,
unsigned char *cr,
108 unsigned char *cb,
unsigned char *out,
109 int rows,
int cols,
int mod)
111 unsigned short *row1;
112 unsigned short *row2;
118 int cols_2 = cols / 2;
120 row1 = (
unsigned short *) out;
121 row2 = row1 + cols + mod;
132 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
133 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
134 + colortab[*cb + 2 * 256];
135 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
140 *row1++ = (
unsigned short) (rgb_2_pix[L + cr_r] |
141 rgb_2_pix[L + crb_g] |
142 rgb_2_pix[L + cb_b]);
145 *row1++ = (
unsigned short) (rgb_2_pix[L + cr_r] |
146 rgb_2_pix[L + crb_g] |
147 rgb_2_pix[L + cb_b]);
153 *row2++ = (
unsigned short) (rgb_2_pix[L + cr_r] |
154 rgb_2_pix[L + crb_g] |
155 rgb_2_pix[L + cb_b]);
158 *row2++ = (
unsigned short) (rgb_2_pix[L + cr_r] |
159 rgb_2_pix[L + crb_g] |
160 rgb_2_pix[L + cb_b]);
177 unsigned char *lum,
unsigned char *cr,
178 unsigned char *cb,
unsigned char *out,
179 int rows,
int cols,
int mod)
189 int cols_2 = cols / 2;
192 row2 = row1 + cols * 3 + mod * 3;
204 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
205 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
206 + colortab[*cb + 2 * 256];
207 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
212 value = (rgb_2_pix[L + cr_r] |
213 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
214 *row1++ = (
value) & 0xFF;
215 *row1++ = (value >> 8) & 0xFF;
216 *row1++ = (value >> 16) & 0xFF;
219 value = (rgb_2_pix[L + cr_r] |
220 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
221 *row1++ = (
value) & 0xFF;
222 *row1++ = (value >> 8) & 0xFF;
223 *row1++ = (value >> 16) & 0xFF;
229 value = (rgb_2_pix[L + cr_r] |
230 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
231 *row2++ = (
value) & 0xFF;
232 *row2++ = (value >> 8) & 0xFF;
233 *row2++ = (value >> 16) & 0xFF;
236 value = (rgb_2_pix[L + cr_r] |
237 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
238 *row2++ = (
value) & 0xFF;
239 *row2++ = (value >> 8) & 0xFF;
240 *row2++ = (value >> 16) & 0xFF;
257 unsigned char *lum,
unsigned char *cr,
258 unsigned char *cb,
unsigned char *out,
259 int rows,
int cols,
int mod)
268 int cols_2 = (cols + 1) / 2;
270 int skip_last_col = 0;
271 int skip_last_row = 0;
273 if ( (cols & 0
x1) ) {
277 if ( (rows & 0x1) ) {
281 row1 = (
unsigned int *) out;
282 row2 = row1 + cols + mod;
293 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
294 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
295 + colortab[*cb + 2 * 256];
296 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
301 *row1++ = (rgb_2_pix[L + cr_r] |
302 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
304 if (!(x == 0 && skip_last_col)) {
306 *row1++ = (rgb_2_pix[L + cr_r] |
307 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
311 if (!(y == 0 && skip_last_row)) {
316 *row2++ = (rgb_2_pix[L + cr_r] |
317 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
319 if (!(x == 1 && skip_last_col)) {
321 *row2++ = (rgb_2_pix[L + cr_r] |
322 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
346 unsigned char *lum,
unsigned char *cr,
347 unsigned char *cb,
unsigned char *out,
348 int rows,
int cols,
int mod)
350 unsigned int *row1 = (
unsigned int *) out;
351 const int next_row = cols + (mod / 2);
352 unsigned int *row2 = row1 + 2 * next_row;
358 int cols_2 = cols / 2;
362 mod = (next_row * 3) + (mod / 2);
370 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
371 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
372 + colortab[*cb + 2 * 256];
373 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
378 row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
379 rgb_2_pix[L + crb_g] |
380 rgb_2_pix[L + cb_b]);
384 row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
385 rgb_2_pix[L + crb_g] |
386 rgb_2_pix[L + cb_b]);
393 row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
394 rgb_2_pix[L + crb_g] |
395 rgb_2_pix[L + cb_b]);
399 row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
400 rgb_2_pix[L + crb_g] |
401 rgb_2_pix[L + cb_b]);
419 unsigned char *lum,
unsigned char *cr,
420 unsigned char *cb,
unsigned char *out,
421 int rows,
int cols,
int mod)
424 unsigned char *row1 = out;
425 const int next_row = (cols * 2 + mod) * 3;
426 unsigned char *row2 = row1 + 2 * next_row;
432 int cols_2 = cols / 2;
436 mod = next_row * 3 + mod * 3;
444 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
445 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
446 + colortab[*cb + 2 * 256];
447 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
452 value = (rgb_2_pix[L + cr_r] |
453 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
454 row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
455 row1[next_row + 3 + 0] = (
value) & 0xFF;
456 row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
457 row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
458 row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
459 row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
463 value = (rgb_2_pix[L + cr_r] |
464 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
465 row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
466 row1[next_row + 3 + 0] = (
value) & 0xFF;
467 row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
468 row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
469 row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
470 row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
477 value = (rgb_2_pix[L + cr_r] |
478 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
479 row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
480 row2[next_row + 3 + 0] = (
value) & 0xFF;
481 row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
482 row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
483 row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
484 row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
488 value = (rgb_2_pix[L + cr_r] |
489 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
490 row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
491 row2[next_row + 3 + 0] = (
value) & 0xFF;
492 row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
493 row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
494 row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
495 row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
513 unsigned char *lum,
unsigned char *cr,
514 unsigned char *cb,
unsigned char *out,
515 int rows,
int cols,
int mod)
517 unsigned int *row1 = (
unsigned int *) out;
518 const int next_row = cols * 2 + mod;
519 unsigned int *row2 = row1 + 2 * next_row;
525 int cols_2 = cols / 2;
529 mod = (next_row * 3) + mod;
537 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
538 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
539 + colortab[*cb + 2 * 256];
540 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
545 row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
546 (rgb_2_pix[L + cr_r] |
547 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
551 row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
552 (rgb_2_pix[L + cr_r] |
553 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
560 row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
561 (rgb_2_pix[L + cr_r] |
562 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
566 row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
567 (rgb_2_pix[L + cr_r] |
568 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
586 unsigned char *lum,
unsigned char *cr,
587 unsigned char *cb,
unsigned char *out,
588 int rows,
int cols,
int mod)
595 int cols_2 = cols / 2;
597 row = (
unsigned short *) out;
605 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
606 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
607 + colortab[*cb + 2 * 256];
608 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
614 *row++ = (
unsigned short) (rgb_2_pix[L + cr_r] |
615 rgb_2_pix[L + crb_g] |
616 rgb_2_pix[L + cb_b]);
620 *row++ = (
unsigned short) (rgb_2_pix[L + cr_r] |
621 rgb_2_pix[L + crb_g] |
622 rgb_2_pix[L + cb_b]);
632 unsigned char *lum,
unsigned char *cr,
633 unsigned char *cb,
unsigned char *out,
634 int rows,
int cols,
int mod)
642 int cols_2 = cols / 2;
644 row = (
unsigned char *) out;
652 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
653 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
654 + colortab[*cb + 2 * 256];
655 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
661 value = (rgb_2_pix[L + cr_r] |
662 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
663 *row++ = (
value) & 0xFF;
664 *row++ = (value >> 8) & 0xFF;
665 *row++ = (value >> 16) & 0xFF;
669 value = (rgb_2_pix[L + cr_r] |
670 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
671 *row++ = (
value) & 0xFF;
672 *row++ = (value >> 8) & 0xFF;
673 *row++ = (value >> 16) & 0xFF;
682 unsigned char *lum,
unsigned char *cr,
683 unsigned char *cb,
unsigned char *out,
684 int rows,
int cols,
int mod)
691 int cols_2 = (cols + 1) / 2;
693 int skip_last_col = 0;
694 if ( (cols & 0
x1) ) {
698 row = (
unsigned int *) out;
705 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
706 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
707 + colortab[*cb + 2 * 256];
708 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
714 *row++ = (rgb_2_pix[L + cr_r] |
715 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
720 if (!(x == 0 && skip_last_col)) {
721 *row++ = (rgb_2_pix[L + cr_r] |
722 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
737 unsigned char *lum,
unsigned char *cr,
738 unsigned char *cb,
unsigned char *out,
739 int rows,
int cols,
int mod)
741 unsigned int *
row = (
unsigned int *) out;
742 const int next_row = cols + (mod / 2);
747 int cols_2 = cols / 2;
755 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
756 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
757 + colortab[*cb + 2 * 256];
758 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
764 row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
765 rgb_2_pix[L + crb_g] |
766 rgb_2_pix[L + cb_b]);
771 row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
772 rgb_2_pix[L + crb_g] |
773 rgb_2_pix[L + cb_b]);
783 unsigned char *lum,
unsigned char *cr,
784 unsigned char *cb,
unsigned char *out,
785 int rows,
int cols,
int mod)
788 unsigned char *
row = out;
789 const int next_row = (cols * 2 + mod) * 3;
794 int cols_2 = cols / 2;
801 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
802 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
803 + colortab[*cb + 2 * 256];
804 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
810 value = (rgb_2_pix[L + cr_r] |
811 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
812 row[0 + 0] = row[3 + 0] = row[next_row + 0] =
813 row[next_row + 3 + 0] = (
value) & 0xFF;
814 row[0 + 1] = row[3 + 1] = row[next_row + 1] =
815 row[next_row + 3 + 1] = (value >> 8) & 0xFF;
816 row[0 + 2] = row[3 + 2] = row[next_row + 2] =
817 row[next_row + 3 + 2] = (value >> 16) & 0xFF;
822 value = (rgb_2_pix[L + cr_r] |
823 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
824 row[0 + 0] = row[3 + 0] = row[next_row + 0] =
825 row[next_row + 3 + 0] = (
value) & 0xFF;
826 row[0 + 1] = row[3 + 1] = row[next_row + 1] =
827 row[next_row + 3 + 1] = (value >> 8) & 0xFF;
828 row[0 + 2] = row[3 + 2] = row[next_row + 2] =
829 row[next_row + 3 + 2] = (value >> 16) & 0xFF;
839 unsigned char *lum,
unsigned char *cr,
840 unsigned char *cb,
unsigned char *out,
841 int rows,
int cols,
int mod)
843 unsigned int *
row = (
unsigned int *) out;
844 const int next_row = cols * 2 + mod;
849 int cols_2 = cols / 2;
857 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
858 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
859 + colortab[*cb + 2 * 256];
860 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
866 row[0] = row[1] = row[next_row] = row[next_row + 1] =
867 (rgb_2_pix[L + cr_r] |
868 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
873 row[0] = row[1] = row[next_row] = row[next_row + 1] =
874 (rgb_2_pix[L + cr_r] |
875 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
924 Uint32 Rmask, Gmask, Bmask, Amask;
928 (target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) || bpp < 15) {
929 return SDL_SetError(
"Unsupported YUV destination format");
933 r_2_pix_alloc = &swdata->
rgb_2_pix[0 * 768];
934 g_2_pix_alloc = &swdata->
rgb_2_pix[1 * 768];
935 b_2_pix_alloc = &swdata->
rgb_2_pix[2 * 768];
940 for (i = 0; i < 256; ++
i) {
944 r_2_pix_alloc[i + 256] <<= freebits;
946 r_2_pix_alloc[i + 256] |= Amask;
951 g_2_pix_alloc[i + 256] <<= freebits;
953 g_2_pix_alloc[i + 256] |= Amask;
958 b_2_pix_alloc[i + 256] <<= freebits;
960 b_2_pix_alloc[i + 256] |= Amask;
971 for (i = 0; i < 256; ++
i) {
972 r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;
973 g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;
974 b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;
982 for (i = 0; i < 256; ++
i) {
983 r_2_pix_alloc[
i] = r_2_pix_alloc[256];
984 r_2_pix_alloc[i + 512] = r_2_pix_alloc[511];
985 g_2_pix_alloc[
i] = g_2_pix_alloc[256];
986 g_2_pix_alloc[i + 512] = g_2_pix_alloc[511];
987 b_2_pix_alloc[
i] = b_2_pix_alloc[256];
988 b_2_pix_alloc[i + 512] = b_2_pix_alloc[511];
996 #ifdef USE_MMX_ASSEMBLY 999 (Gmask == 0x07E0) && (Bmask == 0x001F)
1000 && (swdata->
w & 15) == 0) {
1002 swdata->
Display1X = Color565DitherYV12MMX1X;
1017 #ifdef USE_MMX_ASSEMBLY 1020 (Gmask == 0x0000FF00) &&
1021 (Bmask == 0x000000FF) && (swdata->
w & 15) == 0) {
1023 swdata->
Display1X = ColorRGBDitherYV12MMX1X;
1103 const int sz_plane = w *
h;
1104 const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2);
1105 const int sz_plane_packed = ((w + 1) / 2) *
h;
1111 dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
1117 dst_size = 4 * sz_plane_packed;
1122 dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
1126 SDL_assert(0 &&
"We should never get here (caught above)");
1140 Cr_r_tab = &swdata->
colortab[0 * 256];
1141 Cr_g_tab = &swdata->
colortab[1 * 256];
1142 Cb_g_tab = &swdata->
colortab[2 * 256];
1143 Cb_b_tab = &swdata->
colortab[3 * 256];
1144 for (i = 0; i < 256; i++) {
1148 CB = CR = (i - 128);
1149 Cr_r_tab[
i] = (int) ((0.419 / 0.299) * CR);
1150 Cr_g_tab[
i] = (int) (-(0.299 / 0.419) * CR);
1151 Cb_g_tab[
i] = (int) (-(0.114 / 0.331) * CB);
1152 Cb_b_tab[
i] = (int) ((0.587 / 0.331) * CB);
1169 swdata->
pitches[0] = ((w + 1) / 2) * 4;
1182 SDL_assert(0 &&
"We should never get here (caught above)");
1194 *pixels = swdata->
planes[0];
1201 const void *
pixels,
int pitch)
1203 switch (swdata->
format) {
1206 if (rect->
x == 0 && rect->
y == 0 &&
1207 rect->
w == swdata->
w && rect->
h == swdata->
h) {
1209 (swdata->
h * swdata->
w) + 2* ((swdata->
h + 1) /2) * ((swdata->
w + 1) / 2));
1216 src = (
Uint8 *) pixels;
1217 dst = swdata->
pixels + rect->
y * swdata->
w + rect->
x;
1219 for (row = 0; row < rect->
h; ++
row) {
1226 src = (
Uint8 *) pixels + rect->
h * pitch;
1227 dst = swdata->
pixels + swdata->
h * swdata->
w;
1228 dst += rect->
y/2 * ((swdata->
w + 1) / 2) + rect->
x/2;
1229 length = (rect->
w + 1) / 2;
1230 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
1232 src += (pitch + 1)/2;
1233 dst += (swdata->
w + 1)/2;
1237 src = (
Uint8 *) pixels + rect->
h * pitch + ((rect->
h + 1) / 2) * ((pitch + 1) / 2);
1238 dst = swdata->
pixels + swdata->
h * swdata->
w +
1239 ((swdata->
h + 1)/2) * ((swdata->
w+1) / 2);
1240 dst += rect->
y/2 * ((swdata->
w + 1)/2) + rect->
x/2;
1241 length = (rect->
w + 1) / 2;
1242 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
1244 src += (pitch + 1)/2;
1245 dst += (swdata->
w + 1)/2;
1257 src = (
Uint8 *) pixels;
1261 length = 4 * ((rect->
w + 1) / 2);
1262 for (row = 0; row < rect->
h; ++
row) {
1272 if (rect->
x == 0 && rect->
y == 0 && rect->
w == swdata->
w && rect->
h == swdata->
h) {
1274 (swdata->
h * swdata->
w) + 2* ((swdata->
h + 1) /2) * ((swdata->
w + 1) / 2));
1282 src = (
Uint8 *) pixels;
1283 dst = swdata->
pixels + rect->
y * swdata->
w + rect->
x;
1285 for (row = 0; row < rect->
h; ++
row) {
1292 src = (
Uint8 *) pixels + rect->
h * pitch;
1293 dst = swdata->
pixels + swdata->
h * swdata->
w;
1294 dst += 2 * ((rect->
y + 1)/2) * ((swdata->
w + 1) / 2) + 2 * (rect->
x/2);
1295 length = 2 * ((rect->
w + 1) / 2);
1296 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
1298 src += 2 * ((pitch + 1)/2);
1299 dst += 2 * ((swdata->
w + 1)/2);
1311 const Uint8 *Yplane,
int Ypitch,
1312 const Uint8 *Uplane,
int Upitch,
1313 const Uint8 *Vplane,
int Vpitch)
1322 dst = swdata->
pixels + rect->
y * swdata->
w + rect->
x;
1324 for (row = 0; row < rect->
h; ++
row) {
1333 dst = swdata->
pixels + swdata->
h * swdata->
w;
1335 dst = swdata->
pixels + swdata->
h * swdata->
w +
1336 ((swdata->
h + 1) / 2) * ((swdata->
w + 1) / 2);
1338 dst += rect->
y/2 * ((swdata->
w + 1)/2) + rect->
x/2;
1339 length = (rect->
w + 1) / 2;
1340 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
1343 dst += (swdata->
w + 1)/2;
1349 dst = swdata->
pixels + swdata->
h * swdata->
w;
1351 dst = swdata->
pixels + swdata->
h * swdata->
w +
1352 ((swdata->
h + 1) / 2) * ((swdata->
w + 1) / 2);
1354 dst += rect->
y/2 * ((swdata->
w + 1)/2) + rect->
x/2;
1355 length = (rect->
w + 1) / 2;
1356 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
1359 dst += (swdata->
w + 1)/2;
1366 void **
pixels,
int *pitch)
1368 switch (swdata->
format) {
1374 && (rect->
x != 0 || rect->
y != 0 || rect->
w != swdata->
w 1375 || rect->
h != swdata->
h)) {
1377 (
"YV12, IYUV, NV12, NV21 textures only support full surface locks");
1383 *pixels = swdata->
planes[0] + rect->
y * swdata->
pitches[0] + rect->
x * 2;
1385 *pixels = swdata->
planes[0];
1404 Uint8 *lum, *Cr, *Cb;
1407 if (targetbpp == 0) {
1420 if (srcrect->
x || srcrect->
y || srcrect->
w < swdata->
w 1421 || srcrect->
h < swdata->
h) {
1428 }
else if ((srcrect->
w != w) || (srcrect->
h != h)) {
1429 if ((w == 2 * srcrect->
w) && (h == 2 * srcrect->
h)) {
1437 Uint32 Rmask, Gmask, Bmask, Amask;
1450 Gmask, Bmask, Amask);
1461 Gmask, Bmask, Amask);
1469 switch (swdata->
format) {
1486 lum = swdata->
planes[0] + 1;
1499 target_format, pixels, pitch);
1504 mod = (pitch / targetbpp);
1507 mod -= (swdata->
w * 2);
1509 lum, Cr, Cb, pixels, swdata->
h, swdata->
w, mod);
1513 lum, Cr, Cb, pixels, swdata->
h, swdata->
w, mod);
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata)
GLuint GLfloat GLfloat GLfloat x1
SDL_SW_YUVTexture * SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
void(* Display1X)(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
static void Color24DitherYUY2Mod1X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
static int SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture *swdata, Uint32 target_format)
GLint GLint GLint GLint GLint x
GLfloat GLfloat GLfloat GLfloat h
static void Color16DitherYV12Mod1X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch)
static void Color16DitherYUY2Mod1X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
#define SDL_BYTESPERPIXEL(X)
#define SDL_CreateRGBSurfaceFrom
static void Color24DitherYV12Mod2X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
static int number_of_bits_set(Uint32 a)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch)
static void Color16DitherYV12Mod2X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLfloat * value
static int free_bits_at_bottom_nonzero(Uint32 a)
GLint GLint GLint GLint GLint GLint y
#define SDL_PixelFormatEnumToMasks
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
static void Color32DitherYUY2Mod1X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
void(* Display2X)(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels, int *pitch)
static SDL_INLINE int free_bits_at_bottom(Uint32 a)
#define SDL_CreateRGBSurface
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch)
static void Color16DitherYUY2Mod2X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
#define SDL_ConvertPixels
static void Color32DitherYUY2Mod2X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
GLuint GLsizei GLsizei * length
GLboolean GLboolean GLboolean GLboolean a
static void Color24DitherYV12Mod1X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
static void Color32DitherYV12Mod2X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
A rectangle, with the origin at the upper left.
static void Color24DitherYUY2Mod2X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)
static void Color32DitherYV12Mod1X(int *colortab, Uint32 *rgb_2_pix, unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int rows, int cols, int mod)