Ocean
Loading...
Searching...
No Matches
FrameConverter.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_H
9#define META_OCEAN_CV_FRAME_CONVERTER_H
10
11#include "ocean/cv/CV.h"
13
14#include "ocean/base/Frame.h"
15#include "ocean/base/Worker.h"
16
17#include "ocean/math/Matrix.h"
18
19namespace Ocean
20{
21
22namespace CV
23{
24
25OCEAN_DISABLE_DOCUMENTATION_DIAGNOSTIC // Clang has a bug and need to be disabled for FrameConverter
26
27/**
28 * This is the base class for all frame converter classes.
29 * @ingroup cv
30 */
31class OCEAN_CV_EXPORT FrameConverter
32{
33 public:
34
35 /**
36 * Definition of individual conversion flags.
37 */
38 enum ConversionFlag : uint32_t
39 {
40 /**
41 * Normal conversion, neither flips nor mirrors the image.
42 * The following pattern shows the conversion for an image with resolution 2x2:
43 * <pre>
44 * Input: Output:
45 * | A B | | A B |
46 * | C D | | C D |
47 * </pre>
48 */
50
51 /**
52 * Flipped conversion, exchanges top and bottom of the image (flipping around the x-axis).
53 * The following pattern shows the conversion for an image with resolution 2x2:
54 * <pre>
55 * Input: Output:
56 * | A B | | C D |
57 * | C D | | A B |
58 * </pre>
59 */
61
62 /**
63 * Mirrored conversion, exchanges left and right of the image (like in a mirror, mirroring around the y-axis).
64 * The following pattern shows the conversion for an image with resolution 2x2:
65 * <pre>
66 * Input: Output:
67 * | A B | | B A |
68 * | C D | | D C |
69 * </pre>
70 */
72
73 /**
74 * Rotated conversion, rotates the image by 180.0 degrees with anchor in the center of the image.
75 * The following pattern shows the conversion for an image with resolution 2x2:
76 * <pre>
77 * Input: Output:
78 * | A B | | D C |
79 * | C D | | B A |
80 * </pre>
81 */
82 CONVERT_FLIPPED_AND_MIRRORED
83 };
84
85 /**
86 * Definition of a vector holding conversion flags.
87 */
88 using ConversionFlags = std::vector<ConversionFlag>;
89
90 /**
91 * Definition of a boolean enum for copy preferences (to improve code readability).
92 */
93 enum CopyPreference : bool
94 {
95 /// Tries to avoid copying the frame data whenever possible.
96 CP_AVOID_COPY_IF_POSSIBLE = false,
97 /// Forces a copy of the frame data in any case.
98 CP_ALWAYS_COPY = true
99 };
100
101 /**
102 * Definition of a class storing options for frame conversions.
103 */
105 {
106 public:
107
108 /**
109 * Definition of individual types of options.
110 */
111 enum OptionsType : uint32_t
112 {
113 /// Default conversion.
114 OT_DEFAULT = 0u,
115 /// Conversion with explicit alpha channel target value.
116 OT_ALPHA_CHANNEL_TARGET_VALUE = 1u << 0u,
117 /// Conversion with gamma correction.
118 OT_GAMMA_CORRECTION = 1u << 1u,
119 /// Conversion with black level, white balance, and gamma encoding
120 OT_BLACKLEVEL_WHITEBALANCE_GAMMA = 1u << 2u,
121 /// Approximated conversion.
122 OT_APPROXIMATED = 1u << 2u,
123 };
124
125 public:
126
127 /**
128 * Default constructor.
129 * @param allowApproximation True, to allow an approximated conversion if available
130 */
131 explicit inline Options(const bool allowApproximation = false);
132
133 /**
134 * Creates options for source image without alpha channel but a target image with alpha channel.
135 * @param alphaChannelTargetValue The uint8_t alpha channel value for the target image if the source image does not contain an alpha channel; ignored if the source image contains an alpha channel, with range [0, 255]
136 * @param allowApproximation True, to allow an approximated conversion if available
137 */
138 explicit inline Options(const uint8_t alphaChannelTargetValue, const bool allowApproximation = false);
139
140 /**
141 * Creates options for a conversion applying gamma correction.
142 * @param gamma The gamma value to be applied, with range (0, 2)
143 * @param allowApproximation True, to allow an approximated conversion if available
144 */
145 explicit inline Options(const float gamma, const bool allowApproximation = false);
146
147 /**
148 * Creates options for a conversion applying black level subtraction, white balance, and gamma encoding.
149 * @param blackLevel The black level value that is subtracted from each element of the raw image before any other operation, with range [0, 1024)
150 * @param whiteBalanceRed The white balancing scalar of the red channel, with range [0, infinity)
151 * @param whiteBalanceGreen The white balancing scalar of the green channel, with range [0, infinity)
152 * @param whiteBalanceBlue The white balancing scalar of the blue channel, with range [0, infinity)
153 * @param gamma The gamma value to be applied, with range (0, infinity)
154 * @param allowApproximation True, to allow an allowApproximation conversion if available
155 * @sa FrameConverterRGGB10_Packed::convertRGGB10_PackedToRGB24BlacklevelWhiteBalanceGammaLUT()
156 */
157 explicit inline Options(const uint16_t blackLevel, const float whiteBalanceRed, const float whiteBalanceGreen, const float whiteBalanceBlue, const float gamma, const bool allowApproximation = false);
158
159 /**
160 * Returns the options type.
161 * @return The options' type
162 */
163 inline OptionsType optionsType() const;
164
165 /**
166 * Returns the uint8_t alpha channel value for the target image if the source image does not contain an alpha channel; ignored if the source image contains an alpha channel.
167 * @return The alpha value for the target channel, with range [0, 255]
168 */
169 inline uint8_t alphaChannelTargetValue() const;
170
171 /**
172 * Returns the gamma value for a conversion with gamma correction/encoding.
173 * @return The gamma value, with range (0, 2) (OT_GAMMA_CORRECTION) or [0, infinity) (OT_BLACKLEVEL_WHITEBALANCE_GAMMA)
174 */
175 inline float gamma() const;
176
177 /**
178 * Returns the black level value for a conversion with black level correction.
179 * @return The black level value, with range [0, 1024)
180 */
181 inline uint16_t blackLevel() const;
182
183 /**
184 * Returns the white balance values for a conversion with white balance correction.
185 * @return The white balance values for the red, green, and blue channels, with range [0, infinity)
186 */
187 inline const float* whiteBalance() const;
188
189 /**
190 * Returns whether the conversion can be approximated.
191 * @return True, if so
192 */
193 inline bool allowApproximation() const;
194
195 protected:
196
197 /// The options type.
198 OptionsType optionsType_ = OT_DEFAULT;
199
200 /// The alpha channel value for the target image if the source image does not contain an alpha channel, with range [0, 255]
201 uint8_t alphaChannelTargetValue_ = 0xFFu;
202
203 /// The gamma value for a conversion with gamma correction/encoding, with range (0, 2) (OT_GAMMA_CORRECTION) or [0, infinity) (OT_BLACKLEVEL_WHITEBALANCE_GAMMA)
204 float gamma_ = 1.0f;
205
206 /// The black level value that is subtracted from each element of the raw image before any other operation, with range [0, 1024)
207 uint16_t blackLevel_ = 0u;
208
209 /// The white balancing scalars of the red, green, and blue channels (in that order), with range [0, infinity)
210 float whiteBalance_[3] = { 1.0f, 1.0f, 1.0f };
211 };
212
213 protected:
214
215 /**
216 * This class implements a singleton-based map for function pointers of conversion functions.
217 */
218 class OCEAN_CV_EXPORT ConversionFunctionMap : public Singleton<ConversionFunctionMap>
219 {
220 friend class Singleton<ConversionFunctionMap>;
221
222 public:
223
224 /**
225 * Definition of individual types of conversion functions.
226 */
227 enum FunctionType : uint32_t
228 {
229 /// And invalid function type.
230 FT_INVALID = 0u,
231 /// 1-plane uint8 to 1-plane uint8 conversion function.
233 /// 1-plane uint8 with constant gamma correction to 1-plane uint8 conversion function.
235 /// 1-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
237 /// 1-plane uint8 to 1-plane uint8 conversion function with constant black level, white balance, and gamma values.
239 /// 1-plane uint8 to 1-plane uint16 conversion function.
241 /// 1-plane uint16 to 1-plane uint8 conversion function.
243 /// 1-plane uint16 to 1-plane uint16 conversion function.
245 /// 1-plane uint32 to 1-plane uint8 conversion function.
247 /// 1-plane uint32 to 1-plane uint16 conversion function.
249 /// 1-plane uint8 to 2-plane uint8 conversion function.
251 /// 1-plane uint8 to 3-plane uint8 conversion function.
253 /// 2-plane uint8 to 1-plane uint8 conversion function.
255 /// 2-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
257 /// 2-plane uint8 to 2-plane uint8 conversion function.
259 /// 2-plane uint8 to 3-plane uint8 conversion function.
261 /// 3-plane uint8 to 1-plane uint8 conversion function.
263 /// 3-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
265 /// 3-plane uint8 to 3-plane uint8 conversion function.
266 FT_3_UINT8_TO_3_UINT8
267 };
268
269 /**
270 * Definition of a function pointer to a conversion function with one source plane and one target plane.
271 */
272 template <typename TSource, typename TTarget>
273 using OneSourceOneTargetConversionFunction = void(*)(const TSource* source, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker* worker);
274
275 /**
276 * Definition of a function pointer to a conversion function with one source plane with gamma correction and one target plane.
277 */
278 template <typename TSource, typename TTarget>
279 using OneSourceGammaOneTargetConversionFunction = void(*)(const TSource* source, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker* worker);
280
281 /**
282 * Definition of a function pointer to a conversion function with one source plane and one target plane with constant alpha value.
283 */
284 template <typename TSource, typename TTarget>
285 using OneSourceOneTargetAlphaConversionFunction = void(*)(const TSource* source, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker* worker);
286
287 /**
288 * Definition of a function pointer to a conversion function with one source plane and one target plane with constant values for black level, white balance (red, green, blue), and gamma.
289 */
290 template <typename TSource, typename TTarget>
291 using OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction = void(*)(const TSource* source, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint16_t blackLevelValue, const float* whiteBalanceValues, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker* worker);
292
293 /**
294 * Definition of a function pointer to a conversion function with one source plane and two target planes.
295 */
296 template <typename TSource, typename TTarget>
297 using OneSourceTwoTargetsConversionFunction = void(*)(const TSource* source, TTarget* target0, TTarget* target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker* worker);
298
299 /**
300 * Definition of a function pointer to a conversion function with one source plane and three target planes.
301 */
302 template <typename TSource, typename TTarget>
303 using OneSourceThreeTargetsConversionFunction = void(*)(const TSource* source, TTarget* target0, TTarget* target1, TTarget* target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, const uint32_t target2PaddingElements, Worker* worker);
304
305 /**
306 * Definition of a function pointer to a conversion function with two source planes and one target plane.
307 */
308 template <typename TSource, typename TTarget>
309 using TwoSourcesOneTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, Worker* worker);
310
311 /**
312 * Definition of a function pointer to a conversion function with two source planes and one target plane with constant alpha.
313 */
314 template <typename TSource, typename TTarget>
315 using TwoSourcesOneTargetAlphaConversionFunction = void(*)(const TSource* source0, const TSource* source1, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker* worker);
316
317 /**
318 * Definition of a function pointer to a conversion function with two source planes and two target plane.
319 */
320 template <typename TSource, typename TTarget>
321 using TwoSourcesTwoTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, TTarget* target0, TTarget* target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker* worker);
322
323 /**
324 * Definition of a function pointer to a conversion function with two source planes and three target planes.
325 */
326 template <typename TSource, typename TTarget>
327 using TwoSourcesThreeTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, TTarget* target0, TTarget* target1, TTarget* target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker* worker);
328
329 /**
330 * Definition of a function pointer to a conversion function with three source planes and one target plane.
331 */
332 template <typename TSource, typename TTarget>
333 using ThreeSourcesOneTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, const TSource* source2, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, Worker* worker);
334
335 /**
336 * Definition of a function pointer to a conversion function with three source planes and one target plane with constant alpha value.
337 */
338 template <typename TSource, typename TTarget>
339 using ThreeSourcesOneTargetAlphaConversionFunction = void(*)(const TSource* source0, const TSource* source1, const TSource* source2, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker* worker);
340
341 /**
342 * Definition of a function pointer to a conversion function with three source planes and three target planes.
343 */
344 template <typename TSource, typename TTarget>
345 using ThreeSourcesThreeTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, const TSource* source2, TTarget* target0, TTarget* target1, TTarget* target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker* worker);
346
347 protected:
348
349 /**
350 * This class combines source pixel format, target pixel format, and options types.
351 */
353 {
354 public:
355
356 /**
357 * Helper class for a hash function.
358 * The separate struct is necessary for compilers like GCC.
359 */
360 struct Hash
361 {
362 /**
363 * Hash function.
364 * @param conversionTriple The conversion triple for which the hash will be determined
365 * @return The hash value
366 */
367 inline size_t operator()(const ConversionTriple& conversionTriple) const;
368 };
369
370 public:
371
372 /**
373 * Default constructor.
374 */
375 ConversionTriple() = default;
376
377 /**
378 * Creates a new object.
379 * @param sourcePixelFormat The pixel format of the source frame, must be valid
380 * @param targetPixelFormat The pixel format of the target frame, must be valid
381 * @param optionsType The type of the options for which the conversion is defined
382 */
383 inline ConversionTriple(const FrameType::PixelFormat& sourcePixelFormat, const FrameType::PixelFormat& targetPixelFormat, const Options::OptionsType optionsType = Options::OT_DEFAULT);
384
385 /**
386 * Returns whether two objects are identical.
387 * @param conversionTriple The second object
388 * @return True, if so
389 */
390 inline bool operator==(const ConversionTriple& conversionTriple) const;
391
392 public:
393
394 /// The pixel format of the source frame, must be valid
395 FrameType::PixelFormat sourcePixelFormat_ = FrameType::FORMAT_UNDEFINED;
396
397 /// The pixel format of the target frame, must be valid
398 FrameType::PixelFormat targetPixelFormat_ = FrameType::FORMAT_UNDEFINED;
399
400 /// The type of the options for which the conversion is defined
401 Options::OptionsType optionsType_ = Options::OT_DEFAULT;
402 };
403
404 /**
405 * This class is a wrapper for function pointers.
406 */
408 {
410
411 public:
412
413 /**
414 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8 function.
415 * @param function The pointer to the conversion function, must be valid
416 */
418
419 /**
420 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_GAMMA_TO_1_UINT8 function.
421 * @param function The pointer to the conversion function, must be valid
422 */
424
425 /**
426 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_ALPHA function.
427 * @param function The pointer to the conversion function, must be valid
428 */
430
431 /**
432 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHITEBALANCE_GAMMA function.
433 * @param function The pointer to the conversion function, must be valid
434 */
436
437 /**
438 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT16 function.
439 * @param function The pointer to the conversion function, must be valid
440 */
442
443 /**
444 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT8 function.
445 * @param function The pointer to the conversion function, must be valid
446 */
448
449 /**
450 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT16 function.
451 * @param function The pointer to the conversion function, must be valid
452 */
454
455 /**
456 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT8 function.
457 * @param function The pointer to the conversion function, must be valid
458 */
460
461 /**
462 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT16 function.
463 * @param function The pointer to the conversion function, must be valid
464 */
466
467 /**
468 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_2_UINT8 function.
469 * @param function The pointer to the conversion function, must be valid
470 */
472
473 /**
474 * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_3_UINT8 function.
475 * @param function The pointer to the conversion function, must be valid
476 */
478
479 /**
480 * Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8 function.
481 * @param function The pointer to the conversion function, must be valid
482 */
484
485 /**
486 * Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8_ALPHA function.
487 * @param function The pointer to the conversion function, must be valid
488 */
490
491 /**
492 * Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_2_UINT8 function.
493 * @param function The pointer to the conversion function, must be valid
494 */
496
497 /**
498 * Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_3_UINT8 function.
499 * @param function The pointer to the conversion function, must be valid
500 */
502
503 /**
504 * Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8 function.
505 * @param function The pointer to the conversion function, must be valid
506 */
508
509 /**
510 * Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8_ALPHA function.
511 * @param function The pointer to the conversion function, must be valid
512 */
514
515 /**
516 * Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_3_UINT8 function.
517 * @param function The pointer to the conversion function, must be valid
518 */
520
521 protected:
522
523 /// The function pointer of the conversion function.
524 const void* function_;
525
526 /// The type of the conversion function.
528 };
529
530 /**
531 * Definition of a map mapping pairs or pixel formats to function pointers.
532 */
533 using FormatPair2FunctionWrapperMap = std::unordered_map<ConversionTriple, FunctionWrapper, ConversionTriple::Hash>;
534
535 public:
536
537 /**
538 * Returns the function pointer for a source and target pixel format.
539 * @param sourcePixelFormat The pixel format of the source frame, must be valid
540 * @param targetPixelFormat The pixel format of the target frame, must be valid
541 * @param functionType The resulting type of the conversion function
542 * @param options The options for the conversion
543 * @return The function pointer, nullptr if the combination of source and target pixel format is not supported
544 */
545 const void* function(const FrameType::PixelFormat& sourcePixelFormat, const FrameType::PixelFormat& targetPixelFormat, FunctionType& functionType, const Options& options) const;
546
547 protected:
548
549 /**
550 * Creates a new map object and initializes all function pointers.
551 */
553
554 protected:
555
556 /// The map mapping pairs or pixel formats to function pointers.
558 };
559
560 protected:
561
562 /**
563 * Definition of a function pointer to a function able to convert one image row from one generic pixel format to another generic pixel format.
564 * @param sourceRow The row in the source frame, must be valid
565 * @param targetRow The row in the target frame, must be valid
566 * @param width The number of pixels to convert, with range [1, infinity)
567 * @param options Optional options which are necessary for the conversion, otherwise nullptr
568 * @tparam TSource The data type of each source pixel channel, e.g., 'uint8_t' or 'float'
569 * @tparam TTarget The data type of each target pixel channel, e.g., 'uint8_t' or 'float'
570 */
571 template <typename TSource, typename TTarget>
572 using RowConversionFunction = void (*)(const TSource* sourceRow, TTarget* targetRow, const size_t width, const void* options);
573
574 /**
575 * Definition of a function pointer to a function able to convert multiple image row from an arbitrary pixel format to another arbitrary pixel format.
576 * @param sources The memory pointers defining the source rows, must be valid
577 * @param targets The memory pointers defining the target rows, must be valid
578 * @param multipleRowIndex The index of the rows to be converted, with range [0, height / multipleRowsPerIteration - 1]
579 * @param width The width of the frame in pixel, with range [1, infinity)
580 * @param height The height of the frame in pixel, with range [1, infinity)
581 * @param conversionFlag The conversion to be applied
582 * @param options Optional options which are necessary for the conversion, otherwise nullptr
583 */
584 using MultipleRowsConversionFunction = void (*)(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
585
586 /**
587 * Definition of a function pointer to a function able to reverse the order of pixels in an image row with a generic pixel format.
588 * @param inputRow The row to reverse, must be valid
589 * @param targetRow The row receiving the reversed pixels, must be different from 'inputRow', must be valid
590 * @param width The number of pixels to reverse, with range [1, infinity)
591 * @tparam T The data type of each pixel channel, e.g., 'uint8_t' or 'float'
592 */
593 template <typename T>
594 using RowReversePixelOrderFunction = void (*)(const T* inputRow, T* targetRow, const size_t width);
595
596 /**
597 * Definition of a function pointer to a function able to reverse the order of pixels in an image row with a generic pixel format in-place.
598 * @param row The row to reverse, must be valid
599 * @param width The number of pixels to reverse, with range [1, infinity)
600 * @tparam T The data type of each pixel channel, e.g., 'uint8_t' or 'float'
601 */
602 template <typename T>
603 using RowReversePixelOrderInPlaceFunction = void (*)(T* row, const size_t width);
604
605 /**
606 * Definition of the parameters used by the function for row-wise conversion of RGGB14_PACKED to RGB24/BGR24
607 */
609 {
610 /// The black level that needs to be subtracted from the unpacked pixel values, with range [0, 1024)
611 uint16_t blackLevel = 0u;
612
613 /// The white balance factors for the red, green, and blue channel as 7 bit fixed-point numbers; the order of the channels is the same as in the target frame
614 unsigned int whiteBalance7[3] = { 128u, 128u, 128u };
615
616 /// Pointer to the gamma lookup-table, cf. `FrameConverterY10_Packed::LookupTableManager`
617 const uint8_t* gammaLookupValues = nullptr;
618
619 /// The number of padding elements of the source frame
620 unsigned int sourcePaddingElements = 0u;
621
622 /// The number of padding elements of the target frame
623 unsigned int targetPaddingElements = 0u;
624 };
625
626 public:
627
628 /**
629 * The following comfort class provides comfortable functions simplifying prototyping applications but also increasing binary size of the resulting applications.
630 * Best practice is to avoid using these functions if binary size matters,<br>
631 * as for every comfort function a corresponding function exists with specialized functionality not increasing binary size significantly.<br>
632 */
633 class OCEAN_CV_EXPORT Comfort
634 {
635 public:
636
637 /**
638 * Returns whether the convert function of this class supports the conversion of a frame with one pixel format to a new frame with other pixel format.
639 * @param sourceType The frame type of the source frame, must be valid
640 * @param targetPixelFormat The pixel format of the target frame, must be valid
641 * @param targetPixelOrigin The pixel origin of the target frame, ORIGIN_INVALID to use the pixel origin of the source frame
642 * @param options The options to be used for conversion
643 * @return True, if so
644 * @see convert().
645 */
646 static bool isSupported(const FrameType& sourceType, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin = FrameType::ORIGIN_INVALID, const Options& options = Options());
647
648 /**
649 * Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same dimension, but different pixel format or pixel origin.
650 * @param source The source frame to convert, must be valid
651 * @param targetPixelFormat The pixel format of the target frame, must be valid
652 * @param targetPixelOrigin The pixel origin of the target frame, must be valid
653 * @param target The resulting target frame, the frame will be modified if the frame type is not compatible, or if the target frame is not owner of the frame data, or if the target frame is a read-only frame, can be invalid
654 * @param forceCopy True, if the resulting target image is expected to be the owner of the image data, otherwise the source frame will be the owner of the image data if possible
655 * @param worker Optional worker object to distribute the conversion computation to different CPU cores
656 * @param options The options to be used for conversion
657 * @return True, if the frame type conversion is supported and succeeded
658 *
659 * Here is an example showing how to use this function:
660 * @code
661 * bool function(const Frame& anyFrame)
662 * {
663 * // we do not know which pixel format (and pixel origin) the given frame has
664 * // however, we know that we need e.g., a grayscale frame with 8 bit and pixel origin in the upper left corner of the target frame
665 *
666 * Frame yFrame;
667 * if (!FrameConverter::Comfort::convert(anyFrame, FrameType::FORMAT_Y8, FrameType::ORIGIN_UPPER_LEFT, yFrame, FrameConverter::CP_AVOID_COPY_IF_POSSIBLE)) // we try to avoid a copy if possible
668 * {
669 * // the given frame could not be converted into a Y8 frame, so we stop here
670 * return false;
671 * }
672 *
673 * // from now on we have access to a Y8 frame, it may be
674 * // - a frame not owning the frame data but referencing the memory only (in case 'anyFrame' provided a plain Y8 block)
675 * // - a frame owning the frame data if the given image was converted to a Y8 frame
676 *
677 * // we can use the memory as long as anyFrame exists
678 * const uint8_t* data = yFrame.constdata<uint8_t>();
679 *
680 * // do something here
681 *
682 * return true;
683 * }
684 * @endcode
685 * @see isSupported(), convertAndCopy().
686 */
687 static bool convert(const Frame& source, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, Frame& target, const bool forceCopy = true, Worker* worker = nullptr, const Options& options = Options());
688
689 /**
690 * Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same dimension and pixel origin, but different pixel format.
691 * @param source The source frame to convert, must be valid
692 * @param targetPixelFormat The pixel format of the target frame, must be valid
693 * @param target The resulting target frame, the frame will be modified if the frame type is not compatible, or if the target frame is not owner of the frame data, or if the target frame is a read-only frame, can be invalid
694 * @param forceCopy True, if the resulting target image is expected to be the owner of the image data, otherwise the source frame will be the owner of the image data if possible
695 * @param worker Optional worker object to distribute the conversion computation to different CPU cores
696 * @param options The options to be used for conversion
697 * @return True, if the frame type conversion is supported and succeeded
698 *
699 * Here is an example showing how to use this function:
700 * @code
701 * bool function(const Frame& anyFrame)
702 * {
703 * // we do not know which pixel format (and pixel origin) the given frame has
704 * // however, we know that we need e.g., a grayscale frame with 8 bit with any pixel origin
705 *
706 * Frame yFrame;
707 * if (!FrameConverter::Comfort::convert(anyFrame, FrameType::FORMAT_Y8, yFrame, FrameConverter::CP_AVOID_COPY_IF_POSSIBLE)) // we try to avoid a copy if possible
708 * {
709 * // the given frame could not be converted into a Y8 frame, so we stop here
710 * return false;
711 * }
712 *
713 * // from now on we have access to a Y8 frame, it may be
714 * // - a frame not owning the frame data but referencing the memory only (in case 'anyFrame' provided a plain Y8 block)
715 * // - a frame owning the frame data if the given image was converted to a Y8 frame
716 *
717 * // we can use the memory as long as anyFrame exists
718 * const uint8_t* data = yFrame.constdata<uint8_t>();
719 *
720 * // do something here
721 *
722 * return true;
723 * }
724 * @endcode
725 * @see isSupported(), convertAndCopy().
726 */
727 static inline bool convert(const Frame& source, const FrameType::PixelFormat targetPixelFormat, Frame& target, const bool forceCopy = true, Worker* worker = nullptr, const Options& options = Options());
728
729 /**
730 * Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same dimension and pixel format, but different pixel origin.
731 * @param source The source frame to convert, must be valid
732 * @param targetPixelOrigin The pixel origin of the target frame, must be valid
733 * @param target The resulting target frame, the frame will be modified if the frame type is not compatible, or if the target frame is not owner of the frame data, or if the target frame is a read-only frame, can be invalid
734 * @param forceCopy True, if the resulting target image is expected to be the owner of the image data, otherwise the source frame will be the owner of the image data if possible
735 * @param worker Optional worker object to distribute the conversion computation to different CPU cores
736 * @param options The options to be used for conversion
737 * @return True, if the frame type conversion is supported and succeeded
738 * @see isSupported(), convertAndCopy().
739 */
740 static inline bool convert(const Frame& source, const FrameType::PixelOrigin targetPixelOrigin, Frame& target, const bool forceCopy = true, Worker* worker = nullptr, const Options& options = Options());
741
742 /**
743 * Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same dimension but different pixel format or pixel origin.
744 * This function does always copy the memory to the already existing memory of the target frame.
745 * @param source The source frame to convert, must be valid
746 * @param target The target frame which will receive the converted source image information, must contain writable memory, must be valid
747 * @param worker Optional worker object to distribute the conversion computation to different CPU cores
748 * @param options The options to be used for conversion
749 * @return True, if the frame type conversion is supported and succeeded
750 *
751 * Here is an example showing how to use this function:
752 * @code
753 * bool function(const Frame& anySourceFrame)
754 * {
755 * uint8_t* targetMemoryRGB24 = ...;
756 * const unsigned int targetMemoryPaddingElements = ...;
757 *
758 * const FrameType targetFrameType(anySourceFrame.width(), anySourceFrame.height(), FrameType::FORMAT_RGB24, FrameType::ORIGIN_UPPER_LEFT);
759 *
760 * Frame targetFrame(targetFrameType, targetMemoryRGB24, Frame::CM_USE_KEEP_LAYOUT, targetMemoryPaddingElements);
761 *
762 * if (!FrameConverter::Comfort::convertAndCopy(anySourceFrame, targetFrame))
763 * {
764 * // there is no converter from the source pixel format to the target pixel format, so we stop here
765 * return false;
766 * }
767 *
768 * // do something here with the RGB memory in `targetMemoryRGB24`
769 *
770 * return true;
771 * }
772 * @endcode
773 * @see isSupported(), convert().
774 */
775 static bool convertAndCopy(const Frame& source, Frame& target, Worker* worker = nullptr, const Options& options = Options());
776
777 /**
778 * Converts / changes a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same dimension but different pixel format or pixel origin.
779 * @param frame The frame to convert, must be valid
780 * @param targetPixelFormat The pixel format of the target frame, must be valid
781 * @param targetPixelOrigin The pixel origin of the target frame, must be valid
782 * @param forceCopy True, if the resulting target image is expected to are the owner of the image data, otherwise the source frame will be the owner of the image data if possible
783 * @param worker Optional worker object to distribute the conversion computation to different CPU cores
784 * @param options The options to be used for conversion
785 * @return True, if the frame type conversion is supported and succeeded
786 */
787 static inline bool change(Frame& frame, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy = true, Worker* worker = nullptr, const Options& options = Options());
788
789 /**
790 * Converts / changes a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same dimension and same pixel origin but different pixel format.
791 * @param frame The frame to convert, must be valid
792 * @param targetPixelFormat The pixel format of the target frame, must be valid
793 * @param forceCopy True, if the resulting target image is expected to are the owner of the image data, otherwise the source frame will be the owner of the image data if possible
794 * @param worker Optional worker object to distribute the conversion computation to different CPU cores
795 * @param options The options to be used for conversion
796 * @return True, if the frame type conversion is supported and succeeded
797 */
798 static inline bool change(Frame& frame, const FrameType::PixelFormat targetPixelFormat, const bool forceCopy = true, Worker* worker = nullptr, const Options& options = Options());
799
800 /**
801 * Converts / changes a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same dimension and same pixel format but different pixel origin.
802 * @param frame The frame to convert, must be valid
803 * @param targetPixelOrigin The pixel origin of the target frame, must be valid
804 * @param forceCopy True, if the resulting target image is expected to are the owner of the image data, otherwise the source frame will be the owner of the image data if possible
805 * @param worker Optional worker object to distribute the conversion computation to different CPU cores
806 * @param options The options to be used for conversion
807 * @return True, if the frame type conversion is supported and succeeded
808 */
809 static inline bool change(Frame& frame, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy = true, Worker* worker = nullptr, const Options& options = Options());
810
811 protected:
812
813 /**
814 * Converts frames with compatible formats that do not require an actual conversion, either memory is copyied or used.
815 * @param source The source frame to convert, must be valid
816 * @param targetType The target frame type, must be valid
817 * @param target The resulting target frame, will be modified if conversion is supported
818 * @param forceCopy True, to force copying of frame data; False, to allow referencing source data when possible
819 * @return True, if the conversion was handled by this function; False, if a different conversion method is needed
820 */
821 static bool convertCompatibleFormats(const Frame& source, const FrameType& targetType, Frame& target, const bool forceCopy);
822
823 /**
824 * Converts frames using a registered conversion function from the ConversionFunctionMap.
825 * This function looks up and applies optimized, format-specific conversion functions
826 * that have been registered in the conversion function map (e.g., YUV to RGB, format-specific conversions).
827 * @param source The source frame to convert, must be valid
828 * @param targetType The target frame type, must be valid
829 * @param target The resulting target frame, will be modified if conversion is supported
830 * @param options The conversion options (e.g., alpha channel value, gamma correction)
831 * @param worker Optional worker object to distribute computation across multiple CPU cores
832 * @return True, if a registered conversion function exists and was applied successfully; False, otherwise
833 */
834 static bool convertWithConversionFunction(const Frame& source, const FrameType& targetType, Frame& target, const Options& options, Worker* worker);
835
836 /**
837 * Converts frames with generic pixel formats.
838 * @param source The source frame to convert, must be valid
839 * @param targetType The target frame type, must be valid
840 * @param target The resulting target frame, will be modified if conversion is supported
841 * @param worker Optional worker object to distribute computation across multiple CPU cores
842 * @return True, if the conversion was successful; False, otherwise
843 */
844 static bool convertGenericFormats(const Frame& source, const FrameType& targetType, Frame& target, Worker* worker);
845 };
846
847 /**
848 * Casts the pixel values from one frame type to another frame type.
849 * The source frame must be a zipped frame e.g., FrameType::FORMAT_Y8, FrameType::FORMAT_RGB24, ...<br>
850 * Beware: This function does not handle any out of range issues and does not apply rounding.<br>
851 * This function mainly does the following:
852 * @code
853 * for each pixel and channel:
854 * targetValue = TTarget(sourceValue)
855 * @endcode
856 * @param source The source frame to be casted, must be valid
857 * @param target The target frame receiving the casted pixel values, must be valid (and not overlap the source frame)
858 * @param width The width of the source (and target frame) in pixel, with range [1, infinity)
859 * @param height The height of the source (and target frame) in pixel, with range [1, infinity)
860 * @param channels The number of channels the source frame (and target frame) has, with range [1, infinity)
861 * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
862 * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
863 * @tparam TSource The data type of each pixel channel of the source frame, e.g., 'uint8_t', 'int', 'float', ...
864 * @tparam TTarget The data type of each pixel channel of the target frame, e.g., 'uint8_t', 'int', 'float', ...
865 *
866 * Here is an example how to use this function:
867 * @code
868 * void function()
869 * {
870 * // we have a source frame e.g., with pixel format RGB 24 bit, 'uint8_t' for each pixel channel
871 * Frame sourceFrame(FrameType(1920u, 1080u, FrameType::FORMAT_RGB24, FrameType::ORIGIN_UPPER_LEFT));
872 *
873 * // set the pixel values of sourceFrame here ...
874 *
875 * // we want to cast this frame to a frame with 32 bit floating point values
876 * // we use the frame type of the source as pattern and change the pixel format only
877 * Frame targetFrame(FrameType(sourceFrame, FrameType::genericPixelFormat(FrameType::DT_SIGNED_FLOAT_32, 3u)));
878 *
879 * // now we simply cast the values from the source frame to the target frame
880 * FrameConverter::cast<uint8_t, float>(sourceFrame.constdata<uint8_t>(), targetFrame.data<float>(), sourceFrame.width(), sourceFrame.height(), sourceFrame.channels());
881 *
882 * // now we can access the floating point pixel values of target
883 * const float* floatRGBValues = targetFrame.constdata<float>();
884 * }
885 * @endcode
886 * @see normalizedCast().
887 */
888 template <typename TSource, typename TTarget>
889 static void cast(const TSource* __restrict source, TTarget* __restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements);
890
891 /**
892 * Casts the pixel values from one frame type to another frame type but also normalizes the casted source values before assigning them (by scaling and offsetting).
893 * The source frame must be a zipped frame e.g., FrameType::FORMAT_Y8, FrameType::FORMAT_RGB24, ...<br>
894 * Beware: This function does not handle any out of range issues and does not apply rounding.<br>
895 * This function mainly does the following:
896 * @code
897 * for each pixel and channel:
898 * targetValue = TTarget(sourceValue) * multiplicationFactor + offset
899 * @endcode
900 * @param source The source frame to be casted, must be valid
901 * @param target The target frame receiving the casted pixel values, must be valid (and not overlap the source frame)
902 * @param width The width of the source (and target frame) in pixel, with range [1, infinity)
903 * @param height The height of the source (and target frame) in pixel, with range [1, infinity)
904 * @param channels The number of channels the source frame (and target frame) has, with range [1, infinity)
905 * @param multiplicationFactor The multiplication factor (with data type TTarget) which will be multiplied with each source values before the value is assigned, should not be zero
906 * @param offset The offset (with data type TTarget) that is added to each value after the conversion
907 * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
908 * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
909 * @tparam TSource The data type of each pixel channel of the source frame, e.g., 'uint8_t', 'int', 'float', ...
910 * @tparam TTarget The data type of each pixel channel of the target frame, e.g., 'uint8_t', 'int', 'float', ...
911 *
912 * Here is an example how to use this function:
913 * @code
914 * void function()
915 * {
916 * // we have a source frame e.g., with pixel format RGB 24 bit, 'uint8_t' for each pixel channel
917 * Frame sourceFrame(FrameType(1920u, 1080u, FrameType::FORMAT_RGB24, FrameType::ORIGIN_UPPER_LEFT));
918 *
919 * // set the pixel values of sourceFrame here ...
920 *
921 * // we want to cast this frame to a frame with 32 bit floating point values
922 * // we use the frame type of the source as pattern and change the pixel format only
923 * Frame targetFrame(FrameType(sourceFrame, FrameType::genericPixelFormat(FrameType::DT_SIGNED_FLOAT_32, 3u)));
924 *
925 * // now we normalize the source values by 1/255 and assign the values - so that we get floating point values with range [0, 1]
926 * FrameConverter::normalizedCast<uint8_t, float>(sourceFrame.constdata<uint8_t>(), targetFrame.data<float>(), sourceFrame.width(), sourceFrame.height(), sourceFrame.channels(), 1.0f / 255.0f, 0);
927 *
928 * // now we can access the normalized floating point pixel values of target
929 * const float* floatRGBValues = targetFrame.constdata<float>();
930 * }
931 * @endcode
932 * @see cast().
933 */
934 template <typename TSource, typename TTarget>
935 static void normalizedCast(const TSource* __restrict source, TTarget* __restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const TTarget multiplicationFactor, const TTarget offset, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements);
936
937 /**
938 * Copies a sub-frame of a given frame into a second frame while both frames might have an individual number of padding elements at the end of each row.
939 * The dimension of the sub-frame must fit into the source and target frame.
940 * @param source The source frame from which the sub-frame will be copied, must be valid
941 * @param target The target frame to which the sub-frame will be copied, must be valid
942 * @param sourceWidth Width of the entire source frame in pixels, with range [1, infinity)
943 * @param sourceHeight Height of the entire source frame in pixels, with range [1, infinity)
944 * @param targetWidth Width of the entire target frame in pixels, with range [1, infinity)
945 * @param targetHeight Height of the entire target frame in pixels, with range [1, infinity)
946 * @param channels Number of data channels of the given source (and target) frame, with range [1, infinity)
947 * @param sourceLeft Horizontal start position of the sub-frame inside the source frame in pixels, with range [0, sourceWidth - 1]
948 * @param sourceTop Vertical start position of the sub-frame inside the source frame in pixels, with range [0, sourceHeight - 1]
949 * @param targetLeft Horizontal start position of the sub-frame inside the target frame in pixels, with range [0, targetWidth -1]
950 * @param targetTop Vertical start position of the sub-frame inside the target frame in pixels, with range [0, targetHeight - 1]
951 * @param width The width of the sub-frame in pixel, with range [1, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
952 * @param height The height of the sub-frame in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
953 * @param sourcePaddingElements Optional number of padding elements at the end of each source row, with range [0, infinity)
954 * @param targetPaddingElements Optional number of padding elements at the end of each target row, with range [0, infinity)
955 * @return True, if succeeded
956 * @tparam T The data type of each element
957 */
958 template <typename T>
959 static bool subFrame(const T* source, T* target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements);
960
961 /**
962 * Copies pixels from one sub-frame to another if the pixels are part of a mask; input may use padding.
963 * The behavior of this function can be described as:
964 * <pre>
965 * target[i] = mask[i] == maskValue ? source[i] : target[i]
966 * </pre>
967 * The dimension of the sub-frame must fit into the source and target frame. The mask must have the same size as the sub-frame.
968 * @param sourceFrame The source frame from which the sub-frame will be copied, must be valid
969 * @param targetFrame The target frame to which the sub-frame will be copied, must be valid
970 * @param maskFrame The binary mask that is used to indicate which source pixels to copy to the target frame, must be valid, have one channel, and have the same size of the region that is copied (`subFrameWidth` x `subFrameHeight`)
971 * @param sourceLeft Horizontal start position of the sub-frame inside the source frame in pixels, with range [0, sourceWidth - 1]
972 * @param sourceTop Vertical start position of the sub-frame inside the source frame in pixels, with range [0, sourceHeight - 1]
973 * @param targetLeft Horizontal start position of the sub-frame inside the target frame in pixels, with range [0, targetWidth -1]
974 * @param targetTop Vertical start position of the sub-frame inside the target frame in pixels, with range [0, targetHeight - 1]
975 * @param subFrameWidth Width of the sub-frame in pixel, with range [0, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
976 * @param subFrameHeight Height of the sub-frame in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
977 * @param maskValue Optional value which indicates which pixel value should be interpreted as the foreground (and copied)
978 * @return True, if succeeded
979 * @tparam T The data type of the elements of the source and target frames
980 */
981 template <typename T>
982 static bool subFrameMask(const Frame& sourceFrame, Frame& targetFrame, const Frame& maskFrame, const uint32_t sourceLeft, const uint32_t sourceTop, const uint32_t targetLeft, const uint32_t targetTop, const uint32_t subFrameWidth, const uint32_t subFrameHeight, const uint8_t maskValue = 0u);
983
984 /**
985 * Copies pixels from one sub-frame to another if the pixels are part of a mask; input may use padding.
986 * The behavior of this function can be described as:
987 * <pre>
988 * target[i] = mask[i] == maskValue ? source[i] : target[i]
989 * </pre>
990 * The dimension of the sub-frame must fit into the source and target frame. The mask must have the same size as the sub-frame.
991 * @param source The source frame from which the sub-frame will be copied, must be valid
992 * @param target The target frame to which the sub-frame will be copied, must be valid
993 * @param mask The binary mask that is used to indicate which source pixels to copy to the target frame, must be valid, have one channel, and have the same size of the region that is copied (`subFrameWidth` x `subFrameHeight`)
994 * @param sourceWidth Width of the entire source frame in pixels, with range [1, infinity)
995 * @param sourceHeight Height of the entire source frame in pixels, with range [1, infinity)
996 * @param targetWidth Width of the entire target frame in pixels, with range [1, infinity)
997 * @param targetHeight Height of the entire target frame in pixels, with range [1, infinity)
998 * @param channels Number of data channels of the given source (and target) frame, with range [1, infinity)
999 * @param sourceLeft Horizontal start position of the sub-frame inside the source frame in pixels, with range [0, sourceWidth - 1]
1000 * @param sourceTop Vertical start position of the sub-frame inside the source frame in pixels, with range [0, sourceHeight - 1]
1001 * @param targetLeft Horizontal start position of the sub-frame inside the target frame in pixels, with range [0, targetWidth -1]
1002 * @param targetTop Vertical start position of the sub-frame inside the target frame in pixels, with range [0, targetHeight - 1]
1003 * @param subFrameWidth Width of the sub-frame in pixel, with range [1, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
1004 * @param subFrameHeight Height of the sub-frame in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
1005 * @param sourcePaddingElements Optional number of padding elements at the end of each source row, with range [0, infinity)
1006 * @param targetPaddingElements Optional number of padding elements at the end of each target row, with range [0, infinity)
1007 * @param maskPaddingElements Optional number of padding elements at the end of each source row, with range [0, infinity)
1008 * @param maskValue Optional value which indicates which pixel value should be interpreted as the foreground (and copied)
1009 * @return True, if succeeded
1010 * @tparam T The data type of the elements of the source and target frames
1011 */
1012 template <typename T>
1013 static bool subFrameMask(const T* source, T* target, const uint8_t* mask, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int maskPaddingElements, const uint8_t maskValue = 0u);
1014
1015 /**
1016 * Copies a small patch area of a given frame into a buffer holding only the entire patch.
1017 * @param source The source frame from which the patch will be copied, must be valid
1018 * @param buffer The target buffer to which the frame content will be copied, must be valid
1019 * @param width The width of the source frame in pixels, with range [patchSize, infinity)
1020 * @param channels Number of data channels of the given source frame, with range [1, infinity)
1021 * @param x Horizontal center position of the patch to be copied in pixel, with range [patchSize/2, width - patchSize/2 - 1]
1022 * @param y Vertical center position of the patch to be copied in pixel, with range [patchSize/2, height - patchSize/2 - 1]
1023 * @param patchSize The side length of the patch to be copied in pixel, with range [1, infinity), must be odd
1024 * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
1025 * @param bufferPaddingElements The number of padding elements at the end of each buffer row, in elements, with range [0, infinity)
1026 * @tparam T The data type of the elements of the source frame and the target buffer, e.g., 'uint8_t', or 'float'
1027 */
1028 template <typename T>
1029 static inline void patchFrame(const T* source, T* buffer, const unsigned int width, const unsigned int channels, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements);
1030
1031 /**
1032 * Copies a small patch area of a frame into a buffer holding only the entire patch.
1033 * Pixels in the patch mapping to positions outside the frame are mirrored into the frame.<br>
1034 * @param source The source frame from which the patch will be copied, must be valid
1035 * @param buffer The target buffer to which the frame content will be copied, must be valid
1036 * @param width The width of the source frame in pixels, with range [patchSize/2+1, infinity)
1037 * @param height The height of the source frame in pixels, with range [patchSize/2+1, infinity)
1038 * @param x Horizontal center position of the patch to be copied in pixel, with range [0, width - 1]
1039 * @param y Vertical center position of the patch to be copied in pixel, with range [0, height - 1]
1040 * @param patchSize The side length of the patch to be copied in pixel, with range [1, infinity), must be odd
1041 * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
1042 * @param bufferPaddingElements The number of padding elements at the end of each buffer row, in elements, with range [0, infinity)
1043 * @tparam T The data type of the elements of the source frame and the target buffer, e.g., 'uint8_t', or 'float'
1044 * @tparam tChannels Number of data channels of the given source frame, with range [1, infinity)
1045 */
1046 template <typename T, unsigned int tChannels>
1047 static void patchFrameMirroredBorder(const T* source, T* buffer, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements);
1048
1049 /**
1050 * Returns the 3x4 color space transformation matrix from full range RGB24 to full range YUV24 using BT.601, analog RGB to (analog) YPbPr.
1051 * Below the precise transformation matrices are given:
1052 * <pre>
1053 * RGB input value range: [0, 255]x[0, 255]x[0, 255]
1054 * YUV output value range: [0, 255]x[0, 255]x[0, 255]
1055 *
1056 * | Y | | 0.299 0.587 0.114 0 | | R |
1057 * | U | = | -0.168736 -0.331264 0.5 128 | * | G |
1058 * | V | | 0.5 -0.418688 -0.081312 128 | | B |
1059 * | 1 |
1060 * Approximation with 7 bit precision:
1061 * | Y | | 38 75 15 0 128 | | R |
1062 * 128 * | U | = | -22 -42 64 128 * 128 | * | G |
1063 * | V | | 64 -54 -10 128 * 128 | | B |
1064 * | 1 |
1065 * </pre>
1066 * @return The 3x4 transformation matrix
1067 * @see transformationMatrix_FullRangeRGB24_To_FullRangeYVU24_BT601().
1068 */
1070
1071 /**
1072 * Returns the 3x4 color space transformation matrix from full range RGB24 to full range YVU24 using BT.601, analog RGB to (analog) YPbPr.
1073 * @return The 3x4 transformation matrix
1074 * @see transformationMatrix_FullRangeRGB24_To_FullRangeYUV24_BT601().
1075 */
1077
1078 /**
1079 * Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YUV24 using BT.601, analog RGB to (digital) YCbCr.
1080 * Below the precise transformation matrices are given:
1081 * <pre>
1082 * RGB input value range: [0, 255]x[0, 255]x[0, 255]
1083 * YUV output value range: [16, 235]x[16, 240]x[16, 240]
1084 *
1085 * | Y | | 0.2578125 0.5039063 0.09765625 16.0 | | R |
1086 * | U | = | -0.1484375 -0.2890625 0.4375 128.0 | * | G |
1087 * | V | | 0.4375 -0.3671875 -0.0703125 128.0 | | B |
1088 * | 1 |
1089 * Approximation with 7 bit precision:
1090 * | Y | | 33 64 13 16 * 128 | | R |
1091 * 128 * | U | = | -19 -37 56 128 * 128 | * | G |
1092 * | V | | 56 -47 -9 128 * 128 | | B |
1093 * | 1 |
1094 * </pre>
1095 * @return The 3x4 transformation matrix
1096 * @see transformationMatrix_FullRangeRGB24_To_LimitedRangeYVU24_BT601().
1097 */
1099
1100 /**
1101 * Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YVU24 using BT.601, analog RGB to (digital) YCbCr.
1102 * @return The 3x4 transformation matrix
1103 * @see transformationMatrix_FullRangeRGB24_To_LimitedRangeYUV24_BT601().
1104 */
1106
1107 /**
1108 * Returns the color space transformation matrix from full range YUV24 to full range BGR24 using BT.601, (analog) YPbPr to analog BGR.
1109 * Below the precise transformation matrices are given:
1110 * <pre>
1111 * YUV input value range: [0, 255]x[0, 255]x[0, 255]
1112 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1113 *
1114 * | B | | 1.0 1.772 0.0 -226.816 | | Y |
1115 * | G | = | 1.0 -0.34414 -0.71414 135.45984 | * | U |
1116 * | R | | 1.0 0.0 1.402 -179.456 | | V |
1117 * | 1 |
1118 *
1119 * Approximation with 6 bit precision:
1120 * | B | | 64 113 0 | | Y |
1121 * 64 * | G | = | 64 -22 -46 | * | U - 128 |
1122 * | R | | 64 0 90 | | V - 128 |
1123 * </pre>
1124 * @return The 3x4 transformation matrix
1125 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android().
1126 */
1128
1129 /**
1130 * Returns the color space transformation matrix from full range YUV24 to full range RGB24 using BT.601, (analog) YPbPr to analog RGB.
1131 * Below the precise transformation matrices are given:
1132 * <pre>
1133 * YUV input value range: [0, 255]x[0, 255]x[0, 255s]
1134 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1135 *
1136 * | R | | 1.0 0.0 1.402 -179.456 | | Y |
1137 * | G | = | 1.0 -0.34414 -0.71414 135.45984 | * | U |
1138 * | B | | 1.0 1.772 0.0 -226.816 | | V |
1139 * | 1 |
1140 *
1141 * Approximation with 6 bit precision:
1142 * | R | | 64 0 90 | | Y |
1143 * 64 * | G | = | 64 -22 -46 | * | U - 128 |
1144 * | B | | 64 113 0 | | V - 128 |
1145 * </pre>
1146 * @return The 3x4 transformation matrix
1147 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android().
1148 */
1150
1151 /**
1152 * Returns the color space transformation matrix from full range YUV24 to full range BGR24 similar to BT.601, (analog) YPbPr to analog BGR.
1153 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1154 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android().
1155 * @return The 3x4 transformation matrix
1156 */
1158
1159 /**
1160 * Returns the color space transformation matrix from full range YUV24 to full range RGB24 similar to BT.601, (analog) YPbPr to analog RGB.
1161 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1162 * The conversion can be found in Android's source code: /media/libstagefright/yuv/YUVImage.cpp<br>
1163 * Below the precise transformation matrices are given:
1164 * <pre>
1165 * YUV input value range: [0, 255]x[0, 255]x[0, 255s]
1166 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1167 *
1168 * | R | | 1.0 0.0 1.370705 | | Y | | 1.0 0.0 1.370705 -175.45024 | | Y |
1169 * | G | = | 1.0 -0.337633 -0.698001 | * | U - 128 | = | 1.0 -0.337633 -0.698001 132.561152 | * | U |
1170 * | B | | 1.0 1.732446 0.0 | | V - 128 | | 1.0 1.732446 0.0 -221.753088 | | V |
1171 * | 1 |
1172 *
1173 * Approximation with 6 bit precision:
1174 * | R | | 64 0 88 | | Y |
1175 * 64 * | G | = | 64 -22 -45 | * | U - 128 |
1176 * | B | | 64 111 0 | | V - 128 |
1177 * </pre>
1178 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_BT601(), transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_Android().
1179 * @return The 3x4 transformation matrix
1180 */
1182
1183 /**
1184 * Returns the color space transformation matrix from full range YVU24 to full range BGR24 similar to BT.601, (analog) YPbPr to analog BGR.
1185 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1186 * @see transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_Android().
1187 * @return The 3x4 transformation matrix
1188 */
1190
1191 /**
1192 * Returns the color space transformation matrix from full range YVU24 to full range RGB24 similar to BT.601, (analog) YPbPr to analog RGB.
1193 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1194 * The conversion can be found in Android's source code: /media/libstagefright/yuv/YUVImage.cpp<br>
1195 * Below the precise transformation matrices are given:
1196 * <pre>
1197 * YUV input value range: [0, 255]x[0, 255]x[0, 255s]
1198 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1199 *
1200 * | R | | 1.0 1.370705 0.0 | | Y | | 1.0 1.370705 0.0 -175.45024 | | Y |
1201 * | G | = | 1.0 -0.698001 -0.337633 | * | V - 128 | = | 1.0 -0.698001 -0.337633 132.561152 | * | V |
1202 * | B | | 1.0 0.0 1.732446 | | U - 128 | | 1.0 0.0 1.732446 -221.753088 | | U |
1203 * | 1 |
1204 *
1205 * Approximation with 6 bit precision:
1206 * | R | | 64 88 0 | | Y |
1207 * 64 * | G | = | 64 -45 -22 | * | V - 128 |
1208 * | B | | 64 0 111 | | U - 128 |
1209 * </pre>
1210 * @return The 3x4 transformation matrix
1211 */
1213
1214 /**
1215 * Returns the color space transformation matrix from limited range YUV24 to full range RGB24 using BT.601, (digital) YCbCr to analog RGB.
1216 * Below the precise transformation matrices are given:
1217 * <pre>
1218 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
1219 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1220 *
1221 * | R | | 1.1639404296875 0.0 1.595947265625 -222.904296875 | | Y |
1222 * | G | = | 1.1639404296875 -0.3909912109375 -0.81298828125 135.486328125 | * | U |
1223 * | B | | 1.1639404296875 2.0179443359375 0.0 -276.919921875 | | V |
1224 * | 1 |
1225 *
1226 * Approximation with 13 bit precision:
1227 * | R | | 9535 0 13074 | | Y - 16 |
1228 * 8192 * | G | = | 9535 -3203 -6660 | * | U - 128 |
1229 * | B | | 9535 16531 0 | | V - 128 |
1230 *
1231 * Approximation with 10 bit precision:
1232 * | R | | 1192 0 1634 -223 * 1024 | | Y |
1233 * 1024 * | G | = | 1192 -400 -833 135 * 1024 | * | U |
1234 * | B | | 1192 2066 0 -277 * 1024 | | V |
1235 * | 1 |
1236 *
1237 * Approximation with 8 bit precision:
1238 * | R | | 298 0 409 | | Y - 16 |
1239 * 256 * | G | = | 298 -409 -208 | * | U - 128 |
1240 * | B | | 298 516 0 | | V - 128 |
1241 *
1242 * Approximation with 6 bit precision:
1243 * | R | | 75 0 102 | | Y - 16 |
1244 * 64 * | G | = | 75 -25 -52 | * | U - 128 |
1245 * | B | | 75 128 0 | | V - 128 |
1246 * </pre>
1247 * @return The 3x4 transformation matrix
1248 */
1250
1251 /**
1252 * Returns the color space transformation matrix from full range BGR24 to limited range YUV24 using BT.601, analog RGB to (digital) YCbCr.
1253 * <pre>
1254 * BGR input value range: [0, 255]x[0, 255]x[0, 255]
1255 * YUV output value range: [16, 235]x[16, 240]x[16, 240]
1256 * </pre>
1257 * @return The 3x4 transformation matrix
1258 * @see transformationMatrixFullRangeRGB24ToLimitedRangeYUV24_BT601().
1259 */
1261
1262 /**
1263 * Returns the 3x4 color space transformation matrix from full range BGR24 to full range YUV24 using BT.601, analog BGR to (analog) YPbPr.
1264 * Below the precise transformation matrices are given:
1265 * <pre>
1266 * BGR input value range: [0, 255]x[0, 255]x[0, 255]
1267 * YUV output value range: [0, 255]x[0, 255]x[0, 255]
1268 *
1269 * | Y | | 0.114 0.587 0.299 0 | | B |
1270 * | U | = | 0.5 -0.331264 -0.168736 128 | * | G |
1271 * | V | | -0.081312 -0.418688 0.5 128 | | R |
1272 * | 1 |
1273 * Approximation with 7 bit precision:
1274 * | Y | | 15 75 38 0 128 | | B |
1275 * 128 * | U | = | 64 -42 -22 128 * 128 | * | G |
1276 * | V | | -10 -54 64 128 * 128 | | R |
1277 * | 1 |
1278 * </pre>
1279 * @return The 3x4 transformation matrix
1280 * @see transformationMatrix_FullRangeRGB24_To_FullRangeYUV24_BT601().
1281 */
1283
1284 /**
1285 * Returns the 3x4 color space transformation matrix from full range BGR24 to full range YVU24 using BT.601, analog BGR to (analog) YPbPr.
1286 * Below the precise transformation matrices are given:
1287 * <pre>
1288 * BGR input value range: [0, 255]x[0, 255]x[0, 255]
1289 * YVU output value range: [0, 255]x[0, 255]x[0, 255]
1290 * </pre>
1291 * @return The 3x4 transformation matrix
1292 * @see transformationMatrix_FullRangeBGR24_To_FullRangeYUV24_BT601().
1293 */
1295
1296 /**
1297 * Returns the color space transformation matrix from limited range YUV24 to full range BGR24 using BT.601, (digital) YCbCr to analog BGR.
1298 * <pre>
1299 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
1300 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
1301 * </pre>
1302 * @return The 3x4 transformation matrix
1303 * @see transformationMatrixLimitedRangeYUV24ToFullRangeRGB24_BT601().
1304 */
1306
1307 /**
1308 * Returns the color space transformation matrix from limited range YVU24 to full range BGR24 using BT.601, (digital) YCrCb to analog BGR.
1309 * <pre>
1310 * YVU input value range: [16, 235]x[16, 240]x[16, 240]
1311 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
1312 * </pre>
1313 * @return The 3x4 transformation matrix
1314 * @see transformationMatrixLimitedRangeYUV24ToFullRangeRGB24_BT601().
1315 */
1317
1318 /**
1319 * Returns the color space transformation matrix from limited range YVU24 to full range RGB24 using BT.601, (digital) YCrCb to analog RGB.
1320 * <pre>
1321 * YVU input value range: [16, 235]x[16, 240]x[16, 240]
1322 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1323 * </pre>
1324 * @return The 3x4 transformation matrix
1325 * @see transformationMatrixLimitedRangeYUV24ToFullRangeRGB24_BT601().
1326 */
1328
1329 /**
1330 * Returns the color space transformation matrix from full range YVU24 to full range RGB24 using BT.601, (digital) YCrCb to analog RGB.
1331 * <pre>
1332 * YVU input value range: [0, 255]x[0, 255]x[0, 255]
1333 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1334 * </pre>
1335 * @return The 3x4 transformation matrix
1336 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_BT601().
1337 */
1339
1340 /**
1341 * Returns the color space transformation matrix from full range YVU24 to full range BGR24 using BT.601, (digital) YCrCb to analog BGR.
1342 * <pre>
1343 * YVU input value range: [0, 255]x[0, 255]x[0, 255]
1344 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
1345 * </pre>
1346 * @return The 3x4 transformation matrix
1347 * @see transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_BT601().
1348 */
1350
1351 /**
1352 * Returns a vector holding all possible conversion flags.
1353 * @return The vector with conversion flags, will be four.
1354 */
1356
1357 /**
1358 * Translates a given conversion flag to a string.
1359 * @param conversionFlag The conversion flag to be translated
1360 * @return The resulting string containing the flag
1361 */
1362 static std::string translateConversionFlag(const ConversionFlag conversionFlag);
1363
1364 protected:
1365
1366 /**
1367 * Casts 16 successive elements from one data type to another data type.
1368 * @param source The 16 source elements that will be casted, must be valid
1369 * @param target The 16 target elements receiving the casted pixel values, must be valid
1370 * @tparam TSource The data type of each pixel channel of the source frame, e.g., 'uint8_t', 'int', 'float', ...
1371 * @tparam TTarget The data type of each pixel channel of the target frame, e.g., 'uint8_t', 'int', 'float', ...
1372 */
1373 template <typename TSource, typename TTarget>
1374 static inline void cast16Elements(const TSource* const source, TTarget* const target);
1375
1376 /**
1377 * Converts a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24, ...) to a frame with generic pixel format (e.g., RGB24, Y8).
1378 * This function needs a function pointer that is able to convert one row, and to reverse the order of pixels in one row in the target frame.
1379 * @param source The source frame with generic pixel format, must be valid
1380 * @param target The target frame with generic pixel format, must be valid
1381 * @param width The width of the frame, with range [1, infinity)
1382 * @param height The height of the frame, with range [1, infinity)
1383 * @param sourceStrideElements Number of horizontal elements between the start of two source rows, in elements, with range [width * elementsPerSourcePixel, infinity)
1384 * @param targetStrideElements Number of horizontal elements between the start of two target rows, in elements, with range [width * elementsPerTargetPixel, infinity)
1385 * @param flag Determining the type of conversion
1386 * @param rowConversionFunction The function able to convert one row, must be valid
1387 * @param targetReversePixelOrderInPlaceFunction The function able to reverse the pixel order in one target row, must be valid if 'flag == CONVERT_MIRRORED || CONVERT_FLIPPED_AND_MIRRORED', can be nullptr otherwise
1388 * @param areContinuous True, if source and target frame have continuous memory (without padding); False, otherwise
1389 * @param options Optional options which are necessary in the row conversion function, otherwise nullptr
1390 * @param worker Optional worker to distribute the computation to several CPU cores
1391 * @tparam TSource The data type of each source pixel element, e.g., 'uint8_t' or 'float'
1392 * @tparam TTarget The data type of each target pixel element, e.g., 'uint8_t' or 'float'
1393 */
1394 template <typename TSource, typename TTarget>
1395 static inline 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);
1396
1397 /**
1398 * Converts a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbitrary pixel format.
1399 * This function needs a function pointer that is able to convert multiple rows.
1400 * @param sources The memory pointers defining the source frame, e.g., several individual points to individual blocks in memory, must be valid
1401 * @param targets The memory pointers defining the target frame, e.g., several individual points to individual blocks in memory, must be valid
1402 * @param width The width of the frame, with range [1, infinity)
1403 * @param height The height of the frame, with range [multipleRowsPerIteration, infinity), must be a multiple of 'multipleRowsPerIteration'
1404 * @param flag The conversion type to be applied
1405 * @param multipleRowsPerIteration The number of rows, the specified rows-conversion-functions 'multipleRowsConversionFunction' can handle within one iteration, with range [1, infinity)
1406 * @param multipleRowsConversionFunction The function able to convert several row, must be valid
1407 * @param options Optional options which are necessary in the rows conversion function, otherwise nullptr
1408 * @param worker Optional worker to distribute the computation to several CPU cores
1409 */
1410 static inline 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);
1411
1412 /**
1413 * Converts a subset of a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24, ...) to a frame with generic pixel format (e.g., Y8).
1414 * This function needs a function pointer that is able to convert one row, and to reverse the order of pixels in one row in the target frame.
1415 * @param source The source frame with generic pixel format, must be valid
1416 * @param target The target frame with generic pixel format, must be valid
1417 * @param width The width of the frame, with range [1, infinity)
1418 * @param height The height of the frame, with range [1, infinity)
1419 * @param sourceStrideBytes Number of bytes between the start of two source rows, in bytes, with range [width * elementsPerSourcePixel * sizeof(channelElement), infinity)
1420 * @param targetStrideBytes Number of bytes between the start of two target rows, in bytes, with range [width * elementsPerTargetPixel * sizeof(channelElement), infinity)
1421 * @param flag Determining the type of conversion
1422 * @param rowConversionFunction The function able to convert one row, must be valid
1423 * @param targetReversePixelOrderInPlaceFunction The function able to reverse the pixel order in one target row, must be valid
1424 * @param areContinuous True, if source and target frame have continuous memory (without padding); False, otherwise
1425 * @param options Optional options which are necessary in the row conversion function, otherwise nullptr
1426 * @param firstRow The first row to be handled, with range [0, height - 1]
1427 * @param numberRows The number of rows to be handled, with range [1, height - firstRow]
1428 * @see convertGenericPixelFormat<T>().
1429 */
1430 static void convertGenericPixelFormatSubset(const uint8_t* source, uint8_t* target, const unsigned int width, const unsigned int height, const unsigned int sourceStrideBytes, const unsigned int targetStrideBytes, const ConversionFlag flag, const RowConversionFunction<uint8_t, uint8_t> rowConversionFunction, const RowReversePixelOrderInPlaceFunction<uint8_t> targetReversePixelOrderInPlaceFunction, const bool areContinuous, const void* options, const unsigned int firstRow, const unsigned int numberRows);
1431
1432 /**
1433 * Converts a subset of a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbitrary pixel format.
1434 * @param sources The memory pointers defining the source frame, e.g., several individual points to individual blocks in memory, must be valid
1435 * @param targets The memory pointers defining the target frame, e.g., several individual points to individual blocks in memory, must be valid
1436 * @param width The width of the frame, with range [1, infinity)
1437 * @param height The height of the frame, with range [multipleRowsPerIteration, infinity), must be a multiple of 'multipleRowsPerIteration'
1438 * @param flag The conversion type to be applied
1439 * @param multipleRowsPerIteration The number of rows, the specified rows-conversion-functions 'multipleRowsConversionFunction' can handle within one iteration, with range [1, infinity)
1440 * @param multipleRowsConversionFunction The function able to convert several row, must be valid
1441 * @param options Optional options which are necessary in the rows conversion function, otherwise nullptr
1442 * @param firstMultipleRow The first multiple-row to be handled, with range [0, height / multipleRowsPerIteration - 1]
1443 * @param numberMultipleRows The number of multiple-rows to be handled, with range [1, height / multipleRowsPerIteration]
1444 * @see convertArbitraryPixelFormat().
1445 */
1446 static void convertArbitraryPixelFormatSubset(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, const unsigned int firstMultipleRow, const unsigned int numberMultipleRows);
1447
1448 /**
1449 * This function is not used anymore due to the corresponding 2-row function.
1450 *
1451 * Converts one row of an image with e.g., a Y_UV12 pixel format to one row of an image with e.g., RGB24 pixel format with 6 bit precision.
1452 * This function needs one plane with the first channel and another plane/block of 2x2 sub-sampled pixels containing the second and third channels.<br>
1453 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^6 = 64, and the intermediate results are divided by 64 to obtain the final color values.<br>
1454 * Note: The bias values (b0-b2) are defined in the domain of the color space and will be subtracted from the source color values.<br>
1455 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1456 * <pre>
1457 * source0: source1:
1458 * --------- ---------
1459 * | Y Y Y Y | | U V U V |
1460 * | Y Y Y Y | | U V U V |
1461 * | Y Y Y Y | ---------
1462 * | Y Y Y Y |
1463 * ---------
1464 * </pre>
1465 *
1466 * The layout of the target image of e.g., a RGB24 image looks like this:
1467 * <pre>
1468 * target:
1469 * ----------------------------
1470 * | R G B R G B R G B R G B |
1471 * | R G B R G B R G B R G B |
1472 * | R G B R G B R G B R G B |
1473 * | R G B R G B R G B R G B |
1474 * ----------------------------
1475 * </pre>
1476 *
1477 * The layout of the options parameters is as follows:
1478 * <pre>
1479 * options[ 0] uint32_t: sourcePlane0PaddingElements
1480 * options[ 1] uint32_t: sourcePlane1PaddingElements
1481 * options[ 2] uint32_t: targetPlanePaddingElements
1482 *
1483 * options[ 3] int32_t: f00
1484 * options[ 4] int32_t: f10
1485 * options[ 5] int32_t: f20
1486 * options[ 6] int32_t: f01
1487 * options[ ] ...
1488 * options[11] int32_t: f22
1489 *
1490 * options[12] int32_t: b0, with range [0, 128]
1491 * options[13] int32_t: b1, with range [0, 128]
1492 * options[14] int32_t: b2, with range [0, 128]
1493 *
1494 * with transformation:
1495 * sb0 = s0 - b0 // source adjusted with bias
1496 * sb1 = s1 - b1
1497 * sb2 = s2 - b2
1498 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
1499 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
1500 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
1501 * </pre>
1502 * @param sources The pointer to the first and second memory block of the source image, must be valid
1503 * @param targets The one pointer to the target image, must be valid
1504 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height 1]
1505 * @param width The width of the frame in pixel, with range [1, infinity), must be even
1506 * @param height The height of the frame in pixel, with range [1, infinity), must be even
1507 * @param conversionFlag The conversion to be applied
1508 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1509 * @see convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit().
1510 */
1511 static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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);
1512
1513 /**
1514 * This function is not used anymore due to the corresponding 2-row function.
1515 *
1516 * Converts one row of an image with e.g., a Y_UV12 pixel format to one row of an image with e.g., RGB24 pixel format with 10 bit precision.
1517 * This function needs one plane with the first channel and another plane/block of 2x2 sub-sampled pixels containing the second and third channels.<br>
1518 * This function uses fixed-point arithmetic with 10 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^10 = 1024, and the intermediate results are divided by 1024 to obtain the final color values.<br>
1519 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
1520 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1521 * <pre>
1522 * source0: source1:
1523 * --------- ---------
1524 * | Y Y Y Y | | U V U V |
1525 * | Y Y Y Y | | U V U V |
1526 * | Y Y Y Y | ---------
1527 * | Y Y Y Y |
1528 * ---------
1529 * </pre>
1530 *
1531 * The layout of the target image of e.g., a RGB24 image looks like this:
1532 * <pre>
1533 * target:
1534 * ----------------------------
1535 * | R G B R G B R G B R G B |
1536 * | R G B R G B R G B R G B |
1537 * | R G B R G B R G B R G B |
1538 * | R G B R G B R G B R G B |
1539 * ----------------------------
1540 * </pre>
1541 *
1542 * The layout of the options parameters is as follows:
1543 * <pre>
1544 * options[ 0] uint32_t: sourcePlane0PaddingElements
1545 * options[ 1] uint32_t: sourcePlane1PaddingElements
1546 * options[ 2] uint32_t: targetPlanePaddingElements
1547 *
1548 * options[ 3] int32_t: f00
1549 * options[ 4] int32_t: f10
1550 * options[ 5] int32_t: f20
1551 * options[ 6] int32_t: f01
1552 * options[ ] ...
1553 * options[11] int32_t: f22
1554 *
1555 * options[12] int32_t: b0
1556 * options[13] int32_t: b1
1557 * options[14] int32_t: b2
1558 *
1559 * with transformation:
1560 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
1561 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
1562 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
1563 * </pre>
1564 * @param sources The pointer to the first and second memory block of the source image, must be valid
1565 * @param targets The one pointer to the target image, must be valid
1566 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height 1]
1567 * @param width The width of the frame in pixel, with range [1, infinity), must be even
1568 * @param height The height of the frame in pixel, with range [1, infinity), must be even
1569 * @param conversionFlag The conversion to be applied
1570 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1571 * @see convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit().
1572 */
1573 static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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);
1574
1575 /**
1576 * Converts two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e.g., an RGB24 pixel format with 6 bit precision.
1577 * This function needs one plane with the first channel and another plane/block of 2x2 sub-sampled pixels containing the second and third channels.<br>
1578 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^6 = 64, and the intermediate results are divided by 64 to obtain the final color values.<br>
1579 * Note: The bias values (b0-b2) are defined in the domain of the color space and will be subtracted from the source color values.<br>
1580 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1581 * <pre>
1582 * source0: source1:
1583 * --------- ---------
1584 * | Y Y Y Y | | U V U V |
1585 * | Y Y Y Y | | U V U V |
1586 * | Y Y Y Y | ---------
1587 * | Y Y Y Y |
1588 * ---------
1589 * </pre>
1590 *
1591 * The layout of the target image of e.g., a RGB24 image looks like this:
1592 * <pre>
1593 * target:
1594 * ----------------------------
1595 * | R G B R G B R G B R G B |
1596 * | R G B R G B R G B R G B |
1597 * | R G B R G B R G B R G B |
1598 * | R G B R G B R G B R G B |
1599 * ----------------------------
1600 * </pre>
1601 *
1602 * The layout of the options parameters is as follows:
1603 * <pre>
1604 * options[ 0] uint32_t: sourcePlane0PaddingElements
1605 * options[ 1] uint32_t: sourcePlane1PaddingElements
1606 * options[ 2] uint32_t: targetPlanePaddingElements
1607 *
1608 * options[ 3] int32_t: f00
1609 * options[ 4] int32_t: f10
1610 * options[ 5] int32_t: f20
1611 * options[ 6] int32_t: f01
1612 * options[ ] ...
1613 * options[11] int32_t: f22
1614 *
1615 * options[12] int32_t: b0, with range [0, 128]
1616 * options[13] int32_t: b1, with range [0, 128]
1617 * options[14] int32_t: b2, with range [0, 128]
1618 *
1619 * with transformation:
1620 * sb0 = s0 - b0 // source adjusted with bias
1621 * sb1 = s1 - b1
1622 * sb2 = s2 - b2
1623 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
1624 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
1625 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
1626 * </pre>
1627 * @param sources The pointer to the first and second memory block of the source image, must be valid
1628 * @param targets The one pointer to the target image, must be valid
1629 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1630 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1631 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1632 * @param conversionFlag The conversion to be applied
1633 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1634 */
1635 static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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);
1636
1637 /**
1638 * Converts two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e.g., an RGB24 pixel format with 10 bit precision.
1639 * This function needs one plane with the first channel and another plane/block of 2x2 sub-sampled pixels containing the second and third channels.<br>
1640 * This function uses fixed-point arithmetic with 10 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^10 = 1024, and the intermediate results are divided by 1024 to obtain the final color values.<br>
1641 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
1642 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1643 * <pre>
1644 * source0: source1:
1645 * --------- ---------
1646 * | Y Y Y Y | | U V U V |
1647 * | Y Y Y Y | | U V U V |
1648 * | Y Y Y Y | ---------
1649 * | Y Y Y Y |
1650 * ---------
1651 * </pre>
1652 *
1653 * The layout of the target image of e.g., a RGB24 image looks like this:
1654 * <pre>
1655 * target:
1656 * ----------------------------
1657 * | R G B R G B R G B R G B |
1658 * | R G B R G B R G B R G B |
1659 * | R G B R G B R G B R G B |
1660 * | R G B R G B R G B R G B |
1661 * ----------------------------
1662 * </pre>
1663 *
1664 * The layout of the options parameters is as follows:
1665 * <pre>
1666 * options[ 0] uint32_t: sourcePlane0PaddingElements
1667 * options[ 1] uint32_t: sourcePlane1PaddingElements
1668 * options[ 2] uint32_t: targetPlanePaddingElements
1669 *
1670 * options[ 3] int32_t: f00
1671 * options[ 4] int32_t: f10
1672 * options[ 5] int32_t: f20
1673 * options[ 6] int32_t: f01
1674 * options[ ] ...
1675 * options[11] int32_t: f22
1676 *
1677 * options[12] int32_t: b0
1678 * options[13] int32_t: b1
1679 * options[14] int32_t: b2
1680 *
1681 * with transformation:
1682 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
1683 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
1684 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
1685 * </pre>
1686 * @param sources The pointer to the first and second memory block of the source image, must be valid
1687 * @param targets The one pointer to the target image, must be valid
1688 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1689 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1690 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1691 * @param conversionFlag The conversion to be applied
1692 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1693 */
1694 static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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);
1695
1696 /**
1697 * Converts two rows of an image with e.g., a RGB pixel format to two rows of an image with e.g., an Y_UV12 pixel format with 7 bit precision.
1698 * This function needs a source image with one plane and a target image with two planes.
1699 * This function uses fixed-point arithmetic with 7 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^7 = 128, and the intermediate results are divided by 128 to obtain the final color values.<br>
1700 * Note: The bias values (b0-b2) are added AFTER the division by 128.<br>
1701 * The layout of the source image of e.g., a RGB24 image looks like this:
1702 * <pre>
1703 * source:
1704 * ----------------------------
1705 * | R G B R G B R G B R G B |
1706 * | R G B R G B R G B R G B |
1707 * | R G B R G B R G B R G B |
1708 * | R G B R G B R G B R G B |
1709 * ----------------------------
1710 * </pre>
1711 *
1712 * The layout of the target image of e.g., an Y_UV12 image looks like this:
1713 * <pre>
1714 * target0: target1:
1715 * --------- ---------
1716 * | Y Y Y Y | | U V U V |
1717 * | Y Y Y Y | | U V U V |
1718 * | Y Y Y Y | ---------
1719 * | Y Y Y Y |
1720 * ---------
1721 * </pre>
1722 *
1723 * The layout of the options parameters is as follows:
1724 * <pre>
1725 * options[ 0] uint32_t: sourcePlanePaddingElements
1726 * options[ 1] uint32_t: targetPlane0PaddingElements
1727 * options[ 2] uint32_t: targetPlane1PaddingElements
1728 *
1729 * options[ 3] int32_t: f00
1730 * options[ 4] int32_t: f10
1731 * options[ 5] int32_t: f20
1732 * options[ 6] int32_t: f01
1733 * options[ ] ...
1734 * options[11] int32_t: f22
1735 *
1736 * options[12] int32_t: b0, with range [-128, 128]
1737 * options[13] int32_t: b1, with range [-128, 128]
1738 * options[14] int32_t: b2, with range [-128, 128]
1739 *
1740 * with transformation:
1741 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 128 + b0, 255)
1742 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 128 + b1, 255)
1743 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 128 + b2, 255)
1744 * </pre>
1745 * @param sources The pointer to the source plane, must be valid
1746 * @param targets The pointers to the first and second target plane, must be valid
1747 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1748 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1749 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1750 * @param conversionFlag The conversion to be applied
1751 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1752 */
1753 static void convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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);
1754
1755 /**
1756 * Converts two rows of an image with e.g., a RGB pixel format to two rows of an image with e.g., an Y_U_V12 pixel format with 7 bit precision.
1757 * This function needs a source image with one plane and a target image with three planes.
1758 * This function uses fixed-point arithmetic with 7 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^7 = 128, and the intermediate results are divided by 128 to obtain the final color values.<br>
1759 * Note: The bias values (b0-b2) are added AFTER the division by 128.<br>
1760 * The layout of the source image of e.g., a RGB24 image looks like this:
1761 * <pre>
1762 * source:
1763 * ----------------------------
1764 * | R G B R G B R G B R G B |
1765 * | R G B R G B R G B R G B |
1766 * | R G B R G B R G B R G B |
1767 * | R G B R G B R G B R G B |
1768 * ----------------------------
1769 * </pre>
1770 *
1771 * The layout of the target image of e.g., an Y_U_V12 image looks like this:
1772 * <pre>
1773 * target0: target1: target2:
1774 * --------- ----- -----
1775 * | Y Y Y Y | | U U | | V V |
1776 * | Y Y Y Y | | U U | | V V |
1777 * | Y Y Y Y | ----- -----
1778 * | Y Y Y Y |
1779 * ---------
1780 * </pre>
1781 *
1782 * The layout of the options parameters is as follows:
1783 * <pre>
1784 * options[ 0] uint32_t: sourcePlanePaddingElements
1785 * options[ 1] uint32_t: targetPlane0PaddingElements
1786 * options[ 2] uint32_t: targetPlane1PaddingElements
1787 * options[ 3] uint32_t: targetPlane2PaddingElements
1788 *
1789 * options[ 4] int32_t: f00
1790 * options[ 5] int32_t: f10
1791 * options[ 6] int32_t: f20
1792 * options[ 7] int32_t: f01
1793 * options[ ] ...
1794 * options[12] int32_t: f22
1795 *
1796 * options[13] int32_t: b0, with range [-128, 128]
1797 * options[14] int32_t: b1, with range [-128, 128]
1798 * options[15] int32_t: b2, with range [-128, 128]
1799 *
1800 * with transformation:
1801 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 128 + b0, 255)
1802 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 128 + b1, 255)
1803 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 128 + b2, 255)
1804 * </pre>
1805 * @param sources The pointer to the source plane, must be valid
1806 * @param targets The pointers to the first, second, and third target planes, must be valid
1807 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1808 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1809 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1810 * @param conversionFlag The conversion to be applied
1811 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1812 */
1813 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);
1814
1815 /**
1816 * Converts (maps) one row of an image with e.g., a Y_U_V24 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format.
1817 * This function needs three source planes each holding one channel.<br>
1818 * The layout of the source image of e.g., an Y_U_V24 image looks like this:
1819 * <pre>
1820 * source0: source1: source2:
1821 * --------- --------- ---------
1822 * | Y Y Y Y | | U U U U | | V V V V |
1823 * | Y Y Y Y | | U U U U | | V V V V |
1824 * | Y Y Y Y | | U U U U | | V V V V |
1825 * | Y Y Y Y | | U U U U | | V V V V |
1826 * --------- --------- ---------
1827 * </pre>
1828 *
1829 * The layout of the target image of e.g., an YUV24 image looks like this:
1830 * <pre>
1831 * target:
1832 * ----------------------------
1833 * | Y U V Y U V Y U V Y U V |
1834 * | Y U V Y U V Y U V Y U V |
1835 * | Y U V Y U V Y U V Y U V |
1836 * | Y U V Y U V Y U V Y U V |
1837 * ----------------------------
1838 * </pre>
1839 *
1840 * The layout of the options parameters is as follows:
1841 * <pre>
1842 * options[0] uint32_t: sourcePlane0PaddingElements
1843 * options[1] uint32_t: sourcePlane1PaddingElements
1844 * options[2] uint32_t: sourcePlane2PaddingElements
1845 * options[2] uint32_t: targetPlanePaddingElements
1846 *
1847 * with transformation:
1848 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1849 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1850 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1851 * </pre>
1852 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
1853 * @param targets The one pointer to the target image, must be valid
1854 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
1855 * @param width The width of the frame in pixel, with range [1, infinity)
1856 * @param height The height of the frame in pixel, with range [1, infinity)
1857 * @param conversionFlag The conversion to be applied
1858 * @param options The 4 options parameters: 4 padding parameters, with ranges [0, infinity), must be valid
1859 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
1860 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
1861 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
1862 */
1863 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
1864 static void mapOneRow_3Plane1Channel_To_1Plane3Channels_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
1865
1866 /**
1867 * Converts (maps) one row of an image with e.g., a RGB24 pixel format to one row of an image with e.g., a R_G_B24 pixel format.
1868 * This function needs one source plane holding three channels.<br>
1869 * The layout of the source image of e.g., a RGB24 image looks like this:
1870 * <pre>
1871 * source:
1872 * ----------------------------
1873 * | R G B R G B R G B R G B |
1874 * | R G B R G B R G B R G B |
1875 * | R G B R G B R G B R G B |
1876 * | R G B R G B R G B R G B |
1877 * ----------------------------
1878 * </pre>
1879 *
1880 * The layout of the target image of e.g., a R_G_B24 image looks like this:
1881 * <pre>
1882 * target0: target1: target2:
1883 * --------- --------- ---------
1884 * | R R R R | | G G G G | | B B B B |
1885 * | R R R R | | G G G G | | B B B B |
1886 * | R R R R | | G G G G | | B B B B |
1887 * | R R R R | | G G G G | | B B B B |
1888 * --------- --------- ---------
1889 * </pre>
1890 *
1891 * The layout of the options parameters is as follows:
1892 * <pre>
1893 * options[0] uint32_t: sourcePlanePaddingElements
1894 * options[1] uint32_t: targetPlane0PaddingElements
1895 * options[2] uint32_t: targetPlane1PaddingElements
1896 * options[3] uint32_t: targetPlane2PaddingElements
1897 *
1898 * with transformation:
1899 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1900 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1901 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1902 * </pre>
1903 * @param sources The one pointer to the source image, must be valid
1904 * @param targets The pointer to the first, second, and third memory block of the target image, must be valid
1905 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
1906 * @param width The width of the frame in pixel, with range [1, infinity)
1907 * @param height The height of the frame in pixel, with range [1, infinity)
1908 * @param conversionFlag The conversion to be applied
1909 * @param options The 4 options parameters: 4 padding parameters, with ranges [0, infinity), must be valid
1910 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
1911 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
1912 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
1913 */
1914 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
1915 static void mapOneRow_1Plane3Channels_To_3Plane1Channel_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
1916
1917 /**
1918 * Converts (matches) one row of an image with e.g., a Y_UV12 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format.
1919 * This function needs one plane with the first channel and another plane/block of 2x2 sub-sampled pixels containing the second and third channels.<br>
1920 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1921 * <pre>
1922 * source0: source1:
1923 * --------- ---------
1924 * | Y Y Y Y | | U V U V |
1925 * | Y Y Y Y | | U V U V |
1926 * | Y Y Y Y | ---------
1927 * | Y Y Y Y |
1928 * ---------
1929 * </pre>
1930 *
1931 * The layout of the target image of e.g., an YUV24 image looks like this:
1932 * <pre>
1933 * target:
1934 * ----------------------------
1935 * | Y U V Y U V Y U V Y U V |
1936 * | Y U V Y U V Y U V Y U V |
1937 * | Y U V Y U V Y U V Y U V |
1938 * | Y U V Y U V Y U V Y U V |
1939 * ----------------------------
1940 * </pre>
1941 *
1942 * The layout of the options parameters is as follows:
1943 * <pre>
1944 * options[0] uint32_t: sourcePlane0PaddingElements
1945 * options[1] uint32_t: sourcePlane1PaddingElements
1946 * options[2] uint32_t: targetPlanePaddingElements
1947 *
1948 * with transformation:
1949 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1950 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1951 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1952 * </pre>
1953 * @param sources The pointer to the first and second memory block of the source image, must be valid
1954 * @param targets The one pointer to the target image, must be valid
1955 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
1956 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1957 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1958 * @param conversionFlag The conversion to be applied
1959 * @param options The 3 options parameters: 3 padding parameters, with ranges [0, infinity), must be valid
1960 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
1961 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
1962 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
1963 */
1964 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
1965 static void mapOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
1966
1967 /**
1968 * Converts (matches) two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e.g., an YUV24 or YVU24 pixel format.
1969 * This function needs one plane with the first channel and another plane/block of 2x2 sub-sampled pixels containing the second and third channels.<br>
1970 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1971 * <pre>
1972 * source0: source1:
1973 * --------- ---------
1974 * | Y Y Y Y | | U V U V |
1975 * | Y Y Y Y | | U V U V |
1976 * | Y Y Y Y | ---------
1977 * | Y Y Y Y |
1978 * ---------
1979 * </pre>
1980 *
1981 * The layout of the options parameters is as follows:
1982 * <pre>
1983 * options[0] uint32_t: sourcePlanePaddingElements
1984 * options[1] uint32_t: sourceZippedPaddingElements
1985 * options[2] uint32_t: targetZippedPaddingElements
1986 *
1987 * with transformation:
1988 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1989 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1990 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1991 * </pre>
1992 * @param sources The pointer to the first and second memory block of the source image, must be valid
1993 * @param targets The one pointer to the target image, must be valid
1994 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1995 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1996 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1997 * @param conversionFlag The conversion to be applied
1998 * @param options The 3 options parameters: 3 padding parameters, with ranges [0, infinity), must be valid
1999 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
2000 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
2001 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
2002 */
2003 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2004 static void mapTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2005
2006 /**
2007 * Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e.g., an RGB24 pixel format with 10 bit precision.
2008 * This function needs one plane with the first channel, and two additional planes with 2x2 sub-sampled pixels containing the second and third channels.<br>
2009 * This function uses fixed-point arithmetic with 10 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^10 = 1024, and the intermediate results are divided by 1024 to obtain the final color values.<br>
2010 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2011 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2012 * <pre>
2013 * source0: source1: source2:
2014 * --------- ----- -----
2015 * | Y Y Y Y | | U U | | V V |
2016 * | Y Y Y Y | | U U | | V V |
2017 * | Y Y Y Y | ----- -----
2018 * | Y Y Y Y |
2019 * ---------
2020 * </pre>
2021 *
2022 * The layout of the options parameters is as follows:
2023 * <pre>
2024 * options[ 0] uint32_t: sourcePlane0PaddingElements
2025 * options[ 1] uint32_t: sourcePlane1PaddingElements
2026 * options[ 2] uint32_t: sourcePlane2PaddingElements
2027 * options[ 3] uint32_t: targetZippedPaddingElements
2028 *
2029 * options[ 4] int32_t: f00
2030 * options[ 5] int32_t: f10
2031 * options[ 6] int32_t: f20
2032 * options[ 7] int32_t: f01
2033 * options[ ] ...
2034 * options[12] int32_t: f22
2035 *
2036 * options[13] int32_t: b0
2037 * options[14] int32_t: b1
2038 * options[15] int32_t: b2
2039 *
2040 * with transformation:
2041 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2042 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2043 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2044 * </pre>
2045 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2046 * @param targets The one pointer to the target image, must be valid
2047 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2048 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2049 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2050 * @param conversionFlag The conversion to be applied
2051 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2052 */
2053 static void convertOneRow_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);
2054
2055 /**
2056 * Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an RGB24 pixel format with 10 bit precision.
2057 * This function needs one plane with the first channel, and two additional planes with 2x2 sub-sampled pixels containing the second and third channels.<br>
2058 * This function uses fixed-point arithmetic with 10 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^10 = 1024, and the intermediate results are divided by 1024 to obtain the final color values.<br>
2059 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2060 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2061 * <pre>
2062 * source0: source1: source2:
2063 * --------- ----- -----
2064 * | Y Y Y Y | | U U | | V V |
2065 * | Y Y Y Y | | U U | | V V |
2066 * | Y Y Y Y | ----- -----
2067 * | Y Y Y Y |
2068 * ---------
2069 * </pre>
2070 *
2071 * The layout of the options parameters is as follows:
2072 * <pre>
2073 * options[ 0] uint32_t: sourcePlane0PaddingElements
2074 * options[ 1] uint32_t: sourcePlane1PaddingElements
2075 * options[ 2] uint32_t: sourcePlane2PaddingElements
2076 * options[ 3] uint32_t: targetZippedPaddingElements
2077 *
2078 * options[ 4] int32_t: f00
2079 * options[ 5] int32_t: f10
2080 * options[ 6] int32_t: f20
2081 * options[ 7] int32_t: f01
2082 * options[ ] ...
2083 * options[12] int32_t: f22
2084 *
2085 * options[13] int32_t: b0
2086 * options[14] int32_t: b1
2087 * options[15] int32_t: b2
2088 *
2089 * with transformation:
2090 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2091 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2092 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2093 * </pre>
2094 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2095 * @param targets The one pointer to the target image, must be valid
2096 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
2097 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2098 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2099 * @param conversionFlag The conversion to be applied
2100 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2101 */
2102 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);
2103
2104 /**
2105 * Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format.
2106 * This function needs one plane with the first channel, and two additional planes with 2x2 sub-sampled pixels containing the second and third channels.<br>
2107 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2108 * <pre>
2109 * source0: source1: source2:
2110 * --------- ----- -----
2111 * | Y Y Y Y | | U U | | V V |
2112 * | Y Y Y Y | | U U | | V V |
2113 * | Y Y Y Y | ----- -----
2114 * | Y Y Y Y |
2115 * ---------
2116 * </pre>
2117 *
2118 * The layout of the options parameters is as follows:
2119 * <pre>
2120 * options[0] uint32_t: sourcePlane0PaddingElements
2121 * options[1] uint32_t: sourcePlane1PaddingElements
2122 * options[2] uint32_t: sourcePlane2PaddingElements
2123 * options[3] uint32_t: targetZippedPaddingElements
2124 *
2125 * with transformation:
2126 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2127 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2128 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2129 * </pre>
2130 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2131 * @param targets The one pointer to the target image, must be valid
2132 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2133 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2134 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2135 * @param conversionFlag The conversion to be applied
2136 * @param options The 4 options parameters: 4 padding parameters, must be valid
2137 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2138 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2139 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2140 * @see mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel().
2141 */
2142 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2143 static void mapOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2144
2145 /**
2146 * Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an YUV24 or YVU24 pixel format.
2147 * This function needs one plane with the first channel, and two additional planes with 2x2 sub-sampled pixels containing the second and third channels.<br>
2148 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2149 * <pre>
2150 * source0: source1: source2:
2151 * --------- ----- -----
2152 * | Y Y Y Y | | U U | | V V |
2153 * | Y Y Y Y | | U U | | V V |
2154 * | Y Y Y Y | ----- -----
2155 * | Y Y Y Y |
2156 * ---------
2157 * </pre>
2158 *
2159 * The layout of the options parameters is as follows:
2160 * <pre>
2161 * options[0] uint32_t: sourcePlane0PaddingElements
2162 * options[1] uint32_t: sourcePlane1PaddingElements
2163 * options[2] uint32_t: sourcePlane2PaddingElements
2164 * options[3] uint32_t: targetZippedPaddingElements
2165 *
2166 * with transformation:
2167 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2168 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2169 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2170 * </pre>
2171 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2172 * @param targets The one pointer to the target image, must be valid
2173 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
2174 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2175 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2176 * @param conversionFlag The conversion to be applied
2177 * @param options The 4 options parameters: 4 padding parameters, must be valid
2178 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2179 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2180 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2181 * @see mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel().
2182 */
2183 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2184 static void mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2185
2186 /**
2187 * Converts two rows of an image with e.g., a YUV24 pixel format to two rows of an image with e.g., an Y_U_V12 or Y_V_U12 pixel format.
2188 * This function is mainly the reverse conversion function of mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel().<br>
2189 * The layout of the options parameters is as follows:
2190 * <pre>
2191 * options[0] uint32_t: sourceZippedPaddingElements
2192 * options[1] uint32_t: targetPlane0PaddingElements
2193 * options[2] uint32_t: targetPlane1PaddingElements
2194 * options[3] uint32_t: targetPlane2PaddingElements
2195 *
2196 * with transformation:
2197 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2198 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2199 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2200 * </pre>
2201 * @param sources The one pointer to the source image, must be valid
2202 * @param targets The pointer to the first, second, and third memory block of the target image, must be valid
2203 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
2204 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2205 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2206 * @param conversionFlag The conversion to be applied
2207 * @param options The 4 options parameters: 4 padding parameters, must be valid
2208 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2209 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2210 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2211 * @see mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel().
2212 */
2213 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2214 static void mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2215
2216 /**
2217 * Converts one row of an image with e.g., a Y_U_V24 pixel format to one rows of an image with e.g., an RGB24 pixel format.
2218 * This function needs three source planes/blocks with three individual channels.
2219 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^6 = 64, and the intermediate results are divided by 64 to obtain the final color values.<br>
2220 * Note: The bias values (b0-b2) are defined in the domain of the color space and will be subtracted from the source color values.<br>
2221 * The layout of the options parameters is as follows:
2222 * <pre>
2223 * options[ 0] uint32_t: sourcePlane0PaddingElements
2224 * options[ 1] uint32_t: sourcePlane1PaddingElements
2225 * options[ 2] uint32_t: sourcePlane2PaddingElements
2226 * options[ 3] uint32_t: targetZippedPaddingElements
2227 *
2228 * options[ 4] int32_t: f00
2229 * options[ 5] int32_t: f10
2230 * options[ 6] int32_t: f20
2231 * options[ 7] int32_t: f01
2232 * options[ ] ...
2233 * options[12] int32_t: f22
2234 *
2235 * options[13] int32_t: b0, with range [0, 128]
2236 * options[14] int32_t: b1, with range [0, 128]
2237 * options[15] int32_t: b2, with range [0, 128]
2238 *
2239 * with transformation:
2240 * sb0 = s0 - b0 // source adjusted with bias
2241 * sb1 = s1 - b1
2242 * sb2 = s2 - b2
2243 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2244 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2245 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2246 * </pre>
2247 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2248 * @param targets The one pointer to the target image, must be valid
2249 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2250 * @param width The width of the frame in pixel, with range [1, infinity)
2251 * @param height The height of the frame in pixel, with range [1, infinity)
2252 * @param conversionFlag The conversion to be applied
2253 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2254 */
2255 static void convertOneRow_3Planes1Channel_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);
2256
2257 /**
2258 * Converts one row of an image with e.g., a Y_U_V24 pixel format to one rows of an image with e.g., an RGBA32 pixel format.
2259 * This function needs three source planes/blocks with three individual channels.
2260 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^6 = 64, and the intermediate results are divided by 64 to obtain the final color values.<br>
2261 * Note: The bias values (b0-b2) are defined in the domain of the color space and will be subtracted from the source color values.<br>
2262 * The layout of the options parameters is as follows:
2263 * <pre>
2264 * options[ 0] uint32_t: sourcePlane0PaddingElements
2265 * options[ 1] uint32_t: sourcePlane1PaddingElements
2266 * options[ 2] uint32_t: sourcePlane2PaddingElements
2267 * options[ 3] uint32_t: targetZippedPaddingElements
2268 *
2269 * options[ 4] int32_t: f00
2270 * options[ 5] int32_t: f10
2271 * options[ 6] int32_t: f20
2272 * options[ 7] int32_t: f01
2273 * options[ ] ...
2274 * options[12] int32_t: f22
2275 *
2276 * options[13] int32_t: b0, with range [0, 128]
2277 * options[14] int32_t: b1, with range [0, 128]
2278 * options[15] int32_t: b2, with range [0, 128]
2279 *
2280 * options[16] int32_t: channelValue3, with range [0, 255]
2281 *
2282 * with transformation:
2283 * sb0 = s0 - b0 // source adjusted with bias
2284 * sb1 = s1 - b1
2285 * sb2 = s2 - b2
2286 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2287 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2288 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2289 * t3 = channelValue3
2290 * </pre>
2291 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2292 * @param targets The one pointer to the target image, must be valid
2293 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2294 * @param width The width of the frame in pixel, with range [1, infinity)
2295 * @param height The height of the frame in pixel, with range [1, infinity)
2296 * @param conversionFlag The conversion to be applied
2297 * @param options The 17 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, one constant channel value, must be valid
2298 */
2299 static void convertOneRow_3Planes1Channel_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);
2300
2301 /**
2302 * Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e.g., an RGBA32 pixel format.
2303 * This function needs one plane with the first channel, and two additional planes with 2x2 sub-sampled pixels containing the second and third channels.<br>
2304 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^6 = 64, and the intermediate results are divided by 64 to obtain the final color values.<br>
2305 * Note: The bias values (b0-b2) are defined in the domain of the color space and will be subtracted from the source color values.<br>
2306 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2307 * <pre>
2308 * source0: source1: source2:
2309 * --------- ----- -----
2310 * | Y Y Y Y | | U U | | V V |
2311 * | Y Y Y Y | | U U | | V V |
2312 * | Y Y Y Y | ----- -----
2313 * | Y Y Y Y |
2314 * ---------
2315 * </pre>
2316 * The layout of the options parameters is as follows:
2317 * <pre>
2318 * options[ 0] uint32_t: sourcePlane0PaddingElements
2319 * options[ 1] uint32_t: sourcePlane1PaddingElements
2320 * options[ 2] uint32_t: sourcePlane2PaddingElements
2321 * options[ 3] uint32_t: targetZippedPaddingElements
2322 *
2323 * options[ 4] int32_t: f00
2324 * options[ 5] int32_t: f10
2325 * options[ 6] int32_t: f20
2326 * options[ 7] int32_t: f01
2327 * options[ ] ...
2328 * options[12] int32_t: f22
2329 *
2330 * options[13] int32_t: b0, with range [0, 128]
2331 * options[14] int32_t: b1, with range [0, 128]
2332 * options[15] int32_t: b2, with range [0, 128]
2333 *
2334 * options[16] int32_t: channelValue3
2335 *
2336 * with transformation:
2337 * sb0 = s0 - b0 // source adjusted with bias
2338 * sb1 = s1 - b1
2339 * sb2 = s2 - b2
2340 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2341 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2342 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2343 * t3 = channelValue3
2344 * </pre>
2345 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2346 * @param targets The one pointer to the target image, must be valid
2347 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2348 * @param width The width of the frame in pixel, with range [1, infinity)
2349 * @param height The height of the frame in pixel, with range [1, infinity)
2350 * @param conversionFlag The conversion to be applied
2351 * @param options The 17 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, one constant channel value, must be valid
2352 */
2353 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);
2354
2355 /**
2356 * Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an RGB24 pixel format.
2357 * This function needs one plane with the first channel, and two additional planes with 2x2 sub-sampled pixels containing the second and third channels.<br>
2358 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^6 = 64, and the intermediate results are divided by 64 to obtain the final color values.<br>
2359 * Note: The bias values (b0-b2) are defined in the domain of the color space and will be subtracted from the source color values.<br>
2360 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2361 * <pre>
2362 * source0: source1: source2:
2363 * --------- ----- -----
2364 * | Y Y Y Y | | U U | | V V |
2365 * | Y Y Y Y | | U U | | V V |
2366 * | Y Y Y Y | ----- -----
2367 * | Y Y Y Y |
2368 * ---------
2369 *
2370 * The layout of the target image of e.g., a RGB24 image looks like this:
2371 * <pre>
2372 * target:
2373 * ----------------------------
2374 * | R G B R G B R G B R G B |
2375 * | R G B R G B R G B R G B |
2376 * | R G B R G B R G B R G B |
2377 * | R G B R G B R G B R G B |
2378 * ----------------------------
2379 * </pre>
2380 *
2381 * </pre>
2382 * The layout of the options parameters is as follows:
2383 * <pre>
2384 * options[ 0] uint32_t: sourcePlane0PaddingElements
2385 * options[ 1] uint32_t: sourcePlane1PaddingElements
2386 * options[ 2] uint32_t: sourcePlane2PaddingElements
2387 * options[ 3] uint32_t: targetPlanePaddingElements
2388 *
2389 * options[ 4] int32_t: f00
2390 * options[ 5] int32_t: f10
2391 * options[ 6] int32_t: f20
2392 * options[ 7] int32_t: f01
2393 * options[ ] ...
2394 * options[12] int32_t: f22
2395 *
2396 * options[13] int32_t: b0, with range [0, 128]
2397 * options[14] int32_t: b1, with range [0, 128]
2398 * options[15] int32_t: b2, with range [0, 128]
2399 *
2400 * with transformation:
2401 * sb0 = s0 - b0 // source adjusted with bias
2402 * sb1 = s1 - b1
2403 * sb2 = s2 - b2
2404 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2405 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2406 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2407 * </pre>
2408 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2409 * @param targets The one pointer to the target image, must be valid
2410 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2411 * @param width The width of the frame in pixel, with range [1, infinity)
2412 * @param height The height of the frame in pixel, with range [2, infinity)
2413 * @param conversionFlag The conversion to be applied
2414 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2415 */
2416 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);
2417
2418 /**
2419 * Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an RGBA32 pixel format.
2420 * This function needs one plane with the first channel, and two additional planes with 2x2 sub-sampled pixels containing the second and third channels.<br>
2421 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^6 = 64, and the intermediate results are divided by 64 to obtain the final color values.<br>
2422 * Note: The bias values (b0-b2) are defined in the domain of the color space and will be subtracted from the source color values.<br>
2423 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2424 * <pre>
2425 * source0: source1: source2:
2426 * --------- ----- -----
2427 * | Y Y Y Y | | U U | | V V |
2428 * | Y Y Y Y | | U U | | V V |
2429 * | Y Y Y Y | ----- -----
2430 * | Y Y Y Y |
2431 * ---------
2432 *
2433 * The layout of the target image of e.g., a RGBA32 image looks like this:
2434 * <pre>
2435 * target:
2436 * ------------------------------------
2437 * | R G B A R G B A R G B A R G B A |
2438 * | R G B A R G B A R G B A R G B A |
2439 * | R G B A R G B A R G B A R G B A |
2440 * | R G B A R G B A R G B A R G B A |
2441 * ------------------------------------
2442 * </pre>
2443 *
2444 * </pre>
2445 * The layout of the options parameters is as follows:
2446 * <pre>
2447 * options[ 0] uint32_t: sourcePlane0PaddingElements
2448 * options[ 1] uint32_t: sourcePlane1PaddingElements
2449 * options[ 2] uint32_t: sourcePlane2PaddingElements
2450 * options[ 3] uint32_t: targetPlanePaddingElements
2451 *
2452 * options[ 4] int32_t: f00
2453 * options[ 5] int32_t: f10
2454 * options[ 6] int32_t: f20
2455 * options[ 7] int32_t: f01
2456 * options[ ] ...
2457 * options[12] int32_t: f22
2458 *
2459 * options[13] int32_t: b0, with range [0, 128]
2460 * options[14] int32_t: b1, with range [0, 128]
2461 * options[15] int32_t: b2, with range [0, 128]
2462 *
2463 * options[16] int32_t: channelValue3, with range [0, 255]
2464 *
2465 * with transformation:
2466 * sb0 = s0 - b0 // source adjusted with bias
2467 * sb1 = s1 - b1
2468 * sb2 = s2 - b2
2469 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2470 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2471 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2472 * t3 = channelValue3
2473 * </pre>
2474 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2475 * @param targets The one pointer to the target image, must be valid
2476 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2477 * @param width The width of the frame in pixel, with range [1, infinity)
2478 * @param height The height of the frame in pixel, with range [2, infinity)
2479 * @param conversionFlag The conversion to be applied
2480 * @param options The 17 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, one constant channel value, must be valid
2481 */
2482 static void convertTwoRows_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);
2483
2484 /**
2485 * Converts one row of an image with e.g., a YUYV16 pixel format to one row of an image with e.g., an RGB24 or BGR2424 pixel format.
2486 * This function uses fixed-point arithmetic with 10 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^10 = 1024, and the intermediate results are divided by 1024 to obtain the final color values.<br>
2487 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2488 * The layout of the options parameters is as follows:
2489 * <pre>
2490 * options[ 0] uint32_t: sourcePaddingElements
2491 * options[ 1] uint32_t: targetPaddingElements
2492 *
2493 * options[ 2] int32_t: f00
2494 * options[ 3] int32_t: f10
2495 * options[ 4] int32_t: f20
2496 * options[ 5] int32_t: f01
2497 * options[ ] ...
2498 * options[10] int32_t: f22
2499 *
2500 * options[11] int32_t: b0
2501 * options[12] int32_t: b1
2502 * options[13] int32_t: b2
2503 *
2504 * with transformation:
2505 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2506 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2507 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2508 * </pre>
2509 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2510 * @param targets The one pointer to the target image, must be valid
2511 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2512 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2513 * @param height The height of the frame in pixel, with range [1, infinity), must be even
2514 * @param conversionFlag The conversion to be applied
2515 * @param options The 14 options parameters: 2 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2516 */
2517 static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_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);
2518
2519 /**
2520 * Converts one row of an image with e.g., a UYVY16 pixel format to one row of an image with e.g., an RGB24 or BGR2424 pixel format.
2521 * This function uses fixed-point arithmetic with 10 fractional bits: the conversion factors (f00-f22) are provided pre-multiplied by 2^10 = 1024, and the intermediate results are divided by 1024 to obtain the final color values.<br>
2522 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2523 * The layout of the options parameters is as follows:
2524 * <pre>
2525 * options[ 0] uint32_t: sourcePaddingElements
2526 * options[ 1] uint32_t: targetPaddingElements
2527 *
2528 * options[ 2] int32_t: f00
2529 * options[ 3] int32_t: f10
2530 * options[ 4] int32_t: f20
2531 * options[ 5] int32_t: f01
2532 * options[ ] ...
2533 * options[10] int32_t: f22
2534 *
2535 * options[11] int32_t: b0
2536 * options[12] int32_t: b1
2537 * options[13] int32_t: b2
2538 *
2539 * with transformation:
2540 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2541 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2542 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2543 * </pre>
2544 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2545 * @param targets The one pointer to the target image, must be valid
2546 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2547 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2548 * @param height The height of the frame in pixel, with range [1, infinity), must be even
2549 * @param conversionFlag The conversion to be applied
2550 * @param options The 14 options parameters: 2 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2551 */
2552 static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_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);
2553
2554 /**
2555 * Converts one row of a single-channel image to another single-channel image with 6-bit precision.
2556 * This function supports grayscale range conversions (e.g., Y8_LIMITED_RANGE [16, 235] ↔ Y8_FULL_RANGE [0, 255]).
2557 * This function uses fixed-point arithmetic with 6 fractional bits: the conversion factor is pre-multiplied by 2^6 = 64, and the result is divided by 64.<br>
2558 * The layout of the options parameters is as follows:
2559 * <pre>
2560 * options[0] uint32_t: sourcePaddingElements
2561 * options[1] uint32_t: targetPaddingElements
2562 *
2563 * options[2] int32_t: factor (pre-multiplied by 64)
2564 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2565 * options[4] int32_t: biasOutput (added to output after division)
2566 *
2567 * with transformation:
2568 * t = clamp(0, ((s - biasInput) * factor) / 64 + biasOutput, 255)
2569 * </pre>
2570 * @param sources The pointer to the source plane, must be valid
2571 * @param targets The pointer to the target plane, must be valid
2572 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2573 * @param width The width of the frame in pixel, with range [1, infinity)
2574 * @param height The height of the frame in pixel, with range [1, infinity)
2575 * @param conversionFlag The conversion to be applied
2576 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2577 */
2578 static void convertOneRow_1Plane1Channel_To_1Plane1Channel_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);
2579
2580 /**
2581 * Converts one row of a single-channel image to another single-channel image with 10-bit precision.
2582 * This function supports grayscale range conversions (e.g., Y8_LIMITED_RANGE [16, 235] ↔ Y8_FULL_RANGE [0, 255]).
2583 * This function uses fixed-point arithmetic with 10 fractional bits: the conversion factor is pre-multiplied by 2^10 = 1024, and the result is divided by 1024.<br>
2584 * The layout of the options parameters is as follows:
2585 * <pre>
2586 * options[0] uint32_t: sourcePaddingElements
2587 * options[1] uint32_t: targetPaddingElements
2588 *
2589 * options[2] int32_t: factor (pre-multiplied by 1024)
2590 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2591 * options[4] int32_t: biasOutput (added to output after division)
2592 *
2593 * with transformation:
2594 * t = clamp(0, ((s - biasInput) * factor) / 1024 + biasOutput, 255)
2595 * </pre>
2596 * @param sources The pointer to the source plane, must be valid
2597 * @param targets The pointer to the target plane, must be valid
2598 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2599 * @param width The width of the frame in pixel, with range [1, infinity)
2600 * @param height The height of the frame in pixel, with range [1, infinity)
2601 * @param conversionFlag The conversion to be applied
2602 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2603 */
2604 static void convertOneRow_1Plane1Channel_To_1Plane1Channel_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);
2605
2606 /**
2607 * Converts one row of a single-channel image to a 3-channel image with 10-bit precision and range conversion.
2608 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGB24 [0, 255].
2609 * This function uses fixed-point arithmetic with 10 fractional bits and replicates the converted value to all 3 channels.<br>
2610 * The layout of the options parameters is as follows:
2611 * <pre>
2612 * options[0] uint32_t: sourcePaddingElements
2613 * options[1] uint32_t: targetPaddingElements
2614 *
2615 * options[2] int32_t: factor (pre-multiplied by 1024)
2616 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2617 * options[4] int32_t: biasOutput (added to output after division)
2618 *
2619 * with transformation:
2620 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 1024 + biasOutput, 255)
2621 *
2622 * Example for Y8_LIMITED_RANGE [16, 235] → RGB24 [0, 255]:
2623 * factor = 1192 (255/219 * 1024), biasInput = 16, biasOutput = 0
2624 * </pre>
2625 * @param sources The pointer to the source plane, must be valid
2626 * @param targets The pointer to the target plane, must be valid
2627 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2628 * @param width The width of the frame in pixel, with range [1, infinity)
2629 * @param height The height of the frame in pixel, with range [1, infinity)
2630 * @param conversionFlag The conversion to be applied
2631 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2632 */
2633 static void convertOneRow_1Plane1Channel_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);
2634
2635 /**
2636 * Converts one row of a single-channel image to a 3-channel image with 6-bit precision and range conversion.
2637 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGB24 [0, 255].
2638 * This function uses fixed-point arithmetic with 6 fractional bits and replicates the converted value to all 3 channels.<br>
2639 * The layout of the options parameters is as follows:
2640 * <pre>
2641 * options[0] uint32_t: sourcePaddingElements
2642 * options[1] uint32_t: targetPaddingElements
2643 *
2644 * options[2] int32_t: factor (pre-multiplied by 64)
2645 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2646 * options[4] int32_t: biasOutput (added to output after division)
2647 *
2648 * with transformation:
2649 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 64 + biasOutput, 255)
2650 *
2651 * Example for Y8_LIMITED_RANGE [16, 235] → RGB24 [0, 255]:
2652 * factor = 75 (255/219 * 64), biasInput = 16, biasOutput = 0
2653 * </pre>
2654 * @param sources The pointer to the source plane, must be valid
2655 * @param targets The pointer to the target plane, must be valid
2656 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2657 * @param width The width of the frame in pixel, with range [1, infinity)
2658 * @param height The height of the frame in pixel, with range [1, infinity)
2659 * @param conversionFlag The conversion to be applied
2660 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2661 */
2662 static void convertOneRow_1Plane1Channel_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);
2663
2664 /**
2665 * Converts one row of a single-channel image to a 4-channel image with 10-bit precision and range conversion.
2666 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGBA32 [0, 255].
2667 * This function uses fixed-point arithmetic with 10 fractional bits and replicates the converted value to first 3 channels, with a constant alpha.<br>
2668 * The layout of the options parameters is as follows:
2669 * <pre>
2670 * options[0] uint32_t: sourcePaddingElements
2671 * options[1] uint32_t: targetPaddingElements
2672 *
2673 * options[2] int32_t: factor (pre-multiplied by 1024)
2674 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2675 * options[4] int32_t: biasOutput (added to output after division)
2676 * options[5] int32_t: alphaValue (constant value for alpha channel)
2677 *
2678 * with transformation:
2679 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 1024 + biasOutput, 255)
2680 * t3 = alphaValue
2681 *
2682 * Example for Y8_LIMITED_RANGE [16, 235] → RGBA32 [0, 255]:
2683 * factor = 1192 (255/219 * 1024), biasInput = 16, biasOutput = 0, alphaValue = 255
2684 * </pre>
2685 * @param sources The pointer to the source plane, must be valid
2686 * @param targets The pointer to the target plane, must be valid
2687 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2688 * @param width The width of the frame in pixel, with range [1, infinity)
2689 * @param height The height of the frame in pixel, with range [1, infinity)
2690 * @param conversionFlag The conversion to be applied
2691 * @param options The 6 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, 1 alpha value, must be valid
2692 */
2693 static void convertOneRow_1Plane1Channel_To_1Plane4Channels_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);
2694
2695 /**
2696 * Converts one row of a single-channel image to a 4-channel image with 6-bit precision and range conversion.
2697 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGBA32 [0, 255].
2698 * This function uses fixed-point arithmetic with 6 fractional bits and replicates the converted value to first 3 channels, with a constant alpha.<br>
2699 * The layout of the options parameters is as follows:
2700 * <pre>
2701 * options[0] uint32_t: sourcePaddingElements
2702 * options[1] uint32_t: targetPaddingElements
2703 *
2704 * options[2] int32_t: factor (pre-multiplied by 64)
2705 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2706 * options[4] int32_t: biasOutput (added to output after division)
2707 * options[5] int32_t: alphaValue (constant value for alpha channel)
2708 *
2709 * with transformation:
2710 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 64 + biasOutput, 255)
2711 * t3 = alphaValue
2712 *
2713 * Example for Y8_LIMITED_RANGE [16, 235] → RGBA32 [0, 255]:
2714 * factor = 75 (255/219 * 64), biasInput = 16, biasOutput = 0, alphaValue = 255
2715 * </pre>
2716 * @param sources The pointer to the source plane, must be valid
2717 * @param targets The pointer to the target plane, must be valid
2718 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2719 * @param width The width of the frame in pixel, with range [1, infinity)
2720 * @param height The height of the frame in pixel, with range [1, infinity)
2721 * @param conversionFlag The conversion to be applied
2722 * @param options The 6 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, 1 alpha value, must be valid
2723 */
2724 static void convertOneRow_1Plane1Channel_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);
2725
2726 /**
2727 * Converts one row of an image with e.g., a YUYV16 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format.
2728 * The layout of the options parameters is as follows:
2729 * <pre>
2730 * options[0] uint32_t: sourcePaddingElements
2731 * options[1] uint32_t: targetPaddingElements
2732 *
2733 * with transformation:
2734 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2735 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2736 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2737 * </pre>
2738 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2739 * @param targets The one pointer to the target image, must be valid
2740 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2741 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2742 * @param height The height of the frame in pixel, with range [1, infinity)
2743 * @param conversionFlag The conversion to be applied
2744 * @param options The 2 options parameters: 2 padding parameters, must be valid
2745 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2746 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2747 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2748 * @see mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel().
2749 */
2750 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2751 static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2752
2753 /**
2754 * Converts one row of an image with e.g., a UYVY16 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format.
2755 * The layout of the options parameters is as follows:
2756 * <pre>
2757 * options[0] uint32_t: sourcePaddingElements
2758 * options[1] uint32_t: targetPaddingElements
2759 *
2760 * with transformation:
2761 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2762 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2763 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2764 * </pre>
2765 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2766 * @param targets The one pointer to the target image, must be valid
2767 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2768 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2769 * @param height The height of the frame in pixel, with range [1, infinity)
2770 * @param conversionFlag The conversion to be applied
2771 * @param options The 2 options parameters: 2 padding parameters, must be valid
2772 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2773 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2774 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2775 */
2776 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2777 static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2778
2779 /**
2780 * Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel values to an image with 3-channel un-packed 8-bit pixel format.
2781 * The layout of the options parameters is as follows:
2782 * <pre>
2783 * options[0] uint32_t: sourcePaddingElements
2784 * options[1] uint32_t: targetPaddingElements
2785 * </pre>
2786 * @param sources The one pointer to the source image with Bayer mosaic, must be valid
2787 * @param targets The one pointer to the target image, must be valid
2788 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2789 * @param width The width of the frame in pixel, with range [4, infinity), must be a multiple of 4
2790 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
2791 * @param conversionFlag The conversion to be applied
2792 * @param options The 2 options parameters: 2 padding parameters
2793 * @tparam tIndexRed The index of red channel in the target image, with range [0, 2]
2794 * @tparam tIndexGreen The index of green channel in the target image, with range [0, 2]
2795 * @tparam tIndexBlue The index of blue channel in the target image, with range [0, 2]
2796 */
2797 template <unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
2798 static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8Bit(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2799
2800 /**
2801 * Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel values to an image with 3-channel un-packed 16-bit pixel format.
2802 * The layout of the options parameters is as follows:
2803 * <pre>
2804 * options[0] uint32_t: sourcePaddingElements
2805 * options[1] uint32_t: targetPaddingElements
2806 * </pre>
2807 * @param sources The one pointer to the source image with Bayer mosaic, must be valid
2808 * @param targets The one pointer to the target image, must be valid
2809 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2810 * @param width The width of the frame in pixel, with range [4, infinity), must be a multiple of 4
2811 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
2812 * @param conversionFlag The conversion to be applied
2813 * @param options The 2 options parameters: 2 padding parameters
2814 * @tparam tIndexRed The index of red channel in the target image, with range [0, 2]
2815 * @tparam tIndexGreen The index of green channel in the target image, with range [0, 2]
2816 * @tparam tIndexBlue The index of blue channel in the target image, with range [0, 2]
2817 */
2818 template <unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
2819 static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels16Bit(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2820
2821 /**
2822 * Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel values to an image with 3-channel un-packed 8-bit pixel format and applies black level subtraction, white balance, and gamma encoding
2823 * The layout of the parameters, `options`, is defined in the struct `RGGB10ToRGB24AdvancedOptions`.
2824 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2825 * @param targets The one pointer to the target image, must be valid
2826 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2827 * @param width The width of the frame in pixel, with range [4, infinity), must be a multiple of 4
2828 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
2829 * @param conversionFlag The conversion to be applied
2830 * @param options The 2 options parameters: 2 padding parameters
2831 * @tparam tIndexRed The index of red channel in the target image, with range [0, 2]
2832 * @tparam tIndexGreen The index of green channel in the target image, with range [0, 2]
2833 * @tparam tIndexBlue The index of blue channel in the target image, with range [0, 2]
2834 */
2835 template <unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
2836 static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8BitAdvanced(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2837
2838 /**
2839 * Maps one row of a 1-plane, 2-channel image to two planes with 1 channels.
2840 * @param sources The pointer to the plane of the source image, must be valid
2841 * @param targets The pointer to the first and second plane of the target image, must be valid
2842 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2843 * @param width The width of the frame in pixel, with range [1, infinity)
2844 * @param height The height of the frame in pixel, with range [1, infinity)
2845 * @param conversionFlag The conversion to be applied
2846 * @param options The 3 options parameters: 3 padding parameters
2847 */
2848 static void mapOneRow_1Plane2Channels_To_2Planes1Channel_8BitPerChannel(const void** sources, void** targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void* options);
2849
2850 /**
2851 * Unpacks 5 elements from a row in a packed Bayer mosaic to 4 pixels values
2852 * The required memory layout of the input: `A B C D X ...`
2853 * Bytes marked as `X` store two bits for each of the previous four elements: `X = AABB CCDD`.
2854 * The memory layout of the output will be: `A B C D` (16 bits per element but only the lowest 10 bits are used)
2855 * This function is compatible with pixel formats like `FrameType::FORMAT_RGGB10_PACKED` or `FrameType::FORMAT_Y10_PACKED`.
2856 * @param packed The packed 5 elements, must be valid
2857 * @param unpacked The resulting 4 unpacked elements, must be valid
2858 */
2859 static OCEAN_FORCE_INLINE void unpack5ElementsBayerMosaicPacked10Bit(const uint8_t* const packed, uint16_t* unpacked);
2860
2861#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
2862
2863 /**
2864 * Unpacks 15 elements from a row in a packed Bayer mosaic to 12 pixels values
2865 * The required memory layout of the input: `A B C D X A B C D X A B C D X A ...`
2866 * Bytes marked as `X` store two bits for each of the previous four elements: `X = AABB CCDD`.
2867 * The memory layout of the output will be: `A B C D A B C D A B C D` (16 bits per element but only the lowest 10 bits are used)
2868 * This function is compatible with pixel formats like `FrameType::FORMAT_RGGB10_PACKED` or `FrameType::FORMAT_Y10_PACKED`.
2869 * @param packed The packed 15 elements, must be valid
2870 * @param unpackedAB_u_16x8 The resulting first 8 uint16_t values
2871 * @param unpackedC_u_16x4 The resulting last 4 uint16_t values
2872 * @tparam tAllowLastOverlappingElement True, to allow reading 16 elements from `packed` (if the memory is large enough); False, to force reading only 15 elements
2873 */
2874 template <bool tAllowLastOverlappingElement>
2875 static OCEAN_FORCE_INLINE void unpack15ElementsBayerMosaicPacked10BitNEON(const uint8_t* const packed, uint16x8_t& unpackedAB_u_16x8, uint16x4_t& unpackedC_u_16x4);
2876
2877#endif // OCEAN_HARDWARE_NEON_VERSION
2878};
2879
2880inline FrameConverter::Options::Options(const bool allowApproximation)
2881{
2883 {
2885 }
2886}
2887
2888inline FrameConverter::Options::Options(const uint8_t alphaChannelTargetValue, const bool allowApproximation) :
2889 optionsType_(OT_ALPHA_CHANNEL_TARGET_VALUE),
2890 alphaChannelTargetValue_(alphaChannelTargetValue)
2891{
2893 {
2895 }
2896}
2897
2898inline FrameConverter::Options::Options(const float gamma, const bool allowApproximation) :
2899 optionsType_(OT_GAMMA_CORRECTION),
2900 gamma_(gamma)
2901{
2902 ocean_assert(gamma_ >= 0.0f && gamma_ <= 2.0f);
2903
2905 {
2907 }
2908}
2909
2910inline FrameConverter::Options::Options(const uint16_t blackLevel, const float whiteBalanceRed, const float whiteBalanceGreen, const float whiteBalanceBlue, const float gamma, const bool allowApproximation) :
2911 optionsType_(OT_BLACKLEVEL_WHITEBALANCE_GAMMA),
2912 gamma_(gamma),
2913 blackLevel_(blackLevel)
2914{
2915 ocean_assert(blackLevel_ < 1024u);
2916 ocean_assert(whiteBalanceRed >= 0.0f && whiteBalanceGreen >= 0.0f && whiteBalanceBlue >= 0.0f);
2917 ocean_assert(gamma_ >= 0.0f);
2918
2919 whiteBalance_[0] = whiteBalanceRed;
2920 whiteBalance_[1] = whiteBalanceGreen;
2921 whiteBalance_[2] = whiteBalanceBlue;
2922
2924 {
2926 }
2927}
2928
2930{
2931 return optionsType_;
2932}
2933
2935{
2936 ocean_assert(optionsType_ & OT_ALPHA_CHANNEL_TARGET_VALUE);
2937 return alphaChannelTargetValue_;
2938}
2939
2941{
2942 ocean_assert((optionsType_ & OT_GAMMA_CORRECTION) || (optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA));
2943 return gamma_;
2944}
2945
2947{
2948 ocean_assert(optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA);
2949 return blackLevel_;
2950}
2951
2952inline const float* FrameConverter::Options::whiteBalance() const
2953{
2954 ocean_assert(optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA);
2955 return whiteBalance_;
2956}
2957
2959{
2960 return (optionsType_ & OT_APPROXIMATED) == OT_APPROXIMATED;
2961}
2962
2964{
2965 return size_t(conversionTriple.sourcePixelFormat_ ^ (conversionTriple.targetPixelFormat_ << uint64_t(1u)) ^ (uint64_t(conversionTriple.optionsType_) << uint64_t(2u)));
2966}
2967
2969 sourcePixelFormat_(sourcePixelFormat),
2970 targetPixelFormat_(targetPixelFormat),
2971 optionsType_(optionsType)
2972{
2973 // nothing to do here
2974}
2975
2977{
2978 return sourcePixelFormat_ == conversionTriple.sourcePixelFormat_ && targetPixelFormat_ == conversionTriple.targetPixelFormat_ && optionsType_ == conversionTriple.optionsType_;
2979}
2980
2981inline bool FrameConverter::Comfort::convert(const Frame& source, const FrameType::PixelFormat targetPixelFormat, Frame& target, const bool forceCopy, Worker* worker, const Options& options)
2982{
2983 return convert(source, targetPixelFormat, source.pixelOrigin(), target, forceCopy, worker, options);
2984}
2985
2986inline bool FrameConverter::Comfort::convert(const Frame& source, const FrameType::PixelOrigin targetPixelOrigin, Frame& target, const bool forceCopy, Worker* worker, const Options& options)
2987{
2988 return convert(source, source.pixelFormat(), targetPixelOrigin, target, forceCopy, worker, options);
2989}
2990
2991inline bool FrameConverter::Comfort::change(Frame& frame, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy, Worker* worker, const Options& options)
2992{
2993 ocean_assert(frame.isValid());
2994 ocean_assert(targetPixelFormat != FrameType::FORMAT_UNDEFINED && targetPixelOrigin != FrameType::ORIGIN_INVALID);
2995
2996 if (!frame.isValid())
2997 {
2998 return false;
2999 }
3000
3001 if (frame.pixelFormat() == targetPixelFormat && frame.pixelOrigin() == targetPixelOrigin)
3002 {
3003 return true;
3004 }
3005
3006 Frame tmpFrame;
3007 if (!convert(frame, targetPixelFormat, targetPixelOrigin, tmpFrame, forceCopy, worker, options))
3008 {
3009 return false;
3010 }
3011
3012 // if the intermediate frame could be created without copying the frame data we have to copy the frame data instead
3013 if (frame.isOwner() && !tmpFrame.isOwner())
3014 {
3015 frame.copy(tmpFrame);
3016 }
3017 else
3018 {
3019 frame = std::move(tmpFrame);
3020 }
3021
3022 return true;
3023}
3024
3025inline bool FrameConverter::Comfort::change(Frame& frame, const FrameType::PixelFormat targetPixelFormat, const bool forceCopy, Worker* worker, const Options& options)
3026{
3027 return change(frame, targetPixelFormat, frame.pixelOrigin(), forceCopy, worker, options);
3028}
3029
3030inline bool FrameConverter::Comfort::change(Frame& frame, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy, Worker* worker, const Options& options)
3031{
3032 return change(frame, frame.pixelFormat(), targetPixelOrigin, forceCopy, worker, options);
3033}
3034
3035OCEAN_RE_ENABLE_DOCUMENTATION_DIAGNOSTIC
3036
3037template <typename TSource, typename TTarget>
3038void FrameConverter::cast(const TSource* __restrict source, TTarget* __restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
3039{
3040 ocean_assert(source != nullptr && target != nullptr);
3041 ocean_assert(width != 0u && height != 0u);
3042 ocean_assert(channels != 0u);
3043
3044 // we will have a small performance benefit when applying as less as possible non-16-block iterations
3045 // thus, we distinguish between an execution with and without padding values
3046
3047 if (sourcePaddingElements == 0u && targetPaddingElements == 0u)
3048 {
3049 if (std::is_same<TSource, TTarget>::value)
3050 {
3051 memcpy(target, source, size_t(width * height * channels) * sizeof(TSource));
3052 }
3053 else
3054 {
3055 const unsigned int elementsPerFrame = width * height * channels;
3056 const unsigned int blocksPerFrame_16 = elementsPerFrame / 16u;
3057
3058 const unsigned int remainingElementsPerFrame = elementsPerFrame - blocksPerFrame_16 * 16u;
3059
3060 for (unsigned int n = 0u; n < blocksPerFrame_16; ++n)
3061 {
3062 cast16Elements<TSource, TTarget>(source, target);
3063
3064 source += 16;
3065 target += 16;
3066 }
3067
3068 for (unsigned int i = 0u; i < remainingElementsPerFrame; ++i)
3069 {
3070 target[i] = TTarget(source[i]);
3071 }
3072 }
3073 }
3074 else
3075 {
3076 if (std::is_same<TSource, TTarget>::value)
3077 {
3078 const unsigned int sourceStrideElements = width * channels + sourcePaddingElements;
3079 const unsigned int targetStrideElements = width * channels + targetPaddingElements;
3080
3081 const size_t bytesPerRowToCopy = size_t(width * channels) * sizeof(TSource);
3082
3083 for (unsigned int y = 0u; y < height; ++y)
3084 {
3085 memcpy(target, source, bytesPerRowToCopy);
3086
3087 source += sourceStrideElements;
3088 target += targetStrideElements;
3089 }
3090 }
3091 else
3092 {
3093 const unsigned int elementsPerRow = width * channels;
3094 const unsigned int blocksPerRow_16 = elementsPerRow / 16u;
3095
3096 const unsigned int remainingElementsPerRow = elementsPerRow - blocksPerRow_16 * 16u;
3097
3098 for (unsigned int y = 0u; y < height; ++y)
3099 {
3100 for (unsigned int x = 0u; x < blocksPerRow_16; ++x)
3101 {
3102 cast16Elements<TSource, TTarget>(source, target);
3103
3104 source += 16;
3105 target += 16;
3106 }
3107
3108 for (unsigned int i = 0u; i < remainingElementsPerRow; ++i)
3109 {
3110 target[i] = TTarget(source[i]);
3111 }
3112
3113 source += remainingElementsPerRow + sourcePaddingElements;
3114 target += remainingElementsPerRow + targetPaddingElements;
3115 }
3116 }
3117 }
3118}
3119
3120template <typename TSource, typename TTarget>
3121void FrameConverter::normalizedCast(const TSource* __restrict source, TTarget* __restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const TTarget multiplicationFactor, const TTarget offset, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
3122{
3123 ocean_assert(source != nullptr && target != nullptr);
3124 ocean_assert(width != 0u && height != 0u);
3125 ocean_assert(channels != 0u);
3126
3127 // we will have a small performance benefit when applying as little as possible non-16-block iterations
3128 // thus, we distinguish between an execution with and without padding values
3129
3130 if (sourcePaddingElements == 0u && targetPaddingElements == 0u)
3131 {
3132 const unsigned int elementsPerFrame = width * height * channels;
3133 const unsigned int blocksPerFrame_16 = elementsPerFrame / 16u;
3134
3135 const unsigned int remainingElementsPerFrame = elementsPerFrame - blocksPerFrame_16 * 16u;
3136
3137 for (unsigned int n = 0u; n < blocksPerFrame_16; ++n)
3138 {
3139 for (unsigned int i = 0u; i < 16u; ++i)
3140 {
3141 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3142 }
3143
3144 source += 16;
3145 target += 16;
3146 }
3147
3148 for (unsigned int i = 0u; i < remainingElementsPerFrame; ++i)
3149 {
3150 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3151 }
3152 }
3153 else
3154 {
3155 const unsigned int elementsPerRow = width * channels;
3156 const unsigned int blocksPerRow_16 = elementsPerRow / 16u;
3157
3158 const unsigned int remainingElementsPerRow = elementsPerRow - blocksPerRow_16 * 16u;
3159
3160 for (unsigned int y = 0u; y < height; ++y)
3161 {
3162 for (unsigned int n = 0u; n < blocksPerRow_16; ++n)
3163 {
3164 for (unsigned int i = 0u; i < 16u; ++i)
3165 {
3166 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3167 }
3168
3169 source += 16;
3170 target += 16;
3171 }
3172
3173 for (unsigned int i = 0u; i < remainingElementsPerRow; ++i)
3174 {
3175 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3176 }
3177
3178 source += remainingElementsPerRow + sourcePaddingElements;
3179 target += remainingElementsPerRow + targetPaddingElements;
3180 }
3181 }
3182}
3183
3184#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3185
3186template <>
3187OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, float>(const uint8_t* const source, float* const target)
3188{
3189 const uint8x16_t source_8x16 = vld1q_u8(source);
3190
3191 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3192 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3193
3194 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3195 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3196 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3197 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3198
3199 const float32x4_t target_32x4_0 = vcvtq_f32_u32(source_32x4_0);
3200 const float32x4_t target_32x4_1 = vcvtq_f32_u32(source_32x4_1);
3201 const float32x4_t target_32x4_2 = vcvtq_f32_u32(source_32x4_2);
3202 const float32x4_t target_32x4_3 = vcvtq_f32_u32(source_32x4_3);
3203
3204 vst1q_f32(target + 0, target_32x4_0);
3205 vst1q_f32(target + 4, target_32x4_1);
3206 vst1q_f32(target + 8, target_32x4_2);
3207 vst1q_f32(target + 12, target_32x4_3);
3208}
3209
3210template <>
3211OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, uint16_t>(const uint8_t* const source, uint16_t* const target)
3212{
3213 const uint8x16_t source_8x16 = vld1q_u8(source);
3214
3215 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3216 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3217
3218 vst1q_u16(target + 0, source_16x8_0);
3219 vst1q_u16(target + 8, source_16x8_1);
3220}
3221
3222template <>
3223OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, int16_t>(const uint8_t* const source, int16_t* const target)
3224{
3225 const uint8x16_t source_8x16 = vld1q_u8(source);
3226
3227 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3228 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3229
3230 vst1q_s16(target + 0, vreinterpretq_s16_u16(source_16x8_0));
3231 vst1q_s16(target + 8, vreinterpretq_s16_u16(source_16x8_1));
3232}
3233
3234template <>
3235OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, uint32_t>(const uint8_t* const source, uint32_t* const target)
3236{
3237 const uint8x16_t source_8x16 = vld1q_u8(source);
3238
3239 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3240 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3241
3242 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3243 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3244 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3245 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3246
3247 vst1q_u32(target + 0, source_32x4_0);
3248 vst1q_u32(target + 4, source_32x4_1);
3249 vst1q_u32(target + 8, source_32x4_2);
3250 vst1q_u32(target + 12, source_32x4_3);
3251}
3252
3253template <>
3254OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, int32_t>(const uint8_t* const source, int32_t* const target)
3255{
3256 const uint8x16_t source_8x16 = vld1q_u8(source);
3257
3258 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3259 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3260
3261 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3262 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3263 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3264 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3265
3266 vst1q_s32(target + 0, vreinterpretq_s32_u32(source_32x4_0));
3267 vst1q_s32(target + 4, vreinterpretq_s32_u32(source_32x4_1));
3268 vst1q_s32(target + 8, vreinterpretq_s32_u32(source_32x4_2));
3269 vst1q_s32(target + 12, vreinterpretq_s32_u32(source_32x4_3));
3270}
3271
3272template <>
3273OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<float, uint8_t>(const float* const source, uint8_t* const target)
3274{
3275 const float32x4_t source_32x4_0 = vld1q_f32(source + 0);
3276 const float32x4_t source_32x4_1 = vld1q_f32(source + 4);
3277 const float32x4_t source_32x4_2 = vld1q_f32(source + 8);
3278 const float32x4_t source_32x4_3 = vld1q_f32(source + 12);
3279
3280 const uint32x4_t target_32x4_0 = vcvtq_u32_f32(source_32x4_0);
3281 const uint32x4_t target_32x4_1 = vcvtq_u32_f32(source_32x4_1);
3282 const uint32x4_t target_32x4_2 = vcvtq_u32_f32(source_32x4_2);
3283 const uint32x4_t target_32x4_3 = vcvtq_u32_f32(source_32x4_3);
3284
3285 const uint16x8_t target_16x8_0 = vcombine_u16(vmovn_u32(target_32x4_0), vmovn_u32(target_32x4_1));
3286 const uint16x8_t target_16x8_1 = vcombine_u16(vmovn_u32(target_32x4_2), vmovn_u32(target_32x4_3));
3287
3288 const uint8x16_t target_8x16 = vcombine_u8(vmovn_u16(target_16x8_0), vmovn_u16(target_16x8_1));
3289
3290 vst1q_u8(target, target_8x16);
3291}
3292
3293#endif // #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3294
3295template <typename TSource, typename TTarget>
3296OCEAN_FORCE_INLINE void FrameConverter::cast16Elements(const TSource* const source, TTarget* const target)
3297{
3298 for (unsigned int i = 0u; i < 16u; ++i)
3299 {
3300 target[i] = TTarget(source[i]);
3301 }
3302}
3303
3304template <typename T>
3305bool FrameConverter::subFrame(const T* source, T* target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
3306{
3307 ocean_assert(source != nullptr && target != nullptr);
3308
3309 if (sourceLeft + width > sourceWidth || sourceTop + height > sourceHeight || targetLeft + width > targetWidth || targetTop + height > targetHeight)
3310 {
3311 return false;
3312 }
3313
3314 const unsigned int sourceStrideElements = sourceWidth * channels + sourcePaddingElements;
3315 const unsigned int targetStrideElements = targetWidth * channels + targetPaddingElements;
3316
3317 const T* subSource = source + sourceStrideElements * sourceTop + sourceLeft * channels;
3318 T* subTarget = target + targetStrideElements * targetTop + targetLeft * channels;
3319
3320 if (sourcePaddingElements == 0u && targetPaddingElements == 0u && width == sourceWidth && sourceWidth == targetWidth)
3321 {
3322 memcpy(subTarget, subSource, height * width * channels * sizeof(T));
3323 }
3324 else
3325 {
3326 for (unsigned int y = 0u; y < height; ++y)
3327 {
3328 memcpy(subTarget, subSource, width * channels * sizeof(T));
3329
3330 subTarget += targetStrideElements;
3331 subSource += sourceStrideElements;
3332 }
3333 }
3334
3335 return true;
3336}
3337
3338template <typename T>
3339bool FrameConverter::subFrameMask(const Frame& sourceFrame, Frame& targetFrame, const Frame& maskFrame, const uint32_t sourceLeft, const uint32_t sourceTop, const uint32_t targetLeft, const uint32_t targetTop, const uint32_t subFrameWidth, const uint32_t subFrameHeight, const uint8_t maskValue)
3340{
3341 if (subFrameWidth == 0u || subFrameHeight == 0u)
3342 {
3343 return true;
3344 }
3345
3346 if (!sourceFrame.isValid() || !targetFrame.isValid() || !maskFrame.isValid() || sourceFrame.numberPlanes() != 1u || targetFrame.numberPlanes() != 1u || maskFrame.numberPlanes() != 1u || FrameType::dataType<T>() != sourceFrame.dataType() || FrameType::dataType<T>() != targetFrame.dataType() || maskFrame.dataType() != FrameType::dataType<uint8_t>() || sourceFrame.channels() != targetFrame.channels() || maskFrame.width() != subFrameWidth || maskFrame.height() != subFrameHeight)
3347 {
3348 ocean_assert(false && "Invalid input");
3349 return false;
3350 }
3351
3352 return subFrameMask<T>(sourceFrame.constdata<T>(), targetFrame.data<T>(), maskFrame.constdata<uint8_t>(), sourceFrame.width(), sourceFrame.height(), targetFrame.width(), targetFrame.height(), sourceFrame.channels(), sourceLeft, sourceTop, targetLeft, targetTop, subFrameWidth, subFrameHeight, sourceFrame.paddingElements(), targetFrame.paddingElements(), maskFrame.paddingElements(), maskValue);
3353}
3354
3355template <typename T>
3356bool FrameConverter::subFrameMask(const T* source, T* target, const uint8_t* mask, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int maskPaddingElements, const uint8_t maskValue)
3357{
3358 ocean_assert(source != nullptr && target != nullptr && mask != nullptr);
3359
3360 if (sourceLeft + subFrameWidth > sourceWidth || sourceTop + subFrameHeight > sourceHeight || targetLeft + subFrameWidth > targetWidth || targetTop + subFrameHeight > targetHeight)
3361 {
3362 ocean_assert(false && "Invalid input");
3363 return false;
3364 }
3365
3366 const unsigned int maskStrideElements = subFrameWidth + maskPaddingElements;
3367
3368 const unsigned int sourceStrideElements = sourceWidth * channels + sourcePaddingElements;
3369 const unsigned int targetStrideElements = targetWidth * channels + targetPaddingElements;
3370
3371 for (unsigned int y = 0u; y < subFrameHeight; ++y)
3372 {
3373 const uint8_t* maskRow = mask + maskStrideElements * y;
3374
3375 const T* subSource = source + sourceStrideElements * (sourceTop + y) + sourceLeft * channels;
3376 T* subTarget = target + targetStrideElements * (targetTop + y) + targetLeft * channels;
3377
3378 for (unsigned int x = 0u; x < subFrameWidth; ++x)
3379 {
3380 if (*maskRow == maskValue)
3381 {
3382 for (unsigned int c = 0u; c < channels; ++c)
3383 {
3384 subTarget[c] = subSource[c];
3385 }
3386 }
3387
3388 maskRow++;
3389
3390 subSource += channels;
3391 subTarget += channels;
3392 }
3393 }
3394
3395 return true;
3396}
3397
3398template <typename T>
3399void FrameConverter::patchFrame(const T* source, T* buffer, const unsigned int width, const unsigned int channels, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
3400{
3401 ocean_assert(source != nullptr && buffer != nullptr);
3402 ocean_assert(width >= patchSize && channels >= 1u);
3403
3404 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
3405 const unsigned int patchSize_2 = patchSize / 2u;
3406
3407 ocean_assert(x >= patchSize_2 && y >= patchSize_2);
3408 ocean_assert(x + patchSize_2 < width);
3409
3410 const unsigned int sourceStrideElements = width * channels + sourcePaddingElements;
3411 const unsigned int bufferStrideElements = patchSize * channels + bufferPaddingElements;
3412
3413 const unsigned int sourceLeft = x - patchSize_2;
3414 const unsigned int sourceTop = y - patchSize_2;
3415
3416 source += sourceTop * sourceStrideElements + sourceLeft * channels;
3417
3418 for (unsigned int row = 0u; row < patchSize; ++row)
3419 {
3420 memcpy(buffer, source, channels * patchSize * sizeof(T));
3421
3422 source += sourceStrideElements;
3423 buffer += bufferStrideElements;
3424 }
3425}
3426
3427template <typename T, unsigned int tChannels>
3428void FrameConverter::patchFrameMirroredBorder(const T* source, T* buffer, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
3429{
3430 static_assert(tChannels >= 1u, "Invalid number of color channels!");
3431
3432 ocean_assert(source != nullptr && buffer != nullptr);
3433
3434 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
3435 const unsigned int patchSize_2 = patchSize / 2u;
3436
3437 const unsigned int widthPatchSize1 = width - (patchSize - 1u);
3438 ocean_assert(widthPatchSize1 == width - patchSize_2 * 2u);
3439
3440 ocean_assert(width >= patchSize_2 + 1u && height >= patchSize_2 + 1u);
3441
3442 ocean_assert(x < width && y < height);
3443
3444 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
3445
3446 for (int top = int(y - patchSize_2); top <= int(y + patchSize_2); ++top)
3447 {
3448 const T* sourceRow = source + CVUtilities::mirrorIndex(top, height) * int(sourceStrideElements);
3449
3450 for (int left = int(x - patchSize_2); left <= int(x + patchSize_2); ++left)
3451 {
3452 if ((unsigned int)(left) - patchSize_2 < widthPatchSize1)
3453 {
3454 ocean_assert(left >= int(patchSize_2) && left < int(width - patchSize_2));
3455
3456 const T* sourcePixel = sourceRow + left * tChannels;
3457
3458 for (unsigned int n = 0u; n < tChannels; ++n)
3459 {
3460 buffer[n] = sourcePixel[n];
3461 }
3462 }
3463 else
3464 {
3465 ocean_assert((unsigned int)(left) <= patchSize_2 || (unsigned int)(left) >= width - patchSize_2);
3466
3467 const T* sourcePixel = sourceRow + CVUtilities::mirrorIndex(left, width) * tChannels;
3468
3469 for (unsigned int n = 0u; n < tChannels; ++n)
3470 {
3471 buffer[n] = sourcePixel[n];
3472 }
3473 }
3474
3475 buffer += tChannels;
3476 }
3477
3478 buffer += bufferPaddingElements;
3479 }
3480}
3481
3482template <typename TSource, typename TTarget>
3483inline void FrameConverter::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)
3484{
3485 ocean_assert(source != nullptr && target != nullptr);
3486 ocean_assert(width >= 1u && height >= 1u);
3487 ocean_assert(sourceStrideElements >= width && targetStrideElements >= width);
3488 ocean_assert(rowConversionFunction != nullptr);
3489 ocean_assert(flag == CONVERT_NORMAL || flag == CONVERT_FLIPPED || targetReversePixelOrderInPlaceFunction != nullptr);
3490
3491 // the internal subset conversion function needs bytes instead of elements
3492
3493 const unsigned int sourceStrideBytes = sourceStrideElements * sizeof(TSource);
3494 const unsigned int targetStrideBytes = targetStrideElements * sizeof(TTarget);
3495
3496 if (worker && height >= 200u)
3497 {
3498 worker->executeFunction(Worker::Function::createStatic(&FrameConverter::convertGenericPixelFormatSubset, (const uint8_t*)(source), (uint8_t*)(target), width, height, sourceStrideBytes, targetStrideBytes, flag, (const RowConversionFunction<uint8_t, uint8_t>)rowConversionFunction, (const RowReversePixelOrderInPlaceFunction<uint8_t>)targetReversePixelOrderInPlaceFunction, areContinuous, options, 0u, 0u), 0u, height, 11u, 12u, 20u);
3499 }
3500 else
3501 {
3502 convertGenericPixelFormatSubset((const uint8_t*)(source), (uint8_t*)(target), width, height, sourceStrideBytes, targetStrideBytes, flag, (const RowConversionFunction<uint8_t, uint8_t>)rowConversionFunction, (const RowReversePixelOrderInPlaceFunction<uint8_t>)targetReversePixelOrderInPlaceFunction, areContinuous, options, 0u, height);
3503 }
3504}
3505
3506inline void FrameConverter::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)
3507{
3508 ocean_assert(multipleRowsPerIteration != 0u && height % multipleRowsPerIteration == 0u);
3509
3510 const unsigned int rowIterations = height / multipleRowsPerIteration;
3511
3512 if (worker && rowIterations >= 200u)
3513 {
3514 worker->executeFunction(Worker::Function::createStatic(&FrameConverter::convertArbitraryPixelFormatSubset, sources, targets, width, height, flag, multipleRowsPerIteration, multipleRowsConversionFunction, options, 0u, 0u), 0u, rowIterations, 8u, 9u, 20u);
3515 }
3516 else
3517 {
3518 convertArbitraryPixelFormatSubset(sources, targets, width, height, flag, multipleRowsPerIteration, multipleRowsConversionFunction, options, 0u, rowIterations);
3519 }
3520}
3521
3522OCEAN_FORCE_INLINE void FrameConverter::unpack5ElementsBayerMosaicPacked10Bit(const uint8_t* const packed, uint16_t* unpacked)
3523{
3524 ocean_assert(packed != nullptr);
3525 ocean_assert(unpacked != nullptr);
3526
3527 unpacked[0] = uint16_t(uint16_t(packed[0]) << uint16_t(2) | (uint16_t(packed[4]) & uint16_t(0b00000011)));
3528 unpacked[1] = uint16_t(uint16_t(packed[1]) << uint16_t(2) | ((uint16_t(packed[4]) & uint16_t(0b00001100)) >> uint16_t(2)));
3529 unpacked[2] = uint16_t(uint16_t(packed[2]) << uint16_t(2) | ((uint16_t(packed[4]) & uint16_t(0b00110000)) >> uint16_t(4)));
3530 unpacked[3] = uint16_t(uint16_t(packed[3]) << uint16_t(2) | (uint16_t(packed[4]) >> uint16_t(6)));
3531}
3532
3533#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3534
3535template <bool tAllowLastOverlappingElement>
3536OCEAN_FORCE_INLINE void FrameConverter::unpack15ElementsBayerMosaicPacked10BitNEON(const uint8_t* const packed, uint16x8_t& unpackedAB_u_16x8, uint16x4_t& unpackedC_u_16x4)
3537{
3538 constexpr uint8x8_t shuffleC_u_8x8 = {6u, 2u, 6u, 3u, 6u, 4u, 6u, 5u};
3539
3540 constexpr int8x16_t leftShifts_s_8x16 = {6, 0, 4, 0, 2, 0, 0, 0, 6, 0, 4, 0, 2, 0, 0, 0};
3541 constexpr int16x8_t rightShifts_s_16x8 = {-6, -6, -6, -6, -6, -6, -6, -6};
3542
3543 const uint8x16_t packed_u_8x16 = tAllowLastOverlappingElement ? vld1q_u8(packed) : vcombine_u8(vld1_u8(packed), vext_u8(vld1_u8(packed + 7), shuffleC_u_8x8, 1)); // shuffleC_u_8x8 is just a dummy value
3544
3545 // F E D C B A 9 8 7 6 5 4 3 2 1 0
3546 // 8 9 7 9 6 9 5 9 3 4 2 4 1 4 0 4
3547
3548#ifdef __aarch64__
3549 constexpr uint8x16_t shuffle_u_8x16 = {4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u, 9u, 5u, 9u, 6u, 9u, 7u, 9u, 8u};
3550 const uint8x16_t intermediateAB_u_8x16 = vqtbl1q_u8(packed_u_8x16, shuffle_u_8x16);
3551#else
3552 const uint8x8_t packedA_u_8x8 = vget_low_u8(packed_u_8x16);
3553 const uint8x8_t packedB_u_8x8 = vget_low_u8(vextq_u8(packed_u_8x16, packed_u_8x16, 5));
3554
3555 constexpr uint8x8_t shuffleAB_u_8x8 = {4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u};
3556 const uint8x16_t intermediateAB_u_8x16 = vcombine_u8(vtbl1_u8(packedA_u_8x8, shuffleAB_u_8x8), vtbl1_u8(packedB_u_8x8, shuffleAB_u_8x8));
3557#endif // __aarch64__
3558
3559
3560 // 7 6 5 4 3 2 1 0
3561 // 5 6 4 6 3 6 2 6
3562 const uint8x8_t intermediateC_u_8x8 = vtbl1_u8(vget_high_u8(packed_u_8x16), shuffleC_u_8x8);
3563
3564
3565 // ... XXXXXX99 33333333 44XXXXXX 22222222 XX44XXXX 11111111 XXXX44XX 00000000 XXXXXX44
3566 // ... 99------ 33333333 44------ 22222222 44------ 11111111 44------ 00000000 44------
3567 const uint16x8_t intermediateAB_u_16x8 = vreinterpretq_u16_u8(vshlq_u8(intermediateAB_u_8x16, leftShifts_s_8x16));
3568
3569 const uint16x4_t intermediateC_u_16x4 = vreinterpret_u16_u8(vshl_u8(intermediateC_u_8x8, vget_low_u8(leftShifts_s_8x16)));
3570
3571
3572 // ... 99------ 33333333 44------ 22222222 44------ 11111111 44------ 00000000 44------
3573 // ... 55555599 ------33 33333344 ------22 22222244 ------11 11111144 ------00 00000044
3574 unpackedAB_u_16x8 = vshlq_u16(intermediateAB_u_16x8, rightShifts_s_16x8);
3575
3576 unpackedC_u_16x4 = vshl_u16(intermediateC_u_16x4, vget_low_u8(rightShifts_s_16x8));
3577}
3578
3579#endif // OCEAN_HARDWARE_NEON_VERSION
3580
3581}
3582
3583}
3584
3585#endif // META_OCEAN_CV_FRAME_CONVERTER_H
static OCEAN_FORCE_INLINE unsigned int mirrorIndex(const int index, const unsigned int elements)
Returns the mirrored index for a given index.
Definition CVUtilities.h:459
The following comfort class provides comfortable functions simplifying prototyping applications but a...
Definition FrameConverter.h:634
static bool isSupported(const FrameType &sourceType, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin=FrameType::ORIGIN_INVALID, const Options &options=Options())
Returns whether the convert function of this class supports the conversion of a frame with one pixel ...
static bool convert(const Frame &source, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, Frame &target, const bool forceCopy=true, Worker *worker=nullptr, const Options &options=Options())
Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same d...
static bool convertWithConversionFunction(const Frame &source, const FrameType &targetType, Frame &target, const Options &options, Worker *worker)
Converts frames using a registered conversion function from the ConversionFunctionMap.
static bool convertAndCopy(const Frame &source, Frame &target, Worker *worker=nullptr, const Options &options=Options())
Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same d...
static bool convertCompatibleFormats(const Frame &source, const FrameType &targetType, Frame &target, const bool forceCopy)
Converts frames with compatible formats that do not require an actual conversion, either memory is co...
static bool change(Frame &frame, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy=true, Worker *worker=nullptr, const Options &options=Options())
Converts / changes a frame with arbitrary dimension, pixel format and pixel origin into a frame with ...
Definition FrameConverter.h:2991
static bool convertGenericFormats(const Frame &source, const FrameType &targetType, Frame &target, Worker *worker)
Converts frames with generic pixel formats.
This class combines source pixel format, target pixel format, and options types.
Definition FrameConverter.h:353
bool operator==(const ConversionTriple &conversionTriple) const
Returns whether two objects are identical.
Definition FrameConverter.h:2976
FrameType::PixelFormat sourcePixelFormat_
The pixel format of the source frame, must be valid.
Definition FrameConverter.h:395
Options::OptionsType optionsType_
The type of the options for which the conversion is defined.
Definition FrameConverter.h:401
FrameType::PixelFormat targetPixelFormat_
The pixel format of the target frame, must be valid.
Definition FrameConverter.h:398
This class is a wrapper for function pointers.
Definition FrameConverter.h:408
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint32_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT8 function.
FunctionWrapper(const ThreeSourcesOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8_ALPHA function.
FunctionWrapper(const TwoSourcesTwoTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_2_UINT8 function.
FunctionWrapper(const OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHIT...
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint16_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT16 function.
FunctionWrapper(const ThreeSourcesOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8 function.
FunctionWrapper(const TwoSourcesOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint32_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT16 function.
FunctionWrapper(const TwoSourcesOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8_ALPHA function.
FunctionWrapper(const OneSourceGammaOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_GAMMA_TO_1_UINT8 function.
FunctionWrapper(const OneSourceOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_ALPHA function.
const FunctionType functionType_
The type of the conversion function.
Definition FrameConverter.h:527
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint16_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT8 function.
const void * function_
The function pointer of the conversion function.
Definition FrameConverter.h:524
FunctionWrapper(const ThreeSourcesThreeTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceThreeTargetsConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint8_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT16 function.
FunctionWrapper(const TwoSourcesThreeTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceTwoTargetsConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_2_UINT8 function.
This class implements a singleton-based map for function pointers of conversion functions.
Definition FrameConverter.h:219
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker *worker) OneSourceOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane ...
Definition FrameConverter.h:285
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker *worker) ThreeSourcesOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with three source planes and one target pla...
Definition FrameConverter.h:339
const void * function(const FrameType::PixelFormat &sourcePixelFormat, const FrameType::PixelFormat &targetPixelFormat, FunctionType &functionType, const Options &options) const
Returns the function pointer for a source and target pixel format.
void(*)(const TSource *source, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, const uint32_t target2PaddingElements, Worker *worker) OneSourceThreeTargetsConversionFunction
Definition of a function pointer to a conversion function with one source plane and three target plan...
Definition FrameConverter.h:303
void(*)(const TSource *source0, const TSource *source1, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker *worker) TwoSourcesThreeTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and three target pla...
Definition FrameConverter.h:327
void(*)(const TSource *source0, const TSource *source1, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, Worker *worker) TwoSourcesOneTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and one target plane...
Definition FrameConverter.h:309
void(*)(const TSource *source0, const TSource *source1, TTarget *target0, TTarget *target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker *worker) TwoSourcesTwoTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and two target plane...
Definition FrameConverter.h:321
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker *worker) ThreeSourcesThreeTargetConversionFunction
Definition of a function pointer to a conversion function with three source planes and three target p...
Definition FrameConverter.h:345
FormatPair2FunctionWrapperMap formatPair2FunctionWrapperMap_
The map mapping pairs or pixel formats to function pointers.
Definition FrameConverter.h:557
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceGammaOneTargetConversionFunction
Definition of a function pointer to a conversion function with one source plane with gamma correction...
Definition FrameConverter.h:279
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint16_t blackLevelValue, const float *whiteBalanceValues, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane ...
Definition FrameConverter.h:291
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceOneTargetConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane.
Definition FrameConverter.h:273
FunctionType
Definition of individual types of conversion functions.
Definition FrameConverter.h:228
@ FT_2_UINT8_TO_1_UINT8_ALPHA
2-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
Definition FrameConverter.h:256
@ FT_1_UINT8_TO_1_UINT8_ALPHA
1-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
Definition FrameConverter.h:236
@ FT_1_UINT8_TO_2_UINT8
1-plane uint8 to 2-plane uint8 conversion function.
Definition FrameConverter.h:250
@ FT_2_UINT8_TO_2_UINT8
2-plane uint8 to 2-plane uint8 conversion function.
Definition FrameConverter.h:258
@ FT_1_UINT32_TO_1_UINT16
1-plane uint32 to 1-plane uint16 conversion function.
Definition FrameConverter.h:248
@ FT_3_UINT8_TO_1_UINT8
3-plane uint8 to 1-plane uint8 conversion function.
Definition FrameConverter.h:262
@ FT_3_UINT8_TO_1_UINT8_ALPHA
3-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
Definition FrameConverter.h:264
@ FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHITEBALANCE_GAMMA
1-plane uint8 to 1-plane uint8 conversion function with constant black level, white balance,...
Definition FrameConverter.h:238
@ FT_2_UINT8_TO_1_UINT8
2-plane uint8 to 1-plane uint8 conversion function.
Definition FrameConverter.h:254
@ FT_1_UINT16_TO_1_UINT16
1-plane uint16 to 1-plane uint16 conversion function.
Definition FrameConverter.h:244
@ FT_1_UINT8_GAMMA_TO_1_UINT8
1-plane uint8 with constant gamma correction to 1-plane uint8 conversion function.
Definition FrameConverter.h:234
@ FT_1_UINT16_TO_1_UINT8
1-plane uint16 to 1-plane uint8 conversion function.
Definition FrameConverter.h:242
@ FT_1_UINT8_TO_1_UINT16
1-plane uint8 to 1-plane uint16 conversion function.
Definition FrameConverter.h:240
@ FT_1_UINT8_TO_3_UINT8
1-plane uint8 to 3-plane uint8 conversion function.
Definition FrameConverter.h:252
@ FT_2_UINT8_TO_3_UINT8
2-plane uint8 to 3-plane uint8 conversion function.
Definition FrameConverter.h:260
@ FT_1_UINT32_TO_1_UINT8
1-plane uint32 to 1-plane uint8 conversion function.
Definition FrameConverter.h:246
@ FT_1_UINT8_TO_1_UINT8
1-plane uint8 to 1-plane uint8 conversion function.
Definition FrameConverter.h:232
std::unordered_map< ConversionTriple, FunctionWrapper, ConversionTriple::Hash > FormatPair2FunctionWrapperMap
Definition of a map mapping pairs or pixel formats to function pointers.
Definition FrameConverter.h:533
void(*)(const TSource *source0, const TSource *source1, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker *worker) TwoSourcesOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with two source planes and one target plane...
Definition FrameConverter.h:315
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, Worker *worker) ThreeSourcesOneTargetConversionFunction
Definition of a function pointer to a conversion function with three source planes and one target pla...
Definition FrameConverter.h:333
void(*)(const TSource *source, TTarget *target0, TTarget *target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker *worker) OneSourceTwoTargetsConversionFunction
Definition of a function pointer to a conversion function with one source plane and two target planes...
Definition FrameConverter.h:297
ConversionFunctionMap()
Creates a new map object and initializes all function pointers.
Definition of a class storing options for frame conversions.
Definition FrameConverter.h:105
float gamma() const
Returns the gamma value for a conversion with gamma correction/encoding.
Definition FrameConverter.h:2940
OptionsType optionsType_
The options type.
Definition FrameConverter.h:198
OptionsType
Definition of individual types of options.
Definition FrameConverter.h:112
@ OT_APPROXIMATED
Approximated conversion.
Definition FrameConverter.h:122
OptionsType optionsType() const
Returns the options type.
Definition FrameConverter.h:2929
uint8_t alphaChannelTargetValue() const
Returns the uint8_t alpha channel value for the target image if the source image does not contain an ...
Definition FrameConverter.h:2934
uint16_t blackLevel_
The black level value that is subtracted from each element of the raw image before any other operatio...
Definition FrameConverter.h:207
float gamma_
The gamma value for a conversion with gamma correction/encoding, with range (0, 2) (OT_GAMMA_CORRECTI...
Definition FrameConverter.h:204
Options(const bool allowApproximation=false)
Default constructor.
Definition FrameConverter.h:2880
float whiteBalance_[3]
The white balancing scalars of the red, green, and blue channels (in that order), with range [0,...
Definition FrameConverter.h:210
uint16_t blackLevel() const
Returns the black level value for a conversion with black level correction.
Definition FrameConverter.h:2946
const float * whiteBalance() const
Returns the white balance values for a conversion with white balance correction.
Definition FrameConverter.h:2952
bool allowApproximation() const
Returns whether the conversion can be approximated.
Definition FrameConverter.h:2958
This is the base class for all frame converter classes.
Definition FrameConverter.h:32
static MatrixD transformationMatrix_FullRangeRGB24_To_LimitedRangeYUV24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YUV24 using ...
static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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)
This function is not used anymore due to the corresponding 2-row function.
ConversionFlag
Definition of individual conversion flags.
Definition FrameConverter.h:39
@ CONVERT_NORMAL
Normal conversion, neither flips nor mirrors the image.
Definition FrameConverter.h:49
@ CONVERT_MIRRORED
Mirrored conversion, exchanges left and right of the image (like in a mirror, mirroring around the y-...
Definition FrameConverter.h:71
@ CONVERT_FLIPPED
Flipped conversion, exchanges top and bottom of the image (flipping around the x-axis).
Definition FrameConverter.h:60
std::vector< ConversionFlag > ConversionFlags
Definition of a vector holding conversion flags.
Definition FrameConverter.h:88
static void mapOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(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_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8BitAdvanced(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 3-channel Bayer mosaic pixel format with packed 10-bit pixel value...
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from full range YUV24 to full range BGR24 using BT....
static void convertOneRow_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 one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e....
static OCEAN_FORCE_INLINE void unpack5ElementsBayerMosaicPacked10Bit(const uint8_t *const packed, uint16_t *unpacked)
Unpacks 5 elements from a row in a packed Bayer mosaic to 4 pixels values The required memory layout ...
Definition FrameConverter.h:3522
static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel(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 YUYV16 pixel format to one row of an image with e....
void(*)(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options) MultipleRowsConversionFunction
Definition of a function pointer to a function able to convert multiple image row from an arbitrary p...
Definition FrameConverter.h:584
void(*)(const TSource *sourceRow, TTarget *targetRow, const size_t width, const void *options) RowConversionFunction
Definition of a function pointer to a function able to convert one image row from one generic pixel f...
Definition FrameConverter.h:572
static void normalizedCast(const TSource *__restrict source, TTarget *__restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const TTarget multiplicationFactor, const TTarget offset, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
Casts the pixel values from one frame type to another frame type but also normalizes the casted sourc...
Definition FrameConverter.h:3121
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_Android()
Returns the color space transformation matrix from full range YUV24 to full range BGR24 similar to BT...
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from full range YUV24 to full range RGB24 using BT....
static void convertOneRow_1Plane1Channel_To_1Plane4Channels_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 one row of a single-channel image to a 4-channel image with 10-bit precision and range conve...
static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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_UV12 pixel format to two rows of an image with e....
static const ConversionFlags & conversionFlags()
Returns a vector holding all possible conversion flags.
static void patchFrame(const T *source, T *buffer, const unsigned int width, const unsigned int channels, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
Copies a small patch area of a given frame into a buffer holding only the entire patch.
Definition FrameConverter.h:3399
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android()
Returns the color space transformation matrix from full range YUV24 to full range RGB24 similar to BT...
static void mapOneRow_1Plane3Channels_To_3Plane1Channel_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (maps) one row of an image with e.g., a RGB24 pixel format to one row of an image with e....
static void convertOneRow_1Plane1Channel_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 a single-channel image to a 4-channel image with 6-bit precision and range conver...
static bool subFrameMask(const Frame &sourceFrame, Frame &targetFrame, const Frame &maskFrame, const uint32_t sourceLeft, const uint32_t sourceTop, const uint32_t targetLeft, const uint32_t targetTop, const uint32_t subFrameWidth, const uint32_t subFrameHeight, const uint8_t maskValue=0u)
Copies pixels from one sub-frame to another if the pixels are part of a mask; input may use padding.
Definition FrameConverter.h:3339
static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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)
This function is not used anymore due to the corresponding 2-row function.
static void mapOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (matches) one row of an image with e.g., a Y_UV12 pixel format to one row of an image with e...
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from full range YVU24 to full range RGB24 using BT....
static void mapOneRow_3Plane1Channel_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (maps) one row of an image with e.g., a Y_U_V24 pixel format to one row of an image with e....
static void convertOneRow_3Planes1Channel_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 one row of an image with e.g., a Y_U_V24 pixel format to one rows of an image with e....
static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_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 one row of an image with e.g., a UYVY16 pixel format to one row of an image with e....
static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_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 one row of an image with e.g., a YUYV16 pixel format to one row of an image with e....
static void mapOneRow_1Plane2Channels_To_2Planes1Channel_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Maps one row of a 1-plane, 2-channel image to two planes with 1 channels.
static std::string translateConversionFlag(const ConversionFlag conversionFlag)
Translates a given conversion flag to a string.
static MatrixD transformationMatrix_FullRangeBGR24_To_FullRangeYVU24_BT601()
Returns the 3x4 color space transformation matrix from full range BGR24 to full range YVU24 using BT....
static void convertArbitraryPixelFormatSubset(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, const unsigned int firstMultipleRow, const unsigned int numberMultipleRows)
Converts a subset of a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16,...
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:3483
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 MatrixD transformationMatrix_FullRangeRGB24_To_FullRangeYVU24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to full range YVU24 using BT....
void(*)(T *row, const size_t width) RowReversePixelOrderInPlaceFunction
Definition of a function pointer to a function able to reverse the order of pixels in an image row wi...
Definition FrameConverter.h:603
static void convertOneRow_1Plane1Channel_To_1Plane1Channel_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 one row of a single-channel image to another single-channel image with 10-bit precision.
static void convertOneRow_1Plane1Channel_To_1Plane1Channel_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 a single-channel image to another single-channel image with 6-bit precision.
static MatrixD transformationMatrix_FullRangeRGB24_To_FullRangeYUV24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to full range YUV24 using BT....
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeBGR24_Android()
Returns the color space transformation matrix from full range YVU24 to full range BGR24 similar to BT...
static OCEAN_FORCE_INLINE void unpack15ElementsBayerMosaicPacked10BitNEON(const uint8_t *const packed, uint16x8_t &unpackedAB_u_16x8, uint16x4_t &unpackedC_u_16x4)
Unpacks 15 elements from a row in a packed Bayer mosaic to 12 pixels values The required memory layou...
Definition FrameConverter.h:3536
static void cast(const TSource *__restrict source, TTarget *__restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
Casts the pixel values from one frame type to another frame type.
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels16Bit(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 3-channel Bayer mosaic pixel format with packed 10-bit pixel value...
static void convertTwoRows_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 two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e....
static void cast16Elements(const TSource *const source, TTarget *const target)
Casts 16 successive elements from one data type to another data type.
static void mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(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....
CopyPreference
Definition of a boolean enum for copy preferences (to improve code readability).
Definition FrameConverter.h:94
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_Android()
Returns the color space transformation matrix from full range YVU24 to full range RGB24 similar to BT...
static bool subFrame(const T *source, T *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
Copies a sub-frame of a given frame into a second frame while both frames might have an individual nu...
Definition FrameConverter.h:3305
static void convertGenericPixelFormatSubset(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourceStrideBytes, const unsigned int targetStrideBytes, const ConversionFlag flag, const RowConversionFunction< uint8_t, uint8_t > rowConversionFunction, const RowReversePixelOrderInPlaceFunction< uint8_t > targetReversePixelOrderInPlaceFunction, const bool areContinuous, const void *options, const unsigned int firstRow, const unsigned int numberRows)
Converts a subset of a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24,...
static MatrixD transformationMatrix_FullRangeRGB24_To_LimitedRangeYVU24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YVU24 using ...
static void convertOneRow_3Planes1Channel_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_V24 pixel format to one rows of an image with e....
static MatrixD transformationMatrix_LimitedRangeYVU24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from limited range YVU24 to full range BGR24 using BT....
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 MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from full range YVU24 to full range BGR24 using BT....
static void convertOneRow_1Plane1Channel_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 one row of a single-channel image to a 3-channel image with 6-bit precision and range conver...
static void patchFrameMirroredBorder(const T *source, T *buffer, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
Copies a small patch area of a frame into a buffer holding only the entire patch.
Definition FrameConverter.h:3428
void(*)(const T *inputRow, T *targetRow, const size_t width) RowReversePixelOrderFunction
Definition of a function pointer to a function able to reverse the order of pixels in an image row wi...
Definition FrameConverter.h:594
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 mapTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (matches) two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with...
static void convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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 MatrixD transformationMatrix_LimitedRangeYVU24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from limited range YVU24 to full range RGB24 using BT....
static void mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel(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 YUV24 pixel format to two rows of an image with e....
static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel(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 UYVY16 pixel format to one row of an image with e....
static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_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_UV12 pixel format to two rows of an image with e....
static MatrixD transformationMatrix_LimitedRangeYUV24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from limited range YUV24 to full range BGR24 using BT....
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 convertOneRow_1Plane1Channel_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 one row of a single-channel image to a 3-channel image with 10-bit precision and range conve...
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 MatrixD transformationMatrix_FullRangeBGR24_To_LimitedRangeYUV24_BT601()
Returns the color space transformation matrix from full range BGR24 to limited range YUV24 using BT....
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8Bit(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 3-channel Bayer mosaic pixel format with packed 10-bit pixel value...
static MatrixD transformationMatrix_LimitedRangeYUV24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from limited range YUV24 to full range RGB24 using BT....
static MatrixD transformationMatrix_FullRangeBGR24_To_FullRangeYUV24_BT601()
Returns the 3x4 color space transformation matrix from full range BGR24 to full range YUV24 using BT....
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition Caller.h:2877
This class implements Ocean's image class.
Definition Frame.h:1832
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition Frame.h:4275
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition Frame.h:4266
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4555
bool copy(const Frame &source, const bool copyTimestamp=true)
Deprecated.
bool isOwner() const
Returns whether the frame is the owner of the internal frame data.
Definition Frame.h:4398
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition Frame.h:4149
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
@ FORMAT_UNDEFINED
Undefined pixel format.
Definition Frame.h:187
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3194
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition Frame.h:3239
uint32_t numberPlanes() const
Returns the number of planes of the pixel format of this frame.
Definition Frame.h:3234
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition Frame.h:3204
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1046
@ ORIGIN_INVALID
Invalid origin type.
Definition Frame.h:1048
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3199
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3224
DataType dataType() const
Returns the data type of the pixel format of this frame.
Definition Frame.h:3214
This class implements a matrix with arbitrary size.
Definition Matrix.h:63
This template class is the base class for all singleton objects.
Definition Singleton.h:71
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Helper class for a hash function.
Definition FrameConverter.h:361
size_t operator()(const ConversionTriple &conversionTriple) const
Hash function.
Definition FrameConverter.h:2963
Definition of the parameters used by the function for row-wise conversion of RGGB14_PACKED to RGB24/B...
Definition FrameConverter.h:609