用SDL库播放yuy2 Packed mode 分类: ffmpeg-SDL-VLC-Live555 2013-10-30 15:34 575人阅读 评论(0) 收藏
#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 */
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
exit(1);
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode(720, 576, 32, SDL_SWSURFACE|SDL_ANYFORMAT);
if ( screen == NULL )
{
exit(1);
}
SDL_Overlay* overlay = SDL_CreateYUVOverlay(w, h, SDL_YUY2_OVERLAY, screen);
if (overlay == NULL)
{
exit(1);
}
pY = (unsigned char*)malloc(w*h*2);
SDL_LockSurface(screen);
SDL_LockYUVOverlay(overlay);
fp = fopen("d:\\6082.dat", "rb");
if (fp == NULL)
{
exit(1);
}
while (!feof(fp))
{
fread(pY, 1, w*h*2, fp);
memcpy(overlay->pixels[0], pY, w*h*2);
SDL_UnlockYUVOverlay(overlay);
SDL_UnlockSurface(screen);
rect.w = w;
rect.h = h;
rect.x = rect.y = 0;
SDL_DisplayYUVOverlay(overlay, &rect);
SDL_Delay(40);
i += 1;
}
fclose(fp);
free(pY);
SDL_FreeYUVOverlay(overlay);
SDL_FreeSurface(screen);
str.Format(_T("frmcnt:%d"),i);
MessageBox(str);
版权声明:本文为博主原创文章,未经博主允许不得转载。