From 6ab470877866a23b241da701b7db130110bdffb9 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 23 May 2020 11:23:04 +0000 Subject: [PATCH] WIP: media: rkvdec: h264: return early when no reference pictures NOTE: also change from a switch statement to access reflists from a pointer array, should simplify once we add support for field reference list Signed-off-by: Jonas Karlman --- drivers/staging/media/rkvdec/rkvdec-h264.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index add6e21d71951b..1c68ebdd8d08e8 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -734,6 +734,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, const struct v4l2_ctrl_h264_sps *sps = run->sps; struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu; u32 max_frame_num = 1 << (sps->log2_max_frame_num_minus4 + 4); + u8 *reflists[3] = { h264_ctx->reflists.p, h264_ctx->reflists.b0, h264_ctx->reflists.b1 }; u32 *hw_rps = priv_tbl->rps; u32 i, j; @@ -741,6 +742,9 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, memset(hw_rps, 0, sizeof(priv_tbl->rps)); + if (!h264_ctx->reflists.num_valid) + return; + /* * Assign an invalid pic_num if DPB entry at that position is inactive. * If we assign 0 in that position hardware will treat that as a real @@ -763,19 +767,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, for (j = 0; j < RKVDEC_NUM_REFLIST; j++) { for (i = 0; i < h264_ctx->reflists.num_valid; i++) { u8 dpb_valid = 0; - u8 idx = 0; - - switch (j) { - case 0: - idx = h264_ctx->reflists.p[i]; - break; - case 1: - idx = h264_ctx->reflists.b0[i]; - break; - case 2: - idx = h264_ctx->reflists.b1[i]; - break; - } + u8 idx = reflists[j][i]; if (idx >= ARRAY_SIZE(dec_params->dpb)) continue;