Function: dvpp_jpeg_encode_async

Applicability

Product

Supported (√/x)

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Function Usage

Encodes a YUV image into a JPG image. This API is asynchronous.

Prototype

  • C Prototype
    1
    aclError acldvppJpegEncodeAsync(acldvppChannelDesc *channelDesc, acldvppPicDesc *inputDesc, const void *data, uint32_t *size, acldvppJpegeConfig *config, aclrtStream stream)
    
  • Python Function
    1
    ret = acl.media.dvpp_jpeg_encode_async(dvpp_channel_desc, input_dvpp_pic_desc, data, size_ptr, dvpp_jpege_config, stream)
    

Parameter Description

Parameter

Description

dvpp_channel_desc

Int, pointer address of the channel description. It must be the same as dvpp_channel_desc 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

Specified stream.

Return Value Description

Return Value

Description

ret

Int, error code: 0 on success; else, failure.

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 JPEGD.