Function: dvpp_jpeg_encode_async

C Prototype

aclError acldvppJpegEncodeAsync(acldvppChannelDesc *channelDesc, acldvppPicDesc *inputDesc, const void *data, uint32_t *size, acldvppJpegeConfig *config, aclrtStream stream)

Python Function

ret = acl.media.dvpp_jpeg_encode_async(dvpp_channel_desc, input_dvpp_pic_desc, data, size_ptr, dvpp_jpege_config, stream)

Function Usage

Encodes YUV images into JPG images. This API is asynchronous.

Input Description

dvpp_channel_desc: int, pointer address of the channel description. It must be the same as the dvpp_channel_desc argument passed to the acl.media.dvpp_create_channel call.

input_dvpp_pic_desc: int, pointer address of the description of input images.
  • Call acl.media.dvpp_create_pic_desc to create an image description.
  • Call the acl.media.dvpp_set_pic_desc APIs to set image description parameters (such as the image format, width, and height).

    For details about the requirements on the input image resolution (≤ maximum channel width x maximum channel height) and image format, see Functions and Restrictions.

data: int, pointer address of the output buffer address for storing encoded data.

size_ptr: int, pointer to the output buffer size, in bytes.

  • acl.media.dvpp_jpeg_predict_enc_size is called in advance to predict the output buffer size out_buffer_size.
  • np_out_size = np.array([out_buffer_size], dtype=np.int32) is called to create data of a NumPy array. Then bytes_data = np_out_size.tobytes()-> \->size_ptr = acl.util.bytes_to_ptr(bytes_data), is called to convert the data into an object as the argument.

    Note: After the function is called successfully, the data (np_out_size) converted by size_ptr changes.

dvpp_jpege_config: int, pointer address of the image encoding configuration.

stream: int, stream object.

Return Value

ret: int, error code.

  • 0 indicates the success of task delivery.
  • Other values indicate the failure of task delivery.

Restrictions

This API is asynchronous. The API call delivers a task rather than executes a task. After this API is called, call the synchronization API (for example, acl.rt.synchronize_stream) to ensure that the task is complete.

Reference

For details about the API call sequence and example, see JPEGE.