Commit 80747088 authored by Pavel Rojtberg's avatar Pavel Rojtberg

avoid needless copies during mjpeg decoding

parent 56dd7eda
...@@ -1612,15 +1612,11 @@ uyvy_to_rgb24 (int width, int height, unsigned char *src, unsigned char *dst) ...@@ -1612,15 +1612,11 @@ uyvy_to_rgb24 (int width, int height, unsigned char *src, unsigned char *dst)
/* convert from mjpeg to rgb24 */ /* convert from mjpeg to rgb24 */
static bool static bool
mjpeg_to_rgb24 (int width, int height, mjpeg_to_rgb24(int width, int height, unsigned char* src, int length, IplImage* dst) {
unsigned char *src, int length, using namespace cv;
unsigned char *dst) Mat temp = cvarrToMat(dst);
{ imdecode(Mat(1, length, CV_8U, src), IMREAD_COLOR, &temp);
cv::Mat temp=cv::imdecode(cv::Mat(std::vector<uchar>(src, src + length)), 1); return temp.data && temp.cols == width && temp.rows == height;
if( !temp.data || temp.cols != width || temp.rows != height )
return false;
memcpy(dst, temp.data, width*height*3);
return true;
} }
#endif #endif
...@@ -2068,7 +2064,7 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) { ...@@ -2068,7 +2064,7 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) {
(unsigned char*)(capture->buffers[capture->bufferIndex] (unsigned char*)(capture->buffers[capture->bufferIndex]
.start), .start),
capture->buffers[capture->bufferIndex].length, capture->buffers[capture->bufferIndex].length,
(unsigned char*)capture->frame.imageData)) &capture->frame))
return 0; return 0;
break; break;
#endif #endif
......
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