N0name
N0name

Reputation: 183

libjpeg decode nv12 or yuv420p

I'm trying to get a YUV420 palanar or semiplanar (NV12) image out of jpeg using libjpeg.

I see that there is a option to specify output format to JCS_YCbCr which would generally be a YUV format, but as far as i understand it would give me the data as arrays of 3 elements { Y, U, V }. So to get the image to the right format i would have to rearange and subsample the pixels myself and i want to avoid that for performance reasons.

So I was wondering is there a way to configure libjpeg to output a YUV420p / NV12 buffer directly.

Upvotes: 5

Views: 3425

Answers (1)

Arun T A
Arun T A

Reputation: 41

Just take a look at gst_jpeg_decode() in gstreamer source tree. This function along with gst_jpeg_decode_direct() function does exactly what you want to do.

Note that it gives YUV420 planar output, bypassing all color conversion done by libjpeg. (Note: this assumes that the input JPEG is encoded in YUV420 color space (aka I420), which is true for almost all JPEGs out there.

Upvotes: 4

Related Questions