[vlc-devel] [PATCH 01/31] vout: create/release the decoder device when the window is enabled/disabled

Rémi Denis-Courmont remi at remlab.net
Sat Jul 6 17:05:53 CEST 2019


Hi,

Creating a decoder device is unfortunately potentially both slow and memory-intensive. It must be avoided when not actually necessary, so this patch does not seem acceptable.

Le 5 juillet 2019 17:19:40 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>The decoder device ("dec-dev") won't change during the lifetime of the
>window
>enabled state.
>---
> include/vlc_vout_display.h       |  4 +++-
> modules/video_output/splitter.c  |  7 ++++---
> src/video_output/display.c       | 13 +------------
> src/video_output/video_output.c  |  9 +++++++++
> src/video_output/vout_internal.h |  4 ++++
> src/video_output/vout_wrapper.c  |  4 ++--
> 6 files changed, 23 insertions(+), 18 deletions(-)
>
>diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
>index aa00003c8e..8ede049dc7 100644
>--- a/include/vlc_vout_display.h
>+++ b/include/vlc_vout_display.h
>@@ -305,7 +305,9 @@ struct vout_display_t {
>  */
> VLC_API
>vout_display_t *vout_display_New(vlc_object_t *, const video_format_t
>*,
>-    const vout_display_cfg_t *, const char *module,
>+    const vout_display_cfg_t *,
>+    vlc_video_context *video_context,
>+    const char *module,
>     const vout_display_owner_t *);
> 
> /**
>diff --git a/modules/video_output/splitter.c
>b/modules/video_output/splitter.c
>index de7396788d..8d79794852 100644
>--- a/modules/video_output/splitter.c
>+++ b/modules/video_output/splitter.c
>@@ -228,12 +228,13 @@ static vout_window_t
>*video_splitter_CreateWindow(vlc_object_t *obj,
> static vout_display_t *vlc_vidsplit_CreateDisplay(vlc_object_t *obj,
>     const video_format_t *restrict source,
>     const vout_display_cfg_t *restrict cfg,
>+    vlc_video_context *vctx,
>     const char *name)
> {
>     vout_display_owner_t owner = {
>         .event = vlc_vidsplit_display_Event,
>     };
>-    return vout_display_New(obj, source, cfg, name, &owner);
>+    return vout_display_New(obj, source, cfg, vctx, name, &owner);
> }
> 
> static int vlc_vidsplit_Open(vout_display_t *vd,
>@@ -306,7 +307,7 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
>         }
> 
>         vdcfg.window = part->window;
>-        display = vlc_vidsplit_CreateDisplay(obj, &output->fmt,
>&vdcfg,
>+        display = vlc_vidsplit_CreateDisplay(obj, &output->fmt,
>&vdcfg, ctx,
>                                              modname);
>         if (display == NULL) {
>             vout_window_Disable(part->window);
>@@ -326,7 +327,7 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
>     vd->prepare = vlc_vidsplit_Prepare;
>     vd->display = vlc_vidsplit_Display;
>     vd->control = vlc_vidsplit_Control;
>-    (void) cfg; (void) fmtp; (void) ctx;
>+    (void) cfg; (void) fmtp;
>     return VLC_SUCCESS;
> }
> 
>diff --git a/src/video_output/display.c b/src/video_output/display.c
>index 2173bb084e..d37972a9a7 100644
>--- a/src/video_output/display.c
>+++ b/src/video_output/display.c
>@@ -293,9 +293,6 @@ typedef struct {
>     atomic_bool reset_pictures;
> #endif
>     picture_pool_t *pool;
>-
>-    /* temporary: must come from decoder module */
>-    vlc_video_context video_context;
> } vout_display_priv_t;
> 
> static const struct filter_video_callbacks vout_display_filter_cbs = {
>@@ -740,6 +737,7 @@ void vout_SetDisplayViewpoint(vout_display_t *vd,
> vout_display_t *vout_display_New(vlc_object_t *parent,
>                                  const video_format_t *source,
>                                  const vout_display_cfg_t *cfg,
>+                                 vlc_video_context *video_context,
>                                  const char *module,
>                                  const vout_display_owner_t *owner)
> {
>@@ -777,10 +775,6 @@ vout_display_t *vout_display_New(vlc_object_t
>*parent,
>     vd->sys = NULL;
>     vd->owner = *owner;
> 
>-    osys->video_context.device =
>vlc_decoder_device_Create(osys->cfg.window);
>-    vlc_video_context *video_context = osys->video_context.device ?
>-        &osys->video_context : NULL;
>-
>     vd->module = vlc_module_load(vd, "vout display", module,
>                                  module && *module != '\0',
>                                  vout_display_start, vd, &osys->cfg,
>@@ -811,8 +805,6 @@ vout_display_t *vout_display_New(vlc_object_t
>*parent,
>     return vd;
> error:
>     video_format_Clean(&vd->source);
>-    if (osys->video_context.device)
>-        vlc_decoder_device_Release(osys->video_context.device);
>     vlc_object_delete(vd);
>     return NULL;
> }
>@@ -832,9 +824,6 @@ void vout_display_Delete(vout_display_t *vd)
>         vlc_objres_clear(VLC_OBJECT(vd));
>     }
> 
>-    if (osys->video_context.device)
>-        vlc_decoder_device_Release(osys->video_context.device);
>-
>     video_format_Clean(&vd->source);
>     video_format_Clean(&vd->fmt);
>     vlc_object_delete(vd);
>diff --git a/src/video_output/video_output.c
>b/src/video_output/video_output.c
>index 490d1fa97e..687fb2b932 100644
>--- a/src/video_output/video_output.c
>+++ b/src/video_output/video_output.c
>@@ -49,6 +49,7 @@
> #include <vlc_vout_osd.h>
> #include <vlc_image.h>
> #include <vlc_plugin.h>
>+#include <vlc_codec.h>
> 
> #include <libvlc.h>
> #include "vout_internal.h"
>@@ -1681,6 +1682,8 @@ void vout_Stop(vout_thread_t *vout)
>         vout_StopDisplay(vout);
> 
>     vlc_mutex_lock(&sys->window_lock);
>+    vlc_decoder_device_Release(sys->dec_device);
>+    sys->dec_device = NULL;
>     if (sys->window_enabled) {
>         vout_window_Disable(sys->display_cfg.window);
>         sys->window_enabled = false;
>@@ -1914,6 +1917,10 @@ int vout_Request(const vout_configuration_t
>*cfg, input_thread_t *input)
>             goto error;
>         }
>         sys->window_enabled = true;
>+
>+        sys->dec_device =
>vlc_decoder_device_Create(sys->display_cfg.window);
>+        /* temporary until it comes from the decoder/filters */
>+        sys->video_context.device = sys->dec_device;
>     } else
>         vout_UpdateWindowSizeLocked(vout);
> 
>@@ -1929,6 +1936,8 @@ int vout_Request(const vout_configuration_t *cfg,
>input_thread_t *input)
>         vlc_mutex_lock(&sys->window_lock);
>         vout_window_Disable(sys->display_cfg.window);
>         sys->window_enabled = false;
>+        vlc_decoder_device_Release(sys->dec_device);
>+        sys->dec_device = NULL;
>         vlc_mutex_unlock(&sys->window_lock);
>         goto error;
>     }
>diff --git a/src/video_output/vout_internal.h
>b/src/video_output/vout_internal.h
>index 3c5a7e2688..5a60a2926c 100644
>--- a/src/video_output/vout_internal.h
>+++ b/src/video_output/vout_internal.h
>@@ -179,6 +179,10 @@ struct vout_thread_sys_t
>     vout_display_t *display;
>     vlc_mutex_t     display_lock;
> 
>+    vlc_decoder_device *dec_device;
>+    /* temporary: must come from decoder module */
>+    vlc_video_context video_context;
>+
>     picture_pool_t  *private_pool;
>     picture_pool_t  *display_pool;
>     picture_pool_t  *decoder_pool;
>diff --git a/src/video_output/vout_wrapper.c
>b/src/video_output/vout_wrapper.c
>index 61046f2be0..e24f6ec793 100644
>--- a/src/video_output/vout_wrapper.c
>+++ b/src/video_output/vout_wrapper.c
>@@ -82,8 +82,8 @@ vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
>     else
>         modlist = "splitter,none";
> 
>-    vd = vout_display_New(VLC_OBJECT(vout), &sys->original, cfg,
>modlist,
>-                          &owner);
>+    vd = vout_display_New(VLC_OBJECT(vout), &sys->original, cfg,
>+                          &sys->video_context, modlist, &owner);
>     free(modlistbuf);
> 
>     if (vd == NULL)
>-- 
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190706/f481e8f8/attachment.html>


More information about the vlc-devel mailing list