Using DVPP APIs
The DVPP provides the following three types of APIs by using handles, namely, APIs for creating, using, and destroying handles.
The VPC, JPEGE, JPEGD, and PNGD components share the same set of APIs with varying input parameters. VDEC and VENC each have a separate set of APIs.
- VDEC uses the following three APIs for decoding, which can be called in asynchronous mode. The VdecCtl API is used to transfer configurations including the callback function) and H.264/H.265 data. After hardware decoding, the Matrix framework calls the callback function to return the result.
The data decoded by the VDEC is in HFBC format (internal format), which has to be converted to the YUV420SP format using the VPC. For details, see samples in "Implementing the VDEC Function" of the DVPP API Reference.
int CreateVdecApi(IDVPPAPI *&pIDVPPAPI, int singleton) int VdecCtl(IDVPPAPI *&pIDVPPAPI, int CMD, dvppapi_ctl_msg *MSG, int singleton) int DestroyVdecApi(IDVPPAPI *&pIDVPPAPI, int singleton)
- The VPC, JPEGE, JPEGD, and PNGD use the same interfaces. The configuration parameters vary according to the function. For details, see "VPC/JPEGE/JPEGD/PNGD Interfaces" in the DVPP API Reference.
int CreateDvppApi(IDVPPAPI *&pIDVPPAPI) int DvppCtl(IDVPPAPI *&pIDVPPAPI, int CMD, dvppapi_ctl_msg *MSG) int DestroyDvppApi(IDVPPAPI *&pIDVPPAPI)
- The DVPP is restricted by hardware during its usage. To speed up data read and write, an image's length and width must be aligned to the specified size without affecting the valid region. The image's length and width are aligned to the specified size by padding 0s to leftward and downward.
For example, for a 300 x 300 YUV420SP_UV image, the size must be aligned to 304 x 300 (The width is 16-pixel aligned, and the height is 2-pixel aligned). The valid region ranges from [0, 0] to [300, 300]. In this case, you need to pad 0s rightward to column 304.
- When the JPEGD, VDEC, and PNGD components of the DVPP are used to read input images, the decoded images must meet the length and width alignment requirements. In this case, you need to apply for memory for output images based on the size of the aligned images.
For example, for a 300 x 300 YUV420SP_UV image, you need to apply for memory with the size of (304*300*3/2) bytes. Each pixel of a YUV420SP image requires a 1.5-byte storage space.
- VPC: input and output memory address aligned by 16 bytes
- VPC: output image width aligned by 16 bytes
- VPC: output image height aligned by two bytes
- VPC: input image width aligned by 16 bytes
- VPC: input image height aligned by two bytes
- JPEGD: output image width aligned by 128 bytes
- JPEGD: output image height aligned by 16 bytes
- DVPP components pose many restrictions on output images based on the processing speed and memory usage. For example, the length and width of output images must be aligned, and the output format must be YUV420SP. However, the model input is usually in RGB or BGR format, and the sizes of the input images are different. Therefore, the Ascend 310 chip provides AI pre-processing (AIPP) for image format conversion and image cropping. For details, see the Model Conversion Guide.
Figure 1 shows the handling process of the JPEG image input and H.26* video input.
- When the JPEGD, VDEC, and PNGD components of the DVPP are used to read input images, the decoded images must meet the length and width alignment requirements. In this case, you need to apply for memory for output images based on the size of the aligned images.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot