If the slice header had the num_ref_idx_active_override flag set, we should use the num_ref_idx_l[01]_active_minus1 fields instead of the defaults from the PPS. Signed-off-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx> --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index 7ab534936843..544cf92ab62c 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -28,6 +28,8 @@ static void set_params(struct hantro_ctx *ctx) const struct v4l2_ctrl_h264_pps *pps = ctrls->pps; struct vb2_v4l2_buffer *src_buf = hantro_get_src_buf(ctx); struct hantro_dev *vpu = ctx->dev; + unsigned char refidx0_active; + unsigned char refidx1_active; u32 reg; /* Decoder control register 0. */ @@ -101,9 +103,16 @@ static void set_params(struct hantro_ctx *ctx) vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL5); /* Decoder control register 6. */ + if (sps->flags & V4L2_H264_SLICE_FLAG_NUM_REF_IDX_ACTIVE_OVERRIDE) { + refidx0_active = slices[0].num_ref_idx_l0_active_minus1 + 1; + refidx1_active = slices[0].num_ref_idx_l1_active_minus1 + 1; + } else { + refidx0_active = pps->num_ref_idx_l0_default_active_minus1 + 1; + refidx1_active = pps->num_ref_idx_l1_default_active_minus1 + 1; + } reg = G1_REG_DEC_CTRL6_PPS_ID(slices[0].pic_parameter_set_id) | - G1_REG_DEC_CTRL6_REFIDX0_ACTIVE(pps->num_ref_idx_l0_default_active_minus1 + 1) | - G1_REG_DEC_CTRL6_REFIDX1_ACTIVE(pps->num_ref_idx_l1_default_active_minus1 + 1) | + G1_REG_DEC_CTRL6_REFIDX0_ACTIVE(refidx0_active) | + G1_REG_DEC_CTRL6_REFIDX1_ACTIVE(refidx1_active) | G1_REG_DEC_CTRL6_POC_LENGTH(slices[0].pic_order_cnt_bit_size); vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL6); -- 2.20.1