[hal_h264e_vepu1/2]: Add stream amend to hal flow

Change-Id: Ic92959a922983e2e251b03dbc58bf91ab67f9050
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
2020-06-02 14:35:02 +08:00
parent 197bda000f
commit 23d3e82c0c
2 changed files with 32 additions and 16 deletions

View File

@@ -65,9 +65,7 @@ typedef struct HalH264eVepu1Ctx_t {
H264eMarkingInfo *marking; H264eMarkingInfo *marking;
/* special TSVC stream header fixup */ /* special TSVC stream header fixup */
size_t buf_size; HalH264eVepuStreamAmend amend;
RK_U8 *src_buf;
RK_U8 *dst_buf;
/* vepu1 macroblock ratecontrol context */ /* vepu1 macroblock ratecontrol context */
HalH264eVepuMbRcCtx rc_ctx; HalH264eVepuMbRcCtx rc_ctx;
@@ -94,8 +92,7 @@ static MPP_RET hal_h264e_vepu1_deinit_v2(void *hal)
p->rc_ctx = NULL; p->rc_ctx = NULL;
} }
MPP_FREE(p->src_buf); h264e_vepu_stream_amend_deinit(&p->amend);
MPP_FREE(p->dst_buf);
hal_h264e_dbg_func("leave %p\n", p); 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 */ /* create buffer to TSVC stream */
p->buf_size = SZ_128K; h264e_vepu_stream_amend_init(&p->amend);
p->src_buf = mpp_calloc(RK_U8, p->buf_size);
p->dst_buf = mpp_calloc(RK_U8, p->buf_size);
DONE: DONE:
if (ret) 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->recn[1] = hw_addr->recn[0] + (yuv_size << 10);
hw_addr->refr[1] = hw_addr->refr[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); hal_h264e_dbg_func("leave %p\n", hal);
return MPP_OK; 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_vepu1_get_mbrc(hw_mbrc, &ctx->regs_get);
h264e_vepu_mbrc_update(ctx->rc_ctx, hw_mbrc); 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; task->hw_length += ctx->hw_mbrc.out_strm_size;
hal_h264e_dbg_func("leave %p\n", hal); hal_h264e_dbg_func("leave %p\n", hal);

View File

@@ -65,9 +65,7 @@ typedef struct HalH264eVepu2Ctx_t {
H264eMarkingInfo *marking; H264eMarkingInfo *marking;
/* special TSVC stream header fixup */ /* special TSVC stream header fixup */
size_t buf_size; HalH264eVepuStreamAmend amend;
RK_U8 *src_buf;
RK_U8 *dst_buf;
/* vepu2 macroblock ratecontrol context */ /* vepu2 macroblock ratecontrol context */
HalH264eVepuMbRcCtx rc_ctx; HalH264eVepuMbRcCtx rc_ctx;
@@ -94,8 +92,7 @@ static MPP_RET hal_h264e_vepu2_deinit_v2(void *hal)
p->rc_ctx = NULL; p->rc_ctx = NULL;
} }
MPP_FREE(p->src_buf); h264e_vepu_stream_amend_deinit(&p->amend);
MPP_FREE(p->dst_buf);
hal_h264e_dbg_func("leave %p\n", p); 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 */ /* create buffer to TSVC stream */
p->buf_size = SZ_128K; h264e_vepu_stream_amend_init(&p->amend);
p->src_buf = mpp_calloc(RK_U8, p->buf_size);
p->dst_buf = mpp_calloc(RK_U8, p->buf_size);
DONE: DONE:
if (ret) 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->recn[1] = hw_addr->recn[0] + (yuv_size << 10);
hw_addr->refr[1] = hw_addr->refr[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); hal_h264e_dbg_func("leave %p\n", hal);
return MPP_OK; 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_vepu2_get_mbrc(hw_mbrc, &ctx->regs_get);
h264e_vepu_mbrc_update(ctx->rc_ctx, hw_mbrc); 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; task->hw_length += ctx->hw_mbrc.out_strm_size;
hal_h264e_dbg_func("leave %p\n", hal); hal_h264e_dbg_func("leave %p\n", hal);