annotate test/testoverlay.c @ 596:475f969e8c01

CVS should ignore files automatically generated by building on MacOS X
author Sam Lantinga <slouken@libsdl.org>
date Sun, 09 Feb 2003 02:58:40 +0000
parents e8063c656626
children 2e726be3dc08
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 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 p=s->pixels+s->pitch*y;
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 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 p=s->pixels+s->pitch*y;
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 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 p=s->pixels+s->pitch*y;
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 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 p=s->pixels+s->pitch*y;
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 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 p=s->pixels+s->pitch*y;
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 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 int flip;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 int delay;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 int desired_bpp;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 Uint32 video_flags, overlay_format;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 char *bmpfile;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 Uint32 then, now;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 int i;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 /* Set default options and check command-line */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 flip = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 scale=0;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
331 monochrome=0;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
332 luminance=100;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 delay = 1;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
334 w = WINDOW_WIDTH;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
335 h = WINDOW_HEIGHT;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 desired_bpp = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 video_flags = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 overlay_format = SDL_YV12_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 while ( argc > 1 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 if ( strcmp(argv[1], "-delay") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 delay = atoi(argv[2]);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 "The -delay option requires an argument\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 if ( strcmp(argv[1], "-width") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 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
354 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 "The -width option requires an argument\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 if ( strcmp(argv[1], "-height") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 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
364 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 "The -height option requires an argument\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 if ( strcmp(argv[1], "-bpp") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 desired_bpp = atoi(argv[2]);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 "The -bpp option requires an argument\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 } else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
383 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
384 if ( argv[2] ) {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
385 luminance = atoi(argv[2]);
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
386 argv += 2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
387 argc -= 2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
388 } else {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
389 fprintf(stderr,
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
390 "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
391 exit(1);
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
392 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
393 } else
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 if ( strcmp(argv[1], "-format") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 if(!strcmp(argv[2],"YV12"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 overlay_format = SDL_YV12_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 else if(!strcmp(argv[2],"IYUV"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 overlay_format = SDL_IYUV_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 else if(!strcmp(argv[2],"YUY2"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 overlay_format = SDL_YUY2_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 else if(!strcmp(argv[2],"UYVY"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 overlay_format = SDL_UYVY_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 else if(!strcmp(argv[2],"YVYU"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 overlay_format = SDL_YVYU_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 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
409 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 "The -format option requires an argument\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 if ( strcmp(argv[1], "-hw") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 video_flags |= SDL_HWSURFACE;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 if ( strcmp(argv[1], "-flip") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 video_flags |= SDL_DOUBLEBUF;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 if ( strcmp(argv[1], "-scale") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 scale = 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 } else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
434 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
435 monochrome = 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
436 argv += 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
437 argc -= 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
438 } else
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
439 if (( strcmp(argv[1], "-help") == 0 ) || (strcmp(argv[1], "-h") == 0)) {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
440 PrintUsage(argv[0]);
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
441 exit(1);
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
442 } else
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 if ( strcmp(argv[1], "-fullscreen") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 video_flags |= SDL_FULLSCREEN;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 "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
453 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 atexit(SDL_Quit); /* Clean up on exit */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 /* Initialize the display */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 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
459 if ( screen == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 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
461 w, h, desired_bpp, SDL_GetError());
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 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
465 screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 screen->w, screen->h, screen->format->BitsPerPixel);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 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
468 (screen->flags&SDL_HWSURFACE) ? "video" : "system");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 if ( screen->flags & SDL_DOUBLEBUF ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 printf("Double-buffering enabled\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 flip = 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 }
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 /* Set the window manager title bar */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 SDL_WM_SetCaption("SDL test overlay", "testoverlay");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 /* Load picture */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 bmpfile=(argv[1]?argv[1]:"sample.bmp");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 pic = SDL_LoadBMP(bmpfile);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 if ( pic == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 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
482 SDL_GetError());
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 }
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 /* 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
487 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 SDL_Surface *newsurf;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 SDL_PixelFormat format;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 format.palette=NULL;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 format.BitsPerPixel=32;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 format.BytesPerPixel=4;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 format.Rshift=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 format.Gshift=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 format.Bshift=16;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 #else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 format.Rshift=24;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 format.Gshift=16;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 format.Bshift=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 format.Ashift=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 format.Rmask=0xff<<format.Rshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 format.Gmask=0xff<<format.Gshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 format.Bmask=0xff<<format.Bshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 format.Amask=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 format.Rloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 format.Gloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 format.Bloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 format.Aloss=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 format.colorkey=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 format.alpha=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 newsurf=SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 if(!newsurf)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 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
519 SDL_GetError());
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 SDL_FreeSurface(pic);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 pic=newsurf;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 }
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 /* Create the overlay */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 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
528 if ( overlay == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 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
530 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 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
533 overlay->hw_overlay?"hardware":"software",
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 overlay->format==SDL_YV12_OVERLAY?"YV12":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 overlay->format==SDL_IYUV_OVERLAY?"IYUV":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 overlay->format==SDL_YUY2_OVERLAY?"YUY2":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 overlay->format==SDL_UYVY_OVERLAY?"UYVY":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 overlay->format==SDL_YVYU_OVERLAY?"YVYU":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 "Unknown");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 for(i=0; i<overlay->planes; i++)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 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
543 }
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 /* 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
546 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 then = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 switch(overlay->format)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 case SDL_YV12_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
552 ConvertRGBtoYV12(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 case SDL_UYVY_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
555 ConvertRGBtoUYVY(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 case SDL_YVYU_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
558 ConvertRGBtoYVYU(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 case SDL_YUY2_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
561 ConvertRGBtoYUY2(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 case SDL_IYUV_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
564 ConvertRGBtoIYUV(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 default:
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 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
568 exit(1);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 now = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 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
574 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 /* Do all the drawing work */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 then = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 Draw();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 now = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583 printf("Time: %d milliseconds\n", now-then);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 SDL_Delay(delay*1000);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 return(0);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588