Ocean
Loading...
Searching...
No Matches
FrameConverterY_V_U12.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_CV_FRAME_CONVERTER_Y_V_U_12_H
9#define META_OCEAN_CV_FRAME_CONVERTER_Y_V_U_12_H
10
11#include "ocean/cv/CV.h"
16
17namespace Ocean
18{
19
20namespace CV
21{
22
23/**
24 * This class provides functions to convert frames with Y_V_U12 pixel format.
25 * The Y_V_U12 format holds the three blocks of color channels.<br>
26 * The first block covers the Y channel and holds 8 bit per pixel.<br>
27 * The second block covers the V channel and holds 8 bit for four pixels in a 2x2 neighborhood.<br>
28 * The third block covers the U channel and also holds 8 bit for four pixels in a 2x2 neighborhood.
29 * @ingroup cv
30 */
31class OCEAN_CV_EXPORT FrameConverterY_V_U12 : public FrameConverter
32{
33 public:
34
35 /**
36 * Converts a Y_V_U12_LIMITED_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
37 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
38 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
39 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
40 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
41 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
42 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
43 * @param flag Determining the type of conversion
44 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
45 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
46 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
47 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
48 * @param worker Optional worker object to distribute the computational to several CPU cores
49 */
50 static inline void convertY_V_U12LimitedRangeToY8LimitedRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
51
52 /**
53 * Converts a Y_V_U12_LIMITED_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
54 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
55 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
56 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
57 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
58 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
59 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
60 * @param flag Determining the type of conversion
61 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
62 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
63 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
64 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
65 * @param worker Optional worker object to distribute the computational to several CPU cores
66 */
67 static inline void convertY_V_U12LimitedRangeToY8FullRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
68
69 /**
70 * Converts a Y_V_U12_FULL_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
71 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
72 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
73 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
74 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
75 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
76 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
77 * @param flag Determining the type of conversion
78 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
79 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
80 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
81 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
82 * @param worker Optional worker object to distribute the computational to several CPU cores
83 */
84 static inline void convertY_V_U12FullRangeToY8FullRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
85
86 /**
87 * Converts a Y_V_U12_FULL_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
88 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
89 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
90 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
91 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
92 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
93 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
94 * @param flag Determining the type of conversion
95 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
96 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
97 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity), actually this parameter is not used
98 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
99 * @param worker Optional worker object to distribute the computational to several CPU cores
100 */
101 static inline void convertY_V_U12FullRangeToY8LimitedRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
102
103 /**
104 * Converts a Y_V_U12 frame to an 24 bit BGR frame into a second image buffer.
105 * <pre>
106 * YVU input value range: [16, 235]x[16, 240]x[16, 240]
107 * BGR output value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
108 * </pre>
109 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
110 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, must be valid
111 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, must be valid
112 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
113 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
114 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
115 * @param flag Determining the type of conversion
116 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
117 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
118 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
119 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
120 * @param worker Optional worker object to distribute the computational to several CPU cores
121 */
122 static inline void convertY_V_U12LimitedRangeToBGR24FullRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
123
124 /**
125 * Converts a Y_V_U12 frame to an 24 bit RGB frame into a second image buffer.
126 * <pre>
127 * YVU input value range: [16, 235]x[16, 240]x[16, 240]
128 * RGB output value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
129 * </pre>
130 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
131 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, must be valid
132 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, must be valid
133 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
134 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
135 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
136 * @param flag Determining the type of conversion
137 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
138 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
139 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
140 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
141 * @param worker Optional worker object to distribute the computational to several CPU cores
142 */
143 static inline void convertY_V_U12LimitedRangeToRGB24FullRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
144
145 /**
146 * Converts a Y_V_U12 frame to a 24 bit BGR frame into a second image buffer using BT.601 (analog).
147 * <pre>
148 * YVU input value range: [0, 255]x[0, 255]x[0, 255]
149 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
150 * </pre>
151 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
152 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
153 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
154 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
155 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
156 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
157 * @param flag Determining the type of conversion
158 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
159 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
160 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
161 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
162 * @param worker Optional worker object to distribute the computational to several CPU cores
163 */
164 static inline void convertY_V_U12FullRangeToBGR24FullRangePrecision6Bit(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
165
166 /**
167 * Converts a Y_V_U12 frame to a 24 bit RGB frame into a second image buffer using BT.601 (analog).
168 * <pre>
169 * YVU input value range: [0, 255]x[0, 255]x[0, 255]
170 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
171 * </pre>
172 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
173 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
174 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
175 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
176 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
177 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
178 * @param flag Determining the type of conversion
179 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
180 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
181 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
182 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
183 * @param worker Optional worker object to distribute the computational to several CPU cores
184 */
185 static inline void convertY_V_U12FullRangeToRGB24FullRangePrecision6Bit(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
186
187 /**
188 * Converts a Y_V_U12 frame to an 24 bit YVU frame into a second image buffer.
189 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
190 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, must be valid
191 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, must be valid
192 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
193 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
194 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
195 * @param flag Determining the type of conversion
196 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
197 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
198 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
199 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
200 * @param worker Optional worker object to distribute the computational to several CPU cores
201 */
202 static inline void convertY_V_U12ToYVU24(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
203
204 /**
205 * Converts a Y_V_U12 frame to an 24 bit YUV frame into a second image buffer.
206 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
207 * @param vSource The v source frame buffer, with (2 * width/2 + vPaddingElements) * height/2 elements, must be valid
208 * @param uSource The u source frame buffer, with (2 * width/2 + uPaddingElements) * height/2 elements, must be valid
209 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
210 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
211 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
212 * @param flag Determining the type of conversion
213 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
214 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
215 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
216 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
217 * @param worker Optional worker object to distribute the computational to several CPU cores
218 */
219 static inline void convertY_V_U12ToYUV24(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
220};
221
222inline void FrameConverterY_V_U12::convertY_V_U12LimitedRangeToY8LimitedRange(const uint8_t* ySource, const uint8_t* /* vSource */, const uint8_t* /* uSource */, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int /* vSourcePaddingElements */, const unsigned int /* uSourcePaddingElements */, const unsigned int targetPaddingElements, Worker* worker)
223{
224 ocean_assert(ySource != nullptr && target != nullptr);
225 ocean_assert(width >= 1u && height >= 1u);
226
227 FrameChannels::transformGeneric<uint8_t, 1u>(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
228}
229
230inline void FrameConverterY_V_U12::convertY_V_U12LimitedRangeToY8FullRange(const uint8_t* ySource, const uint8_t* /* vSource */, const uint8_t* /* uSource */, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int /* vSourcePaddingElements */, const unsigned int /* uSourcePaddingElements */, const unsigned int targetPaddingElements, Worker* worker)
231{
232 ocean_assert(ySource != nullptr && target != nullptr);
233 ocean_assert(width >= 1u && height >= 1u);
234
235 FrameConverterY8::convertY8LimitedRangeToY8FullRange(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
236}
237
238inline void FrameConverterY_V_U12::convertY_V_U12FullRangeToY8FullRange(const uint8_t* ySource, const uint8_t* /* vSource */, const uint8_t* /* uSource */, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int /* vSourcePaddingElements */, const unsigned int /* uSourcePaddingElements */, const unsigned int targetPaddingElements, Worker* worker)
239{
240 ocean_assert(ySource != nullptr && target != nullptr);
241 ocean_assert(width >= 1u && height >= 1u);
242
243 FrameChannels::transformGeneric<uint8_t, 1u>(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
244}
245
246inline void FrameConverterY_V_U12::convertY_V_U12FullRangeToY8LimitedRange(const uint8_t* ySource, const uint8_t* /* vSource */, const uint8_t* /* uSource */, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int /* vSourcePaddingElements */, const unsigned int /* uSourcePaddingElements */, const unsigned int targetPaddingElements, Worker* worker)
247{
248 ocean_assert(ySource != nullptr && target != nullptr);
249 ocean_assert(width >= 1u && height >= 1u);
250
251 FrameConverterY8::convertY8FullRangeToY8LimitedRange(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
252}
253
254inline void FrameConverterY_V_U12::convertY_V_U12LimitedRangeToBGR24FullRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker)
255{
256 ocean_assert(ySource != nullptr && vSource != nullptr && uSource != nullptr && target != nullptr);
257
258 ocean_assert(width >= 2u && width % 2u == 0u);
259 ocean_assert(height >= 2u && height % 2u == 0u);
260
261 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
262 {
263 return;
264 }
265
266 // precise color space conversion:
267 // | B | | 1.1639404296875 0.0 2.0179443359375 -276.919921875 | | Y |
268 // | G | = | 1.1639404296875 -0.81298828125 -0.3909912109375 135.486328125 | * | V |
269 // | R | | 1.1639404296875 1.595947265625 0.0 -222.904296875 | | U |
270 // | 1 |
271
272 // approximation:
273 // | B | | 1192 0 2066 -277 | | Y |
274 // | G | = | 1192 -833 -400 135 | * | V |
275 // | R | | 1192 1634 0 -223 | | U |
276 // | 1 |
277
278 const int options[4 + 12] =
279 {
280 // padding parameters
281 int(ySourcePaddingElements), int(vSourcePaddingElements), int(uSourcePaddingElements), int(targetPaddingElements),
282
283 // multiplication parameters (with denominator 1024)
284 1192, 1192, 1192, 0, -833, 1634, 2066, -400, 0,
285
286 // bias/translation parameters (with denominator 1)
287 -277, 135, -223
288 };
289
290 const void* sources[3] =
291 {
292 ySource,
293 vSource,
294 uSource
295 };
296
298}
299
300inline void FrameConverterY_V_U12::convertY_V_U12LimitedRangeToRGB24FullRange(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker)
301{
302 ocean_assert(ySource != nullptr && vSource != nullptr && uSource != nullptr && target != nullptr);
303
304 ocean_assert(width >= 2u && width % 2u == 0u);
305 ocean_assert(height >= 2u && height % 2u == 0u);
306
307 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
308 {
309 return;
310 }
311
312 // precise color space conversion:
313 // | R | | 1.1639404296875 1.595947265625 0.0 -222.904296875 | | Y |
314 // | G | = | 1.1639404296875 -0.81298828125 -0.3909912109375 135.486328125 | * | V |
315 // | B | | 1.1639404296875 0.0 2.0179443359375 -276.919921875 | | U |
316 // | 1 |
317
318 // approximation:
319 // | R | | 1192 1634 0 -223 | | Y |
320 // | G | = | 1192 -833 -400 135 | * | V |
321 // | B | | 1192 0 2066 -277 | | U |
322 // | 1 |
323
324 const int options[4 + 12] =
325 {
326 // padding parameters
327 int(ySourcePaddingElements), int(vSourcePaddingElements), int(uSourcePaddingElements), int(targetPaddingElements),
328
329 // multiplication parameters (with denominator 1024)
330 1192, 1192, 1192, 1634, -833, 0, 0, -400, 2066,
331
332 // bias/translation parameters (with denominator 1)
333 -223, 135, -277
334 };
335
336 const void* sources[3] =
337 {
338 ySource,
339 vSource,
340 uSource
341 };
342
344}
345
346inline void FrameConverterY_V_U12::convertY_V_U12FullRangeToBGR24FullRangePrecision6Bit(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker)
347{
348 FrameConverterY_U_V12::convertY_U_V12FullRangeToBGR24FullRangePrecision6Bit(ySource, uSource, vSource, target, width, height, flag, ySourcePaddingElements, uSourcePaddingElements, vSourcePaddingElements, targetPaddingElements, worker);
349}
350
351inline void FrameConverterY_V_U12::convertY_V_U12FullRangeToRGB24FullRangePrecision6Bit(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker)
352{
353 FrameConverterY_U_V12::convertY_U_V12FullRangeToRGB24FullRangePrecision6Bit(ySource, uSource, vSource, target, width, height, flag, ySourcePaddingElements, uSourcePaddingElements, vSourcePaddingElements, targetPaddingElements, worker);
354}
355
356inline void FrameConverterY_V_U12::convertY_V_U12ToYVU24(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker)
357{
358 FrameConverterY_U_V12::convertY_U_V12ToYUV24(ySource, vSource, uSource, target, width, height, flag, ySourcePaddingElements, vSourcePaddingElements, uSourcePaddingElements, targetPaddingElements, worker);
359}
360
361inline void FrameConverterY_V_U12::convertY_V_U12ToYUV24(const uint8_t* ySource, const uint8_t* vSource, const uint8_t* uSource, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker)
362{
363 ocean_assert(ySource != nullptr && vSource != nullptr && uSource != nullptr && target != nullptr);
364
365 ocean_assert(width >= 2u && width % 2u == 0u);
366 ocean_assert(height >= 2u && height % 2u == 0u);
367
368 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
369 {
370 return;
371 }
372
373 const unsigned int options[4] = {ySourcePaddingElements, vSourcePaddingElements, uSourcePaddingElements, targetPaddingElements};
374
375 const void* sources[3] =
376 {
377 ySource,
378 vSource,
379 uSource
380 };
381
382 FrameConverter::convertArbitraryPixelFormat(sources, (void**)(&target), width, height, flag, 2u, FrameConverter::mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel<0u, 2u, 1u>, options, worker);
383}
384
385}
386
387}
388
389#endif // META_OCEAN_CV_FRAME_CONVERTER_Y_V_U_12_H
This is the base class for all frame converter classes.
Definition FrameConverter.h:32
ConversionFlag
Definition of individual conversion flags.
Definition FrameConverter.h:39
static void convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e....
static void convertArbitraryPixelFormat(const void **sources, void **targets, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int multipleRowsPerIteration, const MultipleRowsConversionFunction multipleRowsConversionFunction, const void *options, Worker *worker)
Converts a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbi...
Definition FrameConverter.h:3506
static void convertY8FullRangeToY8LimitedRange(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y8 full range frame [0, 255] to a Y8 limited range frame [16, 235].
Definition FrameConverterY8.h:320
static void convertY8LimitedRangeToY8FullRange(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y8 limited range frame [16, 235] to a Y8 full range frame [0, 255].
Definition FrameConverterY8.h:288
static void convertY_U_V12ToYUV24(const uint8_t *ySource, const uint8_t *uSource, const uint8_t *vSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_U_V12 frame to a 24 bit YUV frame into a second image buffer.
Definition FrameConverterY_U_V12.h:761
static void convertY_U_V12FullRangeToRGB24FullRangePrecision6Bit(const uint8_t *ySource, const uint8_t *uSource, const uint8_t *vSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_U_V12 frame to a 24 bit RGB frame into a second image buffer.
Definition FrameConverterY_U_V12.h:649
static void convertY_U_V12FullRangeToBGR24FullRangePrecision6Bit(const uint8_t *ySource, const uint8_t *uSource, const uint8_t *vSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_U_V12 frame to a 24 bit BGR frame into a second image buffer using BT....
Definition FrameConverterY_U_V12.h:469
This class provides functions to convert frames with Y_V_U12 pixel format.
Definition FrameConverterY_V_U12.h:32
static void convertY_V_U12ToYUV24(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12 frame to an 24 bit YUV frame into a second image buffer.
Definition FrameConverterY_V_U12.h:361
static void convertY_V_U12FullRangeToY8LimitedRange(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12_FULL_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
Definition FrameConverterY_V_U12.h:246
static void convertY_V_U12FullRangeToRGB24FullRangePrecision6Bit(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12 frame to a 24 bit RGB frame into a second image buffer using BT....
Definition FrameConverterY_V_U12.h:351
static void convertY_V_U12LimitedRangeToRGB24FullRange(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12 frame to an 24 bit RGB frame into a second image buffer.
Definition FrameConverterY_V_U12.h:300
static void convertY_V_U12ToYVU24(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12 frame to an 24 bit YVU frame into a second image buffer.
Definition FrameConverterY_V_U12.h:356
static void convertY_V_U12FullRangeToY8FullRange(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12_FULL_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
Definition FrameConverterY_V_U12.h:238
static void convertY_V_U12LimitedRangeToY8FullRange(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12_LIMITED_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
Definition FrameConverterY_V_U12.h:230
static void convertY_V_U12FullRangeToBGR24FullRangePrecision6Bit(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12 frame to a 24 bit BGR frame into a second image buffer using BT....
Definition FrameConverterY_V_U12.h:346
static void convertY_V_U12LimitedRangeToY8LimitedRange(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12_LIMITED_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
Definition FrameConverterY_V_U12.h:222
static void convertY_V_U12LimitedRangeToBGR24FullRange(const uint8_t *ySource, const uint8_t *vSource, const uint8_t *uSource, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int ySourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y_V_U12 frame to an 24 bit BGR frame into a second image buffer.
Definition FrameConverterY_V_U12.h:254
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15