mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
RGB24 and BGR24 cleanup (#1749)
* RGB24 and BGR24 cleanup * Fix MF-Grabber * Add BGR32 to V42L Grabber * Add BGR32 to V42L Grabber * Add BGR16 to V42L * Revert "Add BGR16 to V42L" This reverts commit 42975380f47a30a09f06d7dee7440b64b93aa305.
This commit is contained in:
parent
76fff98f5c
commit
15c305b8f2
@ -10,6 +10,7 @@ enum class PixelFormat {
|
||||
YUYV,
|
||||
UYVY,
|
||||
BGR16,
|
||||
RGB24,
|
||||
BGR24,
|
||||
RGB32,
|
||||
BGR32,
|
||||
@ -36,6 +37,10 @@ inline PixelFormat parsePixelFormat(const QString& pixelFormat)
|
||||
{
|
||||
return PixelFormat::BGR16;
|
||||
}
|
||||
else if (format.compare("rgb24") == 0)
|
||||
{
|
||||
return PixelFormat::RGB24;
|
||||
}
|
||||
else if (format.compare("bgr24") == 0)
|
||||
{
|
||||
return PixelFormat::BGR24;
|
||||
@ -80,6 +85,10 @@ inline QString pixelFormatToString(const PixelFormat& pixelFormat)
|
||||
{
|
||||
return "BGR16";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::RGB24)
|
||||
{
|
||||
return "RGB24";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::BGR24)
|
||||
{
|
||||
return "BGR24";
|
||||
|
@ -27,7 +27,7 @@
|
||||
static PixelFormat GetPixelFormatForGuid(const GUID guid)
|
||||
{
|
||||
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_YUY2)) return PixelFormat::YUYV;
|
||||
if (IsEqualGUID(guid, MFVideoFormat_UYVY)) return PixelFormat::UYVY;
|
||||
#ifdef HAVE_TURBO_JPEG
|
||||
@ -145,9 +145,9 @@ public:
|
||||
}
|
||||
|
||||
#ifdef HAVE_TURBO_JPEG
|
||||
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
#else
|
||||
if (_pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
if (_pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
#endif
|
||||
pSample = TransformSample(_transform, pSample);
|
||||
|
||||
@ -181,9 +181,9 @@ public:
|
||||
_bEOS = TRUE; // Reached the end of the stream.
|
||||
|
||||
#ifdef HAVE_TURBO_JPEG
|
||||
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
if (_pixelformat != PixelFormat::MJPEG && _pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
#else
|
||||
if (_pixelformat != PixelFormat::BGR24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
if (_pixelformat != PixelFormat::RGB24 && _pixelformat != PixelFormat::NO_CHANGE)
|
||||
#endif
|
||||
SAFE_RELEASE(pSample);
|
||||
|
||||
@ -196,9 +196,9 @@ public:
|
||||
{
|
||||
_pixelformat = format;
|
||||
#ifdef HAVE_TURBO_JPEG
|
||||
if (format == PixelFormat::MJPEG || format == PixelFormat::BGR24 || format == PixelFormat::NO_CHANGE)
|
||||
if (format == PixelFormat::MJPEG || format == PixelFormat::RGB24 || format == PixelFormat::NO_CHANGE)
|
||||
#else
|
||||
if (format == PixelFormat::BGR24 || format == PixelFormat::NO_CHANGE)
|
||||
if (format == PixelFormat::RGB24 || format == PixelFormat::NO_CHANGE)
|
||||
#endif
|
||||
return S_OK;
|
||||
|
||||
@ -392,10 +392,10 @@ private:
|
||||
private:
|
||||
long _nRefCount;
|
||||
CRITICAL_SECTION _critsec;
|
||||
MFGrabber* _grabber;
|
||||
MFGrabber* _grabber;
|
||||
BOOL _bEOS;
|
||||
HRESULT _hrStatus;
|
||||
IMFTransform* _transform;
|
||||
IMFTransform* _transform;
|
||||
PixelFormat _pixelformat;
|
||||
std::atomic<bool> _isBusy;
|
||||
};
|
||||
|
@ -54,6 +54,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(ControlIDPropertyMap, _controlIDPropertyMap, (initCont
|
||||
static PixelFormat GetPixelFormat(const unsigned int format)
|
||||
{
|
||||
if (format == V4L2_PIX_FMT_RGB32) return PixelFormat::RGB32;
|
||||
if (format == V4L2_PIX_FMT_BGR32) return PixelFormat::BGR32;
|
||||
if (format == V4L2_PIX_FMT_RGB24) return PixelFormat::RGB24;
|
||||
if (format == V4L2_PIX_FMT_BGR24) return PixelFormat::BGR24;
|
||||
if (format == V4L2_PIX_FMT_YUYV) return PixelFormat::YUYV;
|
||||
if (format == V4L2_PIX_FMT_UYVY) return PixelFormat::UYVY;
|
||||
@ -557,6 +559,14 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32;
|
||||
break;
|
||||
|
||||
case PixelFormat::BGR32:
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR32;
|
||||
break;
|
||||
|
||||
case PixelFormat::RGB24:
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
|
||||
break;
|
||||
|
||||
case PixelFormat::BGR24:
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24;
|
||||
break;
|
||||
@ -691,6 +701,22 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
||||
}
|
||||
break;
|
||||
|
||||
case V4L2_PIX_FMT_BGR32:
|
||||
{
|
||||
_pixelFormat = PixelFormat::BGR32;
|
||||
_frameByteSize = _width * _height * 4;
|
||||
Debug(_log, "Pixel format=BGR32");
|
||||
}
|
||||
break;
|
||||
|
||||
case V4L2_PIX_FMT_RGB24:
|
||||
{
|
||||
_pixelFormat = PixelFormat::RGB24;
|
||||
_frameByteSize = _width * _height * 3;
|
||||
Debug(_log, "Pixel format=RGB24");
|
||||
}
|
||||
break;
|
||||
|
||||
case V4L2_PIX_FMT_BGR24:
|
||||
{
|
||||
_pixelFormat = PixelFormat::BGR24;
|
||||
@ -699,7 +725,6 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case V4L2_PIX_FMT_YUYV:
|
||||
{
|
||||
_pixelFormat = PixelFormat::YUYV;
|
||||
@ -743,9 +768,9 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
|
||||
|
||||
default:
|
||||
#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, BGR32, RGB24, BGR24, YUYV, UYVY, NV12, I420 and MJPEG are supported");
|
||||
#else
|
||||
throw_exception("Only pixel formats RGB32, BGR24, YUYV, UYVY, NV12 and I420 are supported");
|
||||
throw_exception("Only pixel formats RGB32, BGR32, RGB24, BGR24, YUYV, UYVY, NV12 and I420 are supported");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -133,6 +133,22 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
|
||||
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:
|
||||
{
|
||||
for (int yDest = yDestStart, ySource = cropTop + (_verticalDecimation >> 1); yDest <= yDestEnd; ySource += _verticalDecimation, ++yDest)
|
||||
|
Loading…
x
Reference in New Issue
Block a user