How does jpeg_start_decompress work in the MMAPI samples and why is it used?

I’m looking at this in the MMAPI:

It decodes JPEG frames from a webcam and displays them on screen which is great, however the sample code calls “jpeg_start_decompress” which is undocumented and exists as a symbol in /usr/lib/aarch64-linux-gnu/tegra/

objdump -T /usr/lib/aarch64-linux-gnu/tegra/ | grep jpeg_start_decompress

Please can some expert help me work out what is going on with the undocumented jpeg_start_decompress function?

I was reading the nvjpeg documentation:

And it says that you should use nvjpegDecode to decode an image but I don’t see this used ANYWHERE in the sample code. Are the MMAPI samples using some deprecated interface? If so, where are the samples that show how to use nvjpegDecode?

I would like to get the CUDA JPEG decoder to output luminance channel only which is why I need to understand jpeg_start_decompress. (The nvjpeg documentation is clear on how to use nvjpegDecode to decode only to the Y channel).


Even more hilariously, if you download the AMD64 nvjpeg release:

You find that jpeg_start_decompress is not defined anywhere in here, HOWEVER, nvjpegDecode IS defined!

So to summarise we have the undocumented jpeg_start_decompress function in the Jetson release of nvjpeg, and the documented nvjpegDecode in the AMD64 release.

I am very confused! :-S

The hardware engines of jpeg codec are different on Jetson platforms and desktop GPUs. Hence the APIs are implemented separately. For using Jetson platforms, please check NvJpegDecoder class in


Okay, it appears Nvidia is trying to mimic libjpeg.

Do you know how I can set the output colorspace? I tried modifying NvJpegDecoder.cpp so that all the instances of

cinfo.out_color_space = JCS_YCbCr

were replaced with

cinfo.out_color_space =  JCS_GRAYSCALE

But it didn’t do the colorspace conversion. :-(

For format conversion, you can utilize NvBufferTransform(). Please check NvBuffer APIs in nvbuf_utils.h

The documentation for NvBufferTransform does not describe colourspace conversion.

It is okay though, because it turns out that the default behaviour of libnvjpeg is to decode to YUV so I have what I need. :-)