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