summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-02-28 02:38:18 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-03-18 18:02:40 +0100
commitf28ca209602a93a3b7176d86a6329ddb2a341293 (patch)
tree95da5dcb930ed59aa031e812bc1c8b8dcf92a479 /src
parent9a1e71b8a169930c3be06fb71ab01db67588d689 (diff)
libcamera: Use PixelFormat instead of unsigned int where appropriate
Use the PixelFormat instead of unsigned int where a pixel format is to be used. PixelFormat is defined as an unsigned int but is about to be turned into a class to add functionality. There is no functional change in this patch. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/cam/main.cpp2
-rw-r--r--src/gstreamer/gstlibcamera-utils.cpp10
-rw-r--r--src/libcamera/pipeline/ipu3/ipu3.cpp2
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp2
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp4
-rw-r--r--src/libcamera/pipeline/vimc.cpp4
-rw-r--r--src/qcam/format_converter.cpp2
-rw-r--r--src/qcam/format_converter.h6
-rw-r--r--src/qcam/viewfinder.cpp2
-rw-r--r--src/qcam/viewfinder.h6
10 files changed, 22 insertions, 18 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index ea6f7914..af516f1c 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -303,7 +303,7 @@ int CamApp::infoConfiguration()
std::cout << index << ": " << cfg.toString() << std::endl;
const StreamFormats &formats = cfg.formats();
- for (unsigned int pixelformat : formats.pixelformats()) {
+ for (PixelFormat pixelformat : formats.pixelformats()) {
std::cout << " * Pixelformat: 0x" << std::hex
<< std::setw(8) << pixelformat << " "
<< formats.range(pixelformat).toString()
diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index 44a993fa..3b3973bc 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -79,16 +79,16 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)
{
GstCaps *caps = gst_caps_new_empty();
- for (unsigned int fourcc : formats.pixelformats()) {
- g_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(fourcc);
+ for (PixelFormat pixelformat : formats.pixelformats()) {
+ g_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(pixelformat);
if (!bare_s) {
GST_WARNING("Unsupported DRM format %" GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS(fourcc));
+ GST_FOURCC_ARGS(pixelformat));
continue;
}
- for (const Size &size : formats.sizes(fourcc)) {
+ for (const Size &size : formats.sizes(pixelformat)) {
GstStructure *s = gst_structure_copy(bare_s);
gst_structure_set(s,
"width", G_TYPE_INT, size.width,
@@ -97,7 +97,7 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)
gst_caps_append_structure(caps, s);
}
- const SizeRange &range = formats.range(fourcc);
+ const SizeRange &range = formats.range(pixelformat);
if (range.hStep && range.vStep) {
GstStructure *s = gst_structure_copy(bare_s);
GValue val = G_VALUE_INIT;
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 387bb070..33f97b34 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -349,7 +349,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
for (unsigned int i = 0; i < config_.size(); ++i) {
StreamConfiguration &cfg = config_[i];
- const unsigned int pixelFormat = cfg.pixelFormat;
+ const PixelFormat pixelFormat = cfg.pixelFormat;
const Size size = cfg.size;
const IPU3Stream *stream;
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 13433b21..11e8c494 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -433,7 +433,7 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,
CameraConfiguration::Status RkISP1CameraConfiguration::validate()
{
- static const std::array<unsigned int, 8> formats{
+ static const std::array<PixelFormat, 8> formats{
DRM_FORMAT_YUYV,
DRM_FORMAT_YVYU,
DRM_FORMAT_VYUY,
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index 29afb121..cf419e8b 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -107,10 +107,10 @@ CameraConfiguration::Status UVCCameraConfiguration::validate()
StreamConfiguration &cfg = config_[0];
const StreamFormats &formats = cfg.formats();
- const unsigned int pixelFormat = cfg.pixelFormat;
+ const PixelFormat pixelFormat = cfg.pixelFormat;
const Size size = cfg.size;
- const std::vector<unsigned int> pixelFormats = formats.pixelformats();
+ const std::vector<PixelFormat> pixelFormats = formats.pixelformats();
auto iter = std::find(pixelFormats.begin(), pixelFormats.end(), pixelFormat);
if (iter == pixelFormats.end()) {
cfg.pixelFormat = pixelFormats.front();
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
index 5d3d12fe..5b846cf5 100644
--- a/src/libcamera/pipeline/vimc.cpp
+++ b/src/libcamera/pipeline/vimc.cpp
@@ -106,7 +106,7 @@ private:
namespace {
-constexpr std::array<unsigned int, 3> pixelformats{
+constexpr std::array<PixelFormat, 3> pixelformats{
DRM_FORMAT_RGB888,
DRM_FORMAT_BGR888,
DRM_FORMAT_BGRA8888,
@@ -177,7 +177,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
ImageFormats formats;
- for (unsigned int pixelformat : pixelformats) {
+ for (PixelFormat pixelformat : pixelformats) {
/* The scaler hardcodes a x3 scale-up ratio. */
std::vector<SizeRange> sizes{
SizeRange{ 48, 48, 4096, 2160 }
diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp
index 46041434..d4a66f38 100644
--- a/src/qcam/format_converter.cpp
+++ b/src/qcam/format_converter.cpp
@@ -27,7 +27,7 @@
#define CLIP(x) CLAMP(x,0,255)
#endif
-int FormatConverter::configure(unsigned int format, unsigned int width,
+int FormatConverter::configure(libcamera::PixelFormat format, unsigned int width,
unsigned int height)
{
switch (format) {
diff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h
index 391e6a44..ff488b99 100644
--- a/src/qcam/format_converter.h
+++ b/src/qcam/format_converter.h
@@ -9,12 +9,14 @@
#include <stddef.h>
+#include <libcamera/pixelformats.h>
+
class QImage;
class FormatConverter
{
public:
- int configure(unsigned int format, unsigned int width,
+ int configure(libcamera::PixelFormat format, unsigned int width,
unsigned int height);
void convert(const unsigned char *src, size_t size, QImage *dst);
@@ -31,7 +33,7 @@ private:
void convertRGB(const unsigned char *src, unsigned char *dst);
void convertYUV(const unsigned char *src, unsigned char *dst);
- unsigned int format_;
+ libcamera::PixelFormat format_;
unsigned int width_;
unsigned int height_;
diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp
index d51eebb1..0ebb8edd 100644
--- a/src/qcam/viewfinder.cpp
+++ b/src/qcam/viewfinder.cpp
@@ -44,7 +44,7 @@ QImage ViewFinder::getCurrentImage()
return image_->copy();
}
-int ViewFinder::setFormat(unsigned int format, unsigned int width,
+int ViewFinder::setFormat(libcamera::PixelFormat format, unsigned int width,
unsigned int height)
{
int ret;
diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h
index 2ba28b60..2668aa44 100644
--- a/src/qcam/viewfinder.h
+++ b/src/qcam/viewfinder.h
@@ -10,6 +10,8 @@
#include <QMutex>
#include <QWidget>
+#include <libcamera/pixelformats.h>
+
#include "format_converter.h"
class QImage;
@@ -20,7 +22,7 @@ public:
ViewFinder(QWidget *parent);
~ViewFinder();
- int setFormat(unsigned int format, unsigned int width,
+ int setFormat(libcamera::PixelFormat format, unsigned int width,
unsigned int height);
void display(const unsigned char *rgb, size_t size);
@@ -31,7 +33,7 @@ protected:
QSize sizeHint() const override;
private:
- unsigned int format_;
+ libcamera::PixelFormat format_;
unsigned int width_;
unsigned int height_;