[vlc-devel] [PATCH 1/2] vdpau: do not rely on avctx->refs for VP9
Steve Lhomme
robux4 at ycbcr.xyz
Tue Oct 22 09:39:16 CEST 2019
It gives one when it should be 8. Other codecs seem to be OK.
---
modules/hw/vdpau/avcodec.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 24c79d10201..537f8f86d7c 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -171,7 +171,21 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *d
return VLC_EGENERIC;
}
- unsigned refs = avctx->refs + 2 * avctx->thread_count + 5;
+ unsigned codec_refs;
+ switch (avctx->codec_id)
+ {
+ case AV_CODEC_ID_HEVC:
+ case AV_CODEC_ID_H264:
+ codec_refs = avctx->refs; // we can rely on this
+ break;
+ case AV_CODEC_ID_VP9:
+ codec_refs = 8;
+ break;
+ default:
+ codec_refs = 2;
+ break;
+ }
+ const unsigned refs = codec_refs + 2 * avctx->thread_count + 5;
vlc_va_sys_t *sys = malloc(sizeof (*sys)
+ (refs + 1) * sizeof (sys->pool[0]));
if (unlikely(sys == NULL))
@@ -206,7 +220,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *d
}
sys->pool[i] = NULL;
- if (i < avctx->refs + 3u)
+ if (i < codec_refs + 3u)
{
msg_Err(va, "not enough video RAM");
while (i > 0)
--
2.17.1
More information about the vlc-devel
mailing list