test/testoverlay2.c
changeset 4884 27ab20a36eba
parent 2267 c785543d1843
child 5216 16d5e8e90e01
equal deleted inserted replaced
4883:511948f4919e 4884:27ab20a36eba
   142 void
   142 void
   143 RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance)
   143 RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance)
   144 {
   144 {
   145     if (monochrome) {
   145     if (monochrome) {
   146 #if 1                           /* these are the two formulas that I found on the FourCC site... */
   146 #if 1                           /* these are the two formulas that I found on the FourCC site... */
   147         yuv[0] = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2];
   147         yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
   148         yuv[1] = 128;
   148         yuv[1] = 128;
   149         yuv[2] = 128;
   149         yuv[2] = 128;
   150 #else
   150 #else
   151         yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
   151         yuv[0] = (int)(0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
   152         yuv[1] = 128;
   152         yuv[1] = 128;
   153         yuv[2] = 128;
   153         yuv[2] = 128;
   154 #endif
   154 #endif
   155     } else {
   155     } else {
   156 #if 1                           /* these are the two formulas that I found on the FourCC site... */
   156 #if 1                           /* these are the two formulas that I found on the FourCC site... */
   157         yuv[0] = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2];
   157         yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
   158         yuv[1] = (rgb[2] - yuv[0]) * 0.565 + 128;
   158         yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
   159         yuv[2] = (rgb[0] - yuv[0]) * 0.713 + 128;
   159         yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
   160 #else
   160 #else
   161         yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
   161         yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
   162         yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
   162         yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
   163         yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
   163         yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
   164 #endif
   164 #endif
   604                 quit(0);
   604                 quit(0);
   605             }
   605             }
   606         }
   606         }
   607 
   607 
   608         if ((!paused) || (resized)) {
   608         if ((!paused) || (resized)) {
   609             if (((SDL_GetTicks() - lastftick) > fpsdelay) || (resized)) {
   609             if (((SDL_GetTicks() - lastftick) > (Uint32)fpsdelay) || (resized)) {
   610                 lastftick = SDL_GetTicks();
   610                 lastftick = SDL_GetTicks();
   611 
   611 
   612                 switch (overlay_format) {
   612                 switch (overlay_format) {
   613                 case SDL_YUY2_OVERLAY:
   613                 case SDL_YUY2_OVERLAY:
   614                     ConvertRGBtoYUY2(MooseFrame[i], overlay, 0, 100);
   614                     ConvertRGBtoYUY2(MooseFrame[i], overlay, 0, 100);