vulkan/hevc: handle missing active PPS

I don't pretend to understand how we get into this situation, but there
are files out there where we can end up with the active PPS not being
identified when we call vk_hevc_end_frame. In these situations today,
we will segfault. So, before we give up, see if we can get the active
PPS id from the slice header, and use that if possible.

If that still doesn't work, return an error instead of segfaulting.
This commit is contained in:
Philip Langdale 2023-07-10 16:35:17 +08:00
parent 3b358f151d
commit 1c61c24f5f
1 changed files with 14 additions and 1 deletions

View File

@ -900,6 +900,7 @@ static int vk_hevc_end_frame(AVCodecContext *avctx)
FFVulkanDecodePicture *vp = &hp->vp; FFVulkanDecodePicture *vp = &hp->vp;
FFVulkanDecodePicture *rvp[HEVC_MAX_REFS] = { 0 }; FFVulkanDecodePicture *rvp[HEVC_MAX_REFS] = { 0 };
AVFrame *rav[HEVC_MAX_REFS] = { 0 }; AVFrame *rav[HEVC_MAX_REFS] = { 0 };
int err;
if (!hp->h265_pic_info.sliceSegmentCount) if (!hp->h265_pic_info.sliceSegmentCount)
return 0; return 0;
@ -908,7 +909,19 @@ static int vk_hevc_end_frame(AVCodecContext *avctx)
const HEVCSPS *sps = h->ps.sps; const HEVCSPS *sps = h->ps.sps;
const HEVCPPS *pps = h->ps.pps; const HEVCPPS *pps = h->ps.pps;
int err = vk_hevc_create_params(avctx, &dec->session_params); if (!pps) {
unsigned int pps_id = h->sh.pps_id;
if (pps_id < HEVC_MAX_PPS_COUNT && h->ps.pps_list[pps_id] != NULL)
pps = (const HEVCPPS *)h->ps.pps_list[pps_id]->data;
}
if (!pps) {
av_log(avctx, AV_LOG_ERROR,
"Encountered frame without a valid active PPS reference.\n");
return AVERROR_INVALIDDATA;
}
err = vk_hevc_create_params(avctx, &dec->session_params);
if (err < 0) if (err < 0)
return err; return err;