Restrictions

Resolution Restrictions

Input image resolution::

When the VPC processes images, the general input resolution ranges from 10 x 6 to 8192 x 8192. The resolution restrictions of some APIs may be different. For details, see the description of each API in VPC. When the input image format is YUV440SP or YUV440P, the maximum width of the image is 4096.

Output image resolution:

Model

Resolution Range

Atlas inference product

10*6~4096*4096

Atlas 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

10*6~4096*8192

Restrictions on Buffer Allocation and Freeing APIs

When the VPC processes images, the hi_mpi_dvpp_malloc API needs to be called to allocate the input and output buffers on the device, and the hi_mpi_dvpp_free API needs to be called to release the input and output buffers. The lifecycle of the buffers is managed by the user. For details about the requirements on the input and output buffer sizes, see the calculation formulas in Restrictions on Image Formats, Width and Height Alignment, and Buffers.

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

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

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

To implement VPC functions with related APIs:

  • For details about the image format, see hi_pixel_format. For details about the width stride and height stride, see Terminology.
  • Each interface may have different requirements on the image format. For details, see the description of each interface in VPC.

The image format, width and height alignment, and memory restrictions vary depending on the product model.

Table 1 Atlas 350 Accelerator CardRestrictions on the input image format, width and height alignment, and buffer size

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride

YUV420SP NV12 8bit

YUV420SP NV21 8bit

Width: Must be a multiple of 2.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 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 = Width x 2

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride = Width x 4

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV440SP 8bit

YVU440SP 8bit

Width: No alignment requirements, but the width must be ≤ 4096.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

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

Width stride x Height stride x 2

Table 2 Atlas 350 Accelerator Card Restrictions on the output image format, width and height alignment, and buffer size

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride

YUV420SP NV12 8bit

YUV420SP NV21 8bit

Width: Must be a multiple of 2.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride = Width x 4

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

Table 3 Restrictions on the input image format, width and height alignment, and buffer size of Atlas A3 training product / Atlas A3 inference product and Atlas A2 training product / Atlas A2 inference product

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride

YUV420SP NV12 8bit

YUV420SP NV21 8bit

Width: Must be a multiple of 2.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 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 = Width x 2

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride = Width x 4

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV440SP 8bit

YVU440SP 8bit

Width: No alignment requirements, but the width must be ≤ 4096.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

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

Width stride x Height stride x 2

YVU420Planar

YUV420Planar

Width: Must be a multiple of 2. Height: Must be a multiple of 2.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3/2

YVU422Planar

YUV422Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 2

YVU444Planar

YUV444Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3

YVU444Packed 8bit

No alignment requirement.

Width stride: No alignment requirement. Width stride = Width x 3. Height stride: No alignment requirement. The value is the same as height.

Width stride x Height stride

YUV440Planar

YVU440Planar

Width: No alignment requirement, but the width must be ≤ 4096.

Height: Must be a multiple of 2.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 2

RGB888Planar

BGR888Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3

YUV400 FP32

No alignment requirement.

The width stride does not need to be aligned. The width stride is the value of width x 4 (4 indicates that FP32 occupies four bytes). The height stride does not need to be aligned and must be the same as the height.

Width stride x Height stride

RGB888 FP32

BGR888 FP32

No alignment requirement.

The width stride does not need to be aligned. The width stride is the value of width x 3 x 4 (4 indicates that FP32 occupies four bytes). The height stride does not need to be aligned and must be the same as the height.

Width stride x Height stride

RGB888Planar FP32

BGR888Planar FP32

No alignment requirement.

The width stride does not need to be aligned. The width stride is the value of width x 4 (4 indicates that FP32 occupies four bytes). The height stride does not need to be aligned and must be the same as the height.

Width stride x Height stride x 3

Table 4 Restrictions on the output image format, width and height alignment, and buffer size of Atlas A3 training product / Atlas A3 inference product and Atlas A2 training product / Atlas A2 inference product

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride

YUV420SP NV12 8bit

YUV420SP NV21 8bit

Width: Must be a multiple of 2.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride = Width x 4

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV422Packed YUYV 8bit

YUV422Packed UYVY 8bit

YUV422Packed YVYU 8bit

YUV422Packed VYUY 8bit

Note that only the remapping function supports the YUV422P output image format.

Width: No alignment requirement.

Height: Must be a multiple of 2.

Width stride = Width x 2

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YVU444Packed

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

RGB888Planar

BGR888Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3

YUV400 FP32

No alignment requirement.

The width stride does not need to be aligned. The width stride is the value of width x 4 (4 indicates that FP32 occupies four bytes). The height stride does not need to be aligned and must be the same as the height.

Width stride x Height stride

RGB888 FP32

BGR888 FP32

No alignment requirement.

The width stride does not need to be aligned. The width stride is the value of width x 3 x 4 (4 indicates that FP32 occupies four bytes). The height stride does not need to be aligned and must be the same as the height.

Width stride x Height stride

RGB888Planar FP32

BGR888Planar FP32

No alignment requirement.

The width stride does not need to be aligned. The width stride is the value of width x 4 (4 indicates that FP32 occupies four bytes). The height stride does not need to be aligned and must be the same as the height.

Width stride x Height stride x 3

Table 5 Atlas 200I/500 A2 inference product Restrictions on the input image format, width and height alignment, and buffer size

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride

YUV420SP NV12 8bit

YUV420SP NV21 8bit

Width: Must be a multiple of 2.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 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 = Width x 2

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride = Width x 4

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV440SP 8bit

