MI VDEC API


1. OVERVIEW


1.1. Module Description

The video decoder module is used for fulfilling functions such as creating decoding channel, transmitting and controlling code streams, scaling output image, etc.

There are two main types of input sources for vdec module:

  • User reads stream file and sends data to decoding module

  • User sends the stream data received by the network directly to the decoding module

Table 1-1: Chip Decoding Specifications

Chip Hardware Decoding Module Maximum Number of Channels Protocol Resolution Range Maximum Performance
Taiyaki DEC2.0 16 H.264/H.265 H.264: max 4096x4096, min 176x128
H.265: max 4096x4096, min 176x128
H.264: 3840x2160@30fps
H.265: 3840x2160@30fps
Takoyaki DEC2.0 4 H.264/H.265 H.264: max 4096x4096, min 176x128
H.265: max 4096x4096, min 176x128
H.264: 1920x1080@30fps
H.265: 1920x1080@30fps

1.2. Decoding Flowchart


1.2.1. Taiyaki Data Flowchart

Figure 1-1: VDEC Data Flowchart


1.2.2. Takoyaki Data Flowchart

Figure 1-2: VDEC Data Flowchart


1.3. Key Concepts

  • Bitstream send mode

    VDEC decoder provides two ways to send bitstream:

    • Send by stream (E_MI_VDEC_VIDEO_MODE_STREAM): The user can send any length of bitstream to the decoder each time, and the decoding and splicing process of the bitstream frame is completed by the decoder. For H.264/H.265, the end of the current bitstream frame can only be confirmed after receiving the next bitstream. So, in this mode, the image will not be immediately output after inputting a frame of H.264/H.265 bitstream. Sending by stream is not supported.

    • Send by frame (E_MI_VDEC_VIDEO_MODE_FRAME): Each time the user sends a complete frame of code stream to the decoder and call once the send interface, the decoder considers that the frame coded stream has ended and begins to decode.

    Bitstream send mode can be set in the interface MI_VDEC_CreateChn.

  • Image output order

    According to H.264/H.265 protocol, the decoded image may not be output immediately after decoding. VDEC decoder can output as soon as possible by setting different image output modes. Image output methods include the following two:

    • Decoding order: the decoded image is output in the order of decoding.

    • Display order: the decoded image is output according to the display order in the protocol.

    According to H.264/H.265 protocol, the decoding order of video may be inconsistent with the display order of decoded image. For example, when decoding B frame, P frame before and after B frame is needed as reference, so P frame after B frame is decoded before B frame, but B frame is output before P frame. Output in decoding order is a necessary condition for fast output. If the user chooses to output in decoding order, the decoding order and the display order of the code stream should be the same.

    The combination of sending code stream by frame and outputting by decoding sequence can achieve the purpose of fast decoding and output. The user must ensure that a complete frame code stream is sent each time, and that the decoding sequence and display sequence of the code stream are the same.

    The image output mode will be adaptive to the display order, and the user setting is invalid .

  • PTS

    When sending a bitstream in frame mode, the decoded output image time stamp PTS is the PTS sent by the user in the MI_VDEC_SendStream interface, and the decoder will not change this value. If the PTS value set by the user is -2, this image will not be displayed by the video display module (disp). If it is another value, it means that the decoder will not do anything.

    Note: PTS is not used for frame rate control. For frame rate control function, please refer to API description in MI_VDEC_SendStream.

  • Bitstream buffer

    The bitstream buffer is used by the user to cache the coded stream input and send it to the decoder for decoding. There is no fixed formula for calculating the size of stream buffer.

    Generally, according to experience, if the resolution is less than or equal to D1, the recommended value is 512KB; if the resolution is in the range (d1,1080p], the recommended value is 1MB; if the resolution is in the range (1080p,4K], the recommended value is 2MB. Users can choose reasonable value settings according to actual needs.

  • eDpbBufMode

    By setting eDpbBufMode, users can set different buffer modes for decoding. According to different scenarios, different buffer modes can be selected to save memory. When E_MI_VDEC_DPB_MODE_NORMAL is set, memory cannot be saved. When E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF is set, it can only decode a stream that contains only one reference frame and only one DPB buffer is needed; when E_MI_VDEC_DPB_MODE_INPLACE_TWO_BUF is set, it can only decode a stream that contains only two reference frames and only two DPB buffer are needed.

  • u32RefFrameNum

    u32refframenum represents the maximum number of reference frames. In the actual scene, the memory of the system may not be infinite. So the user can limit the number of reference frames according to the definition of the product, so as to prompt the user that the current code stream may have exceeded the specification. If the user sets eDpbBufMode to E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF or E_MI_VDEC_DPB_MODE_INPLACE_TWO_BUF, the parameter is invalid. If the user sets edpbbufmode to E_MI_VDEC_DPB_MODE_NORMAL and the number of reference frames is less than what the decoder actually needed, the decoded image may be abnormal or decoding timeout may happen.

  • Output image scaling

    The user calls MI_VDEC_SetOutputPortAttr to scale the decoded image to output the image with the required resolution.

    Note that the decoder only supports scaling down the output image.

  • Low latency

    The latency here refers to the latency generated by reordering the image queue to be displayed after decoding the B frame. When decoding the coded stream without B frame, the decoding order and the display order are the same, so there is no latency output, that is, the latency is low. When decoding bitstreams containing B frame, output latency will occur, because B frame has forward and backward reference, making it necessary to wait for the reference image to be decoded before the current frame can be decoded, and besides, the decoded image needs to be reordered.

    These two modes need to be completed by setting bDisableLowLatency. The default value is FALSE, and the user does not need to set it. To decode bitstream with B frame, you need to set bDisableLowLatency to TRUE.

    Note that bDisableLowLatency is TRUE and cannot be used to decode non-B frame streams.

    This function is only used for chip Takoyaki.

  • Output buffer mode

    The user can call MI_VDEC_SetOutputPortLayoutMode to set the output buffer mode. This interface is only used for chip Takoyaki . This interface can be called when the user needs to manually control the output buffer mode.

    If E_MI_VDEC_OUTBUF_LAYOUT_LINEAR is set, it indicates that the output buffer is in linear mode.

    If E_MI_VDEC_OUTBUF_LAYOUT_TILE is set, it indicates that the output buffer is in tile mode.

    If E_MI_VDEC_OUTBUF_LAYOUT_AUTO is set, it indicates that the output buffer will automatically switch between linear mode and tile mode.


2. API LIST

This module provides the following APIs:

Name of API Function
MI_VDEC_InitDev Initialize decoding device
MI_VDEC_DeInitDev De initialize decoding device
MI_VDEC_CreateChn Create a decoding channel
MI_VDEC_DestroyChn Destroy a decoding channel
MI_VDEC_GetChnAttr Get decoding channel attribute
MI_VDEC_StartChn Start the channel decoding
MI_VDEC_StopChn Stop the channel decoding
MI_VDEC_GetChnStat Get decoding channel status
MI_VDEC_FlushChn Clear decoding channel cache
MI_VDEC_ResetChn Reset decoding channel
MI_VDEC_SetChnParam Set decoding channel parameter
MI_VDEC_GetChnParam Get decoding channel parameter
MI_VDEC_SendStream Send video stream data to decoding channel
MI_VDEC_GetUserData Get decoding channel user data
MI_VDEC_ReleaseUserData Release decoding channel user data
MI_VDEC_SetDisplayMode Set decoding channel display mode
MI_VDEC_GetDisplayMode Get decoding channel display mode
MI_VDEC_SetOutputPortAttr Set decoding channel output port attribute
MI_VDEC_GetOutputPortAttr Get decoding channel output port attribute
MI_VDEC_SetOutputPortLayoutMode Set output port layout mode
MI_VDEC_GetOutputPortLayoutMode Get output port layout mode
MI_VDEC_DecRepeatFrame Repeatedly decode the current frame

2.1. MI_VDEC_InitDev

  • Function

    Initialize decoding device.

  • Syntax

    MI_S32 MI_VDEC_InitDev(MI_VDEC_InitParam_t *pstVdecInitParam);
    
  • Parameter

    Parameter Name Description Input/Output
    pstInitParam Decoding initialization parameters pointer. Data type: MI_VDEC_InitParam_t Input

  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful
    MI_ERR_VDEC_INITED Device to be initialized is already initialized.
    MI_ERR_VDEC_NULL_PTR Null pointer

  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is optional. There is no need to call this interface if only the default initialization parameters are used.

    • The interface is different in the use of different platforms, see the following table for details.

      Chips/Platforms Interface usage description
      Taiyaki Without this interface, settings are not supported.
      Takoyaki Optional call.
    • If you choose to use this interface, you must call it before creating a decoding channel; otherwise, it will return the error code MI_ERR_VDEC_INITED which means the device has been initialized.

    • If the interface is called repeatedly, the error code MI_ERR_VDEC_INITED will be returned.

    • If you need to decode the B-frame code stream, you need to set bDisableLowLatency to TRUE to ensure that the decoder outputs the decoded images in the display order; otherwise, the output images will have jitter and inconsistency problems.

  • Example

    MI_S32 StartVdec(void)
    
    {
    
        MI_S32 s32Ret = MI_ERR_VDEC_FAILED;
    
        MI_VDEC_CHN VdecChn = 0;
    
        MI_VDEC_InitParam_t stInitParam;
    
        MI_VDEC_ChnAttr_t stChnAttr;
    
        memset(&stInitParam, 0x0, sizeof(MI_VDEC_InitParam_t));
    
        memset(&stChnAttr, 0x0, sizeof(MI_VDEC_ChnAttr_t));
    
        stInitParam.bDisableLowLatency = FALSE;
    
        s32Ret = MI_VDEC_InitDev(&stInitParam);
    
        if(MI_SUCCESS != s32Ret)
    
        {
            printf("MI_VDEC_InitDev failed, s32Ret: 0x%x.\n", s32Ret);
    
            return s32Ret;
    
        }
    
        VdecChn = 0;
    
        stChnAttr.eCodecType    = E_MI_VDEC_CODEC_TYPE_H264;
    
        stChnAttr.u32PicWidth   = 1920;
    
        stChnAttr.u32PicHeight  = 1080;
    
        stChnAttr.eVideoMode    = E_MI_VDEC_VIDEO_MODE_FRAME;
    
        stChnAttr.u32BufSize    = 1024*1024;
    
        stChnAttr.eDpbBufMode   = E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF;
    
        stChnAttr.stVdecVideoAttr.u32RefFrameNum = 1;
    
        stChnAttr.u32Priority = 0;
    
        stChnAttr.stVdecVideoAttr.stErrHandlePolicy.bUseCusPolicy = FALSE;
    
        s32Ret = MI_VDEC_CreateChn(VdecChn, &stChnAttr);
        if(MI_SUCCESS != s32Ret)
    
        {
            printf("MI_VDEC_CreateChn failed, s32Ret: 0x%x.\n", s32Ret);
    
            return s32Ret;
    
        }
    
        return MI_SUCCESS;
    }
    

2.2. MI_VDEC_DeInitDev

  • Function

    De initialize decoding device.

  • Syntax

    MI_S32 MI_VDEC_DeInitDev(void);
    
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful
    MI_ERR_VDEC_NOT_INIT Device is not initialized.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is optional.

    • The use of this interface varies from platform to platform.Please refer to the instructions of the API MI_VDEC_InitDev.

    • If you choose to use this interface, you must call it after destroying the decoding channel; otherwise, it will return the error code MI_ERR_VDEC_NOT_INIT which means the device has not been initialized.

    • If the interface is called repeatedly, the error code MI_ERR_VDEC_NOT_INIT will be returned.

  • Example

    MI_S32 StopVdec(void)
    
    {
    
        MI_S32 s32Ret = MI_ERR_VDEC_FAILED;
    
        MI_VDEC_CHN VdecChn = 0;
    
        s32Ret = MI_VDEC_DestroyChn(VdecChn);
    
        if(MI_SUCCESS != s32Ret)
    
        {
    
            printf("MI_VDEC_DestroyChn failed, s32Ret: 0x%x.\n", s32Ret);
    
            return s32Ret;
    
        }
    
        //Confirm that you have destroyed all channels
        s32Ret = MI_VDEC_DeInitDev();
    
        if(MI_SUCCESS != s32Ret)
    
        {
    
            printf("MI_VDEC_DeInitDev failed, s32Ret: 0x%x.\n", s32Ret);
    
            return s32Ret;
    
        }
    
        return MI_SUCCESS;
    
    }
    

