[vlc-devel] [PATCH 4/5] picture_pool: remove picture_pool_NewExtended()

Steve Lhomme robux4 at ycbcr.xyz
Mon Feb 25 15:49:06 CET 2019


We should not need to lock pictures when reading/writing from a pool.
---
 include/vlc_picture_pool.h | 32 --------------------------------
 src/libvlccore.sym         |  1 -
 src/misc/picture_pool.c    | 27 +++++++--------------------
 3 files changed, 7 insertions(+), 53 deletions(-)

diff --git a/include/vlc_picture_pool.h b/include/vlc_picture_pool.h
index de385d6a98..359c0abf0d 100644
--- a/include/vlc_picture_pool.h
+++ b/include/vlc_picture_pool.h
@@ -35,38 +35,6 @@
  */
 typedef struct picture_pool_t picture_pool_t;
 
-/**
- * Picture pool configuration
- */
-typedef struct {
-    unsigned  picture_count;
-    picture_t *const *picture;
-
-    int       (*lock)(picture_t *);
-    void      (*unlock)(picture_t *);
-} picture_pool_configuration_t;
-
-/**
- * Creates a pool of preallocated pictures. Free pictures can be allocated from
- * the pool, and are returned to the pool when they are no longer referenced.
- *
- * This avoids allocating and deallocationg pictures repeatedly, and ensures
- * that memory consumption remains within limits.
- *
- * To obtain a picture from the pool, use picture_pool_Get(). To increase and
- * decrease the reference count, use picture_Hold() and picture_Release()
- * respectively.
- *
- * If defined, picture_pool_configuration_t::lock will be called before
- * a picture is used, and picture_pool_configuration_t::unlock will be called
- * as soon as a picture is returned to the pool.
- * Those callbacks can modify picture_t::p and access picture_t::p_sys.
- *
- * @return A pointer to the new pool on success, or NULL on error
- * (pictures are <b>not</b> released on error).
- */
-VLC_API picture_pool_t * picture_pool_NewExtended( const picture_pool_configuration_t * ) VLC_USED;
-
 /**
  * Creates a picture pool with pictures in a given array.
  * This is a convenience wrapper for picture_pool_NewExtended() without the
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a861c988e5..b32864e8cb 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -325,7 +325,6 @@ picture_pool_Release
 picture_pool_Get
 picture_pool_GetSize
 picture_pool_New
-picture_pool_NewExtended
 picture_pool_NewFromFormat
 picture_pool_Reserve
 picture_pool_Wait
diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index 7015f07fa0..d6717d2490 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -114,45 +114,32 @@ static picture_t *picture_pool_ClonePicture(picture_pool_t *pool,
     return clone;
 }
 
-picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg)
+picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
 {
-    if (unlikely(cfg->picture_count > POOL_MAX))
+    if (unlikely(count > POOL_MAX))
         return NULL;
 
     picture_pool_t *pool;
-    size_t size = sizeof (*pool) + cfg->picture_count * sizeof (picture_t *);
+    size_t size = sizeof (*pool) + count * sizeof (picture_t *);
 
     size += (-size) & (POOL_MAX - 1);
     pool = aligned_alloc(POOL_MAX, size);
     if (unlikely(pool == NULL))
         return NULL;
 
-    pool->pic_lock   = cfg->lock;
-    pool->pic_unlock = cfg->unlock;
     vlc_mutex_init(&pool->lock);
     vlc_cond_init(&pool->wait);
-    if (cfg->picture_count == POOL_MAX)
+    if (count == POOL_MAX)
         pool->available = ~0ULL;
     else
-        pool->available = (1ULL << cfg->picture_count) - 1;
+        pool->available = (1ULL << count) - 1;
     atomic_init(&pool->refs,  1);
-    pool->picture_count = cfg->picture_count;
-    memcpy(pool->picture, cfg->picture,
-           cfg->picture_count * sizeof (picture_t *));
+    pool->picture_count = count;
+    memcpy(pool->picture, tab, count * sizeof (picture_t *));
     pool->canceled = false;
     return pool;
 }
 
-picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
-{
-    picture_pool_configuration_t cfg = {
-        .picture_count = count,
-        .picture = tab,
-    };
-
-    return picture_pool_NewExtended(&cfg);
-}
-
 picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt,
                                            unsigned count)
 {
-- 
2.17.1



More information about the vlc-devel mailing list