RGB24 and BGR24 cleanup

This commit is contained in:
LordGrey
2024-05-31 18:56:49 +02:00
parent 897e4aac8a
commit a5b42e3024
4 changed files with 48 additions and 10 deletions

View File

@@ -54,6 +54,7 @@ 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_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 +558,10 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32;
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 +696,14 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
}
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 +712,6 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
}
break;
case V4L2_PIX_FMT_YUYV:
{
_pixelFormat = PixelFormat::YUYV;
@@ -743,9 +755,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, 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, RGB24, BGR24, YUYV, UYVY, NV12 and I420 are supported");
#endif
return;
}