Ocean
Loading...
Searching...
No Matches
FrameConverterY_U_V12.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_U_V_12_H
9#define META_OCEAN_CV_FRAME_CONVERTER_Y_U_V_12_H
10
11#include "ocean/cv/CV.h"
15
16#include "ocean/base/Worker.h"
17
18namespace Ocean
19{
20
21namespace CV
22{
23
24/**
25 * This class provides functions to convert frames with Y_U_V12 pixel format.
26 * The Y_U_V12 format holds the three blocks of color channels.<br>
27 * The first block covers the Y channel and holds 8 bit per pixel.<br>
28 * The second block covers the U channel and holds 8 bit for four pixels in a 2x2 neighborhood.<br>
29 * The third block covers the V channel and also holds 8 bit for four pixels in a 2x2 neighborhood.
30 * @ingroup cv
31 */
32class OCEAN_CV_EXPORT FrameConverterY_U_V12 : public FrameConverter
33{
34 public:
35
36 /**
37 * Converts a Y_U_V12 frame to a Y_U_V12 frame into a second image buffer.
38 * @param ySource The y source plane, with (width + yPaddingElements) * height elements, must be valid
39 * @param uSource The u source plane, with (width/2 + uPaddingElements) * height/2 elements, must be valid
40 * @param vSource The v source plane, with (width/2 + vPaddingElements) * height/2 elements, must be valid
41 * @param yTarget The y target plane, with (width + yTargetPaddingElements) * height elements, must be valid
42 * @param uTarget The u target plane, with (width/2 + uTargetPaddingElements) * height/2 elements, must be valid
43 * @param vTarget The v target plane, with (width/2 + vTargetPaddingElements) * height/2 elements, must be valid
44 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
45 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
46 * @param flag Determining the type of conversion
47 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
48 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
49 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
50 * @param yTargetPaddingElements The number of padding elements at the end of each y-target row, in (uint8_t) elements, with range [0, infinity)
51 * @param uTargetPaddingElements The number of padding elements at the end of each uv-target row, in (uint8_t) elements, with range [0, infinity)
52 * @param vTargetPaddingElements The number of padding elements at the end of each uv-target row, in (uint8_t) elements, with range [0, infinity)
53 * @param worker Optional worker object to distribute the computational to several CPU cores
54 */
55 static inline void convertY_U_V12ToY_U_V12(const uint8_t* ySource, const uint8_t* uSource, const uint8_t* vSource, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget, 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 yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker* worker = nullptr);
56
57 /**
58 * Converts a Y_U_V12_LIMITED_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
59 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
60 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
61 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
62 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
63 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
64 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
65 * @param flag Determining the type of conversion
66 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
67 * @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
68 * @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
69 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
70 * @param worker Optional worker object to distribute the computational to several CPU cores
71 */
72 static inline void convertY_U_V12LimitedRangeToY8LimitedRange(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);
73
74 /**
75 * Converts a Y_U_V12_LIMITED_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
76 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
77 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
78 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
79 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
80 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
81 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
82 * @param flag Determining the type of conversion
83 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
84 * @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
85 * @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
86 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
87 * @param worker Optional worker object to distribute the computational to several CPU cores
88 */
89 static inline void convertY_U_V12LimitedRangeToY8FullRange(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);
90
91 /**
92 * Converts a Y_U_V12_FULL_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
93 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
94 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
95 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
96 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
97 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
98 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
99 * @param flag Determining the type of conversion
100 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
101 * @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
102 * @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
103 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
104 * @param worker Optional worker object to distribute the computational to several CPU cores
105 */
106 static inline void convertY_U_V12FullRangeToY8FullRange(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);
107
108 /**
109 * Converts a Y_U_V12_FULL_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
110 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
111 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
112 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, can be invalid, as this parameter is not used
113 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
114 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
115 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
116 * @param flag Determining the type of conversion
117 * @param ySourcePaddingElements The number of padding elements at the end of each y-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), actually this parameter is not used
119 * @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
120 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
121 * @param worker Optional worker object to distribute the computational to several CPU cores
122 */
123 static inline void convertY_U_V12FullRangeToY8LimitedRange(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);
124
125 /**
126 * Converts a Y_U_V12 frame to a 24 bit BGR frame into a second image buffer using BT.601 (digital).
127 * <pre>
128 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
129 * BGR output value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
130 * </pre>
131 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
132 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
133 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
134 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
135 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
136 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
137 * @param flag Determining the type of conversion
138 * @param ySourcePaddingElements The number of padding elements at the end of each y-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 vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
141 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
142 * @param worker Optional worker object to distribute the computational to several CPU cores
143 */
144 static inline void convertY_U_V12LimitedRangeToBGR24FullRange(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);
145
146 /**
147 * Converts a Y_U_V12 frame to a 24 bit BGR frame into a second image buffer using BT.601 (analog).
148 * <pre>
149 * YUV input value range: [0, 255]x[0, 255]x[0, 255]
150 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
151 * </pre>
152 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
153 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
154 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
155 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
156 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
157 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
158 * @param flag Determining the type of conversion
159 * @param ySourcePaddingElements The number of padding elements at the end of each y-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 vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
162 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
163 * @param worker Optional worker object to distribute the computational to several CPU cores
164 */
165 static inline 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);
166
167 /**
168 * Converts a Y_U_V12 frame to an 32 bit BGRA frame into a second image buffer (with 6 bit precision).
169 * <pre>
170 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
171 * BGRA output value range: [ 0, 255]x[ 0, 255]x[ 0, 255]x[ 0, 255]
172 * </pre>
173 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
174 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
175 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
176 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
177 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
178 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
179 * @param flag Determining the type of conversion
180 * @param ySourcePaddingElements The number of padding elements at the end of each y-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 vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
183 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
184 * @param alphaValue The value of the alpha channel to be set, with range [0, 255]
185 * @param worker Optional worker object to distribute the computational to several CPU cores
186 */
187 static inline void convertY_U_V12LimitedRangeToBGRA32FullRangePrecision6Bit(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, const uint8_t alphaValue = 0xFF, Worker* worker = nullptr);
188
189 /**
190 * Converts a Y_U_V12 frame to a 24 bit RGB frame into a second image buffer.
191 * <pre>
192 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
193 * RGB output value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
194 * </pre>
195 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
196 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
197 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
198 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
199 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
200 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
201 * @param flag Determining the type of conversion
202 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
203 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
204 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
205 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
206 * @param worker Optional worker object to distribute the computational to several CPU cores
207 */
208 static inline void convertY_U_V12LimitedRangeToRGB24FullRange(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);
209
210 /**
211 * Converts a Y_U_V12 frame to a 24 bit RGB frame into a second image buffer (with 6 bit precision).
212 * <pre>
213 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
214 * RGB output value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
215 * </pre>
216 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
217 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
218 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
219 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
220 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
221 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
222 * @param flag Determining the type of conversion
223 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
224 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
225 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
226 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
227 * @param worker Optional worker object to distribute the computational to several CPU cores
228 */
229 static inline void convertY_U_V12LimitedRangeToRGB24FullRangePrecision6Bit(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);
230
231 /**
232 * Converts a Y_U_V12 frame to a 24 bit RGB frame into a second image buffer.
233 * <pre>
234 * YUV input value range: [0, 255]x[0, 255]x[0, 255]
235 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
236 * </pre>
237 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
238 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
239 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
240 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
241 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
242 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
243 * @param flag Determining the type of conversion
244 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
245 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
246 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
247 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
248 * @param worker Optional worker object to distribute the computational to several CPU cores
249 */
250 static inline 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);
251
252 /**
253 * Converts a Y_U_V12 frame to an 32 bit RGBA frame into a second image buffer.
254 * <pre>
255 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
256 * RGBA output value range: [ 0, 255]x[ 0, 255]x[ 0, 255]x[ 0, 255]
257 * </pre>
258 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
259 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
260 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
261 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
262 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
263 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
264 * @param flag Determining the type of conversion
265 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
266 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
267 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
268 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
269 * @param alphaValue The value of the alpha channel to be set, with range [0, 255]
270 * @param worker Optional worker object to distribute the computational to several CPU cores
271 */
272 static inline void convertY_U_V12LimitedRangeToRGBA32FullRangePrecision6Bit(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, const uint8_t alphaValue = 0xFF, Worker* worker = nullptr);
273
274 /**
275 * Converts a Y_U_V12 frame to a 24 bit YUV frame into a second image buffer.
276 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
277 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
278 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
279 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
280 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
281 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
282 * @param flag Determining the type of conversion
283 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
284 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
285 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
286 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
287 * @param worker Optional worker object to distribute the computational to several CPU cores
288 */
289 static inline 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);
290
291 /**
292 * Converts a Y_U_V12 frame to a 24 bit YVU frame into a second image buffer.
293 * @param ySource The y source frame buffer, with (width + yPaddingElements) * height elements, must be valid
294 * @param uSource The u source frame buffer, with (width/2 + uPaddingElements) * height/2 elements, must be valid
295 * @param vSource The v source frame buffer, with (width/2 + vPaddingElements) * height/2 elements, must be valid
296 * @param target The target frame buffer, with (width + targetPaddingElements) * height elements, must be valid
297 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
298 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
299 * @param flag Determining the type of conversion
300 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
301 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
302 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
303 * @param targetPaddingElements The number of padding elements at the end of each target row, in (uint8_t) elements, with range [0, infinity)
304 * @param worker Optional worker object to distribute the computational to several CPU cores
305 */
306 static inline void convertY_U_V12ToYVU24(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);
307
308 /**
309 * Converts a Y_U_V12 frame to a Y_UV12 frame into a second image buffer.
310 * @param ySource The y source plane, with (width + yPaddingElements) * height elements, must be valid
311 * @param uSource The u source plane, with (width/2 + uPaddingElements) * height/2 elements, must be valid
312 * @param vSource The v source plane, with (width/2 + vPaddingElements) * height/2 elements, must be valid
313 * @param yTarget The y target plane, with (width + yTargetPaddingElements) * height elements, must be valid
314 * @param uvTarget The uv target plane, with (width + uvTargetPaddingElements) * height/2 elements, must be valid
315 * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
316 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
317 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
318 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
319 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
320 * @param yTargetPaddingElements The number of padding elements at the end of each y-target row, in (uint8_t) elements, with range [0, infinity)
321 * @param uvTargetPaddingElements The number of padding elements at the end of each uv-target row, in (uint8_t) elements, with range [0, infinity)
322 * @param ySourcePixelStride The stride between consecutive pixels in the y source plane, in elements, with range [1, infinity)
323 * @param uSourcePixelStride The stride between consecutive pixels in the u source plane, in elements, with range [1, infinity)
324 * @param vSourcePixelStride The stride between consecutive pixels in the v source plane, in elements, with range [1, infinity)
325 * @param worker Optional worker object to distribute the computational to several CPU cores
326 */
327 static inline void convertY_U_V12ToY_UV12(const uint8_t* ySource, const uint8_t* uSource, const uint8_t* vSource, uint8_t* yTarget, uint8_t* uvTarget, const unsigned int width, const unsigned int height, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uvTargetPaddingElements, const unsigned int ySourcePixelStride = 1u, const unsigned int uSourcePixelStride = 1u, const unsigned int vSourcePixelStride = 1u, Worker* worker = nullptr);
328
329 protected:
330
331 /**
332 * Converts one row of an image with Y_U_V12 pixel format to one row of an image with RGBA32 pixel format.
333 * This function applies hard-coded conversion parameters.<br>
334 * The layout of the options parameters is as follows:
335 * <pre>
336 * options[0] uint32_t: sourcePlane0PaddingElements
337 * options[1] uint32_t: sourcePlane1PaddingElements
338 * options[2] uint32_t: sourcePlane2PaddingElements
339 * options[3] uint32_t: targetZippedPaddingElements
340 * options[4] uint32_t: channelValue3
341 * </pre>
342 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
343 * @param targets The one pointer to the target image, must be valid
344 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
345 * @param width The width of the frame in pixel, with range [1, infinity)
346 * @param height The height of the frame in pixel, with range [1, infinity)
347 * @param conversionFlag The conversion to be applied
348 * @param options The 5 options parameters: 4 padding parameters, one constant channel value, must be valid
349 */
350 static void convertOneRowY_U_V12ToRGBA32Precision6Bit(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
351
352 /**
353 * Converts two rows of an image with Y_U_V12 pixel format to two rows of an image with a Y_UV12 pixel format.
354 * The layout of the options parameters is as follows:
355 * <pre>
356 * options[0] uint32_t: ySourcePaddingElements
357 * options[1] uint32_t: uSourcePaddingElements
358 * options[2] uint32_t: vSourcePaddingElements
359 * options[3] uint32_t: yTargetPaddingElements
360 * options[4] uint32_t: uvTargetPaddingElements
361 * options[5] uint32_t: ySourcePixelStride
362 * options[6] uint32_t: uSourcePixelStride
363 * options[7] uint32_t: vSourcePixelStride
364 * </pre>
365 * @param sources The pointer to the first, second, and third plane of the source image, must be valid
366 * @param targets The one pointer to the first and second target plane, must be valid
367 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
368 * @param width The width of the frame in pixel, with range [2, infinity), must be even
369 * @param height The height of the frame in pixel, with range [2, infinity), must be even
370 * @param conversionFlag The conversion to be applied, must be CONVERT_NORMAL
371 * @param options The 8 options parameters: 5 padding parameters, 3 pixel stride parameters, must be valid
372 */
373 static void mapY_U_V12ToY_UV12(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
374};
375
376inline void FrameConverterY_U_V12::convertY_U_V12ToY_U_V12(const uint8_t* ySource, const uint8_t* uSource, const uint8_t* vSource, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget, 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 yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker* worker)
377{
378 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr);
379 ocean_assert(yTarget != nullptr && uTarget != nullptr && vTarget != nullptr);
380 ocean_assert(width >= 2u && height >= 2u);
381 ocean_assert(width % 2u == 0u && height % 2u == 0u);
382
383 const unsigned int width_2 = width / 2u;
384 const unsigned int height_2 = height / 2u;
385
386 FrameChannels::transformGeneric<uint8_t, 1u>(ySource, yTarget, width, height, flag, ySourcePaddingElements, yTargetPaddingElements, worker);
387 FrameChannels::transformGeneric<uint8_t, 1u>(uSource, uTarget, width_2, height_2, flag, uSourcePaddingElements, uTargetPaddingElements, worker);
388 FrameChannels::transformGeneric<uint8_t, 1u>(vSource, vTarget, width_2, height_2, flag, vSourcePaddingElements, vTargetPaddingElements, worker);
389}
390
391inline void FrameConverterY_U_V12::convertY_U_V12LimitedRangeToY8LimitedRange(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)
392{
393 ocean_assert(ySource != nullptr && target != nullptr);
394 ocean_assert(width >= 1u && height >= 1u);
395
396 FrameChannels::transformGeneric<uint8_t, 1u>(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
397}
398
399inline void FrameConverterY_U_V12::convertY_U_V12LimitedRangeToY8FullRange(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)
400{
401 ocean_assert(ySource != nullptr && target != nullptr);
402 ocean_assert(width >= 1u && height >= 1u);
403
404 FrameConverterY8::convertY8LimitedRangeToY8FullRange(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
405}
406
407inline void FrameConverterY_U_V12::convertY_U_V12FullRangeToY8FullRange(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)
408{
409 ocean_assert(ySource != nullptr && target != nullptr);
410 ocean_assert(width >= 1u && height >= 1u);
411
412 FrameChannels::transformGeneric<uint8_t, 1u>(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
413}
414
415inline void FrameConverterY_U_V12::convertY_U_V12FullRangeToY8LimitedRange(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)
416{
417 ocean_assert(ySource != nullptr && target != nullptr);
418 ocean_assert(width >= 1u && height >= 1u);
419
420 FrameConverterY8::convertY8FullRangeToY8LimitedRange(ySource, target, width, height, flag, ySourcePaddingElements, targetPaddingElements, worker);
421}
422
423inline void FrameConverterY_U_V12::convertY_U_V12LimitedRangeToBGR24FullRange(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)
424{
425 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
426
427 ocean_assert(width >= 2u && width % 2u == 0u);
428 ocean_assert(height >= 2u && height % 2u == 0u);
429
430 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
431 {
432 return;
433 }
434
435 // precise color space conversion:
436 // | B | | 1.1639404296875 2.0179443359375 0.0 -276.919921875 | | Y |
437 // | G | = | 1.1639404296875 -0.3909912109375 -0.81298828125 135.486328125 | * | U |
438 // | R | | 1.1639404296875 0.0 1.595947265625 -222.904296875 | | V |
439 // | 1 |
440
441 // approximation:
442 // | B | | 1192 2066 0 -277 | | Y |
443 // | G | = | 1192 -400 -833 135 | * | U |
444 // | R | | 1192 0 1634 -223 | | V |
445 // | 1 |
446
447 const int options[4 + 12] =
448 {
449 // padding parameters
450 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
451
452 // multiplication parameters (with denominator 1024)
453 1192, 1192, 1192, 2066, -400, 0, 0, -833, 1634,
454
455 // bias/translation parameters (with denominator 1)
456 -277, 135, -223
457 };
458
459 const void* sources[3] =
460 {
461 ySource,
462 uSource,
463 vSource
464 };
465
467}
468
469inline void FrameConverterY_U_V12::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)
470{
471 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
472
473 ocean_assert(width >= 2u && width % 2u == 0u);
474 ocean_assert(height >= 2u && height % 2u == 0u);
475
476 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
477 {
478 return;
479 }
480
481 /*
482 * | B | | 1.0 1.772 0.0 -226.816 | | Y |
483 * | G | = | 1.0 -0.34414 -0.71414 135.45984 | * | U |
484 * | R | | 1.0 0.0 1.402 -179.456 | | V |
485 * | 1 |
486 *
487 * Approximation with 6 bit precision:
488 * | B | | 64 113 0 | | Y |
489 * 64 * | G | = | 64 -22 -46 | * | U - 128 |
490 * | R | | 64 0 90 | | V - 128 |
491 */
492
493 const int options[4 + 12] =
494 {
495 // padding parameters
496 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
497
498 // multiplication parameters (with denominator 1024)
499 64, 64, 64, 113, -22, 0, 0, -46, 90,
500
501 // bias/translation parameters (with denominator 1)
502 0, 128, 128
503 };
504
505 const void* sources[3] =
506 {
507 ySource,
508 uSource,
509 vSource
510 };
511
513}
514
515inline void FrameConverterY_U_V12::convertY_U_V12LimitedRangeToBGRA32FullRangePrecision6Bit(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, const uint8_t alphaValue, Worker* worker)
516{
517 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
518
519 ocean_assert(width >= 2u && width % 2u == 0u);
520 ocean_assert(height >= 2u && height % 2u == 0u);
521
522 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
523 {
524 return;
525 }
526
527 // Approximation with 6 bit precision:
528 // | B | | 75 128 0 | | Y - 16 |
529 // 64 * | G | = | 75 -25 -52 | * | U - 128 |
530 // | R | | 75 0 102 | | V - 128 |
531
532 const int options[4 + 12 + 1] =
533 {
534 // padding parameters
535 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
536
537 // multiplication parameters (with denominator 64)
538 75, 75, 75, 128, -25, 0, 0, -52, 102,
539
540 // bias/translation parameters (with denominator 1)
541 16, 128, 128,
542
543 // alpha value
544 int(alphaValue)
545 };
546
547 const void* sources[3] =
548 {
549 ySource,
550 uSource,
551 vSource
552 };
553
555}
556
557inline void FrameConverterY_U_V12::convertY_U_V12LimitedRangeToRGB24FullRange(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)
558{
559 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
560
561 ocean_assert(width >= 2u && width % 2u == 0u);
562 ocean_assert(height >= 2u && height % 2u == 0u);
563
564 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
565 {
566 return;
567 }
568
569 // precise color space conversion:
570 // | R | | 1.1639404296875 0.0 1.595947265625 -222.904296875 | | Y |
571 // | G | = | 1.1639404296875 -0.3909912109375 -0.81298828125 135.486328125 | * | U |
572 // | B | | 1.1639404296875 2.0179443359375 0.0 -276.919921875 | | V |
573 // | 1 |
574
575 // approximation:
576 // | R | | 1192 0 1634 -223 | | Y |
577 // | G | = | 1192 -400 -833 135 | * | U |
578 // | B | | 1192 2066 0 -277 | | V |
579 // | 1 |
580
581 const int options[4 + 12] =
582 {
583 // padding parameters
584 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
585
586 // multiplication parameters (with denominator 1024)
587 1192, 1192, 1192, 0, -400, 2066, 1634, -833, 0,
588
589 // bias/translation parameters (with denominator 1)
590 -223, 135, -277
591 };
592
593 const void* sources[3] =
594 {
595 ySource,
596 uSource,
597 vSource
598 };
599
601}
602
603inline void FrameConverterY_U_V12::convertY_U_V12LimitedRangeToRGB24FullRangePrecision6Bit(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)
604{
605 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
606
607 ocean_assert(width >= 2u && width % 2u == 0u);
608 ocean_assert(height >= 2u && height % 2u == 0u);
609
610 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
611 {
612 return;
613 }
614
615 /*
616 * | R | | 1.1639404296875 0.0 1.595947265625 -222.904296875 | | Y |
617 * | G | = | 1.1639404296875 -0.3909912109375 -0.81298828125 135.486328125 | * | U |
618 * | B | | 1.1639404296875 2.0179443359375 0.0 -276.919921875 | | V |
619 * | 1 |
620 *
621 * Approximation with 6 bit precision:
622 * | R | | 75 0 102 | | Y - 16 |
623 * 64 * | G | = | 75 -25 -52 | * | U - 128 |
624 * | B | | 75 128 0 | | V - 128 |
625 */
626
627 const int options[4 + 12] =
628 {
629 // padding parameters
630 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
631
632 // multiplication parameters (with denominator 1024)
633 75, 75, 75, 0, -25, 128, 102, -52, 0,
634
635 // bias/translation parameters (with denominator 1)
636 16, 128, 128
637 };
638
639 const void* sources[3] =
640 {
641 ySource,
642 uSource,
643 vSource
644 };
645
647}
648
649inline void FrameConverterY_U_V12::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)
650{
651 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
652
653 ocean_assert(width >= 2u && width % 2u == 0u);
654 ocean_assert(height >= 2u && height % 2u == 0u);
655
656 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
657 {
658 return;
659 }
660
661 /*
662 * | R | | 1.0 0.0 1.402 -179.456 | | Y |
663 * | G | = | 1.0 -0.34414 -0.71414 135.45984 | * | U |
664 * | B | | 1.0 1.772 0.0 -226.816 | | V |
665 * | 1 |
666 *
667 * Approximation with 6 bit precision:
668 * | R | | 64 0 90 | | Y |
669 * 64 * | G | = | 64 -22 -46 | * | U - 128 |
670 * | B | | 64 113 0 | | V - 128 |
671 */
672
673 const int options[4 + 12] =
674 {
675 // padding parameters
676 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
677
678 // multiplication parameters (with denominator 1024)
679 64, 64, 64, 0, -22, 113, 90, -46, 0,
680
681 // bias/translation parameters (with denominator 1)
682 0, 128, 128
683 };
684
685 const void* sources[3] =
686 {
687 ySource,
688 uSource,
689 vSource
690 };
691
693}
694
695inline void FrameConverterY_U_V12::convertY_U_V12LimitedRangeToRGBA32FullRangePrecision6Bit(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, const uint8_t alphaValue, Worker* worker)
696{
697 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
698
699 ocean_assert(width >= 2u && width % 2u == 0u);
700 ocean_assert(height >= 2u && height % 2u == 0u);
701
702 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
703 {
704 return;
705 }
706
707#if 1
708
709 // Approximation with 6 bit precision:
710 // | R | | 75 0 102 | | Y - 16 |
711 // 64 * | G | = | 75 -25 -52 | * | U - 128 |
712 // | B | | 75 128 0 | | V - 128 |
713
714 const int options[4 + 12 + 1] =
715 {
716 // padding parameters
717 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
718
719 // multiplication parameters (with denominator 64)
720 75, 75, 75, 0, -25, 128, 102, -52, 0,
721
722 // bias/translation parameters (with denominator 1)
723 16, 128, 128,
724
725 // alpha value
726 int(alphaValue)
727 };
728
729 const void* sources[3] =
730 {
731 ySource,
732 uSource,
733 vSource
734 };
735
737
738#else
739
740 const int options[4 + 1] =
741 {
742 // padding parameters
743 int(ySourcePaddingElements), int(uSourcePaddingElements), int(vSourcePaddingElements), int(targetPaddingElements),
744
745 // alpha value
746 int(alphaValue)
747 };
748
749 const void* sources[3] =
750 {
751 ySource,
752 uSource,
753 vSource
754 };
755
756 FrameConverter::convertArbitraryPixelFormat(sources, (void**)(&target), width, height, flag, 1u, convertOneRowY_U_V12ToRGBA32Precision6Bit, options, worker);
757
758#endif
759}
760
761inline void FrameConverterY_U_V12::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)
762{
763 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
764
765 ocean_assert(width >= 2u && width % 2u == 0u);
766 ocean_assert(height >= 2u && height % 2u == 0u);
767
768 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
769 {
770 return;
771 }
772
773 const unsigned int options[4] = {ySourcePaddingElements, uSourcePaddingElements, vSourcePaddingElements, targetPaddingElements};
774
775 const void* sources[3] =
776 {
777 ySource,
778 uSource,
779 vSource
780 };
781
782 FrameConverter::convertArbitraryPixelFormat(sources, (void**)(&target), width, height, flag, 2u, FrameConverter::mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel<0u, 1u, 2u>, options, worker);
783}
784
785inline void FrameConverterY_U_V12::convertY_U_V12ToYVU24(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)
786{
787 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr && target != nullptr);
788
789 ocean_assert(width >= 2u && width % 2u == 0u);
790 ocean_assert(height >= 2u && height % 2u == 0u);
791
792 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
793 {
794 return;
795 }
796
797 const unsigned int options[4] = {ySourcePaddingElements, uSourcePaddingElements, vSourcePaddingElements, targetPaddingElements};
798
799 const void* sources[3] =
800 {
801 ySource,
802 uSource,
803 vSource
804 };
805
806 FrameConverter::convertArbitraryPixelFormat(sources, (void**)(&target), width, height, flag, 2u, FrameConverter::mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel<0u, 2u, 1u>, options, worker);
807}
808
809inline void FrameConverterY_U_V12::convertY_U_V12ToY_UV12(const uint8_t* ySource, const uint8_t* uSource, const uint8_t* vSource, uint8_t* yTarget, uint8_t* uvTarget, const unsigned int width, const unsigned int height, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uvTargetPaddingElements, const unsigned int ySourcePixelStride, const unsigned int uSourcePixelStride, const unsigned int vSourcePixelStride, Worker* worker)
810{
811 ocean_assert(ySource != nullptr && uSource != nullptr && vSource != nullptr);
812 ocean_assert(yTarget != nullptr && uvTarget != nullptr);
813
814 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
815 {
816 ocean_assert(false && "Invalid parameters!");
817 return;
818 }
819
820 const uint32_t options[8] = {ySourcePaddingElements, uSourcePaddingElements, vSourcePaddingElements, yTargetPaddingElements, uvTargetPaddingElements, ySourcePixelStride, uSourcePixelStride, vSourcePixelStride};
821
822 const void* sources[3] =
823 {
824 ySource,
825 uSource,
826 vSource
827 };
828
829 void* targets[2] =
830 {
831 yTarget,
832 uvTarget
833 };
834
835 FrameConverter::convertArbitraryPixelFormat(sources, targets, width, height, CONVERT_NORMAL, 2u, mapY_U_V12ToY_UV12, options, worker);
836}
837
838}
839
840}
841
842#endif // META_OCEAN_CV_FRAME_CONVERTER_Y_U_V_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
@ CONVERT_NORMAL
Normal conversion, neither flips nor mirrors the image.
Definition FrameConverter.h:49
static void convertOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane4Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e....
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 convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit(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 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
This class provides functions to convert frames with Y_U_V12 pixel format.
Definition FrameConverterY_U_V12.h:33
static void convertY_U_V12LimitedRangeToRGB24FullRangePrecision6Bit(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 (with 6 bit precision).
Definition FrameConverterY_U_V12.h:603
static void convertY_U_V12LimitedRangeToBGR24FullRange(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:423
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_V12LimitedRangeToY8LimitedRange(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_LIMITED_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
Definition FrameConverterY_U_V12.h:391
static void convertY_U_V12LimitedRangeToRGBA32FullRangePrecision6Bit(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, const uint8_t alphaValue=0xFF, Worker *worker=nullptr)
Converts a Y_U_V12 frame to an 32 bit RGBA frame into a second image buffer.
Definition FrameConverterY_U_V12.h:695
static void convertOneRowY_U_V12ToRGBA32Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with Y_U_V12 pixel format to one row of an image with RGBA32 pixel forma...
static void convertY_U_V12ToYVU24(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 YVU frame into a second image buffer.
Definition FrameConverterY_U_V12.h:785
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
static void convertY_U_V12LimitedRangeToRGB24FullRange(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:557
static void convertY_U_V12ToY_U_V12(const uint8_t *ySource, const uint8_t *uSource, const uint8_t *vSource, uint8_t *yTarget, uint8_t *uTarget, uint8_t *vTarget, 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 yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker *worker=nullptr)
Converts a Y_U_V12 frame to a Y_U_V12 frame into a second image buffer.
Definition FrameConverterY_U_V12.h:376
static void mapY_U_V12ToY_UV12(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 Y_U_V12 pixel format to two rows of an image with a Y_UV12 pixel f...
static void convertY_U_V12ToY_UV12(const uint8_t *ySource, const uint8_t *uSource, const uint8_t *vSource, uint8_t *yTarget, uint8_t *uvTarget, const unsigned int width, const unsigned int height, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uvTargetPaddingElements, const unsigned int ySourcePixelStride=1u, const unsigned int uSourcePixelStride=1u, const unsigned int vSourcePixelStride=1u, Worker *worker=nullptr)
Converts a Y_U_V12 frame to a Y_UV12 frame into a second image buffer.
Definition FrameConverterY_U_V12.h:809
static void convertY_U_V12FullRangeToY8FullRange(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_FULL_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
Definition FrameConverterY_U_V12.h:407
static void convertY_U_V12LimitedRangeToY8FullRange(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_LIMITED_RANGE frame to a Y8_FULL_RANGE frame into a second image buffer.
Definition FrameConverterY_U_V12.h:399
static void convertY_U_V12LimitedRangeToBGRA32FullRangePrecision6Bit(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, const uint8_t alphaValue=0xFF, Worker *worker=nullptr)
Converts a Y_U_V12 frame to an 32 bit BGRA frame into a second image buffer (with 6 bit precision).
Definition FrameConverterY_U_V12.h:515
static void convertY_U_V12FullRangeToY8LimitedRange(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_FULL_RANGE frame to a Y8_LIMITED_RANGE frame into a second image buffer.
Definition FrameConverterY_U_V12.h:415
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