hbVPVideoDecode

typedef struct {
  uint8_t pixelFormat;
  uint32_t inBufSize;
  uint32_t outBufCount;
  hbVPVideoType videoType;
} hbVPVideoDecParam;

Parameter for Video decoding.

  • Member

    Member NameDescription
    pixelFormatThe pixel format of the input image. The HB_VP_IMAGE_FORMAT_NV12 and HB_VP_IMAGE_FORMAT_YUV420 formats are currently supported.
    inBufSizeSpecifies the size of the internal input buffer of Video Process Unit, its size needs to satisfy 1024 alignment. Value range [1024, 8192 * 4096 * 3], It is typically set according to the size of the decoded yuv, and the result must be aligned to 1024 bytes. The recommended value is 10 * 1024 * 1024.
    outBufCountSpecifies the count of output buffers the Video Process Unit. Value range [1, 31], recommended value 5.
    videoTypeThe type of encoding protocol. The HB_VP_VIDEO_TYPE_H264 and HB_VP_VIDEO_TYPE_H265 formats are currently supported.
int32_t hbVPGetDefaultVideoDecParam(hbVPVideoDecParam *param);

Get the decoder's default decoding parameter,where the pixelFormat parameter is HB_VP_IMAGE_FORMAT_YUV420 , the inBufSize parameter is set to 10 * 1024 * 1024 (which equals 10 MB), and the outBufCount parameter is set to 5.

  • Parameter
    • [in] param Decode the parameter.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • Before calling the interface, you need to specify the videoType as HB_VP_VIDEO_TYPE_H264 or HB_VP_VIDEO_TYPE_H265 .
int32_t hbVPCreateVideoDecContext(hbVPVideoContext *context,
                                  hbVPVideoDecParam const *param);

The API for calling to create decoder context and initialize context to nullptr in advance before creation.

  • Parameter
    • [out] context Decoder context.
    • [in] param Decode the parameter.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • The Video Process Unit highest supports the creation of 32 encoding or decoding contexts.
    • The first frame of the decoder must be an IDR frame containing the header information of VPS+SPS+PPS, otherwise it cannot be decoded properly.
    • The decoder does not support decoding of B-frame streams containing backward reference frames.
int32_t hbVPReleaseVideoDecContext(hbVPVideoContext context);

The API for calling to release the decoder context.

  • Parameter
    • [in] context Decoder context.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
int32_t hbVPVideoDecode(hbUCPTaskHandle_t *taskHandle, 
                        hbVPArray const *srcBuf,
                        hbVPVideoContext context);

The API for calling the Video Process Unit decoding.

  • Parameter
    • [out] taskHandle Task handles are responsible for the interaction of the operator with the UCP architecture.
    • [in] srcBuf Input stream file.
    • [in] context Decoder context.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • Create the task using asynchronous methods is only supported.
    • During video decoding, the supported resolution ranges from a minimum of 256x128 to a maximum of 8192x4096.
    • Due to hardware limitations of the Video Processing Unit, the Video Processing Unit supports a maximum of 31 tasks being submitted simultaneously for either encoding or decoding.
    • To avoid wasting system resources and improve Video Processing Unit decoding performance, it is recommended to reuse input addresses.
int32_t hbVPGetVideoDecOutputBuffer(hbVPImage *outImg,
                                    hbUCPTaskHandle_t taskHandle);

The API calling for to get the decoded data buffer.

  • Parameter
    • [out] outImg Output YUV Image.
    • [in] taskHandle Task handles are responsible for the interaction of the operator with the UCP architecture.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • The output buffer outImg is requested internally by the Video Process Unit.
    • The buffer contains valid data upon the task is successfully completed, and is released during the task release phase.