acldvppDecodeJpeg
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
☓ |
|
☓ |
|
☓ |
Description
Description: decodes .jpg, .jpeg, .JPG, or .JPEG images into single-channel (GRAY) or three-channel (RGB) images.
Prototype
Each operator has two-phase API calls. First, acldvppDecodeJpegGetWorkspaceSize is called to calculate the required workspace size based on the computation process. Then, acldvppDecodeJpeg is called to perform computation. The two-phase APIs are as follows:
- First-phase API:
1acldvppStatus acldvppDecodeJpegGetWorkspaceSize(const aclTensor* self, uint32_t channels, bool tryRecoverTruncated, aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)
- Second-phase API:
1acldvppStatus acldvppDecodeJpeg(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream)
acldvppDecodeJpegGetWorkspaceSize
- Parameters:
- self: input tensor of the operator. Call aclCreateTensor to create data of the aclTensor type (stored on the device). The data type of the input tensor can be UINT8 and the format can be ND. Non-contiguous tensors are not supported.
- channels: number of output channels. The value can be 1 (GRAY images) or 3 (RGB images).
- tryRecoverTruncated: indicates whether to attempt to decode damaged streams. This parameter is reserved and is not supported currently. Set it to true for the current user.
- out: operator output tensor. Call aclCreateTensor to create data of the aclTensor type (stored on the device). The data type of the output tensor can be UINT8, and the format can be NCHW or NHWC. Discontinuous tensors are not supported.
- workspaceSize: size of the workspace to be allocated on the device.
- executor: operator executor, containing the operator computation process.
- Returns:
The status code acldvppStatus is returned. For details, see acldvpp Return Codes.
acldvppDecodeJpeg
- Parameters:
- workspace: The aclrtMalloc API needs to be called to allocate the device memory. The memory size is workspaceSize. The memory address output by the aclrtMalloc API is passed here.
- workspaceSize: The value must be the same as that obtained by calling acldvppDecodeJpegGetWorkspaceSize.
- executor: op executor, which contains the operator computation process and is the same as the executor of the acldvppDecodeJpegGetWorkspaceSize API.
- stream: stream for executing the task. You can reuse the created stream to save resources or call aclrtCreateStream to create a stream, and then pass the stream as an input parameter.
- Returns
The status code acldvppStatus is returned. For details, see acldvpp Return Codes.
Constraints
JPEG images with the resolution ranging from 6 x 4 to 32768 x 32768 can be decoded. The decoding of images with the resolution ranging from 32 x 32 to 16384 x 16384 is accelerated using dedicated hardware. In other scenarios (including the scenario where hardware decoding fails), image decoding is performed on the AI CPU using open-source software libjpeg-turbo.
In the hardware decoding scenario, the decoding result of this operator is the same as that of OpenCV 3.4.2. OpenCV 3.4.2 uses libjpeg-turbo 1.5.3 by default.