annotate test/testoverlay.c @ 3971:aea2f9cd5b8e SDL-1.2

Fixed win32 event name list (WM_MOUSELAST was listed twice, one should be WM_MOUSEWHEEL).
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 16 Jun 2007 05:24:55 +0000
parents 4d3bb026cd16
children 782fd950bd46 c121d94672cb
rev   line source
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 /* Bring up a window and play with it */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 #include <stdlib.h>
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 #include <stdio.h>
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 #include <string.h>
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 #define BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 #define NOTICE(X) printf("%s", X);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
12 #define WINDOW_WIDTH 640
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
13 #define WINDOW_HEIGHT 480
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
14
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 #include "SDL.h"
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 SDL_Surface *screen, *pic;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 SDL_Overlay *overlay;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 int scale;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
20 int monochrome;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
21 int luminance;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
22 int w, h;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
24 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
25 static void quit(int rc)
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
26 {
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
27 SDL_Quit();
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
28 exit(rc);
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
29 }
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
30
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 /* 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
32 only as examples.
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
35 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
36 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
37 if (monochrome)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
38 {
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #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
40 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
41 yuv[1] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
42 yuv[2] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
43 #else
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
44 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
45 yuv[1] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
46 yuv[2] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
47 #endif
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
48 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
49 else
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
50 {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
51 #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
52 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
53 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
54 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
55 #else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
56 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
57 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
58 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
59 #endif
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
60 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
61
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
62 if (luminance!=100)
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 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
65 if (yuv[0]>255)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
66 yuv[0]=255;
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
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
69 /* 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
70 /*
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
71 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
72 {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
73 if(yuv[i]<0)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
74 yuv[i]=0;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
75 if(yuv[i]>255)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
76 yuv[i]=255;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
77 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
78 */
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
1439
4d3bb026cd16 Fixed warnings in -pedantic mode
Sam Lantinga <slouken@libsdl.org>
parents: 1151
diff changeset
81 void 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
82 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 Uint8 *p,*op[3];
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 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 /* Black initialization */
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 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
93 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
94 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
95 */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 /* Convert */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 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
99 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
100 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
101 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
102 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
103 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
104 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
105 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
106 RGBtoYUV(p, yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 *(op[0]++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 if(x%2==0 && y%2==0)
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 *(op[1]++)=yuv[2];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 *(op[2]++)=yuv[1];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 SDL_UnlockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120
1439
4d3bb026cd16 Fixed warnings in -pedantic mode
Sam Lantinga <slouken@libsdl.org>
parents: 1151
diff changeset
121 void 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
122 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 Uint8 *p,*op[3];
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 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 /* Black initialization */
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 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
133 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
134 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
135 */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 /* Convert */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 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
139 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
140 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
141 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
142 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
143 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
144 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
145 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
146 RGBtoYUV(p,yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 *(op[0]++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 if(x%2==0 && y%2==0)
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 *(op[1]++)=yuv[1];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 *(op[2]++)=yuv[2];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 SDL_UnlockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160
1439
4d3bb026cd16 Fixed warnings in -pedantic mode
Sam Lantinga <slouken@libsdl.org>
parents: 1151
diff changeset
161 void 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
162 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 Uint8 *p,*op;
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 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 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
171 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
172 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
173 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
174 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
175 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
176 RGBtoYUV(p, yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 if(x%2==0)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 *(op++)=yuv[1];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 *(op++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 *(op++)=yuv[2];
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 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 *(op++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 SDL_UnlockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
1439
4d3bb026cd16 Fixed warnings in -pedantic mode
Sam Lantinga <slouken@libsdl.org>
parents: 1151
diff changeset
194 void 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
195 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 Uint8 *p,*op;
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 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 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
204 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
205 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
206 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
207 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
208 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
209 RGBtoYUV(p,yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 if(x%2==0)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 *(op++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 *(op++)=yuv[2];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 op[1]=yuv[1];
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 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 *op=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 op+=2;
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
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 SDL_UnlockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229
1439
4d3bb026cd16 Fixed warnings in -pedantic mode
Sam Lantinga <slouken@libsdl.org>
parents: 1151
diff changeset
230 void 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
231 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 Uint8 *p,*op;
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 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 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
240 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
241 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
242 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
243 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
244 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
245 RGBtoYUV(p,yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if(x%2==0)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 *(op++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 *(op++)=yuv[1];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 op[1]=yuv[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 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 *op=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 op+=2;
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
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 p+=s->format->BytesPerPixel;
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
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 SDL_UnlockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 void Draw()
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 SDL_Rect rect;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 int i;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
270 int disp;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 if(!scale)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 rect.w=overlay->w;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 rect.h=overlay->h;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
276 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
277 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 rect.x=i;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 rect.y=i;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 SDL_DisplayYUVOverlay(overlay,&rect);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
285 rect.w=overlay->w/2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
286 rect.h=overlay->h/2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
287 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
288 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
289 disp=rect.y-1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
290 for(i=0; i<disp; i++)
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
292 rect.w+=2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
293 rect.h+=2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
294 rect.x--;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
295 rect.y--;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 SDL_DisplayYUVOverlay(overlay,&rect);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 printf("Displayed %d times.\n",i);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
302 static void PrintUsage(char *argv0)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
303 {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
304 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
305 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
306 fprintf(stderr, " -delay <seconds>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
307 fprintf(stderr, " -width <pixels>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
308 fprintf(stderr, " -height <pixels>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
309 fprintf(stderr, " -bpp <bits>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
310 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
311 fprintf(stderr, " -hw\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
312 fprintf(stderr, " -flip\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
313 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
314 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
315 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
316 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
317 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
318 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
319 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
320
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 int main(int argc, char **argv)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 {
603
2e726be3dc08 From: Jonathan Atkins
Sam Lantinga <slouken@libsdl.org>
parents: 569
diff changeset
323 char *argv0 = argv[0];
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 int flip;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 int delay;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 int desired_bpp;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 Uint32 video_flags, overlay_format;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 char *bmpfile;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 Uint32 then, now;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 int i;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 /* Set default options and check command-line */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 flip = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 scale=0;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
337 monochrome=0;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
338 luminance=100;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 delay = 1;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
340 w = WINDOW_WIDTH;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
341 h = WINDOW_HEIGHT;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 desired_bpp = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 video_flags = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 overlay_format = SDL_YV12_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 while ( argc > 1 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 if ( strcmp(argv[1], "-delay") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 delay = atoi(argv[2]);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 argc -= 2;
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 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 "The -delay option requires an argument\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
355 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 }
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 if ( strcmp(argv[1], "-width") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 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
360 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 argc -= 2;
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 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 "The -width option requires an argument\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
365 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 }
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 if ( strcmp(argv[1], "-height") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 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
370 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 argc -= 2;
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 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 "The -height option requires an argument\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
375 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 }
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 if ( strcmp(argv[1], "-bpp") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 desired_bpp = atoi(argv[2]);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 "The -bpp option requires an argument\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
386 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 } else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
389 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
390 if ( argv[2] ) {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
391 luminance = atoi(argv[2]);
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
392 argv += 2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
393 argc -= 2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
394 } else {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
395 fprintf(stderr,
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
396 "The -lum option requires an argument\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
397 return(1);
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
398 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
399 } else
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 if ( strcmp(argv[1], "-format") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 if(!strcmp(argv[2],"YV12"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 overlay_format = SDL_YV12_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 else if(!strcmp(argv[2],"IYUV"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 overlay_format = SDL_IYUV_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 else if(!strcmp(argv[2],"YUY2"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 overlay_format = SDL_YUY2_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 else if(!strcmp(argv[2],"UYVY"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 overlay_format = SDL_UYVY_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 else if(!strcmp(argv[2],"YVYU"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 overlay_format = SDL_YVYU_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 fprintf(stderr, "The -format option %s is not recognized\n",argv[2]);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
415 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 argc -= 2;
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 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 "The -format option requires an argument\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
422 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 }
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], "-hw") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 video_flags |= SDL_HWSURFACE;
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], "-flip") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 video_flags |= SDL_DOUBLEBUF;
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
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 if ( strcmp(argv[1], "-scale") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 scale = 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 } else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
440 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
441 monochrome = 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
442 argv += 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
443 argc -= 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
444 } else
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
445 if (( strcmp(argv[1], "-help") == 0 ) || (strcmp(argv[1], "-h") == 0)) {
603
2e726be3dc08 From: Jonathan Atkins
Sam Lantinga <slouken@libsdl.org>
parents: 569
diff changeset
446 PrintUsage(argv0);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
447 return(1);
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
448 } else
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 if ( strcmp(argv[1], "-fullscreen") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 video_flags |= SDL_FULLSCREEN;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 break;
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 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 "Couldn't initialize SDL: %s\n", SDL_GetError());
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
459 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 /* Initialize the display */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 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
464 if ( screen == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 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
466 w, h, desired_bpp, SDL_GetError());
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
467 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 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
470 screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 screen->w, screen->h, screen->format->BitsPerPixel);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 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
473 (screen->flags&SDL_HWSURFACE) ? "video" : "system");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 if ( screen->flags & SDL_DOUBLEBUF ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 printf("Double-buffering enabled\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 flip = 1;
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
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 /* Set the window manager title bar */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 SDL_WM_SetCaption("SDL test overlay", "testoverlay");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 /* Load picture */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 bmpfile=(argv[1]?argv[1]:"sample.bmp");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 pic = SDL_LoadBMP(bmpfile);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 if ( pic == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 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
487 SDL_GetError());
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
488 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 }
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 /* 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
492 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 SDL_Surface *newsurf;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 SDL_PixelFormat format;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 format.palette=NULL;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 format.BitsPerPixel=32;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 format.BytesPerPixel=4;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 format.Rshift=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 format.Gshift=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 format.Bshift=16;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 #else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 format.Rshift=24;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 format.Gshift=16;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 format.Bshift=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 format.Ashift=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 format.Rmask=0xff<<format.Rshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 format.Gmask=0xff<<format.Gshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 format.Bmask=0xff<<format.Bshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 format.Amask=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 format.Rloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 format.Gloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 format.Bloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 format.Aloss=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 format.colorkey=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 format.alpha=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 newsurf=SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 if(!newsurf)
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 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
524 SDL_GetError());
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
525 quit(1);
277
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 SDL_FreeSurface(pic);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 pic=newsurf;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 /* Create the overlay */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 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
533 if ( overlay == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
535 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 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
538 overlay->hw_overlay?"hardware":"software",
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 overlay->format==SDL_YV12_OVERLAY?"YV12":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 overlay->format==SDL_IYUV_OVERLAY?"IYUV":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 overlay->format==SDL_YUY2_OVERLAY?"YUY2":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 overlay->format==SDL_UYVY_OVERLAY?"UYVY":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 overlay->format==SDL_YVYU_OVERLAY?"YVYU":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 "Unknown");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 for(i=0; i<overlay->planes; i++)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 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
548 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 /* 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
551 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 then = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 switch(overlay->format)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 case SDL_YV12_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
557 ConvertRGBtoYV12(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 case SDL_UYVY_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
560 ConvertRGBtoUYVY(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 case SDL_YVYU_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
563 ConvertRGBtoYVYU(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 case SDL_YUY2_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
566 ConvertRGBtoYUY2(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 case SDL_IYUV_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
569 ConvertRGBtoIYUV(pic,overlay,monochrome,luminance);
277
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 default:
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 printf("cannot convert RGB picture to obtained YUV format!\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
573 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 break;
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 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 now = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 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
579 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581 /* Do all the drawing work */
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 then = SDL_GetTicks();
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 Draw();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 now = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 printf("Time: %d milliseconds\n", now-then);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 SDL_Delay(delay*1000);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 605
diff changeset
591 SDL_Quit();
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 return(0);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594