Commit 7a46fc43 authored by Romain Vimont's avatar Romain Vimont Committed by Jean-Baptiste Kempf

snapshot: fix snapshots cropping

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 #18970
Signed-off-by: Romain Vimont's avatarRomain Vimont <rom@rom1v.com>
Acked-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 04273382
......@@ -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 );
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment