Jetson Linux API Reference

32.7.3 Release
06_jpeg_decode (JPEG decode)

Overview

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


Building and Running

Prerequisites

To build:

  • Enter:
     $ cd /usr/src/jetson_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]
    

Example

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


Flow

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:

Element Description
NvVideoConverter Contains elements and functions for video format conversion.
NvJpegDecoder Contains 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 Member Description
output_plane V4l2 output plane.
capture_plane V4l2 capture plane.
waitForIdle Wait until all queued output plane buffers are processed and dequeued from the capture plane.
setOutputPlaneFormat Set output plane format.
setCapturePlaneFormat Set 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:

Element Description
setupPlane Setup the plane of V4l2 element.
deinitPlane Destroy the plane of V4l2 element.
setStreamStatus Start/Stop the stream.
setDQThreadCallback Set the callback function of the dqueue buffer thread.
startDQThread Start the thread of the dqueue buffer.
stopDQThread Stop the thread of the dqueue buffer.
qBuffer Queue the V4l2 buffer.
dqBuffer Dequeue the V4l2 buffer.
getNumBuffers Get the number of the V4l2 buffer.
getNumQueuedBuffers Get the number of the V4l2 buffer under queue.
getNthBuffer Get the NvBuffer at Index N.

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

Function Description
decodeToFd Decode to hardware buffer (at a file descriptor) where the data is available to other components.
decodeToBuffer Decode to a software buffer.