API Call Sequence

For the Ascend 310 AI Processor, this function is not supported in the current version.

For the Ascend 910 AI Processor, this function is not supported in the current version.

If video decoding is involved during app development, ensure that your app contains the code logic for such video decoding. For details about the API call sequence, see API Call Sequence. For details about the VDEC functions, see VDEC Functions and Restrictions.

Figure 1 API call sequence

The current system supports decoding H.264 and H.265 video streams. The key APIs are described as follows:

  1. Call hi_mpi_sys_init to initialize the media data processing system.
  2. Call hi_vdec_get_pic_buf_size to obtain the size of the frame buffer required for decoding and call hi_vdec_get_tmv_buf_size to obtain the size of the temporal motion vector (TMV) buffer. The data is required for creating a channel.
  3. Call hi_mpi_vdec_create_chn to create a channel.
  4. Call hi_mpi_dvpp_malloc to allocate the device buffer to store the input or output data.
  5. Before decoding, call hi_mpi_vdec_start_recv_stream to notify the decoder to start receiving streams, and then call hi_mpi_vdec_send_stream to send the streams to be decoded. hi_mpi_vdec_send_stream is an asynchronous API. The API call only delivers a task. You also need to call hi_mpi_vdec_get_frame to obtain the decoding result. You can call hi_mpi_vdec_release_frame to release frame-related resources. After the decoding is complete, call hi_mpi_vdec_stop_recv_stream to notify the decoder to stop receiving streams.
  6. Call hi_mpi_dvpp_free to free the input and output buffers.
  7. Call hi_mpi_vdec_destroy_chn to destroy the channel.
  8. Call hi_mpi_sys_exit to deinitialize the media data processing system.