6.3. API Reference

The function module provides the following APIs for users.

6.3.1. CVI_VPSS_CreateGrp

【Description】

Create a VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_CreateGrp(VPSS_GRP VpssGrp, const VPSS_GRP_ATTR_S *pstGrpAttr);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

pstGrpAttr

VPSS GROUP property pointer.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Create VPSS_GRP_ATTR_S before using this interface.

【Example】

VPSS_GRP_ATTR_S stVpssGrpAttr;
VPSS_CHN VpssChn = VPSS_CHN0;
CVI_BOOL abChnEnable[VPSS_MAX_PHY_CHN_NUM] = {0};
VPSS_CHN_ATTR_S astVpssChnAttr[VPSS_MAX_PHY_CHN_NUM];
CVI_S32 s32Ret = CVI_SUCCESS;
VPSS_CROP_INFO_S pstCropInfo;

stVpssGrpAttr.stFrameRate.s32SrcFrameRate = -1;
stVpssGrpAttr.stFrameRate.s32DstFrameRate = -1;
stVpssGrpAttr.enPixelFormat = PIXEL_FORMAT_YUV_PLANAR_420;
stVpssGrpAttr.u32MaxW = stSize.u32Width;
stVpssGrpAttr.u32MaxH = stSize.u32Height;

astVpssChnAttr[VpssChn].u32Width = 800;
astVpssChnAttr[VpssChn].u32Height = 600;
astVpssChnAttr[VpssChn].enChnMode = VPSS_CHN_MODE_USER;
astVpssChnAttr[VpssChn].enVideoFormat = VIDEO_FORMAT_LINEAR;
astVpssChnAttr[VpssChn].enPixelFormat = PIXEL_FORMAT_BGR_888_PLANAR;
astVpssChnAttr[VpssChn].stFrameRate.s32SrcFrameRate = 30;
astVpssChnAttr[VpssChn].stFrameRate.s32DstFrameRate = 30;
astVpssChnAttr[VpssChn].u32Depth = 0;
astVpssChnAttr[VpssChn].bMirror = CVI_FALSE;
astVpssChnAttr[VpssChn].bFlip = CVI_FALSE;
astVpssChnAttr[VpssChn].stAspectRatio.enMode = ASPECT_RATIO_NONE;

/*start vpss*/
VPSS_CHN VpssChn;
s32Ret = CVI_VPSS_CreateGrp(0, &stVpssGrpAttr);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_CreateGrp failed with %#x!\n", s32Ret);
    return CVI_FAILURE;
}

s32Ret = CVI_VPSS_SetChnAttr(0, 0, &astVpssChnAttr[0]);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_SetChnAttr failed with %#x\n", s32Ret);
    return CVI_FAILURE;
}

s32Ret = CVI_VPSS_EnableChn(0, 0);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_EnableChn failed with %#x\n", s32Ret);
    return CVI_FAILURE;
}

s32Ret = CVI_VPSS_StartGrp(0);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_StartGrp failed with %#x\n", s32Ret);
    return CVI_FAILURE;
}

s32Ret = CVI_VPSS_GetGrpCrop(0, &pstCropInfo);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_ GetGrpCrop failed with %#x\n", s32Ret);
    return CVI_FAILURE;
}

pstCropInfo.stCropRect.s32X = 0;
pstCropInfo.stCropRect.s32Y = 0;
pstCropInfo.stCropRect.u32Width = 600;
pstCropInfo.stCropRect.u32Height = 600;

s32Ret = CVI_VPSS_SetGrpCrop(0, &pstCropInfo);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_ SetGrpCrop failed with %#x\n", s32Ret);
    return CVI_FAILURE;
}

s32Ret = CVI_VPSS_DisableChn(0, 0);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("failed with %#x!\n", s32Ret);
    return CVI_FAILURE;
}

s32Ret = CVI_VPSS_StopGrp(VpssGrp);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("failed with %#x!\n", s32Ret);
    return CVI_FAILURE;
}

s32Ret = CVI_VPSS_DestroyGrp(VpssGrp);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("failed with %#x!\n", s32Ret);
    return CVI_FAILURE;
}

【Related Topic】

6.3.2. CVI_VPSS_DestroyGrp

【Description】

Destroy a VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_DestroyGrp (VPSS_GRP VpssGrp);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Before calling this interface, CVI_VPSS_StopGrp must be called to disable this GROUP first.

  • The function will release all vb_jobs under grp.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.3. CVI_VPSS_GetGrpAttr

【Description】

Get the properties of VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_GetGrpAttr (VPSS_GRP VpssGrp, VPSS_GRP_ATTR_S *pstGrpAttr);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

pstGrpAttr

VPSS GROUP properties pointer.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • The GROUP properties must be valida, and some static properties cannot be set dynamically. Please refer to PSS_GRP_ATTR_S for details.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.4. CVI_VPSS_SetGrpAttr

【Description】

Set the properties of VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_SetGrpAttr (VPSS_GRP VpssGrp, const VPSS_GRP_ATTR_S *pstGrpAttr);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

pstGrpAttr

VPSS GROUP properties pointer.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • The GROUP properties must be valid, and some static properties cannot be set dynamically. Please refer to PSS_GRP_ATTR_S for details.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.5. CVI_VPSS_StartGrp

【Description】

Enable the VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_StartGrp (VPSS_GRP VpssGrp);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • Repetitive calls to this function to set the same group will return a Success.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.6. CVI_VPSS_StopGrp

【Description】

Disable the VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_StopGrp (VPSS_GRP VpssGrp);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created, otherwise it will return a failure.

  • Repetitive calls to disable the same VPSS group will return a Success

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.7. CVI_VPSS_ResetGrp

【Description】

Reset the VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_ResetGrp (VPSS_GRP VpssGrp);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

Group must have been created .

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.8. CVI_VPSS_GetGrpProcAmpCtrl

【Description】

Get a VPSS group color control function description.

【Syntax】

CVI_S32 CVI_VPSS_GetGrpProcAmpCtrl(VPSS_GRP VpssGrp, PROC_AMP_E type, PROC_AMP_CTRL_S *ctrl);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

type

Type of Proc Amp(color control);

Input

ctrl

Define the specific parameter of ProcAmp, including min, max, step, default, etc

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

None.

【Example】

PROC_AMP_CTRL_S stAmpCtrl;
CVI_S32 tmp;

if (CVI_VPSS_GetGrpProcAmp(0, PROC_AMP_BRIGHTNESS, &tmp) != CVI_SUCCESS) {
  CVI_TRACE_LOG(CVI_DBG_ERR, "CVI_VPSS_GetGrpProcAmp NG on grp0!\n");
  return CVI_FAILURE;
}

if (CVI_VPSS_GetGrpProcAmpCtrl(0, PROC_AMP_BRIGHTNESS, &stAmpCtrl) != CVI_SUCCESS) {
  CVI_TRACE_LOG(CVI_DBG_ERR, "CVI_VPSS_GetGrpProcAmpCtrl NG on grp0!\n");
  return CVI_FAILURE;
}

if (CVI_VPSS_SetGrpProcAmp(0, PROC_AMP_BRIGHTNESS, stAmpCtrl.maximum) != CVI_SUCCESS) {
  CVI_TRACE_LOG(CVI_DBG_ERR, "CVI_VPSS_SetGrpProcAmp NG on grp0!\n");
  return CVI_FAILURE;
}

【Related Topic】

6.3.9. CVI_VPSS_GetGrpProcAmp

【Description】

Get the color control property of a VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_GetGrpProcAmp(VPSS_GRP VpssGrp, PROC_AMP_E type, CVI_S32 *value);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

type

Type of Proc Amp(color control);

Input

value

Configuration of ProcAmp

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

None.

【Example】

Please refer to CVI_VPSS_GetGrpProcAmpCtrl.

【Related Topic】

6.3.10. CVI_VPSS_SetGrpProcAmp

【Description】

Set the color control property of a VPSS GROUP.

【Syntax】

CVI_S32 CVI_VPSS_SetGrpProcAmp(VPSS_GRP VpssGrp, PROC_AMP_E type, const CVI_S32 value);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

type

Type of Proc Amp(color control);

Input

value

Configuration of ProcAmp

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

None.

【Example】

Please refer to CVI_VPSS_GetGrpProcAmpCtrl.

【Related Topic】

6.3.11. CVI_VPSS_SetGrpParamfromBin

【Description】

Set the property of a VPSS GROUP according to Bin.

【Syntax】

CVI_S32 CVI_VPSS_SetGrpParamfromBin(VPSS_GRP VpssGrp, CVI_U8 scene);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

scene

