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

Steve Lhomme robux4 at ycbcr.xyz
Mon Jul 8 08:53:41 CEST 2019


On 2019-07-06 17:05, Rémi Denis-Courmont wrote:
> 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.

This patch actually creates the decoder device less often than we 
currently have in master (every time a display module is created). So if 
anything that's an improvement.

Now we can discuss when it makes sense to create one. Given it depends 
on the actual window handle on some platforms it's at least tied to the 
window lifecycle. I don't know if it's when the window is created or 
when it's enabled/disabled.

The X11 handle (string) seems to be created when the module is opened. 
It's used by vdpau and vaapi.
The Wayland handle (wl_display) is created during the open of xdg-shell. 
I'm less sure about the Qt interface once.


> 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é.
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list