[vlc-commits] picture_pool: handle non-pool pictures

Rémi Denis-Courmont git at videolan.org
Thu Dec 27 18:30:56 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Dec 27 14:04:53 2018 +0200| [114500c1b536061f7f178bfa131b01ff0d92a821] | committer: Rémi Denis-Courmont

picture_pool: handle non-pool pictures

This works around picture_pool_OwnsPic() crashing on non-pooled
pictures. The brittle kludge works for the time being because only
pooling and cloning use non-NULL picture_priv_T.gc.opaque.

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

 include/vlc_video_splitter.h | 22 +++++++++++++---------
 src/misc/picture_pool.c      |  3 +++
 src/video_output/display.c   | 23 -----------------------
 3 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/include/vlc_video_splitter.h b/include/vlc_video_splitter.h
index 9118cfb903..c03034335f 100644
--- a/include/vlc_video_splitter.h
+++ b/include/vlc_video_splitter.h
@@ -97,9 +97,6 @@ struct video_splitter_t
                                   const vlc_mouse_t *p_old, const vlc_mouse_t *p_new );
 
     void *p_sys;
-
-    /* Buffer allocation */
-    int  (*pf_picture_new) ( video_splitter_t *, picture_t *pp_picture[] );
     void *p_owner;
 };
 
@@ -111,13 +108,20 @@ struct video_splitter_t
  *
  * If VLC_SUCCESS is not returned, pp_picture values are undefined.
  */
-static inline int video_splitter_NewPicture( video_splitter_t *p_splitter,
-                                             picture_t *pp_picture[] )
+static inline int video_splitter_NewPicture(video_splitter_t *splitter,
+                                            picture_t *pics[])
 {
-    int i_ret = p_splitter->pf_picture_new( p_splitter, pp_picture );
-    if( i_ret )
-        msg_Warn( p_splitter, "can't get output pictures" );
-    return i_ret;
+    for (int i = 0; i < splitter->i_output; i++) {
+        pics[i] = picture_NewFromFormat(&splitter->p_output[i].fmt);
+        if (pics[i] == NULL) {
+            for (int j = 0; j < i; j++)
+                picture_Release(pics[j]);
+
+            msg_Warn(splitter, "can't get output pictures");
+            return VLC_EGENERIC;
+        }
+    }
+    return VLC_SUCCESS;
 }
 
 /**
diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index 948c67bba5..e0fbdd7333 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -292,6 +292,9 @@ bool picture_pool_OwnsPic(picture_pool_t *pool, picture_t *pic)
     picture_priv_t *priv = (picture_priv_t *)pic;
 
     while (priv->gc.destroy != picture_pool_ReleasePicture) {
+        if (priv->gc.opaque == NULL)
+            return false; /* not a pooled picture */
+
         pic = priv->gc.opaque;
         priv = (picture_priv_t *)pic;
     }
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 5f6f07a31a..b9a65267fb 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -1120,28 +1120,6 @@ static int SplitterControl(vout_display_t *vd, int query, va_list args)
     return VLC_EGENERIC;
 }
 
-static int SplitterPictureNew(video_splitter_t *splitter, picture_t *picture[])
-{
-    vout_display_t *wrapper = splitter->p_owner;
-    vout_display_sys_t *wsys = wrapper->sys;
-
-    for (int i = 0; i < wsys->count; i++) {
-        if (vout_IsDisplayFiltered(wsys->display[i])) {
-            /* TODO use a pool ? */
-            picture[i] = picture_NewFromFormat(&wsys->display[i]->source);
-        } else {
-            picture_pool_t *pool = vout_GetPool(wsys->display[i], 3);
-            picture[i] = pool ? picture_pool_Get(pool) : NULL;
-        }
-        if (!picture[i]) {
-            for (int j = 0; j < i; j++)
-                picture_Release(picture[j]);
-            return VLC_EGENERIC;
-        }
-    }
-    return VLC_SUCCESS;
-}
-
 static void SplitterClose(vout_display_t *vd)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -1197,7 +1175,6 @@ vout_display_t *vout_NewSplitter(vout_thread_t *vout,
 
     /* */
     splitter->p_owner = wrapper;
-    splitter->pf_picture_new = SplitterPictureNew;
 
     /* */
     TAB_INIT(sys->count, sys->display);



More information about the vlc-commits mailing list