Mercurial > sdl-ios-xcode
annotate test/testoverlay.c @ 4426:1bceff8f008f
Fixed bug #943
Ozkan Sezer 2010-02-06 12:31:06 PST
Hi:
Here are some small fixes for compiling SDL against mingw-w64.
(see http://mingw-w64.sourceforge.net/ . Despite the name, it
supports both win32 and win64.)
src/audio/windx5/directx.h and src/video/windx5/directx.h (both
SDL-1.2 and SDL-1.3.) I get compilation errors about some union
not having a member named u1 and alike, because of other system
headers being included before this one and them already defining
DUMMYUNIONNAME and stuff. This header probably assumes that those
stuff are defined in windef.h, but mingw-w64 headers define them
in _mingw.h. Easily fixed by moving NONAMELESSUNION definition to
the top of the file.
src/thread/win32/SDL_systhread.c (both SDL-1.2 and SDL-1.3.) :
The __GNUC__ case for pfnSDL_CurrentBeginThread is 32-bit centric
because _beginthreadex returns uintptr_t, not unsigned long which
is 32 bits in win64. Changing the return type to uintptr_t fixes
it.
video/SDL_blit.h (and configure.in) (SDL-1.3-only) : MinGW-w64
uses msvcrt version of _aligned_malloc and _aligned_free and
they are defined in intrin.h (similar to VC). Adding proper
ifdefs fixes it. (Notes about macros to check: __MINGW32__ is
defined for both mingw.org and for mingw-w64 for both win32 and
win64, __MINGW64__ is only defined for _WIN64, so __MINGW64__
can't be used to detect mingw-w64: including _mingw.h and then
checking for __MINGW64_VERSION_MAJOR does the trick.)
SDL_win32video.h (SDL-1.3-only) : Tweaked the VINWER definition
and location in order to avoid multiple redefinition warnings.
Hope these are useful. Thanks.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 10 Mar 2010 15:02:58 +0000 |
parents | c785543d1843 |
children | 27ab20a36eba |
rev | line source |
---|---|
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 /* Bring up a window and play with it */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 #include <stdlib.h> |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 #include <string.h> |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #define BENCHMARK_SDL |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 #define NOTICE(X) printf("%s", X); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
12 #define WINDOW_WIDTH 640 |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
13 #define WINDOW_HEIGHT 480 |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
14 |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 #include "SDL.h" |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 SDL_Surface *screen, *pic; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 SDL_Overlay *overlay; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 int scale; |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
20 int monochrome; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
21 int luminance; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
22 int w, h; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
605
diff
changeset
|
24 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
25 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
26 quit(int rc) |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
605
diff
changeset
|
27 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
28 SDL_Quit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
29 exit(rc); |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
605
diff
changeset
|
30 } |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
605
diff
changeset
|
31 |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 /* NOTE: These RGB conversion functions are not intended for speed, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 only as examples. |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
36 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
37 RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
39 if (monochrome) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
40 #if 1 /* these are the two formulas that I found on the FourCC site... */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
41 yuv[0] = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]; |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
42 yuv[1] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
43 yuv[2] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
44 #else |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
45 yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
46 yuv[1] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
47 yuv[2] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
48 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
49 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
50 #if 1 /* these are the two formulas that I found on the FourCC site... */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
51 yuv[0] = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
52 yuv[1] = (rgb[2] - yuv[0]) * 0.565 + 128; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
53 yuv[2] = (rgb[0] - yuv[0]) * 0.713 + 128; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 #else |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
55 yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
56 yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
57 yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 #endif |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
59 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
60 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
61 if (luminance != 100) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
62 yuv[0] = yuv[0] * luminance / 100; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
63 if (yuv[0] > 255) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
64 yuv[0] = 255; |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
65 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
66 |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
67 /* clamp values...if you need to, we don't seem to have a need */ |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
68 /* |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
69 for(i=0;i<3;i++) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
70 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
71 if(yuv[i]<0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
72 yuv[i]=0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
73 if(yuv[i]>255) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
74 yuv[i]=255; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
75 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
76 */ |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
79 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
80 ConvertRGBtoYV12(SDL_Surface * s, SDL_Overlay * o, int monochrome, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
81 int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
83 int x, y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
84 int yuv[3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
85 Uint8 *p, *op[3]; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
87 SDL_LockSurface(s); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
88 SDL_LockYUVOverlay(o); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
90 /* Black initialization */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
91 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
92 memset(o->pixels[0],0,o->pitches[0]*o->h); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
93 memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
94 memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
95 */ |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
97 /* Convert */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
98 for (y = 0; y < s->h && y < o->h; y++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
99 p = ((Uint8 *) s->pixels) + s->pitch * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
100 op[0] = o->pixels[0] + o->pitches[0] * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
101 op[1] = o->pixels[1] + o->pitches[1] * (y / 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
102 op[2] = o->pixels[2] + o->pitches[2] * (y / 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
103 for (x = 0; x < s->w && x < o->w; x++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
104 RGBtoYUV(p, yuv, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
105 *(op[0]++) = yuv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
106 if (x % 2 == 0 && y % 2 == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
107 *(op[1]++) = yuv[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
108 *(op[2]++) = yuv[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
109 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
110 p += s->format->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
111 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
112 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
114 SDL_UnlockYUVOverlay(o); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
115 SDL_UnlockSurface(s); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
118 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
119 ConvertRGBtoIYUV(SDL_Surface * s, SDL_Overlay * o, int monochrome, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
120 int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
122 int x, y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
123 int yuv[3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
124 Uint8 *p, *op[3]; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
126 SDL_LockSurface(s); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
127 SDL_LockYUVOverlay(o); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
129 /* Black initialization */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
130 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
131 memset(o->pixels[0],0,o->pitches[0]*o->h); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
132 memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
133 memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
134 */ |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
136 /* Convert */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
137 for (y = 0; y < s->h && y < o->h; y++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
138 p = ((Uint8 *) s->pixels) + s->pitch * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
139 op[0] = o->pixels[0] + o->pitches[0] * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
140 op[1] = o->pixels[1] + o->pitches[1] * (y / 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
141 op[2] = o->pixels[2] + o->pitches[2] * (y / 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
142 for (x = 0; x < s->w && x < o->w; x++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
143 RGBtoYUV(p, yuv, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
144 *(op[0]++) = yuv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
145 if (x % 2 == 0 && y % 2 == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
146 *(op[1]++) = yuv[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
147 *(op[2]++) = yuv[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
148 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
149 p += s->format->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
150 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
151 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
153 SDL_UnlockYUVOverlay(o); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
154 SDL_UnlockSurface(s); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
157 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
158 ConvertRGBtoUYVY(SDL_Surface * s, SDL_Overlay * o, int monochrome, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
159 int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
161 int x, y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
162 int yuv[3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
163 Uint8 *p, *op; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
165 SDL_LockSurface(s); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
166 SDL_LockYUVOverlay(o); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
168 for (y = 0; y < s->h && y < o->h; y++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
169 p = ((Uint8 *) s->pixels) + s->pitch * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
170 op = o->pixels[0] + o->pitches[0] * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
171 for (x = 0; x < s->w && x < o->w; x++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
172 RGBtoYUV(p, yuv, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
173 if (x % 2 == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
174 *(op++) = yuv[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
175 *(op++) = yuv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
176 *(op++) = yuv[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
177 } else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
178 *(op++) = yuv[0]; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
180 p += s->format->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
181 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
182 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
184 SDL_UnlockYUVOverlay(o); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
185 SDL_UnlockSurface(s); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
188 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
189 ConvertRGBtoYVYU(SDL_Surface * s, SDL_Overlay * o, int monochrome, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
190 int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
192 int x, y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
193 int yuv[3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
194 Uint8 *p, *op; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
196 SDL_LockSurface(s); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
197 SDL_LockYUVOverlay(o); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
199 for (y = 0; y < s->h && y < o->h; y++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
200 p = ((Uint8 *) s->pixels) + s->pitch * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
201 op = o->pixels[0] + o->pitches[0] * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
202 for (x = 0; x < s->w && x < o->w; x++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
203 RGBtoYUV(p, yuv, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
204 if (x % 2 == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
205 *(op++) = yuv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
206 *(op++) = yuv[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
207 op[1] = yuv[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
208 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
209 *op = yuv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
210 op += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
211 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
213 p += s->format->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
214 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
215 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
217 SDL_UnlockYUVOverlay(o); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
218 SDL_UnlockSurface(s); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
221 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
222 ConvertRGBtoYUY2(SDL_Surface * s, SDL_Overlay * o, int monochrome, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
223 int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
225 int x, y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
226 int yuv[3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
227 Uint8 *p, *op; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
229 SDL_LockSurface(s); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
230 SDL_LockYUVOverlay(o); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
232 for (y = 0; y < s->h && y < o->h; y++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
233 p = ((Uint8 *) s->pixels) + s->pitch * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
234 op = o->pixels[0] + o->pitches[0] * y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
235 for (x = 0; x < s->w && x < o->w; x++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
236 RGBtoYUV(p, yuv, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
237 if (x % 2 == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
238 *(op++) = yuv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
239 *(op++) = yuv[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
240 op[1] = yuv[2]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
241 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
242 *op = yuv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
243 op += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
244 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
246 p += s->format->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
247 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
248 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
250 SDL_UnlockYUVOverlay(o); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
251 SDL_UnlockSurface(s); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
254 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
255 Draw() |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
257 SDL_Rect rect; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
258 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
259 int disp; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
261 if (!scale) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
262 rect.w = overlay->w; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
263 rect.h = overlay->h; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
264 for (i = 0; i < h - rect.h && i < w - rect.w; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
265 rect.x = i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
266 rect.y = i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
267 SDL_DisplayYUVOverlay(overlay, &rect); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
268 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
269 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
270 rect.w = overlay->w / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
271 rect.h = overlay->h / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
272 rect.x = (w - rect.w) / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
273 rect.y = (h - rect.h) / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
274 disp = rect.y - 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
275 for (i = 0; i < disp; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
276 rect.w += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
277 rect.h += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
278 rect.x--; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
279 rect.y--; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
280 SDL_DisplayYUVOverlay(overlay, &rect); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
281 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
282 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
283 printf("Displayed %d times.\n", i); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
286 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
287 PrintUsage(char *argv0) |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
288 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
289 fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
290 fprintf(stderr, "Where 'arg' is one of:\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
291 fprintf(stderr, " -delay <seconds>\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
292 fprintf(stderr, " -width <pixels>\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
293 fprintf(stderr, " -height <pixels>\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
294 fprintf(stderr, " -bpp <bits>\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
295 fprintf(stderr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
296 " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
297 fprintf(stderr, " -hw\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
298 fprintf(stderr, " -flip\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
299 fprintf(stderr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
300 " -scale (test scaling features, from 50%% upto window size)\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
301 fprintf(stderr, " -mono (use monochromatic RGB2YUV conversion)\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
302 fprintf(stderr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
303 " -lum <perc> (use luminance correction during RGB2YUV conversion,\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
304 fprintf(stderr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
305 " from 0%% to unlimited, normal is 100%%)\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
306 fprintf(stderr, " -help (shows this help)\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
307 fprintf(stderr, " -fullscreen (test overlay in fullscreen mode)\n"); |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
308 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
309 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
310 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
311 main(int argc, char **argv) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
313 char *argv0 = argv[0]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
314 int flip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
315 int delay; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
316 int desired_bpp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
317 Uint32 video_flags, overlay_format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
318 char *bmpfile; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 #ifdef BENCHMARK_SDL |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
320 Uint32 then, now; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
322 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
323 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
324 /* Set default options and check command-line */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
325 flip = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
326 scale = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
327 monochrome = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
328 luminance = 100; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
329 delay = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
330 w = WINDOW_WIDTH; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
331 h = WINDOW_HEIGHT; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
332 desired_bpp = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
333 video_flags = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
334 overlay_format = SDL_YV12_OVERLAY; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
336 while (argc > 1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
337 if (strcmp(argv[1], "-delay") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
338 if (argv[2]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
339 delay = atoi(argv[2]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
340 argv += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
341 argc -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
342 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
343 fprintf(stderr, "The -delay option requires an argument\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
344 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
345 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
346 } else if (strcmp(argv[1], "-width") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
347 if (argv[2] && ((w = atoi(argv[2])) > 0)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
348 argv += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
349 argc -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
350 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
351 fprintf(stderr, "The -width option requires an argument\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
352 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
353 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
354 } else if (strcmp(argv[1], "-height") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
355 if (argv[2] && ((h = atoi(argv[2])) > 0)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
356 argv += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
357 argc -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
358 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
359 fprintf(stderr, "The -height option requires an argument\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
360 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
361 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
362 } else if (strcmp(argv[1], "-bpp") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
363 if (argv[2]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
364 desired_bpp = atoi(argv[2]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
365 argv += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
366 argc -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
367 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
368 fprintf(stderr, "The -bpp option requires an argument\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
369 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
370 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
371 } else if (strcmp(argv[1], "-lum") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
372 if (argv[2]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
373 luminance = atoi(argv[2]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
374 argv += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
375 argc -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
376 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
377 fprintf(stderr, "The -lum option requires an argument\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
378 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
379 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
380 } else if (strcmp(argv[1], "-format") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
381 if (argv[2]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
382 if (!strcmp(argv[2], "YV12")) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
383 overlay_format = SDL_YV12_OVERLAY; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
384 else if (!strcmp(argv[2], "IYUV")) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
385 overlay_format = SDL_IYUV_OVERLAY; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
386 else if (!strcmp(argv[2], "YUY2")) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
387 overlay_format = SDL_YUY2_OVERLAY; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
388 else if (!strcmp(argv[2], "UYVY")) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
389 overlay_format = SDL_UYVY_OVERLAY; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
390 else if (!strcmp(argv[2], "YVYU")) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
391 overlay_format = SDL_YVYU_OVERLAY; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
392 else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
393 fprintf(stderr, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
394 "The -format option %s is not recognized\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
395 argv[2]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
396 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
397 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
398 argv += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
399 argc -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
400 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
401 fprintf(stderr, "The -format option requires an argument\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
402 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
403 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
404 } else if (strcmp(argv[1], "-hw") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
405 video_flags |= SDL_HWSURFACE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
406 argv += 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
407 argc -= 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
408 } else if (strcmp(argv[1], "-flip") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
409 video_flags |= SDL_DOUBLEBUF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
410 argv += 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
411 argc -= 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
412 } else if (strcmp(argv[1], "-scale") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
413 scale = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
414 argv += 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
415 argc -= 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
416 } else if (strcmp(argv[1], "-mono") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
417 monochrome = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
418 argv += 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
419 argc -= 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
420 } else if ((strcmp(argv[1], "-help") == 0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
421 || (strcmp(argv[1], "-h") == 0)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
422 PrintUsage(argv0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
423 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
424 } else if (strcmp(argv[1], "-fullscreen") == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
425 video_flags |= SDL_FULLSCREEN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
426 argv += 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
427 argc -= 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
428 } else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
429 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
430 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
431 if (SDL_Init(SDL_INIT_VIDEO) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
432 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
433 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
434 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
436 /* Initialize the display */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
437 screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
438 if (screen == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
439 fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
440 w, h, desired_bpp, SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
441 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
442 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
443 printf("Set%s %dx%dx%d mode\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
444 screen->flags & SDL_FULLSCREEN ? " fullscreen" : "", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
445 screen->w, screen->h, screen->format->BitsPerPixel); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
446 printf("(video surface located in %s memory)\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
447 (screen->flags & SDL_HWSURFACE) ? "video" : "system"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
448 if (screen->flags & SDL_DOUBLEBUF) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
449 printf("Double-buffering enabled\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
450 flip = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
451 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
452 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
453 /* Set the window manager title bar */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
454 SDL_WM_SetCaption("SDL test overlay", "testoverlay"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
455 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
456 /* Load picture */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
457 bmpfile = (argv[1] ? argv[1] : "sample.bmp"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
458 pic = SDL_LoadBMP(bmpfile); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
459 if (pic == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
460 fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
461 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
462 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
463 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
464 /* Convert the picture to 32bits, for easy conversion */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
465 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
466 SDL_Surface *newsurf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
467 SDL_PixelFormat format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
468 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
469 format.palette = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
470 format.BitsPerPixel = 32; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
471 format.BytesPerPixel = 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
472 #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
473 format.Rshift = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
474 format.Gshift = 8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
475 format.Bshift = 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
476 #else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
477 format.Rshift = 24; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
478 format.Gshift = 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
479 format.Bshift = 8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
480 #endif |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
481 format.Ashift = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
482 format.Rmask = 0xff << format.Rshift; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
483 format.Gmask = 0xff << format.Gshift; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
484 format.Bmask = 0xff << format.Bshift; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
485 format.Amask = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
486 format.Rloss = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
487 format.Gloss = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
488 format.Bloss = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
489 format.Aloss = 8; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
491 newsurf = SDL_ConvertSurface(pic, &format, SDL_SWSURFACE); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
492 if (!newsurf) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
493 fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
494 SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
495 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
496 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
497 SDL_FreeSurface(pic); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
498 pic = newsurf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
499 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
501 /* Create the overlay */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
502 overlay = SDL_CreateYUVOverlay(pic->w, pic->h, overlay_format, screen); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
503 if (overlay == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
504 fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
505 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
506 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
507 printf("Created %dx%dx%d %s %s overlay\n", overlay->w, overlay->h, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
508 overlay->planes, overlay->hw_overlay ? "hardware" : "software", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
509 overlay->format == SDL_YV12_OVERLAY ? "YV12" : overlay->format == |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
510 SDL_IYUV_OVERLAY ? "IYUV" : overlay->format == |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
511 SDL_YUY2_OVERLAY ? "YUY2" : overlay->format == |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
512 SDL_UYVY_OVERLAY ? "UYVY" : overlay->format == |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
513 SDL_YVYU_OVERLAY ? "YVYU" : "Unknown"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
514 for (i = 0; i < overlay->planes; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
515 printf(" plane %d: pitch=%d\n", i, overlay->pitches[i]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
516 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
518 /* Convert to YUV, and draw to the overlay */ |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 #ifdef BENCHMARK_SDL |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
520 then = SDL_GetTicks(); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
522 switch (overlay->format) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
523 case SDL_YV12_OVERLAY: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
524 ConvertRGBtoYV12(pic, overlay, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
525 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
526 case SDL_UYVY_OVERLAY: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
527 ConvertRGBtoUYVY(pic, overlay, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
528 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
529 case SDL_YVYU_OVERLAY: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
530 ConvertRGBtoYVYU(pic, overlay, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
531 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
532 case SDL_YUY2_OVERLAY: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
533 ConvertRGBtoYUY2(pic, overlay, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
534 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
535 case SDL_IYUV_OVERLAY: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
536 ConvertRGBtoIYUV(pic, overlay, monochrome, luminance); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
537 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
538 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
539 printf("cannot convert RGB picture to obtained YUV format!\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
540 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
541 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
542 } |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 #ifdef BENCHMARK_SDL |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
544 now = SDL_GetTicks(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
545 printf("Conversion Time: %d milliseconds\n", now - then); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
547 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
548 /* Do all the drawing work */ |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 #ifdef BENCHMARK_SDL |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
550 then = SDL_GetTicks(); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
552 Draw(); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 #ifdef BENCHMARK_SDL |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
554 now = SDL_GetTicks(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
555 printf("Time: %d milliseconds\n", now - then); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
556 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
557 SDL_Delay(delay * 1000); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
558 SDL_Quit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
559 return (0); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 } |