summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-23 04:50:14 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-24 14:49:52 +0200
commit8bd4f20193abafdd8bc25b9b0d37a0aced8aa2cb (patch)
tree62627fbb05ba36ba841474978317c970712b8346
parent798b7ac9692746ea9df15923f3b00b622c7f2ed4 (diff)
qcam: viewfinder: Report the natively supported pixel formats
Expose the pixel formats natively supported by the viewfinder, to allow selection of stream formats that would minimize usage of software conversion. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/qcam/viewfinder.cpp22
-rw-r--r--src/qcam/viewfinder.h3
2 files changed, 17 insertions, 8 deletions
diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp
index df5ee5ee..0d68f62e 100644
--- a/src/qcam/viewfinder.cpp
+++ b/src/qcam/viewfinder.cpp
@@ -19,16 +19,16 @@
#include "format_converter.h"
-static const QMap<uint32_t, QImage::Format> nativeFormats
+static const QMap<libcamera::PixelFormat, QImage::Format> nativeFormats
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
- { DRM_FORMAT_ABGR8888, QImage::Format_RGBA8888 },
+ { libcamera::PixelFormat{ DRM_FORMAT_ABGR8888 }, QImage::Format_RGBA8888 },
#endif
- { DRM_FORMAT_ARGB8888, QImage::Format_RGB32 },
+ { libcamera::PixelFormat{ DRM_FORMAT_ARGB8888 }, QImage::Format_RGB32 },
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- { DRM_FORMAT_BGR888, QImage::Format_BGR888 },
+ { libcamera::PixelFormat{ DRM_FORMAT_BGR888 }, QImage::Format_BGR888 },
#endif
- { DRM_FORMAT_RGB888, QImage::Format_RGB888 },
+ { libcamera::PixelFormat{ DRM_FORMAT_RGB888 }, QImage::Format_RGB888 },
};
ViewFinder::ViewFinder(QWidget *parent)
@@ -41,6 +41,12 @@ ViewFinder::~ViewFinder()
{
}
+const QList<libcamera::PixelFormat> &ViewFinder::nativeFormats() const
+{
+ static const QList<libcamera::PixelFormat> formats = ::nativeFormats.keys();
+ return formats;
+}
+
int ViewFinder::setFormat(const libcamera::PixelFormat &format,
const QSize &size)
{
@@ -50,7 +56,7 @@ int ViewFinder::setFormat(const libcamera::PixelFormat &format,
* If format conversion is needed, configure the converter and allocate
* the destination image.
*/
- if (!nativeFormats.contains(format)) {
+ if (!::nativeFormats.contains(format)) {
int ret = converter_.configure(format, size);
if (ret < 0)
return ret;
@@ -83,7 +89,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)
{
QMutexLocker locker(&mutex_);
- if (nativeFormats.contains(format_)) {
+ if (::nativeFormats.contains(format_)) {
/*
* If the frame format is identical to the display
* format, create a QImage that references the frame
@@ -96,7 +102,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)
*/
image_ = QImage(memory, size_.width(), size_.height(),
size / size_.height(),
- nativeFormats[format_]);
+ ::nativeFormats[format_]);
std::swap(buffer, buffer_);
} else {
/*
diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h
index 1a27f99e..b3f1d25d 100644
--- a/src/qcam/viewfinder.h
+++ b/src/qcam/viewfinder.h
@@ -10,6 +10,7 @@
#include <stddef.h>
#include <QIcon>
+#include <QList>
#include <QImage>
#include <QMutex>
#include <QSize>
@@ -35,6 +36,8 @@ public:
ViewFinder(QWidget *parent);
~ViewFinder();
+ const QList<libcamera::PixelFormat> &nativeFormats() const;
+
int setFormat(const libcamera::PixelFormat &format, const QSize &size);
void render(libcamera::FrameBuffer *buffer, MappedBuffer *map);
void stop();