MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / initP010

Function initP010

sources/utils/FrameDecoder.cpp:131–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129
130
131 static void initP010()
132 {
133 static std::mutex lockerP010;
134 std::lock_guard<std::mutex> locker(lockerP010);
135
136 if (FrameDecoderUtils::initialized)
137 return;
138
139 lutP010_y.resize(1024);
140 lutP010_uv.resize(1024);
141
142 for (int i = 0; i < static_cast<int>(lutP010_y.size()); ++i)
143 {
144 constexpr int sourceRange = 1023;
145 const double sourceValue = std::min(std::max(i, 0), sourceRange)/static_cast<double>(sourceRange);
146 double val = packLuminanceP010(sourceValue);
147 lutP010_y[i] = std::lround(val * 255.0);
148
149 /*
150 double unpack = unpackLuminanceP010(val);
151 double delta = sourceValue - unpack;
152 if (std::abs(delta) > 0.0000001)
153 {
154 bool error = true;
155 }
156 */
157 }
158
159
160 for (int i = 0; i < static_cast<int>(lutP010_uv.size()); ++i)
161 {
162 constexpr int sourceRange = (960 - 64) / 2;
163 const int current = std::abs(i - 512);
164 const double sourceValue = std::min(current, sourceRange) / static_cast<double>(sourceRange);
165 double val = packChromaP010(sourceValue);
166 lutP010_uv[i] = std::max(std::min(128 + std::lround(((i < 512) ? -val : val) * 128.0), 255l), 0l);;
167
168 /*
169 double unpack = unpackChromaP010(val);
170 double delta = sourceValue - unpack;
171 if (std::abs(delta) > 0.0000001)
172 {
173 bool error = true;
174 }
175 */
176 }
177
178 FrameDecoderUtils::initialized = true;
179 };
180};
181
182using namespace FrameDecoderUtils;

Callers 2

processImageMethod · 0.85
processQImageMethod · 0.85

Calls 4

packLuminanceP010Function · 0.85
packChromaP010Function · 0.85
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected