Mercurial > sdl-ios-xcode
annotate src/video/SDL_yuv_sw.c @ 4468:82f357a91d43
SDL_KillThread() is no longer supported - it was always dangerous! :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 24 May 2010 22:56:36 -0700 |
parents | f7b03b6838cb |
children |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3697 | 3 Copyright (C) 1997-2010 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_yuv_sw_c.h" |
89 | |
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
|
90 |
0 | 91 /* The colorspace conversion functions */ |
92 | |
2197
2ff40f30af31
Merged r3261:3262 from branches/SDL-1.2: MMX/YUV with __OPTIMIZE__.
Ryan C. Gordon <icculus@icculus.org>
parents:
2172
diff
changeset
|
93 #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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 extern void ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix, |
0 | 99 unsigned char *lum, unsigned char *cr, |
100 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
|
101 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
|
102 #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
|
103 |
c121d94672cb
SDL 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 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
|
105 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
|
106 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
|
107 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
|
108 int rows, int cols, int mod) |
0 | 109 { |
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
|
110 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
|
111 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
|
112 unsigned char *lum2; |
0 | 113 int x, y; |
114 int cr_r; | |
115 int crb_g; | |
116 int cb_b; | |
117 int cols_2 = cols / 2; | |
118 | |
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
|
119 row1 = (unsigned short *) out; |
0 | 120 row2 = row1 + cols + mod; |
121 lum2 = lum + cols; | |
122 | |
123 mod += cols + mod; | |
124 | |
125 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
|
126 while (y--) { |
0 | 127 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
|
128 while (x--) { |
0 | 129 register int L; |
130 | |
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
|
131 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
|
132 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
|
133 + 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
|
134 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
|
135 ++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
|
136 ++cb; |
0 | 137 |
138 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
|
139 *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
|
140 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
|
141 rgb_2_pix[L + cb_b]); |
0 | 142 |
143 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
|
144 *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
|
145 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
|
146 rgb_2_pix[L + cb_b]); |
0 | 147 |
148 | |
149 /* Now, do second row. */ | |
150 | |
151 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
|
152 *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
|
153 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
|
154 rgb_2_pix[L + cb_b]); |
0 | 155 |
156 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
|
157 *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
|
158 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
|
159 rgb_2_pix[L + cb_b]); |
0 | 160 } |
161 | |
162 /* | |
163 * These values are at the start of the next line, (due | |
164 * to the ++'s above),but they need to be at the start | |
165 * of the line after that. | |
166 */ | |
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
|
167 lum += cols; |
0 | 168 lum2 += cols; |
169 row1 += mod; | |
170 row2 += mod; | |
171 } | |
172 } | |
173 | |
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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 int rows, int cols, int mod) |
0 | 179 { |
180 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
|
181 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
|
182 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
|
183 unsigned char *lum2; |
0 | 184 int x, y; |
185 int cr_r; | |
186 int crb_g; | |
187 int cb_b; | |
188 int cols_2 = cols / 2; | |
189 | |
190 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
|
191 row2 = row1 + cols * 3 + mod * 3; |
0 | 192 lum2 = lum + cols; |
193 | |
194 mod += cols + mod; | |
195 mod *= 3; | |
196 | |
197 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
|
198 while (y--) { |
0 | 199 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
|
200 while (x--) { |
0 | 201 register int L; |
202 | |
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
|
203 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
|
204 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
|
205 + 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
|
206 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
|
207 ++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
|
208 ++cb; |
0 | 209 |
210 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
|
211 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
|
212 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
|
213 *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
|
214 *row1++ = (value >> 8) & 0xFF; |
0 | 215 *row1++ = (value >> 16) & 0xFF; |
216 | |
217 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
|
218 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
|
219 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
|
220 *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
|
221 *row1++ = (value >> 8) & 0xFF; |
0 | 222 *row1++ = (value >> 16) & 0xFF; |
223 | |
224 | |
225 /* Now, do second row. */ | |
226 | |
227 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
|
228 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
|
229 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
|
230 *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
|
231 *row2++ = (value >> 8) & 0xFF; |
0 | 232 *row2++ = (value >> 16) & 0xFF; |
233 | |
234 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
|
235 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
|
236 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
|
237 *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
|
238 *row2++ = (value >> 8) & 0xFF; |
0 | 239 *row2++ = (value >> 16) & 0xFF; |
240 } | |
241 | |
242 /* | |
243 * These values are at the start of the next line, (due | |
244 * to the ++'s above),but they need to be at the start | |
245 * of the line after that. | |
246 */ | |
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
|
247 lum += cols; |
0 | 248 lum2 += cols; |
249 row1 += mod; | |
250 row2 += mod; | |
251 } | |
252 } | |
253 | |
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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 int rows, int cols, int mod) |
0 | 259 { |
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
|
260 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
|
261 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
|
262 unsigned char *lum2; |
0 | 263 int x, y; |
264 int cr_r; | |
265 int crb_g; | |
266 int cb_b; | |
267 int cols_2 = cols / 2; | |
268 | |
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
|
269 row1 = (unsigned int *) out; |
0 | 270 row2 = row1 + cols + mod; |
271 lum2 = lum + cols; | |
272 | |
273 mod += cols + mod; | |
274 | |
275 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
|
276 while (y--) { |
0 | 277 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
|
278 while (x--) { |
0 | 279 register int L; |
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 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
|
282 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
|
283 + 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
|
284 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
|
285 ++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
|
286 ++cb; |
0 | 287 |
288 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
|
289 *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
|
290 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 291 |
292 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
|
293 *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
|
294 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 295 |
296 | |
297 /* Now, do second row. */ | |
298 | |
299 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
|
300 *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
|
301 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 302 |
303 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
|
304 *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
|
305 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 306 } |
307 | |
308 /* | |
309 * These values are at the start of the next line, (due | |
310 * to the ++'s above),but they need to be at the start | |
311 * of the line after that. | |
312 */ | |
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
|
313 lum += cols; |
0 | 314 lum2 += cols; |
315 row1 += mod; | |
316 row2 += mod; | |
317 } | |
318 } | |
319 | |
320 /* | |
321 * In this function I make use of a nasty trick. The tables have the lower | |
322 * 16 bits replicated in the upper 16. This means I can write ints and get | |
323 * the horisontal doubling for free (almost). | |
324 */ | |
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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 int rows, int cols, int mod) |
0 | 330 { |
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 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
|
332 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
|
333 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
|
334 unsigned char *lum2; |
0 | 335 int x, y; |
336 int cr_r; | |
337 int crb_g; | |
338 int cb_b; | |
339 int cols_2 = cols / 2; | |
340 | |
341 lum2 = lum + cols; | |
342 | |
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
|
343 mod = (next_row * 3) + (mod / 2); |
0 | 344 |
345 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
|
346 while (y--) { |
0 | 347 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
|
348 while (x--) { |
0 | 349 register int L; |
350 | |
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
|
351 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
|
352 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
|
353 + 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
|
354 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
|
355 ++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
|
356 ++cb; |
0 | 357 |
358 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
|
359 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
|
360 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
|
361 rgb_2_pix[L + cb_b]); |
0 | 362 row1++; |
363 | |
364 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
|
365 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
|
366 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
|
367 rgb_2_pix[L + cb_b]); |
0 | 368 row1++; |
369 | |
370 | |
371 /* Now, do second row. */ | |
372 | |
373 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
|
374 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
|
375 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
|
376 rgb_2_pix[L + cb_b]); |
0 | 377 row2++; |
378 | |
379 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
|
380 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
|
381 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
|
382 rgb_2_pix[L + cb_b]); |
0 | 383 row2++; |
384 } | |
385 | |
386 /* | |
387 * These values are at the start of the next line, (due | |
388 * to the ++'s above),but they need to be at the start | |
389 * of the line after that. | |
390 */ | |
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
|
391 lum += cols; |
0 | 392 lum2 += cols; |
393 row1 += mod; | |
394 row2 += mod; | |
395 } | |
396 } | |
397 | |
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
|
398 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
|
399 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
|
400 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
|
401 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
|
402 int rows, int cols, int mod) |
0 | 403 { |
404 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
|
405 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
|
406 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
|
407 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
|
408 unsigned char *lum2; |
0 | 409 int x, y; |
410 int cr_r; | |
411 int crb_g; | |
412 int cb_b; | |
413 int cols_2 = cols / 2; | |
414 | |
415 lum2 = lum + cols; | |
416 | |
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
|
417 mod = next_row * 3 + mod * 3; |
0 | 418 |
419 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
|
420 while (y--) { |
0 | 421 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
|
422 while (x--) { |
0 | 423 register int L; |
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 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
|
426 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
|
427 + 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
|
428 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
|
429 ++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
|
430 ++cb; |
0 | 431 |
432 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
|
433 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
|
434 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
|
435 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
|
436 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
|
437 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
|
438 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
|
439 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
|
440 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
|
441 row1 += 2 * 3; |
0 | 442 |
443 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
|
444 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
|
445 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
|
446 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 row1 += 2 * 3; |
0 | 453 |
454 | |
455 /* Now, do second row. */ | |
456 | |
457 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
|
458 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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 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
|
464 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
|
465 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
|
466 row2 += 2 * 3; |
0 | 467 |
468 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 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
|
477 row2 += 2 * 3; |
0 | 478 } |
479 | |
480 /* | |
481 * These values are at the start of the next line, (due | |
482 * to the ++'s above),but they need to be at the start | |
483 * of the line after that. | |
484 */ | |
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 lum += cols; |
0 | 486 lum2 += cols; |
487 row1 += mod; | |
488 row2 += mod; | |
489 } | |
490 } | |
491 | |
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
|
492 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
|
493 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
|
494 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
|
495 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
|
496 int rows, int cols, int mod) |
0 | 497 { |
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
|
498 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
|
499 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
|
500 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
|
501 unsigned char *lum2; |
0 | 502 int x, y; |
503 int cr_r; | |
504 int crb_g; | |
505 int cb_b; | |
506 int cols_2 = cols / 2; | |
507 | |
508 lum2 = lum + cols; | |
509 | |
510 mod = (next_row * 3) + mod; | |
511 | |
512 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
|
513 while (y--) { |
0 | 514 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
|
515 while (x--) { |
0 | 516 register int L; |
517 | |
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
|
518 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
|
519 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
|
520 + 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
|
521 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
|
522 ++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
|
523 ++cb; |
0 | 524 |
525 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
|
526 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
|
527 (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
|
528 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 529 row1 += 2; |
530 | |
531 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
|
532 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
|
533 (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
|
534 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 535 row1 += 2; |
536 | |
537 | |
538 /* Now, do second row. */ | |
539 | |
540 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
|
541 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
|
542 (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
|
543 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 544 row2 += 2; |
545 | |
546 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
|
547 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
|
548 (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
|
549 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 550 row2 += 2; |
551 } | |
552 | |
553 /* | |
554 * These values are at the start of the next line, (due | |
555 * to the ++'s above),but they need to be at the start | |
556 * of the line after that. | |
557 */ | |
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
|
558 lum += cols; |
0 | 559 lum2 += cols; |
560 row1 += mod; | |
561 row2 += mod; | |
562 } | |
563 } | |
564 | |
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
|
565 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
|
566 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
|
567 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
|
568 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
|
569 int rows, int cols, int mod) |
0 | 570 { |
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
|
571 unsigned short *row; |
0 | 572 int x, y; |
573 int cr_r; | |
574 int crb_g; | |
575 int cb_b; | |
576 int cols_2 = cols / 2; | |
577 | |
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
|
578 row = (unsigned short *) out; |
0 | 579 |
580 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
|
581 while (y--) { |
0 | 582 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
|
583 while (x--) { |
0 | 584 register int L; |
585 | |
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
|
586 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
|
587 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
|
588 + 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
|
589 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
|
590 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
|
591 cb += 4; |
0 | 592 |
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
|
593 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
|
594 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
|
595 *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
|
596 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
|
597 rgb_2_pix[L + cb_b]); |
0 | 598 |
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
|
599 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
|
600 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
|
601 *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
|
602 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
|
603 rgb_2_pix[L + cb_b]); |
0 | 604 |
605 } | |
606 | |
607 row += mod; | |
608 } | |
609 } | |
610 | |
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
|
611 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
|
612 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
|
613 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
|
614 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
|
615 int rows, int cols, int mod) |
0 | 616 { |
617 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
|
618 unsigned char *row; |
0 | 619 int x, y; |
620 int cr_r; | |
621 int crb_g; | |
622 int cb_b; | |
623 int cols_2 = cols / 2; | |
624 | |
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
|
625 row = (unsigned char *) out; |
0 | 626 mod *= 3; |
627 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
|
628 while (y--) { |
0 | 629 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
|
630 while (x--) { |
0 | 631 register int L; |
632 | |
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
|
633 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
|
634 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
|
635 + 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
|
636 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
|
637 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
|
638 cb += 4; |
0 | 639 |
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
|
640 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
|
641 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
|
642 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
|
643 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
|
644 *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
|
645 *row++ = (value >> 8) & 0xFF; |
0 | 646 *row++ = (value >> 16) & 0xFF; |
647 | |
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
|
648 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
|
649 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
|
650 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
|
651 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
|
652 *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
|
653 *row++ = (value >> 8) & 0xFF; |
0 | 654 *row++ = (value >> 16) & 0xFF; |
655 | |
656 } | |
657 row += mod; | |
658 } | |
659 } | |
660 | |
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
|
661 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
|
662 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
|
663 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
|
664 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
|
665 int rows, int cols, int mod) |
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 unsigned int *row; |
0 | 668 int x, y; |
669 int cr_r; | |
670 int crb_g; | |
671 int cb_b; | |
672 int cols_2 = cols / 2; | |
673 | |
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
|
674 row = (unsigned int *) out; |
0 | 675 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
|
676 while (y--) { |
0 | 677 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
|
678 while (x--) { |
0 | 679 register int L; |
680 | |
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
|
681 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
|
682 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
|
683 + 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
|
684 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
|
685 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
|
686 cb += 4; |
0 | 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 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
|
689 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
|
690 *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
|
691 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 692 |
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
|
693 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
|
694 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
|
695 *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
|
696 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 697 |
698 | |
699 } | |
700 row += mod; | |
701 } | |
702 } | |
703 | |
704 /* | |
705 * In this function I make use of a nasty trick. The tables have the lower | |
706 * 16 bits replicated in the upper 16. This means I can write ints and get | |
707 * the horisontal doubling for free (almost). | |
708 */ | |
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
|
709 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
|
710 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
|
711 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
|
712 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
|
713 int rows, int cols, int mod) |
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 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
|
716 const int next_row = cols + (mod / 2); |
0 | 717 int x, y; |
718 int cr_r; | |
719 int crb_g; | |
720 int cb_b; | |
721 int cols_2 = cols / 2; | |
722 | |
723 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
|
724 while (y--) { |
0 | 725 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
|
726 while (x--) { |
0 | 727 register int L; |
728 | |
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
|
729 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
|
730 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
|
731 + 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
|
732 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
|
733 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
|
734 cb += 4; |
0 | 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 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
|
737 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
|
738 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
|
739 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
|
740 rgb_2_pix[L + cb_b]); |
0 | 741 row++; |
742 | |
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
|
743 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
|
744 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
|
745 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
|
746 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
|
747 rgb_2_pix[L + cb_b]); |
0 | 748 row++; |
749 | |
750 } | |
751 row += next_row; | |
752 } | |
753 } | |
754 | |
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
|
755 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
|
756 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
|
757 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
|
758 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
|
759 int rows, int cols, int mod) |
0 | 760 { |
761 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
|
762 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
|
763 const int next_row = (cols * 2 + mod) * 3; |
0 | 764 int x, y; |
765 int cr_r; | |
766 int crb_g; | |
767 int cb_b; | |
768 int cols_2 = cols / 2; | |
769 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
|
770 while (y--) { |
0 | 771 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
|
772 while (x--) { |
0 | 773 register int L; |
774 | |
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
|
775 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
|
776 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
|
777 + 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
|
778 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
|
779 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
|
780 cb += 4; |
0 | 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 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
|
783 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
|
784 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
|
785 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
|
786 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
|
787 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
|
788 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
|
789 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
|
790 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
|
791 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
|
792 row += 2 * 3; |
0 | 793 |
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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 row += 2 * 3; |
0 | 805 |
806 } | |
807 row += next_row; | |
808 } | |
809 } | |
810 | |
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
|
811 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
|
812 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
|
813 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
|
814 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
|
815 int rows, int cols, int mod) |
0 | 816 { |
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
|
817 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
|
818 const int next_row = cols * 2 + mod; |
0 | 819 int x, y; |
820 int cr_r; | |
821 int crb_g; | |
822 int cb_b; | |
823 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
|
824 mod += mod; |
0 | 825 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
|
826 while (y--) { |
0 | 827 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
|
828 while (x--) { |
0 | 829 register int L; |
830 | |
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
|
831 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
|
832 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
|
833 + 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
|
834 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
|
835 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
|
836 cb += 4; |
0 | 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 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
|
839 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
|
840 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
|
841 (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
|
842 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 843 row += 2; |
844 | |
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
|
845 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
|
846 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
|
847 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
|
848 (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
|
849 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]); |
0 | 850 row += 2; |
851 | |
852 | |
853 } | |
854 | |
855 row += next_row; | |
856 } | |
857 } | |
858 | |
859 /* | |
860 * How many 1 bits are there in the Uint32. | |
861 * Low performance, do not call often. | |
862 */ | |
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
|
863 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
|
864 number_of_bits_set(Uint32 a) |
0 | 865 { |
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
|
866 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
|
867 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
|
868 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
|
869 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
|
870 return (number_of_bits_set(a >> 1)); |
0 | 871 } |
872 | |
873 /* | |
874 * How many 0 bits are there at least significant end of Uint32. | |
875 * Low performance, do not call often. | |
876 */ | |
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
|
877 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
|
878 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
|
879 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
880 /* 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
|
881 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
|
882 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
|
883 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
|
884 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
|
885 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
|
886 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
887 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
888 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
|
889 SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) |
0 | 890 { |
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
|
891 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
|
892 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
|
893 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
|
894 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
|
895 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
|
896 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
|
897 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
898 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
|
899 (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
|
900 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
|
901 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
|
902 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
903 |
c121d94672cb
SDL 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 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
|
905 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
|
906 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
|
907 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
|
908 |
c121d94672cb
SDL 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 /* |
c121d94672cb
SDL 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 * 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
|
911 */ |
c121d94672cb
SDL 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 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
|
913 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
|
914 r_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Rmask); |
2795
9e7ce3069096
Set the alpha mask fixing software rendering in OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
915 r_2_pix_alloc[i + 256] |= Amask; |
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
|
916 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
|
917 g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Gmask); |
2795
9e7ce3069096
Set the alpha mask fixing software rendering in OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
918 g_2_pix_alloc[i + 256] |= Amask; |
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
|
919 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
|
920 b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Bmask); |
2795
9e7ce3069096
Set the alpha mask fixing software rendering in OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
921 b_2_pix_alloc[i + 256] |= Amask; |
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
|
922 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 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 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
|
926 * 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
|
927 * 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
|
928 * 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
|
929 * 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
|
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 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
|
932 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
|
933 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
|
934 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
|
935 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
|
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 } |
c121d94672cb
SDL 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 /* |
c121d94672cb
SDL 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 * 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
|
941 * 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
|
942 */ |
c121d94672cb
SDL 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 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
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
949 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
|
950 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 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 /* You have chosen wisely... */ |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
953 switch (swdata->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
954 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
955 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
|
956 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
|
957 #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
|
958 /* 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
|
959 if (SDL_HasMMX() && (Rmask == 0xF800) && |
2172
bef26cfc8f79
Fixed compiling YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
2168
diff
changeset
|
960 (Gmask == 0x07E0) && (Bmask == 0x001F) |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
961 && (swdata->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
|
962 /*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
|
963 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
|
964 } 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
|
965 /*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
|
966 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
|
967 } |
c121d94672cb
SDL 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 #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
|
969 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
|
970 #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
|
971 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
|
972 } |
c121d94672cb
SDL 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 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
|
974 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
|
975 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
|
976 } |
c121d94672cb
SDL 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 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
|
978 #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
|
979 /* 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
|
980 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
|
981 (Gmask == 0x0000FF00) && |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
982 (Bmask == 0x000000FF) && (swdata->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
|
983 /*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
|
984 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
|
985 } 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
|
986 /*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
|
987 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
|
988 } |
c121d94672cb
SDL 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 #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
|
990 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
|
991 #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
|
992 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
|
993 } |
c121d94672cb
SDL 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 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
995 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
996 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
997 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
|
998 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
|
999 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
|
1000 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
|
1001 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1002 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
|
1003 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
|
1004 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
|
1005 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1006 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
|
1007 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
|
1008 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
|
1009 } |
c121d94672cb
SDL 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 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
|
1011 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
|
1012 /* 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
|
1013 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
|
1014 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 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 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
|
1017 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
|
1018 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
|
1019 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1020 return 0; |
0 | 1021 } |
1022 | |
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
|
1023 SDL_SW_YUVTexture * |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1024 SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) |
0 | 1025 { |
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
|
1026 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
|
1027 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
|
1028 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
|
1029 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
|
1030 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
|
1031 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
|
1032 int CR, CB; |
0 | 1033 |
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
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 } |
0 | 1039 |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1040 switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1041 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1042 case SDL_PIXELFORMAT_IYUV: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1043 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1044 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1045 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
|
1046 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
|
1047 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
|
1048 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
|
1049 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
|
1050 } |
0 | 1051 |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1052 swdata->format = format; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1053 swdata->target_format = SDL_PIXELFORMAT_UNKNOWN; |
2786 | 1054 swdata->w = w; |
1055 swdata->h = h; | |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1056 swdata->pixels = (Uint8 *) SDL_malloc(w * h * 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
|
1057 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
|
1058 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
|
1059 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
|
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 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
|
1062 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
|
1063 } |
0 | 1064 |
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
|
1065 /* 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
|
1066 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
|
1067 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
|
1068 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
|
1069 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
|
1070 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
|
1071 /* 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
|
1072 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
|
1073 */ |
c121d94672cb
SDL 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 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
|
1075 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
|
1076 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
|
1077 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
|
1078 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
|
1079 } |
0 | 1080 |
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
|
1081 /* Find the pitch and offset values for the overlay */ |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1082 switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1083 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1084 case SDL_PIXELFORMAT_IYUV: |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1085 swdata->pitches[0] = w; |
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
|
1086 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
|
1087 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
|
1088 swdata->planes[0] = swdata->pixels; |
2786 | 1089 swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h; |
1090 swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * h / 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
|
1091 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1092 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1093 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1094 case SDL_PIXELFORMAT_YVYU: |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1095 swdata->pitches[0] = w * 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
|
1096 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
|
1097 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
|
1098 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
|
1099 /* 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
|
1100 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
|
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 /* 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
|
1104 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
|
1105 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1106 |
c121d94672cb
SDL 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 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
|
1108 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
|
1109 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
|
1110 { |
c121d94672cb
SDL 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 *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
|
1112 *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
|
1113 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
|
1114 } |
0 | 1115 |
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
|
1116 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
|
1117 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
|
1118 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
|
1119 { |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1120 switch (swdata->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1121 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1122 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
|
1123 if (rect |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1124 && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w |
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1125 || rect->h != swdata->h)) { |
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
|
1126 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
|
1127 ("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
|
1128 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
|
1129 } |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1130 SDL_memcpy(swdata->pixels, pixels, swdata->h * swdata->w * 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
|
1131 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1132 case SDL_PIXELFORMAT_YUY2: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1133 case SDL_PIXELFORMAT_UYVY: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1134 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
|
1135 { |
c121d94672cb
SDL 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 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
|
1137 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
|
1138 size_t length; |
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 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
|
1141 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
|
1142 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
|
1143 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
|
1144 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
|
1145 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
|
1146 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
|
1147 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
|
1148 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
|
1149 } |
c121d94672cb
SDL 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 } |
c121d94672cb
SDL 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 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
|
1152 } |
c121d94672cb
SDL 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 return 0; |
0 | 1154 } |
1155 | |
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
|
1156 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
|
1157 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
|
1158 int markDirty, void **pixels, int *pitch) |
0 | 1159 { |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1160 switch (swdata->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1161 case SDL_PIXELFORMAT_YV12: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1162 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
|
1163 if (rect |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1164 && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w |
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1165 || rect->h != swdata->h)) { |
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 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
|
1167 ("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
|
1168 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
|
1169 } |
c121d94672cb
SDL 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 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
|
1171 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 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 *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
|
1174 *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
|
1175 return 0; |
0 | 1176 } |
1177 | |
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
|
1178 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
|
1179 SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata) |
0 | 1180 { |
1181 } | |
1182 | |
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
|
1183 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
|
1184 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
|
1185 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
|
1186 int pitch) |
0 | 1187 { |
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
|
1188 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
|
1189 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
|
1190 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
|
1191 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
|
1192 |
c121d94672cb
SDL 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 /* 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
|
1194 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
|
1195 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
|
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 } |
c121d94672cb
SDL 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 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
|
1201 scale_2x = 0; |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1202 if (srcrect->x || srcrect->y || srcrect->w < swdata->w |
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1203 || srcrect->h < swdata->h) { |
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
|
1204 /* 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
|
1205 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
|
1206 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
|
1207 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
|
1208 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1209 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
|
1210 } 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
|
1211 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
|
1212 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
|
1213 } 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
|
1214 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
|
1215 } |
c121d94672cb
SDL 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 } |
c121d94672cb
SDL 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 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
|
1218 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
|
1219 Uint32 Rmask, Gmask, Bmask, Amask; |
0 | 1220 |
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
|
1221 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
|
1222 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
|
1223 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
|
1224 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
|
1225 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
|
1226 } 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
|
1227 /* 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
|
1228 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
|
1229 &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
|
1230 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
|
1231 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
|
1232 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
|
1233 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
|
1234 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
|
1235 } |
c121d94672cb
SDL 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 } |
c121d94672cb
SDL 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 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
|
1238 /* 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
|
1239 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
|
1240 &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
|
1241 swdata->stretch = |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1242 SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask, |
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
|
1243 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
|
1244 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
|
1245 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
|
1246 } |
c121d94672cb
SDL 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 } |
c121d94672cb
SDL 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 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
|
1249 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
|
1250 } |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1251 switch (swdata->format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1252 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
|
1253 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
|
1254 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
|
1255 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
|
1256 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1257 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
|
1258 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
|
1259 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
|
1260 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
|
1261 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1262 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
|
1263 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
|
1264 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
|
1265 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
|
1266 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1267 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
|
1268 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
|
1269 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
|
1270 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
|
1271 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1920
diff
changeset
|
1272 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
|
1273 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
|
1274 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
|
1275 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
|
1276 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
|
1277 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
|
1278 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
|
1279 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
|
1280 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1281 mod = (pitch / SDL_BYTESPERPIXEL(target_format)); |
0 | 1282 |
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
|
1283 if (scale_2x) { |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1284 mod -= (swdata->w * 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
|
1285 swdata->Display2X(swdata->colortab, swdata->rgb_2_pix, |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1286 lum, Cr, Cb, pixels, swdata->h, swdata->w, mod); |
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 } else { |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1288 mod -= swdata->w; |
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
|
1289 swdata->Display1X(swdata->colortab, swdata->rgb_2_pix, |
2781
5651642f4a78
Added software fallback for YUV overlay code when YUV textures aren't available.
Sam Lantinga <slouken@libsdl.org>
parents:
2197
diff
changeset
|
1290 lum, Cr, Cb, pixels, swdata->h, swdata->w, mod); |
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
|
1291 } |
c121d94672cb
SDL 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 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
|
1293 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
|
1294 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
|
1295 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1644
diff
changeset
|
1296 return 0; |
0 | 1297 } |
1298 | |
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
|
1299 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
|
1300 SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) |
0 | 1301 { |
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 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
|
1303 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
|
1304 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
|
1305 } |
c121d94672cb
SDL 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 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
|
1307 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
|
1308 } |
c121d94672cb
SDL 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 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
|
1310 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
|
1311 } |
c121d94672cb
SDL 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 (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
|
1313 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
|
1314 } |
c121d94672cb
SDL 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 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
|
1316 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
|
1317 } |
c121d94672cb
SDL 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 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
|
1319 } |
c121d94672cb
SDL 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 } |
0 | 1321 |
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
|
1322 /* vi: set ts=4 sw=4 expandtab: */ |