2.3. MI_VDEC_CreateChn

  • Function

    Create a decoding channel

  • Syntax

    MI_S32 MI_VDEC_CreateChn(MI_VDEC_CHN VdecChn,MI_VDEC_ChnAttr_t *pstChnAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Decoding channel number
    Range: [0, MI_VDEC_MAX_CHN_NUM)
    Input
    pstChnAttr Decoding channel attribute pointer Data type: MI_VDEC_ChnAttr_t Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful
    MI_ERR_VDEC_INVALID_CHNID Invalid Channel ID.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    MI_ERR_VDEC_NOT_INIT Module not successfully initialized
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter or input parameter exceeding channel decoding capability.
    MI_ERR_VDEC_CHN_EXIST Channel to be created already exists.
    MI_ERR_VDEC_NOMEM Memory allocation fails (due to for example insufficient memory).
    MI_ERR_VDEC_NULL_PTR Null pointer
    MI_ERR_VDEC_NOT_SUPPORT This operation or function is not supported.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • The channel number cannot exceed the maximum channel range allowed.

    • Before creating a decoding channel, you need to ensure that the decoding channel has not been created or destroyed, otherwise the error code MI_ERR_VDEC_CHN_EXIST will be returned.

    • If eDpbBufMode is set to E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF or E_MI_VDEC_DPB_MODE_INPLACE_TWO_BUF, we only guarantee that the decoder can decode the bitstream encoded by Sstar encoder well, but the third party’s decode bitstream is not guaranteed to be fully supported. In addition, eDpbBufMode should be consistent with reference frame number of the bitstream.

  • Example

    MI_S32 StartVdec(void)
    {
        MI_S32 s32Ret = MI_ERR_VDEC_FAILED;
        MI_VDEC_CHN VdecChn = 0;
        MI_VDEC_ChnAttr_t stChnAttr;
        MI_VDEC_OutputPortAttr_t stOutputPortAttr;
    
        memset(&stChnAttr, 0x0, sizeof(MI_VDEC_ChnAttr_t));
        memset(&stOutputPortAttr, 0x0, sizeof(MI_VDEC_OutputPortAttr_t));
    
        VdecChn = 0;
        stChnAttr.eCodecType    = E_MI_VDEC_CODEC_TYPE_H264;
        stChnAttr.u32PicWidth   = 1920;
        stChnAttr.u32PicHeight  = 1080;
        stChnAttr.eVideoMode    = E_MI_VDEC_VIDEO_MODE_FRAME;
        stChnAttr.u32BufSize    = 1024*1024;
        stChnAttr.eDpbBufMode   = E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF;
        stChnAttr.stVdecVideoAttr.u32RefFrameNum = 1;
        stChnAttr.u32Priority = 0;
        stChnAttr.stVdecVideoAttr.stErrHandlePolicy.bUseCusPolicy = FALSE;
    
        s32Ret = MI_VDEC_CreateChn(VdecChn, &stChnAttr);
        if(MI_SUCCESS != s32Ret)
        {
            printf("MI_VDEC_CreateChn failed, s32Ret: 0x%x.\n", s32Ret);
            return s32Ret;
        }
    
        s32Ret = MI_VDEC_StartChn(VdecChn);
        if(MI_SUCCESS != s32Ret)
        {
            printf("MI_VDEC_StartChn failed, s32Ret: 0x%x.\n", s32Ret);
            return s32Ret;
        }
    
        stOutputPortAttr.u16Width  = 720;
        stOutputPortAttr.u16Height = 576;
        s32Ret = MI_VDEC_SetOutputPortAttr(VdecChn, &stOutputPortAttr);
        if(MI_SUCCESS != s32Ret)
        {
            printf("MI_VDEC_SetOutputPortAttr failed, s32Ret: 0x%x.\n", s32Ret);
            return s32Ret;
        }
    
        return MI_SUCCESS;
    }
    

2.4. MI_VDEC_DestroyChn

  • Function

    Destroy a decoding channel.

  • Syntax

    MI_S32 MI_VDEC_DestroyChn(MI_VDEC_CHN VdecChn);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_NOT_STOP Decoding is not stopped before destroying the channel.
    MI_ERR_VDEC_CHN_UNEXIST Channel does not exist.
    MI_ERR_VDEC_NOT_INIT Module not successfully initialized
    MI_ERR_VDEC_NOT_SUPPORT This operation or function is not supported.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before destroying the decoding channel, you must ensure that the channel has been created, otherwise the error code MI_ERR_VDEC_CHN_UNEXIST will be returned.

    • Before destroying the decoding channel, decoding should be stopped first, otherwise the error code MI_ERR_VDEC_CHN_NOT_STOP will be returned.

  • Example

    MI_S32 StopVdec(void)
    {
        MI_S32 s32Ret = MI_ERR_VDEC_FAILED;
        MI_VDEC_CHN VdecChn = 0;
    
        // Destroy send stream thread
        ...
    
        s32Ret = MI_VDEC_StopChn(VdecChn);
        if(MI_SUCCESS != s32Ret)
        {
            printf("MI_VDEC_StopChn failed, s32Ret: 0x%x.\n", s32Ret);
            return s32Ret;
        }
    
        s32Ret = MI_VDEC_DestroyChn(VdecChn);
        if(MI_SUCCESS != s32Ret)
        {
            printf("MI_VDEC_DestroyChn failed, s32Ret: 0x%x.\n", s32Ret);
            return s32Ret;
        }
    
        return MI_SUCCESS;
    }
    

2.5. MI_VDEC_GetChnAttr

  • Function

    Get video decoding channel attribute.

  • Syntax

    MI_S32 MI_VDEC_GetChnAttr(MI_VDEC_CHN VdecChn, 
    MI_VDEC_ChnAttr_t *pstChnAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstChnAttr Decoding channel attribute pointer. Data type: MI_VDEC_InitParam_t. Output
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_NULL_PTR The input parameter is a null pointer.
    MI_ERR_VDEC_CHN_UNEXIST Channel does not exist.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before getting channel attribute, be sure the channel has been created, otherwise the error code MI_ERR_VDEC_CHN_UNEXIST will be return.

2.6. MI_VDEC_StartChn

  • Function

    Start the channel decoding.

  • Syntax

    MI_S32 MI_VDEC_StartChn(MI_VDEC_CHN VdecChn);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed.
    MI_ERR_VDEC_CHN_NOT_STOP The channel does not stop decoding.
    MI_ERR_VDEC_NOT_SUPPORT The operation or function is not supported.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before the channel starts decoding, be sure the channel has been created; otherwise, the error code MI_ERR_VDEC_CHN_UNEXIST will be returned.

    • After the channel starts decoding, MI_VDEC_SendStream will be called to send stream successfully.

    • Repeated calling of the interface will return MI_ERR_VDEC_CHN_NOT_STOP.

  • Example

    See the example of MI_VDEC_CreateChn.


2.7. MI_VDEC_StopChn

  • Function

    Stop the channel decoding.

  • Syntax

    MI_S32 MI_VDEC_StopChn(MI_VDEC_CHN VdecChn);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_NOT_START Channel not started or already stopped
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before calling this interface, be sure the channel has been created; otherwise, the error code MI_ERR_VDEC_CHN_UNEXIST will be returned.

    • Before calling this interface, be sure the channel has been enable; otherwise, the error code MI_ERR_VDEC_CHN_NOT_START will be returned.

    • Calling the video stream sending interface MI_VDEC_SendStream after calling this function will return failed.

    • Repeated calling of this interface will return the error code MI_ERR_VDEC_CHN_NOT_START.

  • Example

    See the example of MI_VDEC_DestroyChn.


2.8. MI_VDEC_GetChnStat

  • Function

    Get the decoding channel status.

  • Syntax

    MI_S32 MI_VDEC_GetChnStat (MI_VDEC_CHN VdecChn, 
    MI_VDEC_ChnStat_t *pstChnStat);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstChnStat Decoding channel status structure pointer. Output
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_NULL_PTR The input parameter is a null pointer.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before getting channel attribute, be sure the channel has been created, otherwise the error code MI_ERR_VDEC_CHN_UNEXIST will be return.
  • Example

    See the example of MI_VDEC_SendStream.


2.9. MI_VDEC_FlushChn

  • Function

    Clear decoding channel cache.

  • Syntax

    MI_S32 MI_VDEC_FlushChn(MI_VDEC_CHN VdecChn);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input

  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful.
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_CHN_NOT_START Channel not started or already stopped.

  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface can be used to clear the cached data of decoding channel when switching to other GOP during decoding, so that decoding can continue.

2.10. MI_VDEC_ResetChn

  • Function

    Reset a decoding channel.

  • Syntax

    MI_S32 MI_VDEC_ResetChn(MI_VDEC_CHN VdecChn);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful.
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_NOT_PERM Unable to reset channel. This function cannot be called along with the MI_VDEC_SendStream.
    MI_ERR_VDEC_NOT_SUPPORT The operation or function is not supported.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is currently not supported.

2.11. MI_VDEC_SetChnParam

  • Function

    Set decoding channel parameter.

  • Syntax

    MI_S32 MI_VDEC_SetChnParam(MI_VDEC_CHN VdecChn, 
    MI_VDEC_ChnParam_t *pstChnParam);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstChnParam Channel parameter. Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
    MI_ERR_VDEC_NOT_PERM Illegal operation. Before calling this function, call MI_VDEC_StopChn to stop channel decoding first.
    MI_ERR_VDEC_NOT_SUPPORT The operation or function is not supported.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is currently not supported.

2.12. MI_VDEC_GetChnParam

  • Function

    Get decoding channel parameter.

  • Syntax

    MI_S32 MI_VDEC_GetChnParam(MI_VDEC_CHN VdecChn, 
    MI_VDEC_ChnParam_t *pstChnParam);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstChnParam Channel parameter. Output
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
    MI_ERR_VDEC_NOT_SUPPORT The operation or function is not supported.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is currently not supported.

2.13. MI_VDEC_SendStream

  • Function

    Send video stream data to decoding channel.

  • Syntax

    MI_S32 MI_VDEC_SendStream(MI_VDEC_CHN VdecChn, 
    MI_VDEC_VideoStream_t *pstVideoStream, MI_S32 s32MilliSec);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstVideoStream Decoding code stream data pointer. Please refer to the definition given in MI_VDEC_VideoStream_t. Input
    s32MilliSec Set data push timeout time parameter.
    Range:
    -1: Blocked.
    0: Not blocked.
    Positive values: Timeout time, unit is ms.
    Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
    MI_ERR_VDEC_CHN_NOT_START The channel is disabled.
    MI_ERR_VDEC_NOT_PERM Illegal operation, e.g. channel not ready.
    MI_ERR_VDEC_BUF_FULL The stream buffer before decoding is full.
    MI_ERR_VDEC_NOMEM Memory allocation fails (due to for example insufficient memory).
    MI_ERR_VDEC_BADADDR Bad address.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Stream-based data transmissions is currently not supported.

    • Setting the blocking time of the interface is currently not supported.

    • For frame-based case, an entire data frame should be transmitted for each transmission at a time.

    • If the user sets pstVideoStream->u64PTS = -2 when sending the stream, VDEC will discard the frame after decoding. It can be set as required.

    • This interface and MI_VDEC_DecRepeatFrame can be used together to decode duplicate frames. See MI_VDEC_DecRepeatFrame description for details.

  • Example

    An entire data frame must be sent for each transmission in frame-based transmission. If the current data frame failed during the transmission, re-transmission is required.

    MI_S32 VdecSendStream(void)
    {
        MI_S32 s32Ret = MI_ERR_VDEC_FAILED;
        MI_VDEC_CHN VdecChn = 0;
        MI_S32 s32MilliSec = 0;
        MI_VDEC_VideoStream_t stVideoStream;
        MI_VDEC_ChnAttr_t stChnAttr;
        MI_VDEC_ChnStat_t stChnStat;
    
        do{
            //Check if you need stop sending stream
            if(bStop)
            {
                break;
            }
    
            memset(&stChnAttr, 0x0, sizeof(MI_VDEC_ChnAttr_t));
            s32Ret = MI_VDEC_GetChnAttr(VdecDev, VdecChn, &stChnAttr);
            if(MI_SUCCESS != s32Ret)
            {
                printf("MI_VDEC_GetChnAttr failed, s32Ret: 0x%x.\n", s32Ret);
                return s32Ret;
            }
    
            memset(&stChnStat, 0x0, sizeof(MI_VDEC_ChnStat_t));
            s32Ret = MI_VDEC_GetChnStat(VdecChn, &stChnStat);
            if(MI_SUCCESS != s32Ret)
            {
                printf("MI_VDEC_SendStream failed, s32Ret: 0x%x.\n", s32Ret);
                return s32Ret;
            }
    
            //suggest to check chn status
            if(stChnAttr.u32Bufsize - stChnStat.u32LeftStreamBytes < u32StreamSize)
            {
                continue;
            }
    
            memset(&stVideoStream, 0x0, sizeof(MI_VDEC_VideoStream_t));
            stVideoStream.pu8Addr = pu8StreamBuf;
            stVideoStream.u32Len  = u32StreamSize;
            stVideoStream.u64PTS  = u64StreamPts;
            stVideoStream.bEndOfFrame  = TRUE;
            stVideoStream.bEndOfStream = FALSE;
            s32MilliSec = 30;                    //30ms
            s32Ret = MI_VDEC_SendStream(VdecChn, &stVideoStream, s32MilliSec);
            if(MI_SUCCESS != s32Ret)
            {
                printf("MI_VDEC_SendStream failed, s32Ret: 0x%x.\n", s32Ret);
                continue;
            }
        }while(!ShouldStop);
    
        return MI_SUCCESS;
    }
    

2.14. MI_VDEC_GetUserData

  • Function

    Get decoding channel user data.

  • Syntax

    MI_S32 MI_VDEC_GetUserData(MI_VDEC_CHN VdecChn, 
    MI_VDEC_UserData_t *pstUserData, MI_S32 s32MilliSec);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    s32MilliSec Get user data timeout definition.
    Range:
    -1: Blocked.
    0: Not blocked.
    Positive values: Timeout time, unit is ms.
    Input
    pstUserData Decoded user data. Please refer to the definition given in MI_VDEC_UserData_t. Output
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed.
    MI_ERR_VDEC_NOT_PERM Illegal operation, e.g. channel not ready.
    MI_ERR_VDEC_BUF_FULL Data frame buffer full after decoding.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is currently not supported.

2.15. MI_VDEC_ReleaseUserData

  • Function

    Release user data.

  • Syntax

    MI_S32 MI_VDEC_ReleaseUserData(MI_VDEC_CHN VdecChn, 
    MI_VDEC_UserData_t *pstUserData);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstUserData Decoded user data pointer, gotten by MI_VDEC_UserData_t interface. Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed.
    MI_ERR_VDEC_NOT_PERM Illegal operation, e.g. channel not ready.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is currently not supported.

2.16. MI_VDEC_SetDisplayMode

  • Function

    Set decoding channel display mode.

  • Syntax

    MI_S32 MI_VDEC_SetDisplayMode(MI_VDEC_CHN VdecChn,MI_VDEC_DisplayMode_e eDisplayMode);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    eDisplayMode Display mode enumeration.
    Please refer to the definition given in MI_VDEC_DisplayMode_e.
    Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is currently not supported.

2.17. MI_VDEC_GetDisplayMode

  • Function

    Get decoding channel display mode.

  • Syntax

    MI_S32 MI_VDEC_GetDisplayMode(MI_VDEC_CHN VdecChn, 
    MI_VDEC_DisplayMode_e *peDisplayMode);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    peDisplayMode Display mode enumeration pointer. Please refer to the definition given in MI_VDEC_DisplayMode_e. Output
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_NULL_PTR The input parameter is a null pointer.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • This interface is currently not supported.

2.18. MI_VDEC_SetOutputPortAttr

  • Function

    Set decoding channel output port attribute

  • Syntax

    MI_S32 MI_VDEC_SetOutputPortAttr (MI_VDEC_CHN VdecChn, 
    MI_VDEC_OutputPortAttr_t *pstOutputPortAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstOutputPortAttr Output port attribute. Please refer to the definition given in MI_VDEC_OutputPortAttr_t. Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
    MI_ERR_VDEC_NULL_PTR Null pointer
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before calling this function, be sure the channel to be used has been created; otherwise, an error code of channel not created (MI_ERR_VDEC_CHN_UNEXIST) will be returned.

    • The scaling width and height need to be aligned by 2.

    • Scaling range[⅛, 1].

    • Scaling up is not supported.

  • Example

    See the example of MI_VDEC_CreateChn.


2.19. MI_VDEC_GetOutputPortAttr

  • Function

    Get decoding channel output port attribute.

  • Syntax

    MI_S32 MI_VDEC_GetOutputPortAttr(MI_VDEC_CHN VdecChn, 
    MI_VDEC_OutputPortAttr_t *pstOutputPortAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    pstOutputPortAttr Output port attribute. Please refer to the definition given in MI_VDEC_OutputPortAttr_t Output
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
    MI_ERR_VDEC_NULL_PTR Null pointer.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before calling this function, be sure the channel to be used has been created; otherwise, an error code of channel not created (MI_ERR_VDEC_CHN_UNEXIST) will be returned.

2.20. MI_VDEC_SetOutputPortLayoutMode

  • Function

    Set output port layout mode

  • Syntax

    MI_S32 MI_VDEC_SetOutputPortLayoutMode
    (MI_VDEC_OutbufLayoutMode_e eBufTileMode);
    
  • Parameter

    Parameter Name Description Input/Output
    eBufTileMode Output buffer mode. Please refer to the definition given in MI_VDEC_OutbufLayoutMode_e. Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_NOT_INIT Device not initialized.
    MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter.
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before calling this function, be sure the device has been initialized; otherwise, an error code of channel not created (MI_ERR_VDEC_NOT_INIT) will be returned.

    • This function is only used for chip Takoyaki.

  • Example

    MI_S32 StartVdec(void)
    {
        MI_S32 s32Ret = MI_ERR_VDEC_FAILED;
        MI_VDEC_CHN VdecChn = 0;
        MI_VDEC_OutbufLayoutMode_e eBufTileMode = E_MI_VDEC_OUTBUF_LAYOUT_MAX;
        MI_VDEC_ChnAttr_t stChnAttr;
    
        memset(&stChnAttr, 0x0, sizeof(MI_VDEC_ChnAttr_t));
    
        eBufTileMode = E_MI_VDEC_OUTBUF_LAYOUT_AUTO;
        s32Ret = MI_VDEC_SetOutputPortLayoutMode(eBufTileMode) ;
        if(MI_SUCCESS != s32Ret)
        {
            printf("MI_VDEC_SetOutputPortLayoutMode failed, s32Ret: 0x%x.\n", s32Ret);
            return s32Ret;
        }
    
        VdecChn = 0;
        stChnAttr.eCodecType    = E_MI_VDEC_CODEC_TYPE_H264;
        stChnAttr.u32PicWidth   = 1920;
        stChnAttr.u32PicHeight  = 1080;
        stChnAttr.eVideoMode    = E_MI_VDEC_VIDEO_MODE_FRAME;
        stChnAttr.u32BufSize    = 1024*1024;
        stChnAttr.eDpbBufMode   = E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF;
        stChnAttr.stVdecVideoAttr.u32RefFrameNum = 1;
        stChnAttr.u32Priority = 0;
        stChnAttr.stVdecVideoAttr.stErrHandlePolicy.bUseCusPolicy = FALSE;
    
        s32Ret = MI_VDEC_CreateChn(VdecChn, &stChnAttr);
        if(MI_SUCCESS != s32Ret)
        {
            printf("MI_VDEC_CreateChn failed, s32Ret: 0x%x.\n", s32Ret);
            return s32Ret;
        }
    
        return MI_SUCCESS;
    }
    

2.21. MI_VDEC_GetOutputPortLayoutMode

  • Function

    Get output port layout mode

  • Syntax

    MI_S32 MI_VDEC_GetOutputPortLayoutMode
    (MI_VDEC_OutbufLayoutMode_e *peBufTileMode);
    
  • Parameter

    Parameter Name Description Input/Output
    peBufTileMode Output buffer mode. Please refer to the definition given in MI_VDEC_OutbufLayoutMode_e. Output
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_NOT_INIT Device not initialized.
    MI_ERR_VDEC_NULL_PTR Null pointer
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • Before calling this function, be sure the device has been initialized; otherwise, an error code of channel not created (MI_ERR_VDEC_NOT_INIT) will be returned.

    • This function is only used for chip Takoyaki.


2.22. MI_VDEC_DecRepeatFrame

  • Function

    Repeatedly decode the current frame

  • Syntax

    MI_S32 MI_VDEC_DecRepeatFrame(MI_VDEC_CHN VdecChn, 
    MI_BOOL bCancleRepeatFrame);
    
  • Parameter

    Parameter Name Description Input/Output
    VdecChn Video decoding channel number.
    Range: [0, MI_VDEC_MAX_CHN_NUM).
    Input
    bCancleRepeatFrame Whether to cancel repeated decoding of the current frame. Data type: MI_BOOL. Input
  • Return Value

    Return Value Description
    MI_SUCCESS Successful
    MI_ERR_VDEC_FAILED Unsuccessful
    MI_ERR_VDEC_INVALID_CHNID Invalid channel ID.
    MI_ERR_VDEC_CHN_UNEXIST Channel not created or already destroyed
  • Requirement

    • Header: mi_vdec.h

    • Library: libmi_vdec.a/libmi_vdec.so

  • Note

    • The channel number cannot exceed the maximum channel range allowed.

    • Before calling this function, be sure the channel to be used has been created; otherwise, an error code of channel not created (MI_ERR_VDEC_CHN_UNEXIST) will be returned.

    • Repeatedly decode the current frame:

      1. User can call MI_VDEC_SendStream, and set bRepeatFrame to TRUE to mark the current frame as a duplicate frame;

      2. When the user calls this interface and sets bCancelRepeatFrame to FALSE, the decoder will repeatedly decode the current incoming frame;

      3. Every time the interface is called, VDEC will repeatedly decode the current frame.

    • Cancel repeatedly decode the current frame:

      By calling this interface and setting bCancelRepeatFrame to TRUE, the user can cancel the repeated decoding of the current frame and return to the normal decoding process of the next frame.

    • This function is only used for chip Taiyaki.

  • Related API

    MI_VDEC_SendStream.


3. DATA TYPE

The video decoder related data types and data structures are defined in the table below:

Data Structure Description
MI_VDEC_CodecType_e Define decoding type
MI_VDEC_DPB_BufMode_e Define DPB buffer mode
MI_VDEC_JpegFormat_e Define JPEG image data format
MI_VDEC_VideoMode_e Define code stream transmission method
MI_VDEC_ErrCode_e Define error code type
MI_VDEC_DecodeMode_e Define video stream decoding mode
MI_VDEC_OutputOrder_e Define decoding output order
MI_VDEC_VideoFormat_e Define decoded image data format
MI_VDEC_DisplayMode_e Define display mode
MI_VDEC_OutbufLayoutMode_e Define output buffer layout mode
MI_VDEC_InitParam_t Define decoding device initialization parameter structure
MI_VDEC_ChnAttr_t Define video decoding channel attribute
[MI_VDEC_JpegAttr_t](#313-mi_vdec_jpegattr_t Define JPEG video decoding channel attribute
MI_VDEC_VideoAttr_t Define video decoding channel attribute
MI_VDEC_ChnStat_t Define channel status structure
MI_VDEC_ChnParam_t Define decoding channel parameter structure
MI_VDEC_VideoStream_t Define decoding video stream structure
MI_VDEC_UserData_t Define user data structure
MI_VDEC_OutputPortAttr_t Define output port attribute
MI_VDEC_ErrHandlePolicy_t Define error macroblock handle policy structure

3.1. MI_VDEC_CodecType_e

  • Description

    Define decoding type.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_CODEC_TYPE_H264 = 0x0,    /* H264 */
    
        E_MI_VDEC_CODEC_TYPE_H265,      /* H265 */
    
        E_MI_VDEC_CODEC_TYPE_JPEG,      /* JPEG */
    
        E_MI_VDEC_CODEC_TYPE_MAX
    
    } MI_VDEC_CodecType_e;
    
  • Member

    Member Description
    E_MI_VDEC_CODEC_TYPE_H264 H264 decoding.
    E_MI_VDEC_CODEC_TYPE_H265 H265 decoding.
    E_MI_VDEC_CODEC_TYPE_JPEG JPEG decoding.
  • Note

    • Currently, users are not supported to set JPEG decoding.

3.2. MI_VDEC_DPB_BufMode_e

  • Description

    Define DPB buffer mode

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_DPB_MODE_NORMAL=0,
    
        E_MI_VDEC_DBP_MODE_INPLACE_ONE_BUF=1,
    
        E_MI_VDEC_DBP_MODE_INPLACE_TWO_BUF=2,
    
        E_MI_VDEC_DPB_MODE_INVALID=0xFFFFFFFF
    
    } MI_VDEC_DPB_BufMode_e;
    
  • Member

    Member Description
    E_MI_VDEC_DPB_MODE_NORMAL Normal buffer mode
    E_MI_VDEC_DBP_MODE_INPLACE_ONE_BUF Inplace one buffer mode.
    E_MI_VDEC_DBP_MODE_INPLACE_TWO_BUF Inplace two buffer mode.

3.3. MI_VDEC_JpegFormat_e

  • Description

    Define JPEG image data format.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_JPEG_FORMAT_YCBCR400 = 0x0, /*YUV400*/
    
        E_MI_VDEC_JPEG_FORMAT_YCBCR420, /*YUV420*/
    
        E_MI_VDEC_JPEG_FORMAT_YCBCR422, /*YUV 422*/
    
        E_MI_VDEC_JPEG_FORMAT_YCBCR444, /*YUV 444*/
    
        E_MI_VDEC_JPEG_FORMAT_MAX
    
    } MI_VDEC_JpegFormat_e;
    
  • Note

    • The related functions of this parameter are not supported currently.

3.4. MI_VDEC_VideoMode_e

  • Description

    Define code stream transmission mode.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_VIDEO_MODE_STREAM = 0x0,
    
        E_MI_VDEC_VIDEO_MODE_FRAME,
    
        E_MI_VDEC_VIDEO_MODE_MAX
    
    } MI_VDEC_VideoMode_e;
    
  • Member

    Member Description
    E_MI_VIDEO_MODE_STREAM Send code stream in stream-based method.
    E_MI_VIDEO_MODE_FRAME Send code stream in frame-based method.
  • Note

    • Stream-based data transmissions is currently not supported.

3.5. MI_VDEC_ErrCode_e

  • Description

    Define error code type.

  • Syntax

    typedef enum
    {
        E_MI_VDEC_ERR_CODE_UNKNOW = 0x0,
        E_MI_VDEC_ERR_CODE_ILLEGAL_ACCESS,
        E_MI_VDEC_ERR_CODE_FRMRATE_UNSUPPORT,
        E_MI_VDEC_ERR_CODE_DEC_TIMEOUT,
        E_MI_VDEC_ERR_CODE_OUT_OF_MEMORY,
        E_MI_VDEC_ERR_CODE_CODEC_TYPE_UNSUPPORT,
        E_MI_VDEC_ERR_CODE_ERR_SPS_UNSUPPORT,
        E_MI_VDEC_ERR_CODE_ERR_PPS_UNSUPPORT,
        E_MI_VDEC_ERR_CODE_REF_LIST_ERR,
        E_MI_VDEC_ERR_CODE_MAX
    } MI_VDEC_ErrCode_e;
    
  • Member

    Member Description
    E_MI_VDEC_ERR_CODE_UNKNOW Unknown error.
    E_MI_VDEC_ERR_CODE_ILLEGAL_ACCESS Illegal access, e.g. HW not yet initialized or has an error.
    E_MI_VDEC_ERR_CODE_FRMRATE_UNSUPPORT Unsupported frame rate
    E_MI_VDEC_ERR_CODE_DEC_TIMEOUT Coding timeout
    E_MI_VDEC_ERR_CODE_OUT_OF_MEMORY Out of memory
    E_MI_VDEC_ERR_CODE_CODEC_TYPE_UNSUPPORT Unsupported decoding type
    E_MI_VDEC_ERR_CODE_ERR_SPS_UNSUPPORT Unsupported SPS or SPS error
    E_MI_VDEC_ERR_CODE_ERR_PPS_UNSUPPORT Unsupported PPS or PPS error
    E_MI_VDEC_ERR_CODE_REF_LIST_ERR Reference frame list error

3.6. MI_VDEC_DecodeMode_e

  • Description

    Define video stream decoding mode.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_DECODE_MODE_ALL = 0x0,
    
        E_MI_VDEC_DECODE_MODE_I,
    
        E_MI_VDEC_DECODE_MODE_IP,
    
        E_MI_VDEC_DECODE_MODE_MAX
    
    } MI_VDEC_DecodeMode_e;
    
  • Member

    Member Description
    E_MI_VDEC_DECODE_MODE_ALL Decode IPB data frame
    E_MI_VDEC_DECODE_MODE_I Decode I frame only
    E_MI_VDEC_DECODE_MODE_IP Decode IP frame only (B skipped)
  • Note

    • The related functions of this parameter are not supported currently.

