Functions and Restrictions

Function Description

JPEG Decoder (JPEGD) implements .jpg, .jpeg, .JPG, and .JPEG image decoding.

Resolution Restrictions

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

During JPEGD image decoding, acldvppMalloc and acldvppFree are called to allocate and free the input and output buffers on the device. The buffer lifetime is managed by the user.

JPEGD supports only Huffman coding and does not support arithmetic encoding, progressive JPEG format, or JPEG 2000 format. The color space of the input image must be YUV with YUV components in the ratio of 4:4:4, 4:2:2, 4:2:0, 4:0:0, or 4:4:0.

For details about the definition of the output image format, see acldvppPixelFormat. 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 (Ascend 310 AI Processor and Ascend 910 AI Processor)

Input Format (YUV)

Output Format

Output Width and Height

Output Width Stride, Height Stride, and Buffer Size

JPEG(444)

YVU444SP 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3

YUV444SP 8-bit

YUV420SP NV12 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

JPEG(422)

YVU422SP 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 2

YUV422SP 8-bit

YUV420SP NV12 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

JPEG(420)

YUV420SP NV12 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

JPEG(400)

YUV420SP NV12 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

JPEG(440)

YVU440SP 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 2

YUV440SP 8-bit

YUV420SP NV12 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 128.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

Table 2 Restrictions on the image format, width and height alignment, and buffer size (Ascend 310P AI Processor)

Input Format (YUV)

Output Format

Output Width and Height

Output Width Stride, Height Stride, and Buffer Size

JPEG(444)

YVU444SP 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3

YUV444SP 8-bit

YUV420SP NV12 8-bit

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 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

JPEG(422)

YVU422SP 8-bit

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 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 2

YUV422SP 8-bit

YUV420SP NV12 8-bit

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 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

JPEG(420)

YUV420SP NV12 8-bit

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 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

JPEG(400)

YUV420SP NV12 8-bit

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 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

YUV400 8-bit

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride

JPEG(440)

YVU440SP 8-bit

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 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 2

YUV440SP 8-bit

YUV420SP NV12 8-bit

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 64.

Height stride: Round up the height to the nearest multiple of 16.

Buffer size (in bytes) ≥ Width stride x Height stride x 3/2

YUV420SP NV21 8-bit

Requirements for Software and Hardware

Accuracy Restrictions

Ascend 310 AI Processor and Ascend 910 AI Processor: In the event of JPEGD+VPC cascade, widthStride x heightStride of the JPEGD output image must be a multiple of 128 x 16, so there are some invalid paddings. Therefore, when executing VPC Functions such as resizing, call the acldvppSetPicDescWidth and acldvppSetPicDescHeight APIs to set the original width and height of the input image. As such, VPC will automatically crop the image based on the width and height of the source image and then resize the image, eliminating the impact of invalid data on image accuracy.

Ascend 310P AI Processor: In the event of JPEGD+VPC cascade, widthStride x heightStride of the JPEGD output image must be a multiple of 64 x 16, so there are some invalid paddings. Therefore, when executing VPC Functions such as resizing, call the acldvppSetPicDescWidth and acldvppSetPicDescHeight APIs to set the original width and height of the input image. As such, VPC will automatically crop the image based on the width and height of the original image and then resize the image, eliminating the impact of invalid data on image accuracy.