vdec_get_frame

Applicable Products

Product

Supported (√/x)

Ascend 950PR&950DT products

√

Atlas A3 products

√

Atlas A2 products

√

Atlas training products

x

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Fetches the decoded image and input stream of a decoding channel.

During JPEGD image decoding, if hardware decoding fails when this API is called, software decoding is triggered within this API.

Prototype

  • C Prototype
    1
    hi_s32 hi_mpi_vdec_get_frame(hi_vdec_chn chn, hi_video_frame_info *frame_info, hi_vdec_supplement_info *supplement, hi_vdec_stream *stream, hi_s32 milli_sec);
    
  • Python Function
    1
    frame_info, supplement, stream, ret = acl.himpi.vdec_get_frame(chn, milli_sec)
    

Parameters

Parameter

Description

chn

Int, decoding channel ID.

milli_sec

Int, timeout interval, in milliseconds.
  • -1: blocking mode.
  • 0: non-blocking mode.
  • >0: timeout interval (timeout mode). The timeout interval varies with the operating system. The deviation is generally within a time slice of an operating system. For example, if the time slice of an operating system is 4 ms and the value of milli_sec is set to 1, the actual timeout interval ranges from 1 ms to 5 ms. When the CPU load is high, the timeout interval may fluctuate.
    NOTE:

    In the JPEGD image decoding scenario, the timeout interval configured here refers only to the wait time for obtaining the hardware decoding result, excluding the software decoding time.

Return Values

Return Value

Description

frame_info

Dict, pointer to information about decoded images. The decoded data is stored in the device memory. For details, see hi_video_frame_info.

supplement

Dict, supplementary information about the decoded images. This parameter is reserved.

stream

Dict, pointer to information dictionary of decoded input streams. For details, see hi_vdec_stream.

ret

Int, error code.
  • 0: success. After the decoded data is obtained successfully, call acl.himpi.vdec_release_frame to release decoding resources. Although success message is returned, the fetched data may be the result of decoding failure. To check the decode success or failure result, query the frame_flag parameter of hi_video_frame (a member of hi_video_frame_info).
  • Non-zero: failure. For details, see VDEC/JPEGD Return Codes.
    NOTE:
    • If no channel is created during image decoding, the error code HI_ERR_VDEC_UNEXIST is returned.
    • If the channel is destroyed in the image fetching process, the error code HI_ERR_VDEC_UNEXIST is returned.
    • If the channel is reset in the image fetching process, the error code HI_ERR_VDEC_UNEXIST is returned.
    • In non-blocking mode, if the buffer has no decoded images, the error code HI_ERR_VDEC_BUF_EMPTY is returned.
    • In timeout mode, if no hardware decoding result is obtained within the specified timeout interval, the error code HI_ERR_VDEC_BUF_EMPTY is returned. In this case, increase the timeout interval or call this API repeatedly to obtain the decoding result.

Constraints

  • This API fetches the VDEC result, including the input buffer and output buffer.
  • For decoding of JPEG(420), JPEG(422), or JPEG(440) input images, if the input width and height are odd numbers, the output width and height are rounded down to the nearest multiples of 2 by default. For decoding of JPEG(444) or JPEG(400) input images, the output width and height are consistent with the input width and height by default. To adjust the alignment mode of the output image width and height, call acl.himpi.vdec_set_jpegd_precision_mode.

Reference

For the API call sequence, see JPEGE and VENC.