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