]> git.sesse.net Git - vlc/commitdiff
Allow picture_Copy to work on different sized pictures.
authorLaurent Aimar <fenrir@videolan.org>
Sun, 27 Jul 2008 20:32:37 +0000 (22:32 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 27 Jul 2008 21:32:25 +0000 (23:32 +0200)
include/vlc_vout.h
src/video_output/vout_pictures.c

index 420ad51faa38d95665b3abd80dce0de2ea5c8fd4..e82f1fb7a638ec4738cab3bf77ed150fad1dd53e 100644 (file)
@@ -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 ) );
 
index 2e98fc4807f7051b5f23fa2e08ee4a7dd00ffba4..55895f756c99b62e481215e75984058d65ae09b1 100644 (file)
@@ -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;
             }