From c2a4fa33b8796c154b3ccd97162f849ea543c343 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 17 Apr 2026 09:22:00 +0200 Subject: [PATCH] frontends/va: Fix finding LTRs from POCs in HEVC decode This should only consider valid entries, not loop over the entire array. In addition the array size was wrong before. Fixes: 779edc07598 ("frontends/va: Correctly derive HEVC StCurrBefore, StCurrAfter and LtCurr") Reviewed-by: Benjamin Cheng Part-of: --- src/gallium/frontends/va/picture_hevc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/va/picture_hevc.c b/src/gallium/frontends/va/picture_hevc.c index 16ba4ca4b79..aa2b6db6993 100644 --- a/src/gallium/frontends/va/picture_hevc.c +++ b/src/gallium/frontends/va/picture_hevc.c @@ -420,7 +420,9 @@ void vlVaDecoderHEVCBitstreamHeader(vlVaContext *context, vlVaBuffer *buf) /* We know the POCs for all LTRs from slice header, fill the LTR ref pic * set with them. */ for (uint8_t i = 0; i < ltr_idx; i++) { - for (uint8_t j = 0; j < sizeof(pic->PicOrderCntVal); ++j) { + for (uint8_t j = 0; j < 15; ++j) { + if (!pic->ref[j]) + continue; uint32_t refpoc = pic->PicOrderCntVal[j]; if ((ltr_tmp[i].msb && ltr_tmp[i].poc == refpoc) || (!ltr_tmp[i].msb && ltr_tmp[i].poc == refpoc % max_poc)) {