From 23d3e82c0c00afc96361f20be9a0d3e8c7f44a3e Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Tue, 2 Jun 2020 14:35:02 +0800 Subject: [PATCH] [hal_h264e_vepu1/2]: Add stream amend to hal flow Change-Id: Ic92959a922983e2e251b03dbc58bf91ab67f9050 Signed-off-by: Herman Chen Signed-off-by: sayon.chen --- mpp/hal/vpu/h264e/hal_h264e_vepu1_v2.c | 24 ++++++++++++++++-------- mpp/hal/vpu/h264e/hal_h264e_vepu2_v2.c | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/mpp/hal/vpu/h264e/hal_h264e_vepu1_v2.c b/mpp/hal/vpu/h264e/hal_h264e_vepu1_v2.c index 892a3416..be51e706 100644 --- a/mpp/hal/vpu/h264e/hal_h264e_vepu1_v2.c +++ b/mpp/hal/vpu/h264e/hal_h264e_vepu1_v2.c @@ -65,9 +65,7 @@ typedef struct HalH264eVepu1Ctx_t { H264eMarkingInfo *marking; /* special TSVC stream header fixup */ - size_t buf_size; - RK_U8 *src_buf; - RK_U8 *dst_buf; + HalH264eVepuStreamAmend amend; /* vepu1 macroblock ratecontrol context */ HalH264eVepuMbRcCtx rc_ctx; @@ -94,8 +92,7 @@ static MPP_RET hal_h264e_vepu1_deinit_v2(void *hal) p->rc_ctx = NULL; } - MPP_FREE(p->src_buf); - MPP_FREE(p->dst_buf); + h264e_vepu_stream_amend_deinit(&p->amend); hal_h264e_dbg_func("leave %p\n", p); @@ -136,9 +133,7 @@ static MPP_RET hal_h264e_vepu1_init_v2(void *hal, MppEncHalCfg *cfg) } /* create buffer to TSVC stream */ - p->buf_size = SZ_128K; - p->src_buf = mpp_calloc(RK_U8, p->buf_size); - p->dst_buf = mpp_calloc(RK_U8, p->buf_size); + h264e_vepu_stream_amend_init(&p->amend); DONE: if (ret) @@ -230,6 +225,9 @@ static MPP_RET hal_h264e_vepu1_get_task_v2(void *hal, HalEncTask *task) hw_addr->recn[1] = hw_addr->recn[0] + (yuv_size << 10); hw_addr->refr[1] = hw_addr->refr[0] + (yuv_size << 10); + h264e_vepu_stream_amend_config(&ctx->amend, task->packet, ctx->cfg, + ctx->slice, &task->rc_task->frm); + hal_h264e_dbg_func("leave %p\n", hal); return MPP_OK; @@ -625,6 +623,16 @@ static MPP_RET hal_h264e_vepu1_wait_v2(void *hal, HalEncTask *task) h264e_vepu1_get_mbrc(hw_mbrc, &ctx->regs_get); h264e_vepu_mbrc_update(ctx->rc_ctx, hw_mbrc); + + { + HalH264eVepuStreamAmend *amend = &ctx->amend; + if (amend->enable) { + amend->old_length = hw_mbrc->out_strm_size; + h264e_vepu_stream_amend_proc(amend); + ctx->hw_mbrc.out_strm_size = amend->new_length; + } + } + task->hw_length += ctx->hw_mbrc.out_strm_size; hal_h264e_dbg_func("leave %p\n", hal); diff --git a/mpp/hal/vpu/h264e/hal_h264e_vepu2_v2.c b/mpp/hal/vpu/h264e/hal_h264e_vepu2_v2.c index b479f421..260eaf2c 100644 --- a/mpp/hal/vpu/h264e/hal_h264e_vepu2_v2.c +++ b/mpp/hal/vpu/h264e/hal_h264e_vepu2_v2.c @@ -65,9 +65,7 @@ typedef struct HalH264eVepu2Ctx_t { H264eMarkingInfo *marking; /* special TSVC stream header fixup */ - size_t buf_size; - RK_U8 *src_buf; - RK_U8 *dst_buf; + HalH264eVepuStreamAmend amend; /* vepu2 macroblock ratecontrol context */ HalH264eVepuMbRcCtx rc_ctx; @@ -94,8 +92,7 @@ static MPP_RET hal_h264e_vepu2_deinit_v2(void *hal) p->rc_ctx = NULL; } - MPP_FREE(p->src_buf); - MPP_FREE(p->dst_buf); + h264e_vepu_stream_amend_deinit(&p->amend); hal_h264e_dbg_func("leave %p\n", p); @@ -136,9 +133,7 @@ static MPP_RET hal_h264e_vepu2_init_v2(void *hal, MppEncHalCfg *cfg) } /* create buffer to TSVC stream */ - p->buf_size = SZ_128K; - p->src_buf = mpp_calloc(RK_U8, p->buf_size); - p->dst_buf = mpp_calloc(RK_U8, p->buf_size); + h264e_vepu_stream_amend_init(&p->amend); DONE: if (ret) @@ -230,6 +225,9 @@ static MPP_RET hal_h264e_vepu2_get_task_v2(void *hal, HalEncTask *task) hw_addr->recn[1] = hw_addr->recn[0] + (yuv_size << 10); hw_addr->refr[1] = hw_addr->refr[0] + (yuv_size << 10); + h264e_vepu_stream_amend_config(&ctx->amend, task->packet, ctx->cfg, + ctx->slice, &task->rc_task->frm); + hal_h264e_dbg_func("leave %p\n", hal); return MPP_OK; @@ -652,6 +650,16 @@ static MPP_RET hal_h264e_vepu2_wait_v2(void *hal, HalEncTask *task) h264e_vepu2_get_mbrc(hw_mbrc, &ctx->regs_get); h264e_vepu_mbrc_update(ctx->rc_ctx, hw_mbrc); + + { + HalH264eVepuStreamAmend *amend = &ctx->amend; + if (amend->enable) { + amend->old_length = hw_mbrc->out_strm_size; + h264e_vepu_stream_amend_proc(amend); + ctx->hw_mbrc.out_strm_size = amend->new_length; + } + } + task->hw_length += ctx->hw_mbrc.out_strm_size; hal_h264e_dbg_func("leave %p\n", hal);