[vlc-devel] [PATCH 5/8] va_surface: remove wait mechanism

Steve Lhomme robux4 at ycbcr.xyz
Tue Jul 28 11:08:38 CEST 2020


Now that each surface in the pool has a corresponding picture pool in the
decoder owner, we don't need to wait for an available surface. If a picture was
available from the pool, a surface is available as well.
---
 modules/codec/avcodec/va_surface.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index bbf3f6b06cb..41468797c51 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -56,7 +56,6 @@ struct va_pool_t
     struct va_pool_cfg callbacks;
 
     atomic_uintptr_t  poolrefs; // 1 ref for the pool creator, 1 ref per surface alive
-    vlc_sem_t    available_surfaces;
 };
 
 static void va_pool_AddRef(va_pool_t *va_pool)
@@ -103,8 +102,6 @@ int va_pool_SetupDecoder(vlc_va_t *va, va_pool_t *va_pool, AVCodecContext *avctx
     va_pool->surface_height = fmt->i_height;
     va_pool->surface_count = count;
 
-    vlc_sem_init(&va_pool->available_surfaces, count);
-
     for (size_t i = 0; i < va_pool->surface_count; i++) {
         vlc_va_surface_t *surface = &va_pool->surface[i];
         atomic_init(&surface->refcount, 1);
@@ -139,10 +136,9 @@ vlc_va_surface_t *va_pool_Get(va_pool_t *va_pool)
 {
     vlc_va_surface_t *surface;
 
-    if (va_pool->surface_count == 0)
+    if (unlikely(va_pool->surface_count == 0))
         return NULL;
 
-    vlc_sem_wait(&va_pool->available_surfaces);
     surface = GetSurface(va_pool);
     assert(surface != NULL);
     return surface;
@@ -156,12 +152,7 @@ void va_surface_AddRef(vlc_va_surface_t *surface)
 void va_surface_Release(vlc_va_surface_t *surface)
 {
     uintptr_t had_refcount = atomic_fetch_sub(&surface->refcount, 1);
-    if (had_refcount == 2)
-    {
-        // the surface is not used anymore
-        vlc_sem_post(&surface->va_pool->available_surfaces);
-    }
-    else if (had_refcount == 1)
+    if (had_refcount == 1)
     {
         // the surface has been released
         va_pool_Release(surface->va_pool);
-- 
2.26.2



More information about the vlc-devel mailing list