Using Batch Processing APIs of VPC to Reduce Delay

Background

AscendCL media data processing provides the following types of APIs for image cropping and resizing:

  • Processing one image at a time: For example, acldvppVpcCropAsync.

    In this mode, if there are multiple input images, the for loop mode is typically used, that is, the acldvppVpcCropAsync API is called once for each image.

  • Processing multiple images at a time (batch processing): For example, acldvppVpcBatchCropAsync.

    In this mode, if there are multiple input images, only the acldvppVpcBatchCropAsync API needs to be called once.

The following table lists the mapping between these two types of APIs.

Single-Image Processing API

Batch Processing API

acldvppVpcCropAsync (cropping)

acldvppVpcBatchCropAsync (batch cropping)

acldvppVpcCropResizeAsync (cropping and resizing)

acldvppVpcBatchCropResizeAsync (batch cropping and resizing)

acldvppVpcCropAndPasteAsync (cropping and pasting)

acldvppVpcBatchCropAndPasteAsync (batch cropping and pasting)

acldvppVpcCropResizePasteAsync (cropping, resizing, and pasting)

acldvppVpcBatchCropResizePasteAsync (batch cropping, resizing, and pasting)

-

acldvppVpcBatchCropResizeMakeBorderAsync (batch cropping, resizing, and padding)

Principles

The Ascend AI Processor has a built-in DVPP unit, which contains multiple VPC modules for functions like image cropping, resizing, and format conversion.

When a batch processing API is called, batch tasks are evenly distributed to multiple VPC modules for parallel processing, reducing the processing delay and improving performance.

Sample

The following uses batch image cropping and resizing as an example to describe how to call the batch processing API acldvppVpcBatchCropResizeAsync. Click here to obtain the complete code.