[vlc-devel] [PATCH v3] snapshot: fix snapshots cropping

Thomas Guillem thomas at gllm.fr
Mon Nov 6 11:50:24 CET 2017


Fine with me.

On Mon, Nov 6, 2017, at 11:06, Romain Vimont wrote:
> The snapshot picture was created using picture_Copy(), which does not
> handle offsets. As a consequence, snapshots of cropped videos were
> broken.
> 
> Use picture_Clone() (shallow copy) instead, then copy the crop settings
> from the format.
> 
> Fixes <https://trac.videolan.org/vlc/ticket/18970>.
> 
> Signed-off-by: Romain Vimont <rom at rom1v.com>
> ---
> CHANGES from v2:
>  - remove 'picture_CloneRegion' implementation, use picture_Clone()
>  instead
>  - make vout_snapshot_Set() picture parameter a non-const pointer (for
>  cloning)
> 
>  src/misc/image.c            | 5 +++++
>  src/video_output/snapshot.c | 6 +++---
>  src/video_output/snapshot.h | 4 ++--
>  3 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/src/misc/image.c b/src/misc/image.c
> index aa5dd43a2d..7c3ad995c8 100644
> --- a/src/misc/image.c
> +++ b/src/misc/image.c
> @@ -778,6 +778,11 @@ static filter_t *CreateFilter( vlc_object_t *p_this,
> const es_format_t *p_fmt_in
>      es_format_Copy( &p_filter->fmt_in, p_fmt_in );
>      es_format_Copy( &p_filter->fmt_out, p_fmt_in );
>      video_format_Copy( &p_filter->fmt_out.video, p_fmt_out );
> +
> +    /* whatever the input offset, write at offset 0 in the target image
> */
> +    p_filter->fmt_out.video.i_x_offset = 0;
> +    p_filter->fmt_out.video.i_y_offset = 0;
> +
>      p_filter->fmt_out.i_codec = p_fmt_out->i_chroma;
>      p_filter->p_module = module_need( p_filter, "video converter", NULL,
>      false );
>  
> diff --git a/src/video_output/snapshot.c b/src/video_output/snapshot.c
> index ceade008cc..f9bc106d73 100644
> --- a/src/video_output/snapshot.c
> +++ b/src/video_output/snapshot.c
> @@ -112,18 +112,18 @@ bool vout_snapshot_IsRequested(vout_snapshot_t
> *snap)
>  }
>  void vout_snapshot_Set(vout_snapshot_t *snap,
>                         const video_format_t *fmt,
> -                       const picture_t *picture)
> +                       picture_t *picture)
>  {
>      if (!fmt)
>          fmt = &picture->format;
>  
>      vlc_mutex_lock(&snap->lock);
>      while (snap->request_count > 0) {
> -        picture_t *dup = picture_NewFromFormat(fmt);
> +        picture_t *dup = picture_Clone(picture);
>          if (!dup)
>              break;
>  
> -        picture_Copy(dup, picture);
> +        video_format_CopyCrop( &dup->format, fmt );
>  
>          dup->p_next = snap->picture;
>          snap->picture = dup;
> diff --git a/src/video_output/snapshot.h b/src/video_output/snapshot.h
> index b27a7212e9..3085d5038b 100644
> --- a/src/video_output/snapshot.h
> +++ b/src/video_output/snapshot.h
> @@ -53,11 +53,11 @@ bool vout_snapshot_IsRequested(vout_snapshot_t *);
>  /**
>   * It set the picture used to create the snapshots.
>   *
> - * The given picture is only copied and not released.
> + * The given picture is cloned.
>   * If p_fmt is non NULL it will override the format of the p_picture
>   (mainly
>   * used because of aspect/crop problems).
>   */
> -void vout_snapshot_Set(vout_snapshot_t *, const video_format_t *, const
> picture_t *);
> +void vout_snapshot_Set(vout_snapshot_t *, const video_format_t *,
> picture_t *);
>  
>  /**
>   * This function will return the directory used for snapshots
> -- 
> 2.11.0
> 
> _______________________________________________
> 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