Mercurial > sdl-ios-xcode
annotate src/video/SDL_yuv_sw.c @ 2199:7e1caa8452f3
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 15 Jul 2007 16:59:16 +0000 |
parents | 2ff40f30af31 |
children | 5651642f4a78 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
9
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
24 /* This is the software implementation of the YUV texture support */ |
0 | 25 |
26 /* This code was derived from code carrying the following copyright notices: | |
27 | |
28 * Copyright (c) 1995 The Regents of the University of California. | |
29 * All rights reserved. | |
30 * | |
31 * Permission to use, copy, modify, and distribute this software and its | |
32 * documentation for any purpose, without fee, and without written agreement is | |
33 * hereby granted, provided that the above copyright notice and the following | |
34 * two paragraphs appear in all copies of this software. | |
35 * | |
36 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR | |
37 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT | |
38 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF | |
39 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
40 * | |
41 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, | |
42 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | |
43 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | |
44 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO | |
45 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
46 | |
47 * Copyright (c) 1995 Erik Corry | |
48 * All rights reserved. | |
49 * | |
50 * Permission to use, copy, modify, and distribute this software and its | |
51 * documentation for any purpose, without fee, and without written agreement is | |
52 * hereby granted, provided that the above copyright notice and the following | |
53 * two paragraphs appear in all copies of this software. | |
54 * | |
55 * IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
56 * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF | |
57 * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED | |
58 * OF THE POSSIBILITY OF SUCH DAMAGE. | |
59 * | |
60 * ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT | |
61 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
62 * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" | |
63 * BASIS, AND ERIK CORRY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, | |
64 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
65 | |
66 * Portions of this software Copyright (c) 1995 Brown University. | |
67 * All rights reserved. | |
68 * | |
69 * Permission to use, copy, modify, and distribute this software and its | |
70 * documentation for any purpose, without fee, and without written agreement | |
71 * is hereby granted, provided that the above copyright notice and the | |
72 * following two paragraphs appear in all copies of this software. | |
73 * | |
74 * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR | |
75 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT | |
76 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN | |
77 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
78 * | |
79 * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT | |
80 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
81 * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" | |
82 * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, | |
83 * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
84 */ | |
85 | |
86 #include "SDL_video.h" | |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
366
diff
changeset
|
87 #include "SDL_cpuinfo.h" |
0 | 88 #include "SDL_stretch_c.h" |
89 #include "SDL_yuv_sw_c.h" | |
90 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
91 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
92 struct SDL_SW_YUVTexture |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
93 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
94 SDL_Texture *texture; |
0 | 95 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
96 Uint32 target_format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
97 Uint8 *pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
98 int *colortab; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
99 Uint32 *rgb_2_pix; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
100 void (*Display1X) (int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
101 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
102 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
103 int rows, int cols, int mod); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
104 void (*Display2X) (int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
105 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
106 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
107 int rows, int cols, int mod); |
0 | 108 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
109 /* These are just so we don't have to allocate them separately */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
110 Uint16 pitches[3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
111 Uint8 *planes[3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
112 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
113 /* This is a temporary surface in case we have to stretch copy */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
114 SDL_Surface *stretch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
115 SDL_Surface *display; |
0 | 116 }; |
117 | |
118 /* The colorspace conversion functions */ | |
119 | |
2197
2ff40f30af31
Merged r3261:3262 from branches/SDL-1.2: MMX/YUV with __OPTIMIZE__.
Ryan C. Gordon <icculus@icculus.org>
parents:
2172
diff
changeset
|
120 #if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
121 extern void Color565DitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
122 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
123 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
124 int rows, int cols, int mod); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
125 extern void ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix, |
0 | 126 unsigned char *lum, unsigned char *cr, |
127 unsigned char *cb, unsigned char *out, | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
128 int rows, int cols, int mod); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
129 #endif |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
130 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
131 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
132 Color16DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
133 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
134 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
135 int rows, int cols, int mod) |
0 | 136 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
137 unsigned short *row1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
138 unsigned short *row2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
139 unsigned char *lum2; |
0 | 140 int x, y; |
141 int cr_r; | |
142 int crb_g; | |
143 int cb_b; | |
144 int cols_2 = cols / 2; | |
145 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
146 row1 = (unsigned short *) out; |
0 | 147 row2 = row1 + cols + mod; |
148 lum2 = lum + cols; | |
149 | |
150 mod += cols + mod; | |
151 | |
152 y = rows / 2; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
153 while (y--) { |
0 | 154 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
155 while (x--) { |
0 | 156 register int L; |
157 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
158 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
159 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
160 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
161 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
162 ++cr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
163 ++cb; |
0 | 164 |
165 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
166 *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
167 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
168 rgb_2_pix[L + cb_b]); |
0 | 169 |
170 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
171 *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
172 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
173 rgb_2_pix[L + cb_b]); |
0 | 174 |
175 | |
176 /* Now, do second row. */ | |
177 | |
178 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
179 *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
180 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
181 rgb_2_pix[L + cb_b]); |
0 | 182 |
183 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
184 *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
185 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
186 rgb_2_pix[L + cb_b]); |
0 | 187 } |
188 | |
189 /* | |
190 * These values are at the start of the next line, (due | |
191 * to the ++'s above),but they need to be at the start | |
192 * of the line after that. | |
193 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
194 lum += cols; |
0 | 195 lum2 += cols; |
196 row1 += mod; | |
197 row2 += mod; | |
198 } | |
199 } | |
200 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
201 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
202 Color24DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
203 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
204 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
205 int rows, int cols, int mod) |
0 | 206 { |
207 unsigned int value; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
208 unsigned char *row1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
209 unsigned char *row2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
210 unsigned char *lum2; |
0 | 211 int x, y; |
212 int cr_r; | |
213 int crb_g; | |
214 int cb_b; | |
215 int cols_2 = cols / 2; | |
216 | |
217 row1 = out; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
218 row2 = row1 + cols * 3 + mod * 3; |
0 | 219 lum2 = lum + cols; |
220 | |
221 mod += cols + mod; | |
222 mod *= 3; | |
223 | |
224 y = rows / 2; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
225 while (y--) { |
0 | 226 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
227 while (x--) { |
0 | 228 register int L; |
229 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
230 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
231 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
232 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
233 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
234 ++cr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
235 ++cb; |
0 | 236 |
237 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
238 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
239 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
240 *row1++ = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
241 *row1++ = (value >> 8) & 0xFF; |
0 | 242 *row1++ = (value >> 16) & 0xFF; |
243 | |
244 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
245 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
246 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
247 *row1++ = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
248 *row1++ = (value >> 8) & 0xFF; |
0 | 249 *row1++ = (value >> 16) & 0xFF; |
250 | |
251 | |
252 /* Now, do second row. */ | |
253 | |
254 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
255 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
256 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
257 *row2++ = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
258 *row2++ = (value >> 8) & 0xFF; |
0 | 259 *row2++ = (value >> 16) & 0xFF; |
260 | |
261 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
262 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
263 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
264 *row2++ = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
265 *row2++ = (value >> 8) & 0xFF; |
0 | 266 *row2++ = (value >> 16) & 0xFF; |
267 } | |
268 | |
269 /* | |
270 * These values are at the start of the next line, (due | |
271 * to the ++'s above),but they need to be at the start | |
272 * of the line after that. | |
273 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
274 lum += cols; |
0 | 275 lum2 += cols; |
276 row1 += mod; | |
277 row2 += mod; | |
278 } | |
279 } | |
280 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
281 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
282 Color32DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
283 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
284 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
285 int rows, int cols, int mod) |
0 | 286 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
287 unsigned int *row1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
288 unsigned int *row2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
289 unsigned char *lum2; |
0 | 290 int x, y; |
291 int cr_r; | |
292 int crb_g; | |
293 int cb_b; | |
294 int cols_2 = cols / 2; | |
295 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
296 row1 = (unsigned int *) out; |
0 | 297 row2 = row1 + cols + mod; |
298 lum2 = lum + cols; | |
299 | |
300 mod += cols + mod; | |
301 | |
302 y = rows / 2; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
303 while (y--) { |
0 | 304 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
305 while (x--) { |
0 | 306 register int L; |
307 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
308 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
309 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
310 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
311 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
312 ++cr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
313 ++cb; |
0 | 314 |
315 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
316 *row1++ = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
317 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 318 |
319 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
320 *row1++ = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
321 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 322 |
323 | |
324 /* Now, do second row. */ | |
325 | |
326 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
327 *row2++ = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
328 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 329 |
330 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
331 *row2++ = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
332 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 333 } |
334 | |
335 /* | |
336 * These values are at the start of the next line, (due | |
337 * to the ++'s above),but they need to be at the start | |
338 * of the line after that. | |
339 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
340 lum += cols; |
0 | 341 lum2 += cols; |
342 row1 += mod; | |
343 row2 += mod; | |
344 } | |
345 } | |
346 | |
347 /* | |
348 * In this function I make use of a nasty trick. The tables have the lower | |
349 * 16 bits replicated in the upper 16. This means I can write ints and get | |
350 * the horisontal doubling for free (almost). | |
351 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
352 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
353 Color16DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
354 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
355 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
356 int rows, int cols, int mod) |
0 | 357 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
358 unsigned int *row1 = (unsigned int *) out; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
359 const int next_row = cols + (mod / 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
360 unsigned int *row2 = row1 + 2 * next_row; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
361 unsigned char *lum2; |
0 | 362 int x, y; |
363 int cr_r; | |
364 int crb_g; | |
365 int cb_b; | |
366 int cols_2 = cols / 2; | |
367 | |
368 lum2 = lum + cols; | |
369 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
370 mod = (next_row * 3) + (mod / 2); |
0 | 371 |
372 y = rows / 2; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
373 while (y--) { |
0 | 374 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
375 while (x--) { |
0 | 376 register int L; |
377 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
378 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
379 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
380 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
381 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
382 ++cr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
383 ++cb; |
0 | 384 |
385 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
386 row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
387 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
388 rgb_2_pix[L + cb_b]); |
0 | 389 row1++; |
390 | |
391 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
392 row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
393 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
394 rgb_2_pix[L + cb_b]); |
0 | 395 row1++; |
396 | |
397 | |
398 /* Now, do second row. */ | |
399 | |
400 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
401 row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
402 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
403 rgb_2_pix[L + cb_b]); |
0 | 404 row2++; |
405 | |
406 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
407 row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
408 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
409 rgb_2_pix[L + cb_b]); |
0 | 410 row2++; |
411 } | |
412 | |
413 /* | |
414 * These values are at the start of the next line, (due | |
415 * to the ++'s above),but they need to be at the start | |
416 * of the line after that. | |
417 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
418 lum += cols; |
0 | 419 lum2 += cols; |
420 row1 += mod; | |
421 row2 += mod; | |
422 } | |
423 } | |
424 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
425 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
426 Color24DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
427 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
428 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
429 int rows, int cols, int mod) |
0 | 430 { |
431 unsigned int value; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
432 unsigned char *row1 = out; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
433 const int next_row = (cols * 2 + mod) * 3; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
434 unsigned char *row2 = row1 + 2 * next_row; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
435 unsigned char *lum2; |
0 | 436 int x, y; |
437 int cr_r; | |
438 int crb_g; | |
439 int cb_b; | |
440 int cols_2 = cols / 2; | |
441 | |
442 lum2 = lum + cols; | |
443 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
444 mod = next_row * 3 + mod * 3; |
0 | 445 |
446 y = rows / 2; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
447 while (y--) { |
0 | 448 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
449 while (x--) { |
0 | 450 register int L; |
451 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
452 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
453 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
454 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
455 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
456 ++cr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
457 ++cb; |
0 | 458 |
459 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
460 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
461 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
462 row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
463 row1[next_row + 3 + 0] = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
464 row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
465 row1[next_row + 3 + 1] = (value >> 8) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
466 row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
467 row1[next_row + 3 + 2] = (value >> 16) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
468 row1 += 2 * 3; |
0 | 469 |
470 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
471 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
472 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
473 row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
474 row1[next_row + 3 + 0] = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
475 row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
476 row1[next_row + 3 + 1] = (value >> 8) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
477 row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
478 row1[next_row + 3 + 2] = (value >> 16) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
479 row1 += 2 * 3; |
0 | 480 |
481 | |
482 /* Now, do second row. */ | |
483 | |
484 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
485 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
486 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
487 row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
488 row2[next_row + 3 + 0] = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
489 row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
490 row2[next_row + 3 + 1] = (value >> 8) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
491 row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
492 row2[next_row + 3 + 2] = (value >> 16) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
493 row2 += 2 * 3; |
0 | 494 |
495 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
496 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
497 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
498 row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
499 row2[next_row + 3 + 0] = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
500 row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
501 row2[next_row + 3 + 1] = (value >> 8) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
502 row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
503 row2[next_row + 3 + 2] = (value >> 16) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
504 row2 += 2 * 3; |
0 | 505 } |
506 | |
507 /* | |
508 * These values are at the start of the next line, (due | |
509 * to the ++'s above),but they need to be at the start | |
510 * of the line after that. | |
511 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
512 lum += cols; |
0 | 513 lum2 += cols; |
514 row1 += mod; | |
515 row2 += mod; | |
516 } | |
517 } | |
518 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
519 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
520 Color32DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
521 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
522 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
523 int rows, int cols, int mod) |
0 | 524 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
525 unsigned int *row1 = (unsigned int *) out; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
526 const int next_row = cols * 2 + mod; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
527 unsigned int *row2 = row1 + 2 * next_row; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
528 unsigned char *lum2; |
0 | 529 int x, y; |
530 int cr_r; | |
531 int crb_g; | |
532 int cb_b; | |
533 int cols_2 = cols / 2; | |
534 | |
535 lum2 = lum + cols; | |
536 | |
537 mod = (next_row * 3) + mod; | |
538 | |
539 y = rows / 2; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
540 while (y--) { |
0 | 541 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
542 while (x--) { |
0 | 543 register int L; |
544 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
545 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
546 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
547 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
548 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
549 ++cr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
550 ++cb; |
0 | 551 |
552 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
553 row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
554 (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
555 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 556 row1 += 2; |
557 | |
558 L = *lum++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
559 row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
560 (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
561 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 562 row1 += 2; |
563 | |
564 | |
565 /* Now, do second row. */ | |
566 | |
567 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
568 row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
569 (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
570 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 571 row2 += 2; |
572 | |
573 L = *lum2++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
574 row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
575 (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
576 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 577 row2 += 2; |
578 } | |
579 | |
580 /* | |
581 * These values are at the start of the next line, (due | |
582 * to the ++'s above),but they need to be at the start | |
583 * of the line after that. | |
584 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
585 lum += cols; |
0 | 586 lum2 += cols; |
587 row1 += mod; | |
588 row2 += mod; | |
589 } | |
590 } | |
591 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
592 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
593 Color16DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
594 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
595 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
596 int rows, int cols, int mod) |
0 | 597 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
598 unsigned short *row; |
0 | 599 int x, y; |
600 int cr_r; | |
601 int crb_g; | |
602 int cb_b; | |
603 int cols_2 = cols / 2; | |
604 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
605 row = (unsigned short *) out; |
0 | 606 |
607 y = rows; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
608 while (y--) { |
0 | 609 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
610 while (x--) { |
0 | 611 register int L; |
612 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
613 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
614 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
615 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
616 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
617 cr += 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
618 cb += 4; |
0 | 619 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
620 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
621 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
622 *row++ = (unsigned short) (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
623 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
624 rgb_2_pix[L + cb_b]); |
0 | 625 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
626 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
627 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
628 *row++ = (unsigned short) (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
629 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
630 rgb_2_pix[L + cb_b]); |
0 | 631 |
632 } | |
633 | |
634 row += mod; | |
635 } | |
636 } | |
637 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
638 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
639 Color24DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
640 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
641 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
642 int rows, int cols, int mod) |
0 | 643 { |
644 unsigned int value; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
645 unsigned char *row; |
0 | 646 int x, y; |
647 int cr_r; | |
648 int crb_g; | |
649 int cb_b; | |
650 int cols_2 = cols / 2; | |
651 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
652 row = (unsigned char *) out; |
0 | 653 mod *= 3; |
654 y = rows; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
655 while (y--) { |
0 | 656 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
657 while (x--) { |
0 | 658 register int L; |
659 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
660 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
661 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
662 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
663 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
664 cr += 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
665 cb += 4; |
0 | 666 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
667 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
668 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
669 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
670 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
671 *row++ = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
672 *row++ = (value >> 8) & 0xFF; |
0 | 673 *row++ = (value >> 16) & 0xFF; |
674 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
675 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
676 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
677 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
678 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
679 *row++ = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
680 *row++ = (value >> 8) & 0xFF; |
0 | 681 *row++ = (value >> 16) & 0xFF; |
682 | |
683 } | |
684 row += mod; | |
685 } | |
686 } | |
687 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
688 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
689 Color32DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
690 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
691 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
692 int rows, int cols, int mod) |
0 | 693 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
694 unsigned int *row; |
0 | 695 int x, y; |
696 int cr_r; | |
697 int crb_g; | |
698 int cb_b; | |
699 int cols_2 = cols / 2; | |
700 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
701 row = (unsigned int *) out; |
0 | 702 y = rows; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
703 while (y--) { |
0 | 704 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
705 while (x--) { |
0 | 706 register int L; |
707 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
708 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
709 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
710 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
711 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
712 cr += 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
713 cb += 4; |
0 | 714 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
715 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
716 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
717 *row++ = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
718 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 719 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
720 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
721 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
722 *row++ = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
723 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 724 |
725 | |
726 } | |
727 row += mod; | |
728 } | |
729 } | |
730 | |
731 /* | |
732 * In this function I make use of a nasty trick. The tables have the lower | |
733 * 16 bits replicated in the upper 16. This means I can write ints and get | |
734 * the horisontal doubling for free (almost). | |
735 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
736 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
737 Color16DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
738 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
739 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
740 int rows, int cols, int mod) |
0 | 741 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
742 unsigned int *row = (unsigned int *) out; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
743 const int next_row = cols + (mod / 2); |
0 | 744 int x, y; |
745 int cr_r; | |
746 int crb_g; | |
747 int cb_b; | |
748 int cols_2 = cols / 2; | |
749 | |
750 y = rows; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
751 while (y--) { |
0 | 752 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
753 while (x--) { |
0 | 754 register int L; |
755 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
756 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
757 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
758 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
759 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
760 cr += 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
761 cb += 4; |
0 | 762 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
763 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
764 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
765 row[0] = row[next_row] = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
766 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
767 rgb_2_pix[L + cb_b]); |
0 | 768 row++; |
769 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
770 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
771 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
772 row[0] = row[next_row] = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
773 rgb_2_pix[L + crb_g] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
774 rgb_2_pix[L + cb_b]); |
0 | 775 row++; |
776 | |
777 } | |
778 row += next_row; | |
779 } | |
780 } | |
781 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
782 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
783 Color24DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
784 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
785 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
786 int rows, int cols, int mod) |
0 | 787 { |
788 unsigned int value; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
789 unsigned char *row = out; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
790 const int next_row = (cols * 2 + mod) * 3; |
0 | 791 int x, y; |
792 int cr_r; | |
793 int crb_g; | |
794 int cb_b; | |
795 int cols_2 = cols / 2; | |
796 y = rows; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
797 while (y--) { |
0 | 798 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
799 while (x--) { |
0 | 800 register int L; |
801 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
802 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
803 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
804 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
805 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
806 cr += 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
807 cb += 4; |
0 | 808 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
809 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
810 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
811 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
812 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
813 row[0 + 0] = row[3 + 0] = row[next_row + 0] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
814 row[next_row + 3 + 0] = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
815 row[0 + 1] = row[3 + 1] = row[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
816 row[next_row + 3 + 1] = (value >> 8) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
817 row[0 + 2] = row[3 + 2] = row[next_row + 2] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
818 row[next_row + 3 + 2] = (value >> 16) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
819 row += 2 * 3; |
0 | 820 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
821 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
822 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
823 value = (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
824 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
825 row[0 + 0] = row[3 + 0] = row[next_row + 0] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
826 row[next_row + 3 + 0] = (value) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
827 row[0 + 1] = row[3 + 1] = row[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
828 row[next_row + 3 + 1] = (value >> 8) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
829 row[0 + 2] = row[3 + 2] = row[next_row + 2] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
830 row[next_row + 3 + 2] = (value >> 16) & 0xFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
831 row += 2 * 3; |
0 | 832 |
833 } | |
834 row += next_row; | |
835 } | |
836 } | |
837 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
838 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
839 Color32DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
840 unsigned char *lum, unsigned char *cr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
841 unsigned char *cb, unsigned char *out, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
842 int rows, int cols, int mod) |
0 | 843 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
844 unsigned int *row = (unsigned int *) out; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
845 const int next_row = cols * 2 + mod; |
0 | 846 int x, y; |
847 int cr_r; | |
848 int crb_g; | |
849 int cb_b; | |
850 int cols_2 = cols / 2; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
851 mod += mod; |
0 | 852 y = rows; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
853 while (y--) { |
0 | 854 x = cols_2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
855 while (x--) { |
0 | 856 register int L; |
857 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
858 cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
859 crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256] |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
860 + colortab[*cb + 2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
861 cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
862 cr += 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
863 cb += 4; |
0 | 864 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
865 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
866 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
867 row[0] = row[1] = row[next_row] = row[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
868 (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
869 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 870 row += 2; |
871 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
872 L = *lum; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
873 lum += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
874 row[0] = row[1] = row[next_row] = row[next_row + 1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
875 (rgb_2_pix[L + cr_r] | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
876 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 877 row += 2; |
878 | |
879 | |
880 } | |
881 | |
882 row += next_row; | |
883 } | |
884 } | |
885 | |
886 /* | |
887 * How many 1 bits are there in the Uint32. | |
888 * Low performance, do not call often. | |
889 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
890 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
891 number_of_bits_set(Uint32 a) |
0 | 892 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
893 if (!a) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
894 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
895 if (a & 1) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
896 return 1 + number_of_bits_set(a >> 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
897 return (number_of_bits_set(a >> 1)); |
0 | 898 } |
899 | |
900 /* | |
901 * How many 0 bits are there at least significant end of Uint32. | |
902 * Low performance, do not call often. | |
903 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
904 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
905 free_bits_at_bottom(Uint32 a) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
906 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
907 /* assume char is 8 bits */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
908 if (!a) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
909 return sizeof(Uint32) * 8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
910 if (((Sint32) a) & 1l) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
911 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
912 return 1 + free_bits_at_bottom(a >> 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
913 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
914 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
915 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
916 SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) |
0 | 917 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
918 Uint32 *r_2_pix_alloc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
919 Uint32 *g_2_pix_alloc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
920 Uint32 *b_2_pix_alloc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
921 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
922 int bpp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
923 Uint32 Rmask, Gmask, Bmask, Amask; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
924 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
925 if (!SDL_PixelFormatEnumToMasks |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
926 (target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) || bpp < 15) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
927 SDL_SetError("Unsupported YUV destination format"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
928 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
929 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
930 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
931 swdata->target_format = target_format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
932 r_2_pix_alloc = &swdata->rgb_2_pix[0 * 768]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
933 g_2_pix_alloc = &swdata->rgb_2_pix[1 * 768]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
934 b_2_pix_alloc = &swdata->rgb_2_pix[2 * 768]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
935 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
936 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
937 * Set up entries 0-255 in rgb-to-pixel value tables. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
938 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
939 for (i = 0; i < 256; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
940 r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Rmask)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
941 r_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Rmask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
942 g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Gmask)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
943 g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Gmask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
944 b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Bmask)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
945 b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Bmask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
946 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
947 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
948 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
949 * If we have 16-bit output depth, then we double the value |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
950 * in the top word. This means that we can write out both |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
951 * pixels in the pixel doubling mode with one op. It is |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
952 * harmless in the normal case as storing a 32-bit value |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
953 * through a short pointer will lose the top bits anyway. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
954 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
955 if (SDL_BYTESPERPIXEL(target_format) == 2) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
956 for (i = 0; i < 256; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
957 r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
958 g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
959 b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
960 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
961 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
962 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
963 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
964 * Spread out the values we have to the rest of the array so that |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
965 * we do not need to check for overflow. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
966 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
967 for (i = 0; i < 256; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
968 r_2_pix_alloc[i] = r_2_pix_alloc[256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
969 r_2_pix_alloc[i + 512] = r_2_pix_alloc[511]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
970 g_2_pix_alloc[i] = g_2_pix_alloc[256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
971 g_2_pix_alloc[i + 512] = g_2_pix_alloc[511]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
972 b_2_pix_alloc[i] = b_2_pix_alloc[256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
973 b_2_pix_alloc[i + 512] = b_2_pix_alloc[511]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
974 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
975 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
976 /* You have chosen wisely... */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
977 switch (swdata->texture->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
978 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
979 case SDL_PIXELFORMAT_IYUV: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
980 if (SDL_BYTESPERPIXEL(target_format) == 2) { |
2197
2ff40f30af31
Merged r3261:3262 from branches/SDL-1.2: MMX/YUV with __OPTIMIZE__.
Ryan C. Gordon <icculus@icculus.org>
parents:
2172
diff
changeset
|
981 #if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
982 /* inline assembly functions */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
983 if (SDL_HasMMX() && (Rmask == 0xF800) && |
2172
bef26cfc8f79
Fixed compiling YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
2168
diff
changeset
|
984 (Gmask == 0x07E0) && (Bmask == 0x001F) |
bef26cfc8f79
Fixed compiling YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
2168
diff
changeset
|
985 && (swdata->texture->w & 15) == 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
986 /*printf("Using MMX 16-bit 565 dither\n");*/ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
987 swdata->Display1X = Color565DitherYV12MMX1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
988 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
989 /*printf("Using C 16-bit dither\n");*/ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
990 swdata->Display1X = Color16DitherYV12Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
991 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
992 #else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
993 swdata->Display1X = Color16DitherYV12Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
994 #endif |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
995 swdata->Display2X = Color16DitherYV12Mod2X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
996 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
997 if (SDL_BYTESPERPIXEL(target_format) == 3) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
998 swdata->Display1X = Color24DitherYV12Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
999 swdata->Display2X = Color24DitherYV12Mod2X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1000 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1001 if (SDL_BYTESPERPIXEL(target_format) == 4) { |
2197
2ff40f30af31
Merged r3261:3262 from branches/SDL-1.2: MMX/YUV with __OPTIMIZE__.
Ryan C. Gordon <icculus@icculus.org>
parents:
2172
diff
changeset
|
1002 #if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1003 /* inline assembly functions */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1004 if (SDL_HasMMX() && (Rmask == 0x00FF0000) && |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1005 (Gmask == 0x0000FF00) && |
2172
bef26cfc8f79
Fixed compiling YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
2168
diff
changeset
|
1006 (Bmask == 0x000000FF) && (swdata->texture->w & 15) == 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1007 /*printf("Using MMX 32-bit dither\n");*/ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1008 swdata->Display1X = ColorRGBDitherYV12MMX1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1009 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1010 /*printf("Using C 32-bit dither\n");*/ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1011 swdata->Display1X = Color32DitherYV12Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1012 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1013 #else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1014 swdata->Display1X = Color32DitherYV12Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1015 #endif |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1016 swdata->Display2X = Color32DitherYV12Mod2X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1017 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1018 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1019 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1020 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1021 case SDL_PIXELFORMAT_YVYU: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1022 if (SDL_BYTESPERPIXEL(target_format) == 2) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1023 swdata->Display1X = Color16DitherYUY2Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1024 swdata->Display2X = Color16DitherYUY2Mod2X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1025 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1026 if (SDL_BYTESPERPIXEL(target_format) == 3) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1027 swdata->Display1X = Color24DitherYUY2Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1028 swdata->Display2X = Color24DitherYUY2Mod2X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1029 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1030 if (SDL_BYTESPERPIXEL(target_format) == 4) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1031 swdata->Display1X = Color32DitherYUY2Mod1X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1032 swdata->Display2X = Color32DitherYUY2Mod2X; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1033 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1034 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1035 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1036 /* We should never get here (caught above) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1037 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1038 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1039 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1040 if (swdata->display) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1041 SDL_FreeSurface(swdata->display); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1042 swdata->display = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1043 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1044 return 0; |
0 | 1045 } |
1046 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1047 SDL_SW_YUVTexture * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1048 SDL_SW_CreateYUVTexture(SDL_Texture * texture) |
0 | 1049 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1050 SDL_SW_YUVTexture *swdata; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1051 int *Cr_r_tab; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1052 int *Cr_g_tab; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1053 int *Cb_g_tab; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1054 int *Cb_b_tab; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1055 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1056 int CR, CB; |
0 | 1057 |
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1058 swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1059 if (!swdata) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1060 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1061 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1062 } |
0 | 1063 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1064 switch (texture->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1065 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1066 case SDL_PIXELFORMAT_IYUV: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1067 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1068 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1069 case SDL_PIXELFORMAT_YVYU: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1070 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1071 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1072 SDL_SetError("Unsupported YUV format"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1073 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1074 } |
0 | 1075 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1076 swdata->texture = texture; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1077 swdata->target_format = SDL_PIXELFORMAT_UNKNOWN; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1078 swdata->pixels = (Uint8 *) SDL_malloc(texture->w * texture->h * 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1079 swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1080 swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1081 if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1082 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1083 SDL_SW_DestroyYUVTexture(swdata); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1084 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1085 } |
0 | 1086 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1087 /* Generate the tables for the display surface */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1088 Cr_r_tab = &swdata->colortab[0 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1089 Cr_g_tab = &swdata->colortab[1 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1090 Cb_g_tab = &swdata->colortab[2 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1091 Cb_b_tab = &swdata->colortab[3 * 256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1092 for (i = 0; i < 256; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1093 /* Gamma correction (luminescence table) and chroma correction |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1094 would be done here. See the Berkeley mpeg_play sources. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1095 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1096 CB = CR = (i - 128); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1097 Cr_r_tab[i] = (int) ((0.419 / 0.299) * CR); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1098 Cr_g_tab[i] = (int) (-(0.299 / 0.419) * CR); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1099 Cb_g_tab[i] = (int) (-(0.114 / 0.331) * CB); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1100 Cb_b_tab[i] = (int) ((0.587 / 0.331) * CB); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1101 } |
0 | 1102 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1103 /* Find the pitch and offset values for the overlay */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1104 switch (texture->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1105 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1106 case SDL_PIXELFORMAT_IYUV: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1107 swdata->pitches[0] = texture->w; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1108 swdata->pitches[1] = swdata->pitches[0] / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1109 swdata->pitches[2] = swdata->pitches[0] / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1110 swdata->planes[0] = swdata->pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1111 swdata->planes[1] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1112 swdata->planes[0] + swdata->pitches[0] * texture->h; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1113 swdata->planes[2] = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1114 swdata->planes[1] + swdata->pitches[1] * texture->h / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1115 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1116 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1117 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1118 case SDL_PIXELFORMAT_YVYU: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1119 swdata->pitches[0] = texture->w * 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1120 swdata->planes[0] = swdata->pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1121 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1122 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1123 /* We should never get here (caught above) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1124 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1125 } |
0 | 1126 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1127 /* We're all done.. */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1128 return (swdata); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1129 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1130 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1131 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1132 SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1133 int *pitch) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1134 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1135 *pixels = swdata->planes[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1136 *pitch = swdata->pitches[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1137 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1138 } |
0 | 1139 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1140 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1141 SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1142 const void *pixels, int pitch) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1143 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1144 SDL_Texture *texture = swdata->texture; |
0 | 1145 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1146 switch (texture->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1147 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1148 case SDL_PIXELFORMAT_IYUV: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1149 if (rect |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1150 && (rect->x != 0 || rect->y != 0 || rect->w != texture->w |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1151 || rect->h != texture->h)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1152 SDL_SetError |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1153 ("YV12 and IYUV textures only support full surface updates"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1154 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1155 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1156 SDL_memcpy(swdata->pixels, pixels, texture->h * texture->w * 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1157 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1158 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1159 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1160 case SDL_PIXELFORMAT_YVYU: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1161 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1162 Uint8 *src, *dst; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1163 int row; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1164 size_t length; |
0 | 1165 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1166 src = (Uint8 *) pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1167 dst = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1168 swdata->planes[0] + rect->y * swdata->pitches[0] + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1169 rect->x * 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1170 length = rect->w * 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1171 for (row = 0; row < rect->h; ++row) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1172 SDL_memcpy(dst, src, length); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1173 src += pitch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1174 dst += swdata->pitches[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1175 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1176 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1177 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1178 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1179 return 0; |
0 | 1180 } |
1181 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1182 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1183 SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1184 int markDirty, void **pixels, int *pitch) |
0 | 1185 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1186 SDL_Texture *texture = swdata->texture; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1187 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1188 switch (texture->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1189 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1190 case SDL_PIXELFORMAT_IYUV: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1191 if (rect |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1192 && (rect->x != 0 || rect->y != 0 || rect->w != texture->w |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1193 || rect->h != texture->h)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1194 SDL_SetError |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1195 ("YV12 and IYUV textures only support full surface locks"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1196 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1197 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1198 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1199 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1200 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1201 *pixels = swdata->planes[0] + rect->y * swdata->pitches[0] + rect->x * 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1202 *pitch = swdata->pitches[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1203 return 0; |
0 | 1204 } |
1205 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1206 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1207 SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata) |
0 | 1208 { |
1209 } | |
1210 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1211 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1212 SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1213 Uint32 target_format, int w, int h, void *pixels, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1214 int pitch) |
0 | 1215 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1216 SDL_Texture *texture = swdata->texture; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1217 int stretch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1218 int scale_2x; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1219 Uint8 *lum, *Cr, *Cb; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1220 int mod; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1221 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1222 /* Make sure we're set up to display in the desired format */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1223 if (target_format != swdata->target_format) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1224 if (SDL_SW_SetupYUVDisplay(swdata, target_format) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1225 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1226 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1227 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1228 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1229 stretch = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1230 scale_2x = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1231 if (srcrect->x || srcrect->y || srcrect->w < texture->w |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1232 || srcrect->h < texture->h) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1233 /* The source rectangle has been clipped. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1234 Using a scratch surface is easier than adding clipped |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1235 source support to all the blitters, plus that would |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1236 slow them down in the general unclipped case. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1237 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1238 stretch = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1239 } else if ((srcrect->w != w) || (srcrect->h != h)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1240 if ((w == 2 * srcrect->w) && (h == 2 * srcrect->h)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1241 scale_2x = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1242 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1243 stretch = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1244 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1245 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1246 if (stretch) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1247 int bpp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1248 Uint32 Rmask, Gmask, Bmask, Amask; |
0 | 1249 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1250 if (swdata->display) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1251 swdata->display->w = w; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1252 swdata->display->h = h; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1253 swdata->display->pixels = pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1254 swdata->display->pitch = pitch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1255 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1256 /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1257 SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1258 &Bmask, &Amask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1259 swdata->display = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1260 SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1261 Gmask, Bmask, Amask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1262 if (!swdata->display) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1263 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1264 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1265 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1266 if (!swdata->stretch) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1267 /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1268 SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1269 &Bmask, &Amask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1270 swdata->stretch = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1271 SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1272 Gmask, Bmask, Amask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1273 if (!swdata->stretch) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1274 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1275 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1276 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1277 pixels = swdata->stretch->pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1278 pitch = swdata->stretch->pitch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1279 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1280 switch (texture->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1281 case SDL_PIXELFORMAT_YV12: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1282 lum = swdata->planes[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1283 Cr = swdata->planes[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1284 Cb = swdata->planes[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1285 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1286 case SDL_PIXELFORMAT_IYUV: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1287 lum = swdata->planes[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1288 Cr = swdata->planes[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1289 Cb = swdata->planes[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1290 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1291 case SDL_PIXELFORMAT_YUY2: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1292 lum = swdata->planes[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1293 Cr = lum + 3; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1294 Cb = lum + 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1295 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1296 case SDL_PIXELFORMAT_UYVY: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1297 lum = swdata->planes[0] + 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1298 Cr = lum + 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1299 Cb = lum - 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1300 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1301 case SDL_PIXELFORMAT_YVYU: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1302 lum = swdata->planes[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1303 Cr = lum + 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1304 Cb = lum + 3; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1305 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1306 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1307 SDL_SetError("Unsupported YUV format in copy"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1308 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1309 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1310 mod = (pitch / SDL_BYTESPERPIXEL(target_format)); |
0 | 1311 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1312 if (scale_2x) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1313 mod -= (texture->w * 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1314 swdata->Display2X(swdata->colortab, swdata->rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1315 lum, Cr, Cb, pixels, texture->h, texture->w, mod); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1316 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1317 mod -= texture->w; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1318 swdata->Display1X(swdata->colortab, swdata->rgb_2_pix, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1319 lum, Cr, Cb, pixels, texture->h, texture->w, mod); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1320 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1321 if (stretch) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1322 SDL_Rect rect = *srcrect; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1323 SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1324 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1325 return 0; |
0 | 1326 } |
1327 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1328 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1329 SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) |
0 | 1330 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1331 if (swdata) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1332 if (swdata->pixels) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1333 SDL_free(swdata->pixels); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1334 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1335 if (swdata->colortab) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1336 SDL_free(swdata->colortab); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1337 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1338 if (swdata->rgb_2_pix) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1339 SDL_free(swdata->rgb_2_pix); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1340 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1341 if (swdata->stretch) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1342 SDL_FreeSurface(swdata->stretch); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1343 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1344 if (swdata->display) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1345 SDL_FreeSurface(swdata->display); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1346 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1347 SDL_free(swdata); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1348 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1349 } |
0 | 1350 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1351 /* vi: set ts=4 sw=4 expandtab: */ |