From 50df95650a535e655128ae04f29dfea5c871fd2f Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Wed, 22 Feb 2012 12:16:01 +0000 Subject: [PATCH] fixed #924 --- modules/highgui/src/cap_ffmpeg_impl.hpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp index d1e41f1..a2c6166 100644 --- a/modules/highgui/src/cap_ffmpeg_impl.hpp +++ b/modules/highgui/src/cap_ffmpeg_impl.hpp @@ -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 -- 2.7.4