fixed #924
authorAlexander Shishkov <no@email>
Wed, 22 Feb 2012 12:16:01 +0000 (12:16 +0000)
committerAlexander Shishkov <no@email>
Wed, 22 Feb 2012 12:16:01 +0000 (12:16 +0000)
modules/highgui/src/cap_ffmpeg_impl.hpp

index d1e41f1..a2c6166 100644 (file)
@@ -1199,13 +1199,33 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int
             temp_image.width = width;
             temp_image.height = height;
             temp_image.cn = cn;
-            temp_image.data = malloc(temp_image.step*temp_image.height);
+            temp_image.data = (unsigned char*)malloc(temp_image.step*temp_image.height);
         }
         for( int y = 0; y < height; y++ )
             memcpy(temp_image.data + y*temp_image.step, data + (height-1-y)*step, width*cn);
         data = temp_image.data;
         step = temp_image.step;
     }
+#else
+    if( width*cn != step )
+    {
+        if( !temp_image.data )
+        {
+            temp_image.step = width*cn;
+            temp_image.width = width;
+            temp_image.height = height;
+            temp_image.cn = cn;
+            temp_image.data = (unsigned char*)malloc(temp_image.step*temp_image.height);
+        }
+        if (origin == 1)
+            for( int y = 0; y < height; y++ )
+                memcpy(temp_image.data + y*temp_image.step, data + (height-1-y)*step, temp_image.step);
+        else
+            for( int y = 0; y < height; y++ )
+                memcpy(temp_image.data + y*temp_image.step, data + y*step, temp_image.step);
+        data = temp_image.data;
+        step = temp_image.step;
+    }
 #endif
 
     // check parameters