media: hevc: Embedded indexes in RPS
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Fri, 7 Jan 2022 15:54:55 +0000 (16:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:31 +0000 (14:23 +0200)
[ Upstream commit d95a63daca85f4bca3b70e622c75586b5bf0ea5c ]

Reference Picture Set lists provide indices of short and long term
reference in DBP array.
Fix Hantro to not do a look up in DBP entries.
Make documentation more clear about it.

[hverkuil: fix typo in commit log]

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
drivers/staging/media/hantro/hantro_g2_hevc_dec.c

index 976d344..f1421cf 100644 (file)
@@ -3326,15 +3326,15 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
     * - __u8
       - ``poc_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]``
       - PocStCurrBefore as described in section 8.3.2 "Decoding process for reference
-        picture set.
+        picture set": provides the index of the short term before references in DPB array.
     * - __u8
       - ``poc_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]``
       - PocStCurrAfter as described in section 8.3.2 "Decoding process for reference
-        picture set.
+        picture set": provides the index of the short term after references in DPB array.
     * - __u8
       - ``poc_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]``
       - PocLtCurr as described in section 8.3.2 "Decoding process for reference
-        picture set.
+        picture set": provides the index of the long term references in DPB array.
     * - __u64
       - ``flags``
       - See :ref:`Decode Parameters Flags <hevc_decode_params_flags>`
index e63b777..87086f5 100644 (file)
@@ -264,24 +264,11 @@ static void set_params(struct hantro_ctx *ctx)
        hantro_reg_write(vpu, &g2_apf_threshold, 8);
 }
 
-static int find_ref_pic_index(const struct v4l2_hevc_dpb_entry *dpb, int pic_order_cnt)
-{
-       int i;
-
-       for (i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) {
-               if (dpb[i].pic_order_cnt[0] == pic_order_cnt)
-                       return i;
-       }
-
-       return 0x0;
-}
-
 static void set_ref_pic_list(struct hantro_ctx *ctx)
 {
        const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls;
        struct hantro_dev *vpu = ctx->dev;
        const struct v4l2_ctrl_hevc_decode_params *decode_params = ctrls->decode_params;
-       const struct v4l2_hevc_dpb_entry *dpb = decode_params->dpb;
        u32 list0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] = {};
        u32 list1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] = {};
        static const struct hantro_reg ref_pic_regs0[] = {
@@ -325,11 +312,11 @@ static void set_ref_pic_list(struct hantro_ctx *ctx)
        /* List 0 contains: short term before, short term after and long term */
        j = 0;
        for (i = 0; i < decode_params->num_poc_st_curr_before && j < ARRAY_SIZE(list0); i++)
-               list0[j++] = find_ref_pic_index(dpb, decode_params->poc_st_curr_before[i]);
+               list0[j++] = decode_params->poc_st_curr_before[i];
        for (i = 0; i < decode_params->num_poc_st_curr_after && j < ARRAY_SIZE(list0); i++)
-               list0[j++] = find_ref_pic_index(dpb, decode_params->poc_st_curr_after[i]);
+               list0[j++] = decode_params->poc_st_curr_after[i];
        for (i = 0; i < decode_params->num_poc_lt_curr && j < ARRAY_SIZE(list0); i++)
-               list0[j++] = find_ref_pic_index(dpb, decode_params->poc_lt_curr[i]);
+               list0[j++] = decode_params->poc_lt_curr[i];
 
        /* Fill the list, copying over and over */
        i = 0;
@@ -338,11 +325,11 @@ static void set_ref_pic_list(struct hantro_ctx *ctx)
 
        j = 0;
        for (i = 0; i < decode_params->num_poc_st_curr_after && j < ARRAY_SIZE(list1); i++)
-               list1[j++] = find_ref_pic_index(dpb, decode_params->poc_st_curr_after[i]);
+               list1[j++] = decode_params->poc_st_curr_after[i];
        for (i = 0; i < decode_params->num_poc_st_curr_before && j < ARRAY_SIZE(list1); i++)
-               list1[j++] = find_ref_pic_index(dpb, decode_params->poc_st_curr_before[i]);
+               list1[j++] = decode_params->poc_st_curr_before[i];
        for (i = 0; i < decode_params->num_poc_lt_curr && j < ARRAY_SIZE(list1); i++)
-               list1[j++] = find_ref_pic_index(dpb, decode_params->poc_lt_curr[i]);
+               list1[j++] = decode_params->poc_lt_curr[i];
 
        i = 0;
        while (j < ARRAY_SIZE(list1))