diff options
author | David Plowman <david.plowman@raspberrypi.com> | 2020-09-07 08:15:59 +0100 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-09-29 11:43:06 +0100 |
commit | 78cbd6a93fbb49a20b97793b925769eefb52e516 (patch) | |
tree | 4a95407d8f764ff61cf4bd8efb8aaa4c4e1a567c /include | |
parent | edf19e4c72842704933c66f519e708107a14c47b (diff) |
libcamera: Add BayerFormat type
This type encodes BayerFormats in an explicit way, that makes them
easier to use than some of the other more opaque type formats. This
makes the BayerFormat useful for editing or manipulating Bayer types
more easily.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/internal/bayer_format.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h new file mode 100644 index 00000000..4280b76b --- /dev/null +++ b/include/libcamera/internal/bayer_format.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * + * bayer_format.h - Bayer Pixel Format + */ +#ifndef __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ +#define __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ + +#include <stdint.h> +#include <string> + +#include "libcamera/internal/v4l2_pixelformat.h" + +namespace libcamera { + +enum class Transform; + +class BayerFormat +{ +public: + enum Order : uint8_t { + BGGR = 0, + GBRG = 1, + GRBG = 2, + RGGB = 3 + }; + + enum Packing : uint16_t { + None = 0, + CSI2Packed = 1, + IPU3Packed = 2, + }; + + constexpr BayerFormat() + : order(Order::BGGR), bitDepth(0), packing(Packing::None) + { + } + + constexpr BayerFormat(Order o, uint8_t b, Packing p) + : order(o), bitDepth(b), packing(p) + { + } + + explicit BayerFormat(V4L2PixelFormat v4l2Format); + bool isValid() const { return bitDepth != 0; } + + std::string toString() const; + + V4L2PixelFormat toV4L2PixelFormat() const; + BayerFormat transform(Transform t) const; + + Order order; + uint8_t bitDepth; + + Packing packing; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */ |