[vlc-devel] [PATCH 1/5] [RFC] core: allow use different pool sources for different types

Steve Lhomme robux4 at videolabs.io
Tue Mar 28 16:23:56 CEST 2017


In Direct3D11 textures are "strongly" types. A texture used from a decoder can
be used in a pixel shader but not as input to a VideoProcessor at the same time.

That means a native D3D11 deinterlacer is not possible until the pool used for
filters is provided a different type of texture than the one used by the
decoder.

This patches allows a vout to request different types for each pool we need
(decoder, display and filter).
---
 include/vlc_vout_display.h              | 13 ++++-
 include/vlc_vout_wrapper.h              |  4 +-
 modules/codec/omxil/vout.c              |  5 +-
 modules/hw/mmal/vout.c                  |  3 +-
 modules/hw/vdpau/display.c              |  3 +-
 modules/video_output/aa.c               |  5 +-
 modules/video_output/android/display.c  |  5 +-
 modules/video_output/caca.c             |  5 +-
 modules/video_output/caopengllayer.m    |  5 +-
 modules/video_output/decklink.cpp       |  4 +-
 modules/video_output/directfb.c         |  5 +-
 modules/video_output/evas.c             |  3 +-
 modules/video_output/fb.c               |  5 +-
 modules/video_output/flaschen.c         |  5 +-
 modules/video_output/kva.c              |  5 +-
 modules/video_output/macosx.m           |  5 +-
 modules/video_output/opengl/display.c   |  5 +-
 modules/video_output/sdl.c              |  5 +-
 modules/video_output/vdummy.c           |  6 ++-
 modules/video_output/vmem.c             |  5 +-
 modules/video_output/wayland/shm.c      |  3 +-
 modules/video_output/win32/direct3d11.c |  4 +-
 modules/video_output/win32/direct3d9.c  |  5 +-
 modules/video_output/win32/directdraw.c |  5 +-
 modules/video_output/win32/glwin32.c    |  5 +-
 modules/video_output/win32/wingdi.c     |  5 +-
 modules/video_output/xcb/x11.c          |  5 +-
 modules/video_output/xcb/xvideo.c       |  5 +-
 modules/video_output/yuv.c              |  6 ++-
 src/video_output/display.c              |  9 ++--
 src/video_output/vout_wrapper.c         | 88 +++++++++++++++++++++++----------
 31 files changed, 159 insertions(+), 82 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 46825bea8c..674fa546dc 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -132,6 +132,7 @@ typedef struct {
     bool has_pictures_invalid;              /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
     bool needs_event_thread VLC_DEPRECATED; /* Will events (key at least) be emitted using an independent thread */
     const vlc_fourcc_t *subpicture_chromas; /* List of supported chromas for subpicture rendering. */
+    bool typed_pools;                       /* will produce different pools for each vout_display_pool_t */
 } vout_display_info_t;
 
 /**
@@ -249,6 +250,16 @@ struct vout_display_owner_t {
     void           (*window_del)(vout_display_t *, vout_window_t *);
 };
 
+/**
+ * Type of the picture pool being used.
+ */
+typedef enum {
+    VOUT_POOL_DISPLAY, /**< pictures for the display, owned by the display module. */
+    VOUT_POOL_DECODER, /**< pictures for decoder, owned by the core. */
+    VOUT_POOL_FILTERS, /**< picture for filters, owned by the core. */
+    VOUT_POOL_COUNT,   /**< Number of picture pool types. */
+} vout_display_pool_t;
+
 struct vout_display_t {
     VLC_COMMON_MEMBERS
 
@@ -296,7 +307,7 @@ struct vout_display_t {
      * The vout display module keeps the ownership of the pool and can
      * destroy it only when closing or on invalid pictures control.
      */
-    picture_pool_t *(*pool)(vout_display_t *, unsigned count);
+    picture_pool_t *(*pool)(vout_display_t *, unsigned count, vout_display_pool_t type);
 
     /* Prepare a picture and an optional subpicture for display (optional).
      *
diff --git a/include/vlc_vout_wrapper.h b/include/vlc_vout_wrapper.h
index 7cf13b82fb..c496b503a1 100644
--- a/include/vlc_vout_wrapper.h
+++ b/include/vlc_vout_wrapper.h
@@ -31,9 +31,9 @@
 /**
  * It retreives a picture pool from the display
  */
-static inline picture_pool_t *vout_display_Pool(vout_display_t *vd, unsigned count)
+static inline picture_pool_t *vout_display_Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
-    return vd->pool(vd, count);
+    return vd->pool(vd, count, type);
 }
 
 /**
diff --git a/modules/codec/omxil/vout.c b/modules/codec/omxil/vout.c
index ffbe4f5b13..529c8aab78 100644
--- a/modules/codec/omxil/vout.c
+++ b/modules/codec/omxil/vout.c
@@ -55,7 +55,7 @@ vlc_module_end()
  * Local prototypes
  *****************************************************************************/
 
-static picture_pool_t   *Pool  (vout_display_t *, unsigned);
+static picture_pool_t   *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void             Display(vout_display_t *, picture_t *, subpicture_t *);
 static int              Control(vout_display_t *, int, va_list);
 
@@ -377,9 +377,10 @@ static void Close(vlc_object_t *p_this)
     DeinitOmxCore();
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     VLC_UNUSED(count);
+    VLC_UNUSED(type);
 
     return vd->sys->pool;
 }
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index 4043f73d31..672139acda 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -438,7 +438,7 @@ static int configure_display(vout_display_t *vd, const vout_display_cfg_t *cfg,
     return 0;
 }
 
-static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
     picture_resource_t picture_res;
@@ -446,6 +446,7 @@ static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count)
     video_format_t fmt = vd->fmt;
     MMAL_STATUS_T status;
     unsigned i;
+    VLC_UNUSED(type);
 
     if (sys->picture_pool) {
         if (sys->num_buffers < count)
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index a92ac742e5..34c166ea24 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -155,9 +155,10 @@ static void PoolFree(vout_display_t *vd, picture_pool_t *pool)
     picture_pool_Release(pool);
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    (void) type;
 
     if (sys->pool == NULL)
         sys->pool = PoolAlloc(vd, requested_count);
diff --git a/modules/video_output/aa.c b/modules/video_output/aa.c
index e4ff1391c3..c81de2ba1a 100644
--- a/modules/video_output/aa.c
+++ b/modules/video_output/aa.c
@@ -65,7 +65,7 @@ vlc_module_end()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static picture_pool_t *Pool   (vout_display_t *, unsigned);
+static picture_pool_t *Pool   (vout_display_t *, unsigned, vout_display_pool_t);
 static void            Prepare(vout_display_t *, picture_t *, subpicture_t *);
 static void            PictureDisplay(vout_display_t *, picture_t *, subpicture_t *);
 static int             Control(vout_display_t *, int, va_list);
@@ -162,10 +162,11 @@ static void Close(vlc_object_t *object)
 /**
  * Return a pool of direct buffers
  */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
     VLC_UNUSED(count);
+    VLC_UNUSED(type);
 
     if (!sys->pool) {
         picture_resource_t rsc;
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 8161f6e1c3..e232cfecae 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -82,7 +82,7 @@ static const vlc_fourcc_t subpicture_chromas[] =
     0
 };
 
-static picture_pool_t   *Pool  (vout_display_t *, unsigned);
+static picture_pool_t   *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void             Prepare(vout_display_t *, picture_t *, subpicture_t *);
 static void             Display(vout_display_t *, picture_t *, subpicture_t *);
 static int              Control(vout_display_t *, int, va_list);
@@ -1085,9 +1085,10 @@ static void SubpicturePrepare(vout_display_t *vd, subpicture_t *subpicture)
         picture_BlendSubpicture(sys->p_sub_pic, sys->p_spu_blend, subpicture);
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
 
     if (sys->pool == NULL)
         sys->pool = PoolAlloc(vd, requested_count);
diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c
index b9d0cf83f0..69d0e096a8 100644
--- a/modules/video_output/caca.c
+++ b/modules/video_output/caca.c
@@ -61,7 +61,7 @@ vlc_module_end()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Prepare(vout_display_t *, picture_t *, subpicture_t *);
 static void    PictureDisplay(vout_display_t *, picture_t *, subpicture_t *);
 static int            Control(vout_display_t *, int, va_list);
@@ -244,9 +244,10 @@ static void Close(vlc_object_t *object)
 /**
  * Return a pool of direct buffers
  */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
 
     if (!sys->pool)
         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
diff --git a/modules/video_output/caopengllayer.m b/modules/video_output/caopengllayer.m
index ed77118f99..bb84784ff3 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -65,7 +65,7 @@ vlc_module_begin()
     set_callbacks(Open, Close)
 vlc_module_end()
 
-static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count);
+static picture_pool_t *Pool (vout_display_t *vd, unsigned, vout_display_pool_t);
 static void PictureRender   (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
 static void PictureDisplay  (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
 static int Control          (vout_display_t *vd, int query, va_list ap);
@@ -319,9 +319,10 @@ static void Close (vlc_object_t *p_this)
     free(sys);
 }
 
-static picture_pool_t *Pool (vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool (vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
 
     if (!sys->pool && !OpenglLock(sys->gl)) {
         sys->pool = vout_display_opengl_GetPool(sys->vgl, count);
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 35cb1ada38..9ca6b6f288 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -764,9 +764,11 @@ error:
  * Video
  *****************************************************************************/
 
-static picture_pool_t *PoolVideo(vout_display_t *vd, unsigned requested_count)
+static picture_pool_t *PoolVideo(vout_display_t *vd, unsigned requested_count, vout_display_pool_t type)
 {
     struct decklink_sys_t *sys = (struct decklink_sys_t *) vd->sys;
+    (void) type;
+
     if (!sys->video.pool)
         sys->video.pool = picture_pool_NewFromFormat(&vd->fmt, requested_count);
     return sys->video.pool;
diff --git a/modules/video_output/directfb.c b/modules/video_output/directfb.c
index f5728f4368..6d2b5f41a2 100644
--- a/modules/video_output/directfb.c
+++ b/modules/video_output/directfb.c
@@ -56,7 +56,7 @@ vlc_module_end()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *);
 static int            Control(vout_display_t *, int, va_list);
 
@@ -196,9 +196,10 @@ static int Lock(picture_t *pic)
 }
 
 /* */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     VLC_UNUSED(count);
+    VLC_UNUSED(type);
     vout_display_sys_t *sys = vd->sys;
     IDirectFBSurface *primary = sys->primary;
 
diff --git a/modules/video_output/evas.c b/modules/video_output/evas.c
index 213fdf75b9..bcfc4a594d 100644
--- a/modules/video_output/evas.c
+++ b/modules/video_output/evas.c
@@ -709,8 +709,9 @@ error:
 }
 
 static picture_pool_t *
-Pool( vout_display_t *vd, unsigned i_requested_count )
+Pool( vout_display_t *vd, unsigned i_requested_count, vout_display_pool_t type )
 {
+    (void) type;
     vout_display_sys_t *sys = vd->sys;
 
     if( sys->p_pool == NULL )
diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c
index de2c35c77d..63ec6ffa78 100644
--- a/modules/video_output/fb.c
+++ b/modules/video_output/fb.c
@@ -97,7 +97,7 @@ vlc_module_end ()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *);
 static int            Control(vout_display_t *, int, va_list);
 
@@ -339,8 +339,9 @@ static void Close(vlc_object_t *object)
 }
 
 /* */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
+    (void) type;
     vout_display_sys_t *sys = vd->sys;
 
     if (!sys->pool) {
diff --git a/modules/video_output/flaschen.c b/modules/video_output/flaschen.c
index 5e2d3ed0b4..6385648006 100644
--- a/modules/video_output/flaschen.c
+++ b/modules/video_output/flaschen.c
@@ -80,7 +80,7 @@ struct vout_display_sys_t {
 
     picture_pool_t *pool;
 };
-static picture_pool_t *Pool(vout_display_t *, unsigned count);
+static picture_pool_t *Pool(vout_display_t *, unsigned, vout_display_pool_t);
 static void            Display(vout_display_t *, picture_t *, subpicture_t *);
 static int             Control(vout_display_t *, int, va_list);
 
@@ -165,9 +165,10 @@ static void Close(vlc_object_t *object)
     free(sys);
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
     if (!sys->pool)
         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
     return sys->pool;
diff --git a/modules/video_output/kva.c b/modules/video_output/kva.c
index eb9aed4a99..ed5305c35d 100644
--- a/modules/video_output/kva.c
+++ b/modules/video_output/kva.c
@@ -114,7 +114,7 @@ struct picture_sys_t
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static picture_pool_t *Pool   (vout_display_t *, unsigned);
+static picture_pool_t *Pool   (vout_display_t *, unsigned, vout_display_pool_t);
 static void            Display(vout_display_t *, picture_t *, subpicture_t * );
 static int             Control(vout_display_t *, int, va_list);
 static void            Manage (vout_display_t *);
@@ -369,10 +369,11 @@ static void Close ( vlc_object_t *object )
 /**
  * Return a pool of direct buffers
  */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
     VLC_UNUSED(count);
+    VLC_UNUSED(type);
 
     return sys->pool;
 }
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 03086fa6f4..4751d99e03 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -63,7 +63,7 @@ const CFStringRef kCGColorSpaceITUR_2020 = CFSTR("kCGColorSpaceITUR_2020");
 static int Open (vlc_object_t *);
 static void Close (vlc_object_t *);
 
-static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count);
+static picture_pool_t *Pool (vout_display_t *vd, unsigned, vout_display_pool_t);
 static void PictureRender (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
 static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
 static int Control (vout_display_t *vd, int query, va_list ap);
@@ -368,9 +368,10 @@ void Close (vlc_object_t *this)
  * vout display callbacks
  *****************************************************************************/
 
-static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
+static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
 
     if (!sys->pool)
     {
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index 281ed71f17..b6ef5761b0 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -78,7 +78,7 @@ struct vout_display_sys_t
 };
 
 /* Display callbacks */
-static picture_pool_t *Pool (vout_display_t *, unsigned);
+static picture_pool_t *Pool (vout_display_t *, unsigned, vout_display_pool_t);
 static void PictureRender (vout_display_t *, picture_t *, subpicture_t *);
 static void PictureDisplay (vout_display_t *, picture_t *, subpicture_t *);
 static int Control (vout_display_t *, int, va_list);
@@ -163,9 +163,10 @@ static void Close (vlc_object_t *obj)
 /**
  * Returns picture buffers
  */
-static picture_pool_t *Pool (vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool (vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
 
     if (!sys->pool)
     {
diff --git a/modules/video_output/sdl.c b/modules/video_output/sdl.c
index 1fe55d64f3..298ad51601 100644
--- a/modules/video_output/sdl.c
+++ b/modules/video_output/sdl.c
@@ -83,7 +83,7 @@ vlc_module_end()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           PictureDisplay(vout_display_t *, picture_t *, subpicture_t *);
 static int            Control(vout_display_t *, int, va_list);
 static void           Manage(vout_display_t *);
@@ -397,10 +397,11 @@ static void Close(vlc_object_t *object)
 /**
  * Return a pool of direct buffers
  */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
     VLC_UNUSED(count);
+    VLC_UNUSED(type);
 
     if (!sys->pool) {
         picture_resource_t rsc;
diff --git a/modules/video_output/vdummy.c b/modules/video_output/vdummy.c
index 925897fd8d..032ddd3c7a 100644
--- a/modules/video_output/vdummy.c
+++ b/modules/video_output/vdummy.c
@@ -68,7 +68,7 @@ vlc_module_end ()
 struct vout_display_sys_t {
     picture_pool_t *pool;
 };
-static picture_pool_t *Pool(vout_display_t *, unsigned count);
+static picture_pool_t *Pool(vout_display_t *, unsigned, vout_display_pool_t);
 static void            Display(vout_display_t *, picture_t *, subpicture_t *);
 static void            DisplayStat(vout_display_t *, picture_t *, subpicture_t *);
 static int             Control(vout_display_t *, int, va_list);
@@ -129,9 +129,11 @@ static void Close(vlc_object_t *object)
     free(sys);
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
+
     if (!sys->pool)
         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
     return sys->pool;
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index d0ff7160c1..57f4f17954 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -103,7 +103,7 @@ struct vout_display_sys_t {
 typedef unsigned (*vlc_format_cb)(void **, char *, unsigned *, unsigned *,
                                   unsigned *, unsigned *);
 
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Prepare(vout_display_t *, picture_t *, subpicture_t *);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *);
 static int            Control(vout_display_t *, int, va_list);
@@ -239,9 +239,10 @@ static void Close(vlc_object_t *object)
     free(sys);
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
 
     if (sys->pool == NULL)
         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
diff --git a/modules/video_output/wayland/shm.c b/modules/video_output/wayland/shm.c
index 8de51a3e34..fb202ce620 100644
--- a/modules/video_output/wayland/shm.c
+++ b/modules/video_output/wayland/shm.c
@@ -99,8 +99,9 @@ static void PictureDetach(void *data, picture_t *pic)
     (void) data;
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned req)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned req, vout_display_pool_t type)
 {
+    (void) type;
     vout_display_sys_t *sys = vd->sys;
 
     if (sys->pool != NULL)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 008ee9ba2e..0cac84e6ac 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -206,7 +206,7 @@ typedef struct {
 #define RECTWidth(r)   (int)((r).right - (r).left)
 #define RECTHeight(r)  (int)((r).bottom - (r).top)
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count);
+static picture_pool_t *Pool(vout_display_t *, unsigned, vout_display_pool_t);
 
 static void Prepare(vout_display_t *, picture_t *, subpicture_t *subpicture);
 static void Display(vout_display_t *, picture_t *, subpicture_t *subpicture);
@@ -732,7 +732,7 @@ error:
     return VLC_EGENERIC;
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
     ID3D11Texture2D  *textures[pool_size * D3D11_MAX_SHADER_VIEW];
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 16b0678adc..47d2072380 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -159,7 +159,7 @@ struct picture_sys_t
 
 static int  Open(vlc_object_t *);
 
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Prepare(vout_display_t *, picture_t *, subpicture_t *subpicture);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *subpicture);
 static int            Control(vout_display_t *, int, va_list);
@@ -345,8 +345,9 @@ static D3DCOLOR GetFormatBlack(D3DFORMAT format)
 }
 
 /* */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
+    VLC_UNUSED(type);
     if ( vd->sys->sys.pool != NULL )
         return vd->sys->sys.pool;
 
diff --git a/modules/video_output/win32/directdraw.c b/modules/video_output/win32/directdraw.c
index d3c59310e3..698b92f8d4 100644
--- a/modules/video_output/win32/directdraw.c
+++ b/modules/video_output/win32/directdraw.c
@@ -173,7 +173,7 @@ struct vout_display_sys_t
 DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56);
 DEFINE_GUID(IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27);
 
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *);
 static int            Control(vout_display_t *, int, va_list);
 static void           Manage (vout_display_t *);
