Function: vdec_send_frame

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

Feeds a stream (the input buffer, as well as the output buffer) to the decoder for decoding. This API is asynchronous.

Prototype

  • C Prototype
    1
    aclError aclvdecSendFrame(aclvdecChannelDesc *channelDesc, acldvppStreamDesc *input, acldvppPicDesc *output, aclvdecFrameConfig *config, void* userData)
    
  • Python Function
    1
    ret = acl.media.vdec_send_frame(vdec_channel_desc, dvpp_stream_desc, dvpp_pic_desc, vdec_frame_config, user_data)
    

Parameter Description

Parameter

Description

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

Call the acl.media.vdec_set_channel_desc APIs to set attributes of the channel description, including the decoding channel ID, thread, callback function, and video coding protocol.

NOTE:

For the Atlas training products , due to software restrictions, it is not allowed to set the channel description attributes by calling acl.media.vdec_set_channel_desc_ref_frame_num. If the API is called, an error is returned.

dvpp_stream_desc

Int, pointer address of the input stream description. You need to allocate the input buffer in advance.

dvpp_pic_desc

Int, pointer address of the output image description. You need to allocate the output buffer in advance.

When dvpp_pic_desc is an input, the user needs to:

  • Call acl.media.dvpp_create_pic_desc to create an image description.
  • Call the acl.media.dvpp_set_pic_desc APIs to set the data buffer, buffer size, width, height, and format of the output image.
    • The output width and height correspond to four parameters: width, height, width_stride, and height_stride. When width is less than 16, width_stride must be aligned to 32 instead of 16. If none of the four parameters are set, the input width and height are used. If only some of the four parameters are set, the API returns an error.
    • If the output image format is set in this API call, the setting is applied. Otherwise, the setting in the channel description is applied.
    • For details about the requirements on the output image format, see Functions and Restrictions.

vdec_frame_config

Int, pointer address of the decoding configuration. This parameter is reserved and can be set to 0 currently.

user_data

Python object, pointer address of the user-defined data.

If you want to obtain the sequence number of the decoded frame, define the user_data parameter. Then, the sequence number can be passed to the VDEC callback function to determine the frame to be processed.

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.
  • The channel passed to this call must have been created. Otherwise, an error code is returned.

  • A stream must be fed in frame mode, which means that a complete frame must be fed in every call to this API.

  • It is not supported to feed empty packets with eos set to 0 (the stream length is 0 or the stream address is empty).

  • After all streams are fed, an empty packet with eos set to 1 can be fed, indicating the end of the current stream file. After the eos is transmitted, this API returns only after all transmitted frames are decoded and the user callback function is processed.

  • Due to stream exception or decoding timeout, the acl.media.vdec_send_frame API may fail to send frames or the EOS frame. You are advised to obtain the return code of this API when writing code. If this API fails to be called, handle the exception.
  • acl.rt.launch_callback is encapsulated in acl.media.vdec_send_frame to insert a callback function that needs to be executed to the stream. To implement the VDEC function, acl.rt.launch_callback does not need to be called separately.

Reference

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