mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-24 00:55:07 +03:00
libcamera: bayer_format: Add PixelFormat conversion helpers to BayerFormat class
Add BayerFormat::toPixelFormat() and BayerFormat::fromPixelFormat() helper functions to convert between BayerFormat and PixelFormat types. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [Kieran: Minor checkstyle fix] Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
16ab13eaa9
commit
91bd175c8f
2 changed files with 33 additions and 0 deletions
|
@ -10,6 +10,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <libcamera/pixel_format.h>
|
||||||
|
|
||||||
#include "libcamera/internal/v4l2_pixelformat.h"
|
#include "libcamera/internal/v4l2_pixelformat.h"
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
@ -50,6 +52,8 @@ public:
|
||||||
|
|
||||||
V4L2PixelFormat toV4L2PixelFormat() const;
|
V4L2PixelFormat toV4L2PixelFormat() const;
|
||||||
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format);
|
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format);
|
||||||
|
PixelFormat toPixelFormat() const;
|
||||||
|
static BayerFormat fromPixelFormat(PixelFormat format);
|
||||||
BayerFormat transform(Transform t) const;
|
BayerFormat transform(Transform t) const;
|
||||||
|
|
||||||
Order order;
|
Order order;
|
||||||
|
|
|
@ -307,6 +307,35 @@ BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)
|
||||||
return BayerFormat();
|
return BayerFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Convert a BayerFormat into the corresponding PixelFormat
|
||||||
|
* \return The PixelFormat corresponding to this BayerFormat
|
||||||
|
*/
|
||||||
|
PixelFormat BayerFormat::toPixelFormat() const
|
||||||
|
{
|
||||||
|
const auto it = bayerToFormat.find(*this);
|
||||||
|
if (it != bayerToFormat.end())
|
||||||
|
return it->second.pixelFormat;
|
||||||
|
|
||||||
|
return PixelFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Convert a PixelFormat into the corresponding BayerFormat
|
||||||
|
* \return The BayerFormat corresponding to this PixelFormat
|
||||||
|
*/
|
||||||
|
BayerFormat BayerFormat::fromPixelFormat(PixelFormat format)
|
||||||
|
{
|
||||||
|
const auto it = std::find_if(bayerToFormat.begin(), bayerToFormat.end(),
|
||||||
|
[format](const auto &i) {
|
||||||
|
return i.second.pixelFormat == format;
|
||||||
|
});
|
||||||
|
if (it != bayerToFormat.end())
|
||||||
|
return it->first;
|
||||||
|
|
||||||
|
return BayerFormat();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Apply a transform to this BayerFormat
|
* \brief Apply a transform to this BayerFormat
|
||||||
* \param[in] t The transform to apply
|
* \param[in] t The transform to apply
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue