[mpp_enc]: Use qp config in rc to setup encoder

1. Unify H.264/H.265/vp8 qp config
2. H.264/H.265 encoder setup default rc qp config.
3. Move rc_cfg process all to mpp_enc module.
4. Fix some encoder config in encoder test.

Change-Id: I2a31c6abf904f1c16c2acd937c8d467d48db531d
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Signed-off-by: sayon.chen <sayon.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2021-01-06 08:56:49 +08:00
parent f04fabc136
commit 17e3a2fefd
10 changed files with 341 additions and 608 deletions

View File

@@ -595,6 +595,21 @@ static MPP_RET mpi_rc_codec(MpiRcTestCtx *ctx)
rc_cfg->fps_out_flex = 0;
rc_cfg->gop = fps;
rc_cfg->max_reenc_times = 1;
rc_cfg->qp_init = -1;
if (rc_cfg->rc_mode == MPP_ENC_RC_MODE_FIXQP) {
/* constant QP mode qp is fixed */
rc_cfg->qp_init = 26;
rc_cfg->qp_max = 26;
rc_cfg->qp_min = 26;
} else if (rc_cfg->rc_mode == MPP_ENC_RC_MODE_CBR) {
/* constant bitrate do not limit qp range */
rc_cfg->qp_max = 48;
rc_cfg->qp_min = 4;
} else if (rc_cfg->rc_mode == MPP_ENC_RC_MODE_VBR) {
/* variable bitrate has qp min limit */
rc_cfg->qp_max = 40;
rc_cfg->qp_min = 12;
}
ret = enc_mpi->control(enc_ctx, MPP_ENC_SET_RC_CFG, rc_cfg);
if (ret) {
@@ -618,8 +633,7 @@ static MPP_RET mpi_rc_codec(MpiRcTestCtx *ctx)
codec_cfg->coding = type;
codec_cfg->h264.change = MPP_ENC_H264_CFG_CHANGE_PROFILE |
MPP_ENC_H264_CFG_CHANGE_ENTROPY |
MPP_ENC_H264_CFG_CHANGE_QP_LIMIT;
MPP_ENC_H264_CFG_CHANGE_ENTROPY;
/*
* H.264 profile_idc parameter
* 66 - Baseline profile
@@ -639,21 +653,6 @@ static MPP_RET mpi_rc_codec(MpiRcTestCtx *ctx)
codec_cfg->h264.entropy_coding_mode = 1;
codec_cfg->h264.cabac_init_idc = 0;
codec_cfg->h264.qp_init = 0;
if (rc_cfg->rc_mode == MPP_ENC_RC_MODE_FIXQP) {
/* constant QP mode qp is fixed */
codec_cfg->h264.qp_init = 26;
codec_cfg->h264.qp_max = 26;
codec_cfg->h264.qp_min = 26;
} else if (rc_cfg->rc_mode == MPP_ENC_RC_MODE_CBR) {
/* constant bitrate do not limit qp range */
codec_cfg->h264.qp_max = 48;
codec_cfg->h264.qp_min = 4;
} else if (rc_cfg->rc_mode == MPP_ENC_RC_MODE_VBR) {
/* variable bitrate has qp min limit */
codec_cfg->h264.qp_max = 40;
codec_cfg->h264.qp_min = 12;
}
ret = enc_mpi->control(enc_ctx, MPP_ENC_SET_CODEC_CFG, codec_cfg);
if (ret) {
mpp_err("mpi control enc set codec cfg failed ret %d\n", ret);