Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
562 lines (510 loc) · 15.9 KB

testoverlay.c

File metadata and controls

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