[vlc-devel] [PATCH 13/17] video_output: group the code to setup and load the display module in a function
Steve Lhomme
robux4 at ycbcr.xyz
Mon Nov 23 14:01:45 CET 2020
On 2020-11-20 21:09, Thomas Guillem wrote:
>
>
> On Fri, Nov 20, 2020, at 15:45, Steve Lhomme wrote:
>> vout_Start is also handling filter setup.
>>
>> The function must be called under display lock. The crop and aspect ratio
>> values need to be read under window lock.
>> ---
>> src/video_output/video_output.c | 67 +++++++++++++++++++++------------
>> 1 file changed, 42 insertions(+), 25 deletions(-)
>>
>> diff --git a/src/video_output/video_output.c
>> b/src/video_output/video_output.c
>> index 5ff0a7d1bef..74602e09c76 100644
>> --- a/src/video_output/video_output.c
>> +++ b/src/video_output/video_output.c
>> @@ -1725,6 +1725,39 @@ static void
>> ThreadProcessMouseState(vout_thread_sys_t *p_vout,
>> sys->mouse_event(m, sys->mouse_opaque);
>> }
>>
>> +static int vout_StartDisplayAloneLocked(vout_thread_sys_t *vout,
>> + const video_format_t *fmt,
>
> I prefer vout_StartDisplayLocked
>
> It's self-explanatory that it is starting only the display.
OK.
>> vlc_video_context *vctx,
>> + const vout_display_cfg_t *cfg,
>> + const vlc_rational_t *dar,
>> const vlc_rational_t *crop,
>> + int x, int y, int w, int h)
>> +{
>> + vout_thread_sys_t *sys = vout;
>> + sys->private.display_pool = NULL;
>> + sys->private.private_pool = NULL;
>> +
>> + vout_display_cfg_t dcfg = *cfg;
>> +
>> + /* Setup the window size, protected by the display_lock */
>> + dcfg.window_props.width = sys->window_width;
>> + dcfg.window_props.height = sys->window_height;
>> +
>> + // original is used both as decoder output and display input
>> + video_format_Clean(&sys->original);
>> + video_format_Copy(&sys->original, fmt);
>> +
>> + sys->display = vout_OpenWrapper(&vout->obj, &sys->private,
>> sys->splitter_name, &dcfg,
>> + fmt, vctx);
>> + if (sys->display == NULL)
>> + return VLC_EGENERIC;
>> +
>> + vout_SetDisplayCrop(sys->display, crop->num, crop->den, x, y, w,
>> h);
>> +
>> + if (dar->num != 0 && dar->den != 0)
>> + vout_SetDisplayAspect(sys->display, dar->num, dar->den);
>> +
>> + return VLC_SUCCESS;
>> +}
>> +
>> static int vout_Start(vout_thread_sys_t *vout, vlc_video_context
>> *vctx, const vout_configuration_t *cfg)
>> {
>> vout_thread_sys_t *sys = vout;
>> @@ -1735,8 +1768,6 @@ static int vout_Start(vout_thread_sys_t *vout,
>> vlc_video_context *vctx, const vo
>> vlc_mouse_Init(&sys->mouse);
>>
>> sys->decoder_fifo = picture_fifo_New();
>> - sys->private.display_pool = NULL;
>> - sys->private.private_pool = NULL;
>>
>> sys->filter.configuration = NULL;
>> video_format_Copy(&sys->filter.src_fmt, &sys->original);
>> @@ -1758,9 +1789,6 @@ static int vout_Start(vout_thread_sys_t *vout,
>> vlc_video_context *vctx, const vo
>> sys->filter.chain_interactive = filter_chain_NewVideo(&vout->obj,
>> true, &owner);
>>
>> vout_display_cfg_t dcfg;
>> - int x = 0, y = 0, w = 0, h = 0;
>> - unsigned crop_num = 0, crop_den = 0;
>> - unsigned num, den;
>>
>> vlc_mutex_lock(&sys->window_lock);
>> #ifndef NDEBUG
>> @@ -1775,12 +1803,14 @@ static int vout_Start(vout_thread_sys_t *vout,
>> vlc_video_context *vctx, const vo
>>
>> dcfg = sys->display_cfg;
>>
>> + int x = 0, y = 0, w = 0, h = 0;
>> + vlc_rational_t crop = {0};
>> switch (sys->source.crop.mode) {
>> case VOUT_CROP_NONE:
>> break;
>> case VOUT_CROP_RATIO:
>> - crop_num = sys->source.crop.ratio.num;
>> - crop_den = sys->source.crop.ratio.den;
>> + crop = (vlc_rational_t) { sys->source.crop.ratio.num,
>> + sys->source.crop.ratio.den };
>> break;
>> case VOUT_CROP_WINDOW:
>> x = sys->source.crop.window.x;
>> @@ -1796,31 +1826,18 @@ static int vout_Start(vout_thread_sys_t *vout,
>> vlc_video_context *vctx, const vo
>> break;
>> }
>>
>> - num = sys->source.dar.num;
>> - den = sys->source.dar.den;
>> + vlc_rational_t dar = (vlc_rational_t) { sys->source.dar.num,
>> sys->source.dar.den };
>> vlc_mutex_lock(&sys->display_lock);
>> vlc_mutex_unlock(&sys->window_lock);
>>
>> - /* Setup the window size, protected by the display_lock */
>> - dcfg.window_props.width = sys->window_width;
>> - dcfg.window_props.height = sys->window_height;
>> -
>> - sys->display = vout_OpenWrapper(&vout->obj, &sys->private,
>> sys->splitter_name, &dcfg,
>> - &sys->original, vctx);
>> - if (sys->display == NULL) {
>> - vlc_mutex_unlock(&sys->display_lock);
>> - goto error;
>> - }
>> -
>> - vout_SetDisplayCrop(sys->display, crop_num, crop_den, x, y, w, h);
>> -
>> - if (num != 0 && den != 0)
>> - vout_SetDisplayAspect(sys->display, num, den);
>> + int err = vout_StartDisplayAloneLocked(vout, &sys->original, vctx,
>> &dcfg,
>> + &dar, &crop, x, y, h, w);
>> vlc_mutex_unlock(&sys->display_lock);
>> + if (err != VLC_SUCCESS)
>> + goto error;
>>
>> assert(sys->private.display_pool != NULL &&
>> sys->private.private_pool != NULL);
>>
>> - sys->displayed.current = NULL;
>> sys->displayed.decoded = NULL;
>> sys->displayed.date = VLC_TICK_INVALID;
>> sys->displayed.is_interlaced = false;
>> --
>> 2.26.2
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> 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