3.7. MI_VDEC_OutputOrder_e

  • Description

    Define decoding output order.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_OUTPUT_ORDER_DISPLAY = 0x0,
    
        E_MI_VDEC_OUTPUT_ORDER_DECODE,
    
        E_MI_VDEC_OUTPUT_ORDER_MAX,
    
    } MI_VDEC_OutputOrder_e;
    
  • Member

    Member Description
    E_MI_VDEC_OUTPUT_ORDER_DISPLAY Output data frame by display order
    E_MI_VDEC_OUTPUT_ORDER_DECODE Output data frame by decoding order
  • Note

    • The data frames are output in the display order by default, and user settings are not supported.

3.8. MI_VDEC_VideoFormat_e

  • Description

    Define decoded image data format.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_VIDEO_FORMAT_TILE = 0x0,
    
        E_MI_VDEC_VIDEO_FORMAT_REDUCE,
    
        E_MI_VDEC_VIDEO_FORMAT_MAX
    
    } MI_VDEC_VideoFormat_e;
    
  • Member

    Member Description
    E_MI_VDEC_VIDEO_FORMAT_TILE TILE data format.
    E_MI_VDEC_VIDEO_FORMAT_REDUCE Data frame compressed format, to reduce memory used by the data frame.
  • Note

    • The current data type does not support upper layer setting. You should return to the supported data types.

