Jetson Linux API Reference

32.7.3 Release
NvJPEGDecoder Class Reference

Detailed Description

Helper class for decoding JPEG images using libjpeg APIs.

NvJPEGDecoder uses the libjpeg APIs for decoding JPEG images. It supports two methods for decoding:

  • Decode to a DMABUF and return its file descriptor (FD).
  • Decode and write data to a NvBuffer object, i.e., software allocated memory (malloc).

The JPEG decoder is capable of decoding YUV420, YUV422, and YUV444 JPEG images.

Note
Only the JCS_YCbCr (YUV420) color space is currently supported.

Definition at line 86 of file NvJpegDecoder.h.

Inheritance diagram for NvJPEGDecoder:
Collaboration diagram for NvJPEGDecoder:

Public Member Functions

 ~NvJPEGDecoder ()
 
int decodeToFd (int &fd, unsigned char *in_buf, unsigned long in_buf_size, uint32_t &pixfmt, uint32_t &width, uint32_t &height)
 Decodes a JPEG image to hardware buffer memory. More...
 
int decodeToBuffer (NvBuffer **buffer, unsigned char *in_buf, unsigned long in_buf_size, uint32_t *pixfmt, uint32_t *width, uint32_t *height)
 Decodes a JPEG image to software buffer memory. More...
 
virtual int isInError ()
 Indicates whether the element encountered an error during its operation. More...
 
void getProfilingData (NvElementProfiler::NvElementProfilerData &data)
 Gets profiling data for the element. More...
 
void printProfilingStats (std::ostream &out_stream=std::cout)
 Prints profiling data for the element to an output stream. More...
 
virtual void enableProfiling ()
 Enables profiling for the element. More...
 
bool isProfilingEnabled ()
 Checks whether profiling is enabled for the element. More...
 

Static Public Member Functions

static NvJPEGDecodercreateJPEGDecoder (const char *comp_name)
 Creates a new JPEG Decoder named comp_name. More...
 

Protected Attributes

int is_in_error
 Indicates if an error was encountered during the operation of the element. More...
 
const char * comp_name
 Specifies the name of the component, for debugging. More...
 
NvElementProfiler profiler
 Profiler for the element. More...
 

Constructor & Destructor Documentation

◆ ~NvJPEGDecoder()

NvJPEGDecoder::~NvJPEGDecoder ( )

Member Function Documentation

◆ createJPEGDecoder()

static NvJPEGDecoder* NvJPEGDecoder::createJPEGDecoder ( const char *  comp_name)
static

Creates a new JPEG Decoder named comp_name.

Returns
Reference to the newly created decoder object, or NULL in case of failure during initialization.

◆ decodeToBuffer()

int NvJPEGDecoder::decodeToBuffer ( NvBuffer **  buffer,
unsigned char *  in_buf,
unsigned long  in_buf_size,
uint32_t *  pixfmt,
uint32_t *  width,
uint32_t *  height 
)

Decodes a JPEG image to software buffer memory.

This method decodes JPEG images in software memory to a specified width and size.

Note
The decodeToBuffer method is slower than the NvJPEGDecoder::decodeToFd method because it involves conversion from hardware buffer memory to software buffer memory.
Attention
The application must free the NvBuffer object.
Parameters
[out]bufferIndirect pointer to an NvBuffer object that contains the decoded image. The object is allocated by the method and the buffer memory is allocated using NvBuffer::allocateMemory.
[in]in_bufA pointer to the memory containing the JPEG.
[in]in_buf_sizeSize of the input buffer in bytes.
[out]pixfmtA pointer to the V4L2 pixel format of the decoded image.
[out]widthA pointer to the width of the decoded image in pixels.
[out]heightA pointer to the height of the decoded image in pixels.
Returns
0 for success, -1 otherwise.

◆ decodeToFd()

int NvJPEGDecoder::decodeToFd ( int &  fd,
unsigned char *  in_buf,
unsigned long  in_buf_size,
uint32_t &  pixfmt,
uint32_t &  width,
uint32_t &  height 
)

Decodes a JPEG image to hardware buffer memory.

This method decodes JPEG images in hardware memory to a specified width and size.

Parameters
[out]fdA reference to the file descriptor (FD) of the hardware buffer.
[in]in_bufA pointer to the memory containing the JPEG image.
[in]in_buf_sizeSize of the input buffer in bytes.
[out]pixfmtA reference to the V4L2 pixel format of the decoded image.
[out]widthA reference to the width of the decoded image in pixels.
[out]heightA reference to the height of the decoded image in pixels.
Returns
0 for success, -1 otherwise.

◆ enableProfiling()

virtual void NvElement::enableProfiling ( )
virtualinherited

Enables profiling for the element.

Reimplemented in NvV4l2Element.

◆ getProfilingData()

void NvElement::getProfilingData ( NvElementProfiler::NvElementProfilerData data)
inherited

Gets profiling data for the element.

Returns
A constant reference to the element's profiling data.

◆ isInError()

virtual int NvElement::isInError ( )
inlinevirtualinherited

Indicates whether the element encountered an error during its operation.

Returns
0 if no error was encountered, a non-zero value if an error was encountered.

Reimplemented in NvV4l2Element.

Definition at line 72 of file NvElement.h.

References NvElement::is_in_error.

◆ isProfilingEnabled()

bool NvElement::isProfilingEnabled ( )
inherited

Checks whether profiling is enabled for the element.

Returns
Boolean value indicating if profiling is enabled.

◆ printProfilingStats()

void NvElement::printProfilingStats ( std::ostream &  out_stream = std::cout)
inherited

Prints profiling data for the element to an output stream.

Parameters
[in]out_streamOutput stream of type std::ostream to print the data to. It takes the default value std::cout if not specified.

Field Documentation

◆ comp_name

const char* NvElement::comp_name
protectedinherited

Specifies the name of the component, for debugging.

Definition at line 122 of file NvElement.h.

◆ is_in_error

int NvElement::is_in_error
protectedinherited

Indicates if an error was encountered during the operation of the element.

Definition at line 120 of file NvElement.h.

Referenced by NvElement::isInError().

◆ profiler

NvElementProfiler NvElement::profiler
protectedinherited

Profiler for the element.

Definition at line 124 of file NvElement.h.


The documentation for this class was generated from the following file: