[vlc-commits] avcodec: vdpau: do not rely on avctx->refs for VP9

Steve Lhomme git at videolan.org
Mon Nov 4 12:15:05 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Oct 21 16:32:54 2019 +0200| [7905bf1eba6b38d8456f414478cfe6809a07614f] | committer: Steve Lhomme

avcodec: vdpau: do not rely on avctx->refs for VP9

It gives 1 when it should be 8. Other codecs seem to be OK.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7905bf1eba6b38d8456f414478cfe6809a07614f
---

 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 a4f1cf96d3..50527e435a 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -193,7 +193,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));
     if (unlikely(sys == NULL))
        return VLC_ENOMEM;
@@ -239,7 +253,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *d
     }
     vctx_priv->pool[i] = NULL;
 
-    if (i < avctx->refs + 3u)
+    if (i < codec_refs + 3u)
     {
         msg_Err(va, "not enough video RAM");
         while (i > 0)



More information about the vlc-commits mailing list