@@ -290,9 +290,10 @@ static void Close(vlc_object_t *object)
     free(sys);
 }
 
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     VLC_UNUSED(count);
+    VLC_UNUSED(type);
     return vd->sys->sys.pool;
 }
 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index 4b94a286c3..353e28cd57 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -71,7 +71,7 @@ struct vout_display_sys_t
     HDC                   affinityHDC; // DC for the selected GPU
 };
 
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Prepare(vout_display_t *, picture_t *, subpicture_t *);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *);
 static void           Manage (vout_display_t *);
@@ -292,9 +292,10 @@ static void Close(vlc_object_t *object)
 }
 
 /* */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
 
     if (!sys->sys.pool)
         sys->sys.pool = vout_display_opengl_GetPool(sys->vgl, count);
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 4dc43a7ee2..e44b18c758 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -77,7 +77,7 @@ struct vout_display_sys_t
     };
 };
 
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *subpicture);
 static int            Control(vout_display_t *, int, va_list);
 static void           Manage (vout_display_t *);
@@ -138,9 +138,10 @@ static void Close(vlc_object_t *object)
 }
 
 /* */
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     VLC_UNUSED(count);
+    VLC_UNUSED(type);
     return vd->sys->sys.pool;
 }
 
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index 81501b74e9..2a2a66dad2 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -75,7 +75,7 @@ struct vout_display_sys_t
     picture_pool_t *pool; /* picture pool */
 };
 