3.9. MI_VDEC_DisplayMode_e

  • Description

    Define display mode.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_DISPLAY_MODE_PREVIEW = 0x0,
    
        E_MI_VDEC_DISPLAY_MODE_PLAYBACK,
    
        E_MI_VDEC_DISPLAY_MODE_MAX,
    
    } MI_VDEC_DisplayMode_e;
    
  • Member

    Member Description
    E_MI_DISPLAY_MODE_PREVIEW Preview mode.
    E_MI_DISPLAY_MODE_PLAYBACK Playback mode.
  • Note

    • This parameter is currently not supported.

3.10. MI_VDEC_OutbufLayoutMode_e

  • Description

    Define output buffer layout mode.

  • Syntax

    typedef enum
    
    {
    
        E_MI_VDEC_OUTBUF_LAYOUT_AUTO = 0x0,
    
        E_MI_VDEC_OUTBUF_LAYOUT_LINEAR,
    
        E_MI_VDEC_OUTBUF_LAYOUT_TILE,
    
        E_MI_VDEC_OUTBUF_LAYOUT_MAX
    
    } MI_VDEC_OutbufLayoutMode_e;
    
  • Member

    Member Description
    E_MI_VDEC_OUTBUF_LAYOUT_AUTO Automatic mode.
    E_MI_VDEC_OUTBUF_LAYOUT_LINEAR Linear mode.
    E_MI_VDEC_OUTBUF_LAYOUT_TILE Tile mode.
  • Note

    • The rotation function of the MI_DISP module is linked to the TILE mode of the MI_VDEC module. If the MI_DISP module needs to turn on the rotation function, the buffer sent by its front end must be in TILE format. The MI_VDEC module has two ways to output images in TILE format.

      1) When the output buffer mode is E_MI_VDEC_OUTBUF_LAYOUT_AUTO (default), the MI_DISP module and the MI_VDEC module need to be bound; at this time, the MI_DISP module turns on the rotation, and at the same time informs the MI_VDEC module through u64SidebandMsg, and then the MI_VDEC module automatically turns on the TILE mode to complete the rotate function. If the MI_DISP module turns off the rotation, the MI_VDEC module will also be notified through u64SidebandMsg, and then the MI_VDEC module will automatically turn off the TILE mode. This process does not require user processing and is automatically completed by the module.

      2) When the output buffer mode is E_MI_VDEC_OUTBUF_LAYOUT_TILE, the MI_VDEC module only outputs images in TILE format. The MI_DISP module must turn on the rotation function to display the TILE format images normally. In this mode, the MI_VDEC module and the MI_DISP module can be directly bound, or the user can obtain the output buffer of the MI_VDEC module, and then send it to the MI_DISP module.

    • If MI_VDEC module needs to output LINEAR image, there are two ways.

      1) When the output buffer mode is E_MI_VDEC_OUTBUF_LAYOUT_AUTO (default), if the MI_VDEC module is bound to the MI_DISP module, the MI_DISP module will turn off the rotation and you can output the LINEAR image. In other cases, LINEAR images are output.

      2) When the output buffer mode is E_MI_VDEC_OUTBUF_LAYOUT_LINEAR, the MI_VDEC module only outputs LINEAR images.

    • In TILE mode, the output buffer alignment of MI_VDEC module is as follows:

      Chip TILE output buffer alignment requirements (BYTE)
      Taiyaki 128x32
      Takoyaki 128x32

      Therefore, when setting the output buffer width and height of the MI_VDEC module through MI_VDEC_OutputPortAttr_t, you also need to follow the TILE output buffer alignment requirements, otherwise the output image will be abnormal.

      For example: TILE output buffer alignment requirement is 128x32, so does MI_VDEC_OutputPortAttr_t sets the width and height of MI_VDEC module output buffer.


