Loading...
Searching...
No Matches
pixel_format.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* libcamera Pixel Format
*/
#pragma once
#include <ostream>
#include <stdint.h>
#include <string>
namespace libcamera {
class PixelFormat
{
public:
constexpr PixelFormat()
: fourcc_(0), modifier_(0)
{
}
explicit constexpr PixelFormat(uint32_t fourcc, uint64_t modifier = 0)
: fourcc_(fourcc), modifier_(modifier)
{
}
bool operator==(const PixelFormat &other) const;
bool operator!=(const PixelFormat &other) const { return !(*this == other); }
bool operator<(const PixelFormat &other) const;
constexpr bool isValid() const { return fourcc_ != 0; }
constexpr operator uint32_t() const { return fourcc_; }
constexpr uint32_t fourcc() const { return fourcc_; }
constexpr uint64_t modifier() const { return modifier_; }
std::string toString() const;
static PixelFormat fromString(const std::string &name);
private:
uint32_t fourcc_;
uint64_t modifier_;
};
std::ostream &operator<<(std::ostream &out, const PixelFormat &f);
} /* namespace libcamera */
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::PixelFormat::operator<
bool operator<(const PixelFormat &other) const
Compare pixel formats for smaller than order.
Definition pixel_format.cpp:65
libcamera::PixelFormat::fromString
static PixelFormat fromString(const std::string &name)
Create a PixelFormat from a string.
Definition pixel_format.cpp:138
libcamera::PixelFormat::isValid
constexpr bool isValid() const
Check if the pixel format is valid.
Definition pixel_format.h:33
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:24
libcamera::PixelFormat::operator==
bool operator==(const PixelFormat &other) const
Compare pixel formats for equality.
Definition pixel_format.cpp:50
libcamera::PixelFormat::modifier
constexpr uint64_t modifier() const
Retrieve the pixel format modifier.
Definition pixel_format.h:37
libcamera::PixelFormat::operator!=
bool operator!=(const PixelFormat &other) const
Compare pixel formats for inequality.
Definition pixel_format.h:30
libcamera::PixelFormat::PixelFormat
constexpr PixelFormat()
Construct a PixelFormat with an invalid format.
Definition pixel_format.h:19
libcamera::PixelFormat::fourcc
constexpr uint32_t fourcc() const
Retrieve the pixel format FourCC.
Definition pixel_format.h:36
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 bound_method.h:15
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