QVideoFrame + OpenGL, which is the best way?
-
I am currently making a video player where the video display would be OpenGL drawn.
Currently, I will transfer the QVideoFrame to a PBO, but what I want to evade is unnecessary copying of the frame's pixels from VRAM to RAM and vice versa.
Saw the QAbstractVideoBuffer::GLTextureHandle handle type and was wondering what should be the scenario where the decoder, or whatever decodes and couples up the video frame, would create the frame in this format (as an OpenGL texture or something in the video memory), so that the frame could be directly used by the OpenGL shaders.
How the functionality that creates the frames could be made to upload decoded frames directly to the video memory (as textures, for instance - QAbstractVideoBuffer::GLTextureHandle)?
Otherwise the decoded frame data would be first mapped (copied to somewhere as Qt documentation states), then one should copy it to a PBO. This way two unnecessary copies of the frame data could be triggered:- QVideoFrame::map:
"Maps the contents of a video frame to system (CPU addressable) memory.
In some cases the video frame data might be stored in video memory or otherwise inaccessible memory, so it is necessary to map a frame before accessing the pixel data. This may involve copying the contents around, so avoid mapping and unmapping unless required." (sorry for using quotes, the bq. doesn't work)
- From VRAM / RAM to VRAM - the PBO.
Also, as "nVidia's documentation":http://http.download.nvidia.com/developer/Papers/2005/Fast_Texture_Transfers/Fast_Texture_Transfers.pdf states:
"Storing 8-bit textures in a BGRA layout in system memory and use the
GL_BGRA as the external format for textures to avoid swizzling"... it is best to provide the pixel data to the video memory in the BGRA pixel format.
Is possible to make the decoder pass the QVideoFrame directly to the video memory and provide the data in the BGRA format?
- QVideoFrame::map: