[vp8e]: Fix vp8 reencode logic error.

Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: I0ca2e7725fb2dfb746c882eed14c0e9cf17353db
Signed-off-by: xueman.ruan <xueman.ruan@rock-chips.com>
This commit is contained in:
xueman.ruan
2023-01-29 15:42:50 +08:00
parent 69870145ef
commit 4c9071d19a
4 changed files with 31 additions and 11 deletions

View File

@@ -785,7 +785,7 @@ static MPP_RET set_picbuf_ref(void *hal)
return MPP_OK;
}
static void write_ivf_header(void *hal, RK_U8 *out)
void write_ivf_header(void *hal, RK_U8 *dst)
{
RK_U8 data[IVF_HDR_BYTES] = {0};
@@ -826,7 +826,7 @@ static void write_ivf_header(void *hal, RK_U8 *out)
data[26] = (ctx->frame_cnt >> 16) & 0xff;
data[27] = (ctx->frame_cnt >> 24) & 0xff;
memcpy(out, data, IVF_HDR_BYTES);
memcpy(dst, data, IVF_HDR_BYTES);
}
static void write_ivf_frame(void *hal, RK_U8 *out)
@@ -1569,12 +1569,7 @@ MPP_RET hal_vp8e_update_buffers(void *hal, HalEncTask *task)
RK_S32 disable_ivf = ctx->cfg->codec.vp8.disable_ivf;
if (!disable_ivf) {
if (ctx->frame_cnt == 0) {
write_ivf_header(hal, p_out);
p_out += IVF_HDR_BYTES;
enc_task->length += IVF_HDR_BYTES;
}
p_out += enc_task->length;
if (ctx->frame_size) {
write_ivf_frame(ctx, p_out);

View File

@@ -357,8 +357,9 @@ typedef struct hal_vp8e_ctx_s {
RK_U32 frame_size;
RK_U32 buffer_ready;
RK_U32 ivf_hdr_rdy;
RK_U64 frame_cnt;
RK_U8 last_frm_intra;
RK_U32 last_frm_intra;
Vp8FrmType frame_type;
RK_U32 mb_per_frame;
@@ -376,6 +377,7 @@ MPP_RET hal_vp8e_enc_strm_code(void *hal, HalEncTask *info);
MPP_RET hal_vp8e_init_qp_table(void *hal);
MPP_RET hal_vp8e_setup(void *hal);
MPP_RET hal_vp8e_buf_free(void *hal);
void write_ivf_header(void *hal, RK_U8 *dst);
#ifdef __cplusplus
}
#endif

View File

@@ -307,6 +307,7 @@ static MPP_RET hal_vp8e_vepu1_init_v2(void *hal, MppEncHalCfg *cfg)
ctx->frame_type = VP8E_FRM_KEY;
ctx->prev_frame_lost = 0;
ctx->frame_size = 0;
ctx->ivf_hdr_rdy = 0;
ctx->reg_size = SWREG_AMOUNT_VEPU1;
hw_cfg->irq_disable = 0;
@@ -448,6 +449,7 @@ static MPP_RET hal_vp8e_vepu1_wait_v2(void *hal, HalEncTask *task)
Vp8eFeedback *fb = &ctx->feedback;
Vp8eVepu1Reg_t *regs = (Vp8eVepu1Reg_t *)ctx->regs;
RK_S32 sw_length = task->length;
if (NULL == ctx->dev) {
mpp_err_f("invalid dev ctx\n");
@@ -470,7 +472,7 @@ static MPP_RET hal_vp8e_vepu1_wait_v2(void *hal, HalEncTask *task)
ctx->frame_cnt++;
task->rc_task->info.bit_real = ctx->frame_size << 3;
task->hw_length = task->length;
task->hw_length = task->length - sw_length;
return ret;
}
@@ -493,6 +495,15 @@ static MPP_RET hal_vp8e_vepu1_get_task_v2(void *hal, HalEncTask *task)
ctx->frame_type = task->rc_task->frm.is_intra ? VP8E_FRM_KEY : VP8E_FRM_P;
if (!ctx->cfg->codec.vp8.disable_ivf && !ctx->ivf_hdr_rdy) {
RK_U8 *p_out = mpp_buffer_get_ptr(task->output);
write_ivf_header(hal, p_out);
task->length += IVF_HDR_BYTES;
ctx->ivf_hdr_rdy = 1;
}
return MPP_OK;
}

View File

@@ -311,6 +311,7 @@ static MPP_RET hal_vp8e_vepu2_init_v2(void *hal, MppEncHalCfg *cfg)
ctx->frame_type = VP8E_FRM_KEY;
ctx->prev_frame_lost = 0;
ctx->frame_size = 0;
ctx->ivf_hdr_rdy = 0;
ctx->reg_size = SWREG_AMOUNT_VEPU2;
hw_cfg->irq_disable = 0;
@@ -451,6 +452,7 @@ static MPP_RET hal_vp8e_vepu2_wait_v2(void *hal, HalEncTask *task)
Vp8eFeedback *fb = &ctx->feedback;
Vp8eVepu2Reg_t *regs = (Vp8eVepu2Reg_t *) ctx->regs;
RK_S32 sw_length = task->length;
if (NULL == ctx->dev) {
mpp_err_f("invalid dev ctx\n");
@@ -473,7 +475,7 @@ static MPP_RET hal_vp8e_vepu2_wait_v2(void *hal, HalEncTask *task)
ctx->frame_cnt++;
task->rc_task->info.bit_real = ctx->frame_size << 3;
task->hw_length = task->length;
task->hw_length = task->length - sw_length;
return ret;
}
@@ -494,6 +496,16 @@ static MPP_RET hal_vp8e_vepu2_get_task_v2(void *hal, HalEncTask *task)
}
ctx->frame_type = task->rc_task->frm.is_intra ? VP8E_FRM_KEY : VP8E_FRM_P;
if (!ctx->cfg->codec.vp8.disable_ivf && !ctx->ivf_hdr_rdy) {
RK_U8 *p_out = mpp_buffer_get_ptr(task->output);
write_ivf_header(hal, p_out);
task->length += IVF_HDR_BYTES;
ctx->ivf_hdr_rdy = 1;
}
return MPP_OK;
}