Commit ba939b2d authored by Laurent Aimar's avatar Laurent Aimar

Allow picture_Copy to work on different sized pictures.

parent 15335d09
...@@ -167,6 +167,8 @@ static inline void picture_CopyProperties( picture_t *p_dst, const picture_t *p_ ...@@ -167,6 +167,8 @@ static inline void picture_CopyProperties( picture_t *p_dst, const picture_t *p_
/** /**
* This function will copy the picture pixels. * 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 ) ); VLC_EXPORT( void, picture_CopyPixels, ( picture_t *p_dst, const picture_t *p_src ) );
......
...@@ -1033,11 +1033,16 @@ void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src ) ...@@ -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++ ) 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 ) if( p_src->p[i].i_pitch == p_dst->p[i].i_pitch )
{ {
/* There are margins, but with the same width : perfect ! */ /* There are margins, but with the same width : perfect ! */
vlc_memcpy( p_dst->p[i].p_pixels, p_src->p[i].p_pixels, 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 else
{ {
...@@ -1049,9 +1054,9 @@ void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src ) ...@@ -1049,9 +1054,9 @@ void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src )
assert( p_in ); assert( p_in );
assert( p_out ); 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_in += p_src->p[i].i_pitch;
p_out += p_dst->p[i].i_pitch; p_out += p_dst->p[i].i_pitch;
} }
......
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