test/testoverlay2.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 08 Aug 2003 21:31:18 +0000
changeset 672 5955fa16d4b8
child 673 63419da96d13
permissions -rw-r--r--
Date: Mon, 28 Jul 2003 18:30:50 +0300 From: "Mike Gorchak" Subject: New test for overlays While writting QNX Photon Overlay code I've found that the existent overlay test application is not enough, it performs too artificial tests - it always moves/resizes the overlay's viewport, but in the real life that happens very rare. So I decided to write new test (commonly base on testoverlay.c code) and called it testoverlay2 :) moose.dat - raw 8 bit paletted data of the small movie. (It was a moose.gif, also included in the attachment as reference, but not needed for this test, it is just for information). I cannot find, who created this .gif, so no credits this time :) But over inet I saw this gif zillion times, so I think we do not infringing somebody rights :)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
void Draw()
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
}
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
static void PrintUsage(char *argv0)
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
    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
   261
    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
   262
    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
   263
    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
   264
    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
   265
    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
   266
    fprintf(stderr, "\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
    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
   268
    fprintf(stderr, "\n");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
}
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
int main(int argc, char **argv)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
{
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
    Uint8* RawMooseData;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
    SDL_RWops* handle;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
    SDL_Surface* screen;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
    SDL_Surface* MooseFrame[MOOSEFRAMES_COUNT];
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
    SDL_Overlay* overlay;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
    SDL_Rect overlayrect;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
    SDL_Event event;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
    Uint32 lastftick;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
    int paused=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
    int i;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
    int fps=12;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
    int fpsdelay;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
    int overlay_format=SDL_YUY2_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
    int scale=5;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
    while ( argc > 1 )
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
        if (strcmp(argv[1], "-fps")== 0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
        {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
            if (argv[2])
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
                fps = atoi(argv[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
                if (fps==0)
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
                    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
   298
                    return -1;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
                }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
                if ((fps<0) || (fps>1000))
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
                    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
   303
                    return -1;
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
                argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
                argc -= 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
            }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
            else
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
                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
   311
                return -1;
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
        } else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
        if (strcmp(argv[1], "-format") == 0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
        {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
            if (argv[2])
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
            {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
                if (!strcmp(argv[2],"YV12"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
                    overlay_format = SDL_YV12_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
                else if(!strcmp(argv[2],"IYUV"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
                    overlay_format = SDL_IYUV_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
                else if(!strcmp(argv[2],"YUY2"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
                    overlay_format = SDL_YUY2_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
                else if(!strcmp(argv[2],"UYVY"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
                    overlay_format = SDL_UYVY_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
                else if(!strcmp(argv[2],"YVYU"))
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
                    overlay_format = SDL_YVYU_OVERLAY;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
                else
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
                    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
   331
                    return -1;
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
                argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
                argc -= 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
            }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
            else
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
                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
   339
                return -1;
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
        } else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
        if (strcmp(argv[1], "-scale") == 0)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
        {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
            if (argv[2])
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
                scale = atoi(argv[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   347
                if (scale==0)
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
                    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
   350
                    return -1;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
                }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   352
                if ((scale<0) || (scale>50))
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
                    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
   355
                    return -1;
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
                argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
                argc -= 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
            }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
            else
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
                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
   363
                return -1;
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
        } else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
        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
   367
        {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
            PrintUsage(argv[0]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
            return 0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
        } else
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
            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
   373
            return -1;
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
        break;
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
   
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
    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
   379
    if (RawMooseData==NULL)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
        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
   382
        free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
        return 1;
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
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
    /* load the trojan moose images */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
    handle=SDL_RWFromFile("moose.dat", "r");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
    if (handle==NULL)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
        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
   391
        free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
        return 2;
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
    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
   396
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
    SDL_RWclose(handle);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
    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
   400
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
        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
   402
        free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   403
        return 3;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   404
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
    atexit(SDL_Quit);
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
    /* Set 640x480 video mode */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
    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
   409
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
        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
   411
        free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
        return 4;
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
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
    /* Set the window manager title bar */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   416
    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
   417
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   418
    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
   419
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   420
        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
   421
                                               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
   422
        if (MooseFrame[i]==NULL)
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
            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
   425
            free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   426
            return 5;
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_SetColors(MooseFrame[i], MooseColors, 0, 84);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
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
		SDL_Surface *newsurf;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   432
		SDL_PixelFormat format;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   433
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   434
		format.palette=NULL;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   435
		format.BitsPerPixel=32;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   436
		format.BytesPerPixel=4;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   437
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   438
		format.Rshift=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   439
		format.Gshift=8;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   440
		format.Bshift=16;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   441
#else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   442
		format.Rshift=24;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   443
		format.Gshift=16;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   444
		format.Bshift=8;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   445
#endif
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   446
		format.Ashift=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   447
		format.Rmask=0xff<<format.Rshift;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   448
		format.Gmask=0xff<<format.Gshift;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   449
		format.Bmask=0xff<<format.Bshift;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
		format.Amask=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
		format.Rloss=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
		format.Gloss=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   453
		format.Bloss=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   454
		format.Aloss=8;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   455
		format.colorkey=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   456
		format.alpha=0;
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
		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
   459
		if(!newsurf)
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
                    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
   462
                    return 6;
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
		SDL_FreeSurface(MooseFrame[i]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   465
		MooseFrame[i]=newsurf;
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
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   468
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   469
    free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   470
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   471
    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
   472
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   473
    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
   474
           overlay->hw_overlay?"hardware":"software",
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   475
           overlay->format==SDL_YV12_OVERLAY?"YV12":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   476
           overlay->format==SDL_IYUV_OVERLAY?"IYUV":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   477
           overlay->format==SDL_YUY2_OVERLAY?"YUY2":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   478
           overlay->format==SDL_UYVY_OVERLAY?"UYVY":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   479
           overlay->format==SDL_YVYU_OVERLAY?"YVYU":
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
           "Unknown");
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   481
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   482
    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
   483
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   484
        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
   485
    }
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
    overlayrect.x=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   488
    overlayrect.y=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   489
    overlayrect.w=MOOSEPIC_W*scale;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   490
    overlayrect.h=MOOSEPIC_H*scale;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   491
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   492
    /* set the start frame */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   493
    i=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   494
    fpsdelay=1000/fps;
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
    /* 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
   497
    SDL_EventState(SDL_KEYUP, SDL_IGNORE);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   498
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   499
    lastftick=SDL_GetTicks();
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
    /* Loop, waiting for QUIT or RESIZE */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   502
    while (1)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   503
    {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   504
        if (SDL_PollEvent(&event))
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
            switch (event.type)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   507
            {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
                case SDL_VIDEORESIZE:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
                     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
   510
                     overlayrect.w=event.resize.w;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   511
                     overlayrect.h=event.resize.h;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   512
                     break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   513
                case SDL_KEYDOWN:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   514
                     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
   515
                     {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   516
                         paused=!paused;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   517
                         break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   518
                     }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   519
                     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
   520
                     {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   521
                         break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   522
                     }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   523
                case SDL_QUIT:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   524
                     SDL_FreeYUVOverlay(overlay);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   525
                     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
   526
                     {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   527
                         SDL_FreeSurface(MooseFrame[i]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   528
                     }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   529
                     return 0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   530
            }
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
        if (!paused)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   534
        {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   535
            if ((SDL_GetTicks()-lastftick)>fpsdelay)
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
                lastftick=SDL_GetTicks();
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
                switch (overlay_format)
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_YUY2_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   542
                         ConvertRGBtoYUY2(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   543
                         break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   544
                    case SDL_YV12_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   545
                         ConvertRGBtoYV12(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   546
                         break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   547
                    case SDL_UYVY_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   548
                         ConvertRGBtoUYVY(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   549
                         break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   550
                    case SDL_YVYU_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   551
                         ConvertRGBtoYVYU(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   552
                         break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   553
                    case SDL_IYUV_OVERLAY:
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   554
                         ConvertRGBtoIYUV(MooseFrame[i], overlay, 0, 100);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   555
                         break;
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
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   558
                SDL_DisplayYUVOverlay(overlay, &overlayrect);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   559
                i++;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   560
                if (i==10)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   561
                {
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   562
                    i=0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   563
                }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   564
            }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   565
        }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   566
        /* kind of timeslice to OS */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   567
        SDL_Delay(1);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   568
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   569
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   570
    return 0;
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