8.3. API Reference

This function module provides the following APIs to users:

8.3.1. CVI_VDEC_CreateChn

Description

CreateVideo DecodingChannel.

Syntax

CVI_S32 CVI_VDEC_CreateChn(VDEC_CHN VdChn, const VDEC_CHN_ATTR_S *pstAttr); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstAttr

Decoding channelAttributePointer.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • The VDEC module supports PT_JPEG and PT_MJPEG.

  • systemInsufficient memorytimewillReturn CVII_ERR_VDEC_NOMEM Error Codes.

  • UseJPEG/MJPEGtimeinCreateDecodingChannelbeforefirstCreateto VDEC mode block VB pool, notsameProtocolDecodingrequiredImage VB blockSizenotsame, canReference sample_vdec_lib.c invdecInitVBPoolfunction.

Example

CVI_S32 SAMPLE_COMM_VDEC_Start(vdecChnCtx *pvdchnCtx) {  //SetVDEC RelatedParameter  VDEC_CHN_ATTR_S stChnAttr, *pstChnAttr = &stChnAttr;  VDEC_CHN VdecChn = pvdchnCtx->VdecChn;  SAMPLE_VDEC_ATTR *psvdattr = &pvdchnCtx->stSampleVdecAttr;  VDEC_CHN_PARAM_S stChnParam;  pstChnAttr->enType = psvdattr->enType;  pstChnAttr->enMode = psvdattr->enMode;  pstChnAttr->u32PicWidth = psvdattr->u32Width;  pstChnAttr->u32PicHeight = psvdattr->u32Height;  pstChnAttr->u32StreamBufSize = psvdattr->u32Width * psvdattr->u32Height;  pstChnAttr->u32FrameBufCnt = psvdattr->u32FrameBufCnt;  //JPEG, MJPEG 需要SetVB buffer  if (psvdattr->enType == PT_JPEG || psvdattr->enType == PT_MJPEG) {  pstChnAttr->enMode = VIDEO_MODE_FRAME;  pstChnAttr->u32FrameBufSize = VDEC_GetPicBufferSize(  pstChnAttr->enType, psvdattr->u32Width, psvdattr->u32Height,  psvdattr->stSapmleVdecPicture.enPixelFormat, DATA_BITWIDTH_8, 0);  }  //CreateVDECChannel  CHECK_CHN_RET(CVI_VDEC_CreateChn(VdecChn, pstChnAttr), VdecChn,  "CVI_VDEC_CreateChn");  //确认目前default Parameter  CHECK_CHN_RET(CVI_VDEC_GetChnParam(VdecChn, &stChnParam), VdecChn,  "CVI_VDEC_GetChnParam");  if (psvdattr->enType == PT_JPEG || psvdattr->enType == PT_MJPEG)  {  stChnParam.stVdecPictureParam.enPixelFormat =  psvdattr->stSapmleVdecPicture.enPixelFormat;  stChnParam.stVdecPictureParam.u32Alpha =  psvdattr->stSapmleVdecPicture.u32Alpha;  }  //Setdisplay frame..等Parameter  stChnParam.u32DisplayFrameNum = psvdattr->u32DisplayFrameNum;  //SetVDEC Parameter  CHECK_CHN_RET(CVI_VDEC_SetChnParam(VdecChn, &stChnParam), VdecChn,  "CVI_MPI_VDEC_GetChnParam");  //Enable VDEC frame 传输  CHECK_CHN_RET(CVI_VDEC_StartRecvStream(VdecChn), VdecChn,  "CVI_MPI_VDEC_StartRecvStream");  return CVI_SUCCESS; } 

Related Topics

CVI_VDEC_DestroyChn

8.3.2. CVI_VDEC_DestroyChn

Description

DestroyVideo DecodingChannel.

Syntax

CVI_S32 CVI_VDEC_DestroyChn(VDEC_CHN VdChn); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • the channel must have been created before destruction; otherwise, the function returnsChannelnot createdError.

  • DestroybeforemuststopReceiveBitstream (orusernotstartReceiveBitstream), otherwisereturns an error.

Example

  • None.

Related Topics

CVI_VDEC_CreateChn

8.3.3. CVI_VDEC_ResetChn

Description

Reset the channel.

Syntax

CVI_S32 CVI_VDEC_ResetChn(VDEC_CHN VdChn); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Channel number.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • Reset anddoes not existChannel, ReturnFailureCVI_FAILURE.

  • If aChannelnothasstopReceiveBitstreamwhile reset Channel, thenReturnFailure.

Example

  • None.

8.3.4. CVI_VDEC_GetChnAttr

Description

GetVideo DecodingChannel attributes.

Syntax

CVI_S32 CVI_VDEC_GetChnAttr(VDEC_CHN VdChn, VDEC_CHN_ATTR_S *pstAttr); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstAttr

Decoding channelAttributePointer.

Output

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • VDEC Channelmust already be created.

  • thisfunctionUsually in CVI_VDEC_SetChnAttr beforeUse, orisinGetdecoder framebeforecall, withverifyChannelnormal.

Example

See also sample_common_vdec.c in the SAMPLE_COMM_VDEC_GetPic function.

CVI_VOID *SAMPLE_COMM_VDEC_GetPic(CVI_VOID *pArgs) {  VDEC_THREAD_PARAM_S *pstVdecThreadParam = (VDEC_THREAD_PARAM_S *)pArgs;  FILE *fp = CVI_NULL;  CVI_S32 s32Ret, s32Cnt = 0;  VDEC_CHN_ATTR_S stAttr;  VIDEO_FRAME_INFO_S stVFrame;  CVI_CHAR cSaveFile[256];  prctl(PR_SET_NAME, "VdecGetPic", 0, 0, 0);  s32Ret = CVI_VDEC_GetChnAttr(pstVdecThreadParam->s32ChnId, &stAttr);  if (s32Ret != CVI_SUCCESS) {  CVI_VDEC_ERR("chn %d get chn attr fail for %#x!\n",  pstVdecThreadParam->s32ChnId,  s32Ret);  return (CVI_VOID *)(CVI_FAILURE);  }  if (stAttr.enType != PT_JPEG) {  CVI_VDEC_ERR("chn %d enType %d do not support save file!\n",  pstVdecThreadParam->s32ChnId,  stAttr.enType);  return (CVI_VOID *)(CVI_FAILURE);  }  while (1) {  if (pstVdecThreadParam->eThreadCtrl == THREAD_CTRL_STOP)  break;  s32Ret = CVI_VDEC_GetFrame(  pstVdecThreadParam->s32ChnId,  &stVFrame,  pstVdecThreadParam->s32MilliSec);  CVI_VDEC_TRACE("leave CVI_VDEC_GetFrame %d\n", s32Ret);  ...  ...  } } 

Related Topics

CVI_VDEC_SetChnAttr

8.3.5. CVI_VDEC_SetChnAttr

Description

SetVideo DecodingChannel attributes.

Syntax

CVI_S32 CVI_VDEC_SetChnAttr(VDEC_CHN VdChn, const VDEC_CHN_ATTR_S *pstAttr); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstAttr

Decoding channelAttributePointer.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • VDEC Channelmust already be created.

  • Channel attributesbeforemust firststopReceiveBitstream, otherwisereturns an error.

Example

  • None.

Related Topics

CVI_VDEC_GetChnAttr

8.3.6. CVI_VDEC_StartRecvStream

Description

DecodingdevicestartReceiveUserSendBitstream.

Syntax

CVI_S32 CVI_VDEC_StartRecvStream(VDEC_CHN VdChn); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • bootReceiveBitstreambeforemust ensureChannelmust have been created; otherwise, the function returnsError.

Example

See CVI_VDEC_CreateChn Example

Related Topics

CVI_VDEC_CreateChn

8.3.7. CVI_VDEC_StopRecvStream

Description

DecodingdevicestopReceiveUserSendBitstream.

Syntax

CVI_S32 CVI_VDEC_StopRecvStream(VDEC_CHN VdChn); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

Example

See sample_common_vdec.c inSAMPLE_COMM_VDEC_Stop:

CVI_S32 SAMPLE_COMM_VDEC_Stop(CVI_S32 s32ChnNum) {  CVI_S32 i;  for (i = 0; i < s32ChnNum; i++) {  CHECK_CHN_RET(CVI_VDEC_DestroyChn(i), i, "CVI_MPI_VDEC_DestroyChn");  CHECK_CHN_RET(CVI_VDEC_StopRecvStream(i), i, "CVI_MPI_VDEC_StopRecvStream");  }  return CVI_SUCCESS; } 

Related Topics

  • None.

8.3.8. CVI_VDEC_QueryStatus

Description

QueryDecoding channelStatus.

Syntax

CVI_S32 CVI_VDEC_QueryStatus(VDEC_CHN VdChn, VDEC_CHN_STATUS_S *pstStatus); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstStatus

Video DecodingChannelStatusStructurePointer

Output

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • QueryDecoding channelStatusbeforemust ensureChannelmust have been created; otherwise, the function returnsError.

Example

  • See also sample_common_vdec.c inofSAMPLE_COMM_VDEC_CmdCtrlmethod.

  • CVI_VDEC_QueryStatus UsercanQuerywithunderInformation:

    • enType: decodingFormat.

    • bStartRecvStream: Whetheralreadystartsendframegivedecodingdevice.

    • u32DecodeStreamFrames: alreadydecodingframenumber.

    • u32LeftPics: remainingimageframenumber.

    • stVdecDecErr: decodingdeviceErrorStatus (s32FormatErr: FormatError Codes, s32PicSizeErrSet: imageSizeError, s32StreamUnsprt: notBitstreamFormat…).

Related Topics

  • None.

8.3.9. CVI_VDEC_SetChnParam

Description

SetDecoding channelParameter.

Syntax

CVI_S32 CVI_VDEC_SetChnParam(VDEC_CHN VdChn, const VDEC_CHN_PARAM_S *pstParam); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstParam

ChannelParameter.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • SetDecoding channelParameterbeforemust ensureChannelmust have been created; otherwise, the function returnsError.

Example

See sample_common_vdec.c inSAMPLE_COMM_VDEC_Startfunction:

CVI_S32 SAMPLE_COMM_VDEC_Start(vdecChnCtx *pvdchnCtx) {  VDEC_CHN_ATTR_S stChnAttr, *pstChnAttr = &stChnAttr;  VDEC_CHN VdecChn = pvdchnCtx->VdecChn;  SAMPLE_VDEC_ATTR *psvdattr = &pvdchnCtx->stSampleVdecAttr;  VDEC_CHN_PARAM_S stChnParam;  pstChnAttr->enType = psvdattr->enType;  pstChnAttr->enMode = psvdattr->enMode;  pstChnAttr->u32PicWidth = psvdattr->u32Width;  pstChnAttr->u32PicHeight = psvdattr->u32Height;  pstChnAttr->u32StreamBufSize = psvdattr->u32Width * psvdattr->u32Height;  pstChnAttr->u32FrameBufCnt = psvdattr->u32FrameBufCnt;  if (psvdattr->enType == PT_JPEG || psvdattr->enType == PT_MJPEG) {  pstChnAttr->enMode = VIDEO_MODE_FRAME;  pstChnAttr->u32FrameBufSize = VDEC_GetPicBufferSize(  pstChnAttr->enType, psvdattr->u32Width, psvdattr->u32Height,  psvdattr->stSapmleVdecPicture.enPixelFormat, DATA_BITWIDTH_8, 0);  }  CHECK_CHN_RET(CVI_VDEC_CreateChn(VdecChn, pstChnAttr), VdecChn, "CVI_VDEC_CreateChn");  CHECK_CHN_RET(CVI_VDEC_GetChnParam(VdecChn, &stChnParam), VdecChn, "CVI_VDEC_GetChnParam");  if (psvdattr->enType == PT_JPEG || psvdattr->enType == PT_MJPEG)  {  stChnParam.stVdecPictureParam.enPixelFormat =  psvdattr->stSapmleVdecPicture.enPixelFormat;  stChnParam.stVdecPictureParam.u32Alpha =  psvdattr->stSapmleVdecPicture.u32Alpha;  }  stChnParam.u32DisplayFrameNum = psvdattr->u32DisplayFrameNum;  CHECK_CHN_RET(CVI_VDEC_SetChnParam(VdecChn, &stChnParam), VdecChn, "CVI_MPI_VDEC_GetChnParam");  CHECK_CHN_RET(CVI_VDEC_StartRecvStream(VdecChn), VdecChn, "CVI_MPI_VDEC_StartRecvStream");  return CVI_SUCCESS; } 

Related Topics

  • None.

8.3.10. CVI_VDEC_GetChnParam

Description

GetDecoding channelParameter.

Syntax

CVI_S32 CVI_VDEC_GetChnParam(VDEC_CHN VdChn, VDEC_CHN_PARAM_S *pstParam); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstParam

ChannelParameter.

Output

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • GetDecoding channelParameterbeforemust ensureChannelmust have been created; otherwise, the function returnsError.

Example

See also sample_common_vdec.c inSAMPLE_COMM_VDEC_Startfunction.

Related Topics

CVI_VDEC_SetChnParam

8.3.11. CVI_VDEC_SendStream

Description

SendBitstreamDatatoVideo DecodingChannel.

Syntax

CVI_S32 CVI_VDEC_SendStream(VDEC_CHN VdChn, const VDEC_STREAM_S *pstStream, CVI_S32 s32MilliSec); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstStream

DecodingBitstreamDataPointer.

Input

s32MilliSec

sendBitstreamMethodflag.
Value Range:
-1: Blocking.
0: Non-blocking
othercurrentlynumber: Timeoutetc.pendingtime

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • SendDatabeforemust ensurealreadyCall CVI_VDEC_CreateChn, CVI_VDEC_StartRecvStream.

  • thisInterfaceinmjpeg, jpegdecodingStatusunder, sendinLength0(pstStream->u32Len)willReturnCVI_SUCCESS;

  • decodingFailurewillError Codes: ERR_CVI_VDEC_SEND_STREAM.

Example

pleaseSee sample_common_vdec.c inSAMPLE_COMM_VDEC_SendStreamfunction.

Related Topics

  • None.

8.3.12. CVI_VDEC_GetFrame

Description

GetVideo DecodingChannelDecodingImage.

Syntax

CVI_S32 CVI_VDEC_GetFrame(VDEC_CHN VdChn, VIDEO_FRAME_INFO_S *pstFrameInfo, CVI_S32 s32MilliSec); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

s32MilliSec

GetImageMethodflag.
Value Range:
-1: Blocking.
0: Non-blocking
othercurrentlynumber: Timeoutetc.pendingtime

Input

pstFrameInfo

GetDecodingImageInformation.

Output

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • GetDecodingImagetimemust ensureChannelalreadybeCreate, otherwisereturns an error.

Example

See sample_common_vdec.c in the SAMPLE_COMM_VDEC_GetPic function.

Related Topics

None.

8.3.13. CVI_VDEC_ReleaseFrame

Description

ReleaseVideo DecodingChannelImage.

Syntax

CVI_S32 CVI_VDEC_ReleaseFrame(VDEC_CHN VdChn, const VIDEO_FRAME_INFO_S *pstFrameInfo); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Video decoding channel number.

Input

pstFrameInfo

DecodingafterImageInformationPointer

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • thisInterfaceneed towith CVI_VDEC_GetFrame forUse, GetDatashouldWhen inUsecompleteofafter that isRelease, If notandtimeRelease, willcauseDecodingprocessblockingetc.pendingresource.

  • ReleaseDatamustis CVI_VDEC_GetFrame fromthisChannelGetData, notforData Structureperform anymodify.

  • ReleaseVideo DecodingChannelImagemustinChannelDestroybefore.

Example

None.

Related Topics

None.

8.3.14. CVI_VDEC_SetModParam

Description

SetDecodingrelated moduleParameter.

Syntax

CVI_S32 CVI_VDEC_SetModParam(const VDEC_PARAM_MOD_S *pstModParam); 

Parameters

Parameter Name

Description

Input/Output

pstModParam

DecodingModuleParameterPointer.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • thisInterfacecaninChannelCreatebeforeaftercall.

  • thisInterfacemainused to SetcorrespondingDecodingVB poolGetMethod, UsercanthroughStructure VDEC_PARAM_MOD_S in VB_SOURCE_E TypevariableSetVB mode.

Example

  • None.

8.3.15. CVI_VDEC_GetModParam

Description

GetDecodingrelated moduleParameter.

Syntax

CVI_S32 CVI_VDEC_GetModParam(VDEC_PARAM_MOD_S *pstModParam); 

Parameters

Parameter Name

Description

Input/Output

pstModParam

DecodingModuleParameterPointer.

Output

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

Example

  • None.

8.3.16. CVI_VDEC_AttachVbPool

Description

willDecoding channelbind to a video buffer VB poolin.

Syntax

CVI_S32 CVI_VDEC_AttachVbPool(VDEC_CHN VdChn, const VDEC_CHN_POOL_S *pstPool); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Channel number.

Input

pstPool

VideocacheVB pool Id number

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • The channel must have been created; otherwise, the CVI_FAILURE error code is returned.

  • The user must call CVI_VB_CreatePool to create a video buffer VB pool, then call the interface CVI_VDEC_AttachVbPool currentEncoding channelBindtofixed PoolId VB pool Medium. canmultipleEncoding channelBindtosamea VB poolin, butisnotcansameaEncoding channel tomultiple VB poolin.

  • pstPool mustisalready created VB poolValid PoolId, includingstorage Picture VB poolandstoragestorage Picture Information VB pool.

  • UserCallthisInterface, mustdeterminethrough CVI_VDEC_SetModParam SetinVB_SOURCE_USERMode.

Example

  • None.

8.3.17. CVI_VDEC_DetachVbPool

Description

willDecoding channelunbind from a video buffer VB unbind from the pool.

Syntax

CVI_S32 CVI_VDEC_DetachVbPool(VDEC_CHN VdChn); 

Parameters

Parameter Name

Description

Input/Output

VdChn

Channel number.

Input

Return Value

Return Value

Description

0

Success

Non-zero

Failure; its value is Error Codes.

Requirements

  • Header files: cvi_vdec.h, cvi_comm_video.h, cvi_comm_vdec.h

  • Library files: libvdec.so/libvdec.a

Note

  • The channel must have been created; otherwise, the CVI_FAILURE error code is returned.

Example

  • None.