Adrien F
06-27-2011, 01:53 AM
Hello,
My application intends to blend various synchronised video streams into one output stream in YUV.
I have multiple cameras delivering raw RGB (Bayer pattern) streams.
I also have a functional fragment shader doing conversion from raw RGB to regular RGB.
I know the formulas to do RGB->YUV conversion.
Where I need your help is on how to write YUYV 4:2:2 interleaved data.
Basically my workflow is :
1/ read bayer pattern textures
2/ for each texture
draw it using alpha blending (a single shader doing color conversion and alpha blending for each stream)
3/ glReadPixels to write the resulting frame buffer to disk
YUYV 422 format impose that each even pixel has a Y and a U component, each odd pixel a Y and V. Thus I would use :
gl_FragColor = vec4(vec3(Y/3),U); or gl_FragColor = vec4(vec3(Y/3),V); depending on the case and
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0,0,w,h,GL_LUMINANCE_ALPHA,GL_UNSIGNE D_BYTE,&data); to write only two bytes of data for each pixel.
I think this idea should work if I only had 1 stream to write.
But, using the alpha channel to pass U or V component, I can no more do alpha blending between video streams, each one being logically overwritten by the next one with irrelevant alpha values.
So do you know any efficient mean to write only 2 components per pixel without using alpha channel?
Or do you have any other workflow ideas to reach my goal?
Thanks in advance for any tips.
Adrien
My application intends to blend various synchronised video streams into one output stream in YUV.
I have multiple cameras delivering raw RGB (Bayer pattern) streams.
I also have a functional fragment shader doing conversion from raw RGB to regular RGB.
I know the formulas to do RGB->YUV conversion.
Where I need your help is on how to write YUYV 4:2:2 interleaved data.
Basically my workflow is :
1/ read bayer pattern textures
2/ for each texture
draw it using alpha blending (a single shader doing color conversion and alpha blending for each stream)
3/ glReadPixels to write the resulting frame buffer to disk
YUYV 422 format impose that each even pixel has a Y and a U component, each odd pixel a Y and V. Thus I would use :
gl_FragColor = vec4(vec3(Y/3),U); or gl_FragColor = vec4(vec3(Y/3),V); depending on the case and
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0,0,w,h,GL_LUMINANCE_ALPHA,GL_UNSIGNE D_BYTE,&data); to write only two bytes of data for each pixel.
I think this idea should work if I only had 1 stream to write.
But, using the alpha channel to pass U or V component, I can no more do alpha blending between video streams, each one being logically overwritten by the next one with irrelevant alpha values.
So do you know any efficient mean to write only 2 components per pixel without using alpha channel?
Or do you have any other workflow ideas to reach my goal?
Thanks in advance for any tips.
Adrien