7.3. API Reference

The video encoding module mainly provides the creation and destruction of the video coding channel, the reset of the video coding channel, the start and stop of receiving images, the setting and acquisition of the attributes of the coding channel, the acquisition and release of the code stream and other functions.

The following APIs are available:

7.3.1. CVI_VENC_CreateChn

【Description】

Create an encoding channel

【Syntax】

CVI_S32 CVI_VENC_CreateChn(VENC_CHN VeChn, const VENC_CHN_ATTR_S *pstAttr);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel ID

Input

pstAttr

VENC_CHN_ATTR_S attribute pointer

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel attributes are divided into three structures:

typedef struct _VENC_CHN_ATTR_S {
VENC_ATTR_S stVencAttr;///< The attribute of video encoder
VENC_RC_ATTR_S stRcAttr;///< The attribute of bitrate control
VENC_GOP_ATTR_S stGopAttr;} VENC_CHN_ATTR_S;
  • VENC_ATTR_S: Determine the encoding property, which determines the encoding protocol and assigns values to set the corresponding width and height.

  • VENC_RC_ATTR_S: Property of the rate control module,

    which sets the corresponding sub-structure based on the encoding settings and rate control mode

    (CBR, VBR, AVBR, FIXQP).

  • VENC_GOP_ATTR_S :

    GOP type attribute, encoding GOP type (encoding single reference frame, P frame, GOP type).

  • The recommended coding width and height are 1920x1080(1080P)、 1280x720(720P).

【Example】

User can refer to SAMPLE_COMM_VENC_SetChnAttr in sample_common_venc.c for the settings for the corresponding property pointer.

【Related Topic】

7.3.2. CVI_VENC_DestroyChn

【Description】

Destroy an encoding channel

【Syntax】

CVI_S32 CVI_VENC_DestroyChn (VENC_CHN VeChn);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel ID

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

Destroying a nonexistent channel will return a failure.

【Example】

See sample_common_venc.c. The frame must be stopped before destroying the channel.

CVI_S32 SAMPLE_COMM_VENC_Stop(VENC_CHN VencChn)
{
  CVI_S32 s32Ret;
            //stop transmission of venc frame data reception
  s32Ret = CVI_VENC_StopRecvFrame(VencChn);
  if (s32Ret != CVI_SUCCESS) {
    CVI_VENC_ERR("CVI_VENC_StopRecvPic vechn[%d] failed with %#x!\n",
        VencChn, s32Ret);
    return CVI_FAILURE;
  }
            //stop thread execution
  if (gs_VencTask[VencChn] != 0) {
    pthread_join(gs_VencTask[VencChn], CVI_NULL);
    CVI_VENC_SYNC("GetVencStreamProc done\n");
    gs_VencTask[VencChn] = 0;
  }
            //destroy the venc channel
  s32Ret = CVI_VENC_DestroyChn(VencChn);
  if (s32Ret != CVI_SUCCESS) {
    CVI_VENC_ERR("CVI_VENC_DestroyChn vechn[%d] failed with %#x!\n",
        VencChn, s32Ret);
    return CVI_FAILURE;
  }
  return CVI_SUCCESS;
}

【Related Topic】

7.3.3. CVI_VENC_ResetChn

【Description】

Reset the channel.

【Syntax】

CVI_S32 CVI_VENC_ResetChn(VENC_CHN VeChn);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel ID

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files:libvenc.a

【Note】

  • Reseting a non-exsitsting channel will return failure CVI_FAILURE.

  • If a channel is reset without stopping receiving images, it will return a failure.

【Example】

  • None

7.3.4. CVI_VENC_StartRecvFrame

【Description】

Starts an encoding channel to receive input images and allows specifying the number of frames to receive. Once the specified number of frames is reached, the channel automatically stops receiving images.

【Syntax】

CVI_S32 CVI_VENC_StartRecvFrame(VENC_CHN VeChn, const VENC_RECV_PIC_PARAM_S *pstRecvParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel ID

Input

pstRecvParam

Pointer to a structure that specifies the number of image frames to be received.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files:libvenc.a

【Note】

  • If the channel is not created, failure will be returned.

  • The image coding can be received only after the encoder is turned on.

【Example】

  • Refer to SAMPLE_COMM_VENC_Start function in sample_common_venc.c.

CVI_S32 s32Ret;
VENC_RECV_PIC_PARAM_S stRecvParam;

//create venc channel
s32Ret = SAMPLE_COMM_VENC_Create(
    pIc, VencChn, enType, enSize, enRcMode,
    u32Profile, bRcnRefShareBuf, pstGopAttr);
if (s32Ret != CVI_SUCCESS) {
  CVI_VENC_ERR("SAMPLE_COMM_VENC_Create failed with %d\n", s32Ret);
  return CVI_FAILURE;
}
//setting venc bindmode or not
if (pIc->bind_mode == VENC_BIND_VI) {
  VI_PIPE ViPipe = 0;
  VI_CHN ViChn = 0;
  SAMPLE_COMM_VI_Bind_VENC(ViPipe, ViChn, VencChn);
} else if (pIc->bind_mode == VENC_BIND_VPSS) {
  VPSS_GRP VpssGrp = 0;
  VPSS_CHN VpssChn = 0;
  SAMPLE_COMM_VPSS_Bind_VENC(VpssGrp, VpssChn, VencChn);
}

// Specify the number of frames to receive and allow frames to be received
stRecvParam.s32RecvPicNum = pIc->num_frames;
s32Ret = CVI_VENC_StartRecvFrame(VencChn, &stRecvParam);
if (s32Ret != CVI_SUCCESS) {
  CVI_VENC_ERR("CVI_VENC_StartRecvPic failed with %d\n", s32Ret);
  return CVI_FAILURE;
}
return CVI_SUCCESS;

【Related Topic】

7.3.5. CVI_VENC_StopRecvFrame

【Description】

Stop the encoding channel from receiving the input image.

【Syntax】

CVI_S32 CVI_VENC_StopRecvFrame(VENC_CHN VeChn);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel ID

intput

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • CVI_VENC_StopRecvFrame needs to be called before destroying the channel.

  • If the channel doesn’t exsist or is already destroyed, failure will be returned.

  • Calling this interface will only stop receiving the RAW data encoding, the code stream buffer will not be cleared.

  • This interface is used to stop the encoding channel from receiving images for encoding.

    It must be called before the encoding channel is destroyed or reset.

【Example】

  • Refer to SAMPLE_COMM_VENC_Stop function in  sample_common_venc.c.

【Related Topic】

7.3.6. CVI_VENC_QueryStatus

【Description】

Query the encoding channel status.

【Syntax】

CVI_S32 CVI_VENC_QueryStatus(VENC_CHN VeChn, VENC_CHN_STATUS_S *pstStatus);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel ID

Input

pstStatus

Pointer to the status of the encoding channel

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • If the channel is not created, failure will be returned.

  • In the encoding channel status structure, u32CurPacks represents the number of packets of the current frame.

    Before calling CVI_VENC_GetStream, it should be ensured that u32CurPacks is greater than 0.

7.3.7. CVI_VENC_SetChnAttr

【Description】

Set the encoding channel attributes.

【Syntax】

CVI_S32 CVI_VENC_SetChnAttr(VENC_CHN VeChn, const VENC_CHN_ATTR_S *pstChnAttr);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel ID

Input

pstChnAttr

Encoding channel attribute pointer

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

None.

【Example】

7.3.8. CVI_VENC_GetChnAttr

【Description】

Get the encoding channel attributes.

【Syntax】

CVI_S32 CVI_VENC_GetChnAttr(VENC_CHN VeChn, VENC_CHN_ATTR_S *pstChnAttr);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstChnAttr

Encoding channel attribute pointer.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • Get the attributes of an uncreated channel will return a failure.

【Example】

7.3.9. CVI_VENC_GetStream

【Description】

Get the encoded stream.

【Syntax】

CVI_S32 CVI_VENC_GetStream(VENC_CHN VeChn, VENC_STREAM_S *pstStream, CVI_S32 S32MilliSec);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstFrame

Code stream structure pointer VENC_STREAM_S。

Output

S32MilliSec

Image sending timeout

Value range: [-1, + 1) -1: Blocking. 0: Non-blocking. Greater than 0: Timeout.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The Venc channel must be created first or this function will return an error.

  • In non-bind mode conditions, the CVI_VENC_SendFrame must have been called,

    otherwise the CVI_VENC_GetStream will not be able to obtain the bitstream structure.

  • CVI_VENC_GetStream can be paired with CVI_VENC_GetChnAttr before calling,

    CVI_VENC_QueryStatus calls ensure the correctness of the current encoding channel.

  • Bit Stream Structure VENC_STREAM_S contains four parts:

    • The stream packet information pointer pstPack points to a set of VENC_PACK_S memory spaces allocated by the caller.

    • Note: pstPack space must be given space before calling CVI_VENC_GetStream, otherwise an error will be returned.

【Example】

Refer to sample_venc_lib.c SAMPLE_VENC_GetVencStreamProc:

while (pVencChnCtx->chnStat == CHN_STAT_START) {
  VENC_CHN_STATUS_S stStat;
          //bind mode mode check
  if (pVencChnCtx->chnIc.bind_mode == VENC_BIND_DISABLE) {
    CVI_S32 s32SetFrameMilliSec = 20000;
    s32Ret = cviReadSrcFrame(pVencChnCtx->pstVFrame, pVencChnCtx->fpSrc);

    s32Ret = CVI_VENC_SendFrame(VencChn, pVencChnCtx->pstFrameInfo,
        s32SetFrameMilliSec);
    if (s32Ret == CVI_ERR_VENC_FRC_NO_ENC) {
      continue;
    } else if (s32Ret != CVI_SUCCESS) {
      break;
    }
  }
            // Start getting venc stream based on venc channel state
  if (pVencChnCtx->chnIc.bsMode == BS_MODE_QUERY_STAT) {
    VENC_CHN_ATTR_S stVencChnAttr;
    VENC_STREAM_S stStream;

    s32Ret = CVI_VENC_GetChnAttr(VencChn, &stVencChnAttr);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_GetChnAttr, VencChn = %d, s32Ret = %d\n",
          VencChn, s32Ret);
      break;
    }
    s32Ret = CVI_VENC_QueryStatus(VencChn, &stStat);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_QueryStatus, Vench = %d, s32Ret = %d\n",
          VencChn, s32Ret);
      break;
    }
    if (!stStat.u32CurPacks) {
      CVI_VENC_ERR("u32CurPacks = NULL!\n");
      break;
    }
                        // pstPack space needs to be given first
    stStream.pstPack =
    (VENC_PACK_S *)malloc(sizeof(VENC_PACK_S) * stStat.u32CurPacks);
    if (stStream.pstPack == NULL) {
      CVI_VENC_ERR("malloc memory failed!\n");
      break;
    }
    s32Ret = CVI_VENC_GetStream(VencChn, &stStream, -1);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_GetStream, VencChn = %d, s32Ret = %d\n",
          VencChn, s32Ret);
      free(stStream.pstPack);
      stStream.pstPack = NULL;
      break;
    }
                        //Users can archive or give the removed stStream to the upper app
    s32Ret = CVI_VENC_ReleaseStream(VencChn, &stStream);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_ReleaseStream, s32Ret = %d\n", s32Ret);
      free(stStream.pstPack);
      stStream.pstPack = NULL;
      break;
    }
    free(stStream.pstPack);
    stStream.pstPack = NULL;
  }
}

