hbVPVideoDecode

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

Parameter for Video decoding.

  • Member

    Member NameDescription
    pixelFormatThe pixel format of the input image. The HB_VP_IMAGE_FORMAT_NV12, HB_VP_IMAGE_FORMAT_YUV420 and HB_VP_IMAGE_FORMAT_NV12_Y10C8_MSB (only support J6B) 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.
    backendSpecifies the execution backend for video decoding tasks. Only supports configuration to a single specific core backend, and does not support multiple backends or ANY-type backends.
    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), the outBufCount parameter is set to 5, and the backend parameter is set to HB_UCP_VPU_CORE_0.

  • 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 decoding contexts for one core; howerver, constrained by device buffer limitations, the maximum number may be less than 32.
    • 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.
    • Due to hardware limitations, the H264 encoding adopts a 16x16 alignment method. The decoded data will also be decoded in line with the alignment requirements set during encoding. Specifically, the resolution after decoding will be aligned to multiples of 16x16.
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.