annotate test/testoverlay.c @ 1298:e1b8e1b97b67

This library is now available under the LGPL 2.1, the major change of which is allowing linking with a shared object to be considered sufficient for complying with section 6 of the LGPL.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 30 Jan 2006 14:27:56 +0000
parents be9c9c8f6d53
children 4d3bb026cd16
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 int i;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
38
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
39 if (monochrome)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
40 {
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #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
42 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
43 yuv[1] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
44 yuv[2] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
45 #else
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
46 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
47 yuv[1] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
48 yuv[2] = 128;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
49 #endif
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 else
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
52 {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
53 #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
54 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
55 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
56 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
57 #else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
58 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
59 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
60 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
61 #endif
569
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 if (luminance!=100)
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 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
67 if (yuv[0]>255)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
68 yuv[0]=255;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
69 }
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 /* 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
72 /*
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
73 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
74 {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
75 if(yuv[i]<0)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
76 yuv[i]=0;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
77 if(yuv[i]>255)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
78 yuv[i]=255;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
79 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
80 */
277
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
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
83 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
84 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 Uint8 *p,*op[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 SDL_LockYUVOverlay(o);
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 /* Black initialization */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 /*
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 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
95 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
96 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
97 */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 /* Convert */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 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
101 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
102 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
103 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
104 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
105 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
106 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
107 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
108 RGBtoYUV(p, yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 *(op[0]++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 if(x%2==0 && y%2==0)
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 *(op[1]++)=yuv[2];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 *(op[2]++)=yuv[1];
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 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 SDL_UnlockSurface(s);
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
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
123 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
124 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 Uint8 *p,*op[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 SDL_LockYUVOverlay(o);
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 /* Black initialization */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 /*
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 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
135 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
136 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
137 */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 /* Convert */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 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
141 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
142 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
143 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
144 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
145 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
146 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
147 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
148 RGBtoYUV(p,yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 *(op[0]++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 if(x%2==0 && y%2==0)
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 *(op[1]++)=yuv[1];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 *(op[2]++)=yuv[2];
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 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 SDL_UnlockSurface(s);
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
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
163 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
164 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 Uint8 *p,*op;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 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
173 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
174 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
175 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
176 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
177 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
178 RGBtoYUV(p, yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 if(x%2==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 *(op++)=yuv[1];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 *(op++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 *(op++)=yuv[2];
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 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 *(op++)=yuv[0];
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 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 SDL_UnlockSurface(s);
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
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
196 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
197 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 Uint8 *p,*op;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 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
206 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
207 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
208 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
209 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
210 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
211 RGBtoYUV(p,yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 if(x%2==0)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 *(op++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 *(op++)=yuv[2];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 op[1]=yuv[1];
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 else
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 *op=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 op+=2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 }
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 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 SDL_UnlockSurface(s);
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
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
232 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
233 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 int x,y;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 int yuv[3];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 Uint8 *p,*op;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 SDL_LockSurface(s);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 SDL_LockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 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
242 {
605
6399f4e90211 IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents: 603
diff changeset
243 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
244 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
245 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
246 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
247 RGBtoYUV(p,yuv, monochrome, luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 if(x%2==0)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 *(op++)=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 *(op++)=yuv[1];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 op[1]=yuv[2];
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 else
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 *op=yuv[0];
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 op+=2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 }
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 p+=s->format->BytesPerPixel;
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 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 SDL_UnlockYUVOverlay(o);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 SDL_UnlockSurface(s);
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
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 void Draw()
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 SDL_Rect rect;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 int i;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
272 int disp;
277
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 if(!scale)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 rect.w=overlay->w;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 rect.h=overlay->h;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
278 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
279 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 rect.x=i;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 rect.y=i;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 SDL_DisplayYUVOverlay(overlay,&rect);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 else
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=overlay->w/2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
288 rect.h=overlay->h/2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
289 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
290 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
291 disp=rect.y-1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
292 for(i=0; i<disp; i++)
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 {
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
294 rect.w+=2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
295 rect.h+=2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
296 rect.x--;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
297 rect.y--;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 SDL_DisplayYUVOverlay(overlay,&rect);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 }
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 printf("Displayed %d times.\n",i);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
304 static void PrintUsage(char *argv0)
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
305 {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
306 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
307 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
308 fprintf(stderr, " -delay <seconds>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
309 fprintf(stderr, " -width <pixels>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
310 fprintf(stderr, " -height <pixels>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
311 fprintf(stderr, " -bpp <bits>\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
312 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
313 fprintf(stderr, " -hw\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
314 fprintf(stderr, " -flip\n");
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
315 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
316 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
317 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
318 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
319 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
320 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
321 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
322
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 int main(int argc, char **argv)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 {
603
2e726be3dc08 From: Jonathan Atkins
Sam Lantinga <slouken@libsdl.org>
parents: 569
diff changeset
325 char *argv0 = argv[0];
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 int flip;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 int delay;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 int desired_bpp;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 Uint32 video_flags, overlay_format;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 char *bmpfile;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 Uint32 then, now;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 int i;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 /* Set default options and check command-line */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 flip = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 scale=0;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
339 monochrome=0;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
340 luminance=100;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 delay = 1;
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
342 w = WINDOW_WIDTH;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
343 h = WINDOW_HEIGHT;
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 desired_bpp = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 video_flags = 0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 overlay_format = SDL_YV12_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 while ( argc > 1 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 if ( strcmp(argv[1], "-delay") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 delay = atoi(argv[2]);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 "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
357 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 if ( strcmp(argv[1], "-width") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 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
362 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 "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
367 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 if ( strcmp(argv[1], "-height") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 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
372 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 "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
377 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 if ( strcmp(argv[1], "-bpp") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 desired_bpp = atoi(argv[2]);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 "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
388 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 } else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
391 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
392 if ( argv[2] ) {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
393 luminance = atoi(argv[2]);
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
394 argv += 2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
395 argc -= 2;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
396 } else {
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
397 fprintf(stderr,
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
398 "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
399 return(1);
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
400 }
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
401 } else
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 if ( strcmp(argv[1], "-format") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 if ( argv[2] ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 if(!strcmp(argv[2],"YV12"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 overlay_format = SDL_YV12_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 else if(!strcmp(argv[2],"IYUV"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 overlay_format = SDL_IYUV_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 else if(!strcmp(argv[2],"YUY2"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 overlay_format = SDL_YUY2_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 else if(!strcmp(argv[2],"UYVY"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 overlay_format = SDL_UYVY_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 else if(!strcmp(argv[2],"YVYU"))
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 overlay_format = SDL_YVYU_OVERLAY;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 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
417 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 argv += 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 argc -= 2;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 } else {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 "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
424 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 if ( strcmp(argv[1], "-hw") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 video_flags |= SDL_HWSURFACE;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 if ( strcmp(argv[1], "-flip") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 video_flags |= SDL_DOUBLEBUF;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 if ( strcmp(argv[1], "-scale") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 scale = 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 } else
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
442 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
443 monochrome = 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
444 argv += 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
445 argc -= 1;
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
446 } else
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
447 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
448 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
449 return(1);
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
450 } else
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 if ( strcmp(argv[1], "-fullscreen") == 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 video_flags |= SDL_FULLSCREEN;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 argv += 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 argc -= 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 } else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 fprintf(stderr,
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 "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
461 return(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 }
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 /* Initialize the display */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 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
466 if ( screen == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 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
468 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
469 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 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
472 screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 screen->w, screen->h, screen->format->BitsPerPixel);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 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
475 (screen->flags&SDL_HWSURFACE) ? "video" : "system");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 if ( screen->flags & SDL_DOUBLEBUF ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 printf("Double-buffering enabled\n");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 flip = 1;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 /* Set the window manager title bar */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 SDL_WM_SetCaption("SDL test overlay", "testoverlay");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 /* Load picture */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 bmpfile=(argv[1]?argv[1]:"sample.bmp");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 pic = SDL_LoadBMP(bmpfile);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 if ( pic == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 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
489 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
490 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 /* 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
494 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 SDL_Surface *newsurf;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 SDL_PixelFormat format;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 format.palette=NULL;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 format.BitsPerPixel=32;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 format.BytesPerPixel=4;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 format.Rshift=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 format.Gshift=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 format.Bshift=16;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 #else
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 format.Rshift=24;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 format.Gshift=16;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 format.Bshift=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 format.Ashift=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 format.Rmask=0xff<<format.Rshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 format.Gmask=0xff<<format.Gshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 format.Bmask=0xff<<format.Bshift;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 format.Amask=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 format.Rloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 format.Gloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 format.Bloss=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 format.Aloss=8;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 format.colorkey=0;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 format.alpha=0;
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 newsurf=SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 if(!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 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
526 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
527 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 SDL_FreeSurface(pic);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 pic=newsurf;
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
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 /* Create the overlay */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 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
535 if ( overlay == NULL ) {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 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
537 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 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
540 overlay->hw_overlay?"hardware":"software",
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 overlay->format==SDL_YV12_OVERLAY?"YV12":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 overlay->format==SDL_IYUV_OVERLAY?"IYUV":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 overlay->format==SDL_YUY2_OVERLAY?"YUY2":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 overlay->format==SDL_UYVY_OVERLAY?"UYVY":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 overlay->format==SDL_YVYU_OVERLAY?"YVYU":
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 "Unknown");
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 for(i=0; i<overlay->planes; 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 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
550 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 /* 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
553 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 then = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 switch(overlay->format)
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 {
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 case SDL_YV12_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
559 ConvertRGBtoYV12(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 case SDL_UYVY_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
562 ConvertRGBtoUYVY(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 case SDL_YVYU_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
565 ConvertRGBtoYVYU(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 case SDL_YUY2_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
568 ConvertRGBtoYUY2(pic,overlay,monochrome,luminance);
277
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 case SDL_IYUV_OVERLAY:
569
e8063c656626 Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 277
diff changeset
571 ConvertRGBtoIYUV(pic,overlay,monochrome,luminance);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 default:
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 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
575 quit(1);
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 break;
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 now = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 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
581 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583 /* Do all the drawing work */
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 then = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 Draw();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 #ifdef BENCHMARK_SDL
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 now = SDL_GetTicks();
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 printf("Time: %d milliseconds\n", now-then);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 #endif
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 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
593 SDL_Quit();
277
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 return(0);
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595 }
255c7ee077cb Added a YUV overlay test program (thanks Jon!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596