-static picture_pool_t *Pool (vout_display_t *, unsigned);
+static picture_pool_t *Pool (vout_display_t *, unsigned, vout_display_pool_t);
 static void Display (vout_display_t *, picture_t *, subpicture_t *subpicture);
 static int Control (vout_display_t *, int, va_list);
 
@@ -333,10 +333,11 @@ static void Close (vlc_object_t *obj)
 /**
  * Return a direct buffer
  */
-static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
+static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
     (void)requested_count;
+    (void)type;
 
     if (sys->pool)
         return sys->pool;
diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/xcb/xvideo.c
index 14c245c0e9..ff3499201e 100644
--- a/modules/video_output/xcb/xvideo.c
+++ b/modules/video_output/xcb/xvideo.c
@@ -97,7 +97,7 @@ struct vout_display_sys_t
     picture_pool_t *pool; /* picture pool */
 };
 
-static picture_pool_t *Pool (vout_display_t *, unsigned);
+static picture_pool_t *Pool (vout_display_t *, unsigned, vout_display_pool_t);
 static void Display (vout_display_t *, picture_t *, subpicture_t *subpicture);
 static int Control (vout_display_t *, int, va_list);
 
@@ -654,8 +654,9 @@ static void PoolAlloc (vout_display_t *vd, unsigned requested_count)
 /**
  * Return a direct buffer
  */