3.11. MI_VDEC_InitParam_t

  • Description

    Define decoding device initialization parameter structure.

  • Syntax

    typedef struct MI_VDEC_InitParam_s
    
    {
    
        MI_BOOL bDisableLowLatency;
    
    } MI_VDEC_InitParam_t;
    
  • Member

    Member Description
    bDisableLowLatency Enable or disable low latency mode, default value is false. Parameter type: MI_BOOL
  • Note

    • If bDisableLowLatency is set to true, it means low latency is turned off. This case is applicable to decoding B frame, and it is used to reorder the output of B frame, and the output image will have delay. In addition, the reorder operation will increase memory usage.

    • By default, the low latency mode is enabled, i.e. bdisablelowlatency is false. If the scene does not involve a delay mode, MI_VDEC_InitDev does not need to be called.


3.12. MI_VDEC_ChnAttr_t

  • Description

    Define decoding channel attribute.

  • Syntax

    typedef struct MI_VDEC_ChnAttr_s { MI_VDEC_CodecType_e eCodecType; MI_U32 u32BufSize MI_U32 u32Priority MI_U32 u32PicWidth MI_U32 u32PicHeight MI_VDEC_VideoMode_e eVideoMode MI_VDEC_DPB_BufMode_e eDpbBufMode; union { MI_VDEC_JpegAttr_t stVdecJpegAttr; MI_VDEC_VideoAttr_t stVdecVideoAttr; }; } MI_VDEC_ChnAttr_t;

  • Member

    Member Description
    eCodecType Decoding type enumeration value. Parameter type: MI_VDEC_CodecType_e
    u32BufSize Code stream buffer size.
    u32Priority Channel priority, parameter range is 1 ~ 255. The bigger the value, the higher the priority. Note: This function is currently not supported.
    u32PicWidth Max. width of decoded image supported by channel (unit: pixel)
    u32PicHeight Max. height of decoded image supported by channel (unit: pixel)
    eVideoMode Code stream transmission method. Note: Currently, only frame-based transmission is supported.
    eDpbBufMode DPB buffer mode. Note: eDpbBufMode=1 is used only for bitstream which has only one reference frame; eDpbBufMode=2 is used only for bitstream which has only two reference frames; eDpbBufMode=0 is used for all different kinds of bitstream.
    stVdecJpegAttr JPEG channel related attribute, currently not available for configuration.
    stVdecVideoAttr Attribute of all supported channel types except JPEG.
  • Note

    • The value of u32RefFrameNum will be invalid when eInplaceMode is set to E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF or E_MI_VDEC_DPB_MODE_INPLACE_TWO_BUF.

    • E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF and E_MI_VDEC_DPB_MODE_INPLACE_TWO_BUF are memory saving modes. The E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF decoder only allocates one reference frame, so it can only decode the video stream of one reference frame. In the same way, E_MI_VDEC_DPB_MODE_INPLACE_TWO_BUF only allocates two reference frames at most, so it can only decode the video stream of two reference frames. E_MI_VDEC_DPB_MODE_NORMAL is used for video stream more than two reference frames. For example, when set to E_MI_VDEC_DPB_MODE_NORMAL mode, to decode the video stream of one reference frame, the decoder needs to apply for two reference frames to decode normally, which will apply for 1 reference frame more than E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF memory saving mode.

    • When eDpbBufMode is E_MI_VDEC_DPB_MODE_NORMAL, you need to set the value of u32RefFrameNum to limit the maximum number of reference frames and avoid allocating too many frame buffers; if the value of u32RefFrameNum is less than the number of reference frames required for current decoding, the decoder may not decode or decode the abnormal image.

    • If the number of video stream reference frames cannot be determined in advance, it is recommended to set E_MI_VDEC_DPB_MODE_NORMAL mode, and the maximum number of applied reference frames u32RefFrameNum is set to 16. The decoder will automatically analyze the number of reference frames required for the video stream to apply. For example, u32RefFrameNum is set to 16, and the current video stream decoding requires 3 reference frames, then the decoder will apply for 4 reference frames; on the contrary, if u32RefFrameNum is set to 2, the current decoding requires 3 reference frames, then the decoder can only apply for 2 reference frames and cannot decode normally.


3.13. MI_VDEC_JpegAttr_t

  • Description

    Define JPEG decoding channel attribute.

  • Syntax

    typedef struct MI_VDEC_JpegAttr_s
    
    {
    
        MI_VDEC_JpegFormat_e eJpegFormat;
    
    }MI_VDEC_JpegAttr_t;
    
  • Member

    Member Description
    eJpegFormat JPEG image storage format. Range is [0,E_MI_JPEG_FORMAT_MAX).
  • Note

    • Currently the related function of this parameter is not supported.

