SDL YUV overlay surface?

Ideas and dreaming will go this forum
Post Reply

geo650
Official SamyGO Developer
Posts: 303
Joined: Wed Oct 07, 2009 12:03 pm

SDL YUV overlay surface?

Post by geo650 »

Hi!
Does B65x support YUV (or similar) overlay SDL surfaces?

I mean SDL_CreateYUVOverlay() function and others.
http://www.libsdl.org/release/SDL-1.2.1 ... erlay.html

It would be better to use it to display some things without time-consuming YUV-to-RGBA conversion.

My starting app with unsuccessfull tests:

Code: Select all

#include <SDL/SDL.h>

int Game_Main(const char  *path, const char *udn __attribute__ ((unused)))
{
   Uint32 video_flags, overlay_format;

   // surface pointers
   SDL_Overlay *overlay = NULL;
   SDL_Surface *screen = NULL;

   system("echo app started...>>/mtd_ram/log.txt");

   // SDL init
   SDL_Init(SDL_INIT_VIDEO);

   video_flags = 0;
//   video_flags |= SDL_HWSURFACE;
//   video_flags |= SDL_DOUBLEBUF;
//   video_flags |= SDL_FULLSCREEN;

   // set video mode for screen
   screen = SDL_SetVideoMode(1920/2, 1080/2, 32, video_flags);	// bpp = 32, 24 or 16 - changes depth only

   overlay_format = SDL_YV12_OVERLAY;
//   overlay_format = SDL_IYUV_OVERLAY;
//   overlay_format = SDL_YUY2_OVERLAY;
//   overlay_format = SDL_UYVY_OVERLAY;
//   overlay_format = SDL_YVYU_OVERLAY;

   overlay = SDL_CreateYUVOverlay(1920/2, 1080/2, overlay_format, screen);
   if ( overlay == NULL ) system("echo cannot create overlay!>>/mtd_ram/log.txt");
   else
   {
      SDL_LockSurface(screen);
      SDL_LockYUVOverlay(overlay);

      // draw something... (fill overlay memory)
      memset(overlay->pixels[0], 100, overlay->pitches[0] * overlay->h /4);
      memset(overlay->pixels[1], 156, overlay->pitches[1] * ((overlay->h / 4 + 1) / 2));
      memset(overlay->pixels[2], 228, overlay->pitches[2] * ((overlay->h / 4 + 1) / 2));

      SDL_UnlockYUVOverlay(overlay);
      SDL_UnlockSurface(screen);

      SDL_Flip(screen);
      SDL_Delay(5000);	// wait 5s
   }

   // quit
   SDL_Quit();

   system("echo app ends...>>/mtd_ram/log.txt");
   return 0;
}

Post Reply

Return to “[B] Brainstorm”