acldvppDecodeJpeg
Applicability
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
x |
|
|
x |
|
|
x |
Function Usage
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, which is of the aclTensor type created by calling aclCreateTensor (the tensor data is stored on the device). The value of dataType of the input tensor can be UINT8, and the value of Format can be ND, and 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 this parameter to true.
- out: output tensor of the operator, which is of the aclTensor type created by calling aclCreateTensor (the tensor data is stored on the device). The value of dataType of the output tensor can be UINT8, the value of Format can be NCHW or NHWC, and non-contiguous tensors are not supported.
- workspaceSize: size of the workspace to be allocated on the device.
- executor: operator executor, containing the operator computation process.
- Returns:
acldvppStatus status code. For details, see acldvpp Return Codes.
acldvppDecodeJpeg
- Parameters:
- workspace: address of the device memory allocated by calling aclrtMalloc. The size of the device memory is specified by workspaceSize.
- 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 a task, which can be a created stream for saving resources or newly created by calling aclrtCreateStream.
- Returns:
acldvppStatus status code. 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.