]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_wrapper.c
LGPL
[vlc] / src / video_output / vout_wrapper.c
index 3c2c3f4a31ec7aee5570fe5571abf71b8cb46be0..fc6072f93d5ecc5253d9b75426ae8b4a8eae020d 100644 (file)
@@ -6,19 +6,19 @@
  *
  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -48,7 +48,7 @@ static int  Forward(vlc_object_t *, char const *,
  *
  *****************************************************************************/
 int vout_OpenWrapper(vout_thread_t *vout,
-                     const char *name, const vout_display_state_t *state)
+                     const char *splitter_name, const vout_display_state_t *state)
 {
     vout_thread_sys_t *sys = vout->p;
     msg_Dbg(vout, "Opening vout display wrapper");
@@ -57,22 +57,16 @@ int vout_OpenWrapper(vout_thread_t *vout,
     sys->display.title = var_CreateGetNonEmptyString(vout, "video-title");
 
     /* */
-    video_format_t source   = vout->p->original;
-    source.i_visible_width  = source.i_width;
-    source.i_visible_height = source.i_height;
-    source.i_x_offset       = 0;
-    source.i_y_offset       = 0;
-
     const mtime_t double_click_timeout = 300000;
     const mtime_t hide_timeout = var_CreateGetInteger(vout, "mouse-hide-timeout") * 1000;
 
-    sys->display.vd = vout_NewDisplay(vout, &source, state, name ? name : "$vout",
-                                      double_click_timeout, hide_timeout);
-    /* If we need to video filter and it fails, then try a splitter
-     * XXX it is a hack for now FIXME */
-    if (name && !sys->display.vd)
-        sys->display.vd = vout_NewSplitter(vout, &source, state, "$vout", name,
+    if (splitter_name) {
+        sys->display.vd = vout_NewSplitter(vout, &vout->p->original, state, "$vout", splitter_name,
                                            double_click_timeout, hide_timeout);
+    } else {
+        sys->display.vd = vout_NewDisplay(vout, &vout->p->original, state, "$vout",
+                                          double_click_timeout, hide_timeout);
+    }
     if (!sys->display.vd) {
         free(sys->display.title);
         return VLC_EGENERIC;
@@ -112,6 +106,26 @@ void vout_CloseWrapper(vout_thread_t *vout, vout_display_state_t *state)
 /*****************************************************************************
  *
  *****************************************************************************/
+/* Minimum number of display picture */
+#define DISPLAY_PICTURE_COUNT (1)
+
+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);
+    else
+        //sys->display_pool = picture_pool_Reserve(sys->decoder_pool, DISPLAY_PICTURE_COUNT);
+        sys->display_pool = picture_pool_NewFromFormat(&sys->display.vd->source, DISPLAY_PICTURE_COUNT);
+}
+static void NoDrClean(vout_thread_t *vout)
+{
+    vout_thread_sys_t *sys = vout->p;
+
+    if (!sys->display.use_dr)
+        picture_pool_Delete(sys->display_pool);
+}
 int vout_InitWrapper(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = vout->p;
@@ -119,12 +133,11 @@ int vout_InitWrapper(vout_thread_t *vout)
     video_format_t source = vd->source;
 
     sys->display.use_dr = !vout_IsDisplayFiltered(vd);
-    const bool allow_dr = !vd->info.has_pictures_invalid && sys->display.use_dr;
-    const unsigned private_picture  = 3; /* XXX 2 for filter, 1 for SPU */
-    const unsigned display_picture  = 1; /* Minimum number of display picture */
+    const bool allow_dr = !vd->info.has_pictures_invalid && !vd->info.is_slow && sys->display.use_dr;
+    const unsigned private_picture  = 4; /* XXX 3 for filter, 1 for SPU */
     const unsigned decoder_picture  = 1 + sys->dpb_size;
     const unsigned kept_picture     = 1; /* last displayed picture */
-    const unsigned reserved_picture = display_picture +
+    const unsigned reserved_picture = DISPLAY_PICTURE_COUNT +
                                       private_picture +
                                       kept_picture;
     picture_pool_t *display_pool =
@@ -135,23 +148,18 @@ int vout_InitWrapper(vout_thread_t *vout)
         sys->dpb_size     = picture_pool_GetSize(display_pool) - reserved_picture;
         sys->decoder_pool = display_pool;
         sys->display_pool = display_pool;
-        sys->is_decoder_pool_slow = vd->info.is_slow;
     } else if (!sys->decoder_pool) {
         sys->decoder_pool =
             picture_pool_NewFromFormat(&source,
                                        __MAX(VOUT_MAX_PICTURES,
-                                             reserved_picture + decoder_picture));
+                                             reserved_picture + decoder_picture - DISPLAY_PICTURE_COUNT));
         if (allow_dr) {
             msg_Warn(vout, "Not enough direct buffers, using system memory");
             sys->dpb_size = 0;
         } else {
             sys->dpb_size = picture_pool_GetSize(sys->decoder_pool) - reserved_picture;
         }
-        if (sys->display.use_dr)
-            sys->display_pool = display_pool;
-        else
-            sys->display_pool = picture_pool_Reserve(sys->decoder_pool, display_picture);
-        sys->is_decoder_pool_slow = false;
+        NoDrInit(vout);
     }
     sys->private_pool = picture_pool_Reserve(sys->decoder_pool, private_picture);
     sys->display.filtered = NULL;
@@ -170,8 +178,7 @@ void vout_EndWrapper(vout_thread_t *vout)
         picture_pool_Delete(sys->private_pool);
 
     if (sys->decoder_pool != sys->display_pool) {
-        if (!sys->display.use_dr)
-            picture_pool_Delete(sys->display_pool);
+        NoDrClean(vout);
         picture_pool_Delete(sys->decoder_pool);
     }
 }
@@ -187,41 +194,14 @@ void vout_ManageWrapper(vout_thread_t *vout)
     bool reset_display_pool = sys->display.use_dr && vout_AreDisplayPicturesInvalid(vd);
     vout_ManageDisplay(vd, !sys->display.use_dr || reset_display_pool);
 
-    if (reset_display_pool)
-        sys->display_pool = vout_display_Pool(vd, 3);
-}
-
-/*****************************************************************************
- * Render
- *****************************************************************************/
-void vout_RenderWrapper(vout_thread_t *vout, picture_t *picture)
-{
-    vout_thread_sys_t *sys = vout->p;
-    vout_display_t *vd = sys->display.vd;
-
-    assert(vout_IsDisplayFiltered(vd) == !sys->display.use_dr);
+    if (reset_display_pool) {
+        NoDrClean(vout);
 
-    if (sys->display.use_dr) {
-        vout_display_Prepare(vd, picture);
-    } else {
-        sys->display.filtered = vout_FilterDisplay(vd, picture);
-        if (sys->display.filtered)
-            vout_display_Prepare(vd, sys->display.filtered);
+        sys->display.use_dr = !vout_IsDisplayFiltered(vd);
+        NoDrInit(vout);
     }
 }
 
-/*****************************************************************************
- *
- *****************************************************************************/
-void vout_DisplayWrapper(vout_thread_t *vout, picture_t *picture)
-{
-    vout_thread_sys_t *sys = vout->p;
-    vout_display_t *vd = sys->display.vd;
-
-     vout_display_Display(vd, sys->display.filtered ? sys->display.filtered : picture);
-     sys->display.filtered = NULL;
-}
-
 #ifdef WIN32
 static int Forward(vlc_object_t *object, char const *var,
                    vlc_value_t oldval, vlc_value_t newval, void *data)