7.3.10. CVI_VENC_ReleaseStream

【Description】

Release the encoded stream cache.

【Syntax】

CVI_S32 CVI_VENC_ReleaseStream(VENC_CHN VeChn, VENC_STREAM_S *pstStream);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstStream

VENC_STREAM_S 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_venc.h、cvi_venc.h

  • Library file: libvenc.a

【Note】

  • Verify that the venc channel has been created.

  • Please confirm that if CVI_VENC_ReleaseStream is called early after CVI_VENC_GetStream,

    CVI_VENC_GetStream will not have the right stream guarantee.

  • The user must release the obtained bitstream buffer in a timely manner after getting the bitstream,

    otherwise it may cause the buffer to be full and affect the encoder’s encoding.

【Example】

  • please refer to the example of CVI_VENC_GetStream

7.3.11. CVI_VENC_SendFrame

【Description】

Send out the image for encoding.

【Syntax】

CVI_S32 CVI_VENC_SendFrame(VENC_CHN VeChn, const VIDEO_FRAME_INFO_S *pstFrame, CVI_S32 S32MilliSec);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number

Input

pstFrame

VIDEO_FRAME_INFO_S property pointer

Input

S32MilliSec

Image sending Timeout

Value range: [-1, + 1)

  • 1: Blocking.

0: Non-blocking.

Greater than 0: Timeout.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This interface enables users to send images to the encoding channel for encoding.

  • Call this interface to send an image.

    The user needs to ensure that the encoding channel has been created and is ready to receive input images.

【Example】

Refer to SAMPLE_VENC_GetVencStreamProc in sample_venc_lib.c:

while (pVencChnCtx->chnStat == CHN_STAT_START) {
  VENC_CHN_STATUS_S stStat;
  if (pVencChnCtx->chnIc.bind_mode == VENC_BIND_DISABLE) {
    CVI_S32 s32SetFrameMilliSec = 20000;
    s32Ret = cviReadSrcFrame(pVencChnCtx->pstVFrame, pVencChnCtx->fpSrc);
    if (s32Ret < 0) {
      CVI_VENC_ERR("(chn %d) cviReadSrcFrame fail\n", VencChn);
      break;
    }
    s32Ret = CVI_VENC_SendFrame(VencChn, pVencChnCtx->pstFrameInfo,
        s32SetFrameMilliSec);
    if (s32Ret == CVI_ERR_VENC_FRC_NO_ENC) {
      CVI_VENC_FRC("no encode\n");
      continue;
    } else if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_SendFrame, VencChn = %d, s32Ret = %d\n",
          VencChn, s32Ret);
      break;
    }
  }
  if (pVencChnCtx->chnIc.bsMode == BS_MODE_QUERY_STAT) {
    VENC_CHN_ATTR_S stVencChnAttr;
    VENC_STREAM_S stStream;
    s32Ret = CVI_VENC_GetChnAttr(VencChn, &stVencChnAttr);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_GetChnAttr, VencChn = %d, s32Ret = %d\n",
          VencChn, s32Ret);
      break;
    }
    s32Ret = CVI_VENC_QueryStatus(VencChn, &stStat);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_QueryStatus, Vench = %d, s32Ret = %d\n",
          VencChn, s32Ret);
      break;
    }
    if (!stStat.u32CurPacks) {
      CVI_VENC_ERR("u32CurPacks = NULL!\n");
      break;
    }

    stStream.pstPack =
      (VENC_PACK_S *)malloc(sizeof(VENC_PACK_S) * stStat.u32CurPacks);
    if (stStream.pstPack == NULL) {
      CVI_VENC_ERR("malloc memory failed!\n");
      break;
    }

    s32Ret = CVI_VENC_GetStream(VencChn, &stStream, -1);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_GetStream, VencChn = %d, s32Ret = %d\n",
          VencChn, s32Ret);
      free(stStream.pstPack);
      stStream.pstPack = NULL;
      break;
    }
    s32Ret = CVI_VENC_ReleaseStream(VencChn, &stStream);
    if (s32Ret != CVI_SUCCESS) {
      CVI_VENC_ERR("CVI_VENC_ReleaseStream, s32Ret = %d\n", s32Ret);
      free(stStream.pstPack);
      stStream.pstPack = NULL;
      break;
    }
    free(stStream.pstPack);
    stStream.pstPack = NULL;
  }

  if (pVencChnCtx->chnIc.bind_mode) {
    if (pVencChnCtx->chnStat != pVencChnCtx->nextChnStat) {
      s32Ret = CVI_VENC_QueryStatus(VencChn, &stStat);
      if (s32Ret != CVI_SUCCESS) {
        CVI_VENC_ERR("CVI_VENC_QueryStatus, Vench = %d, s32Ret = %d\n",
            VencChn, s32Ret);
        break;
      }

      CVI_VENC_TRACE("u32LeftStreamFrames = %d\n",
          stStat.u32LeftStreamFrames);
      if (stStat.u32LeftStreamFrames <= 0) {
        pVencChnCtx->chnStat = CHN_STAT_STOP;
        CVI_VENC_SYNC("chnStat = CHN_STAT_STOP\n");
      }
    }
  } else {

    if (i >= pVencChnCtx->num_frames) {
      pVencChnCtx->chnStat = CHN_STAT_STOP;
    }
  }
}

