Mercurial > sdl-ios-xcode
annotate test/testoverlay2.c @ 815:6176f9a0d61a
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 13 Feb 2004 06:42:17 +0000 |
parents | b14fdadd8311 |
children | 05c551e5bc64 |
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 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #include "SDL.h" |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 #define MOOSEPIC_W 64 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 #define MOOSEPIC_H 88 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 #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
|
14 #define MOOSEFRAMES_COUNT 10 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 SDL_Color MooseColors[84]={ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 { 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
|
18 { 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
|
19 { 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
|
20 { 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
|
21 { 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
|
22 {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
|
23 {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
|
24 {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
|
25 {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
|
26 {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
|
27 {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
|
28 {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
|
29 {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
|
30 {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
|
31 {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
|
32 {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
|
33 {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
|
34 {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
|
35 {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
|
36 {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
|
37 {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
|
38 }; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 /* 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
|
41 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 /* 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
|
43 only as examples. |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 */ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 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
|
47 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 int i; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 if (monochrome) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 #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
|
53 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
|
54 yuv[1] = 128; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 yuv[2] = 128; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 #else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 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
|
58 yuv[1] = 128; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 yuv[2] = 128; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 #endif |
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 else |
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] = (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
|
67 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
|
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 - (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
|
71 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
|
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 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 if (luminance!=100) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 yuv[0]=yuv[0]*luminance/100; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 if (yuv[0]>255) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 yuv[0]=255; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 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
|
84 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 int x,y; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 int yuv[3]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 Uint8 *p,*op[3]; |
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 SDL_LockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 SDL_LockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 /* Convert */ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 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
|
94 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 RGBtoYUV(p, yuv, monochrome, luminance); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 *(op[0]++)=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 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
|
104 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 *(op[1]++)=yuv[2]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 *(op[2]++)=yuv[1]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 p+=s->format->BytesPerPixel; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 SDL_UnlockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 SDL_UnlockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 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
|
117 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 int x,y; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 int yuv[3]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 Uint8 *p,*op[3]; |
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 SDL_LockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 SDL_LockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 /* Convert */ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 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
|
127 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 RGBtoYUV(p,yuv, monochrome, luminance); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 *(op[0]++)=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 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
|
137 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 *(op[1]++)=yuv[1]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 *(op[2]++)=yuv[2]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 p+=s->format->BytesPerPixel; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 SDL_UnlockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 SDL_UnlockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 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
|
150 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 int x,y; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 int yuv[3]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 Uint8 *p,*op; |
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 SDL_LockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 SDL_LockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 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
|
159 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 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
|
161 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
|
162 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
|
163 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 RGBtoYUV(p, yuv, monochrome, luminance); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 if(x%2==0) |
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 *(op++)=yuv[1]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 *(op++)=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 *(op++)=yuv[2]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 *(op++)=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 p+=s->format->BytesPerPixel; |
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 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 SDL_UnlockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 SDL_UnlockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 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
|
183 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 int x,y; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 int yuv[3]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 Uint8 *p,*op; |
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 SDL_LockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 SDL_LockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 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
|
192 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 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
|
194 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
|
195 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
|
196 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 RGBtoYUV(p,yuv, monochrome, luminance); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 if(x%2==0) |
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 *(op++)=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 *(op++)=yuv[2]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 op[1]=yuv[1]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 *op=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 op+=2; |
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 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 p+=s->format->BytesPerPixel; |
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 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 SDL_UnlockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 SDL_UnlockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 } |
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 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
|
219 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 int x,y; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 int yuv[3]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 Uint8 *p,*op; |
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 SDL_LockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 SDL_LockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 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
|
228 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 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
|
230 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
|
231 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
|
232 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 RGBtoYUV(p,yuv, monochrome, luminance); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 if(x%2==0) |
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 *(op++)=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 *(op++)=yuv[1]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 op[1]=yuv[2]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 *op=yuv[0]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 op+=2; |
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 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 p+=s->format->BytesPerPixel; |
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 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 SDL_UnlockYUVOverlay(o); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 SDL_UnlockSurface(s); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 } |
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 static void PrintUsage(char *argv0) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 fprintf(stderr, "Where 'arg' is one of:\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 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
|
259 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
|
260 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
|
261 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
|
262 fprintf(stderr, "\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 fprintf(stderr, " Press ESC to exit, or SPACE to freeze the movie while application running.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 fprintf(stderr, "\n"); |
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 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 int main(int argc, char **argv) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 Uint8* RawMooseData; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 SDL_RWops* handle; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 SDL_Surface* screen; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 SDL_Surface* MooseFrame[MOOSEFRAMES_COUNT]; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 SDL_Overlay* overlay; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 SDL_Rect overlayrect; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 SDL_Event event; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 Uint32 lastftick; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 int paused=0; |
753
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
278 int resized=0; |
672
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 int i; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 int fps=12; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 int fpsdelay; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 int overlay_format=SDL_YUY2_OVERLAY; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 int scale=5; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 while ( argc > 1 ) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 if (strcmp(argv[1], "-fps")== 0) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 if (argv[2]) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 fps = atoi(argv[2]); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 if (fps==0) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 if ((fps<0) || (fps>1000)) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 fprintf(stderr, "The -fps option must be in range from 1 to 1000, default is 12.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 argv += 2; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 argc -= 2; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 else |
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 fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 } else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 if (strcmp(argv[1], "-format") == 0) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 if (argv[2]) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 if (!strcmp(argv[2],"YV12")) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 overlay_format = SDL_YV12_OVERLAY; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 else if(!strcmp(argv[2],"IYUV")) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 overlay_format = SDL_IYUV_OVERLAY; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 else if(!strcmp(argv[2],"YUY2")) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 overlay_format = SDL_YUY2_OVERLAY; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 else if(!strcmp(argv[2],"UYVY")) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 overlay_format = SDL_UYVY_OVERLAY; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 else if(!strcmp(argv[2],"YVYU")) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 overlay_format = SDL_YVYU_OVERLAY; |
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 -format option %s is not recognized, see help for info.\n", argv[2]); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 return -1; |
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 argv += 2; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 argc -= 2; |
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 else |
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 fprintf(stderr, "The -format option requires an argument, default is YUY2.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 } else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 if (strcmp(argv[1], "-scale") == 0) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 if (argv[2]) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 scale = atoi(argv[2]); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 if (scale==0) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 fprintf(stderr, "The -scale option requires an argument [from 1 to 50], default is 5.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 if ((scale<0) || (scale>50)) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 fprintf(stderr, "The -scale option must be in range from 1 to 50, default is 5.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 argv += 2; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 argc -= 2; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 } else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 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
|
364 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 PrintUsage(argv[0]); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 return 0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 } else |
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 fprintf(stderr, "Unrecognized option: %s.\n", argv[1]); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 return -1; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 break; |
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 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 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
|
376 if (RawMooseData==NULL) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 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
|
379 free(RawMooseData); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 return 1; |
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 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 /* load the trojan moose images */ |
673
63419da96d13
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
672
diff
changeset
|
384 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
|
385 if (handle==NULL) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 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
|
388 free(RawMooseData); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 return 2; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 } |
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 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
|
393 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 SDL_RWclose(handle); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) |
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, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 free(RawMooseData); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 return 3; |
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 atexit(SDL_Quit); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 |
673
63419da96d13
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
672
diff
changeset
|
404 /* Set video mode */ |
672
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 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
|
406 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 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
|
408 free(RawMooseData); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 return 4; |
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 /* Set the window manager title bar */ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 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
|
414 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 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
|
416 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 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
|
418 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
|
419 if (MooseFrame[i]==NULL) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 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
|
422 free(RawMooseData); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 return 5; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 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
|
426 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 SDL_Surface *newsurf; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 SDL_PixelFormat format; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 format.palette=NULL; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 format.BitsPerPixel=32; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 format.BytesPerPixel=4; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 format.Rshift=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 format.Gshift=8; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 format.Bshift=16; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 #else |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 format.Rshift=24; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 format.Gshift=16; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 format.Bshift=8; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 #endif |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 format.Ashift=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 format.Rmask=0xff<<format.Rshift; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 format.Gmask=0xff<<format.Gshift; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 format.Bmask=0xff<<format.Bshift; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 format.Amask=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 format.Rloss=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 format.Gloss=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 format.Bloss=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 format.Aloss=8; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 format.colorkey=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 format.alpha=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 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
|
456 if(!newsurf) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n", SDL_GetError()); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 return 6; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 SDL_FreeSurface(MooseFrame[i]); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 MooseFrame[i]=newsurf; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 free(RawMooseData); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 overlay=SDL_CreateYUVOverlay(MOOSEPIC_W, MOOSEPIC_H, overlay_format, screen); |
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 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
|
471 overlay->hw_overlay?"hardware":"software", |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 overlay->format==SDL_YV12_OVERLAY?"YV12": |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 overlay->format==SDL_IYUV_OVERLAY?"IYUV": |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 overlay->format==SDL_YUY2_OVERLAY?"YUY2": |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 overlay->format==SDL_UYVY_OVERLAY?"UYVY": |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 overlay->format==SDL_YVYU_OVERLAY?"YVYU": |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 "Unknown"); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 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
|
480 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 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
|
482 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 overlayrect.x=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 overlayrect.y=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 overlayrect.w=MOOSEPIC_W*scale; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 overlayrect.h=MOOSEPIC_H*scale; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 /* set the start frame */ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 i=0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 fpsdelay=1000/fps; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 /* 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
|
494 SDL_EventState(SDL_KEYUP, SDL_IGNORE); |
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 lastftick=SDL_GetTicks(); |
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 /* Loop, waiting for QUIT or RESIZE */ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 while (1) |
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 if (SDL_PollEvent(&event)) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 switch (event.type) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 case SDL_VIDEORESIZE: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 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
|
507 overlayrect.w=event.resize.w; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 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
|
509 if (paused) |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
510 { |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
511 resized=1; |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
512 } |
672
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 break; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 case SDL_KEYDOWN: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 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
|
516 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 paused=!paused; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 break; |
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 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
|
521 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 break; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 case SDL_QUIT: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 SDL_FreeYUVOverlay(overlay); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 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
|
527 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 SDL_FreeSurface(MooseFrame[i]); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 return 0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 |
753
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
534 if ((!paused)||(resized)) |
672
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 { |
753
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
536 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
|
537 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 lastftick=SDL_GetTicks(); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 switch (overlay_format) |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 { |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 case SDL_YUY2_OVERLAY: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 ConvertRGBtoYUY2(MooseFrame[i], overlay, 0, 100); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 break; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 case SDL_YV12_OVERLAY: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 ConvertRGBtoYV12(MooseFrame[i], overlay, 0, 100); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 break; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 case SDL_UYVY_OVERLAY: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 ConvertRGBtoUYVY(MooseFrame[i], overlay, 0, 100); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 break; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 case SDL_YVYU_OVERLAY: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 ConvertRGBtoYVYU(MooseFrame[i], overlay, 0, 100); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 break; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 case SDL_IYUV_OVERLAY: |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 ConvertRGBtoIYUV(MooseFrame[i], overlay, 0, 100); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
556 break; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 } |
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 SDL_DisplayYUVOverlay(overlay, &overlayrect); |
753
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
560 if (!resized) |
672
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 { |
753
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
562 i++; |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
563 if (i==10) |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
564 { |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
565 i=0; |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
566 } |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
567 } |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
568 else |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
569 { |
b14fdadd8311
Date: Thu, 4 Dec 2003 07:48:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
673
diff
changeset
|
570 resized=0; |
672
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 /* kind of timeslice to OS */ |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 SDL_Delay(1); |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 return 0; |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 } |
5955fa16d4b8
Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 |