[vlc-devel] [PATCH 1/2] vout: use the window size to configure the vout display size
Rémi Denis-Courmont
remi at remlab.net
Wed Mar 25 17:32:45 CET 2020
Le keskiviikkona 25. maaliskuuta 2020, 16.32.10 EET Thomas Guillem a écrit :
> Refs #22674
> ---
> include/vlc_vout_display.h | 10 +++++++---
> modules/video_output/splitter.c | 4 ++--
> src/video_output/display.c | 23 +++++++++++++++++++----
> src/video_output/vout_wrapper.c | 1 +
> 4 files changed, 29 insertions(+), 9 deletions(-)
>
> diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
> index cd183fb56c..8209f61cac 100644
> --- a/include/vlc_vout_display.h
> +++ b/include/vlc_vout_display.h
> @@ -371,8 +371,8 @@ struct vout_display_t {
> VLC_API
> vout_display_t *vout_display_New(vlc_object_t *,
> const video_format_t *, vlc_video_context *,
> - const vout_display_cfg_t *, const char *module,
> - const vout_display_owner_t *);
> + const vout_display_cfg_t *, unsigned window_width, unsigned
> window_height,
> + const char *module, const vout_display_owner_t *);
That's horrible and it won't scale if we need to add other window properties
(which seems quite likely in the near term). Just put the window and its
dimensions together in a sub-compound of the configuration.
>
> /**
> * Destroys a video output display.
> @@ -462,7 +462,11 @@ static inline bool vout_display_cfg_IsWindowed(const
> vout_display_cfg_t *cfg) *
> * This asssumes that the picture is already cropped.
> */
> -VLC_API void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned
> *height, const video_format_t *source, const vout_display_cfg_t *);
> +VLC_API void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned
> *height, + const
> video_format_t *source, +
> const vout_display_cfg_t *, +
> unsigned window_width, +
> unsigned window_height);
>
>
> /**
> diff --git a/modules/video_output/splitter.c
> b/modules/video_output/splitter.c index 71ceda4674..a8a548314c 100644
> --- a/modules/video_output/splitter.c
> +++ b/modules/video_output/splitter.c
> @@ -207,7 +207,7 @@ static vout_window_t
> *video_splitter_CreateWindow(vlc_object_t *obj, };
>
> vout_display_GetDefaultDisplaySize(&cfg.width, &cfg.height, source,
> - vdcfg);
> + vdcfg, 0, 0);
>
> vout_window_t *window = vout_window_New(obj, NULL, &owner);
> if (window != NULL) {
> @@ -288,7 +288,7 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
>
> vdcfg.window = part->window;
> vout_display_t *display = vout_display_New(obj, &output->fmt, ctx,
> &vdcfg, - modname, NULL);
> + modname, NULL, 0, 0);
> if (display == NULL) {
> vout_window_Disable(part->window);
> vout_window_Delete(part->window);
> diff --git a/src/video_output/display.c b/src/video_output/display.c
> index 76d49ee240..6c0aa69cb8 100644
> --- a/src/video_output/display.c
> +++ b/src/video_output/display.c
> @@ -100,8 +100,14 @@ static int vout_display_start(void *func, bool forced,
> va_list ap) /* */
> void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
> const video_format_t *source,
> - const vout_display_cfg_t *cfg)
> + const vout_display_cfg_t *cfg,
> + unsigned window_width,
> + unsigned window_height)
> {
> + /* The window size is either fully valid or not at all */
> + assert((window_width == 0) == (window_height == 0));
> +
> + /* Requested by the user */
> if (cfg->display.width != 0 && cfg->display.height != 0) {
> *width = cfg->display.width;
> *height = cfg->display.height;
> @@ -113,7 +119,14 @@ void vout_display_GetDefaultDisplaySize(unsigned
> *width, unsigned *height, *width = (int64_t)source->i_visible_width *
> source->i_sar_num * cfg->display.height * cfg->display.sar.den /
> source->i_visible_height / source->i_sar_den / cfg->display.sar.num;
> *height = cfg->display.height;
> - } else if (source->i_sar_num >= source->i_sar_den) {
> + }
> + /* Size reported by the window module */
> + else if (window_width != 0 && window_height != 0) {
> + *width = window_width;
> + *height = window_height;
> + }
> + /* Use the original video size */
> + else if (source->i_sar_num >= source->i_sar_den) {
> *width = (int64_t)source->i_visible_width * source->i_sar_num *
> cfg->display.sar.den / source->i_sar_den / cfg->display.sar.num; *height =
> source->i_visible_height;
> } else {
> @@ -159,7 +172,7 @@ void vout_display_PlacePicture(vout_display_place_t
> *place, cfg_tmp.display.width = 0;
> cfg_tmp.display.height = 0;
> vout_display_GetDefaultDisplaySize(&display_width, &display_height,
> - source, &cfg_tmp);
> + source, &cfg_tmp, 0, 0);
> }
>
> const unsigned width = source->i_visible_width;
> @@ -725,6 +738,7 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
> const video_format_t *source,
> vlc_video_context *vctx,
> const vout_display_cfg_t *cfg,
> + unsigned window_width, unsigned
> window_height, const char *module,
> const vout_display_owner_t *owner)
> {
> @@ -736,7 +750,8 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
> osys->cfg = *cfg;
> vout_display_GetDefaultDisplaySize(&osys->cfg.display.width,
> &osys->cfg.display.height,
> - source, &osys->cfg);
> + source, &osys->cfg,
> + window_width, window_height);
> #ifdef _WIN32
> osys->reset_pictures = false;
> #endif
> diff --git a/src/video_output/vout_wrapper.c
> b/src/video_output/vout_wrapper.c index 9e5b14a56b..f92da8cfab 100644
> --- a/src/video_output/vout_wrapper.c
> +++ b/src/video_output/vout_wrapper.c
> @@ -74,6 +74,7 @@ vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
> modlist = "splitter,none";
>
> vd = vout_display_New(VLC_OBJECT(vout), &sys->original, vctx, cfg,
> + 0, 0,
> modlist, &owner);
> free(modlistbuf);
--
雷米‧德尼-库尔蒙
http://www.remlab.net/
More information about the vlc-devel
mailing list