aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2023-07-10 16:35:17 +0800
committerPhilip Langdale <philipl@overt.org>2023-07-10 16:49:32 +0800
commit1c61c24f5f681c573afce2fba804962e88ca262a (patch)
tree200d89fd3e44beb066f6bf7f4fdc0dfe17c0ef7a
parent3b358f151ddc7543f1c0fc0cff82b6fe4ddf9cbf (diff)
downloadffmpeg-1c61c24f5f681c573afce2fba804962e88ca262a.tar.gz
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.
-rw-r--r--libavcodec/vulkan_hevc.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index af5da3984b..ab0f6b96d0 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -900,6 +900,7 @@ static int vk_hevc_end_frame(AVCodecContext *avctx)
FFVulkanDecodePicture *vp = &hp->vp;
FFVulkanDecodePicture *rvp[HEVC_MAX_REFS] = { 0 };
AVFrame *rav[HEVC_MAX_REFS] = { 0 };
+ int err;
if (!hp->h265_pic_info.sliceSegmentCount)
return 0;
@@ -908,7 +909,19 @@ static int vk_hevc_end_frame(AVCodecContext *avctx)
const HEVCSPS *sps = h->ps.sps;
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)
return err;