Ocean
FrameConverterBGR24.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_BGR_24_H
9 #define META_OCEAN_CV_FRAME_CONVERTER_BGR_24_H
10 
11 #include "ocean/cv/CV.h"
13 #include "ocean/cv/FrameChannels.h"
14 
15 namespace Ocean
16 {
17 
18 // Forward declaration.
19 class Worker;
20 
21 namespace CV
22 {
23 
24 /**
25  * This class provides functions to convert frames with BGR pixel format.
26  * @ingroup cv
27  */
28 class OCEAN_CV_EXPORT FrameConverterBGR24 : public FrameConverter
29 {
30  public:
31 
32  /**
33  * Converts a BGR 24 bit frame to a BGR 24 bit frame.
34  * @param source The source frame buffer, must be valid
35  * @param target The target frame buffer, must be valid
36  * @param width The width of the frame in pixel, with range [1, infinity)
37  * @param height The height of the frame in pixel, with range [1, infinity)
38  * @param flag Determining the type of conversion
39  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
40  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
41  * @param worker Optional worker object to distribute the computation
42  */
43  static inline void convertBGR24ToBGR24(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);
44 
45  /**
46  * Converts a BGR 24 bit frame to a BGR 24 bit frame.
47  * @param source The source frame buffer, must be valid
48  * @param target The target frame buffer, must be valid
49  * @param width The width of the frame in pixel, with range [1, infinity)
50  * @param height The height of the frame in pixel, with range [1, infinity)
51  * @param flag Determining the type of conversion
52  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
53  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
54  * @param alphaValue The value of the alpha channel to be set, with range [0, 255]
55  * @param worker Optional worker object to distribute the computation
56  */
57  static inline void convertBGR24ToBGRA32(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, const uint8_t alphaValue = 0xFF, Worker* worker = nullptr);
58 
59  /**
60  * Converts a BGR 24 bit frame to a RGB 24 bit frame.
61  * @param source The source frame buffer, must be valid
62  * @param target The target frame buffer, must be valid
63  * @param width The width of the frame in pixel, with range [1, infinity)
64  * @param height The height of the frame in pixel, with range [1, infinity)
65  * @param flag Determining the type of conversion
66  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
67  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
68  * @param worker Optional worker object to distribute the computation
69  */
70  static inline void convertBGR24ToRGB24(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);
71 
72  /**
73  * Converts a BGR 24 bit frame to a RGBA 32 bit frame.
74  * @param source The source frame buffer, must be valid
75  * @param target The target frame buffer, must be valid
76  * @param width The width of the frame in pixel, with range [1, infinity)
77  * @param height The height of the frame in pixel, with range [1, infinity)
78  * @param flag Determining the type of conversion
79  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
80  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
81  * @param alphaValue The value of the alpha channel to be set, with range [0, 255]
82  * @param worker Optional worker object to distribute the computation
83  */
84  static inline void convertBGR24ToRGBA32(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, const uint8_t alphaValue = 0xFF, Worker* worker = nullptr);
85 
86  /**
87  * Converts a BGR 24 bit frame to a gray scale frame.
88  * Gray = Red * 0.299 + Green * 0.587 + Blue * 0.114
89  * @param source The source frame buffer, must be valid
90  * @param target The target frame buffer, must be valid
91  * @param width The width of the frame in pixel, with range [1, infinity)
92  * @param height The height of the frame in pixel, with range [1, infinity)
93  * @param flag Determining the type of conversion
94  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
95  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
96  * @param worker Optional worker object to distribute the computation
97  */
98  static inline void convertBGR24ToY8(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);
99 
100  /**
101  * Converts a BGR 24 bit frame to a YUV 24 bit frame by the exact conversion.
102  * @param source The source frame buffer, must be valid
103  * @param target The target frame buffer, must be valid
104  * @param width The width of the frame in pixel, with range [1, infinity)
105  * @param height The height of the frame in pixel, with range [1, infinity)
106  * @param flag Determining the type of conversion
107  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
108  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
109  * @param worker Optional worker object to distribute the computation
110  */
111  static inline void convertBGR24ToYUV24(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);
112 
113  /**
114  * Converts a full range BGR24 frame to a limited range Y_U_V12 frame with 7-bit precision using BT.601.
115  * <pre>
116  * BGR input value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
117  * YUV input value range: [16, 235]x[16, 240]x[16, 240]
118  * </pre>
119  * @param source The source frame plane, must be valid
120  * @param yTarget The y-target frame plane, must be valid
121  * @param uTarget The u-target frame plane, must be valid
122  * @param vTarget The v-target frame plane, must be valid
123  * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
124  * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
125  * @param flag Determining the type of conversion
126  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
127  * @param yTargetPaddingElements Optional number of padding elements at the end of each y-target row, in (uint8_t) elements, with range [0, infinity)
128  * @param uTargetPaddingElements Optional number of padding elements at the end of each u-target row, in (uint8_t) elements, with range [0, infinity)
129  * @param vTargetPaddingElements Optional number of padding elements at the end of each v-target row, in (uint8_t) elements, with range [0, infinity)
130  * @param worker Optional worker object to distribute the computational load
131  */
132  static inline void convertBGR24FullRangeToY_U_V12LimitedRange(const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker* worker = nullptr);
133 
134  /**
135  * Converts a full range BGR24 frame to a limited range Y_V_U12 frame with 7-bit precision using BT.601.
136  * <pre>
137  * BGR input value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
138  * YUV input value range: [16, 235]x[16, 240]x[16, 240]
139  * </pre>
140  * @param source The source frame plane, must be valid
141  * @param yTarget The y-target frame plane, must be valid
142  * @param vTarget The v-target frame plane, must be valid
143  * @param uTarget The u-target frame plane, must be valid
144  * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
145  * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
146  * @param flag Determining the type of conversion
147  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
148  * @param yTargetPaddingElements Optional number of padding elements at the end of each y-target row, in (uint8_t) elements, with range [0, infinity)
149  * @param vTargetPaddingElements Optional number of padding elements at the end of each v-target row, in (uint8_t) elements, with range [0, infinity)
150  * @param uTargetPaddingElements Optional number of padding elements at the end of each u-target row, in (uint8_t) elements, with range [0, infinity)
151  * @param worker Optional worker object to distribute the computational load
152  */
153  static inline void convertBGR24FullRangeToY_V_U12LimitedRange(const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker* worker = nullptr);
154 
155  /**
156  * Converts a full range BGR24 frame to a full range Y_U_V12 frame with 7-bit precision using BT.601.
157  * <pre>
158  * BGR input value range: [0, 255]x[0, 255]x[0, 255]
159  * YUV output value range: [0, 255]x[0, 255]x[0, 255]
160  * </pre>
161  * @param source The source frame plane, must be valid
162  * @param yTarget The y-target frame plane, must be valid
163  * @param uTarget The u-target frame plane, must be valid
164  * @param vTarget The v-target frame plane, must be valid
165  * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
166  * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
167  * @param flag Determining the type of conversion
168  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
169  * @param yTargetPaddingElements Optional number of padding elements at the end of each y-target row, in (uint8_t) elements, with range [0, infinity)
170  * @param uTargetPaddingElements Optional number of padding elements at the end of each u-target row, in (uint8_t) elements, with range [0, infinity)
171  * @param vTargetPaddingElements Optional number of padding elements at the end of each v-target row, in (uint8_t) elements, with range [0, infinity)
172  * @param worker Optional worker object to distribute the computational load
173  */
174  static inline void convertBGR24FullRangeToY_U_V12FullRange(const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker* worker = nullptr);
175 
176  /**
177  * Converts a full range BGR24 frame to a full range Y_V_U12 frame with 7-bit precision using BT.601.
178  * <pre>
179  * BGR input value range: [0, 255]x[0, 255]x[0, 255]
180  * YVU output value range: [0, 255]x[0, 255]x[0, 255]
181  * </pre>
182  * @param source The source frame plane, must be valid
183  * @param yTarget The y-target frame plane, must be valid
184  * @param vTarget The v-target frame plane, must be valid
185  * @param uTarget The u-target frame plane, must be valid
186  * @param width The width of the frame in pixel, with range [2, infinity), must be a multiple of 2
187  * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
188  * @param flag Determining the type of conversion
189  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
190  * @param yTargetPaddingElements Optional number of padding elements at the end of each y-target row, in (uint8_t) elements, with range [0, infinity)
191  * @param vTargetPaddingElements Optional number of padding elements at the end of each v-target row, in (uint8_t) elements, with range [0, infinity)
192  * @param uTargetPaddingElements Optional number of padding elements at the end of each u-target row, in (uint8_t) elements, with range [0, infinity)
193  * @param worker Optional worker object to distribute the computational load
194  */
195  static inline void convertBGR24FullRangeToY_V_U12FullRange(const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker* worker = nullptr);
196 };
197 
198 inline void FrameConverterBGR24::convertBGR24ToBGR24(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)
199 {
200  ocean_assert(source != nullptr && target != nullptr);
201  ocean_assert(width >= 1u && height >= 1u);
202 
203  FrameChannels::transformGeneric<uint8_t, 3u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
204 }
205 
206 inline void FrameConverterBGR24::convertBGR24ToBGRA32(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, const uint8_t alphaValue, Worker* worker)
207 {
208  ocean_assert(source != nullptr && target != nullptr);
209  ocean_assert(width >= 1u && height >= 1u);
210 
211  FrameChannels::addLastChannelValue<uint8_t, 3u>(source, alphaValue, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
212 }
213 
214 inline void FrameConverterBGR24::convertBGR24ToRGB24(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)
215 {
216  ocean_assert(source != nullptr && target != nullptr);
217  ocean_assert(width >= 1u && height >= 1u);
218 
219  FrameChannels::reverseChannelOrder<uint8_t, 3u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
220 }
221 
222 inline void FrameConverterBGR24::convertBGR24ToRGBA32(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, const uint8_t alphaValue, Worker* worker)
223 {
224  ocean_assert(source != nullptr && target != nullptr);
225  ocean_assert(width >= 1u && height >= 1u);
226 
227  // source frame B G R
228  // 0 1 2
229  // target frame R G B A
230  // pattern 2 1 0
231  constexpr unsigned int shufflePattern = 0x012u;
232 
233  FrameChannels::shuffleChannelsAndSetLastChannelValue<uint8_t, 3u, 4u, shufflePattern>(source, alphaValue, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
234 }
235 
236 inline void FrameConverterBGR24::convertBGR24ToY8(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)
237 {
238  ocean_assert(source != nullptr && target != nullptr);
239  ocean_assert(width >= 1u && height >= 1u);
240 
241  const unsigned int sourceStrideElements = width * 3u + sourcePaddingElements;
242  const unsigned int targetStrideElements = width + targetPaddingElements;
243 
244  constexpr unsigned int channelFactors[3] = {15u, 75u, 38u}; // 15/128 ~ 0.114, 75/128 ~ 0.587, 38/128 ~ 0.299
245 
246  static_assert(channelFactors[0] + channelFactors[1] + channelFactors[2] == 128u, "Invalid factors!");
247 
248  constexpr bool useFactorChannel0 = channelFactors[0] != 0u;
249  constexpr bool useFactorChannel1 = channelFactors[1] != 0u;
250  constexpr bool useFactorChannel2 = channelFactors[2] != 0u;
251 
252  const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
253 
254  FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag, CV::FrameChannels::convertRow3ChannelsTo1Channel8BitPerChannel7BitPrecision<useFactorChannel0, useFactorChannel1, useFactorChannel2>, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 1u>, areContinuous, channelFactors, worker);
255 }
256 
257 inline void FrameConverterBGR24::convertBGR24ToYUV24(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)
258 {
259  ocean_assert(source != nullptr && target != nullptr);
260  ocean_assert(width >= 1u && height >= 1u);
261 
262  const unsigned int sourceStrideElements = width * 3u + sourcePaddingElements;
263  const unsigned int targetStrideElements = width * 3u + targetPaddingElements;
264 
265  // approximation:
266  // Y = ( 33 * R + 64 * G + 13 * B) / 128 + 16
267  // U = (-19 * R - 37 * G + 56 * B) / 128 + 128
268  // V = ( 56 * R - 47 * G - 9 * B) / 128 + 128
269 
270  const int parameters[12] = {13, 56, -9, 64, -37, -47, 33, -19, 56, 16, 128, 128};
271 
272  const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
273 
274  FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag, CV::FrameChannels::convertRow3ChannelsTo3Channels8BitPerChannel7BitPrecision, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 3u>, areContinuous, parameters, worker);
275 }
276 
277 inline void FrameConverterBGR24::convertBGR24FullRangeToY_U_V12LimitedRange(const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker* worker)
278 {
279  ocean_assert(source != nullptr && yTarget != nullptr && uTarget != nullptr && vTarget != nullptr);
280 
281  ocean_assert(width >= 2u && width % 2u == 0u);
282  ocean_assert(height >= 2u && height % 2u == 0u);
283 
284  if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
285  {
286  return;
287  }
288 
289  /*
290  * BGR input value range: [ 0, 255]x[ 0, 255]x[ 0, 255]
291  * YUV output value range: [16, 235]x[16, 240]x[16, 240]
292  *
293  * | Y | | 0.09765625 0.5039063 0.2578125 16.0 | | B |
294  * | U | = | 0.4375 -0.2890625 -0.1484375 128.0 | * | G |
295  * | V | | -0.0703125 -0.3671875 0.4375 128.0 | | R |
296  * | 1 |
297  * Approximation with 7 bit precision:
298  * | Y | | 13 64 33 16 * 128 | | B |
299  * 128 * | U | = | 56 -37 -19 128 * 128 | * | G |
300  * | V | | -9 -47 56 128 * 128 | | R |
301  * | 1 |
302  */
303 
304  const int options[4 + 9 + 3] =
305  {
306  // padding parameters
307  int(sourcePaddingElements), int(yTargetPaddingElements), int(uTargetPaddingElements), int(vTargetPaddingElements),
308 
309  // multiplication parameters
310  13, 56, -9, 64, -37, -47, 33, -19, 56,
311 
312  // bias/translation parameters
313  16, 128, 128
314  };
315 
316  void* target[3] =
317  {
318  yTarget,
319  uTarget,
320  vTarget
321  };
322 
324 }
325 
326 inline void FrameConverterBGR24::convertBGR24FullRangeToY_V_U12LimitedRange(const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker* worker)
327 {
328  // just swapping u- and v-plane, and calling converter to Y_U_V12
329 
330  convertBGR24FullRangeToY_U_V12LimitedRange(source, yTarget, uTarget, vTarget, width, height, flag, sourcePaddingElements, yTargetPaddingElements, uTargetPaddingElements, vTargetPaddingElements, worker);
331 }
332 
333 inline void FrameConverterBGR24::convertBGR24FullRangeToY_U_V12FullRange(const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker* worker)
334 {
335  ocean_assert(source != nullptr && yTarget != nullptr && uTarget != nullptr && vTarget != nullptr);
336 
337  ocean_assert(width >= 2u && width % 2u == 0u);
338  ocean_assert(height >= 2u && height % 2u == 0u);
339 
340  if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
341  {
342  return;
343  }
344 
345  /*
346  * BGR input value range: [0, 255]x[0, 255]x[0, 255]
347  * YUV output value range: [0, 255]x[0, 255]x[0, 255]
348  *
349  * | Y | | 0.114 0.587 0.299 0 | | B |
350  * | U | = | 0.5 -0.331264 -0.168736 128 | * | G |
351  * | V | | -0.081312 -0.418688 0.5 128 | | R |
352  * | 1 |
353  * Approximation with 7 bit precision:
354  * | Y | | 15 75 38 0 * 128 | | B |
355  * 128 * | U | = | 64 -42 -22 128 * 128 | * | G |
356  * | V | | -10 -54 64 128 * 128 | | R |
357  * | 1 |
358  */
359 
360  const int options[4 + 9 + 3] =
361  {
362  // padding parameters
363  int(sourcePaddingElements), int(yTargetPaddingElements), int(uTargetPaddingElements), int(vTargetPaddingElements),
364 
365  // multiplication parameters
366  15, 64, -10, 75, -42, -54, 38, -22, 64,
367 
368  // bias/translation parameters
369  0, 128, 128
370  };
371 
372  void* target[3] =
373  {
374  yTarget,
375  uTarget,
376  vTarget
377  };
378 
380 }
381 
382 inline void FrameConverterBGR24::convertBGR24FullRangeToY_V_U12FullRange(const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker* worker)
383 {
384  // just swapping u- and v-plane, and calling converter to Y_U_V12
385 
386  convertBGR24FullRangeToY_U_V12FullRange(source, yTarget, uTarget, vTarget, width, height, flag, sourcePaddingElements, yTargetPaddingElements, uTargetPaddingElements, vTargetPaddingElements, worker);
387 }
388 
389 }
390 
391 }
392 
393 #endif // META_OCEAN_CV_FRAME_CONVERTER_BGR_24_H
static void convertRow3ChannelsTo3Channels8BitPerChannel7BitPrecision(const uint8_t *source, uint8_t *target, const size_t size, const void *parameters)
Converts a row of pixels with 3 channels to pixels with 3 channels by a linear combination of the thr...
This class provides functions to convert frames with BGR pixel format.
Definition: FrameConverterBGR24.h:29
static void convertBGR24FullRangeToY_U_V12FullRange(const uint8_t *source, uint8_t *yTarget, uint8_t *uTarget, uint8_t *vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a full range Y_U_V12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:333
static void convertBGR24ToRGBA32(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, const uint8_t alphaValue=0xFF, Worker *worker=nullptr)
Converts a BGR 24 bit frame to a RGBA 32 bit frame.
Definition: FrameConverterBGR24.h:222
static void convertBGR24ToBGRA32(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, const uint8_t alphaValue=0xFF, Worker *worker=nullptr)
Converts a BGR 24 bit frame to a BGR 24 bit frame.
Definition: FrameConverterBGR24.h:206
static void convertBGR24ToYUV24(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 BGR 24 bit frame to a YUV 24 bit frame by the exact conversion.
Definition: FrameConverterBGR24.h:257
static void convertBGR24FullRangeToY_V_U12LimitedRange(const uint8_t *source, uint8_t *yTarget, uint8_t *vTarget, uint8_t *uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a limited range Y_V_U12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:326
static void convertBGR24FullRangeToY_U_V12LimitedRange(const uint8_t *source, uint8_t *yTarget, uint8_t *uTarget, uint8_t *vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a limited range Y_U_V12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:277
static void convertBGR24ToRGB24(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 BGR 24 bit frame to a RGB 24 bit frame.
Definition: FrameConverterBGR24.h:214
static void convertBGR24ToBGR24(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 BGR 24 bit frame to a BGR 24 bit frame.
Definition: FrameConverterBGR24.h:198
static void convertBGR24FullRangeToY_V_U12FullRange(const uint8_t *source, uint8_t *yTarget, uint8_t *vTarget, uint8_t *uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a full range Y_V_U12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:382
static void convertBGR24ToY8(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 BGR 24 bit frame to a gray scale frame.
Definition: FrameConverterBGR24.h:236
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 convertGenericPixelFormat(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const unsigned int sourceStrideElements, const unsigned int targetStrideElements, const ConversionFlag flag, const RowConversionFunction< TSource, TTarget > rowConversionFunction, const RowReversePixelOrderInPlaceFunction< TTarget > targetReversePixelOrderInPlaceFunction, const bool areContinuous, const void *options, Worker *worker)
Converts a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24, ...) to a frame with generic ...
Definition: FrameConverter.h:3211
static void convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelsDownsampled2x2_8BitPerChannel_Precision7Bit(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 RGB 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:3234
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