【Related Topic】

7.3.12. CVI_VENC_GetFd

【Description】

Get the device file handle corresponding to the encoding channel.

【Syntax】

CVI_S32 CVI_VENC_GetFd(VENC_CHN VeChn);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number

Input

【Return Value】

Return Value

Description

Greater than 0

Success.

Less than or equal to 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • none

【Example】

  • none

【Related Topic】

7.3.13. CVI_VENC_CloseFd

【Description】

Close the channel handle.

【Syntax】

CVI_S32 CVI_VENC_CloseFd(VENC_CHN VeChn);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This API cannot be used when monitoring Stream using select function.

【Example】

  • none

【Related Topic】

7.3.14. CVI_VENC_SetJpegParam

【Description】

Set advanced parameter for JPEG encoding protocol

【Syntax】

CVI_S32 CVI_VENC_SetJpegParam(VENC_CHN VeChn, const VENC_JPEG_PARAM_S *pstJpegParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstJpegParam

Pointer to the collection of advanced parameters for the JPEG protocol encoding channel.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This interface is used to set advanced parameters for JPEG protocol encoding channels.

  • This interface is used after the Venc channel is created.

  • Advanced parameters Composition

    • u32Qfactor: The range of the quantization table factor is [1, 99].

      The larger the value of u32Qfactor, the smaller the quantization coefficients in the quantization table, which leads to better image quality and lower compression ratio.

      Conversely, the smaller the value of u32Qfactor, the larger the quantization coefficients in the quantization table, which leads to poorer image quality and higher compression ratio.

      Note that u32Qfactor=50 is a reserved custom setting item and is not currently supported.

    • u32MCUPerECS: The number of MCU in each ECS.

      When the system mode u32MCUPerECS = 0, all MCUs in the current frame are encoded into one ECS.

      The value of u32MCUPerECS should be no less than 0 and no greater than (picwidth+15)>>4 * (picheight+15)>>4 * 2.

  • It is recommended that users call this interface before starting the encoding after creating the channel,

    reducing the number of calls in encoding process.

    It is recommended that the user call the CVI_VENC_GetJpegParam interface before calling this interface to obtain the JegParam configuration of the current coding channel, and then set it.

【Example】

  • Please refer to the SAMPLE_COMM_VENC_SetJpegParam function in the sample_common_venc.

CVI_S32 SAMPLE_COMM_VENC_SetJpegParam(chnInputCfg *pIc, VENC_CHN VencChn)
{
  VENC_JPEG_PARAM_S stJpegParam, *pstJpegParam = &stJpegParam;
  CVI_S32 s32Ret = CVI_SUCCESS;

  s32Ret = CVI_VENC_GetJpegParam(VencChn, pstJpegParam);
  if (s32Ret != CVI_SUCCESS) {
    CVI_VENC_ERR("CVI_VENC_GetJpegParam\n");
    return CVI_FAILURE;
  }

  pstJpegParam->u32Qfactor = pIc->quality;

  s32Ret = CVI_VENC_SetJpegParam(VencChn, pstJpegParam);
  if (s32Ret != CVI_SUCCESS) {
    CVI_VENC_ERR("CVI_VENC_SetJpegParam\n");
    return CVI_FAILURE;
  }

  return s32Ret;
}

7.3.15. CVI_VENC_GetJpegParam

【Description】

Gets the advanced parameter configuration of the JPEG protocol encoding channel.

【Syntax】

CVI_S32 CVI_VENC_GetJpegParam(VENC_CHN VeChn, VENC_JPEG_PARAM_S *pstJpegParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstJpegParam

Pointer to the collection of advanced parameters for the JPEG protocol encoding channel.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This interface is called before the encoding channel is created and the encoding channel is destroyed.

  • It is recommended that users call this interface before starting the encoding

    after creating the channel, reducing the number of calls in encoding process.

【Example】

  • please refer to the example of CVI_VENC_SetJpegParam

7.3.16. CVI_VENC_SetRcParam

【Description】

Set advanced parameters for channel rate control.

【Syntax】

CVI_S32 CVI_VENC_SetRcParam(VENC_CHN VeChn, const

 VENC_RC_PARAM_S *pstRcParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstRcParam

Advanced parameters for in channel rate control

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This interface is called before the encoding channel is created and the encoding channel is destroyed.

  • This function is called after CVI_VENC_CreateChn and before CVI_VENC_SetChnParam.

  • You are advised to invoke the CVI_VENC_GetRcParam interface to obtain the RC advanced parameters,

    modify them, and then invoke this interface to set the advanced parameters.

【Example】

  • refer to the SAMPLE_COMM_VENC_SetRcParam function in sample_common_venc.c :

static CVI_S32 SAMPLE_COMM_VENC_SetRcParam(
    chnInputCfg * pIc,
    VENC_CHN VencChn)
{
  CVI_S32 s32Ret;
  VENC_RC_PARAM_S stRcParam, *pstRcParam = &stRcParam;

  s32Ret = CVI_VENC_GetRcParam(VencChn, pstRcParam);
  if (s32Ret != CVI_SUCCESS) {
    CVI_VENC_ERR("GetRcParam failed!\n");
    return CVI_FAILURE;
  }

  pstRcParam->s32FirstFrameStartQp = pIc->firstFrmstartQp;
  if (!strcmp(pIc->codec, "264") && pIc->rcMode == 0) {
    pstRcParam->stParamH264Cbr.u32MaxIQp = pIc->maxIqp;
    pstRcParam->stParamH264Cbr.u32MinIQp = pIc->minIqp;
    pstRcParam->stParamH264Cbr.u32MaxQp = pIc->maxQp;
    pstRcParam->stParamH264Cbr.u32MinQp = pIc->minQp;
  } else if (!strcmp(pIc->codec, "265") && pIc->rcMode == 0) {
    pstRcParam->stParamH265Cbr.u32MaxIQp = pIc->maxIqp;
    pstRcParam->stParamH265Cbr.u32MinIQp = pIc->minIqp;
    pstRcParam->stParamH265Cbr.u32MaxQp = pIc->maxQp;
    pstRcParam->stParamH265Cbr.u32MinQp = pIc->minQp;
  }  else if (!strcmp(pIc->codec, "264") && pIc->rcMode == 1) {
    pstRcParam->stParamH264Vbr.u32MaxIQp = pIc->maxIqp;
    pstRcParam->stParamH264Vbr.u32MinIQp = pIc->minIqp;
    pstRcParam->stParamH264Vbr.u32MaxQp = pIc->maxQp;
    pstRcParam->stParamH264Vbr.u32MinQp = pIc->minQp;
  }  else if (!strcmp(pIc->codec, "265") && pIc->rcMode == 1) {
    pstRcParam->stParamH265Vbr.u32MaxIQp = pIc->maxIqp;
    pstRcParam->stParamH265Vbr.u32MinIQp = pIc->minIqp;
    pstRcParam->stParamH265Vbr.u32MaxQp = pIc->maxQp;
    pstRcParam->stParamH265Vbr.u32MinQp = pIc->minQp;
  }

  CVI_VENC_TRACE("firstFrmstartQp = %d\n", pIc->firstFrmstartQp);

  s32Ret = CVI_VENC_SetRcParam(VencChn, pstRcParam);
  if (s32Ret != CVI_SUCCESS) {
    CVI_VENC_ERR("SetRcParam failed!\n");
    return CVI_FAILURE;
  }

  return s32Ret;
}

7.3.17. CVI_VENC_GetRcParam

【Description】

Get the advanced parameters for channel rate control.

【Syntax】

CVI_S32 CVI_VENC_GetRcParam(VENC_CHN VeChn, VENC_RC_PARAM_S *pstRcParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstRcParam

Advanced parameters for channel rate control

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This interface is called after the encoding channel is created and before the encoding channel is destroyed.

  • Before invoking this interface, you are advised to invoke the CVI_VENC_GetChnParam interface

    to obtain the parameter configuration of the front channel and then set it.

【Example】

None.

7.3.18. CVI_VENC_SetChnParam

【Description】

Set channel parameters.

【Syntax】

CVI_S32 CVI_VENC_SetChnParam(VENC_CHN VeChn, const VENC_CHN_PARAM_S *pstChnParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstChnParam

Channel parameters of Venc.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This interface is called after the encoding channel is created and before the encoding channel is destroyed.

  • This function is called after CVI_VENC_CreateChn and before CVI_VENC_SetChnParam.

  • The API parameter of this function supports the setting of venc CROP.

    The parameter used is VENC_CHN_PARAM_S, stCropCfg.

    The corresponding x, Y axes, width and height can be set.

【Example】

CVI_S32 SAMPLE_COMM_VENC_SetChnParam(chnInputCfg *pIc, VENC_CHN VencChn)
{
    VENC_CHN_PARAM_S stChnParam, *pstChnParam = &stChnParam;
    CVI_S32 s32Ret = CVI_SUCCESS;

    s32Ret = CVI_VENC_GetChnParam(VencChn, pstChnParam);
    if (s32Ret != CVI_SUCCESS) {
    CVI_VENC_ERR("CVI_VENC_GetJpegParam\n");
    return CVI_FAILURE;
    }
    pstChnParam->stCropCfg.bEnable = (pIc->posX || pIc->posY);
    pstChnParam->stCropCfg.stRect.s32X = pIc->posX;
    pstChnParam->stCropCfg.stRect.s32Y = pIc->posY;
    pstChnParam->stCropCfg.stRect.u32Width = pIc->width;
    pstChnParam->stCropCfg.stRect.u32Height = pIc->height;

    s32Ret = CVI_VENC_SetChnParam(VencChn, pstChnParam);
    if (s32Ret != CVI_SUCCESS) {
        CVI_VENC_ERR("CVI_VENC_SetJpegParam\n");
        return CVI_FAILURE;
    }
    return s32Ret;
}

7.3.19. CVI_VENC_GetChnParam

【Description】

Get the channel parameters.

【Syntax】

CVI_S32 CVI_VENC_GetChnParam(VENC_CHN VeChn, VENC_CHN_PARAM_S *pstChnParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number

Input

pstChnParam

Pointer to VENC channel parameter

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • None.

【Example】

  • None.

7.3.20. CVI_VENC_RequestIDR

【Description】

Request IDR frame.

【Syntax】

CVI_S32 CVI_VENC_RequestIDR(VENC_CHN VeChn, CVI_BOOL bInstant);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

bInstant

Enable immediate encoding of IDR frame.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • If the channel is not created, a failure will be returned.

  • After receiving the IDR frame request, regardless of bInstant =0 or not, the IDR frame is immediately encoded, which is not subject to frame rate control.

  • Request for IDR frame, only supported by H.264/H.265 encoding protocols.

  • This interface is not affected by frame rate control and will produce an IDR frame each time it is called. Frequent calls to this interface can affect the stability of the stream frame rate and bit rate.

  • Multiple interface calls before the next frame encoding will only produce one IDR.

    It does not work if the original frame is already an IDR frame.

  • When advanced frame skipping is enabled, the request IDR frame may be delayed.

【Example】

  • None.

7.3.21. CVI_VENC_SetRoiAttr

【Description】

Set the ROI attribute of H.264/H.265 channel.

【Syntax】

CVI_S32 CVI_VENC_SetRoiAttr(VENC_CHN VeChn, const VENC_ROI_ATTR_S *pstRoiAttr);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstRoiAttr

ROI regional parameters.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • u32Index:

    Each channel supports setting up to 8 ROI regions, which are managed according to the index number from 0 to 7.

    The u32Index parameter represents the index number of the ROI region set by the user. If there are duplicate regions, the ROI regions are prioritized in order of the index number from 0 to 7.

  • bEnable: Specifies whether the current ROI region is enabled.

  • bAbsQp: Specifies whether the current ROI region uses absolute QP or relative QP mode.

  • s32Qp:

    When bAbsQp is CVI_True, s32Qp is the QP value set for the ROI area.

    When bAbsQp is CVI_False, s32Qp is the QP value set for the internal rate control of the ROI area plus the QP offset value.

  • stRect:

    Specifies the location coordinates and size of the current ROI region.

    ROI area must be within the image range.

  • By default, the system does not have ROI area enabled.

    The user must set and call this interface to start ROI after the coding channel is created and before the coding channel is destroyed.

    When this interface is called during encoding, it will take effect at the next frame.

  • It is recommended that users call this interface before starting the encoding after creating the channel, reducing the number of calls in encoding process.

    It is recommended that users call the CVI_VENC_GetRoiAttr interface before calling this interface to obtain the ROI configuration of the current channel before setting.

  • After setting the interface, if the current frame is judged to be pskip frame, the pskip frame effect takes precedence.

  • When the rate control mode is not Fixed QP mode, the ROI area can be configured.

  • When ROI is enabled in H.264, macroblock-level bitrate control is disabled.

  • In absolute QP mode, the actual encoded QP of macroblocks may differ slightly from the configured QP due to the bitrate control adjustment of macroblock QP.

    In absolute Qp mode, because the rate control adapts the macroblock QP, there may be some differences between the actual coded QP and the set QP.

【Example】

  • None.

7.3.22. CVI_VENC_GetRoiAttr

【Description】

Get the ROI attribute of H.264/H.265 channel.

【Syntax】

CVI_S32 CVI_VENC_GetRoiAttr(VENC_CHN VeChn, CVI_U32 u32Index, VENC_ROI_ATTR_S *pstRoiAttr);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

u32Index

ROI zone index.

Input

pstRoiAttr

ROI zone parameters.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • According to the u32Index index, the ROI region configuration is obtained.

  • The user must set and call this interface after the code channel is created and before the code channel is destroyed

  • It is recommended that users call CVI_VENC_SetRoiAttr interface before calling it to obtain the ROI configuration of the current channel before setting.

【Example】

  • None.

7.3.23. CVI_VENC_SetRefParam

【Description】

Set the advanced frame skipping reference parameters of H.264/H.265 encoding channel.

【Syntax】

CVI_S32 CVI_VENC_SetRefParam(VENC_CHN VeChn,

 const VENC_REF_PARAM_S *pstRefParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstRefParam

H.264/H.265 coding channel advanced frame skipping reference parameters.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • Both H.264 and H.265 support 1-x, 2-x and 4-x frame skipping reference modes. The default mode is 1-x frame skipping reference mode (no frame skipping).

  • This interface needs to be called after creating the channel and before starting encoding to avoid calling during the encoding process.

  • The configuration of 1x frame skipping reference mode is : bEnablePred = HI_TRUE, u32Enhance = 0,u32Base = 1

  • The configuration of 2x frame skipping reference mode is : bEnablePred = HI_TRUE,u32Enhance = 1,u32Base = 1。

  • The configuration of 4x frame skipping reference mode is : bEnablePred = HI_TRUE,u32Enhance = 1,u32Base = 2

  • When the Gop Mode of the channel is set to NormalP, the u32Gop of 2x frame skipping reference mode should be a multiple of 2, and the u32Gop of 4x frame skipping reference mode should be a multiple of 4

  • When the Gop Mode of the channel is set to SmartP, the u32Gop and u32BgInterval of 2x frame skipping reference mode should be a multiple of 2; the u32Gop and u32BgInterval of 4x frame skipping reference mode should be a multiple of 4

7.3.24. CVI_VENC_GetRefParam

【Description】

Get the advanced frame skipping reference parameters of H.264/H.265 encoding channel.

【Syntax】

CVI_S32 CVI_VENC_GetRefParam(VENC_CHN VeChn, VENC_REF_PARAM_S *pstRefParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstRefParam

H.264/H.265 coding channel advanced frame skipping reference parameters.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • None.

【Example】

  • None.

7.3.25. CVI_VENC_SetFrameLostStrategy

【Description】

Set the frame dropping strategy when the instantaneous bitrate of the encoding channel exceeds the threshold.

【Syntax】

CVI_S32 CVI_VENC_SetFrameLostStrategy(VENC_CHN VeChn,  const VENC_FRAMELOST_S *pstFrmLostParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstFrmLostParam

The parameters of frame in dropping strategy

Input/Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The frame dropping strategy is only supported by H.264/H.265 encoding protocols.

  • The frame dropping strategy configuration is determined by four parameters

    • bFrmLostOpen:

      When the bitrate exceeds the threshold, dropping frames is enabled to ensure that the peak value of the bit rate in the interval does not exceed a certain limit.

    • enFrmLostMode:

      The frame dropping method is only supported for encoding as P-skip frames.

    • u32FrmLostBpsThr:

      According to the system capacity setting, it is recommended to set at least 1.2 times the bit rate

    • u32EncFrmGaps:

      Limiting the maximum number of consecutive dropped frames can make the pictures during the dropout period smoother, but the peak value of the interval bit rate may be higher.

      Setting it to 0 means that there is no limit on the number of consecutive dropped frames, indicating that frames can be dropped continuously as long as the instantaneous bit rate exceeds the threshold, until the instantaneous bit rate is less than or equal to the threshold.

  • Users can choose to enable or disable the frame dropping strategy by calling this interface, and it is disabled by default.

  • This interface is called after the code channel is created and before the code channel is destroyed 。

  • pskip frames are only supported by encoding channels with GOP mode VENC_GOPMODE_NORMALP.

    If the OSD is enabled for the current frame and the OSD has been updated, it cannot be encoded as a Pskip frame.

  • When frame skipping reference mode is enabled, it is not recommended to turn on frame dropping strategy

  • Only supports CBR/VBR rate control modes for H.264/H.265.

【Example】

  • None.

7.3.26. CVI_VENC_GetFrameLostStrategy

【Description】

Get the frame dropping strategy when the instantaneous bitrate of the encoding channel exceeds the threshold.

【Syntax】

CVI_S32 CVI_VENC_GetFrameLostStrategy(VENC_CHN VeChn, VENC_FRAMELOST_S *pstFrmLostParam);

【Parameter】

Parameter

Description

Input/Output

VeChn

VENC Channel number.

Input

pstFrmLostParam

The parameters of frame dropping strategy

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • None.

【Example】

  • None.

7.3.27. CVI_VENC_SetModParam

【Description】

Set the module parameters related to encoding.

【Syntax】

CVI_S32 CVI_VENC_SetModParam(const VENC_PARAM_MOD_S *pstModParam);

【Parameter】

Parameter

Description

Input/Output

pstModParam

Encoding module parameter pointer.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • This interface can be called before and after channel creation.

  • This interface is mainly used to set the corresponding encoding VB pool acquisition method.

    Users can set the VB mode through the VB_SOURCE_E type variable in the VENC_PARAM_MOD_S structure.

【Example】

  • None.

7.3.28. CVI_VENC_GetModParam

【Description】

Get module parameters related to encoding 。

【Syntax】

CVI_S32 CVI_VENC_GetModParam(VENC_PARAM_MOD_S *pstModParam);

【Parameter】

Parameter

Description

Input/Output

pstModParam

Encoding module parameter pointer.

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • Typically used in conjunction with the CVI_VENC_SetModParam function, before making the call.

【Example】

  • None.

7.3.29. CVI_VENC_AttachVbPool

【Description】

Bind the encoding channel to a video buffer VB pool.

【Syntax】

CVI_S32 CVI_VENC_AttachVbPool(VENC_CHN VeChn, const VENC_CHN_POOL_S *pstPool);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstPool

The Id number of the video buffer VB pool.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h、cvi_comm_vb.h

  • Library files: libvenc.a

【Note】

  • You must ensure that the channel has been created, otherwise the error code of CVI_FAILURE will be returned.

  • The user must call the interface CVI_VB_CreatePool creates a visual cache VB pool and then calls the interface CVI_VENC_AttachVbPool binds the current encoding channel to a fixed pool of VB.

    Multiple encoding channels can be bound to the same VB pool, but the same encoding channel cannot be bound to multiple VB pools.

  • pstPool must be a valid PoolId of the created VB pool, including VB pools that store pictures and VB pools that store picture information.

  • Only H.264/H.265 encoding supports UserVB pool mode.

    If the current encoding frame storage allocation method is not using the encoding UserVB pool, CVI_FAILURE will be returned.

  • The user must call this interface in VB_SOURCE_USER mode set through CVI_VENC_SetModParam.

【Example】

  • None.

7.3.30. CVI_VENC_DetachVbPool

【Description】

Unbind the encoding channel from a video cache VB pool .

【Syntax】

CVI_S32 CVI_VENC_DetachVbPool(VENC_CHN VeChn);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h、cvi_comm_vb.h

  • Library files: libvenc.a

【Note】

  • You must ensure that the channel has been created, otherwise the error code of CVI_FAILURE will be returned.

【Example】

  • None.

7.3.31. CVI_VENC_GetH264Entropy

【Description】

Get H.264 entropy coding information

【Syntax】

CVI_S32 CVI_VENC_GetH264Entropy(VENC_CHN VeChn, VENC_H264_ENTROPY_S *pstH264EntropyEnc);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstH264EntropyEnc

Pointer to entropy coding information structure

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

【Example】

  • None.

7.3.32. CVI_VENC_SetH264Entropy

【Description】

Set H.264 entropy coding information

【Syntax】

CVI_S32 CVI_VENC_SetH264Entropy(VENC_CHN VeChn,  const VENC_H264_ENTROPY_S *pstH264EntropyEnc);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstH264EntropyEnc

Pointer to entropy coding information structure

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

【Example】

  • None.

7.3.33. CVI_VENC_InsertUserData

【Description】

Insert user data

【Syntax】

CVI_S32 CVI_VENC_InsertUserData(VENC_CHN VeChn, CVI_U8 *pu8Data,  CVI_U32 u32Len);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number

Input

pu8Data

Data head addres

Input

u32Len

Data size

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

【Example】

  • None.

7.3.34. CVI_VENC_GetCuPrediction

【Description】

CU prediction information retrieval

【Syntax】

CVI_S32 CVI_VENC_GetCuPrediction(VENC_CHN VeChn,

 VENC_CU_PREDICTION_S *pstCuPrediction);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstCuPrediction

Pointer to prediction information structure

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

  • This interface is currently only available for H264 encoding

【Example】

  • None.

7.3.35. CVI_VENC_SetCuPrediction

【Description】

Set CU prediction information.

【Syntax】

CVI_S32 CVI_VENC_SetCuPrediction(VENC_CHN VeChn,  VENC_CU_PREDICTION_S *pstCuPrediction);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstCuPrediction

Pointer to prediction information structure

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

  • This interface is currently only available for H264 encoding

【Example】

  • None.

7.3.36. CVI_VENC_GetH264Trans

【Description】

Get H.264 coding channel transform and quantization attributes

【Syntax】

CVI_S32 CVI_VENC_GetH264Trans(VENC_CHN VeChn, VENC_H264_TRANS_S *pstH264Trans);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstH264Trans

H.264 coding channel transform and quantization attributes

Input

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

  • This interface is currently only available for H264 encoding

【Example】

  • None.

7.3.37. CVI_VENC_SetH264Trans

【Description】

Set H.264 coding channel transform and quantization attributes

【Syntax】

CVI_S32 CVI_VENC_SetH264Trans(VENC_CHN VeChn, const VENC_H264_TRANS_S *pstH264Trans);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstH264Trans

H.264 coding channel transform and quantization attributes

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

  • This interface is currently only available for H264 encoding

【Example】

  • None.

7.3.38. CVI_VENC_SetH265Trans

【Description】

Set H.265 coding channel transform and quantization attributes

【Syntax】

CVI_S32 CVI_VENC_SetH265Trans(VENC_CHN VeChn,

 const VENC_H265_TRANS_S *pstH265Trans);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstH265Trans

H.265 coding channel transform and quantization attributes

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

  • This interface is currently only available for H265 encoding

【Example】

  • None.

7.3.39. CVI_VENC_GetH265Trans

【Description】

Get H.265 coding channel transform and quantization attributes

【Syntax】

CVI_S32 CVI_VENC_SetH264Trans(VENC_CHN VeChn,  const VENC_H264_TRANS_S *pstH264Trans);

【Parameter】

Parameter

Description

Input/Output

VeChn

Channel number.

Input

pstH265Trans

H.265 coding channel transform and quantization attributes

Output

【Return Value】

Return Value

Description

0

Success.

Non 0

Failure. For details, please refer to Error Codes.

【Requirement】

  • Header files: cvi_comm_venc.h、cvi_venc.h

  • Library files: libvenc.a

【Note】

  • The channel must be created beforehand, otherwise an error code of CVI_FAILURE will be returned.

  • This interface is currently only available for H265 encoding

【Example】

  • None.