15#include "libcamera/internal/sensor_cfa_layout.h"
19inline bool softwareIspNeedsCellCollapse(std::string_view model)
21 return sensorCfaLayout(model).softwareIspNeedsCellCollapse();
24inline Size quadBayerLogicalSize(
const Size &physicalSize)
26 return { physicalSize.width / 2, physicalSize.height / 2 };
29inline bool isQuadBayerInputSizeSupported(
const Size &size)
31 return size.
width >= 4 && size.height >= 4 &&
32 size.width % 4 == 0 && size.height % 4 == 0;
36 const Size &outputSize,
39 const Size &viewportSize = quadBayer ? outputSize : physicalSize;
40 return { 0, 0, viewportSize.width, viewportSize.height };
43inline Rectangle quadBayerStatsWindow(
const Size &physicalSize,
44 const Size &logicalOutputSize)
46 Size statsSize = physicalSize;
47 if (
static_cast<uint64_t
>(physicalSize.width) * logicalOutputSize.height >
48 static_cast<uint64_t
>(physicalSize.height) * logicalOutputSize.width) {
49 statsSize.width =
static_cast<uint64_t
>(physicalSize.height) *
50 logicalOutputSize.width / logicalOutputSize.height;
51 statsSize.width &= ~3U;
53 statsSize.height =
static_cast<uint64_t
>(physicalSize.width) *
54 logicalOutputSize.height / logicalOutputSize.width;
55 statsSize.height &= ~3U;
58 static_cast<int>(((physicalSize.width - statsSize.width) / 2) & ~3U),
59 static_cast<int>(((physicalSize.height - statsSize.height) / 2) & ~3U),
65inline std::array<float, 8> softwareIspTextureCoordinates(
const Size &physicalSize,
82 const float left =
static_cast<float>(window.x) / physicalSize.
width;
83 const float top =
static_cast<float>(window.y) / physicalSize.height;
84 const float right =
static_cast<float>(window.x + window.width) / physicalSize.width;
85 const float bottom =
static_cast<float>(window.y + window.height) / physicalSize.height;
98inline Point quadBayerCellOrigin(
const Size &physicalSize,
const Point &pixel)
101 std::clamp(pixel.x & ~1, 0,
static_cast<int>(physicalSize.width) - 2),
102 std::clamp(pixel.y & ~1, 0,
static_cast<int>(physicalSize.height) - 2),
122inline bool isQuadBayerInputFormatSupported(
PixelFormat inputFormat)
125 return bayerFormat.bitDepth == 10 &&
127 quadBayerOrderShifts(bayerFormat.order).x >= 0;
130template<
typename Sample>
133 using Value =
decltype(sample(0, 0));
134 const Point redShift = quadBayerOrderShifts(order);
135 const Point red(redShift.x / 2, redShift.y / 2);
136 const Point blue(1 - red.x, 1 - red.y);
137 const Value green0 = sample(1 - red.x, red.y);
138 const Value green1 = sample(red.x, 1 - red.y);
139 return std::array<Value, 3>{
140 sample(red.x, red.y),
141 static_cast<Value
>((green0 + green1) / 2),
142 sample(blue.x, blue.y),
146template<
typename Sample>
147inline auto averageQuadBayerCell(Sample sample,
unsigned int x,
unsigned int y)
149 const unsigned int physicalX = x * 2;
150 const unsigned int physicalY = y * 2;
151 return (sample(physicalX, physicalY) +
152 sample(physicalX + 1, physicalY) +
153 sample(physicalX, physicalY + 1) +
154 sample(physicalX + 1, physicalY + 1) + 2) /
Describe a point in two-dimensional space.
Definition geometry.h:19
Describe a rectangle's position and dimensions.
Definition geometry.h:247
Describe a two-dimensional size.
Definition geometry.h:51
unsigned int width
The Size width.
Definition geometry.h:63
Data structures related to geometric objects.
Top-level libcamera namespace.
Definition backtrace.h:17