[vlc-commits] va_surface: fix reusing a pool already setup

Steve Lhomme git at videolan.org
Fri Oct 18 16:47:40 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 18 16:30:57 2019 +0200| [f6da761f7c954d8b8753a69e16d0b388c38bb320] | committer: Steve Lhomme

va_surface: fix reusing a pool already setup

+ simplify the va_pool_SetupDecoder() code

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

 modules/codec/avcodec/va_surface.c | 41 +++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index 411d85fa96..9ace60fcc8 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -85,48 +85,39 @@ static void ReleasePoolSurfaces(va_pool_t *va_pool)
 int va_pool_SetupDecoder(vlc_va_t *va, va_pool_t *va_pool, const AVCodecContext *avctx,
                          const video_format_t *fmt, unsigned count)
 {
-    int err = VLC_ENOMEM;
-
     if ( va_pool->surface_count >= count &&
          va_pool->surface_width  == fmt->i_width &&
          va_pool->surface_height == fmt->i_height )
     {
         msg_Dbg(va, "reusing surface pool");
-        err = VLC_SUCCESS;
         goto done;
     }
 
-    /* */
-    ReleasePoolSurfaces(va_pool);
-
     /* */
     msg_Dbg(va, "va_pool_SetupDecoder id %d %dx%d count: %d", avctx->codec_id, avctx->coded_width, avctx->coded_height, count);
 
     if (count > MAX_SURFACE_COUNT)
         return VLC_EGENERIC;
 
-    err = va_pool->callbacks.pf_create_decoder_surfaces(va, avctx->codec_id, fmt, count);
-    if (err == VLC_SUCCESS)
-    {
-        va_pool->surface_width  = fmt->i_width;
-        va_pool->surface_height = fmt->i_height;
-        va_pool->surface_count = count;
-    }
+    int err = va_pool->callbacks.pf_create_decoder_surfaces(va, avctx->codec_id, fmt, count);
+    if (err != VLC_SUCCESS)
+        return err;
 
-done:
-    if (err == VLC_SUCCESS)
-    {
-        for (unsigned i = 0; i < va_pool->surface_count; i++) {
-            vlc_va_surface_t *surface = &va_pool->surface[i];
-            atomic_init(&surface->refcount, 1);
-            va_pool_AddRef(va_pool);
-            surface->index = i;
-            surface->va_pool = va_pool;
-        }
-        va_pool->callbacks.pf_setup_avcodec_ctx(va_pool->callbacks.opaque);
+    va_pool->surface_width  = fmt->i_width;
+    va_pool->surface_height = fmt->i_height;
+    va_pool->surface_count = count;
+
+    for (unsigned i = 0; i < va_pool->surface_count; i++) {
+        vlc_va_surface_t *surface = &va_pool->surface[i];
+        atomic_init(&surface->refcount, 1);
+        va_pool_AddRef(va_pool);
+        surface->index = i;
+        surface->va_pool = va_pool;
     }
+done:
+    va_pool->callbacks.pf_setup_avcodec_ctx(va_pool->callbacks.opaque);
 
-    return err;
+    return VLC_SUCCESS;
 }
 
 static vlc_va_surface_t *GetSurface(va_pool_t *va_pool)



More information about the vlc-commits mailing list