Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rui Wang and committed by
Mauro Carvalho Chehab
dea42fb7 18e2565d

+25 -4
+25 -4
drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
··· 110 110 * @buf_len_sz_c : size used to store cbcr plane ufo info (AP-R, VPU-W) 111 111 112 112 * @profile : profile sparsed from vpu (AP-R, VPU-W) 113 - * @show_frame : display this frame or not (AP-R, VPU-W) 113 + * @show_frame : [BIT(0)] display this frame or not (AP-R, VPU-W) 114 + * [BIT(1)] reset segment data or not (AP-R, VPU-W) 115 + * [BIT(2)] trig decoder hardware or not (AP-R, VPU-W) 116 + * [BIT(3)] ask VPU to set bits(0~4) accordingly (AP-W, VPU-R) 117 + * [BIT(4)] do not reset segment data before every frame (AP-R, VPU-W) 114 118 * @show_existing_frame : inform this frame is show existing frame 115 119 * (AP-R, VPU-W) 116 120 * @frm_to_show_idx : index to show frame (AP-R, VPU-W) ··· 498 494 frm_to_show->fb->base_y.size); 499 495 } 500 496 if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) { 501 - if (vsi->show_frame) 497 + if (vsi->show_frame & BIT(0)) 502 498 vp9_add_to_fb_disp_list(inst, inst->cur_fb); 503 499 } 504 500 } else { 505 501 if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) { 506 - if (vsi->show_frame) 502 + if (vsi->show_frame & BIT(0)) 507 503 vp9_add_to_fb_disp_list(inst, frm_to_show->fb); 508 504 } 509 505 } ··· 804 800 } 805 801 806 802 inst->vsi = (struct vdec_vp9_vsi *)inst->vpu.vsi; 803 + 804 + inst->vsi->show_frame |= BIT(3); 805 + 807 806 init_all_fb_lists(inst); 808 807 809 808 ctx->drv_handle = inst; ··· 877 870 vsi->sf_frm_sz[idx]); 878 871 } 879 872 } 880 - memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size); 873 + 874 + if (!(vsi->show_frame & BIT(4))) 875 + memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size); 876 + 881 877 ret = vpu_dec_start(&inst->vpu, data, 3); 882 878 if (ret) { 883 879 mtk_vcodec_err(inst, "vpu_dec_start failed"); 884 880 goto DECODE_ERROR; 881 + } 882 + 883 + if (vsi->show_frame & BIT(1)) { 884 + memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size); 885 + 886 + if (vsi->show_frame & BIT(2)) { 887 + if (vpu_dec_start(&inst->vpu, NULL, 0)) { 888 + mtk_vcodec_err(inst, "vpu trig decoder failed"); 889 + goto DECODE_ERROR; 890 + } 891 + } 885 892 } 886 893 887 894 ret = validate_vsi_array_indexes(inst, vsi);