JPEGE Functions and Restrictions

The Atlas training products does not support the JPEGE function described in this section.

Function Usage

JPEG Encoder (JPEGE) encodes YUV images into JPEG images, for example, .jpg images.

Resolution Restrictions

  • Input image resolution range

    Version

    Resolution Range

    Atlas inference products

    Atlas A2 training products/Atlas A2 inference products

    Atlas A3 training products/Atlas A3 inference products

    32 x 32 to 8192 x 8192

    Atlas 200I/500 A2 inference products

    32 x 32 to 16384 x 16384

  • Output resolution range:

    JPEGE only encodes images and does not change the image resolution. Therefore, the resolution of the output image is the same as that of the input image.

Restrictions on Buffer Allocation and Freeing APIs

The size of the input buffer refers to the actual size occupied by input streams. For details about the size of the output buffer, see the formula in Table 1.

Version

Input Buffer Allocation/Freeing API

Input Buffer Allocation/Freeing API

Atlas inference products

During JPEGE image encoding, call acl.himpi.dvpp_malloc/acl.himpi.dvpp_free to allocate or free the input buffer on the device. The buffer lifetime is managed by the user.

The following two methods are supported:
  • Managed by DVPP: Call acl.himpi.venc_send_frame to send source images for encoding.

    Correctly set the attribute value of hi_venc_chn_attr["venc_attr"]["buf_size"] When creating a channel by calling acl.himpi.venc_create_chn. For 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.

  • Managed by users: Call acl.himpi.venc_send_jpege_frame to send source images for encoding.

    When creating a channel by calling acl.himpi.venc_create_chn, set hi_venc_chn_attr["venc_attr"]["buf_size"] to 0 (for details about the parameter description, see hi_venc_attr). Then call acl.himpi.venc_get_jpege_predicted_size to estimate the output memory size, and call acl.himpi.dvpp_malloc or acl.himpi.dvpp_free to allocate or free the output memory.

    In this mode, the output buffer address is set when acl.himpi.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.

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas A3 training products/Atlas A3 inference products

During JPEGE image encoding, the following two types of buffer allocation/freeing APIs are supported:

Note: acl.himpi.dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer planning is cared or buffer resources are limited, you are advised to allocate buffer by calling acl.rt.malloc.

The following two methods are supported:
  • Managed by DVPP: Call acl.himpi.venc_send_frame to send source images for encoding.

    Correctly set the attribute value of hi_venc_chn_attr["venc_attr"]["buf_size"] When creating a channel by calling acl.himpi.venc_create_chn. For 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.

  • Managed by users: Call acl.himpi.venc_send_jpege_frame to send source images for encoding.

    When creating a channel by calling acl.himpi.venc_create_chn, set hi_venc_chn_attr["venc_attr"]["buf_size"] to 0 (for details about the parameter description, see hi_venc_attr), estimate the output memory size by calling acl.himpi.venc_get_jpege_predicted_size, and allocate or release the output memory by calling acl.himpi.dvpp_malloc\acl.himpi.dvpp_free. (You can also allocate or release the output memory on the device by calling acl.rt.malloc\acl.rt.free.)

    In this mode, the output buffer address is set when acl.himpi.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.

Restrictions on Image Formats, Width and Height Alignment, and Buffers

For details about the definition of the input image format, see hi_pixel_format. For details about the concepts such as width stride and height stride, see Terminology.

Table 1 Restrictions on the image format, width and height alignment, and buffer size

Input Format

Input Width and Height

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