h->long_ref isn't guaranteed to be contiguously filled. Use the approach from both vaapi_h264 and vdpau_h264 which goes through the 16 frames in h->long_ref to find the LTR entries. Fixes MR2_MW_A.264 from JVT-AVC_V1.
Unified · Split
| @@ -406,10 +406,14 @@ static int vk_h264_start_frame(AVCodecContext *avctx, · 405 unmodified lines | ||
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /* Fill in long-term refs */ |
| 409 | − for (int r = 0, i = h->short_ref_count; i < h->short_ref_count + h->long_ref_count; i++, r++) { | |
| 409 | + for (int r = 0, i = h->short_ref_count; r < H264_MAX_DPB_FRAMES && | |
| 410 | + i < h->short_ref_count + h->long_ref_count; r++) { | |
| 411 | + if (!h->long_ref[r]) | |
| 412 | + continue; | |
| 413 | + | |
| 410 | 414 | dpb_slot_index = 0; |
| 411 | − for (unsigned slot = 0; slot < H264_MAX_PICTURE_COUNT; slot++) { | |
| 412 | − if (h->long_ref[i] == &h->DPB[slot]) { | |
| 415 | + for (unsigned slot = 0; slot < 16; slot++) { | |
| 416 | + if (h->long_ref[r] == &h->DPB[slot]) { | |
| 413 | 417 | dpb_slot_index = slot; |
| 414 | 418 | break; |
| 415 | 419 | } |
| @@ -422,6 +426,7 @@ static int vk_h264_start_frame(AVCodecContext *avctx, · 6 unmodified lines | ||
| 422 | 426 | dpb_slot_index); |
| 423 | 427 | if (err < 0) |
| 424 | 428 | return err; |
| 429 | + i++; | |
| 425 | 430 | } |
| 426 | 431 | |
| 427 | 432 | hp->h264pic = (StdVideoDecodeH264PictureInfo) { |