[vlc-devel] commit: Allow picture_Copy to work on different sized pictures. ( Laurent Aimar )
git version control
git at videolan.org
Sun Jul 27 23:29:49 CEST 2008
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Jul 27 22:32:37 2008 +0200| [ba939b2d2bbb24fd5f45177d0583ae425e7eeefc]
Allow picture_Copy to work on different sized pictures.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ba939b2d2bbb24fd5f45177d0583ae425e7eeefc
---
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 420ad51..e82f1fb 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 2e98fc4..55895f7 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;
}
More information about the vlc-devel
mailing list