NvJpegEncoder
uses the libjpeg
APIs for decoding JPEG images.
It supports two methods for encoding:
malloc
); supports YUV420 color format.Definition at line 85 of file NvJpegEncoder.h.
Public Member Functions | |
~NvJPEGEncoder () | |
int | encodeFromFd (int fd, J_COLOR_SPACE color_space, unsigned char **out_buf, unsigned long &out_buf_size, int quality=75) |
Encodes a JPEG image from a file descriptor (FD) of hardware buffer memory. More... | |
int | encodeFromBuffer (NvBuffer &buffer, J_COLOR_SPACE color_space, unsigned char **out_buf, unsigned long &out_buf_size, int quality=75) |
Encodes a JPEG image from software buffer memory. More... | |
void | setCropRect (uint32_t left, uint32_t top, uint32_t width, uint32_t height) |
Sets the cropping rectangle used by the JPEG encoder. More... | |
void | setScaledEncodeParams (uint32_t scale_width, uint32_t scale_height) |
Sets scaling parameters by which image needs to be scaled and encoded. 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 NvJPEGEncoder * | createJPEGEncoder (const char *comp_name) |
Creates a new JPEG encoder 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... | |
NvJPEGEncoder::~NvJPEGEncoder | ( | ) |
|
static |
Creates a new JPEG encoder named comp_name.
|
virtualinherited |
Enables profiling for the element.
Reimplemented in NvV4l2Element.
int NvJPEGEncoder::encodeFromBuffer | ( | NvBuffer & | buffer, |
J_COLOR_SPACE | color_space, | ||
unsigned char ** | out_buf, | ||
unsigned long & | out_buf_size, | ||
int | quality = 75 |
||
) |
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 the YUV420 format only.
[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. |
[in] | quality | Sets the image quality. |
int NvJPEGEncoder::encodeFromFd | ( | int | fd, |
J_COLOR_SPACE | color_space, | ||
unsigned char ** | out_buf, | ||
unsigned long & | out_buf_size, | ||
int | quality = 75 |
||
) |
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.
[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. |
[in] | quality | Sets the image quality. |
|
inherited |
Gets profiling data for the element.
|
inlinevirtualinherited |
Indicates whether the element encountered an error during its operation.
Reimplemented in NvV4l2Element.
Definition at line 72 of file NvElement.h.
References NvElement::is_in_error.
|
inherited |
Checks whether profiling is enabled for the element.
|
inherited |
Prints profiling data for the element to an output stream.
[in] | out_stream | Output stream of type std::ostream to print the data to. It takes the default value std::cout if not specified. |
void NvJPEGEncoder::setCropRect | ( | uint32_t | left, |
uint32_t | top, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Sets the cropping rectangle used by the JPEG encoder.
This method must be called before encodeFromFd or encodeFromBuffer for the cropping to take effect.
[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. |
void NvJPEGEncoder::setScaledEncodeParams | ( | uint32_t | scale_width, |
uint32_t | scale_height | ||
) |
Sets scaling parameters by which image needs to be scaled and encoded.
This method must be called before encodeFromFd or encodeFromBuffer for scaled encoding to take effect.
[in] | scale_width | Specifies width of the scaled image. |
[in] | scale_height | Specifies height of the scaled image. |
|
protectedinherited |
Specifies the name of the component, for debugging.
Definition at line 122 of file NvElement.h.
|
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().
|
protectedinherited |
Profiler for the element.
Definition at line 124 of file NvElement.h.