-static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
+static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count, vout_display_pool_t type)
 {
+    (void) type;
     vout_display_sys_t *p_sys = vd->sys;
 
     if (!p_sys->pool)
diff --git a/modules/video_output/yuv.c b/modules/video_output/yuv.c
index 1fcc9e9f05..a7f383f0d5 100644
--- a/modules/video_output/yuv.c
+++ b/modules/video_output/yuv.c
@@ -76,7 +76,7 @@ vlc_module_end()
  *****************************************************************************/
 
 /* */
-static picture_pool_t *Pool  (vout_display_t *, unsigned);
+static picture_pool_t *Pool  (vout_display_t *, unsigned, vout_display_pool_t);
 static void           Display(vout_display_t *, picture_t *, subpicture_t *subpicture);
 static int            Control(vout_display_t *, int, va_list);
 
@@ -185,9 +185,11 @@ static void Close(vlc_object_t *object)
 /*****************************************************************************
  *
  *****************************************************************************/
-static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(type);
+
     if (!sys->pool)
         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
     return sys->pool;
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 098e1e8a86..8d086561aa 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -60,7 +60,7 @@ static picture_t *VideoBufferNew(filter_t *filter)
            vd->fmt.i_width  == fmt->i_width  &&
            vd->fmt.i_height == fmt->i_height);
 
