[vlc-commits] avcodec: vdpau: split the Lock call to get a surface to decode to

Steve Lhomme git at videolan.org
Thu Jun 20 10:03:26 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jun 19 09:27:54 2019 +0200| [e1945a7676459ead34b3800192f8b8119e8c0054] | committer: Steve Lhomme

avcodec: vdpau: split the Lock call to get a surface to decode to

This looks like a good candidate to use the codec/avcodec/va_surface API.

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

 modules/hw/vdpau/avcodec.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 604d548e1e..3576b003ca 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -89,7 +89,7 @@ static vlc_vdp_video_field_t *GetSurface(vlc_va_t *va)
     return NULL;
 }
 
-static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
+static vlc_vdp_video_field_t *Get(vlc_va_t *va)
 {
     vlc_vdp_video_field_t *field;
     unsigned tries = (VLC_TICK_FROM_SEC(1) + VOUT_OUTMEM_SLEEP) / VOUT_OUTMEM_SLEEP;
@@ -97,12 +97,21 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
     while ((field = GetSurface(va)) == NULL)
     {
         if (--tries == 0)
-            return VLC_ENOMEM;
+            return NULL;
         /* Pool empty. Wait for some time as in src/input/decoder.c.
          * XXX: Both this and the core should use a semaphore or a CV. */
         vlc_tick_sleep(VOUT_OUTMEM_SLEEP);
     }
 
+    return field;
+}
+
+static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
+{
+    vlc_vdp_video_field_t *field = Get(va);
+    if (field == NULL)
+        return VLC_ENOMEM;
+
     pic->context = &field->context;
     *data = (void *)(uintptr_t)field->frame->surface;
     return VLC_SUCCESS;



More information about the vlc-commits mailing list