mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-13 04:43:42 +08:00
[rc]: Fix error div zero on reencoding
Change-Id: I8ecbcbf3d5af822e6f0332bcb42d98a2881a8b5a Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
@@ -724,6 +724,7 @@ void *mpp_enc_thread(void *data)
|
||||
|
||||
enc_dbg_detail("task %d rc frame end\n", frm->seq_idx);
|
||||
RUN_ENC_RC_FUNC(rc_frm_end, enc->rc_ctx, rc_task, mpp, ret);
|
||||
|
||||
if (frm->reencode) {
|
||||
enc_dbg_reenc("reencode time %d\n", frm->reencode_times);
|
||||
goto TASK_REENCODE;
|
||||
@@ -844,7 +845,8 @@ MPP_RET mpp_enc_init_v2(MppEnc *enc, MppEncCfg *cfg)
|
||||
p->enc_hal = enc_hal;
|
||||
p->mpp = cfg->mpp;
|
||||
|
||||
{ // create header packet storage
|
||||
{
|
||||
// create header packet storage
|
||||
size_t size = SZ_1K;
|
||||
void *ptr = mpp_calloc_size(void, size);
|
||||
|
||||
|
@@ -420,13 +420,10 @@ MPP_RET reenc_calc_cbr_ratio(RcModelV2Ctx *ctx, EncRcTaskInfo *cfg)
|
||||
RK_S32 target_bps = ctx->target_bps;
|
||||
RK_S32 water_level = 0;
|
||||
RK_S32 idx1, idx2;
|
||||
RK_S32 i_flag = 0;
|
||||
RK_S32 bit_diff_ratio, ins_ratio, bps_ratio, wl_ratio;
|
||||
|
||||
rc_dbg_func("enter %p\n", ctx);
|
||||
|
||||
i_flag = (ctx->frame_type == INTRA_FRAME);
|
||||
|
||||
if (real_bit + ctx->stat_watl > ctx->stat_watl_thrd)
|
||||
water_level = ctx->stat_watl_thrd - ctx->bit_per_frame;
|
||||
else
|
||||
@@ -454,7 +451,7 @@ MPP_RET reenc_calc_cbr_ratio(RcModelV2Ctx *ctx, EncRcTaskInfo *cfg)
|
||||
ins_ratio = 6 * ins_ratio;
|
||||
ins_ratio = mpp_clip(ins_ratio, -192, 256);
|
||||
} else {
|
||||
if (i_flag) {
|
||||
if (ctx->frame_type == INTRA_FRAME) {
|
||||
ins_ratio = 3 * ins_ratio;
|
||||
ins_ratio = mpp_clip(ins_ratio, -192, 256);
|
||||
} else {
|
||||
@@ -850,11 +847,11 @@ MPP_RET rc_model_v2_end(void *ctx, EncRcTask *task)
|
||||
} else {
|
||||
rc_dbg_rc("bits_mode_update real_bit %d", cfg->bit_real);
|
||||
bits_model_update(p, cfg->bit_real);
|
||||
p->pre_target_bits = cfg->bit_target;
|
||||
p->pre_real_bits = cfg->bit_real;
|
||||
p->last_inst_bps = p->ins_bps;
|
||||
p->last_frame_type = p->frame_type;
|
||||
}
|
||||
p->pre_target_bits = cfg->bit_target;
|
||||
p->pre_real_bits = cfg->bit_real;
|
||||
|
||||
rc_dbg_func("leave %p\n", ctx);
|
||||
return MPP_OK;
|
||||
|
Reference in New Issue
Block a user