当前位置: 首页 > 工具软件 > SDL > 使用案例 >

SDL显示

淳于昊然
2023-12-01

SDL (多平台支持硬件缩放)
SDL(Simple DirectMedia Layer) is a cross-platform multimedia library designed to provide low level access to audio keyboard mouse joystick 3D hardware via OpenGL and 2D video framebuffer.
其实SDL就是一个中间件,它封装了下层的OpenGL frameBuffer X11 DirectX等给上层提供一个统一的API接口,使用SDL的优点是我们不必再为X11或DirectX分别做个视(fen bie zuo ge shi)频输出程序了。
SDL可以直接显示YUV数据和RGB数据一般解码得到的picture都是YUV420P格式的不用做YUV2RGB的转换就可以直接显示主要代码如下:
static int vo_sdl_init(void)
{
....
screen = SDL_SetVideoMode(ww wh 0 flags);
overlay = SDL_CreateYUVOverlay(dw dh SDL_YV12_OVERLAY screen);
....
}
static void vo_sdl_display(AVPicture *pict)
{
SDL_Rect rect;
AVPicture p;
SDL_LockYUVOverlay(overlay);
p.data[0] = overlay->pixels[0];
p.data[1] = overlay->pixels[2];
p.data[2] = overlay->pixels[1];
p.linesize[0] = overlay->pitches[0];www.spbemis.net.cn
p.linesize[1] = overlay->pitches[2];
p.linesize[2] = overlay->pitches[1];
vo_sdl_sws( &p pict ); /* only do memcpy */
SDL_UnlockYUVOverlay(overlay);
rect.x = dx;
rect.y = dy;
rect.w = dw;
rect.h = dh;
SDL_DisplayYUVOverlay(overlay &rect);
}


本文来自CSDN博客,转载请标明出处:http://www.yanfaw.com/html/46/n-2946.html

 类似资料: