hello
I want to display a YUV file,but when i run the program, it doesn’t seem
to display the file, it just display a green color.
The following is my program.
Can you please help me with that.
Thanks in advace
const int frameRate=25;
const int numByteFrame=24176144;
const int numSeconds=5;
int numByteTot;
char *bufferFrames;
SDL_Surface *screen;
SDL_Overlay *videoYUV;
SDL_Rect posizDest={0,0,176,144};
int framenum=40;
int sdl_display_yuv(char *finput)
{
int i=1;
int ret,ret1;
int numFrameTot;
numByteTot=framenum*numByteFrame;
fprintf(stdout,“framenum = %d, numByteTot = %d\n”,framenum,numByteTot);
//???SDL???
ret=SDL_Init ( SDL_INIT_VIDEO );
fprintf(stdout,“initialize SDL:%d\n”,ret);
if ( ret< 0 )
{
fprintf (stdout, “Couldn’t initialize SDL: %s\n”, SDL_GetError() );
return(-1);
}
atexit ( SDL_Quit ) ;
bufferFrames=(int *)calloc(numByteTot+1,sizeof(int));//?bufferFrames???
?
fprintf(stdout,“the size of memory allocated for bufferframes is
%d\n”,bufferFrames);
if(bufferFrames==0)
{
fprintf(stdout,“couldnt allocate memory for bufferframe\n”);
abort();
}
screen=SDL_SetVideoMode(176,144,24,SDL_SWSURFACE|SDL_ANYFORMAT);
if (screen==NULL)
{
fprintf (stdout, “Couldn’t Set SDL_video_mode: %s\n”, SDL_GetError() );
return(-1);
}
videoYUV=SDL_CreateYUVOverlay(176,144,SDL_YV12_OVERLAY,screen);
if (videoYUV==NULL)
{
fprintf (stdout, “Couldn’t create YUVoverlay: %s\n”, SDL_GetError() );
return(-1);
}
fprintf(stdout,“the program go here\n”);
for(i=0;i<framenum;i++)
{
SDL_LockYUVOverlay(videoYUV);
fprintf(stdout,“sdl start to lock the overlay\n”);
memcpy(videoYUV->pixels[0],&bufferFrames[i*numByteFrame],176*144);
memcpy(videoYUV->pixels[1],&bufferFrames[176144+inumByteFrame],176*144/4);
memcpy(videoYUV->pixels[2],&bufferFrames[176144+176144/4+inumByteFrame],176144/4);
SDL_UnlockYUVOverlay(videoYUV);
fprintf(stdout,“sdl start to unlock the overlay\n”);
SDL_DisplayYUVOverlay(videoYUV,&posizDest);
fprintf(stdout,“sdl start to display the overlay\n”);
SDL_Delay(1000);
}
fprintf(stdout,“the sdl program go to the end/n”);
return(0);
}_________________________________________________________________
??? MSN Hotmail? http://www.hotmail.com