[SDL] display YUV file

elhadj benkhelifa ebenkhelifa at yahoo.co.uk
Wed Nov 12 10:55:01 PST 2003


hello all, 

i am doing similar thing. i want to display a YUV
file,

i open file the read it.
and my display function are :

void initDisplay(){
  
  /* Initialize the SDL library */
  
  if( SDL_Init(SDL_INIT_VIDEO) ==-1 ) {
    fprintf(stderr,
	    "Couldn't initialize SDL: %s\n", SDL_GetError());
    exit(1);
  }  
    
  screen = SDL_SetVideoMode(width, height, 24,
SDL_SWSURFACE|SDL_ANYFORMAT);
  if ( screen == NULL ) {
    fprintf(stderr, "Couldn't set 640x480x8 video
mode: %s\n",
	    SDL_GetError());
    exit(1);
  }
  
  YUVOverlay = SDL_CreateYUVOverlay(width, height,
SDL_YUY2_OVERLAY , screen);
  YUVOverlay->pixels=pYCbCrData;
  }
void displayYUV (){
    
  int i;
  disRect.x = 0; 
  disRect.y = 0;
  disRect.w= width;
  disRect.h= height;
  printf("OK2 = %d \n %d \n %d \n%d",
disRect.x,disRect.y, disRect.w,disRect.h);

   
    SDL_LockYUVOverlay(YUVOverlay);
   memcpy(pYCbCrData, pYCbCrData+(Total_Bytes*0),
Total_Bytes);
    i = SDL_DisplayYUVOverlay(YUVOverlay, &disRect );
        printf("something\n");
    if(i!=0){
      printf("canot display overlay");
    }
    SDL_UnlockYUVOverlay(YUVOverlay);
  
}

i have got a problem when i run the program, 
it doesn't seem to display the file, it just display a
green color.

can you please help me with that.

thanks in advace

________________________________________________________________________
Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk




More information about the SDL mailing list