From ba939b2d2bbb24fd5f45177d0583ae425e7eeefc Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 27 Jul 2008 22:32:37 +0200 Subject: [PATCH] Allow picture_Copy to work on different sized pictures. --- include/vlc_vout.h | 2 ++ src/video_output/vout_pictures.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/vlc_vout.h b/include/vlc_vout.h index 420ad51faa..e82f1fb7a6 100644 --- a/include/vlc_vout.h +++ b/include/vlc_vout.h @@ -167,6 +167,8 @@ static inline void picture_CopyProperties( picture_t *p_dst, const picture_t *p_ /** * This function will copy the picture pixels. + * You can safely copy between pictures that do not have the same size, + * only the compatible(smaller) part will be copied. */ VLC_EXPORT( void, picture_CopyPixels, ( picture_t *p_dst, const picture_t *p_src ) ); diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c index 2e98fc4807..55895f756c 100644 --- a/src/video_output/vout_pictures.c +++ b/src/video_output/vout_pictures.c @@ -1033,11 +1033,16 @@ void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src ) for( i = 0; i < p_src->i_planes ; i++ ) { + const unsigned i_width = __MIN( p_dst->p[i].i_visible_pitch, + p_src->p[i].i_visible_pitch ); + const unsigned i_height = __MIN( p_dst->p[i].i_visible_lines, + p_src->p[i].i_visible_lines ); + if( p_src->p[i].i_pitch == p_dst->p[i].i_pitch ) { /* There are margins, but with the same width : perfect ! */ vlc_memcpy( p_dst->p[i].p_pixels, p_src->p[i].p_pixels, - p_src->p[i].i_pitch * p_src->p[i].i_visible_lines ); + p_src->p[i].i_pitch * i_height ); } else { @@ -1049,9 +1054,9 @@ void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src ) assert( p_in ); assert( p_out ); - for( i_line = p_src->p[i].i_visible_lines; i_line--; ) + for( i_line = i_height; i_line--; ) { - vlc_memcpy( p_out, p_in, p_src->p[i].i_visible_pitch ); + vlc_memcpy( p_out, p_in, i_width ); p_in += p_src->p[i].i_pitch; p_out += p_dst->p[i].i_pitch; } -- 2.39.5