-    picture_pool_t *pool = vout_display_Pool(vd, 3);
+    picture_pool_t *pool = vout_display_Pool(vd, 3, VOUT_POOL_FILTERS);
     if (!pool)
         return NULL;
     return picture_pool_Get(pool);
@@ -96,6 +96,7 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
     vd->info.has_pictures_invalid = false;
     vd->info.needs_event_thread = false;
     vd->info.subpicture_chromas = NULL;
+    vd->info.typed_pools = false;
 
     vd->cfg = cfg;
     vd->pool = NULL;
@@ -1440,9 +1441,11 @@ static void SplitterEvent(vout_display_t *vd, int event, va_list args)
     }
 }
 
-static picture_pool_t *SplitterPool(vout_display_t *vd, unsigned count)
+static picture_pool_t *SplitterPool(vout_display_t *vd, unsigned count, vout_display_pool_t type)
 {
     vout_display_sys_t *sys = vd->sys;
+    (void) type;
+
     if (!sys->pool)
         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
     return sys->pool;
@@ -1504,7 +1507,7 @@ static int SplitterPictureNew(video_splitter_t *splitter, picture_t *picture[])
             /* TODO use a pool ? */
             picture[i] = picture_NewFromFormat(&wsys->display[i]->source);
         } else {
-            picture_pool_t *pool = vout_display_Pool(wsys->display[i], 1);
+            picture_pool_t *pool = vout_display_Pool(wsys->display[i], 1, VOUT_POOL_DISPLAY);
             picture[i] = pool ? picture_pool_Get(pool) : NULL;
         }
         if (!picture[i]) {
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index 310f50cdc6..0c6a869faa 100644
--- a/src/video_output/vout_wrapper.c
+++ b/src/video_output/vout_wrapper.c
@@ -111,7 +111,7 @@ static void NoDrInit(vout_thread_t *vout)
     vout_thread_sys_t *sys = vout->p;
 
     if (sys->display.use_dr)
-        sys->display_pool = vout_display_Pool(sys->display.vd, 3);
+        sys->display_pool = vout_display_Pool(sys->display.vd, 3, VOUT_POOL_DISPLAY);
     else
         sys->display_pool = NULL;
 }
@@ -130,28 +130,61 @@ int vout_InitWrapper(vout_thread_t *vout)
     const unsigned reserved_picture = DISPLAY_PICTURE_COUNT +
                                       private_picture +
                                       kept_picture;
-    const unsigned display_pool_size = allow_dr ? __MAX(VOUT_MAX_PICTURES,
-                                                        reserved_picture + decoder_picture) : 3;
-    picture_pool_t *display_pool = vout_display_Pool(vd, display_pool_size);
-    if (display_pool == NULL)
-        return VLC_EGENERIC;
+    const unsigned decoder_pool_size = __MAX( decoder_picture,
+                                              VOUT_MAX_PICTURES - reserved_picture );
 