3.14. MI_VDEC_VideoAttr_t

  • Description

    Define video decoding channel attribute.

  • Syntax

    typedef struct MI_VDEC_VideoAttr_s
    
    {
    
        MI_U32 u32RefFrameNum;
    
        MI_VDEC_ErrHandlePolicy_t stErrHandlePolicy;
    
    }MI_VDEC_VideoAttr_t;
    
  • Member

    Member Description
    u32RefFrameNum Reference frame number.
    Range: [0, 16], unit is frame. The number of reference frames decides the number of reference frames required for decoding and will influence the memory usage. We suggest setting an appropriate value according to each case concerned. For code stream testing, the recommended setting is 2.
    stErrHandlePolicy Set the output strategy for the data frame having erroneous MB. Please refer to the definition given in MI_VDEC_ErrHandlePolicy_t.
  • Note

    • The value of u32RefFrameNum will be invalid when eDpbBufMode is set to E_MI_VDEC_DPB_MODE_INPLACE_ONE_BUF or E_MI_VDEC_DPB_MODE_INPLACE_TWO_BUF.

    • When eDpbBufMode is set to E_MI_VDEC_DPB_MODE_NORMAL, u32RefFrameNum must be set to limit the maximum number of reference frames. If the value of u32RefFrameNum is smaller than the number of the frame buffer that the decoder needs, the decoder may not start decoding or abnormal image may be output.

    • The parameter stErrHandlePolicy is only used for chip Takoyaki.


3.15. MI_VDEC_ChnStat_t

  • Description

    Define channel status structure.

  • Syntax

    typedef MI_VDEC_ChnStat_s
    {
        MI_VDEC_CodecType_e eCodecType;
        MI_U32  u32LeftStreamBytes; 
        MI_U32  u32LeftStreamFrames;
        MI_U32  u32LeftPics;
        MI_BOOL bChnStart;
        MI_U32 u32RecvStreamFrames;
        MI_U32 u32DecodeStreamFrames;
        MI_VDEC_ErrCode_e eErrCode;
    } MI_VDEC_ChnStat_t;
    
  • Member

    Member Description
    eCodecType Decoding type
    u32LeftStreamBytes Number of bytes to be decoded in code stream buffer.
    u32LeftStreamFrames Number of frames to be decoded in code stream buffer. –1 represents invalid setting. This parameter works only for frame-based transmission.
    u32LeftPics Number of pictures remaining in the image buffer.
    bChnStart Indicates whether decoder has been enabled to receive code stream.
    u32RecvStreamFrames Number of code stream frames received in the code stream buffer. –1 represents invalid setting. This parameter works only for frame-based transmission.
    u32DecodeStreamFrames Number of decoded frames in the code stream buffer.
    eErrCode Decoding error message.

3.16. MI_VDEC_ChnParam_t

  • Description

    Define decoding channel parameter.

  • Syntax

    typedef struct MI_VDEC_ChnParam_s
    {
        MI_VDEC_DecodeMode_e eDecMode;
        MI_VDEC_OutputOrder_e eOutputOrder;
        MI_VDEC_VideoFormat_e eVideoFormat;
    } MI_VDEC_ChnParam_t;
    
  • Member

    Member Description
    eDecMode Decoding mode, please refer to MI_VDEC_DecodeMode_e definition. Default is E_MI_VDEC_DECODE_MODE_IP. E_MI_VDEC_DECODE_MODE_ALL requires more memory usage.
    eOutputOrder Please refer to the definition given in MI_VDEC_OutputOrder_e. Default is E_MI_VDEC_OUTPUT_ORDER_DECODE, outputting frames by decoding order.
    eVideoFormat Please refer to the definition given in MI_VDEC_VideoFormat_e.
  • Note

    • Currently these parameters cannot be set.

3.17. MI_VDEC_VideoStream_t

  • Description

    Define video coding code stream structure.

  • Syntax

    typedef struct MI_VDEC_VideoStream_s
    
    {
    
        MI_U8* pu8Addr;
    
        MI_U32 u32Len;
    
        MI_U64 u64PTS;
    
        MI_BOOL bEndOfFrame;
    
        MI_BOOL bEndOfStream;
    
        MI_BOOL bRepeatFrame;
    
    }MI_VDEC_VideoStream_t;
    
  • Member

    Member Description
    pu8Addr Code stream packet address.
    u32Len Code stream packet length, unit is word.
    u64PTS Code stream packet timestamp, unit is millisecond.
    bEndOfFrame End of frame indication (reserved function). Currently only frame-based transmission under frame mode is supported.
    bEndOfStream End of code stream indication. When all the code stream data frames have been transmitted, bEndOfStream must be set to TRUE.
  • Note

    • Stream-based data transmissions is currently not supported. For frame-based case, an entire data frame should be transmitted for each transmission at a time.

    • If the video stream frame data contains PTS, the decoded output data will output the same PTS. When u64PTS=-2, the frame will be discarded by VDEC after decoding. It can be set as required.


3.18. MI_VDEC_UserData_t

  • Description

    Define user data structure.

  • Syntax

    typedef struct MI_VDEC_UserData_s
    
    {
    
        MI_U8* pu8Addr;
    
        MI_U32 u32Len;
    
        MI_BOOL bValid;
    
    } MI_VDEC_UserData_t;
    
  • Member

    Member Description
    pu8Addr User data virtual address.
    u32Len User data length, in byte unit.
    bValid Current data validity indication. Range:
  • Note

    • Currently the related function of this parameter is not supported.

3.19. MI_VDEC_OutputPortAttr_t

  • Description

    Define output port attribute.

  • Syntax

    typedef struct MI_VDEC_OutputPortAttr_s
    
    {
    
        MI_U16 u16Width;             // Width of target image
    
        MI_U16 u16Height;            // Height of target image
    
    }MI_VDEC_OutputPortAttr_t;
    
  • Member

    Member Description
    u16Width Width of output image
    u16Height Height of output image
  • Note

    • Scaling width and height need to be aligned by 2.

    • Scaling range[⅛, 1].

    • Scaling up is not supported.


3.20. MI_VDEC_ErrHandlePolicy_t

  • Description

    Define error macroblock handle policy structure.

  • Syntax

    typedef struct MI_VDEC_ErrHandlePolicy_s
    
    {
    
        MI_BOOL bUseCusPolicy;     // FALSE: use default; TRUE: use customized value
    
        MI_U8 u8ErrMBPercentThreshold;
    
    } MI_VDEC_ErrHandlePolicy_t;
    
  • Member

    Member Description
    bUseCusPolicy Decide whether to customize the error frame output strategy.
    u8ErrMBPercentThreshold Set the ratio of the number of error macroblocks to the number of macro blocks in the whole data frame in the case where the data frame is not output. The value range is [0, 100].
  • Note

    • If the value of bUseCusPolicy is FALSE, it means no customization, and the u8ErrMBPercentThreshold will use the default value of 30 built in the system; if the value of bUseCusPolicy is TRUE, the customized u8ErrMBPercentThreshold value is used.

    • The value range of u8ErrMBPercentThreshold is [0, 100]. For example, when the value is 10, it means that when the number of error macroblocks accounts for less than 10% of the total number of macroblocks in the whole frame, the output of the current frame will be displayed, otherwise (greater than or equal to 10%) it will not be displayed. When the value is 0, it means that frames which have error MB will not be displayed. When the value is 100, the current frame will be displayed no matter how many error MBs there are.

    • The u8ErrMBPercentThreshold value calculates the ratio value based on the MB.

    • This parameter is only used for chip Takoyaki.


4. Error code

The video decoding error code is shown in table 4-1:

Table 4-1: VDEC API error codes

Error Code Macro Definition Description
0xA0082001 MI_ERR_VDEC_INVALID_DEVID Invalid Device ID
0xA0082002 MI_ERR_VDEC_INVALID_CHNID Invalid Channel ID
0xA0082003 MI_ERR_VDEC_ILLEGAL_PARAM Illegal parameter or inputted parameter exceeding channel decoding capability
0xA0082004 MI_ERR_VDEC_CHN_EXIST Channel to be created already exists
0xA0082005 MI_ERR_VDEC_CHN_UNEXIST Channel does not exist
0xA0082006 MI_ERR_VDEC_NULL_PTR Null pointer
0xA0082007 MI_ERR_VDEC_NOT_CONFIG Not configured before use
0xA0082008 MI_ERR_VDEC_NOT_SUPPORT This operation or function is not supported
0xA0082009 MI_ERR_VDEC_NOT_PERM Illegal operation, for example, no user image is allowed to be inserted before performing this operation
0xA008200C MI_ERR_VDEC_NOMEM Memory allocation fails (due to for example insufficient memory)
0xA008200D MI_ERR_VDEC_NOBUF Buffer allocation fails(For example, the requested data buffer is too large)
0xA008200E MI_ERR_VDEC_BUF_EMPTY No data in buffer
0xA008200F MI_ERR_VDEC_BUF_FULL Buffer full
0xA0082010 MI_ERR_VDEC_SYS_NOTREADY The system is not initialized or the dependent modules are not loaded
0xA0082011 MI_ERR_VDEC_BADADDR Address error
0xA0082012 MI_ERR_VDEC_BUSY System busy
0xA0082013 MI_ERR_VDEC_CHN_NOT_START Channel not started or already stopped
0xA0082014 MI_ERR_VDEC_CHN_NOT_STOP Channel cannot be closed before code stream reception is stopped
0xA0082015 MI_ERR_VDEC_NOT_INIT Device is not initialized
0xA0082016 MI_ERR_VDEC_INITED Device to be initialized is already initialized
0xA0082017 MI_ERR_VDEC_NOT_ENABLE Decoder is not enabled
0xA0082018 MI_ERR_VDEC_NOT_DISABLE Decoder is not disabled
0xA008201F MI_ERR_VDEC_FAILED Unsuccessful

