From 1a8e2ca27cea29a8e5576e4e35622bc4a787c213 Mon Sep 17 00:00:00 2001 From: SputnikElf Date: Mon, 30 Dec 2019 22:27:02 +0100 Subject: [PATCH] VType as QString --- include/grabber/V4L2Grabber.h | 4 ++-- include/grabber/V4L2Wrapper.h | 2 +- include/hyperion/Grabber.h | 2 +- libsrc/grabber/v4l2/V4L2Grabber.cpp | 35 ++++++++++++++++++++--------- libsrc/grabber/v4l2/V4L2Wrapper.cpp | 2 +- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/grabber/V4L2Grabber.h b/include/grabber/V4L2Grabber.h index 13488e81..a9099ee0 100644 --- a/include/grabber/V4L2Grabber.h +++ b/include/grabber/V4L2Grabber.h @@ -85,7 +85,7 @@ public: virtual void setGrabberFixValues( int width, int height, - int vtype); + QString vtype); /// /// @brief overwrite Grabber.h implementation @@ -216,6 +216,6 @@ private: bool _grabberFixEnabled; int _gf_width; int _gf_height; - int _gf_vtype; + QString _gf_vtype; }; diff --git a/include/grabber/V4L2Wrapper.h b/include/grabber/V4L2Wrapper.h index 50d6f58d..7490ceed 100644 --- a/include/grabber/V4L2Wrapper.h +++ b/include/grabber/V4L2Wrapper.h @@ -26,7 +26,7 @@ public slots: void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax); void setSignalDetectionEnable(bool enable); void setGrabberFixEnable(bool enable); - void setGrabberFixValues(int width, int height, string vtype); + void setGrabberFixValues(int width, int height, QString vtype); void setDeviceVideoStandard(QString device, VideoStandard videoStandard); signals: diff --git a/include/hyperion/Grabber.h b/include/hyperion/Grabber.h index 90bf1fea..236faeae 100644 --- a/include/hyperion/Grabber.h +++ b/include/hyperion/Grabber.h @@ -70,7 +70,7 @@ public: virtual void setGrabberFixValues( int width, int height, - int vtype) {}; + QString vtype) {}; /// /// @brief Apply device and videoStanded (used from v4l) diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index 96ff26f1..3810188b 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -210,13 +210,13 @@ void V4L2Grabber::setSignalDetectionOffset(double horizontalMin, double vertical Info(_log, "Signal detection area set to: %f,%f x %f,%f", _x_frac_min, _y_frac_min, _x_frac_max, _y_frac_max ); } -void V4L2Grabber::setGrabberFixValues(int width, int height, string vtype) +void V4L2Grabber::setGrabberFixValues(int width, int height, QString vtype) { _gf_width = width; _gf_height = height; _gf_vtype = vtype; - Warning(_log, "Grabber fix set to: %d x %d, %s", _gf_width, _gf_height, _gf_vtype); + Warning(_log, "Grabber fix set to: %d x %d, %s", _gf_width, _gf_height, QSTRING_CSTR(_gf_vtype)); } bool V4L2Grabber::start() @@ -628,17 +628,30 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input) fmtdesc.index++; } // RPi Camera V1.3 & V2.1 workaround resolution and pixelformat - Warning(_log, "vor _grabberFixEnabled"); if (_grabberFixEnabled) { - Warning(_log, "_grabberFixEnabled"); - //if (max_width == 2592 || max_width == 3280) { - max_width = _gf_width; - max_height = _gf_height; + max_width = _gf_width; + max_height = _gf_height; + + QString pixformat = _gf_vtype.toLower(); + if (pixformat == "yuyv") + { + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; + } + else if (pixformat == "uyvy") + { fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY; - Warning(_log, "wxh %d x %d", max_width, max_height); - //} - } else { - Warning(_log, "nicht _grabberFixEnabled"); + } + else if (pixformat == "rgb32") + { + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32; + } +#ifdef HAVE_JPEG + else if (pixformat == "mjpeg") + { + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG; + } +#endif + Warning(_log, "wxh %d x %d, vtype %s", max_width, max_height, QSTRING_CSTR(pixformat.toUpper())); } // set the settings diff --git a/libsrc/grabber/v4l2/V4L2Wrapper.cpp b/libsrc/grabber/v4l2/V4L2Wrapper.cpp index af1c8e33..fb92c2b2 100644 --- a/libsrc/grabber/v4l2/V4L2Wrapper.cpp +++ b/libsrc/grabber/v4l2/V4L2Wrapper.cpp @@ -52,7 +52,7 @@ void V4L2Wrapper::setSignalDetectionOffset(double verticalMin, double horizontal { _grabber.setSignalDetectionOffset(verticalMin, horizontalMin, verticalMax, horizontalMax); } -void V4L2Wrapper::setGrabberFixValues(int width, int height, string vtype) +void V4L2Wrapper::setGrabberFixValues(int width, int height, QString vtype) { _grabber.setGrabberFixValues(width, height, vtype); }