JPEGE Functions and Restrictions
Function Description
JPEG Encoder (JPEGE) encodes YUV images into JPEG image files, for example, .jpg files.
Resolution Restrictions
|
Model |
Resolution Range |
|---|---|
|
|
32 x 32 to 8192 x 8192 |
|
|
32 x 32 to 16384 x 16384 |
|
Atlas 350 Accelerator Card |
32 x 32 to 32768 x 32768 |
Output image resolution:
JPEGE encodes images without changing the image resolution. Therefore, the output image resolution is the same as the input image resolution.
Restrictions on Buffer Allocation and Freeing APIs
The size of the input buffer is the size of the input stream. For details about the size of the output buffer, see the formula in Restrictions on Image Formats, Width and Height Alignment, and Buffers.
- Input memory allocation/release API::
During JPEGE image encoding, the hi_mpi_dvpp_malloc\hi_mpi_dvpp_free API is called to allocate or release the input buffer on the device. The lifecycle of the buffer is managed by the user.
- Output memory allocation/release API:
- If the output buffer does not need to be managed by the user the output buffer is managed by the DVPP , call the hi_mpi_venc_send_frame API to send the source image for encoding.
When calling the hi_mpi_venc_create_chn API to create a channel, you must correctly set the hi_venc_chn_attr.venc_attr.buf_size parameter. For details about the parameter description, see hi_venc_attr.
In this mode, the JPEG header of the output data does not contain the COM comment field, and the data length is smaller. However, you need to copy the output data from the buffer returned by DVPP to the specified memory.
- The user manages the output buffer and buffer lifecycle, and calls the hi_mpi_venc_send_jpege_frame API to send the source image for encoding.
When calling the hi_mpi_venc_create_chn API to create a channel, set hi_venc_chn_attr.venc_attr.buf_size to 0 (for details about the parameter description, see hi_venc_attr), call the hi_mpi_venc_get_jpege_predicted_size API to estimate the output buffer size, and call the hi_mpi_dvpp_malloc\hi_mpi_dvpp_free API to allocate or free the output buffer.
In this mode, the output buffer address is set when hi_mpi_venc_send_jpege_frame is called. The output data is directly stored in the buffer set by the user. Compared with the other mode, this mode does not require you to copy the output data from the buffer returned by DVPP to the specified memory. However, the JPEG header of the output data may contain the COM comment field (whose length ranges from 4 bytes to 19 bytes), and thus the data length is larger.
- If the output buffer does not need to be managed by the user the output buffer is managed by the DVPP , call the hi_mpi_venc_send_frame API to send the source image for encoding.
For the following product models, the aclrtMalloc\aclrtFree API can be called to allocate or release the input and output memory on the device. The lifecycle of the memory is managed by users.
Atlas 350 Accelerator Card
The memory allocated by calling hi_mpi_dvpp_malloc is the dedicated memory for media data processing. However, the address space of the dedicated memory is limited. If you are concerned about memory planning or memory resources are limited, you are advised to call aclrtMalloc to allocate memory. When the aclrtMalloc interface is called to allocate memory, it is recommended that the memory of the ACL_MEM_MALLOC_HUGE_FIRST type be allocated. The huge page memory is preferentially allocated because the huge page performance is better.
Restrictions on Image Formats, Width and Height Alignment, and Buffers
For details about the input image format, see hi_pixel_format. For details about the width stride and height stride, see Terminology.
The image format, width and height alignment, and buffer size vary depending on the product model.
|
Input Format |
Input Width and Height Alignment |
Input Width Stride, Height Stride, and Buffer Size |
Output Format |
|---|---|---|---|
|
YUV420SP NV12 8bit |
Width: Must be a multiple of 2. Height: Must be a multiple of 2. |
Width stride: No alignment requirements. The value is the same as the width. The height stride does not need to be configured. Buffer size (in bytes) = Width stride x Height x 3/2 |
Output format: JPEG, for example, *.jpg Only Huffman coding is supported. Arithmetic coding and progressive coding are not supported. |
|
YUV420SP NV21 8bit |
|||
|
YUV422Packed YUYV 8bit |
Width: Must be a multiple of 2. Height: No alignment requirement. |
Width stride: No alignment requirements. The value is the same as the width. The height stride does not need to be configured. Buffer size (in bytes) = Width stride x Height |
|
|
YUV422Packed UYVY 8bit |
|||
|
YUV422Packed YVYU 8bit |
|||
|
YUV422Packed VYUY 8bit |
|
Input Format |
Input Width and Height Alignment |
Input Width Stride, Height Stride, and Buffer Size |
Output Format |
|---|---|---|---|
|
YUV420SP NV12 8bit |
Width: Must be a multiple of 2. Height: Must be a multiple of 2. |
Width stride: Round up the width to the nearest multiple of 16 or any multiple of 16, for example, 128 (which offers better performance). The height stride does not need to be configured. Buffer size (in bytes) = Width stride x Height x 3/2 |
Output format: JPEG, for example, *.jpg Only Huffman coding is supported. Arithmetic coding and progressive coding are not supported. |
|
YUV420SP NV21 8bit |
|||
|
YUV422Packed YUYV 8bit |
Width: Must be a multiple of 2. Height: No alignment requirement. |
Width stride: Double the width and then round up the result to the nearest multiple of 16. The height stride does not need to be configured. Buffer size (in bytes) = Width stride x Height |
|
|
YUV422Packed UYVY 8bit |
|||
|
YUV422Packed YVYU 8bit |
|||
|
YUV422Packed VYUY 8bit |