Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Plana YUV -> RGB using GLSL

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    2

    Plana YUV -> RGB using GLSL

    Hi,

    I have a video in planar YUV format (Three planes in three different arrays) and I want to convert this into RGB and display it using shaders. Normally if it was packed (interleaved) format I would write one frame to a texture than decompose it the Y,U and V planes using a 2D samplers. But since there are 3 different arrays one way can be uploading them to three different textures converting it but I dont want to use 3 textures per video since I will display multiple videos (12) at a time. How can I write a shader which will take the whole planar YUV data (maybe by PBO), decompose into Y,U,V, convert to RGB and display it in a 2D rectangle.

    thanks
    mike

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2009
    Location
    France, Bordeaux.
    Posts
    24
    Does your decoder support setting linesize ? (the pitche in byte to go to the next line). I it does, you can arrange your planes like this in your pbo :

    http://www.mdk.org.pl/assets/yuv-buffer.png

    and shift your texture coordinates. But, due to opengl's filtering, you may have some artefacts to the texture's edges. If you use SDL, here a video decoder that can do this for you :

    http://waave.sourceforge.net/

    But I think creating 36 textures isn't really a problem...

  3. #3
    Intern Contributor
    Join Date
    May 2008
    Location
    USA
    Posts
    99
    Yes, the number of textures shouldn't be a problem - the memory used is the same, and as long as you don't expect to draw all those videos in one shader pass (probably can't anyway), binding the right textures is fine. You also will probably help the GPU cache the texels you want to sample, as opposed to picking from three points on one texture, which would probably subvert the caching each shader unit does.

    If you really feel you must, then upload a huge single channel texture and work out where to sample in the pixel shader. It's not too hard.

    Bruce

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •