VPC Restrictions

Resolution Restrictions

Input Image Resolution Range

During image processing by VPC, the general input resolution ranges from 10 × 6 to 8192 × 8192. The resolution restrictions of some APIs may be different. For details, see the API descriptions in VPC. When the input image format is YUV440SP or YUV440P, the maximum width of the image is 4096.

Output Resolution Range

Model

Resolution Range

Atlas inference products

10*6~4096*4096

Ascend 950PR / Ascend 950DT

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

10*6~4096*8192

APIs for Buffer Allocation and Freeing

During image processing by VPC, call hi_mpi_dvpp_malloc to allocate the input and output buffers on the device, and hi_mpi_dvpp_free to free the input and output buffers. The buffer lifetime 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, you can also call aclrtMalloc and aclrtFree to allocate and free the input and output buffers on the device. The buffer lifetime is managed by the users.

Ascend 950PR / Ascend 950DT

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

hi_mpi_dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer planning is considered or buffer resources are limited, you are advised to allocate a buffer by calling aclrtMalloc. When calling aclrtMalloc to allocate a buffer, you are advised to allocate the buffer of the ACL_MEM_MALLOC_HUGE_FIRST type. Huge page buffers are preferred because they have better performance.

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 Basic Concepts.
  • Different APIs may have different requirements on image formats. For details, see the API descriptions in VPC.
Table 1 Restrictions on input image formats, width and height alignment, and buffer size for Ascend 950PR / Ascend 950DT

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: a multiple of 2

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

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

Width stride × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV422Packed YUYV 8bit

YUV422Packed UYVY 8bit

YUV422Packed YVYU 8bit

YUV422Packed VYUY 8bit

Width: a multiple of 2

Height: No alignment requirements.

Width stride: Width × 2.

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

Width stride × Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirements.

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

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

Width stride × Height stride × 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

Width stride: Width × 4.

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

Width stride × Height stride

YUV440SP 8bit

YVU440SP 8bit

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

Height: a multiple of 2

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

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

Width stride × Height stride × 2

Table 2 Restrictions on output image formats, width and height alignment, and buffer size for Ascend 950PR / Ascend 950DT

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: a multiple of 2

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

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

Width stride × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

Width stride: Width × 4.

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

Width stride × Height stride

Table 3 Restrictions on input image formats, width and height alignment, and buffer size for Atlas A3 training products / Atlas A3 inference products and Atlas A2 training products / Atlas A2 inference products

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: a multiple of 2

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

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

Width stride × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV422Packed YUYV 8bit

YUV422Packed UYVY 8bit

YUV422Packed YVYU 8bit

YUV422Packed VYUY 8bit

Width: a multiple of 2

Height: No alignment requirements.

Width stride: Width × 2.

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

Width stride × Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirements.

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

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

Width stride × Height stride × 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

Width stride: Width × 4.

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

Width stride × Height stride

YUV440SP 8bit

YVU440SP 8bit

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

Height: a multiple of 2

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

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

Width stride × Height stride × 2

YVU420Planar

YUV420Planar

Both width and height: 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 × Height stride × 3/2

YVU422Planar

YUV422Planar

No alignment requirements.

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 × Height stride × 2

YVU444Planar

YUV444Planar

No alignment requirements.

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 × Height stride × 3

YVU444Packed 8bit

No alignment requirements.

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

Width stride × Height stride

YUV440Planar

YVU440Planar

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

Height: 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 × Height stride × 2

RGB888Planar

BGR888Planar

No alignment requirements.

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 × Height stride × 3

YUV400 FP32

No alignment requirements.

Width stride: No alignment requirements, but the value must be the width × 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height.

Width stride × Height stride

RGB888 FP32

BGR888 FP32

No alignment requirements.

Width stride: No alignment requirements, but the value must be the width × 3 × 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height.

Width stride × Height stride

RGB888Planar FP32

BGR888Planar FP32

No alignment requirements.

Width stride: No alignment requirements, but the value must be the width × 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height.

Width stride × Height stride × 3

Table 4 Restrictions on output image formats, width and height alignment, and buffer size for Atlas A3 training products / Atlas A3 inference products and Atlas A2 training products / Atlas A2 inference products

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: a multiple of 2

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

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

Width stride × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

Width stride: Width × 4.

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

Width stride × 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 requirements.

Height: a multiple of 2

Width stride: Width × 2.

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

Width stride × Height stride

YVU444Packed

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

RGB888Planar

BGR888Planar

No alignment requirements.

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 × Height stride × 3

YUV400 FP32

No alignment requirements.

Width stride: No alignment requirements, but the value must be the width × 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height.

Width stride × Height stride

RGB888 FP32

BGR888 FP32

No alignment requirements.

Width stride: No alignment requirements, but the value must be the width × 3 × 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height.

Width stride × Height stride

RGB888Planar FP32

BGR888Planar FP32

No alignment requirements.

Width stride: No alignment requirements, but the value must be the width × 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height.

Width stride × Height stride × 3

Table 5 Restrictions on input image formats, width and height alignment, and buffer size for Atlas 200I/500 A2 inference products

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: a multiple of 2

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

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

Width stride × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV422Packed YUYV 8bit

YUV422Packed UYVY 8bit

YUV422Packed YVYU 8bit

YUV422Packed VYUY 8bit

Width: a multiple of 2

Height: No alignment requirements.

Width stride: Width × 2.

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

Width stride × Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirements.

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

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

Width stride × Height stride × 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

Width stride: Width × 4.

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

Width stride × Height stride

YUV440SP 8bit

YVU440SP 8bit

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

Height: a multiple of 2

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

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

Width stride × Height stride × 2

YVU420Planar

YUV420Planar

Both width and height: 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 × Height stride × 3/2

YVU422Planar

YUV422Planar

No alignment requirements.

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 × Height stride × 2

YVU444Planar

YUV444Planar

No alignment requirements.

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 × Height stride × 3

YVU444Packed 8bit

No alignment requirements.

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

Width stride × Height stride

YUV440Planar

YVU440Planar

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

Height: 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 × Height stride × 2

RGB888Planar

BGR888Planar

No alignment requirements.

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 × Height stride × 3

Table 6 Restrictions on output image formats, width and height alignment, and buffer size for Atlas 200I/500 A2 inference products

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: a multiple of 2

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

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

Width stride × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

Width stride: Width × 4.

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

Width stride × 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 requirements.

Height: a multiple of 2

Width stride: Width × 2.

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

Width stride × Height stride

YVU444Packed

No alignment requirements.

Width stride: Width × 3.

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

Width stride × Height stride

RGB888Planar

BGR888Planar

No alignment requirements.

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 × Height stride × 3

Table 7 Restrictions on input image formats, width and height alignment, and buffer size for Atlas inference products

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: 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 × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV422Packed YUYV 8bit

YUV422Packed UYVY 8bit

YUV422Packed YVYU 8bit

YUV422Packed VYUY 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

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

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

Width stride × Height stride

YUV444SP 8bit

YVU444SP 8bit

No alignment requirements.

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

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

Width stride × Height stride × 3

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

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

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

Width stride × Height stride

YUV440SP 8bit

YVU440SP 8bit

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

Height: 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 × Height stride × 2

Table 8 Restrictions on output image formats, width and height alignment, and buffer size for Atlas inference products

Model

Image Format

Width × Height Alignment

Width Stride × Height Stride Alignment

Buffer Size (in Bytes)

General format, supported by all models

YUV400 8bit

No alignment requirements.

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

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

Width stride × Height stride

YUV420SP NV12 8-bit

YUV420SP NV21 8-bit

Width: a multiple of 2

Height: 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 × Height stride × 3/2

YUV422SP 8bit

YVU422SP 8bit

Width: a multiple of 2

Height: No alignment requirements.

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

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

Width stride × Height stride × 2

YUV444Packed 8bit

RGB888

BGR888

No alignment requirements.

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

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

Width stride × Height stride

ARGB8888

ABGR8888

RGBA8888

BGRA8888

No alignment requirements.

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

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

Width stride × Height stride

The minimum and maximum values of the width stride and height stride vary with product models.

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

    Ascend 950PR / Ascend 950DT

    Atlas A3 training products / Atlas A3 inference products

    Atlas A2 training products / Atlas A2 inference products

    Atlas 200I/500 A2 inference products

  • The width stride ranges from 32 to 16384 (4096 × 4). For a 4096-pixel ARGB image, one pixel occupies four bytes, and a line of pixels occupies 4096 × 4. The height stride ranges from 6 to 16384. This applies to the following product models:

    Atlas inference products

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 crop and paste ROIs:

    If the output image is in YUV420SP format, the left offset and top offset of the paste 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 of the paste ROI 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.
    Due to the 16-pixel alignment requirement, the following restrictions apply to Atlas inference products :
    • Round up the left offset of the paste ROI to the nearest multiple of 16. The paste ROI can locate on the leftmost side of the output image. That means the left offset relative to the output image is 0, which also meets the 16-pixel alignment requirement.
    • It is recommended that the paste ROI width be rounded up to the nearest multiple of 16. Otherwise, invalid extra data will be padded 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 paste 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.

    • For resizing with the aspect ratio preserved, the left offset for pasting must be a multiple of 16. Therefore, the hi_mpi_vpc_crop_resize_paste call may result in paste ROI deviation from the center of the output image. In this case, you can add the hi_mpi_vpc_crop_resize_make_border or hi_mpi_vpc_batch_crop_resize_make_border call to implement the cropping, resizing, and padding functions together.

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 is downsampled, has such restrictions due to the data format. Therefore, abnormal data may exist on the output image borders.

Figure 1 Example of abnormal images

The root cause is that during the computation, when the output image is at an odd starting 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.