VPSS Bin scene settings to be applied

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • If a new PQ bin is used, the group must already be created

  • If the PQ bin does not exist, default parameters will be used.

  • Currently, only the setting of ProcAmp (brightness, contract, hue, saturation) is supported

【Example】

VPSS_GRP_ATTR_S stVpssGrpAttr;
VPSS_CHN VpssChn = VPSS_CHN0;
CVI_BOOL abChnEnable[VPSS_MAX_PHY_CHN_NUM] = {0};
VPSS_CHN_ATTR_S astVpssChnAttr[VPSS_MAX_PHY_CHN_NUM];
CVI_S32 s32Ret = CVI_SUCCESS;
VPSS_CROP_INFO_S pstCropInfo;

stVpssGrpAttr.stFrameRate.s32SrcFrameRate = -1;
stVpssGrpAttr.stFrameRate.s32DstFrameRate = -1;
stVpssGrpAttr.enPixelFormat = PIXEL_FORMAT_YUV_PLANAR_420;
stVpssGrpAttr.u32MaxW = stSize.u32Width;
stVpssGrpAttr.u32MaxH = stSize.u32Height;

astVpssChnAttr[VpssChn].u32Width = 800;
astVpssChnAttr[VpssChn].u32Height = 600;
astVpssChnAttr[VpssChn].enChnMode = VPSS_CHN_MODE_USER;
astVpssChnAttr[VpssChn].enVideoFormat = VIDEO_FORMAT_LINEAR;
astVpssChnAttr[VpssChn].enPixelFormat = PIXEL_FORMAT_BGR_888_PLANAR;
astVpssChnAttr[VpssChn].stFrameRate.s32SrcFrameRate = 30;
astVpssChnAttr[VpssChn].stFrameRate.s32DstFrameRate = 30;
astVpssChnAttr[VpssChn].u32Depth = 0;
astVpssChnAttr[VpssChn].bMirror = CVI_FALSE;
astVpssChnAttr[VpssChn].bFlip = CVI_FALSE;
astVpssChnAttr[VpssChn].stAspectRatio.enMode = ASPECT_RATIO_NONE;

/*start vpss*/
VPSS_CHN VpssChn;
s32Ret = CVI_VPSS_CreateGrp(0, &stVpssGrpAttr);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_CreateGrp failed with %#x!\n", s32Ret);
    return CVI_FAILURE;
}

/*vpss grp0套用場景0*/
s32Ret = CVI_VPSS_SetGrpParamfromBin(0, 0);
if (s32Ret != CVI_SUCCESS) {
    SAMPLE_PRT("CVI_VPSS_SetGrpParamfromBin failed with %#x!\n", s32Ret);
    return CVI_FAILURE;
}

【Related Topic】

6.3.12. CVI_VPSS_GetChnAttr

【Description】

Get VPSS channel properties.

【Syntax】

CVI_S32 CVI_VPSS_GetChnAttr (VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VPSS_CHN_ATTR_S *pstChnAttr);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

VpssChn

VPSS channel number.

Value Range: [0, VPSS_MAX_PHY_CHN_NUM);

Input

pstChnAttr

VPSS channel properties

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

Group must have been created.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.13. CVI_VPSS_SetChnAttr

【Description】

Set the VPSS channel properties.

【Syntax】

CVI_S32 CVI_VPSS_SetChnAttr (VPSS_GRP VpssGrp, VPSS_CHN VpssChn, const VPSS_CHN_ATTR_S *pstChnAttr);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

VpssChn

VPSS channel number.

Value Range: [0, VPSS_MAX_PHY_CHN_NUM);

Input

pstChnAttr

VPSS channel properties

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

Group must have been created.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.14. CVI_VPSS_EnableChn

【Description】

Enable the VPSS channel.

【Syntax】

CVI_S32 CVI_VPSS_EnableChn(VPSS_GRP VpssGrp, VPSS_CHN VpssChn);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

VpssChn

VPSS channel number.

Value Range: [0, VPSS_MAX_PHY_CHN_NUM);

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • Repetitive enable calls will return a Success.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.15. CVI_VPSS_DisableChn

【Description】

Disable the VPSS channel.

【Syntax】

CVI_S32 CVI_VPSS_DisableChn (VPSS_GRP VpssGrp, VPSS_CHN VpssChn);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

VpssChn

VPSS channel number.

Value Range: [0, VPSS_MAX_PHY_CHN_NUM);

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • Repetitive disable calls will return a Success.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.16. CVI_VPSS_SetGrpCrop

