NvJpegEncoder
uses the libjpeg
APIs for decoding JPEG images.
It supports two methods for encoding:
- Encode using a file descriptor (FD) of the MMAP buffer created by a V4L2 element (supports YUV420 and NV12 color formats).
- Encode using data pointers in NvBuffer object, i.e., software allocated memory (
malloc
); supports YUV420 color format.
- Note
- Only the JCS_YCbCr (YUV420) color space is currently supported.
Definition at line 85 of file NvJpegEncoder.h.
|
| ~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...
|
|
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.
- 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. |
[in] | quality | Sets the image quality. |
- Returns
- 0 for success, -1 otherwise.
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.
- 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. |
[in] | quality | Sets the image quality. |
- Returns
- 0 for success, -1 otherwise.