[vlc-devel] [PATCH 2/3] va_surface: add a mode where the surfaces are not preallocated on setup

Steve Lhomme robux4 at videolabs.io
Fri Jun 23 17:35:00 CEST 2017


This allows using all the setup/release phases without actually allocating
the surfaces that may come directly from the vout.
---
 modules/codec/avcodec/va_surface.c          | 4 +++-
 modules/codec/avcodec/va_surface_internal.h | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index 9110d96e57..eda240c8d2 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -98,7 +98,7 @@ int va_pool_Setup(vlc_va_t *va, va_pool_t *va_pool, const AVCodecContext *avctx,
     if (va_pool->pf_create_decoder_surfaces(va, avctx->codec_id, &fmt, count))
         return VLC_EGENERIC;
 
-    for (i = 0; i < count; i++) {
+    for (i = 0; i < count && !va_pool->b_extern_pool; i++) {
         struct vlc_va_surface_t *p_surface = malloc(sizeof(*p_surface));
         if (unlikely(p_surface==NULL))
             goto done;
@@ -146,6 +146,8 @@ int va_pool_Get(va_pool_t *va_pool, picture_t *pic)
     unsigned tries = (CLOCK_FREQ + VOUT_OUTMEM_SLEEP) / VOUT_OUTMEM_SLEEP;
     picture_context_t *field;
 
+    assert(!va_pool->b_extern_pool);
+
     while ((field = GetSurface(va_pool)) == NULL)
     {
         if (--tries == 0)
diff --git a/modules/codec/avcodec/va_surface_internal.h b/modules/codec/avcodec/va_surface_internal.h
index ee83dcc322..7ccc38784c 100644
--- a/modules/codec/avcodec/va_surface_internal.h
+++ b/modules/codec/avcodec/va_surface_internal.h
@@ -45,6 +45,10 @@ typedef struct
     int          surface_width;
     int          surface_height;
 
+    /** do not preallocate surfaces
+     * should be set once pf_create_decoder_surfaces() has been called */
+    bool         b_extern_pool;
+
     struct va_pic_context  *surface[MAX_SURFACE_COUNT];
 
     int (*pf_create_device)(vlc_va_t *);
-- 
2.12.1



More information about the vlc-devel mailing list