annotate test/testoverlay2.c @ 1306:0c105755b110

Changed references to XFree86 to Xext to match change in directory structure. Reference Bugzilla #116.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 31 Jan 2006 18:39:32 +0000
parents be9c9c8f6d53
children 4d3bb026cd16
rev   line source
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /********************************************************************************
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 * *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 * Test of the overlay used for moved pictures, test more closed to real life. *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 * Running trojan moose :) Coded by Mike Gorchak. *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 * *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 ********************************************************************************/
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7
1030
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
8 #include <stdlib.h>
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
9 #include <stdio.h>
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
10 #include <string.h>
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
11
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 #include "SDL.h"
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 #define MOOSEPIC_W 64
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 #define MOOSEPIC_H 88
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 #define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 #define MOOSEFRAMES_COUNT 10
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 SDL_Color MooseColors[84]={
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 { 49, 49, 49}, { 66, 24, 0}, { 66, 33, 0}, { 66, 66, 66},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 { 66, 115, 49}, { 74, 33, 0}, { 74, 41, 16}, { 82, 33, 8},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 { 82, 41, 8}, { 82, 49, 16}, { 82, 82, 82}, { 90, 41, 8},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 { 90, 41, 16}, { 90, 57, 24}, { 99, 49, 16}, { 99, 66, 24},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 { 99, 66, 33}, { 99, 74, 33}, {107, 57, 24}, {107, 82, 41},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 {115, 57, 33}, {115, 66, 33}, {115, 66, 41}, {115, 74, 0},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 {115, 90, 49}, {115, 115, 115}, {123, 82, 0}, {123, 99, 57},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 {132, 66, 41}, {132, 74, 41}, {132, 90, 8}, {132, 99, 33},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 {132, 99, 66}, {132, 107, 66}, {140, 74, 49}, {140, 99, 16},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 {140, 107, 74}, {140, 115, 74}, {148, 107, 24}, {148, 115, 82},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 {148, 123, 74}, {148, 123, 90}, {156, 115, 33}, {156, 115, 90},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 {156, 123, 82}, {156, 132, 82}, {156, 132, 99}, {156, 156, 156},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 {165, 123, 49}, {165, 123, 90}, {165, 132, 82}, {165, 132, 90},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 {165, 132, 99}, {165, 140, 90}, {173, 132, 57}, {173, 132, 99},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 {173, 140, 107}, {173, 140, 115}, {173, 148, 99}, {173, 173, 173},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 {181, 140, 74}, {181, 148, 115}, {181, 148, 123}, {181, 156, 107},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 {189, 148, 123}, {189, 156, 82}, {189, 156, 123}, {189, 156, 132},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 {189, 189, 189}, {198, 156, 123}, {198, 165, 132}, {206, 165, 99},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 {206, 165, 132}, {206, 173, 140}, {206, 206, 206}, {214, 173, 115},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 {214, 173, 140}, {222, 181, 148}, {222, 189, 132}, {222, 189, 156},
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 {222, 222, 222}, {231, 198, 165}, {231, 231, 231}, {239, 206, 173}
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 };
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
44
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
45 /* 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: 1030
diff changeset
46 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: 1030
diff changeset
47 {
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
48 SDL_Quit();
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
49 exit(rc);
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
50 }
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
51
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 /* All RGB2YUV conversion code and some other parts of code has been taken from testoverlay.c */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 /* NOTE: These RGB conversion functions are not intended for speed,
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 only as examples.
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 int i;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 if (monochrome)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 #if 1 /* these are the two formulas that I found on the FourCC site... */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 yuv[1] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 yuv[2] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 #else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 yuv[1] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 yuv[2] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 #endif
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 #if 1 /* these are the two formulas that I found on the FourCC site... */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 yuv[1] = (rgb[2]-yuv[0])*0.565 + 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 yuv[2] = (rgb[0]-yuv[0])*0.713 + 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 #else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 #endif
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 if (luminance!=100)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 yuv[0]=yuv[0]*luminance/100;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 if (yuv[0]>255)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 yuv[0]=255;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 ConvertRGBtoYV12(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 int x,y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 int yuv[3];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 Uint8 *p,*op[3];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 SDL_LockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 SDL_LockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 /* Convert */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 for(y=0; y<s->h && y<o->h; y++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 p=((Uint8 *) s->pixels)+s->pitch*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 op[0]=o->pixels[0]+o->pitches[0]*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 op[1]=o->pixels[1]+o->pitches[1]*(y/2);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 op[2]=o->pixels[2]+o->pitches[2]*(y/2);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 for(x=0; x<s->w && x<o->w; x++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 RGBtoYUV(p, yuv, monochrome, luminance);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 *(op[0]++)=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 if(x%2==0 && y%2==0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 *(op[1]++)=yuv[2];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 *(op[2]++)=yuv[1];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 p+=s->format->BytesPerPixel;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 SDL_UnlockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 SDL_UnlockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 ConvertRGBtoIYUV(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 int x,y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 int yuv[3];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 Uint8 *p,*op[3];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 SDL_LockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 SDL_LockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 /* Convert */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 for(y=0; y<s->h && y<o->h; y++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 p=((Uint8 *) s->pixels)+s->pitch*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 op[0]=o->pixels[0]+o->pitches[0]*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 op[1]=o->pixels[1]+o->pitches[1]*(y/2);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 op[2]=o->pixels[2]+o->pitches[2]*(y/2);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 for(x=0; x<s->w && x<o->w; x++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 RGBtoYUV(p,yuv, monochrome, luminance);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 *(op[0]++)=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 if(x%2==0 && y%2==0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 *(op[1]++)=yuv[1];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 *(op[2]++)=yuv[2];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 p+=s->format->BytesPerPixel;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 SDL_UnlockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 SDL_UnlockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 ConvertRGBtoUYVY(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 int x,y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 int yuv[3];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 Uint8 *p,*op;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 SDL_LockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 SDL_LockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 for(y=0; y<s->h && y<o->h; y++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 p=((Uint8 *) s->pixels)+s->pitch*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 op=o->pixels[0]+o->pitches[0]*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 for(x=0; x<s->w && x<o->w; x++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 RGBtoYUV(p, yuv, monochrome, luminance);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 if(x%2==0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 *(op++)=yuv[1];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 *(op++)=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 *(op++)=yuv[2];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 *(op++)=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 p+=s->format->BytesPerPixel;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 SDL_UnlockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 SDL_UnlockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 ConvertRGBtoYVYU(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 int x,y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 int yuv[3];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 Uint8 *p,*op;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 SDL_LockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 SDL_LockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 for(y=0; y<s->h && y<o->h; y++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 p=((Uint8 *) s->pixels)+s->pitch*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 op=o->pixels[0]+o->pitches[0]*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 for(x=0; x<s->w && x<o->w; x++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 RGBtoYUV(p,yuv, monochrome, luminance);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 if(x%2==0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 *(op++)=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 *(op++)=yuv[2];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 op[1]=yuv[1];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 *op=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 op+=2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 p+=s->format->BytesPerPixel;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 SDL_UnlockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 SDL_UnlockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 int x,y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 int yuv[3];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 Uint8 *p,*op;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 SDL_LockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 SDL_LockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 for(y=0; y<s->h && y<o->h; y++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 p=((Uint8 *) s->pixels)+s->pitch*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 op=o->pixels[0]+o->pitches[0]*y;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 for(x=0; x<s->w && x<o->w; x++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 RGBtoYUV(p,yuv, monochrome, luminance);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if(x%2==0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 *(op++)=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 *(op++)=yuv[1];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 op[1]=yuv[2];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 *op=yuv[0];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 op+=2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 p+=s->format->BytesPerPixel;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 SDL_UnlockYUVOverlay(o);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 SDL_UnlockSurface(s);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 static void PrintUsage(char *argv0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
886
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
269 fprintf(stderr, "\n");
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
270 fprintf(stderr, "Where 'arg' is any of the following options:\n");
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
271 fprintf(stderr, "\n");
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 fprintf(stderr, " -fps <frames per second>\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 fprintf(stderr, " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 fprintf(stderr, " -scale <scale factor> (initial scale of the overlay)\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 fprintf(stderr, " -help (shows this help)\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 fprintf(stderr, "\n");
886
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
277 fprintf(stderr, "Press ESC to exit, or SPACE to freeze the movie while application running.\n");
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 fprintf(stderr, "\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 int main(int argc, char **argv)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 Uint8* RawMooseData;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 SDL_RWops* handle;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 SDL_Surface* screen;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 SDL_Surface* MooseFrame[MOOSEFRAMES_COUNT];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 SDL_Overlay* overlay;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 SDL_Rect overlayrect;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 SDL_Event event;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 Uint32 lastftick;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 int paused=0;
753
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
292 int resized=0;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 int i;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 int fps=12;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 int fpsdelay;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 int overlay_format=SDL_YUY2_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 int scale=5;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
299 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
300 {
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
301 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
302 return 3;
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
303 }
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
304
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 while ( argc > 1 )
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 if (strcmp(argv[1], "-fps")== 0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 if (argv[2])
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 fps = atoi(argv[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 if (fps==0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
315 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 if ((fps<0) || (fps>1000))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 fprintf(stderr, "The -fps option must be in range from 1 to 1000, default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
320 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 argc -= 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
328 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 } else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 if (strcmp(argv[1], "-format") == 0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 if (argv[2])
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 if (!strcmp(argv[2],"YV12"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 overlay_format = SDL_YV12_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 else if(!strcmp(argv[2],"IYUV"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 overlay_format = SDL_IYUV_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 else if(!strcmp(argv[2],"YUY2"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 overlay_format = SDL_YUY2_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 else if(!strcmp(argv[2],"UYVY"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 overlay_format = SDL_UYVY_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 else if(!strcmp(argv[2],"YVYU"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 overlay_format = SDL_YVYU_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 fprintf(stderr, "The -format option %s is not recognized, see help for info.\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: 1030
diff changeset
348 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 argc -= 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 fprintf(stderr, "The -format option requires an argument, default is YUY2.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
356 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 } else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 if (strcmp(argv[1], "-scale") == 0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 if (argv[2])
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 scale = atoi(argv[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 if (scale==0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 fprintf(stderr, "The -scale option requires an argument [from 1 to 50], default is 5.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
367 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 if ((scale<0) || (scale>50))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 fprintf(stderr, "The -scale option must be in range from 1 to 50, default is 5.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
372 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 argc -= 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
380 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 } else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 if ((strcmp(argv[1], "-help") == 0 ) || (strcmp(argv[1], "-h") == 0))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 PrintUsage(argv[0]);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
386 quit(0);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 } else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 fprintf(stderr, "Unrecognized option: %s.\n", argv[1]);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
390 quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 RawMooseData=(Uint8*)malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 if (RawMooseData==NULL)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 fprintf(stderr, "Can't allocate memory for movie !\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 free(RawMooseData);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
400 quit(1);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 /* load the trojan moose images */
673
63419da96d13 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 672
diff changeset
404 handle=SDL_RWFromFile("moose.dat", "rb");
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 if (handle==NULL)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 fprintf(stderr, "Can't find the file moose.dat !\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 free(RawMooseData);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
409 quit(2);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 SDL_RWclose(handle);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415
673
63419da96d13 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 672
diff changeset
416 /* Set video mode */
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 if ( (screen=SDL_SetVideoMode(MOOSEPIC_W*scale, MOOSEPIC_H*scale, 0, SDL_RESIZABLE | SDL_SWSURFACE)) == NULL )
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 fprintf(stderr, "Couldn't set video mode: %s\n", 0, SDL_GetError());
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 free(RawMooseData);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
421 quit(4);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 /* Set the window manager title bar */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 SDL_WM_SetCaption("SDL test overlay: running moose", "testoverlay2");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 for (i=0; i<MOOSEFRAMES_COUNT; i++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 MooseFrame[i]=SDL_CreateRGBSurfaceFrom(RawMooseData+i*MOOSEFRAME_SIZE, MOOSEPIC_W,
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 MOOSEPIC_H, 8, MOOSEPIC_W, 0, 0, 0, 0);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 if (MooseFrame[i]==NULL)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 fprintf(stderr, "Couldn't create SDL_Surfaces:%s\n", 0, SDL_GetError());
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 free(RawMooseData);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
435 quit(5);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 SDL_SetColors(MooseFrame[i], MooseColors, 0, 84);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 SDL_Surface *newsurf;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 SDL_PixelFormat format;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 format.palette=NULL;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 format.BitsPerPixel=32;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 format.BytesPerPixel=4;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 format.Rshift=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 format.Gshift=8;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 format.Bshift=16;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 #else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 format.Rshift=24;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 format.Gshift=16;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 format.Bshift=8;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 #endif
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 format.Ashift=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 format.Rmask=0xff<<format.Rshift;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 format.Gmask=0xff<<format.Gshift;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 format.Bmask=0xff<<format.Bshift;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 format.Amask=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 format.Rloss=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 format.Gloss=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 format.Bloss=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 format.Aloss=8;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 format.colorkey=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 format.alpha=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 newsurf=SDL_ConvertSurface(MooseFrame[i], &format, SDL_SWSURFACE);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 if(!newsurf)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 fprintf(stderr, "Couldn't convert picture to 32bits RGB: %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: 1030
diff changeset
471 quit(6);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 SDL_FreeSurface(MooseFrame[i]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 MooseFrame[i]=newsurf;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 overlay=SDL_CreateYUVOverlay(MOOSEPIC_W, MOOSEPIC_H, overlay_format, screen);
886
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
481 if (!overlay)
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
482 {
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
483 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: 1030
diff changeset
484 quit(7);
886
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
485 }
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 printf("Created %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes,
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 overlay->hw_overlay?"hardware":"software",
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 overlay->format==SDL_YV12_OVERLAY?"YV12":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 overlay->format==SDL_IYUV_OVERLAY?"IYUV":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 overlay->format==SDL_YUY2_OVERLAY?"YUY2":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 overlay->format==SDL_UYVY_OVERLAY?"UYVY":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 overlay->format==SDL_YVYU_OVERLAY?"YVYU":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 "Unknown");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 for(i=0; i<overlay->planes; i++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 printf(" plane %d: pitch=%d\n", i, overlay->pitches[i]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 overlayrect.x=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 overlayrect.y=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 overlayrect.w=MOOSEPIC_W*scale;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 overlayrect.h=MOOSEPIC_H*scale;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 /* set the start frame */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 i=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 fpsdelay=1000/fps;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 /* Ignore key up events, they don't even get filtered */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 SDL_EventState(SDL_KEYUP, SDL_IGNORE);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 lastftick=SDL_GetTicks();
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 /* Loop, waiting for QUIT or RESIZE */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 while (1)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 if (SDL_PollEvent(&event))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 switch (event.type)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 case SDL_VIDEORESIZE:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 screen=SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_RESIZABLE | SDL_SWSURFACE);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 overlayrect.w=event.resize.w;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 overlayrect.h=event.resize.h;
753
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
526 if (paused)
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
527 {
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
528 resized=1;
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
529 }
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 case SDL_KEYDOWN:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 if (event.key.keysym.sym == SDLK_SPACE)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 paused=!paused;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 if (event.key.keysym.sym != SDLK_ESCAPE)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 case SDL_QUIT:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 SDL_FreeYUVOverlay(overlay);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 for (i=0; i<MOOSEFRAMES_COUNT; i++)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 SDL_FreeSurface(MooseFrame[i]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 }
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
547 quit(0);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550
753
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
551 if ((!paused)||(resized))
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 {
753
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
553 if (((SDL_GetTicks()-lastftick)>fpsdelay)||(resized))
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 lastftick=SDL_GetTicks();
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 switch (overlay_format)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 case SDL_YUY2_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 ConvertRGBtoYUY2(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 case SDL_YV12_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 ConvertRGBtoYV12(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 case SDL_UYVY_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 ConvertRGBtoUYVY(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 case SDL_YVYU_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 ConvertRGBtoYVYU(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 case SDL_IYUV_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 ConvertRGBtoIYUV(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 SDL_DisplayYUVOverlay(overlay, &overlayrect);
753
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
577 if (!resized)
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 {
753
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
579 i++;
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
580 if (i==10)
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
581 {
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
582 i=0;
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
583 }
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
584 }
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
585 else
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
586 {
b14fdadd8311 Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 673
diff changeset
587 resized=0;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 /* kind of timeslice to OS */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 SDL_Delay(1);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
595 SDL_Quit();
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 return 0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598