-#ifndef NDEBUG
-    if ( picture_pool_GetSize(display_pool) < display_pool_size )
-        msg_Warn(vout, "Not enough display buffers in the pool, requested %d got %d",
-                 display_pool_size, picture_pool_GetSize(display_pool));
-#endif
+    if (!allow_dr) {
+        sys->display_pool = vout_display_Pool(vd, 3, VOUT_POOL_DISPLAY);
+        if (sys->display_pool == NULL)
+            return VLC_EGENERIC;
+    } else if (!vd->info.typed_pools) {
+        /* old style pool, all pool types are using the same pool */
+        picture_pool_t *display_pool;
+        display_pool = vout_display_Pool(vd,
+                                         decoder_pool_size + private_picture + DISPLAY_PICTURE_COUNT + kept_picture,
+                                         VOUT_POOL_DECODER);
+        if (!display_pool)
+            return VLC_EGENERIC;
+        if (picture_pool_GetSize(display_pool) < reserved_picture + decoder_picture) {
+            /* the pool is not big enough, fallback to internal decoder pool */
+            picture_pool_Release(display_pool);
+            display_pool = NULL;
+        } else {
+            sys->dpb_size = picture_pool_GetSize(display_pool) - reserved_picture;
+            sys->decoder_pool = display_pool;
+            sys->display_pool = display_pool;
+            sys->private_pool = picture_pool_Reserve(sys->decoder_pool, private_picture);
+            if (!sys->private_pool)
+            {
+                picture_pool_Release(sys->decoder_pool);
+                sys->display_pool = sys->decoder_pool = NULL;
+                return VLC_EGENERIC;
+            }
+        }
+    } else {
+        /* new style of typed pools */
+        sys->decoder_pool = vout_display_Pool(vd, decoder_pool_size, VOUT_POOL_DECODER);
+        if (!sys->decoder_pool)
+            return VLC_EGENERIC;
 
-    if (allow_dr &&
-        picture_pool_GetSize(display_pool) >= reserved_picture + decoder_picture) {
-        sys->dpb_size     = picture_pool_GetSize(display_pool) - reserved_picture;
-        sys->decoder_pool = display_pool;
-        sys->display_pool = display_pool;
-    } else if (!sys->decoder_pool) {
+        sys->private_pool = vout_display_Pool(vd, private_picture, VOUT_POOL_FILTERS);
+        if (sys->private_pool == NULL)
+        {
+            picture_pool_Release(sys->decoder_pool);
+            return VLC_EGENERIC;
+        }
+        sys->display_pool = vout_display_Pool(vd, DISPLAY_PICTURE_COUNT + kept_picture, VOUT_POOL_DISPLAY);
+        if (sys->display_pool == NULL)
+        {
+            picture_pool_Release(sys->decoder_pool);
+            picture_pool_Release(sys->private_pool);
+            return VLC_EGENERIC;
+        }
+    }
+    if (!sys->decoder_pool) {
         sys->decoder_pool =
             picture_pool_NewFromFormat(&source,
-                                       __MAX(VOUT_MAX_PICTURES,
-                                             reserved_picture + decoder_picture - DISPLAY_PICTURE_COUNT));
+                                       decoder_pool_size + private_picture);
         if (!sys->decoder_pool)
             return VLC_EGENERIC;
         if (allow_dr) {
@@ -161,15 +194,16 @@ int vout_InitWrapper(vout_thread_t *vout)
             sys->dpb_size = picture_pool_GetSize(sys->decoder_pool) - reserved_picture;
         }
         NoDrInit(vout);
+        sys->private_pool = picture_pool_Reserve(sys->decoder_pool, private_picture);
+        if (!sys->private_pool)
+        {
+            if (sys->decoder_pool != sys->display_pool)
+                picture_pool_Release(sys->decoder_pool);
+            sys->display_pool = sys->decoder_pool = NULL;
+            return VLC_EGENERIC;
+        }
     }
-    sys->private_pool = picture_pool_Reserve(sys->decoder_pool, private_picture);
-    if (!sys->private_pool)
-    {
-        if (sys->decoder_pool != sys->display_pool)
-            picture_pool_Release(sys->decoder_pool);
-        sys->display_pool = sys->decoder_pool = NULL;
-        return VLC_EGENERIC;
-    }
+
     return VLC_SUCCESS;
 }
 
-- 
2.11.1




More information about the vlc-devel mailing list