Message ID | 20220829100414.28404-3-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thank you for the patch. On 8/29/22 3:34 PM, Laurent Pinchart via libcamera-devel wrote: > To prepare for color space support in the viewfinder, pass the color > space to the setFormat() function. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/qcam/main_window.cpp | 6 +++++- > src/qcam/viewfinder.h | 2 ++ > src/qcam/viewfinder_gl.cpp | 5 +++-- > src/qcam/viewfinder_gl.h | 1 + > src/qcam/viewfinder_qt.cpp | 5 +++-- > src/qcam/viewfinder_qt.h | 1 + > 6 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp > index 7433d647e8a0..addf0d96daf4 100644 > --- a/src/qcam/main_window.cpp > +++ b/src/qcam/main_window.cpp > @@ -447,9 +447,13 @@ int MainWindow::startCapture() > else > rawStream_ = nullptr; > > - /* Configure the viewfinder. */ > + /* > + * Configure the viewfinder. If no color space is reported, default to > + * sYCC. > + */ If there's a mismatch between the pixelformat and sYCC default, we can be sure - it will be adjusted accordingly, provided we will have logic for adjustment merged in.. soonish. Good to see.. Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > ret = viewfinder_->setFormat(vfConfig.pixelFormat, > QSize(vfConfig.size.width, vfConfig.size.height), > + vfConfig.colorSpace.value_or(ColorSpace::Sycc), > vfConfig.stride); > if (ret < 0) { > qInfo() << "Failed to set viewfinder format"; > diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h > index 260074aed440..a57446e85951 100644 > --- a/src/qcam/viewfinder.h > +++ b/src/qcam/viewfinder.h > @@ -11,6 +11,7 @@ > #include <QList> > #include <QSize> > > +#include <libcamera/color_space.h> > #include <libcamera/formats.h> > #include <libcamera/framebuffer.h> > > @@ -24,6 +25,7 @@ public: > virtual const QList<libcamera::PixelFormat> &nativeFormats() const = 0; > > virtual int setFormat(const libcamera::PixelFormat &format, const QSize &size, > + const libcamera::ColorSpace &colorSpace, > unsigned int stride) = 0; > virtual void render(libcamera::FrameBuffer *buffer, Image *image) = 0; > virtual void stop() = 0; > diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp > index 3ae8b03accb5..ec295b6de0dd 100644 > --- a/src/qcam/viewfinder_gl.cpp > +++ b/src/qcam/viewfinder_gl.cpp > @@ -71,8 +71,9 @@ const QList<libcamera::PixelFormat> &ViewFinderGL::nativeFormats() const > return supportedFormats; > } > > -int ViewFinderGL::setFormat(const libcamera::PixelFormat &format, > - const QSize &size, unsigned int stride) > +int ViewFinderGL::setFormat(const libcamera::PixelFormat &format, const QSize &size, > + [[maybe_unused]] const libcamera::ColorSpace &colorSpace, > + unsigned int stride) > { > if (format != format_) { > /* > diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h > index 0a9275baf9b9..798830a31cd2 100644 > --- a/src/qcam/viewfinder_gl.h > +++ b/src/qcam/viewfinder_gl.h > @@ -39,6 +39,7 @@ public: > const QList<libcamera::PixelFormat> &nativeFormats() const override; > > int setFormat(const libcamera::PixelFormat &format, const QSize &size, > + const libcamera::ColorSpace &colorSpace, > unsigned int stride) override; > void render(libcamera::FrameBuffer *buffer, Image *image) override; > void stop() override; > diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp > index 7a6a60c96393..c20fd6bc8fc2 100644 > --- a/src/qcam/viewfinder_qt.cpp > +++ b/src/qcam/viewfinder_qt.cpp > @@ -54,8 +54,9 @@ const QList<libcamera::PixelFormat> &ViewFinderQt::nativeFormats() const > return formats; > } > > -int ViewFinderQt::setFormat(const libcamera::PixelFormat &format, > - const QSize &size, unsigned int stride) > +int ViewFinderQt::setFormat(const libcamera::PixelFormat &format, const QSize &size, > + [[maybe_unused]] const libcamera::ColorSpace &colorSpace, > + unsigned int stride) > { > image_ = QImage(); > > diff --git a/src/qcam/viewfinder_qt.h b/src/qcam/viewfinder_qt.h > index 8c62145211d1..eb3a99882d19 100644 > --- a/src/qcam/viewfinder_qt.h > +++ b/src/qcam/viewfinder_qt.h > @@ -32,6 +32,7 @@ public: > const QList<libcamera::PixelFormat> &nativeFormats() const override; > > int setFormat(const libcamera::PixelFormat &format, const QSize &size, > + const libcamera::ColorSpace &colorSpace, > unsigned int stride) override; > void render(libcamera::FrameBuffer *buffer, Image *image) override; > void stop() override;
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 7433d647e8a0..addf0d96daf4 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -447,9 +447,13 @@ int MainWindow::startCapture() else rawStream_ = nullptr; - /* Configure the viewfinder. */ + /* + * Configure the viewfinder. If no color space is reported, default to + * sYCC. + */ ret = viewfinder_->setFormat(vfConfig.pixelFormat, QSize(vfConfig.size.width, vfConfig.size.height), + vfConfig.colorSpace.value_or(ColorSpace::Sycc), vfConfig.stride); if (ret < 0) { qInfo() << "Failed to set viewfinder format"; diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h index 260074aed440..a57446e85951 100644 --- a/src/qcam/viewfinder.h +++ b/src/qcam/viewfinder.h @@ -11,6 +11,7 @@ #include <QList> #include <QSize> +#include <libcamera/color_space.h> #include <libcamera/formats.h> #include <libcamera/framebuffer.h> @@ -24,6 +25,7 @@ public: virtual const QList<libcamera::PixelFormat> &nativeFormats() const = 0; virtual int setFormat(const libcamera::PixelFormat &format, const QSize &size, + const libcamera::ColorSpace &colorSpace, unsigned int stride) = 0; virtual void render(libcamera::FrameBuffer *buffer, Image *image) = 0; virtual void stop() = 0; diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp index 3ae8b03accb5..ec295b6de0dd 100644 --- a/src/qcam/viewfinder_gl.cpp +++ b/src/qcam/viewfinder_gl.cpp @@ -71,8 +71,9 @@ const QList<libcamera::PixelFormat> &ViewFinderGL::nativeFormats() const return supportedFormats; } -int ViewFinderGL::setFormat(const libcamera::PixelFormat &format, - const QSize &size, unsigned int stride) +int ViewFinderGL::setFormat(const libcamera::PixelFormat &format, const QSize &size, + [[maybe_unused]] const libcamera::ColorSpace &colorSpace, + unsigned int stride) { if (format != format_) { /* diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h index 0a9275baf9b9..798830a31cd2 100644 --- a/src/qcam/viewfinder_gl.h +++ b/src/qcam/viewfinder_gl.h @@ -39,6 +39,7 @@ public: const QList<libcamera::PixelFormat> &nativeFormats() const override; int setFormat(const libcamera::PixelFormat &format, const QSize &size, + const libcamera::ColorSpace &colorSpace, unsigned int stride) override; void render(libcamera::FrameBuffer *buffer, Image *image) override; void stop() override; diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp index 7a6a60c96393..c20fd6bc8fc2 100644 --- a/src/qcam/viewfinder_qt.cpp +++ b/src/qcam/viewfinder_qt.cpp @@ -54,8 +54,9 @@ const QList<libcamera::PixelFormat> &ViewFinderQt::nativeFormats() const return formats; } -int ViewFinderQt::setFormat(const libcamera::PixelFormat &format, - const QSize &size, unsigned int stride) +int ViewFinderQt::setFormat(const libcamera::PixelFormat &format, const QSize &size, + [[maybe_unused]] const libcamera::ColorSpace &colorSpace, + unsigned int stride) { image_ = QImage(); diff --git a/src/qcam/viewfinder_qt.h b/src/qcam/viewfinder_qt.h index 8c62145211d1..eb3a99882d19 100644 --- a/src/qcam/viewfinder_qt.h +++ b/src/qcam/viewfinder_qt.h @@ -32,6 +32,7 @@ public: const QList<libcamera::PixelFormat> &nativeFormats() const override; int setFormat(const libcamera::PixelFormat &format, const QSize &size, + const libcamera::ColorSpace &colorSpace, unsigned int stride) override; void render(libcamera::FrameBuffer *buffer, Image *image) override; void stop() override;
To prepare for color space support in the viewfinder, pass the color space to the setFormat() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/qcam/main_window.cpp | 6 +++++- src/qcam/viewfinder.h | 2 ++ src/qcam/viewfinder_gl.cpp | 5 +++-- src/qcam/viewfinder_gl.h | 1 + src/qcam/viewfinder_qt.cpp | 5 +++-- src/qcam/viewfinder_qt.h | 1 + 6 files changed, 15 insertions(+), 5 deletions(-)