libcamera: include/libcamera/pixel_format.h Source File

libcamera v0.0.4 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
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
8#pragma once
9
10#include <ostream>
11#include <set>
12#include <stdint.h>
13#include <string>
14
15namespace libcamera {
16
17 class PixelFormat
18{
19public:
20 constexpr PixelFormat()
21 : fourcc_(0), modifier_(0)
22 {
23 }
24
25 explicit constexpr PixelFormat(uint32_t fourcc, uint64_t modifier = 0)
26 : fourcc_(fourcc), modifier_(modifier)
27 {
28 }
29
30 bool operator==(const PixelFormat &other) const;
31 bool operator!=(const PixelFormat &other) const { return !(*this == other); }
32 bool operator<(const PixelFormat &other) const;
33
34 constexpr bool isValid() const { return fourcc_ != 0; }
35
36 constexpr operator uint32_t() const { return fourcc_; }
37 constexpr uint32_t fourcc() const { return fourcc_; }
38 constexpr uint64_t modifier() const { return modifier_; }
39
40 std::string toString() const;
41
42 static PixelFormat fromString(const std::string &name);
43
44private:
45 uint32_t fourcc_;
46 uint64_t modifier_;
47};
48
49std::ostream &operator<<(std::ostream &out, const PixelFormat &f);
50
51} /* namespace libcamera */
libcamera::PixelFormat
libcamera image pixel format
Definition: pixel_format.h:18
libcamera::PixelFormat::modifier
constexpr uint64_t modifier() const
Retrieve the pixel format modifier.
Definition: pixel_format.h:38
libcamera::PixelFormat::operator<
bool operator<(const PixelFormat &other) const
Compare pixel formats for smaller than order.
Definition: pixel_format.cpp:65
libcamera::PixelFormat::PixelFormat
constexpr PixelFormat(uint32_t fourcc, uint64_t modifier=0)
Construct a PixelFormat from a DRM FourCC and a modifier.
Definition: pixel_format.h:25
libcamera::PixelFormat::fromString
static PixelFormat fromString(const std::string &name)
Create a PixelFormat from a string.
Definition: pixel_format.cpp:138
libcamera::PixelFormat::PixelFormat
constexpr PixelFormat()
Construct a PixelFormat with an invalid format.
Definition: pixel_format.h:20
libcamera::PixelFormat::operator==
bool operator==(const PixelFormat &other) const
Compare pixel formats for equality.
Definition: pixel_format.cpp:50
libcamera::PixelFormat::isValid
constexpr bool isValid() const
Check if the pixel format is valid.
Definition: pixel_format.h:34
libcamera::PixelFormat::operator!=
bool operator!=(const PixelFormat &other) const
Compare pixel formats for inequality.
Definition: pixel_format.h:31
libcamera::PixelFormat::fourcc
constexpr uint32_t fourcc() const
Retrieve the pixel format FourCC.
Definition: pixel_format.h:37
libcamera::PixelFormat::toString
std::string toString() const
Assemble and return a string describing the pixel format.
Definition: pixel_format.cpp:107
libcamera
Top-level libcamera namespace.
Definition: backtrace.h:17
libcamera::operator<<
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition: geometry.cpp:91