YVU440SP 8bit

Width: No alignment requirements, but the width must be ≤ 4096.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

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

Width stride x Height stride x 2

YVU420Planar

YUV420Planar

Width: Must be a multiple of 2. Height: Must be a multiple of 2.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3/2

YVU422Planar

YUV422Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 2

YVU444Planar

YUV444Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3

YVU444Packed 8bit

No alignment requirement.

Width stride: No alignment requirement. Width stride = Width x 3. Height stride: No alignment requirement. The value is the same as height.

Width stride x Height stride

YUV440Planar

YVU440Planar

Width: No alignment requirement, but the width must be ≤ 4096.

Height: Must be a multiple of 2.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 2

RGB888Planar

BGR888Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3

Table 6 Atlas 200I/500 A2 inference product Restrictions on the output image format, width and height alignment, and buffer size

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride

YUV420SP NV12 8bit

YUV420SP NV21 8bit

Width: Must be a multiple of 2.

Height: Must be a multiple of 2.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

Width stride: No alignment requirement. The value is the same as width.

No alignment requirements on the height stride but must be the same as height.

Width stride x Height stride x 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride = Width x 4

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV422Packed YUYV 8bit

YUV422Packed UYVY 8bit

YUV422Packed YVYU 8bit

YUV422Packed VYUY 8bit

Note that only the remapping function supports the YUV422P output image format.

Width: No alignment requirement.

Height: Must be a multiple of 2.

Width stride = Width x 2

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YVU444Packed

No alignment requirement.

Width stride = Width x 3

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

RGB888Planar

BGR888Planar

No alignment requirement.

Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height.

Width stride x Height stride x 3

Table 7 Atlas inference product Restrictions on the input image format, width and height alignment, and buffer size

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirement.

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

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

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.

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

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

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

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride x 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: Round up the width to the nearest multiple of 16 and multiply the result by 2.

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 3.

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirement.

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

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride x 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 4.

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

YUV440SP 8bit

YVU440SP 8bit

Width: No alignment requirements, but the width must be ≤ 4096.

Height: Must be a multiple of 2.

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

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

Width stride x Height stride x 2

Table 8 Atlas inference product Restrictions on the output image format, width and height alignment, and buffer size

Model

Image format

Width x Height Alignment

Width Stride x Height Stride Alignment

Buffer Size (in Bytes)

General format, supported by all models

YUV400 8bit

No alignment requirement.

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

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

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.

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

Width stride x Height stride x 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: Must be a multiple of 2.

Height: No alignment requirement.

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

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride x 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 3.

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 4.

Height stride: No alignment requirements. The value is the same as the height.

Width stride x Height stride

The minimum or maximum width stride and height stride vary according to product models.

  • The minimum width stride is 10 and the minimum height stride is 6, which applies to the following product models:

    Atlas 350 Accelerator Card

    Atlas A3 training product / Atlas A3 inference product

    Atlas A2 training product / Atlas A2 inference product

    Atlas 200I/500 A2 inference product

  • The minimum width stride is 32 and the maximum width stride is 16384. (16384=4096 x 4. For a 4096-pixel ARGB image, one pixel occupies four bytes, and a line of pixels occupies 4096 x 4.) The minimum height stride is 6 and the maximum height stride is 16384. The following models are supported:

    Atlas inference product

Restrictions on Image Cropping and Pasting

  • The crop ROI must not be larger than the input image.
  • Restrictions on the odd and even numbers of the cropped and pasted ROIs:

    If the output image is in YUV420SP format, the left offset and top offset of the pasted ROI must be even numbers, and the right offset and bottom offset must be odd numbers.

    If the output image is in YUV422SP format, the left offset must be an even number and the right offset must be an odd number.

    For other formats, there are no such limits.

  • The paste ROI must not be larger than the output image. A maximum of 256 paste ROIs are supported.
    On Atlas inference product , the following constraints exist due to the 16-byte alignment requirements:
    • Round up the left offset of the paste ROI to the nearest multiple of 16. The pasted ROI can locate on the leftmost side of the output image, that is, with zero left offset relative to the output image.
    • Round up the output paste ROI width to the nearest multiple of 16. Otherwise, padding is performed to meet the alignment requirement.

      For inference, when the VPC output is used as the input of model inference, if the width of the valid pasted ROI is not a multiple of 16, you can resize this width to a multiple of 16 before pasting, or use AIPP to crop the valid ROI and remove invalid data to ensure inference accuracy.

    • In the proportional resizing scenario, the left offset of the pasted image is 16-pixel aligned. If the hi_mpi_vpc_crop_resize_paste API is directly called to implement the resizing function, the pasted image may not be in the center of the output image. In this case, you can use the cropping, resizing, and padding functions together (by calling the hi_mpi_vpc_crop_resize_make_border or hi_mpi_vpc_batch_crop_resize_make_border API). Implements proportional scaling.

Restrictions on Downsampling of YUV Images

VPC converts the input image format to YUV444 or RGB for internal processing based on the input or output image format. YUV444 or RGB output format has no restriction on the odd and even numbers of the width and height, while the YUV420SP or YUV422SP output format, which performs downsampling processing, has such restrictions due to the data format. Therefore, abnormal data may exist on the output image boarders.

Figure 1 Example of abnormal images

The root cause is that during the computation, when the output image is at an odd start point, the image is correct for the YUV444 format. However, when the YUV420SP format is downsampled, the odd and even lines share the same UV. In this case, the Y of the start line and the UV of the previous line form a new pixel and abnormal data is generated.