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