acldvppEncodeJpeg

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Function

Description: encodes a single-channel (GRAY) or three-channel (RGB) image into a JPEG image.

Prototype

Each operator has two-phase API calls. First, acldvppEncodeJpegGetWorkspaceSize is called to calculate the required workspace size based on the computation process. Then, acldvppEncodeJpeg is called to perform computation. The two-phase APIs are as follows:

  • First-phase API:
    1
    acldvppStatus acldvppEncodeJpegGetWorkspaceSize(const aclTensor* self, uint32_t quality, aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)
    
  • Second-phase API:
    1
    acldvppStatus acldvppEncodeJpeg(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream)
    

acldvppEncodeJpegGetWorkspaceSize

  • 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 NCHW or NHWC. Discontinuous tensors are not supported, the value of N can be 1 or empty, and the value of C can be 1 or 3. The value 1 indicates that a GRAY image is input, and the value 3 indicates that an RGB image is input.
    • quality: encoding quality. The value range is [1, 100]. A smaller value indicates poorer image quality, but a smaller image data volume and less memory usage. A larger value indicates higher image quality, but a larger image data volume and more memory usage.
    • 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 ND. 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:

    The status code acldvppStatus is returned. For details, see acldvpp Return Codes.

acldvppEncodeJpeg

  • 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 acldvppEncodeJpegGetWorkspaceSize.
    • executor: op executor, which contains the operator computation process and is the same as the executor of the acldvppEncodeJpegGetWorkspaceSize 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

Encoding of JPEG images with a resolution ranging from 32 x 32 to 8192 x 8192.

The width and height of the original picture must be 2-pixel aligned.