NvJPEGEncoder Class Reference
[Image Encode]

NvJpegEncoder uses the libjpeg APIs for encoding JPEG images. More...

#include <NvJpegEncoder.h>

Inheritance diagram for NvJPEGEncoder:

NvElement

List of all members.

Public Member Functions

 ~NvJPEGEncoder ()
int encodeFromFd (int fd, J_COLOR_SPACE color_space, unsigned char **out_buf, unsigned long &out_buf_size)
 Encodes a JPEG image from a file descriptor (FD) of hardware buffer memory.
int encodeFromBuffer (NvBuffer &buffer, J_COLOR_SPACE color_space, unsigned char **out_buf, unsigned long &out_buf_size)
 Encodes a JPEG image from software buffer memory.
void setCropRect (uint32_t left, uint32_t top, uint32_t width, uint32_t height)
 Set the cropping rectangle to be used by the jpeg encoder.

Static Public Member Functions

static NvJPEGEncodercreateJPEGEncoder (const char *comp_name)
 Create a new JPEG Encoder named comp_name.

Private Member Functions

 NvJPEGEncoder (const char *comp_name)

Private Attributes

struct jpeg_compress_struct cinfo
struct jpeg_error_mgr jerr

Static Private Attributes

static const
NvElementProfiler::ProfilerField 
valid_fields


Detailed Description

NvJpegEncoder uses the libjpeg APIs for encoding JPEG images.

It supports two methods for encoding:

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

Definition at line 85 of file NvJpegEncoder.h.


Constructor & Destructor Documentation

NvJPEGEncoder::~NvJPEGEncoder (  ) 

Definition at line 62 of file NvJpegEncoder.cpp.

NvJPEGEncoder::NvJPEGEncoder ( const char *  comp_name  )  [private]

Definition at line 39 of file NvJpegEncoder.cpp.


Member Function Documentation

NvJPEGEncoder * NvJPEGEncoder::createJPEGEncoder ( const char *  comp_name  )  [static]

Create a new JPEG Encoder named comp_name.

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

Definition at line 51 of file NvJpegEncoder.cpp.

int NvJPEGEncoder::encodeFromBuffer ( NvBuffer buffer,
J_COLOR_SPACE  color_space,
unsigned char **  out_buf,
unsigned long &  out_buf_size 
)

Encodes a JPEG image from software buffer memory.

The application may allocate the memory for storing the JPEG image. If the allocation is less than what is required, libjpeg allocates more memory. The out_buf pointer and out_buf_size are updated accordingly.

The encodeFromBuffer method is slower than NvJPEGEncoder::encodeFromFd because encodeFromBuffer involves conversion from software buffer memory to hardware buffer memory.

Supports YUV420 format only.

Attention:
The application must free the out_buf memory.
Parameters:
[out] buffer Indicates the NvBuffer object to contain the encoded image.
[out] color_space Indicates the color_space to use for encoding.
[in] out_buf Specifies a pointer to the memory for the JPEG image.
[in] out_buf_size Specifies the size of the output buffer in bytes.
Returns:
0 for success, -1 otherwise.

Definition at line 122 of file NvJpegEncoder.cpp.

int NvJPEGEncoder::encodeFromFd ( int  fd,
J_COLOR_SPACE  color_space,
unsigned char **  out_buf,
unsigned long &  out_buf_size 
)

Encodes a JPEG image from a file descriptor (FD) of hardware buffer memory.

The application may allocate the memory for storing the JPEG image. If the allocation is less than what is required, libjpeg allocates more memory. The out_buf pointer and out_buf_size are updated accordingly.

Supports YUV420 and NV12 formats.

Attention:
The application must free the out_buf memory.
Parameters:
[out] fd Indicates the file descriptor (FD) of the hardware buffer.
[out] color_space Indicates the color_space to use for encoding.
[in] out_buf Specifies a pointer to the memory for the JPEG image.
[in] out_buf_size Specifies the size of the output buffer in bytes.
Returns:
0 for success, -1 otherwise.

Definition at line 69 of file NvJpegEncoder.cpp.

void NvJPEGEncoder::setCropRect ( uint32_t  left,
uint32_t  top,
uint32_t  width,
uint32_t  height 
)

Set the cropping rectangle to be used by the jpeg encoder.

This method should be called before encodeFromFd or encodeFromBuffer for the cropping to take effect.

Attention:
The jpeg encoder resets the crop paramaters after each call to jpeg_finish_compress. Hence, this method must be called before every call to encodeFromFd or encodeFromBuffer.
Parameters:
[in] left Horizontal offset of the cropping rectangle, in pixels
[in] top Vertical offset of the cropping rectangle, in pixels
[in] width Width of the cropping rectangle, in pixels
[in] height Height of the cropping rectangle, in pixels

Definition at line 277 of file NvJpegEncoder.cpp.


Member Data Documentation

struct jpeg_compress_struct NvJPEGEncoder::cinfo [read, private]

Definition at line 167 of file NvJpegEncoder.h.

struct jpeg_error_mgr NvJPEGEncoder::jerr [read, private]

Definition at line 168 of file NvJpegEncoder.h.


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

Generated on Wed Nov 9 19:52:25 2016 for NVIDIA Tegra Multimedia API Framework by  doxygen 1.5.8