1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #7854 from alalek:backports_2016

(2.4) Backports from master branch (#7854)
This commit is contained in:
Alexander Alekhin
2016-12-15 18:09:44 +02:00
committed by GitHub
parent 49e6bb2993
commit cc09f5a7de
61 changed files with 1546 additions and 966 deletions
@@ -118,7 +118,6 @@ private:
int height;
int settingWidth;
int settingHeight;
OSType mInputPixelFormat;
int started;
};
@@ -165,7 +164,6 @@ private:
CMTime mFrameTimestamp;
size_t mFrameNum;
OSType mInputPixelFormat;
int started;
};
+21 -21
View File
@@ -907,10 +907,10 @@ b = b > 255 ? 255 : b
uyv2bgr(const unsigned char *src, unsigned char *dest,
unsigned long long int NumPixels)
{
register int i = NumPixels + (NumPixels << 1) - 1;
register int j = NumPixels + (NumPixels << 1) - 1;
register int y, u, v;
register int r, g, b;
int i = NumPixels + (NumPixels << 1) - 1;
int j = NumPixels + (NumPixels << 1) - 1;
int y, u, v;
int r, g, b;
while (i > 0) {
v = src[i--] - 128;
@@ -927,10 +927,10 @@ uyv2bgr(const unsigned char *src, unsigned char *dest,
uyvy2bgr(const unsigned char *src, unsigned char *dest,
unsigned long long int NumPixels)
{
register int i = (NumPixels << 1) - 1;
register int j = NumPixels + (NumPixels << 1) - 1;
register int y0, y1, u, v;
register int r, g, b;
int i = (NumPixels << 1) - 1;
int j = NumPixels + (NumPixels << 1) - 1;
int y0, y1, u, v;
int r, g, b;
while (i > 0) {
y1 = src[i--];
@@ -953,10 +953,10 @@ uyvy2bgr(const unsigned char *src, unsigned char *dest,
uyyvyy2bgr(const unsigned char *src, unsigned char *dest,
unsigned long long int NumPixels)
{
register int i = NumPixels + (NumPixels >> 1) - 1;
register int j = NumPixels + (NumPixels << 1) - 1;
register int y0, y1, y2, y3, u, v;
register int r, g, b;
int i = NumPixels + (NumPixels >> 1) - 1;
int j = NumPixels + (NumPixels << 1) - 1;
int y0, y1, y2, y3, u, v;
int r, g, b;
while (i > 0) {
y3 = src[i--];
@@ -988,9 +988,9 @@ uyyvyy2bgr(const unsigned char *src, unsigned char *dest,
y2bgr(const unsigned char *src, unsigned char *dest,
unsigned long long int NumPixels)
{
register int i = NumPixels - 1;
register int j = NumPixels + (NumPixels << 1) - 1;
register int y;
int i = NumPixels - 1;
int j = NumPixels + (NumPixels << 1) - 1;
int y;
while (i > 0) {
y = src[i--];
@@ -1004,9 +1004,9 @@ y2bgr(const unsigned char *src, unsigned char *dest,
y162bgr(const unsigned char *src, unsigned char *dest,
unsigned long long int NumPixels, int bits)
{
register int i = (NumPixels << 1) - 1;
register int j = NumPixels + (NumPixels << 1) - 1;
register int y;
int i = (NumPixels << 1) - 1;
int j = NumPixels + (NumPixels << 1) - 1;
int y;
while (i > 0) {
y = src[i--];
@@ -1022,9 +1022,9 @@ y162bgr(const unsigned char *src, unsigned char *dest,
rgb482bgr(const unsigned char *src, unsigned char *dest,
unsigned long long int NumPixels, int bits)
{
register int i = (NumPixels << 1) - 1;
register int j = NumPixels + (NumPixels << 1) - 1;
register int y;
int i = (NumPixels << 1) - 1;
int j = NumPixels + (NumPixels << 1) - 1;
int y;
while (i > 0) {
y = src[i--];
+24 -1
View File
@@ -45,6 +45,7 @@
#ifdef HAVE_JASPER
#include "grfmt_jpeg2000.hpp"
#include "opencv2/imgproc.hpp"
#ifdef WIN32
#define JAS_WIN_MSVC_BUILD 1
@@ -159,6 +160,21 @@ bool Jpeg2KDecoder::readData( Mat& img )
jas_stream_t* stream = (jas_stream_t*)m_stream;
jas_image_t* image = (jas_image_t*)m_image;
#ifndef WIN32
// At least on some Linux instances the
// system libjasper segfaults when
// converting color to grey.
// We do this conversion manually at the end.
Mat clr;
if (CV_MAT_CN(img.type()) < CV_MAT_CN(this->type()))
{
clr.create(img.size().height, img.size().width, this->type());
color = true;
data = clr.ptr();
step = (int)clr.step;
}
#endif
if( stream && image )
{
bool convert;
@@ -171,7 +187,7 @@ bool Jpeg2KDecoder::readData( Mat& img )
else
{
convert = (jas_clrspc_fam( jas_image_clrspc( image ) ) != JAS_CLRSPC_FAM_GRAY);
colorspace = JAS_CLRSPC_SGRAY; // TODO GENGRAY or SGRAY?
colorspace = JAS_CLRSPC_SGRAY; // TODO GENGRAY or SGRAY? (GENGRAY fails on Win.)
}
// convert to the desired colorspace
@@ -256,6 +272,13 @@ bool Jpeg2KDecoder::readData( Mat& img )
close();
#ifndef WIN32
if (!clr.empty())
{
cv::cvtColor(clr, img, COLOR_BGR2GRAY);
}
#endif
return result;
}