From 5bae75e3a03bef20bde1dbfe4b9f52962fda2de4 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 15 Apr 2025 17:11:51 +0200 Subject: [PATCH] radeonsi/vcn: Fix decode target index for H264 interlaced streams With H264 the target surface can also be in the reference list for current frame, so it can only be inserted into the DPB list after iterating over all references. Fixes: 0e68a2655f4 ("radeonsi/vcn: Rework decode ref handling") Reviewed-by: Ruijing Dong Part-of: (cherry picked from commit b0b52d4922c5d1cd818461801506a0bd6593643d) --- .pick_status.json | 2 +- src/gallium/drivers/radeonsi/radeon_vcn_dec.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index db94835a26d..f0c86acbb41 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -224,7 +224,7 @@ "description": "radeonsi/vcn: Fix decode target index for H264 interlaced streams", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "0e68a2655f46b2a1d2ce969cf18fbababa09a099", "notes": null diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c index a11753f1083..3585044d8ea 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c +++ b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c @@ -155,11 +155,18 @@ static rvcn_dec_message_avc_t get_h264_msg(struct radeon_decoder *dec, if (!found) dec->render_pic_list[i] = NULL; } - if (dec->render_pic_list[i] == target) { - result.decoded_pic_idx = i; - } else if (result.decoded_pic_idx == 0xff && !dec->render_pic_list[i]) { - dec->render_pic_list[i] = target; + if (dec->render_pic_list[i] == target) result.decoded_pic_idx = i; + } + + /* Target surface can also be a reference (other field) */ + if (result.decoded_pic_idx == 0xff) { + for (i = 0; i < ARRAY_SIZE(pic->ref) + 1; i++) { + if (!dec->render_pic_list[i]) { + dec->render_pic_list[i] = target; + result.decoded_pic_idx = i; + break; + } } }