L4T Multimedia API Reference

28.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages


The JPEG decode sample demonstrates JPEG decode and optional use of the lib4L2 conversion API, should buffer format conversion be required.

Building and Running


To build:

  • Enter:
     $ cd $HOME/tegra_multimedia_api/samples/06_jpeg_decode
     $ make

To run

  • Enter:
     $ ./jpeg_decode num_files <number of files to decode> \
         <in-file1> <out-file1> ...<in-filen> <out-filen> [OPTIONS]


   $ ./jpeg_decode num_files 1 ../../data/Picture/nvidia-logo.jpg ../../data/Picture/nvidia-logo.yuv


The following diagram shows the flow of data through the sample.

Additional Details

The output plane is used to receive input and the capture plane is used to produce output. When calling decodeToFd, the data format matches Tegra hardware so that no format conversion is required. Calling decodeToBuffer requires converting the buffer to software format after hardware-accelerated JPEG decoding. The JPEG file format contains the standard software format.

Key Structure and Classes

This sample uses the following key structures and classes:

NvVideoConverterContains elements and functions for video format conversion.
NvJpegDecoderContains elements and functions for decoding JPEG images.

NvVideoConverter contains all video converting related elements and functions. Key members of NvVideoConverter used in the sample are:

NvVideoConverter MemberDescription
output_planeV4l2 output plane.
capture_planeV4l2 capture plane.
waitForIdleWait until all queued output plane buffers are processed and dequeued from the capture plane.
setOutputPlaneFormatSet output plane format.
setCapturePlaneFormatSet capture plane format.

The NvVideoConverter elements output_plane and capture_plane belong to the NvV4l2ElementPlane class. Key members of NvV4l2ElementPlane used in the sample are as follows:

setupPlaneSetup the plane of V4l2 element.
deinitPlaneDestroy the plane of V4l2 element.
setStreamStatusStart/Stop the stream.
setDQThreadCallbackSet the callback function of the dqueue buffer thread.
startDQThreadStart the thread of the dqueue buffer.
stopDQThreadStop the thread of the dqueue buffer.
qBufferQueue the V4l2 buffer.
dqBufferDequeue the V4l2 buffer.
getNumBuffersGet the number of the V4l2 buffer.
getNumQueuedBuffersGet the number of the V4l2 buffer under queue.
getNthBufferGet the NvBuffer at Index N.

The NvJpegDecoder class contains all of the functions for JPEG image decoding. Key members used are:

decodeToFdDecode to hardware buffer (at a file descriptor) where the data is available to other components.
decodeToBufferDecode to a software buffer.