test/testoverlay2.c
changeset 7504 5a45a9536a65
parent 7478 0d02f6a323f5
child 7517 965d57022c01
     1.1 --- a/test/testoverlay2.c	Tue Jul 23 12:44:14 2013 -0700
     1.2 +++ b/test/testoverlay2.c	Tue Jul 23 12:46:22 2013 -0700
     1.3 @@ -16,15 +16,6 @@
     1.4   *                                                                              *
     1.5   ********************************************************************************/
     1.6  
     1.7 -#if 1 /* FIXME: Rework this using the 2.0 API */
     1.8 -#include <stdio.h>
     1.9 -
    1.10 -int main(int argc, char *argv[])
    1.11 -{
    1.12 -    printf("FIXME\n");
    1.13 -    return 0;
    1.14 -}
    1.15 -#else
    1.16  #include <stdlib.h>
    1.17  #include <stdio.h>
    1.18  #include <string.h>
    1.19 @@ -215,135 +206,6 @@
    1.20      }
    1.21  }
    1.22  
    1.23 -void
    1.24 -ConvertRGBtoIYUV(SDL_Surface * s, SDL_Overlay * o, int monochrome,
    1.25 -                 int luminance)
    1.26 -{
    1.27 -    int x, y;
    1.28 -    int yuv[3];
    1.29 -    Uint8 *p, *op[3];
    1.30 -
    1.31 -    SDL_LockSurface(s);
    1.32 -    SDL_LockYUVOverlay(o);
    1.33 -
    1.34 -    /* Convert */
    1.35 -    for (y = 0; y < s->h && y < o->h; y++) {
    1.36 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
    1.37 -        op[0] = o->pixels[0] + o->pitches[0] * y;
    1.38 -        op[1] = o->pixels[1] + o->pitches[1] * (y / 2);
    1.39 -        op[2] = o->pixels[2] + o->pitches[2] * (y / 2);
    1.40 -        for (x = 0; x < s->w && x < o->w; x++) {
    1.41 -            RGBtoYUV(p, yuv, monochrome, luminance);
    1.42 -            *(op[0]++) = yuv[0];
    1.43 -            if (x % 2 == 0 && y % 2 == 0) {
    1.44 -                *(op[1]++) = yuv[1];
    1.45 -                *(op[2]++) = yuv[2];
    1.46 -            }
    1.47 -            p += s->format->BytesPerPixel;
    1.48 -        }
    1.49 -    }
    1.50 -
    1.51 -    SDL_UnlockYUVOverlay(o);
    1.52 -    SDL_UnlockSurface(s);
    1.53 -}
    1.54 -
    1.55 -void
    1.56 -ConvertRGBtoUYVY(SDL_Surface * s, SDL_Overlay * o, int monochrome,
    1.57 -                 int luminance)
    1.58 -{
    1.59 -    int x, y;
    1.60 -    int yuv[3];
    1.61 -    Uint8 *p, *op;
    1.62 -
    1.63 -    SDL_LockSurface(s);
    1.64 -    SDL_LockYUVOverlay(o);
    1.65 -
    1.66 -    for (y = 0; y < s->h && y < o->h; y++) {
    1.67 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
    1.68 -        op = o->pixels[0] + o->pitches[0] * y;
    1.69 -        for (x = 0; x < s->w && x < o->w; x++) {
    1.70 -            RGBtoYUV(p, yuv, monochrome, luminance);
    1.71 -            if (x % 2 == 0) {
    1.72 -                *(op++) = yuv[1];
    1.73 -                *(op++) = yuv[0];
    1.74 -                *(op++) = yuv[2];
    1.75 -            } else
    1.76 -                *(op++) = yuv[0];
    1.77 -
    1.78 -            p += s->format->BytesPerPixel;
    1.79 -        }
    1.80 -    }
    1.81 -
    1.82 -    SDL_UnlockYUVOverlay(o);
    1.83 -    SDL_UnlockSurface(s);
    1.84 -}
    1.85 -
    1.86 -void
    1.87 -ConvertRGBtoYVYU(SDL_Surface * s, SDL_Overlay * o, int monochrome,
    1.88 -                 int luminance)
    1.89 -{
    1.90 -    int x, y;
    1.91 -    int yuv[3];
    1.92 -    Uint8 *p, *op;
    1.93 -
    1.94 -    SDL_LockSurface(s);
    1.95 -    SDL_LockYUVOverlay(o);
    1.96 -
    1.97 -    for (y = 0; y < s->h && y < o->h; y++) {
    1.98 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
    1.99 -        op = o->pixels[0] + o->pitches[0] * y;
   1.100 -        for (x = 0; x < s->w && x < o->w; x++) {
   1.101 -            RGBtoYUV(p, yuv, monochrome, luminance);
   1.102 -            if (x % 2 == 0) {
   1.103 -                *(op++) = yuv[0];
   1.104 -                *(op++) = yuv[2];
   1.105 -                op[1] = yuv[1];
   1.106 -            } else {
   1.107 -                *op = yuv[0];
   1.108 -                op += 2;
   1.109 -            }
   1.110 -
   1.111 -            p += s->format->BytesPerPixel;
   1.112 -        }
   1.113 -    }
   1.114 -
   1.115 -    SDL_UnlockYUVOverlay(o);
   1.116 -    SDL_UnlockSurface(s);
   1.117 -}
   1.118 -
   1.119 -void
   1.120 -ConvertRGBtoYUY2(SDL_Surface * s, SDL_Overlay * o, int monochrome,
   1.121 -                 int luminance)
   1.122 -{
   1.123 -    int x, y;
   1.124 -    int yuv[3];
   1.125 -    Uint8 *p, *op;
   1.126 -
   1.127 -    SDL_LockSurface(s);
   1.128 -    SDL_LockYUVOverlay(o);
   1.129 -
   1.130 -    for (y = 0; y < s->h && y < o->h; y++) {
   1.131 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
   1.132 -        op = o->pixels[0] + o->pitches[0] * y;
   1.133 -        for (x = 0; x < s->w && x < o->w; x++) {
   1.134 -            RGBtoYUV(p, yuv, monochrome, luminance);
   1.135 -            if (x % 2 == 0) {
   1.136 -                *(op++) = yuv[0];
   1.137 -                *(op++) = yuv[1];
   1.138 -                op[1] = yuv[2];
   1.139 -            } else {
   1.140 -                *op = yuv[0];
   1.141 -                op += 2;
   1.142 -            }
   1.143 -
   1.144 -            p += s->format->BytesPerPixel;
   1.145 -        }
   1.146 -    }
   1.147 -
   1.148 -    SDL_UnlockYUVOverlay(o);
   1.149 -    SDL_UnlockSurface(s);
   1.150 -}
   1.151 -
   1.152  static void
   1.153  PrintUsage(char *argv0)
   1.154  {
   1.155 @@ -384,7 +246,7 @@
   1.156      int scale = 5;
   1.157      SDL_bool done = SDL_FALSE;
   1.158  
   1.159 -    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
   1.160 +    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   1.161          fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   1.162          return 3;
   1.163      }
   1.164 @@ -414,31 +276,6 @@
   1.165              nodelay = 1;
   1.166              argv += 1;
   1.167              argc -= 1;
   1.168 -        } else if (strcmp(argv[1], "-format") == 0) {
   1.169 -            if (argv[2]) {
   1.170 -                if (!strcmp(argv[2], "YV12"))
   1.171 -                    pixel_format = SDL_PIXELFORMAT_YV12;
   1.172 -                else if (!strcmp(argv[2], "IYUV"))
   1.173 -                    pixel_format = SDL_PIXELFORMAT_IYUV;
   1.174 -                else if (!strcmp(argv[2], "YUY2"))
   1.175 -                    pixel_format = SDL_PIXELFORMAT_YUY2;
   1.176 -                else if (!strcmp(argv[2], "UYVY"))
   1.177 -                    pixel_format = SDL_PIXELFORMAT_UYVY;
   1.178 -                else if (!strcmp(argv[2], "YVYU"))
   1.179 -                    pixel_format = SDL_PIXELFORMAT_YVYU;
   1.180 -                else {
   1.181 -                    fprintf(stderr,
   1.182 -                            "The -format option %s is not recognized, see help for info.\n",
   1.183 -                            argv[2]);
   1.184 -                    quit(10);
   1.185 -                }
   1.186 -                argv += 2;
   1.187 -                argc -= 2;
   1.188 -            } else {
   1.189 -                fprintf(stderr,
   1.190 -                        "The -format option requires an argument, default is YUY2.\n");
   1.191 -                quit(10);
   1.192 -            }
   1.193          } else if (strcmp(argv[1], "-scale") == 0) {
   1.194              if (argv[2]) {
   1.195                  scale = atoi(argv[2]);
   1.196 @@ -516,6 +353,8 @@
   1.197          free(RawMooseData);
   1.198          quit(5);
   1.199      }
   1.200 +    /* Uncomment this to check vertex color with a YUV texture */
   1.201 +    /*SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80);*/
   1.202  
   1.203      for (i = 0; i < MOOSEFRAMES_COUNT; i++) {
   1.204          Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3];
   1.205 @@ -600,6 +439,5 @@
   1.206      quit(0);
   1.207      return 0;
   1.208  }
   1.209 -#endif
   1.210  
   1.211  /* vi: set ts=4 sw=4 expandtab: */