123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- /******************************************************************************
- Copyright (C), 2016-2017, Hisilicon Tech. Co., Ltd.
- ******************************************************************************
- File Name : hi_comm_rc.h
- Version : Initial Draft
- Author : Hisilicon multimedia software group
- Created : 2016/11/15
- Last Modified :
- Description : common struct definition for Rate control
- Function List :
- ******************************************************************************/
- #ifndef __HI_COMM_RC_H__
- #define __HI_COMM_RC_H__
- #include "hi_defines.h"
- #ifdef __cplusplus
- #if __cplusplus
- extern "C"{
- #endif
- #endif /* __cplusplus */
- typedef HI_U32 HI_FR32;
- /* rc mode */
- typedef enum hiVENC_RC_MODE_E
- {
- VENC_RC_MODE_H264CBR = 1,
- VENC_RC_MODE_H264VBR,
- VENC_RC_MODE_H264AVBR,
- 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_H265FIXQP,
- VENC_RC_MODE_H265QPMAP,
- VENC_RC_MODE_BUTT,
- }VENC_RC_MODE_E;
- /* qpmap mode*/
- typedef enum hiVENC_RC_QPMAP_MODE_E
- {
- VENC_RC_QPMAP_MODE_MEANQP= 0,
- VENC_RC_QPMAP_MODE_MINQP ,
- VENC_RC_QPMAP_MODE_MAXQP,
- VENC_RC_QPMAP_MODE_BUTT,
- }VENC_RC_QPMAP_MODE_E;
- /* the attribute of h264e fixqp*/
- typedef struct hiVENC_H264_FIXQP_S
- {
- HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- HI_U32 u32IQp; /* RW; Range:[0, 51]; qp of the i frame */
- HI_U32 u32PQp; /* RW; Range:[0, 51]; qp of the p frame */
- HI_U32 u32BQp; /* RW; Range:[0, 51]; qp of the b frame */
- } VENC_H264_FIXQP_S;
- /* the attribute of h264e cbr*/
- typedef struct hiVENC_H264_CBR_S
- {
- HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of I Frame. */
- HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- HI_U32 u32BitRate; /* RW; Range:[2, 409600]; average bitrate */
- } VENC_H264_CBR_S;
- /* the attribute of h264e vbr*/
- typedef struct hiVENC_H264_VBR_S
- {
- HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
- HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- HI_U32 u32MaxBitRate; /* RW; Range:[2, 409600];the max bitrate */
- }VENC_H264_VBR_S;
- /* the attribute of h264e avbr*/
- typedef struct hiVENC_H264_AVBR_S
- {
- HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
- HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- HI_U32 u32MaxBitRate; /* RW; Range:[2, 409600];the max bitrate */
- }VENC_H264_AVBR_S;
- /* the attribute of h264e qpmap*/
- typedef struct hiVENC_H264_QPMAP_S
- {
- HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
- HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- }VENC_H264_QPMAP_S;
- /* the attribute of h265e qpmap*/
- typedef struct hiVENC_H265_QPMAP_S
- {
- HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
- HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; the QpMap Mode.*/
- }VENC_H265_QPMAP_S;
- typedef struct hiVENC_H264_CBR_S VENC_H265_CBR_S;
- typedef struct hiVENC_H264_VBR_S VENC_H265_VBR_S;
- typedef struct hiVENC_H264_AVBR_S VENC_H265_AVBR_S;
- typedef struct hiVENC_H264_FIXQP_S VENC_H265_FIXQP_S;
- /* the attribute of mjpege fixqp*/
- typedef struct hiVENC_MJPEG_FIXQP_S
- {
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- HI_U32 u32Qfactor; /* RW; Range:[1,99];image quality. */
- }VENC_MJPEG_FIXQP_S;
- /* the attribute of mjpege cbr*/
- typedef struct hiVENC_MJPEG_CBR_S
- {
- HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- HI_U32 u32BitRate; /* RW; Range:[2, 409600]; average bitrate */
- } VENC_MJPEG_CBR_S;
- /* the attribute of mjpege vbr*/
- typedef struct hiVENC_MJPEG_VBR_S
- {
- HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
- HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
- HI_FR32 fr32DstFrameRate; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
- HI_U32 u32MaxBitRate; /* RW; Range:[2, 409600];the max bitrate */
- }VENC_MJPEG_VBR_S;
- /* the attribute of rc*/
- typedef struct hiVENC_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_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_FIXQP_S stH265FixQp;
- VENC_H265_QPMAP_S stH265QpMap;
- };
- }VENC_RC_ATTR_S;
- /*the super frame mode*/
- typedef enum hiRC_SUPERFRM_MODE_E
- {
- SUPERFRM_NONE=0, /* sdk don't care super frame */
- SUPERFRM_DISCARD, /* the super frame is discarded */
- SUPERFRM_REENCODE, /* the super frame is re-encode */
- SUPERFRM_BUTT
- }VENC_SUPERFRM_MODE_E;
- /* The param of H264e cbr*/
- typedef struct hiVENC_PARAM_H264_CBR_S
- {
- HI_U32 u32MinIprop; /* RW; Range:[1, 100]; the min ratio of i frame and p frame */
- HI_U32 u32MaxIprop; /* RW; Range:[u32MinIprop, 100]; the max ratio of i frame and p frame */
- HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51];the max QP value */
- HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min QP value */
- HI_U32 u32MaxIQp; /* RW; Range:(MinQp, 51]; max qp for i frame */
- HI_U32 u32MinIQp; /* RW; Range:[0, 51]; min qp for i frame */
- HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
- HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
- }VENC_PARAM_H264_CBR_S;
- /* The param of H264e vbr*/
- typedef struct hiVENC_PARAM_H264_VBR_S
- {
- HI_S32 s32ChangePos; /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to the maximum
- bit rate when the QP value starts to be adjusted */
- HI_U32 u32MinIprop; /* RW; Range:[1, 100] ; the min ratio of i frame and p frame */
- HI_U32 u32MaxIprop; /* RW; Range:[u32MinIprop, 100] ; the max ratio of i frame and p frame */
- HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; max number of re-encode times */
- HI_BOOL bQpMapEn;
- HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51]; the max P B qp */
- HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min P B qp */
- HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51]; the max I qp */
- HI_U32 u32MinIQp; /* RW; Range:[0, 51]; the min I qp */
- } VENC_PARAM_H264_VBR_S;
- /* The param of H264e avbr*/
- typedef struct hiVENC_PARAM_H264_AVBR_S
- {
- HI_S32 s32ChangePos; /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to the maximum
- bit rate when the QP value starts to be adjusted */
- HI_U32 u32MinIprop; /* RW; Range:[1, 100] ; the min ratio of i frame and p frame */
- HI_U32 u32MaxIprop; /* RW; Range:[u32MinIprop, 100] ; the max ratio of i frame and p frame */
- HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; max number of re-encode times */
- HI_BOOL bQpMapEn;
- HI_S32 s32MinStillPercent; /* RW; Range:[20, 100]; the min percent of target bitrate for still scene */
- HI_U32 u32MaxStillQP; /* RW; Range:[MinIQp, MaxIQp]; the max QP value of I frame for still scene*/
- HI_U32 u32MinStillPSNR; /* RW; reserved,Invalid member currently */
- HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51]; the max P B qp */
- HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min P B qp */
- HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51]; the max I qp */
- HI_U32 u32MinIQp; /* RW; Range:[0, 51]; the min I qp */
- HI_U32 u32MotionSensitivity; /* RW; Range:[0, 100]; Motion Sensitivity */
- } VENC_PARAM_H264_AVBR_S;
- /* The param of mjpege cbr*/
- typedef struct hiVENC_PARAM_MJPEG_CBR_S
- {
- HI_U32 u32MaxQfactor; /* RW; Range:[MinQfactor, 99]; the max Qfactor value*/
- HI_U32 u32MinQfactor; /* RW; Range:[1, 99]; the min Qfactor value */
- }VENC_PARAM_MJPEG_CBR_S;
- /* The param of mjpege vbr*/
- typedef struct hiVENC_PARAM_MJPEG_VBR_S
- {
- HI_S32 s32ChangePos; /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to the maximum
- bit rate when the Qfactor value starts to be adjusted */
- HI_U32 u32MaxQfactor; /* RW; Range:[MinQfactor, 99]; max image quailty allowed */
- HI_U32 u32MinQfactor; /* RW; Range:[1, 99]; min image quality allowed */
- }VENC_PARAM_MJPEG_VBR_S;
- /* The param of h265e cbr*/
- typedef struct hiVENC_PARAM_H265_CBR_S
- {
- HI_U32 u32MinIprop; /* RW; Range: [u32MinIprop, 100]; the min ratio of i frame and p frame */
- HI_U32 u32MaxIprop; /* RW; Range: [1, 100];the max ratio of i frame and p frame */
- HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51];the max QP value */
- HI_U32 u32MinQp; /* RW; Range:[1, 51];the min QP value */
- HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51];max qp for i frame */
- HI_U32 u32MinIQp; /* RW; Range:[1, 51];min qp for i frame */
- HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
- HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
- VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; Qpmap Mode*/
- }VENC_PARAM_H265_CBR_S;
- /* The param of h265e vbr*/
- typedef struct hiVENC_PARAM_H265_VBR_S
- {
- HI_S32 s32ChangePos; /* RW; Range:[50, 100];Indicates the ratio of the current bit rate to the maximum bit rate when the QP value starts to be adjusted */
- HI_U32 u32MinIprop; /* RW; [1, 100]the min ratio of i frame and p frame */
- HI_U32 u32MaxIprop; /* RW; (MinIprop, 100]the max ratio of i frame and p frame */
- HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
- HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51]; the max P B qp */
- HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min P B qp */
- HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51]; the max I qp */
- HI_U32 u32MinIQp; /* RW; Range:[0, 51]; the min I qp */
- HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
- VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; Qpmap Mode*/
- } VENC_PARAM_H265_VBR_S;
- /* The param of h265e vbr*/
- typedef struct hiVENC_PARAM_H265_AVBR_S
- {
- HI_S32 s32ChangePos; /* RW; Range:[50, 100];Indicates the ratio of the current bit rate to the maximum
- bit rate when the QP value starts to be adjusted */
- HI_U32 u32MinIprop; /* RW; [1, 100]the min ratio of i frame and p frame */
- HI_U32 u32MaxIprop; /* RW; (MinIprop, 100]the max ratio of i frame and p frame */
- HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
- HI_S32 s32MinStillPercent; /* RW; Range:[20, 100]; the min percent of target bitrate for still scene */
- HI_U32 u32MaxStillQP; /* RW; Range:[MinIQp, MaxIQp]; the max QP value of I frame for still scene*/
- HI_U32 u32MinStillPSNR; /* RW; reserved */
- HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51];the max P B qp */
- HI_U32 u32MinQp; /* RW; Range:[1, 51];the min P B qp */
- HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51];the max I qp */
- HI_U32 u32MinIQp; /* RW; Range:[1, 51];the min I qp */
- HI_U32 u32MotionSensitivity; /* RW; Range:[0, 100]; Motion Sensitivity */
- HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
- VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; Qpmap Mode*/
- } VENC_PARAM_H265_AVBR_S;
- /* The param of rc*/
- typedef struct hiVENC_RC_PARAM_S
- {
- HI_U32 u32ThrdI[RC_TEXTURE_THR_SIZE]; /*RW; Range:[0, 255]; Mad threshold for controlling the macroblock-level bit rate of I frames */
- HI_U32 u32ThrdP[RC_TEXTURE_THR_SIZE]; /*RW; Range:[0, 255]; Mad threshold for controlling the macroblock-level bit rate of P frames */
- HI_U32 u32ThrdB[RC_TEXTURE_THR_SIZE]; /*RW; Range:[0, 255]; Mad threshold for controlling the macroblock-level bit rate of B frames */
- HI_U32 u32DirectionThrd; /*RW; Range:[0, 16]; The direction for controlling the macroblock-level bit rate*/
- HI_U32 u32RowQpDelta; /* RW; Range:[0, 10];the start QP value of each macroblock row relative to the start QP value */
- HI_S32 s32FirstFrameStartQp; /* RW; Range:[1, 51];Start QP value of the first frame*/
- union
- {
- VENC_PARAM_H264_CBR_S stParamH264Cbr;
- VENC_PARAM_H264_VBR_S stParamH264Vbr;
- VENC_PARAM_H264_AVBR_S stParamH264AVbr;
- VENC_PARAM_H265_CBR_S stParamH265Cbr;
- VENC_PARAM_H265_VBR_S stParamH265Vbr;
- VENC_PARAM_H265_AVBR_S stParamH265AVbr;
- VENC_PARAM_MJPEG_CBR_S stParamMjpegCbr;
- VENC_PARAM_MJPEG_VBR_S stParamMjpegVbr;
- };
- }VENC_RC_PARAM_S;
- /* the frame lost mode*/
- typedef enum hiVENC_FRAMELOST_MODE_E
- {
- FRMLOST_NORMAL=0, /*normal mode*/
- FRMLOST_PSKIP, /*pskip*/
- FRMLOST_BUTT,
- }VENC_FRAMELOST_MODE_E;
- /* The param of the frame lost mode*/
- typedef struct hiVENC_FRAMELOST_S
- {
- HI_BOOL bFrmLostOpen; /* RW; Range:[0,1];Indicates whether to discard frames to ensure stable bit rate when the instant bit rate is exceeded */
- HI_U32 u32FrmLostBpsThr; /* RW; Range:[64k, 163840k];the instant bit rate threshold */
- VENC_FRAMELOST_MODE_E enFrmLostMode; /* frame lost strategy*/
- HI_U32 u32EncFrmGaps; /* RW; Range:[0,65535]; the gap of frame lost*/
- }VENC_FRAMELOST_S;
- /* the rc priority*/
- typedef enum hiVENC_RC_PRIORITY_E
- {
- VENC_RC_PRIORITY_BITRATE_FIRST = 1, /* bitrate first */
- VENC_RC_PRIORITY_FRAMEBITS_FIRST, /* framebits first*/
- VENC_RC_PRIORITY_BUTT,
- } VENC_RC_PRIORITY_E;
- /* the config of the superframe */
- typedef struct hiVENC_SUPERFRAME_CFG_S
- {
- VENC_SUPERFRM_MODE_E enSuperFrmMode; /* RW; Indicates the mode of processing the super frame*/
- HI_U32 u32SuperIFrmBitsThr; /* RW; Range:[0, 4294967295];Indicate the threshold of the super I frame for enabling the super frame processing mode */
- HI_U32 u32SuperPFrmBitsThr; /* RW; Range:[0, 4294967295];Indicate the threshold of the super P frame for enabling the super frame processing mode */
- HI_U32 u32SuperBFrmBitsThr; /* RW; Range:[0, 4294967295];Indicate the threshold of the super B frame for enabling the super frame processing mode */
- VENC_RC_PRIORITY_E enRcPriority; /* RW; Rc Priority*/
- }VENC_SUPERFRAME_CFG_S;
- #ifdef __cplusplus
- #if __cplusplus
- }
- #endif
- #endif /* __cplusplus */
- #endif /* __HI_COMM_RC_H__ */
|