3. Encoder Input Message¶
3.1. ROI Interface Definition¶
3.1.1. CVI_VENC_SetRoiAttr¶
【Description】
Set the ROI properties for the H.264/H.265 channel.
【Syntax】
CVI_S32 CVI_VENC_SetRoiAttr(VENC_CHN VeChn, const VENC_ROI_ATTR_S *pstRoiAttr);【Parameter】
Name
Descriotion
Input/Output
VeChn
VENC Channel number
Input
pstRoiAttr
ROI region parameter
Input
【Return Value】
Return Value
Description
CVI_SUCCESS
Success
Non 0
Failure, please refer to the error code.
【Requirement】
Header files: cvi_comm_venc.h、cvi_venc.h
Library files: libvenc.a
【Note】
u32Index:Each channel can be set with 8 ROI regions. The ROI zones are managed by indexes ranging from 0 to 7. u32Index indicates the ROI index set by the user. Repeat areas are prioritized in order of ROI index numbers from 0 to 7.
bEnable:Specifies whether the current ROI area is enabled.
bAbsQp:Specifies whether absolute QP or relative QP mode is used for the current ROI region.
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 from the internal rate control of the ROI area plus the Qp offset value.
stRect:Specify the location coordinates and size of the current ROI area. The ROI area must be within the image range.
The system has no ROI area enabled by default. 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 takes effect on the next frame.
It is recommended that users call this interface before starting the encoding after creating the channel to reduce the number of calls during encoding.
It is recommended that users call the CVI_VENC_GetRoiAttr interface before calling this interface to obtain the ROI configuration of the current channel and then set it.
After setting the interface, if the current frame is judged to be PSkip frame, the PSkip frame effect takes precedence.
The ROI area can be configured only when the bitrate control mode is not fixed QP mode.
When ROI starts to work in H.264, macroblock level rate control cannot work.
Because the internal rate control adapts the macro block QP, the actual coding QP may be different from the QP set by the absolute Qp mode.
【Example】
None
3.1.2. CVI_VENC_GetRoiAttr¶
【Description】
Get the ROI properties of H.264/H.265 channels.
【Syntax】
CVI_S32 CVI_VENC_GetRoiAttr(VENC_CHN VeChn, CVI_U32 u32Index, VENC_ROI_ATTR_S *pstRoiAttr);【Parameter】
Name
Description
Input/Output
VeChn
VENC Channel number
Input
u32Index
Index number of ROI area
Input
pstRoiAttr
ROI regional parameter
Input
【Return Value】
Return Value
Description
CVI_SUCCESS
Success
Non 0
Failure, please refer to the error code.
【Requirement】
Header files: cvi_comm_venc.h、cvi_venc.h
Library files: libvenc.a
【Note】
Obtain the ROI region configuration according to u32index index
The user must set and call this interface after the encoding channel is created and before the channel is destroyed
It is recommended that users call CVI_VENC_SetRoiAttr interface to obtain the ROI configuration of the current channel then set it.
【Example】
None
3.2. Bitrate Control Interface¶
typedef enum _VENC_RC_MODE_E {
VENC_RC_MODE_H264CBR = 1,
VENC_RC_MODE_H264VBR,
VENC_RC_MODE_H264AVBR,
VENC_RC_MODE_H264QVBR,
VENC_RC_MODE_H264FIXQP,
VENC_RC_MODE_H264QPMAP,
VENC_RC_MODE_MJPEGCBR,
VENC_RC_MODE_MJPEGVBR,
VENC_RC_MODE_MJPEGFIXQP,
VENC_RC_MODE_H265CBR,
VENC_RC_MODE_H265VBR,
VENC_RC_MODE_H265AVBR,
VENC_RC_MODE_H265QVBR,
VENC_RC_MODE_H265FIXQP,
VENC_RC_MODE_H265QPMAP,
VENC_RC_MODE_BUTT,
} VENC_RC_MODE_E;
typedef struct _VENC_RC_ATTR_S {
VENC_RC_MODE_E enRcMode; /* RW; the type of rc*/
union {
VENC_H264_CBR_S stH264Cbr;
VENC_H264_VBR_S stH264Vbr;
VENC_H264_AVBR_S stH264AVbr;
VENC_H264_QVBR_S stH264QVbr;
VENC_H264_FIXQP_S stH264FixQp;
VENC_H264_QPMAP_S stH264QpMap;
VENC_MJPEG_CBR_S stMjpegCbr;
VENC_MJPEG_VBR_S stMjpegVbr;
VENC_MJPEG_FIXQP_S stMjpegFixQp;
VENC_H265_CBR_S stH265Cbr;
VENC_H265_VBR_S stH265Vbr;
VENC_H265_AVBR_S stH265AVbr;
VENC_H265_QVBR_S stH265QVbr;
VENC_H265_FIXQP_S stH265FixQp; ///< The Attribute of FixedQp Mode
VENC_H265_QPMAP_S stH265QpMap;
};
} VENC_RC_ATTR_S;