[vlc-commits] picture_pool: fix prototypes

Rémi Denis-Courmont git at videolan.org
Sat Nov 1 10:31:47 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov  1 10:59:44 2014 +0200| [fb2ff2574e39e7d61903ad386a0511190317e19c] | committer: Rémi Denis-Courmont

picture_pool: fix prototypes

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

 include/vlc_picture_pool.h |   13 ++++++++-----
 src/misc/picture_pool.c    |   37 +++++++++++++++++++------------------
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/include/vlc_picture_pool.h b/include/vlc_picture_pool.h
index 8073d54..4b520e1 100644
--- a/include/vlc_picture_pool.h
+++ b/include/vlc_picture_pool.h
@@ -43,8 +43,8 @@ typedef struct picture_pool_t picture_pool_t;
  * Picture pool configuration
  */
 typedef struct {
-    int       picture_count;
-    picture_t **picture;
+    unsigned  picture_count;
+    picture_t *const *picture;
 
     int       (*lock)(picture_t *);
     void      (*unlock)(picture_t *);
@@ -69,14 +69,16 @@ VLC_API picture_pool_t * picture_pool_NewExtended( const picture_pool_configurat
  *
  * It is provided as convenience.
  */
-VLC_API picture_pool_t * picture_pool_New( int picture_count, picture_t *picture[] ) VLC_USED;
+VLC_API picture_pool_t * picture_pool_New(unsigned count,
+                                          picture_t *const *tab) VLC_USED;
 
 /**
  * It creates a picture_pool_t creating images using the given format.
  *
  * Provided for convenience.
  */
-VLC_API picture_pool_t * picture_pool_NewFromFormat( const video_format_t *, int picture_count ) VLC_USED;
+VLC_API picture_pool_t * picture_pool_NewFromFormat(const video_format_t *,
+                                                    unsigned count) VLC_USED;
 
 /**
  * It destroys a pool created by picture_pool_New.
@@ -121,7 +123,8 @@ void picture_pool_NonEmpty( picture_pool_t * );
  * The returned pool must be deleted before the master pool.
  * When deleted, all pictures return to the master pool.
  */
-VLC_API picture_pool_t * picture_pool_Reserve(picture_pool_t *, int picture_count) VLC_USED;
+VLC_API picture_pool_t * picture_pool_Reserve(picture_pool_t *, unsigned count)
+VLC_USED;
 
 /**
  * It returns the size of the given pool.
diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index 5d54301..14d8f09 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -52,7 +52,7 @@ struct picture_pool_t {
     picture_pool_t *master;
     int64_t        tick;
     /* */
-    int            picture_count;
+    unsigned       picture_count;
     picture_t      **picture;
     bool           *picture_reserved;
 
@@ -147,7 +147,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
      *    when it gets pooled.
      *  - Picture plane pointers and sizes must not be mangled in any case.
      */
-    for (int i = 0; i < cfg->picture_count; i++) {
+    for (unsigned i = 0; i < cfg->picture_count; i++) {
         picture_t *picture = cfg->picture[i];
 
         /* Save the original garbage collector */
@@ -175,34 +175,35 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
 
 }
 
-picture_pool_t *picture_pool_New(int picture_count, picture_t *picture[])
+picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
 {
     picture_pool_configuration_t cfg;
 
     memset(&cfg, 0, sizeof(cfg));
-    cfg.picture_count = picture_count;
-    cfg.picture       = picture;
+    cfg.picture_count = count;
+    cfg.picture       = tab;
 
     return picture_pool_NewExtended(&cfg);
 }
 
-picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt, int picture_count)
+picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt,
+                                           unsigned count)
 {
-    picture_t *picture[picture_count];
+    picture_t *picture[count];
 
-    for (int i = 0; i < picture_count; i++) {
+    for (unsigned i = 0; i < count; i++) {
         picture[i] = picture_NewFromFormat(fmt);
         if (!picture[i])
             goto error;
     }
-    picture_pool_t *pool = picture_pool_New(picture_count, picture);
+    picture_pool_t *pool = picture_pool_New(count, picture);
     if (!pool)
         goto error;
 
     return pool;
 
 error:
-    for (int i = 0; i < picture_count; i++) {
+    for (unsigned i = 0; i < count; i++) {
         if (!picture[i])
             break;
         picture_Release(picture[i]);
@@ -210,7 +211,7 @@ error:
     return NULL;
 }
 
-picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count)
+picture_pool_t *picture_pool_Reserve(picture_pool_t *master, unsigned count)
 {
     picture_pool_t *pool = Create(master, count);
     if (!pool)
@@ -219,8 +220,8 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count)
     pool->pic_lock   = master->pic_lock;
     pool->pic_unlock = master->pic_unlock;
 
-    int found = 0;
-    for (int i = 0; i < master->picture_count && found < count; i++) {
+    unsigned found = 0;
+    for (unsigned i = 0; i < master->picture_count && found < count; i++) {
         if (master->picture_reserved[i])
             continue;
 
@@ -240,10 +241,10 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count)
 
 void picture_pool_Delete(picture_pool_t *pool)
 {
-    for (int i = 0; i < pool->picture_count; i++) {
+    for (unsigned i = 0; i < pool->picture_count; i++) {
         picture_t *picture = pool->picture[i];
         if (pool->master) {
-            for (int j = 0; j < pool->master->picture_count; j++) {
+            for (unsigned j = 0; j < pool->master->picture_count; j++) {
                 if (pool->master->picture[j] == picture)
                     pool->master->picture_reserved[j] = false;
             }
@@ -267,7 +268,7 @@ void picture_pool_Delete(picture_pool_t *pool)
 
 picture_t *picture_pool_Get(picture_pool_t *pool)
 {
-    for (int i = 0; i < pool->picture_count; i++) {
+    for (unsigned i = 0; i < pool->picture_count; i++) {
         if (pool->picture_reserved[i])
             continue;
 
@@ -292,7 +293,7 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
 
 void picture_pool_Reset(picture_pool_t *pool)
 {
-    for (int i = 0; i < pool->picture_count; i++) {
+    for (unsigned i = 0; i < pool->picture_count; i++) {
         if (pool->picture_reserved[i])
             continue;
 
@@ -309,7 +310,7 @@ void picture_pool_NonEmpty(picture_pool_t *pool)
 {
     picture_t *oldest = NULL;
 
-    for (int i = 0; i < pool->picture_count; i++) {
+    for (unsigned i = 0; i < pool->picture_count; i++) {
         if (pool->picture_reserved[i])
             continue;
 



More information about the vlc-commits mailing list