[h264e_sps]: Add parameters config for encoder

Encorder parameters: constraint_set0~5

Signed-off-by: xueman.ruan <xueman.ruan@rock-chips.com>
Change-Id: I7f90ff97881f875ffad77cf4125ee6623d179563
This commit is contained in:
xueman.ruan
2022-08-01 11:48:47 +08:00
committed by Herman Chen
parent a71135a060
commit 82ae30f031
5 changed files with 47 additions and 1 deletions

View File

@@ -667,6 +667,10 @@ typedef enum MppEncH264CfgChange_e {
/* change on vui */
MPP_ENC_H264_CFG_CHANGE_VUI = (1 << 28),
/* change on constraint */
MPP_ENC_H264_CFG_CHANGE_CONSTRAINT_SET = (1 << 29),
MPP_ENC_H264_CFG_CHANGE_ALL = (0xFFFFFFFF),
} MppEncH264CfgChange;
@@ -806,6 +810,17 @@ typedef struct MppEncH264Cfg_t {
RK_S32 max_tid;
RK_S32 prefix_mode;
RK_S32 base_layer_pid;
/*
* Mpp encoder constraint_set parameter
* Mpp encoder constraint_set controls constraint_setx_flag in AVC.
* Mpp encoder constraint_set uses type RK_U32 to store force_flag and constraint_force as followed.
* | 00 | force_flag | 00 | constraint_force |
* As for force_flag and constraint_force, only low 6 bits are valid,
* corresponding to constraint_setx_flag from 5 to 0.
* If force_flag bit is enabled, constraint_setx_flag will be set correspondingly.
* Otherwise, constraint_setx_flag will use default value.
*/
RK_U32 constraint_set;
} MppEncH264Cfg;
#define H265E_MAX_ROI_NUMBER 64

View File

@@ -206,6 +206,7 @@ public:
ENTRY(h264, max_ltr, S32, RK_S32, MPP_ENC_H264_CFG_CHANGE_MAX_LTR, codec.h264, max_ltr_frames) \
ENTRY(h264, prefix_mode, S32, RK_S32, MPP_ENC_H264_CFG_CHANGE_ADD_PREFIX, codec.h264, prefix_mode) \
ENTRY(h264, base_layer_pid, S32, RK_S32, MPP_ENC_H264_CFG_CHANGE_BASE_LAYER_PID, codec.h264, base_layer_pid) \
ENTRY(h264, constraint_set, U32, RK_U32, MPP_ENC_H264_CFG_CHANGE_CONSTRAINT_SET, codec.h264, constraint_set) \
/* h265 config*/ \
ENTRY(h265, profile, S32, RK_S32, MPP_ENC_H265_CFG_PROFILE_LEVEL_TILER_CHANGE, codec.h265, profile) \
ENTRY(h265, level, S32, RK_S32, MPP_ENC_H265_CFG_PROFILE_LEVEL_TILER_CHANGE, codec.h265, level) \
@@ -357,7 +358,7 @@ MppEncCfgService::MppEncCfgService() :
MPP_RET ret;
RK_S32 i;
ret = mpp_trie_init(&trie, 1604, cfg_cnt);
ret = mpp_trie_init(&trie, 1622, cfg_cnt);
if (ret) {
mpp_err_f("failed to init enc cfg set trie\n");
return ;

View File

@@ -435,6 +435,12 @@ static MPP_RET h264e_proc_h264_cfg(MppEncH264Cfg *dst, MppEncH264Cfg *src)
dst->change |= MPP_ENC_H264_CFG_CHANGE_BASE_LAYER_PID;
}
if ((change & MPP_ENC_H264_CFG_CHANGE_CONSTRAINT_SET) &&
(dst->constraint_set != src->constraint_set)) {
dst->constraint_set = src->constraint_set;
dst->change |= MPP_ENC_H264_CFG_CHANGE_CONSTRAINT_SET;
}
src->change = 0;
return ret;
}

View File

@@ -117,6 +117,24 @@ MPP_RET h264e_sps_update(H264eSps *sps, MppEncCfgSet *cfg)
} break;
}
//updata constraint_set0~5
RK_U32 set = h264->constraint_set;
RK_U8 constraint_force = (set >> 0) & 0x3f;
RK_U8 force_flag = (set >> 16) & 0x3f;
if (force_flag & 1)
sps->constraint_set0 = (constraint_force & 1) ? 1 : 0;
if (force_flag & 2)
sps->constraint_set1 = (constraint_force & 2) ? 1 : 0;
if (force_flag & 4)
sps->constraint_set2 = (constraint_force & 4) ? 1 : 0;
if (force_flag & 8)
sps->constraint_set3 = (constraint_force & 8) ? 1 : 0;
if (force_flag & 16)
sps->constraint_set4 = (constraint_force & 16) ? 1 : 0;
if (force_flag & 32)
sps->constraint_set5 = (constraint_force & 32) ? 1 : 0;
// level_idc is connected with frame size
{
RK_S32 mbs = (aligned_w * aligned_h) >> 8;

View File

@@ -405,6 +405,8 @@ MPP_RET test_mpp_enc_cfg_setup(MpiEncMultiCtxInfo *info)
mpp_enc_cfg_set_s32(cfg, "codec:type", p->type);
switch (p->type) {
case MPP_VIDEO_CodingAVC : {
RK_U32 constraint_set;
/*
* H.264 profile_idc parameter
* 66 - Baseline profile
@@ -424,6 +426,10 @@ MPP_RET test_mpp_enc_cfg_setup(MpiEncMultiCtxInfo *info)
mpp_enc_cfg_set_s32(cfg, "h264:cabac_en", 1);
mpp_enc_cfg_set_s32(cfg, "h264:cabac_idc", 0);
mpp_enc_cfg_set_s32(cfg, "h264:trans8x8", 1);
mpp_env_get_u32("constraint_set", &constraint_set, 0);
if (constraint_set & 0x3f0000)
mpp_enc_cfg_set_s32(cfg, "h264:constraint_set", constraint_set);
} break;
case MPP_VIDEO_CodingHEVC :
case MPP_VIDEO_CodingMJPEG :