fix memory management issue in voip (patch from electron)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7804 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-12-30 15:42:15 +00:00
parent 326d91d4c7
commit 67bd9493e1

View File

@ -65,14 +65,17 @@ void QVideoInputDevice::grabFrame()
if(img->nChannels != 3) if(img->nChannels != 3)
{ {
std::cerr << "(EE) expected 3 channels. Got " << img->nChannels << std::endl; std::cerr << "(EE) expected 3 channels. Got " << img->nChannels << std::endl;
cvReleaseImage(&img) ;
return ; return ;
} }
// convert to RGB and copy to new buffer, because cvQueryFrame tells us to not modify the buffer
cv::Mat img_rgb;
cv::cvtColor(cv::Mat(img), img_rgb, CV_BGR2RGB);
static const int _encoded_width = 128 ; static const int _encoded_width = 128 ;
static const int _encoded_height = 128 ; static const int _encoded_height = 128 ;
QImage image = QImage((uchar*)img->imageData,img->width,img->height,QImage::Format_RGB888).scaled(QSize(_encoded_width,_encoded_height),Qt::IgnoreAspectRatio,Qt::SmoothTransformation) ; QImage image = QImage(img_rgb.data,img_rgb.cols,img_rgb.rows,QImage::Format_RGB888).scaled(QSize(_encoded_width,_encoded_height),Qt::IgnoreAspectRatio,Qt::SmoothTransformation) ;
if(_video_encoder != NULL) if(_video_encoder != NULL)
{ {