test/testoverlay2.c
changeset 9046 c3ec7c3e6c24
parent 8149 681eb46b8ac4
child 9278 8900afb78a19
     1.1 --- a/test/testoverlay2.c	Wed Aug 06 00:28:02 2014 -0700
     1.2 +++ b/test/testoverlay2.c	Wed Aug 06 11:34:54 2014 -0700
     1.3 @@ -206,6 +206,29 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +void
     1.8 +ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h,
     1.9 +                 int monochrome, int luminance)
    1.10 +{
    1.11 +    int x, y;
    1.12 +    int yuv[3];
    1.13 +    Uint8 *op[2];
    1.14 +
    1.15 +    op[0] = out;
    1.16 +    op[1] = op[0] + w*h;
    1.17 +    for (y = 0; y < h; ++y) {
    1.18 +        for (x = 0; x < w; ++x) {
    1.19 +            RGBtoYUV(rgb, yuv, monochrome, luminance);
    1.20 +            *(op[0]++) = yuv[0];
    1.21 +            if (x % 2 == 0 && y % 2 == 0) {
    1.22 +                *(op[1]++) = yuv[1];
    1.23 +                *(op[1]++) = yuv[2];
    1.24 +            }
    1.25 +            rgb += 3;
    1.26 +        }
    1.27 +    }
    1.28 +}
    1.29 +
    1.30  static void
    1.31  PrintUsage(char *argv0)
    1.32  {
    1.33 @@ -241,7 +264,11 @@
    1.34      int fps = 12;
    1.35      int fpsdelay;
    1.36      int nodelay = 0;
    1.37 +#ifdef TEST_NV12
    1.38 +    Uint32 pixel_format = SDL_PIXELFORMAT_NV12;
    1.39 +#else
    1.40      Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
    1.41 +#endif
    1.42      int scale = 5;
    1.43      SDL_bool done = SDL_FALSE;
    1.44  
    1.45 @@ -371,7 +398,17 @@
    1.46              rgb[2] = MooseColors[frame[j]].b;
    1.47              rgb += 3;
    1.48          }
    1.49 -        ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
    1.50 +        switch (pixel_format) {
    1.51 +        case SDL_PIXELFORMAT_YV12:
    1.52 +            ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
    1.53 +            break;
    1.54 +        case SDL_PIXELFORMAT_NV12:
    1.55 +            ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
    1.56 +            break;
    1.57 +        default:
    1.58 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n");
    1.59 +            break;
    1.60 +        }
    1.61      }
    1.62  
    1.63      free(RawMooseData);