Functions and Restrictions

Function Description

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

Resolution Restrictions

Input image resolution::

Model

Resolution Range

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas inference product

Atlas training product

32 x 32 to 8192 x 8192

Atlas 200I/500 A2 inference product

32 x 32 to 16384 x 16384

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 Image Formats, Width and Height Alignment, and Buffers

To implement the JPEGE function:

  • Call the acldvppMalloc API to allocate the input and output buffers on the device, and call the acldvppFree API to free the input and output buffers. The lifecycle of the buffers is managed by the user.
    • The input buffer size refers to the size of the buffer for storing the input image. For details, see the formula in the following table.
    • The size of the output buffer is the size of the encoded image. You can call the acldvppJpegPredictEncSize API to estimate the size of the output buffer.
  • The following table lists the supported input image formats.

    For the definition of the input image format, see acldvppPixelFormat.

  • The following table describes the requirements on the width stride and height stride of the input image.

    For details about the width stride and height stride, see Terminology.

  • The output image is a JPEG image, for example, *.jpg. Only Huffman encoding is supported. Arithmetic encoding and progressive encoding are not supported.
Table 1 Restrictions on the input image format, width and height alignment, and buffer size

Input formats:

Input Width and Height Alignment

Width stride and height stride of the input image

Memory requirements for the input image

YUV420SP NV12 8bit

YUV420SP NV21 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 can be set to the height of the input image or a value that is rounded up to the nearest multiple of 16 (at least 32). This alignment mode can be used when the JPEGD output image is directly used as the JPEGE input (the height of the JPEGD output image is rounded up to the nearest multiple of 16).

Buffer size (in bytes) = Width stride × Height stride × 3/2

YUV422Packed YUYV 8bit

YUV422Packed UYVY 8bit

YUV422Packed YVYU 8bit

YUV422Packed VYUY 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 can be set to the height of the input image or a value that is rounded up to the nearest multiple of 16 (at least 32). This alignment mode can be used when the JPEGD output image is directly used as the JPEGE input (the height of the JPEGD output image is rounded up to the nearest multiple of 16).

Buffer size (in bytes) = Width stride × Height stride