[vlc-devel] [PATCH 3/7] video_output: split the code to set the crop/AR value from the display update

Thomas Guillem thomas at gllm.fr
Tue Sep 1 14:59:42 CEST 2020



On Tue, Sep 1, 2020, at 12:06, Steve Lhomme wrote:
> ---
>  src/video_output/video_output.c | 61 +++++++++++++++++++++++----------
>  1 file changed, 42 insertions(+), 19 deletions(-)
> 
> diff --git a/src/video_output/video_output.c 
> b/src/video_output/video_output.c
> index 5149059d2b4..78e17cda742 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -628,6 +628,13 @@ void vout_ChangeZoom(vout_thread_t *vout, unsigned 
> num, unsigned den)
>      vlc_mutex_unlock(&sys->display_lock);
>  }
>  
> +static void ChangeDisplayAspectRatio(vout_thread_sys_t *sys,
> +                                     unsigned dar_num, unsigned dar_den)
> +{
> +    sys->source.dar.num = dar_num;
> +    sys->source.dar.den = dar_den;
> +}
> +
>  void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
>                                     unsigned dar_num, unsigned dar_den)
>  {
> @@ -635,8 +642,7 @@ void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
>      assert(!sys->dummy);
>  
>      vlc_mutex_lock(&sys->window_lock);
> -    sys->source.dar.num = dar_num;
> -    sys->source.dar.den = dar_den;
> +    ChangeDisplayAspectRatio(sys, dar_num, dar_den);
>  
>      vout_UpdateWindowSizeLocked(sys);
>  
> @@ -648,18 +654,23 @@ void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
>      vlc_mutex_unlock(&sys->display_lock);
>  }
>  
> -void vout_ChangeCropRatio(vout_thread_t *vout, unsigned num, unsigned den)
> +static void ChangeCropRatio(vout_thread_sys_t *sys, unsigned num, unsigned den)
>  {
> -    vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
> -    assert(!sys->dummy);
> -
> -    vlc_mutex_lock(&sys->window_lock);
>      if (num != 0 && den != 0) {
>          sys->source.crop.mode = VOUT_CROP_RATIO;
>          sys->source.crop.ratio.num = num;
>          sys->source.crop.ratio.den = den;
>      } else
>          sys->source.crop.mode = VOUT_CROP_NONE;
> +}
> +
> +void vout_ChangeCropRatio(vout_thread_t *vout, unsigned num, unsigned den)
> +{
> +    vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
> +    assert(!sys->dummy);
> +
> +    vlc_mutex_lock(&sys->window_lock);
> +    ChangeCropRatio(sys, num, den);
>  
>      vout_UpdateWindowSizeLocked(sys);
>  
> @@ -671,12 +682,9 @@ void vout_ChangeCropRatio(vout_thread_t *vout, 
> unsigned num, unsigned den)
>      vlc_mutex_unlock(&sys->display_lock);
>  }
>  
> -void vout_ChangeCropWindow(vout_thread_t *vout,
> -                           int x, int y, int width, int height)
> +static void ChangeCropWindow(vout_thread_sys_t *sys,
> +                             int x, int y, int width, int height)

We already disagreed on such changes. Please keep using vout.

>  {
> -    vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
> -    assert(!sys->dummy);
> -
>      if (x < 0)
>          x = 0;
>      if (y < 0)
> @@ -686,12 +694,21 @@ void vout_ChangeCropWindow(vout_thread_t *vout,
>      if (height < 0)
>          height = 0;
>  
> -    vlc_mutex_lock(&sys->window_lock);
>      sys->source.crop.mode = VOUT_CROP_WINDOW;
>      sys->source.crop.window.x = x;
>      sys->source.crop.window.y = y;
>      sys->source.crop.window.width = width;
>      sys->source.crop.window.height = height;
> +}
> +
> +void vout_ChangeCropWindow(vout_thread_t *vout,
> +                           int x, int y, int width, int height)
> +{
> +    vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
> +    assert(!sys->dummy);
> +
> +    vlc_mutex_lock(&sys->window_lock);
> +    ChangeCropWindow(sys, x, y, width, height);
>  
>      vout_UpdateWindowSizeLocked(sys);
>  
> @@ -703,12 +720,9 @@ void vout_ChangeCropWindow(vout_thread_t *vout,
>      vlc_mutex_unlock(&sys->display_lock);
>  }
>  
> -void vout_ChangeCropBorder(vout_thread_t *vout,
> -                           int left, int top, int right, int bottom)
> +static void ChangeCropBorder(vout_thread_sys_t *sys,
> +                             int left, int top, int right, int bottom)
>  {
> -    vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
> -    assert(!sys->dummy);
> -
>      if (left < 0)
>          left = 0;
>      if (top < 0)
> @@ -718,12 +732,21 @@ void vout_ChangeCropBorder(vout_thread_t *vout,
>      if (bottom < 0)
>          bottom = 0;
>  
> -    vlc_mutex_lock(&sys->window_lock);
>      sys->source.crop.mode = VOUT_CROP_BORDER;
>      sys->source.crop.border.left = left;
>      sys->source.crop.border.right = right;
>      sys->source.crop.border.top = top;
>      sys->source.crop.border.bottom = bottom;
> +}
> +
> +void vout_ChangeCropBorder(vout_thread_t *vout,
> +                           int left, int top, int right, int bottom)
> +{
> +    vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
> +    assert(!sys->dummy);
> +
> +    vlc_mutex_lock(&sys->window_lock);
> +    ChangeCropBorder(sys, left, top, right, bottom);
>  
>      vout_UpdateWindowSizeLocked(sys);
>  
> -- 
> 2.26.2
> 
> _______________________________________________
> 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