SDL_UpdateTexture,SDL_UpdateYUVTexture截屏效率比较,sdl_savebmp黑屏

两个初始化方式:

方式1

m_sdlwindow_output = SDL_CreateWindow("test", 0, 0, m_cfg.encwidth, m_cfg.encheight, SDL_WINDOW_BORDERLESS);
assert(m_sdlwindow_output > 0);
SDL_HideWindow(m_sdlwindow_output);
m_sdlsurface_output = SDL_GetWindowSurface(m_sdlwindow_output);
assert(m_sdlsurface_output > 0);
m_sdlrenderer_output = SDL_CreateRenderer(m_sdlwindow_output, -1, SDL_RENDERER_ACCELERATED);
assert(m_sdlrenderer_output > 0);

这个方式走的是硬件渲染

方式2

 m_sdlsurface_output = SDL_CreateRGBSurface(SDL_SWSURFACE, m_cfg.encwidth, m_cfg.encheight, 32, 0, 0, 0, 0);
 assert(m_sdlsurface_output != NULL);
 m_sdlrenderer_output = SDL_CreateSoftwareRenderer(m_sdlsurface_output);
 assert(m_sdlrenderer_output != NULL);

 //m_sdltexture_output = SDL_CreateTexture(m_sdlrenderer_output, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_TARGET,
 m_sdltexture_output = SDL_CreateTexture(m_sdlrenderer_output, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_TARGET,
  m_cfg.encwidth, m_cfg.encheight);
 assert(m_sdltexture_output != NULL);

这个走的是软件渲染

方式1,渲染速度非常快1毫秒多,1080p分辨率,但是此种方式用sdl_surface.savebmp,保存的是黑屏,

方式1,渲染速度非常慢,因为实在软件上渲染,15毫秒,1080p分辨率,但是此种方式用sdl_surface.savebmp,可以保存到正确的图像。


 int pitch0 = g_ptrMainWnd->m_cfg.encwidth * SDL_BYTESPERPIXEL(SDL_PIXELFORMAT_RGB24);

 DWORD dw1 = GetTickCount();

 //for (int m = 0; m < 1000; m++)
 {
  //ret = SDL_UpdateYUVTexture(g_ptrMainWnd->m_sdltexture_output, &g_ptrMainWnd->m_ptrActList[chnIdx]->m_outputTun.rect,
  // data_in[0], linesize_in[0],
  // data_in[1], linesize_in[1],
  // data_in[2], linesize_in[2]);
  //assert(ret == 0);


  ret = SDL_UpdateTexture(g_ptrMainWnd->m_sdltexture_output, &g_ptrMainWnd->m_ptrActList[chnIdx]->m_outputTun.rect,
   data_in[0], pitch0);
  // data_in[1], linesize_in[1],
  // data_in[2], linesize_in[2]);
  assert(ret == 0);



同样是软件上渲染更新纹理时候也是两种方式,yuv稍快,15毫秒一帧,rgb24方式要30毫秒一帧。1080p的分辨率







展开阅读全文

没有更多推荐了,返回首页