mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-21 08:09:22 +08:00
[rc_v2]: Fix divide 0 when gop is infinite
1. Fix bit calc when gop set 0 or 1 2. When gop set 0, will set 300 for bit calc Change-Id: I8c6f8dfd634a5c5cee760de6226f156e897d91b0 Signed-off-by: sayon.chen <sayon.chen@rock-chips.com>
This commit is contained in:
@@ -166,6 +166,11 @@ MPP_RET bits_model_init(RcModelV2Ctx *ctx)
|
||||
ctx->usr_cfg.max_i_bit_prop = 20;
|
||||
}
|
||||
|
||||
if (!gop_len) {
|
||||
mpp_log("infinte gop, set default for rc bit calc\n");
|
||||
ctx->usr_cfg.igop = gop_len = 300;
|
||||
}
|
||||
|
||||
ctx->super_ifrm_bits_thr = -1;
|
||||
ctx->super_pfrm_bits_thr = -1;
|
||||
|
||||
@@ -320,7 +325,11 @@ MPP_RET bits_model_alloc(RcModelV2Ctx *ctx, EncRcTaskInfo *cfg)
|
||||
}
|
||||
|
||||
rc_dbg_rc("i_scale %d, total_bits %lld", i_scale, total_bits);
|
||||
cfg->bit_target = total_bits / (i_scale + 16 * (gop_len - 1));
|
||||
if (gop_len > 1) {
|
||||
cfg->bit_target = total_bits / (i_scale + 16 * (gop_len - 1));
|
||||
} else {
|
||||
cfg->bit_target = total_bits / i_scale;
|
||||
}
|
||||
ctx->ins_bps = ins_bps;
|
||||
|
||||
rc_dbg_func("leave %p\n", ctx);
|
||||
@@ -331,10 +340,15 @@ MPP_RET calc_next_i_ratio(RcModelV2Ctx *ctx)
|
||||
{
|
||||
RK_S32 max_i_prop = ctx->usr_cfg.max_i_bit_prop * 16;
|
||||
RK_S32 gop_len = ctx->usr_cfg.igop;
|
||||
RK_S32 bits_alloc = ctx->gop_total_bits * max_i_prop / (max_i_prop + 16 * (gop_len - 1));
|
||||
RK_S32 pre_qp = ctx->pre_i_qp;
|
||||
RK_S32 bits_alloc;
|
||||
|
||||
rc_dbg_func("enter %p\n", ctx);
|
||||
if (gop_len > 1) {
|
||||
bits_alloc = ctx->gop_total_bits * max_i_prop / (max_i_prop + 16 * (gop_len - 1));
|
||||
} else {
|
||||
bits_alloc = ctx->gop_total_bits * max_i_prop / max_i_prop;
|
||||
}
|
||||
|
||||
if (ctx->pre_real_bits > bits_alloc || ctx->next_i_ratio) {
|
||||
RK_S32 ratio = ((ctx->pre_real_bits - bits_alloc) << 8) / bits_alloc;
|
||||
|
Reference in New Issue
Block a user