blob: d501c5f09c6bf4f61f2377c071c20dc971c55a04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* pixel_format.cpp - libcamera Pixel Format
*/
#include <libcamera/pixel_format.h>
/**
* \file pixel_format.h
* \brief libcamera pixel format
*/
namespace libcamera {
/**
* \class PixelFormat
* \brief libcamera image pixel format
*
* The PixelFormat type describes the format of images in the public libcamera
* API. It stores a FourCC value as a 32-bit unsigned integer and a modifier.
* The FourCC and modifier values are defined in the Linux kernel DRM/KMS API
* (see linux/drm_fourcc.h).
*/
/**
* \fn PixelFormat::PixelFormat()
* \brief Construct a PixelFormat with an invalid format
*
* PixelFormat instances constructed with the default constructor are
* invalid, calling the isValid() function returns false.
*/
/**
* \fn PixelFormat::PixelFormat(uint32_t fourcc, uint64_t modifier)
* \brief Construct a PixelFormat from a DRM FourCC and a modifier
* \param[in] fourcc A DRM FourCC
* \param[in] modifier A DRM FourCC modifier
*/
/**
* \brief Compare pixel formats for equality
* \return True if the two pixel formats are equal, false otherwise
*/
bool PixelFormat::operator==(const PixelFormat &other) const
{
return fourcc_ == other.fourcc() && modifier_ == other.modifier_;
}
/**
* \fn bool PixelFormat::operator!=(const PixelFormat &other) const
* \brief Compare pixel formats for inequality
* \return True if the two pixel formats are not equal, false otherwise
*/
/**
* \brief Compare pixel formats for smaller than order
* \return True if \a this is smaller than \a other, false otherwise
*/
bool PixelFormat::operator<(const PixelFormat &other) const
{
if (fourcc_ < other.fourcc_)
return true;
if (fourcc_ > other.fourcc_)
return false;
return modifier_ < other.modifier_;
}
/**
* \fn bool PixelFormat::isValid() const
* \brief Check if the pixel format is valid
*
* PixelFormat instances constructed with the default constructor are
* invalid. Instances constructed with a FourCC defined in the DRM API
* are valid. The behaviour is undefined otherwise.
*
* \return True if the pixel format is valid, false otherwise
*/
/**
* \fn PixelFormat::operator uint32_t() const
* \brief Convert the the pixel format numerical value
* \return The pixel format numerical value
*/
/**
* \fn PixelFormat::fourcc() const
* \brief Retrieve the pixel format FourCC
* \return DRM FourCC
*/
/**
* \fn PixelFormat::modifier() const
* \brief Retrieve the pixel format modifier
* \return DRM modifier
*/
/**
* \brief Assemble and return a string describing the pixel format
* \return A string describing the pixel format
*/
std::string PixelFormat::toString() const
{
char str[11];
snprintf(str, 11, "0x%08x", fourcc_);
return str;
}
} /* namespace libcamera */
|