5. PROCFS INTRODUCTION


5.1. cat

  • Debug info

    # cat /proc/mi_modules/mi_vdec/mi_vdec0
    

  • Debug info analysis

    The printing is divided into two parts, separated by Private Vdec0 Info. The upper half is common information, and the lower half is vdec module information.

    It mainly records the usage and configuration attributes of the decoding channel, which can be used to check the attribute configuration and the working status of the current channel to facilitate debugging.

  • Parameter Description


    Parameter Description
      fwVersion Fw version
    VLC Buffer Status Idx Vlc buffer index
    State Vlc buffer state
    0: FREE;
    1: READY;
    2: USING
    Base Vlc buffer base address
    Phy Vlc buffer physical address
    Virt Vlc buffer virtual address
    Size Vlc buffer size
    CHN ATTR Info ChnID  Channel ID
    CodecType  Decoding protocol type
    0: H264;
    1: H265;
    2: JPEG
    Width  The maximum width of the decoded image.
    Height   The maximum height of the decoded image.
    BufSize  VDEC video stream buffer size, unit: byte.
    VideoMode  Video stream send mode
    STREAM: Send by stream;
    FRAME: Send by frame.
    RefFrmNum The maximum number of reference frames, the JPEG channel is invalid.
    DpbBufMode Decoding mode
    INPLACE1: DBP_MODE_INPLACE_ONE_BUF;
    INPLACE2: DBP_MODE_INPLACE_TWO_BUF;
    NORMAL: DBP_MODE_NORMAL
    CHN PARAM Info ChnID  Channel ID
    bScale Whether to set scale function.
    N: Not set, output according to the size of the source video stream.
    Y: Set.
    ScaleW Set the width of the scale output.
    ScaleH Set the height of the scale output.
    DisplayMode Display mode.
    PREVIEW PLAYBACK
    minFrmBufCnt The count of reference frames allocated for decoding the current source video stream.
    SkipFrmMode Skip frame mode.
    0: decode all frames; 1: only decode I frame; 2: only decode reference frames
    bRepeatFrm Whether to repeatedly decode the same frame. 0: No; 1: Yes
    Decode Frame Info ChnID Channel ID
    DecW The width of source video stream
    DecH The height of source video stream.
    DispW The width of the output data frame.
    DispH The height of the output data frame.
    Output Frame Info ChnID Channel ID
    bTileMode Whether to open tilemode output format. Y: Yes N: No
    TileFormat The alignment format after opening TileMode.
    128x64: 128x64 Byte alignment.
    128x32: 128x32 Byte alignment.
    32x32: 32x32 Byte alignment.
    Invalid: Not support.
    NA: Not open tilemode output format.
    Width The width of the output data frame.
    Height The height of the output data frame.
    Stride The output data frame needs to be aligned width.
    PixelFmt The format of the output data frame.
    YUV420SP: NV12 data frame format output.
    CHN STATE ChnID  Channel ID
    bStart  Whether to start the decoder.
    Y: Start, enter the decoding state
    N: Stop the decoding state.
    DecState The decoding state of the current channel.
    0: Undefined.
    1: The channel has just been created.
    2: Wait for key data frames such as sps and pps.
    3: Obtain information completion state of key sps, pps.
    4: Before decoding, apply for the memory state of the reference frame and so on
    5: Apply for the memory required for decoding under normal decoding state.
    6: The channel is closed.
    SendCnt The count of video streams sent by the application layer.
    SendStrmSize The size of video streams sent by the application layer.
    LeftStrmBytes The bytes to be decoded in the stream buffer.
    StrmLeftCnt Corresponding to SendCntParameter, the count to be decoded.
    DecFrmCnt The count of successfully decoded output frames.
    fps The current decoding frame rate.
    CHN STATE ChnID Channel ID
    startCnt The count to start decoding.
    getCnt The count the decoding result was successfully got
    dropCnt The count that the display cannot be output is dropped.
    errCnt The count that the decoder reports error to MI_VDEC.
    runCnt The count that the decoding task is still running.
    seqChgCnt The count the image sequence has changed. For example: SPS.
    initSeqCnt The interrupt frequency of decoding video stream head information returned from decoder corresponding to an Issue request.
    decPicCnt The interrupt frequency of decoding done returned from decoder.
    insuffiCnt The interrupt frequency of insufficient VLC Buffer.
    emptyCnt The interrupt frequency of empty bitstream buffer for decoding.


5.2. echo

Function
Dump the input bitstream data from the specified channel to the specified path.
Command echo dumpbs [chn] [path] > /proc/mi_modules/mi_vdec/mi_vdec0
Parameter Description chn: Channel ID [0~63]
path: The output path of dump file. Entering off means stop dumping bitstream.
Example echo dumpbs 3 /mnt/dump/ > /proc/mi_modules/mi_vdec/mi_vdec0
// Dump the bitstream buffer data from channel 3 to /mnt/dump.
Function
Dump all data of the current video stream buffer from the specified channel to the specified path. (The entire video stream buffer contains valid data and invalid data, pay attention to the difference with the previous dumpbs)
Command echo dumpbsb [chn] [path] > /proc/mi_modules/mi_vdec/mi_vdec0
Parameter Description chn: Channel ID [0~63]
path: The output path of dump file.
Example echo dumpbsb 3 /mnt/dump/ > /proc/mi_modules/mi_vdec/mi_vdec0
// Dump the entire video stream buffer data from channel 3 to /mnt/dump.
Function
Dump the decoded frames from the specified channel to the specified path.
Command echo dumpfb [chn] [path] [frmcnt] [bDumpAll] [bDetile] > /proc/mi_modules/mi_vdec/mi_vdec0
Parameter Description chn: Channel ID [0~63]
path: The output path of dumped file.
Frmcnt: dumped frames
bDumpAll: 0: Only dump yuv buffer. 1: Dump Y buffer, UV buffer and YUV buffer at the same time.
bDetile: 0: Do not detile the YUV to be dumped (Tile format data is dumped in tilemode mode). 1: Detile the YUV to be dumped (YUV format data is dumped in tilemode mode).
Example echo dumpfb 3 /mnt/dump/ 99 0 1 > /proc/mi_modules/mi_vdec/mi_vdec0
Channel 3, the storage path is /mnt/dump/, dumps 99 frames, does not save Y buffer and UV buffer separately, and detiles the YUV to be stored
Function
Turn on/off flow checkpoint to check the running status of the decoding task. (Not recommended for customers, internal debugging)
Command echo flowdbg [Status] > /proc/mi_modules/mi_vdec/mi_vdec0
Parameter Description Status: on / off
Example echo flowdbg on > /proc/mi_modules/mi_vdec/mi_vdec0
// Turn on vdec flow checkpoint, and then enter cat /proc/mi_modules/mi_vdec/mi_vdec0 to view the checkpoints of multiple functions in vdec procfs.
Function
Turn on/off the frame drop switch, discard all decoded output data frames, and do not output to the decoded back end.
Command echo dropoutbuf [Status] > /proc/mi_modules/mi_vdec/mi_vdec0
Parameter Description Status: on / off
Example echo dropoutbuf on > /proc/mi_modules/mi_vdec/mi_vdec0
// Drop the frame buffer to be output.
Function
Turn on/off the vdec performance statistics switch, which will output more detailed proc debug information. (Not recommended for customers, internal debugging)
Command echo setperf [Status] > /proc/mi_modules/mi_vdec/mi_vdec0
Parameter Description Status: on / off
Example echo setperf on > /proc/mi_modules/mi_vdec/mi_vdec0
// Turn on the vdec performance statistics switch, and then enter cat /proc/mi_modules/mi_vdec/mi_vdec0 to view the current decoding time and other data in vdec procfs.