packed to planar conversion

Started by
2 comments, last by _the_phantom_ 16 years, 1 month ago
Dear All, We are using FFMPEG and OpenGL and are facing the problem of converting from packed to planar frame format. That is from a three dimensional array pixels[3][256][256] ( pixels[YUV][x][y] ) to a one dimensional array of RGBRGBRGBRGB... Now the conversion is done with a for loop, but this is far to slow. Are there other solution examples to do the conversion (extensions, GPU programming, assembly)? With kind regards
Advertisement
You could use the GL_SGI_color_matrix extension (or the GL_ARB_imaging extension, or OpenGL >= 1.2). Just setting the color matrix to a YUV decoding matrix and uploading the data as a texture should get the data converted on the fly. I never tried that though.

To get the RGB data (if you really need it) just set the matrix to identity and call glGetTexImage (slow, but maybe faster than your own conversion routine).
blah :)
Thank you very much for your reaction.

From you answer I understood that these methods are good to convert from RGB to YUV.

My main concern is how to convert from a 3 dimensional array {Y1, Y2, Y3, ...}{U1, U2, U3, ...}{V1, V2, V3, ...} to a 1 dimensional array {Y1, U1, V1, Y2, U2, V3, Y3, U3, V3, ....}?

The conversion from RGB to YUV is solved.

Long story short; don't.

Upload each block as it's own texture and use a pixel shader to decode to RGB sampling from each texture as required.

This topic is closed to new replies.

Advertisement