【Description】

Set the VPSS GROUP CROP function properties.

【Syntax】

CVI_S32 CVI_VPSS_SetGrpCrop (VPSS_GRP VpssGrp, const VPSS_CROP_INFO_S *pstCropInfo);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

pstCropInfo

CROP function properties

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • The size of the crop area cannot be less than the minimum size of the VPSS,

    and cannot exceed the maximum size.

    Otherwise, the failure is returned.

  • VPSS Online mode does not support group cropping.

  • This setting is invalid when the DIS is enabled

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.17. CVI_VPSS_GetGrpCrop

【Description】

Get the VPSS GROUP CROP function properties.

【Syntax】

CVI_S32 CVI_VPSS_GetGrpCrop (VPSS_GRP VpssGrp, VPSS_CROP_INFO_S *pstCropInfo);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM).

Input

pstCropInfo

CROP function properties

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

Group must have been created.

【Example】

Please refer to CVI_VPSS_CreateGrp.

【Related Topic】

6.3.18. CVI_VPSS_SendFrame

【Description】

User sends data to VPSS.

【Syntax】

CVI_S32 CVI_VPSS_SendFrame (VPSS_GRP VpssGrp, const VIDEO_FRAME_INFO_S *pstVideoFrame, CVI_S32 s32MilliSec);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM);

Input

pstVideoFrame

Image information to be sent. Please refer to the chapter “system control” for details .

Input

s32MilliSec

Not used in the current version.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created and enabled, otherwise it will return a failure.

【Example】

None.

【Related Topic】

None.

6.3.19. CVI_VPSS_GetChnFrame

【Description】

The user obtains a processed image from the channel.

【Syntax】

CVI_S32 CVI_VPSS_GetChnFrame(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VIDEO_FRAME_INFO_S *pstFrameInfo, CVI_S32 s32MilliSec);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range: [0, VPSS_MAX_CHN_NUM);

Input

pstVideoFrame

Image information to be sent. Please refer to the chapter “system control” for details.

Output

s32MilliSec

Time out

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • This function saves the acquired image information in pstvideoFrame, including the virtual and physical addresses of the image.

【Example】

VIDEO_FRAME_INFO_S pstVideoFrame;
FILE *fp;
size_t image_size;
unsigned char ptr[image_size];
int count = 0;

CVI_VPSS_GetChnFrame(0, 0, &pstVideoFrame, 5000);
image_size = pstVideoFrame.stVFrame.u32Width * pstVideoFrame.stVFrame.u32Height * 3;

for (int i = 0; i < 3; i++) {
  memcpy(&ptr[count], (const CVI_VOID *)pstVideoFrame.stVFrame.u64VirAddr[i], pstVideoFrame.stVFrame.u32Length[i]);
  count += pstVideoFrame.stVFrame.u32Length[i];
}
fp = fopen("/tmp/dump.bin", "w");
if (fp == CVI_NULL) {
  CVI_TRACE_VPSS(CVI_DBG_ERR, "open data file error\n");
  return CVI_FAILURE;
}
fwrite(ptr, image_size, 1, fp);
fclose(fp);
if (CVI_VPSS_ReleaseChnFrame(0, 0, &pstVideoFrame) != 0)
  SAMPLE_PRT("CVI_VI_ReleaseChnFrame NG\n");

【Related Topic】

6.3.20. CVI_VPSS_SendChnFrame

【Description】

The user specifies channel data to the VPSS, which can be used for image stitching.

【Syntax】

CVI_S32 CVI_VPSS_SendChnFrame (VPSS_GRP VpssGrp, VPSS_CHN VpssChn, const VIDEO_FRAME_INFO_S *pstVideoFrame, CVI_S32 s32MilliSec);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range: [0, VPSS_MAX_CHN_NUM);

Input

pstVideoFrame

Image information to be sent. Please refer to the chapter “system control” for details.

Input

s32MilliSec

Not used in current version.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group/Chn must have been created.

【Example】

None.

【Related Topic】

None.

6.3.21. CVI_VPSS_ReleaseChnFrame

【Description】

The user releases a frame of image processed by the channel.

【Syntax】

