diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/bayer_format.cpp | 18 | ||||
-rw-r--r-- | src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index a6a40be0..9eb83898 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -7,6 +7,7 @@ #include "libcamera/internal/bayer_format.h" +#include <algorithm> #include <map> #include <unordered_map> @@ -273,6 +274,23 @@ V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const } /** + * \brief Convert \a v4l2Format to the corresponding BayerFormat + * \param[in] v4l2Format The raw format to convert into a BayerFormat + * \return The BayerFormat corresponding to \a v4l2Format + */ +BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) +{ + auto it = std::find_if(bayerToV4l2.begin(), bayerToV4l2.end(), + [v4l2Format](const auto &i) { + return i.second == v4l2Format; + }); + if (it != bayerToV4l2.end()) + return it->first; + + return BayerFormat(); +} + +/** * \brief Apply a transform to this BayerFormat * \param[in] t The transform to apply * diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 5ad12d99..0f802f6c 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -357,7 +357,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() */ V4L2PixelFormat fourcc = sensorFormat.fourcc; if (data_->flipsAlterBayerOrder_) { - BayerFormat bayer(fourcc); + BayerFormat bayer = BayerFormat::fromV4L2PixelFormat(fourcc); bayer.order = data_->nativeBayerOrder_; bayer = bayer.transform(combined); fourcc = bayer.toV4L2PixelFormat(); @@ -1001,7 +1001,7 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) BayerFormat bayerFormat; for (const auto &iter : dev->formats()) { V4L2PixelFormat v4l2Format = iter.first; - bayerFormat = BayerFormat(v4l2Format); + bayerFormat = BayerFormat::fromV4L2PixelFormat(v4l2Format); if (bayerFormat.isValid()) break; } |