Mercurial > sdl-ios-xcode
annotate test/testoverlay.c @ 791:ab0d977f91f8
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 29 Jan 2004 04:35:51 +0000 |
parents | 6399f4e90211 |
children | be9c9c8f6d53 |
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 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* 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
|
25 only as examples. |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
28 void 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
|
29 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
30 int i; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
31 |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
32 if (monochrome) |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
33 { |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #if 1 /* these are the two formulas that I found on the FourCC site... */ |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
35 yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
36 yuv[1] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
37 yuv[2] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
38 #else |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
39 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
|
40 yuv[1] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
41 yuv[2] = 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
42 #endif |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
43 } |
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 { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
46 #if 1 /* these are the two formulas that I found on the FourCC site... */ |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
47 yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
48 yuv[1] = (rgb[2]-yuv[0])*0.565 + 128; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
49 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
|
50 #else |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 #endif |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
55 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
56 |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
57 if (luminance!=100) |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
58 { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
59 yuv[0]=yuv[0]*luminance/100; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
60 if (yuv[0]>255) |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
61 yuv[0]=255; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
62 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
63 |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
64 /* 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
|
65 /* |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
66 for(i=0;i<3;i++) |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
67 { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
68 if(yuv[i]<0) |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
69 yuv[i]=0; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
70 if(yuv[i]>255) |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
71 yuv[i]=255; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
72 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
73 */ |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
76 ConvertRGBtoYV12(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance) |
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 int x,y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 int yuv[3]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 Uint8 *p,*op[3]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_LockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 SDL_LockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 /* Black initialization */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 /* |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 memset(o->pixels[0],0,o->pitches[0]*o->h); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2)); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 /* Convert */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 for(y=0; y<s->h && y<o->h; y++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 { |
605
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
603
diff
changeset
|
95 p=((Uint8 *) s->pixels)+s->pitch*y; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 op[0]=o->pixels[0]+o->pitches[0]*y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 op[1]=o->pixels[1]+o->pitches[1]*(y/2); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 op[2]=o->pixels[2]+o->pitches[2]*(y/2); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 for(x=0; x<s->w && x<o->w; x++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
101 RGBtoYUV(p, yuv, monochrome, luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 *(op[0]++)=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 if(x%2==0 && y%2==0) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 *(op[1]++)=yuv[2]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 *(op[2]++)=yuv[1]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 p+=s->format->BytesPerPixel; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 SDL_UnlockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 SDL_UnlockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
116 ConvertRGBtoIYUV(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 int x,y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 int yuv[3]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 Uint8 *p,*op[3]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 SDL_LockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 SDL_LockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 /* Black initialization */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 /* |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 memset(o->pixels[0],0,o->pitches[0]*o->h); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2)); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 /* Convert */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 for(y=0; y<s->h && y<o->h; y++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 { |
605
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
603
diff
changeset
|
135 p=((Uint8 *) s->pixels)+s->pitch*y; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 op[0]=o->pixels[0]+o->pitches[0]*y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 op[1]=o->pixels[1]+o->pitches[1]*(y/2); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 op[2]=o->pixels[2]+o->pitches[2]*(y/2); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 for(x=0; x<s->w && x<o->w; x++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
141 RGBtoYUV(p,yuv, monochrome, luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 *(op[0]++)=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 if(x%2==0 && y%2==0) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 *(op[1]++)=yuv[1]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 *(op[2]++)=yuv[2]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 p+=s->format->BytesPerPixel; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 SDL_UnlockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 SDL_UnlockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
156 ConvertRGBtoUYVY(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 int x,y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 int yuv[3]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 Uint8 *p,*op; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 SDL_LockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 SDL_LockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 for(y=0; y<s->h && y<o->h; y++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 { |
605
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
603
diff
changeset
|
167 p=((Uint8 *) s->pixels)+s->pitch*y; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 op=o->pixels[0]+o->pitches[0]*y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 for(x=0; x<s->w && x<o->w; x++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
171 RGBtoYUV(p, yuv, monochrome, luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 if(x%2==0) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 *(op++)=yuv[1]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 *(op++)=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 *(op++)=yuv[2]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 *(op++)=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 p+=s->format->BytesPerPixel; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 SDL_UnlockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 SDL_UnlockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
189 ConvertRGBtoYVYU(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 int x,y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 int yuv[3]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 Uint8 *p,*op; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 SDL_LockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 SDL_LockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 for(y=0; y<s->h && y<o->h; y++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 { |
605
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
603
diff
changeset
|
200 p=((Uint8 *) s->pixels)+s->pitch*y; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 op=o->pixels[0]+o->pitches[0]*y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 for(x=0; x<s->w && x<o->w; x++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
204 RGBtoYUV(p,yuv, monochrome, luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 if(x%2==0) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 *(op++)=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 *(op++)=yuv[2]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 op[1]=yuv[1]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 *op=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 op+=2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 p+=s->format->BytesPerPixel; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 } |
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 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 SDL_UnlockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 SDL_UnlockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
225 ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 int x,y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 int yuv[3]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 Uint8 *p,*op; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 SDL_LockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 SDL_LockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 for(y=0; y<s->h && y<o->h; y++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 { |
605
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
603
diff
changeset
|
236 p=((Uint8 *) s->pixels)+s->pitch*y; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 op=o->pixels[0]+o->pitches[0]*y; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 for(x=0; x<s->w && x<o->w; x++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
240 RGBtoYUV(p,yuv, monochrome, luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 if(x%2==0) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 *(op++)=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 *(op++)=yuv[1]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 op[1]=yuv[2]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 *op=yuv[0]; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 op+=2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 } |
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 p+=s->format->BytesPerPixel; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 SDL_UnlockYUVOverlay(o); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 SDL_UnlockSurface(s); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 void Draw() |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 SDL_Rect rect; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 int i; |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
265 int disp; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 if(!scale) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 rect.w=overlay->w; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 rect.h=overlay->h; |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
271 for(i=0; i<h-rect.h && i<w-rect.w; i++) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 rect.x=i; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 rect.y=i; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 SDL_DisplayYUVOverlay(overlay,&rect); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
280 rect.w=overlay->w/2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
281 rect.h=overlay->h/2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
282 rect.x=(w-rect.w)/2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
283 rect.y=(h-rect.h)/2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
284 disp=rect.y-1; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
285 for(i=0; i<disp; i++) |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 { |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
287 rect.w+=2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
288 rect.h+=2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
289 rect.x--; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
290 rect.y--; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 SDL_DisplayYUVOverlay(overlay,&rect); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 printf("Displayed %d times.\n",i); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
297 static void PrintUsage(char *argv0) |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
298 { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
299 fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
300 fprintf(stderr, "Where 'arg' is one of:\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
301 fprintf(stderr, " -delay <seconds>\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
302 fprintf(stderr, " -width <pixels>\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
303 fprintf(stderr, " -height <pixels>\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
304 fprintf(stderr, " -bpp <bits>\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
305 fprintf(stderr, " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
306 fprintf(stderr, " -hw\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
307 fprintf(stderr, " -flip\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
308 fprintf(stderr, " -scale (test scaling features, from 50%% upto window size)\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
309 fprintf(stderr, " -mono (use monochromatic RGB2YUV conversion)\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
310 fprintf(stderr, " -lum <perc> (use luminance correction during RGB2YUV conversion,\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
311 fprintf(stderr, " from 0%% to unlimited, normal is 100%%)\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
312 fprintf(stderr, " -help (shows this help)\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
313 fprintf(stderr, " -fullscreen (test overlay in fullscreen mode)\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
314 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
315 |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 int main(int argc, char **argv) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 { |
603 | 318 char *argv0 = argv[0]; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 int flip; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 int delay; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 int desired_bpp; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 Uint32 video_flags, overlay_format; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 char *bmpfile; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 #ifdef BENCHMARK_SDL |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 Uint32 then, now; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 #endif |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 int i; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 /* Set default options and check command-line */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 flip = 0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 scale=0; |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
332 monochrome=0; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
333 luminance=100; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 delay = 1; |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
335 w = WINDOW_WIDTH; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
336 h = WINDOW_HEIGHT; |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 desired_bpp = 0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 video_flags = 0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 overlay_format = SDL_YV12_OVERLAY; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 while ( argc > 1 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 if ( strcmp(argv[1], "-delay") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 if ( argv[2] ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 delay = atoi(argv[2]); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 argv += 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 argc -= 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 } else { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 fprintf(stderr, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 "The -delay option requires an argument\n"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 } else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 if ( strcmp(argv[1], "-width") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 if ( argv[2] && ((w = atoi(argv[2])) > 0) ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 argv += 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 argc -= 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 } else { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 fprintf(stderr, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 "The -width option requires an argument\n"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 } else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 if ( strcmp(argv[1], "-height") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 if ( argv[2] && ((h = atoi(argv[2])) > 0) ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 argv += 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 argc -= 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 } else { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 fprintf(stderr, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 "The -height option requires an argument\n"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 } else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 if ( strcmp(argv[1], "-bpp") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 if ( argv[2] ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 desired_bpp = atoi(argv[2]); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 argv += 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 argc -= 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 } else { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 fprintf(stderr, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 "The -bpp option requires an argument\n"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 } else |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
384 if ( strcmp(argv[1], "-lum") == 0 ) { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
385 if ( argv[2] ) { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
386 luminance = atoi(argv[2]); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
387 argv += 2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
388 argc -= 2; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
389 } else { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
390 fprintf(stderr, |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
391 "The -lum option requires an argument\n"); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
392 exit(1); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
393 } |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
394 } else |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 if ( strcmp(argv[1], "-format") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 if ( argv[2] ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 if(!strcmp(argv[2],"YV12")) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 overlay_format = SDL_YV12_OVERLAY; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 else if(!strcmp(argv[2],"IYUV")) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 overlay_format = SDL_IYUV_OVERLAY; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 else if(!strcmp(argv[2],"YUY2")) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 overlay_format = SDL_YUY2_OVERLAY; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 else if(!strcmp(argv[2],"UYVY")) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 overlay_format = SDL_UYVY_OVERLAY; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 else if(!strcmp(argv[2],"YVYU")) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 overlay_format = SDL_YVYU_OVERLAY; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 fprintf(stderr, "The -format option %s is not recognized\n",argv[2]); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 argv += 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 argc -= 2; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 } else { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 fprintf(stderr, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 "The -format option requires an argument\n"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 } else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 if ( strcmp(argv[1], "-hw") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 video_flags |= SDL_HWSURFACE; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 argv += 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 argc -= 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 } else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 if ( strcmp(argv[1], "-flip") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 video_flags |= SDL_DOUBLEBUF; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 argv += 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 argc -= 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 } else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 if ( strcmp(argv[1], "-scale") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 scale = 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 argv += 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 argc -= 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 } else |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
435 if ( strcmp(argv[1], "-mono") == 0 ) { |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
436 monochrome = 1; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
437 argv += 1; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
438 argc -= 1; |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
439 } else |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
440 if (( strcmp(argv[1], "-help") == 0 ) || (strcmp(argv[1], "-h") == 0)) { |
603 | 441 PrintUsage(argv0); |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
442 exit(1); |
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
443 } else |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 if ( strcmp(argv[1], "-fullscreen") == 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 video_flags |= SDL_FULLSCREEN; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 argv += 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 argc -= 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 } else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 break; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 fprintf(stderr, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 "Couldn't initialize SDL: %s\n", SDL_GetError()); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 atexit(SDL_Quit); /* Clean up on exit */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 /* Initialize the display */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 if ( screen == NULL ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 w, h, desired_bpp, SDL_GetError()); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 printf("Set%s %dx%dx%d mode\n", |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 screen->flags & SDL_FULLSCREEN ? " fullscreen" : "", |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 screen->w, screen->h, screen->format->BitsPerPixel); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 printf("(video surface located in %s memory)\n", |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 (screen->flags&SDL_HWSURFACE) ? "video" : "system"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 if ( screen->flags & SDL_DOUBLEBUF ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 printf("Double-buffering enabled\n"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 flip = 1; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 /* Set the window manager title bar */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 SDL_WM_SetCaption("SDL test overlay", "testoverlay"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 /* Load picture */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 bmpfile=(argv[1]?argv[1]:"sample.bmp"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 pic = SDL_LoadBMP(bmpfile); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 if ( pic == NULL ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 SDL_GetError()); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 /* Convert the picture to 32bits, for easy conversion */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 SDL_Surface *newsurf; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 SDL_PixelFormat format; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 format.palette=NULL; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 format.BitsPerPixel=32; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 format.BytesPerPixel=4; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 format.Rshift=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 format.Gshift=8; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 format.Bshift=16; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 #else |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 format.Rshift=24; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 format.Gshift=16; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 format.Bshift=8; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 #endif |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 format.Ashift=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 format.Rmask=0xff<<format.Rshift; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 format.Gmask=0xff<<format.Gshift; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 format.Bmask=0xff<<format.Bshift; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 format.Amask=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 format.Rloss=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 format.Gloss=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 format.Bloss=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 format.Aloss=8; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 format.colorkey=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 format.alpha=0; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 newsurf=SDL_ConvertSurface(pic, &format, SDL_SWSURFACE); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 if(!newsurf) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n", |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 SDL_GetError()); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 SDL_FreeSurface(pic); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 pic=newsurf; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 /* Create the overlay */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 overlay = SDL_CreateYUVOverlay(pic->w, pic->h, overlay_format, screen); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 if ( overlay == NULL ) { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError()); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 printf("Created %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes, |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 overlay->hw_overlay?"hardware":"software", |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 overlay->format==SDL_YV12_OVERLAY?"YV12": |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 overlay->format==SDL_IYUV_OVERLAY?"IYUV": |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 overlay->format==SDL_YUY2_OVERLAY?"YUY2": |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 overlay->format==SDL_UYVY_OVERLAY?"UYVY": |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 overlay->format==SDL_YVYU_OVERLAY?"YVYU": |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 "Unknown"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 for(i=0; i<overlay->planes; i++) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 printf(" plane %d: pitch=%d\n", i, overlay->pitches[i]); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 /* Convert to YUV, and draw to the overlay */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 #ifdef BENCHMARK_SDL |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 then = SDL_GetTicks(); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 #endif |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 switch(overlay->format) |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 { |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 case SDL_YV12_OVERLAY: |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
553 ConvertRGBtoYV12(pic,overlay,monochrome,luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 break; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 case SDL_UYVY_OVERLAY: |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
556 ConvertRGBtoUYVY(pic,overlay,monochrome,luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 break; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 case SDL_YVYU_OVERLAY: |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
559 ConvertRGBtoYVYU(pic,overlay,monochrome,luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 break; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 case SDL_YUY2_OVERLAY: |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
562 ConvertRGBtoYUY2(pic,overlay,monochrome,luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 break; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 case SDL_IYUV_OVERLAY: |
569
e8063c656626
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
277
diff
changeset
|
565 ConvertRGBtoIYUV(pic,overlay,monochrome,luminance); |
277
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
566 break; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
567 default: |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 printf("cannot convert RGB picture to obtained YUV format!\n"); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 exit(1); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 break; |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 #ifdef BENCHMARK_SDL |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 now = SDL_GetTicks(); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 printf("Conversion Time: %d milliseconds\n", now-then); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 #endif |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 /* Do all the drawing work */ |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 #ifdef BENCHMARK_SDL |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 then = SDL_GetTicks(); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 #endif |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 Draw(); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 #ifdef BENCHMARK_SDL |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 now = SDL_GetTicks(); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 printf("Time: %d milliseconds\n", now-then); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 #endif |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 SDL_Delay(delay*1000); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 return(0); |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 } |
255c7ee077cb
Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 |