libcamera  v0.0.0
Supporting cameras in Linux since 2019
pixel_format.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  *
5  * pixel_format.h - libcamera Pixel Format
6  */
7 #ifndef __LIBCAMERA_PIXEL_FORMAT_H__
8 #define __LIBCAMERA_PIXEL_FORMAT_H__
9 
10 #include <set>
11 #include <stdint.h>
12 #include <string>
13 
14 namespace libcamera {
15 
17 {
18 public:
19  constexpr PixelFormat()
20  : fourcc_(0), modifier_(0)
21  {
22  }
23 
24  explicit constexpr PixelFormat(uint32_t fourcc, uint64_t modifier = 0)
25  : fourcc_(fourcc), modifier_(modifier)
26  {
27  }
28 
29  bool operator==(const PixelFormat &other) const;
30  bool operator!=(const PixelFormat &other) const { return !(*this == other); }
31  bool operator<(const PixelFormat &other) const;
32 
33  constexpr bool isValid() const { return fourcc_ != 0; }
34 
35  constexpr operator uint32_t() const { return fourcc_; }
36  constexpr uint32_t fourcc() const { return fourcc_; }
37  constexpr uint64_t modifier() const { return modifier_; }
38 
39  std::string toString() const;
40 
41 private:
42  uint32_t fourcc_;
43  uint64_t modifier_;
44 };
45 
46 } /* namespace libcamera */
47 
48 #endif /* __LIBCAMERA_PIXEL_FORMAT_H__ */
libcamera image pixel format
Definition: pixel_format.h:17
constexpr uint64_t modifier() const
Retrieve the pixel format modifier.
Definition: pixel_format.h:37
bool operator<(const PixelFormat &other) const
Compare pixel formats for smaller than order.
Definition: pixel_format.cpp:65
constexpr PixelFormat(uint32_t fourcc, uint64_t modifier=0)
Construct a PixelFormat from a DRM FourCC and a modifier.
Definition: pixel_format.h:24
constexpr PixelFormat()
Construct a PixelFormat with an invalid format.
Definition: pixel_format.h:19
bool operator==(const PixelFormat &other) const
Compare pixel formats for equality.
Definition: pixel_format.cpp:50
constexpr bool isValid() const
Check if the pixel format is valid.
Definition: pixel_format.h:33
bool operator!=(const PixelFormat &other) const
Compare pixel formats for inequality.
Definition: pixel_format.h:30
constexpr uint32_t fourcc() const
Retrieve the pixel format FourCC.
Definition: pixel_format.h:36
std::string toString() const
Assemble and return a string describing the pixel format.
Definition: pixel_format.cpp:107