During image processing by VPC, 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.
For the Ascend 310 AI Processor and Ascend 910 AI Processor, the restrictions on the image format and width and height alignment are listed below. For details, see Table 1 and Table 2. In the 8K scenario, the input image format must be YUV420SP NV12 8-bit or YUV420SP NV21 8-bit.
To implement VPC functions with related APIs:
Input Format |
Input Width and Height |
Input Width Stride, Height Stride, and Buffer Size |
|---|---|---|
YUV400 8-bit |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride x 3/2 |
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 16. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride x 3/2 |
YUV420SP NV21 8-bit |
||
YUV422SP 8-bit |
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: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride x 2 |
YVU422SP 8-bit |
||
YUV444SP 8-bit |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride x 3 |
YVU444SP 8-bit |
||
YUV422 Packed YUYV 8-bit |
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: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride |
YUV422 Packed UYVY 8-bit |
||
YUV422 Packed YVYU 8-bit |
||
YUV422 Packed VYUY 8-bit |
||
YUV444 Packed 8-bit |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 3. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride |
RGB888 |
||
BGR888 |
||
ARGB8888 |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 4. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride |
ABGR8888 |
||
RGBA8888 |
||
BGRA8888 |
Output Format |
Output Width and Height |
Output Width Stride, Height Stride, and Buffer Size |
|---|---|---|
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 16. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride x 3/2 |
YUV420SP NV21 8-bit |
Input Format |
Input Width and Height |
Input Width Stride, Height Stride, and Buffer Size |
|---|---|---|
YUV400 8-bit |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: Has no alignment requirements but must be the same as height. Buffer size (in bytes) = Width stride x Height stride |
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 16. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride x 3/2 |
YUV420SP NV21 8-bit |
||
YUV422SP 8-bit |
Width: Must be a multiple of 2. Height: No alignment requirement. |
The width stride is 16-pixel aligned. The height stride can be the same as the height stride. Buffer size (in bytes) = Width stride x Height stride x 2 |
YVU422SP 8-bit |
||
YUV444SP 8-bit |
No alignment requirement. |
The width stride is 16-pixel aligned. The height stride can be the same as the height stride. Buffer size (in bytes) = Width stride x Height stride x 3 |
YVU444SP 8-bit |
||
YUV422 Packed YUYV 8-bit |
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: Has no alignment requirements but must be the same as height. Buffer size (in bytes) = Width stride x Height stride |
YUV422 Packed UYVY 8-bit |
||
YUV422 Packed YVYU 8-bit |
||
YUV422 Packed VYUY 8-bit |
||
YUV444 Packed 8-bit |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 3. Height stride: Has no alignment requirements but must be the same as height. Buffer size (in bytes) = Width stride x Height stride |
RGB888 |
||
BGR888 |
||
ARGB8888 |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 4. Height stride: Has no alignment requirements but must be the same as height. Buffer size (in bytes) = Width stride x Height stride |
ABGR8888 |
||
RGBA8888 |
||
BGRA8888 |
||
YUV440SP 8bit |
Width: No alignment requirement. 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. Buffer size (in bytes) = Width stride x Height stride x 2 |
YVU440SP 8-bit |
Output Format |
Output Width and Height |
Output Width Stride, Height Stride, and Buffer Size |
|---|---|---|
YUV400 8-bit |
No alignment requirement. |
The width stride is 16-pixel aligned. The height stride can be the same as the height stride. Buffer size (in bytes) = Width stride x Height stride |
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 16. Height stride: Round up the height to the nearest multiple of 2. Buffer size (in bytes) = Width stride x Height stride x 3/2 |
YUV420SP NV21 8-bit |
||
YUV422SP 8-bit |
Width: Must be a multiple of 2. Height: No alignment requirement. |
The width stride is 16-pixel aligned. The height stride can be the same as the height stride. Buffer size (in bytes) = Width stride x Height stride x 2 |
YVU422SP 8-bit |
||
YUV444 Packed 8-bit |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 3. Height stride: Has no alignment requirements but must be the same as height. Buffer size (in bytes) = Width stride x Height stride |
RGB888 |
||
BGR888 |
||
ARGB8888 |
No alignment requirement. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 4. Height stride: Has no alignment requirements but must be the same as height. Buffer size (in bytes) = Width stride x Height stride |
ABGR8888 |
||
RGBA8888 |
||
BGRA8888 |
The left offset of the paste ROI relative to the output image must be a multiple of 16. The paste ROI can be directly placed on the leftmost side of the output image. That is, the left offset relative to the output image is 0, which also meets the 16-pixel alignment requirement.
Ascend AI Processor |
Restrictions |
|---|---|
Ascend 310 AI Processor |
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. |
Ascend 910 AI Processor |
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. |
Ascend 310P AI Processor |
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 must be an even number and the right offset must be an odd number. For other formats, there are no such limits. |
For image resizing, the aspect ratio ranges of the paste and crop ROIs are as follows:
Ascend 310 AI Processor: [1/32, 16]
Ascend 910 AI Processor: [1/32, 16]
Ascend 310P AI Processor: [1/1024, 512]
For resizing with the aspect ratio preserved, the left offset for pasting must be a multiple of 16. Therefore, the acldvppVpcCropResizePasteAsync call may result in paste ROI deviation from the center of the output image. In this case, you can add the acldvppVpcBatchCropResizeMakeBorderAsync call to implementing the cropping, resizing, and padding functions together.
Restrictions on the VPC output as the input for model inference
Ascend 310 AI Processor and Ascend 910 AI Processor: For the VPC function, width x height of the paste ROI must be a multiple of 16 x 2. Otherwise, the paste ROI may contain invalid data for padding. In this case, you need to use AIPP to crop the valid ROI and remove invalid data to ensure inference accuracy.
Ascend 310P AI Processor: For the VPC function, the width of the paste ROI must be a multiple of 16. Otherwise, the paste ROI may contain invalid data for padding. In this case, you need to use AIPP to crop the valid ROI and remove invalid data to ensure inference accuracy.