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

I’m looking at this in the MMAPI:

https://docs.nvidia.com/jetson/l4t-multimedia/l4t_mm_v4l2_cam_cuda_group.html

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/libnvjpeg.so:

objdump -T /usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so | 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:

https://docs.nvidia.com/cuda/nvjpeg/index.html#nvjpeg-single-image-decoding

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).

Thanks.

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

https://developer.nvidia.com/nvjpeg-release-download

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

Hi,
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

/usr/src/jetson_multimedia_api/samples/common/classes/NvJpegDecoder.cpp

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. :-(

Hi,
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. :-)