media: mtk-vcodec: reset segment data then trig decoder

VP9 bitstream specification indicate segment data should reset to
default when meet key frames, intra only frames or enable error
resilience mode. So memset segmentation map buffer before every
decode process is not appropriate.

Reset segment data only when needed, then start decoder hardware

Signed-off-by: Rui Wang <gtk_ruiwang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Rui Wang 2020-02-11 06:55:32 +01:00 committed by Mauro Carvalho Chehab
parent 18e2565d7d
commit dea42fb79f

View File

@ -110,7 +110,11 @@ struct vp9_sf_ref_fb {
* @buf_len_sz_c : size used to store cbcr plane ufo info (AP-R, VPU-W) * @buf_len_sz_c : size used to store cbcr plane ufo info (AP-R, VPU-W)
* @profile : profile sparsed from vpu (AP-R, VPU-W) * @profile : profile sparsed from vpu (AP-R, VPU-W)
* @show_frame : display this frame or not (AP-R, VPU-W) * @show_frame : [BIT(0)] display this frame or not (AP-R, VPU-W)
* [BIT(1)] reset segment data or not (AP-R, VPU-W)
* [BIT(2)] trig decoder hardware or not (AP-R, VPU-W)
* [BIT(3)] ask VPU to set bits(0~4) accordingly (AP-W, VPU-R)
* [BIT(4)] do not reset segment data before every frame (AP-R, VPU-W)
* @show_existing_frame : inform this frame is show existing frame * @show_existing_frame : inform this frame is show existing frame
* (AP-R, VPU-W) * (AP-R, VPU-W)
* @frm_to_show_idx : index to show frame (AP-R, VPU-W) * @frm_to_show_idx : index to show frame (AP-R, VPU-W)
@ -494,12 +498,12 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst)
frm_to_show->fb->base_y.size); frm_to_show->fb->base_y.size);
} }
if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) { if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) {
if (vsi->show_frame) if (vsi->show_frame & BIT(0))
vp9_add_to_fb_disp_list(inst, inst->cur_fb); vp9_add_to_fb_disp_list(inst, inst->cur_fb);
} }
} else { } else {
if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) { if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) {
if (vsi->show_frame) if (vsi->show_frame & BIT(0))
vp9_add_to_fb_disp_list(inst, frm_to_show->fb); vp9_add_to_fb_disp_list(inst, frm_to_show->fb);
} }
} }
@ -800,6 +804,9 @@ static int vdec_vp9_init(struct mtk_vcodec_ctx *ctx)
} }
inst->vsi = (struct vdec_vp9_vsi *)inst->vpu.vsi; inst->vsi = (struct vdec_vp9_vsi *)inst->vpu.vsi;
inst->vsi->show_frame |= BIT(3);
init_all_fb_lists(inst); init_all_fb_lists(inst);
ctx->drv_handle = inst; ctx->drv_handle = inst;
@ -870,13 +877,27 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
vsi->sf_frm_sz[idx]); vsi->sf_frm_sz[idx]);
} }
} }
memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size);
if (!(vsi->show_frame & BIT(4)))
memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size);
ret = vpu_dec_start(&inst->vpu, data, 3); ret = vpu_dec_start(&inst->vpu, data, 3);
if (ret) { if (ret) {
mtk_vcodec_err(inst, "vpu_dec_start failed"); mtk_vcodec_err(inst, "vpu_dec_start failed");
goto DECODE_ERROR; goto DECODE_ERROR;
} }
if (vsi->show_frame & BIT(1)) {
memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size);
if (vsi->show_frame & BIT(2)) {
if (vpu_dec_start(&inst->vpu, NULL, 0)) {
mtk_vcodec_err(inst, "vpu trig decoder failed");
goto DECODE_ERROR;
}
}
}
ret = validate_vsi_array_indexes(inst, vsi); ret = validate_vsi_array_indexes(inst, vsi);
if (ret) { if (ret) {
mtk_vcodec_err(inst, "Invalid values from VPU."); mtk_vcodec_err(inst, "Invalid values from VPU.");