mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
RGB24 and BGR24 cleanup
This commit is contained in:
parent
897e4aac8a
commit
a5b42e3024
@ -10,6 +10,7 @@ enum class PixelFormat {
|
|||||||
YUYV,
|
YUYV,
|
||||||
UYVY,
|
UYVY,
|
||||||
BGR16,
|
BGR16,
|
||||||
|
RGB24,
|
||||||
BGR24,
|
BGR24,
|
||||||
RGB32,
|
RGB32,
|
||||||
BGR32,
|
BGR32,
|
||||||
@ -36,6 +37,10 @@ inline PixelFormat parsePixelFormat(const QString& pixelFormat)
|
|||||||
{
|
{
|
||||||
return PixelFormat::BGR16;
|
return PixelFormat::BGR16;
|
||||||
}
|
}
|
||||||
|
else if (format.compare("rgb24") == 0)
|
||||||
|
{
|
||||||
|
return PixelFormat::RGB24;
|
||||||
|
}
|
||||||
else if (format.compare("bgr24") == 0)
|
else if (format.compare("bgr24") == 0)
|
||||||
{
|
{
|
||||||
return PixelFormat::BGR24;
|
return PixelFormat::BGR24;
|
||||||
@ -80,6 +85,10 @@ inline QString pixelFormatToString(const PixelFormat& pixelFormat)
|
|||||||
{
|
{
|
||||||
return "BGR16";
|
return "BGR16";
|
||||||
}
|
}
|
||||||
|
else if (pixelFormat == PixelFormat::RGB24)
|
||||||
|
{
|
||||||
|
return "RGB24";
|
||||||
|
}
|
||||||
else if (pixelFormat == PixelFormat::BGR24)
|
else if (pixelFormat == PixelFormat::BGR24)
|
||||||
{
|
{
|
||||||
return "BGR24";
|
return "BGR24";
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
static PixelFormat GetPixelFormatForGuid(const GUID guid)
|
static PixelFormat GetPixelFormatForGuid(const GUID guid)
|
||||||
{
|
{
|
||||||
if (IsEqualGUID(guid, MFVideoFormat_RGB32)) return PixelFormat::RGB32;
|
if (IsEqualGUID(guid, MFVideoFormat_RGB32)) return PixelFormat::RGB32;
|
||||||
if (IsEqualGUID(guid, MFVideoFormat_RGB24)) return PixelFormat::BGR24;
|
if (IsEqualGUID(guid, MFVideoFormat_RGB24)) return PixelFormat::RGB24;
|
||||||
|
if (IsEqualGUID(guid, MFVideoFormat_BGR24)) return PixelFormat::BGR24;
|
||||||
if (IsEqualGUID(guid, MFVideoFormat_YUY2)) return PixelFormat::YUYV;
|
if (IsEqualGUID(guid, MFVideoFormat_YUY2)) return PixelFormat::YUYV;
|
||||||
if (IsEqualGUID(guid, MFVideoFormat_UYVY)) return PixelFormat::UYVY;
|
if (IsEqualGUID(guid, MFVideoFormat_UYVY)) return PixelFormat::UYVY;
|
||||||
#ifdef HAVE_TURBO_JPEG
|
#ifdef HAVE_TURBO_JPEG
|
||||||
@ -145,9 +146,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_TURBO_JPEG
|
#ifdef HAVE_TURBO_JPEG
|
||||||
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||||
#else
|
#else
|
||||||
if (_pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
if (_pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||||
#endif
|
#endif
|
||||||
pSample = TransformSample(_transform, pSample);
|
pSample = TransformSample(_transform, pSample);
|
||||||
|
|
||||||
@ -181,9 +182,9 @@ public:
|
|||||||
_bEOS = TRUE; // Reached the end of the stream.
|
_bEOS = TRUE; // Reached the end of the stream.
|
||||||
|
|
||||||
#ifdef HAVE_TURBO_JPEG
|
#ifdef HAVE_TURBO_JPEG
|
||||||
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||||
#else
|
#else
|
||||||
if (_pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
if (_pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||||
#endif
|
#endif
|
||||||
SAFE_RELEASE(pSample);
|
SAFE_RELEASE(pSample);
|
||||||
|
|
||||||
@ -196,9 +197,9 @@ public:
|
|||||||
{
|
{
|
||||||
_pixelformat = format;
|
_pixelformat = format;
|
||||||
#ifdef HAVE_TURBO_JPEG
|
#ifdef HAVE_TURBO_JPEG
|
||||||
if (format == PixelFormat::MJPEG || format == PixelFormat::BGR24 || format == PixelFormat::NO_CHANGE)
|
if (format == PixelFormat::MJPEG || format == PixelFormat::RGB24 || format == PixelFormat::BGR24 || format == PixelFormat::NO_CHANGE)
|
||||||
#else
|
#else
|
||||||
if (format == PixelFormat::BGR24 || format == PixelFormat::NO_CHANGE)
|
if (format == PixelFormat::RGB24 || format == PixelFormat::BGR24 || format == PixelFormat::NO_CHANGE)
|
||||||
#endif
|
#endif
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(ControlIDPropertyMap, _controlIDPropertyMap, (initCont
|
|||||||
static PixelFormat GetPixelFormat(const unsigned int format)
|
static PixelFormat GetPixelFormat(const unsigned int format)
|
||||||
{
|
{
|
||||||
if (format == V4L2_PIX_FMT_RGB32) return PixelFormat::RGB32;
|
if (format == V4L2_PIX_FMT_RGB32) return PixelFormat::RGB32;
|
||||||
|
if (format == V4L2_PIX_FMT_RGB24) return PixelFormat::RGB24;
|
||||||
if (format == V4L2_PIX_FMT_BGR24) return PixelFormat::BGR24;
|
if (format == V4L2_PIX_FMT_BGR24) return PixelFormat::BGR24;
|
||||||
if (format == V4L2_PIX_FMT_YUYV) return PixelFormat::YUYV;
|
if (format == V4L2_PIX_FMT_YUYV) return PixelFormat::YUYV;
|
||||||
if (format == V4L2_PIX_FMT_UYVY) return PixelFormat::UYVY;
|
if (format == V4L2_PIX_FMT_UYVY) return PixelFormat::UYVY;
|
||||||
@ -557,6 +558,10 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
|||||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32;
|
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PixelFormat::RGB24:
|
||||||
|
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
|
||||||
|
break;
|
||||||
|
|
||||||
case PixelFormat::BGR24:
|
case PixelFormat::BGR24:
|
||||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24;
|
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24;
|
||||||
break;
|
break;
|
||||||
@ -691,6 +696,14 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case V4L2_PIX_FMT_RGB24:
|
||||||
|
{
|
||||||
|
_pixelFormat = PixelFormat::RGB24;
|
||||||
|
_frameByteSize = _width * _height * 3;
|
||||||
|
Debug(_log, "Pixel format=RGB24");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case V4L2_PIX_FMT_BGR24:
|
case V4L2_PIX_FMT_BGR24:
|
||||||
{
|
{
|
||||||
_pixelFormat = PixelFormat::BGR24;
|
_pixelFormat = PixelFormat::BGR24;
|
||||||
@ -699,7 +712,6 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case V4L2_PIX_FMT_YUYV:
|
case V4L2_PIX_FMT_YUYV:
|
||||||
{
|
{
|
||||||
_pixelFormat = PixelFormat::YUYV;
|
_pixelFormat = PixelFormat::YUYV;
|
||||||
@ -743,9 +755,9 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
#ifdef HAVE_TURBO_JPEG
|
#ifdef HAVE_TURBO_JPEG
|
||||||
throw_exception("Only pixel formats RGB32, BGR24, YUYV, UYVY, NV12, I420 and MJPEG are supported");
|
throw_exception("Only pixel formats RGB32, RGB24, BGR24, YUYV, UYVY, NV12, I420 and MJPEG are supported");
|
||||||
#else
|
#else
|
||||||
throw_exception("Only pixel formats RGB32, BGR24, YUYV, UYVY, NV12 and I420 are supported");
|
throw_exception("Only pixel formats RGB32, RGB24, BGR24, YUYV, UYVY, NV12 and I420 are supported");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,22 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case PixelFormat::RGB24:
|
||||||
|
{
|
||||||
|
for (int yDest = yDestStart, ySource = cropTop + (_verticalDecimation >> 1); yDest <= yDestEnd; ySource += _verticalDecimation, ++yDest)
|
||||||
|
{
|
||||||
|
for (int xDest = xDestStart, xSource = cropLeft + (_horizontalDecimation >> 1); xDest <= xDestEnd; xSource += _horizontalDecimation, ++xDest)
|
||||||
|
{
|
||||||
|
ColorRgb & rgb = outputImage(abs(xDest), abs(yDest));
|
||||||
|
int index = lineLength * ySource + (xSource << 1) + xSource;
|
||||||
|
rgb.red = data[index ];
|
||||||
|
rgb.green = data[index+1];
|
||||||
|
rgb.blue = data[index+2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case PixelFormat::BGR24:
|
case PixelFormat::BGR24:
|
||||||
{
|
{
|
||||||
for (int yDest = yDestStart, ySource = cropTop + (_verticalDecimation >> 1); yDest <= yDestEnd; ySource += _verticalDecimation, ++yDest)
|
for (int yDest = yDestStart, ySource = cropTop + (_verticalDecimation >> 1); yDest <= yDestEnd; ySource += _verticalDecimation, ++yDest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user