From 83e434b2dccbcc3c9653767dce000052e1e52297 Mon Sep 17 00:00:00 2001 From: Sebastian Fricke Date: Tue, 26 Jan 2021 19:48:50 +0100 Subject: libcamera: bayer_format: Add the fromV4L2PixelFormat function Add a static member function to get the corresponding BayerFormat from a given V4L2PixelFormat. The motivation behind this patch is to align the overall structure of the BayerFormat class with other parts of the code base, such as the V4L2PixelFormat class. The downside of this change is a slightly worse time complexity, but the upside is a smaller codebase and lower memory consumption. As the function is probably not used very frequently, I tend to favor the mentioned upsides. Reviewed-by: Laurent Pinchart Signed-off-by: Sebastian Fricke Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcamera/pipeline/raspberrypi') 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; } -- cgit v1.2.1