CVI_S32 CVI_VPSS_ReleaseChnFrame (VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VIDEO_FRAME_INFO_S *pstFrameInfo);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range: [0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range: [0, VPSS_MAX_CHN_NUM);

Input

pstVideoFrame

Image information to be sent. Please refer to the chapter “system control” for details.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

This interface should be used in conjunction with CVI_VPSS_GetChnFrame.

【Example】

Please refer to CVI_VPSS_GetChnFrame.

【Related Topic】

6.3.22. CVI_VPSS_GetGrpFrame

【Description】

The function has not been implemented so far.

6.3.23. CVI_VPSS_ReleaseGrpFrame

【Description】

The function has not been implemented so far.

6.3.24. CVI_VPSS_SetChnCrop

【Description】

Set the attributes of VPSS channel clipping function

【Syntax】

CVI_S32 CVI_VPSS_SetChnCrop(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, const VPSS_CROP_INFO_S *pstCropInfo);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

pstCropInfo

Image information to be sent. Please refer to the chapter “system control” for detailed description.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Groupmust have been created.

  • The size of the CROP area can neither be less than the minimum size of the VPSS nor exceed the maximum size.

    Otherwise, a failure will be returned.

  • This function sets the image for the VPSS output channel, while GrpCrop sets the image for the VPSS input.

【Example】

None.

【Related Topic】

6.3.25. CVI_VPSS_GetChnCrop

【Description】

Get the attributes of VPSS channel clipping function.

【Syntax】

CVI_S32 CVI_VPSS_GetChnCrop(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VPSS_CROP_INFO_S *pstCropInfo);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

pstCropInfo

CROP function properties.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_vpss.h、cvi_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must have been created.

  • This function obtains the image cropping information for the VPSS output channel,

    while CVI_VPSS_GetGrpCrop obtains the image cropping information for the VPSS input.

【Example】

None.

【Related Topic】

6.3.26. CVI_VPSS_SetChnRotation

【Description】

Set the attributes of VPSS channel rotation.

【Syntax】

CVI_S32 CVI_VPSS_SetChnRotation(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, ROTATION_E enRotation);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

enRotation

Rotation attributes. See ROTATION_E for details.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Before using this interface, it is necessary to call CVI_VPSS_SetChnAttr first, otherwise it will fail.

  • The channel attributes must be set before setting this attribute.

  • CV181x/CV180x do not support 180-degree rotation, but it can be achieved using mirror+flip.

  • Only NV12/NV21/YUV400 rotation formats are supported.

  • After rotation, the output image size of the channel may change.

    For example, the 1920x1080 input image, rotated 90 degrees, the actual output is 1088x1920.

    Since rotation requires 64 pixel alignment, invalid areas will be generated.

    If the back end is connected to vo or venc, the back end module will automatically crop the valid part.

    In the case of GetChnFrame, the valid region is specified in the VIDEO_FRAME_S structure s16OffsetTop, s16OffsetBottom, s16OffsetLeft, s16OffsetRight.

【Example】

None.

【Related Topic】

None.

6.3.27. CVI_VPSS_GetChnRotation

【Description】

Get the attributes of VPSS channel rotation.

【Syntax】

CVI_S32 CVI_VPSS_GetChnRotation(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, ROTATION_E *penRotation);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

penRotation

Rotation attributes. See ROTATION_E for details.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Before using this interface, it is necessary to call CVI_VPSS_SetChnAttr first, otherwise it will fail.

【Example】

None.

【Related Topic】

6.3.28. CVI_VPSS_SetChnLDCAttr

【Description】

Set the attributes of VPSS channel lens distortion correction.

【Syntax】

CVI_S32 CVI_VPSS_SetChnLDCAttr(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, const VPSS_LDC_ATTR_S *pstLDCAttr);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

pstLDCAttr

Lens distortion correction attributes.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Before using this interface, it is necessary to call CVI_VPSS_SetChnAttr first, otherwise it will fail.

  • The channel attributes must be set before setting this attribute

  • Only NV21 and YUV400 rotation formats are supported.

【Example】

None.

【Related Topic】

6.3.29. CVI_VPSS_GetChnLDCAttr

【Description】

Get the attributes of VPSS channel lens distortion correction.

【Syntax】

CVI_S32 CVI_VPSS_GetChnLDCAttr(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VPSS_LDC_ATTR_S *pstLDCAttr);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

pstLDCAttr

Lens distortion correction attributes.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Before using this interface, it is necessary to call CVI_VPSS_SetChnAttr first, otherwise it will fail.

【Example】

None.

【Related Topic】

6.3.30. CVI_VPSS_GetChnFd

【Description】

Get the device file handle corresponding to the VPSS channel.

【Syntax】

CVI_S32 CVI_VPSS_GetChnFd(VPSS_GRP VpssGrp, VPSS_CHN VpssChn);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

【Return Value】

Return Value

Description

Positive value

Success.

Negative value

invalid value

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

None.

【Example】

None.

【Related Topic】

None.

6.3.31. CVI_VPSS_CloseFd

【Description】

Close the file handle of the VPSS device channel.

【Syntax】

CVI_S32 CVI_VPSS_CloseFd(CVI_VOID);

【Parameter】

None.

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

After calling this interface, other MMF interfaces of VPSS will be invalidated.

【Example】

None.

【Related Topic】

6.3.32. CVI_VPSS_AttachVbPool

【Description】

Bind the VPSS channel to a video cache VB pool.

【Syntax】

CVI_S32 CVI_VPSS_AttachVbPool(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VB_POOL hVbPool);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

hVbPool

Video memory block pool ID

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must already be created.

  • Repeated calls to this function to set the same group return Success.

  • The CVI_VPSS_AttachVbPool interface needs to be adjusted again when switching the VB pool bound to the current group.

  • Correct configuration to the VB pool.

  • hVbPool must be a valid Pool Id of a created VB pool.

  • After calling CVI_VPSS_DetachVbPool, before destroying the created VB, we need to ensure that the VB is not used by the back-end bound module of VPSS.

    We can release the VB by sleep or clear the cache of the back-end module channel, and then destroy the cache VB pool.

  • VB size is calculated according to the output image of VPSS channel.

    For details, refer to cvi_buffer.h.

【Example】

None.

【Related Topic】

None.

6.3.33. CVI_VPSS_DetachVbPool

【Description】

Unbind the VPSS channel from a video cache VB pool

【Syntax】

CVI_S32 CVI_VPSS_DetachVbPool(VPSS_GRP VpssGrp, VPSS_CHN VpssChn);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must already be created

【Example】

None.

【Related Topic】

None.

6.3.34. CVI_VPSS_SetChnBufWrapAttr

【Description】

Setting low-latency looping property.

【Syntax】

CVI_S32 CVI_VPSS_SetChnBufWrapAttr(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, const VPSS_CHN_BUF_WRAP_S *pstVpssChnBufWrap);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

pstVpssChnBufWrap

Channel Buffer Loop Attribute structure.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must already be created.

  • Channel enablement is not supported.

  • The interface can be set only after the channel attributes have been set.

  • semi-planar422 graphics and Flip graphics are not supported.

  • When channel winding with low delay is enabled, access, brightness, rotation, CoverEx, OverlayEx, rotation at any Angle, and LDC of the channel are invalid.

  • In low-delay winding channel binding coding scenarios, the software does not support frame rate control.

【Example】

None.

【Related Topic】

None.

6.3.35. CVI_VPSS_GetChnBufWrapAttr

【Description】

Get the low-latency looping property.

【Syntax】

CVI_S32 CVI_VPSS_GetChnBufWrapAttr(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VPSS_CHN_BUF_WRAP_S *pstVpssChnBufWrap);

【Parameter】

Parameter

Description

Input/Output

VpssGrp

VPSS GROUP number.

Value Range:[0, VPSS_MAX_GRP_NUM)。

Input

VpssChn

VPSS channel number.

Value Range:[0, VPSS_MAX_CHN_NUM);

Input

pstVpssChnBufWrap

Channel Buffer Loop Attribute structure.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

  • Group must already be created.

【Example】

None.

【Related Topic】

None.

6.3.36. CVI_VPSS_GetWrapBufferSize

【Description】

Get the required buffer size for low-latency wrapping

【Syntax】

CVI_U32 CVI_VPSS_GetWrapBufferSize(CVI_U32 u32Width, CVI_U32 u32Height, PIXEL_FORMAT_E enPixelFormat, CVI_U32 u32BufLine, CVI_U32 u32BufDepth);

【Parameter】

Parameter

Description

Input/Output

u32Width

Image width

Input

u32Height

Image height

Input

enPixelFormat

Image pixel format

Input

u32BufLine

Number of lines in a single winding cache

Input

u32BufDepth

Number of winding caches

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_vpss.h, cvi_comm_vpss.h

  • Library files: libvpu.a

【Note】

None.

【Example】

None.

【Related Topic】

None.