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, analog RGB to (analog) YPbPr.
1052 * Below the precise transformation matrices are given:
1053 * <pre>
1054 * RGB input value range: [0, 255]x[0, 255]x[0, 255]
1055 * YUV output value range: [0, 255]x[0, 255]x[0, 255]
1056 *
1057 * | Y | | 0.299 0.587 0.114 0 | | R |
1058 * | U | = | -0.168736 -0.331264 0.5 128 | * | G |
1059 * | V | | 0.5 -0.418688 -0.081312 128 | | B |
1060 * | 1 |
1061 * Approximation with 7 bit precision:
1062 * | Y | | 38 75 15 0 128 | | R |
1063 * 128 * | U | = | -22 -42 64 128 * 128 | * | G |
1064 * | V | | 64 -54 -10 128 * 128 | | B |
1065 * | 1 |
1066 * </pre>
1067 * @return The 3x4 transformation matrix
1068 * @see transformationMatrix_FullRangeRGB24_To_FullRangeYVU24_BT601().
1069 */
1071
1072 /**
1073 * Returns the 3x4 color space transformation matrix from full range RGB24 to full range YVU24 using BT.601, analog RGB to (analog) YPbPr.
1074 * @return The 3x4 transformation matrix
1075 * @see transformationMatrix_FullRangeRGB24_To_FullRangeYUV24_BT601().
1076 */
1078
1079 /**
1080 * Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YUV24 using BT.601, analog RGB to (digital) YCbCr.
1081 * Below the precise transformation matrices are given:
1082 * <pre>
1083 * RGB input value range: [0, 255]x[0, 255]x[0, 255]
1084 * YUV output value range: [16, 235]x[16, 240]x[16, 240]
1085 *
1086 * | Y | | 0.2578125 0.5039063 0.09765625 16.0 | | R |
1087 * | U | = | -0.1484375 -0.2890625 0.4375 128.0 | * | G |
1088 * | V | | 0.4375 -0.3671875 -0.0703125 128.0 | | B |
1089 * | 1 |
1090 * Approximation with 7 bit precision:
1091 * | Y | | 33 64 13 16 * 128 | | R |
1092 * 128 * | U | = | -19 -37 56 128 * 128 | * | G |
1093 * | V | | 56 -47 -9 128 * 128 | | B |
1094 * | 1 |
1095 * </pre>
1096 * @return The 3x4 transformation matrix
1097 * @see transformationMatrix_FullRangeRGB24_To_LimitedRangeYVU24_BT601().
1098 */
1100
1101 /**
1102 * Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YVU24 using BT.601, analog RGB to (digital) YCbCr.
1103 * @return The 3x4 transformation matrix
1104 * @see transformationMatrix_FullRangeRGB24_To_LimitedRangeYUV24_BT601().
1105 */
1107
1108 /**
1109 * Returns the color space transformation matrix from full range YUV24 to full range BGR24 using BT.601, (analog) YPbPr to analog BGR.
1110 * Below the precise transformation matrices are given:
1111 * <pre>
1112 * YUV input value range: [0, 255]x[0, 255]x[0, 255]
1113 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1114 *
1115 * | B | | 1.0 1.772 0.0 -226.816 | | Y |
1116 * | G | = | 1.0 -0.34414 -0.71414 135.45984 | * | U |
1117 * | R | | 1.0 0.0 1.402 -179.456 | | V |
1118 * | 1 |
1119 *
1120 * Approximation with 6 bit precision:
1121 * | B | | 64 113 0 | | Y |
1122 * 64 * | G | = | 64 -22 -46 | * | U - 128 |
1123 * | R | | 64 0 90 | | V - 128 |
1124 * </pre>
1125 * @return The 3x4 transformation matrix
1126 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android().
1127 */
1129
1130 /**
1131 * Returns the color space transformation matrix from full range YUV24 to full range RGB24 using BT.601, (analog) YPbPr to analog RGB.
1132 * Below the precise transformation matrices are given:
1133 * <pre>
1134 * YUV input value range: [0, 255]x[0, 255]x[0, 255s]
1135 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1136 *
1137 * | R | | 1.0 0.0 1.402 -179.456 | | Y |
1138 * | G | = | 1.0 -0.34414 -0.71414 135.45984 | * | U |
1139 * | B | | 1.0 1.772 0.0 -226.816 | | V |
1140 * | 1 |
1141 *
1142 * Approximation with 6 bit precision:
1143 * | R | | 64 0 90 | | Y |
1144 * 64 * | G | = | 64 -22 -46 | * | U - 128 |
1145 * | B | | 64 113 0 | | V - 128 |
1146 * </pre>
1147 * @return The 3x4 transformation matrix
1148 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android().
1149 */
1151
1152 /**
1153 * Returns the color space transformation matrix from full range YUV24 to full range BGR24 similar to BT.601, (analog) YPbPr to analog BGR.
1154 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1155 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android().
1156 * @return The 3x4 transformation matrix
1157 */
1159
1160 /**
1161 * Returns the color space transformation matrix from full range YUV24 to full range RGB24 similar to BT.601, (analog) YPbPr to analog RGB.
1162 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1163 * The conversion can be found in Android's source code: /media/libstagefright/yuv/YUVImage.cpp<br>
1164 * Below the precise transformation matrices are given:
1165 * <pre>
1166 * YUV input value range: [0, 255]x[0, 255]x[0, 255s]
1167 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1168 *
1169 * | R | | 1.0 0.0 1.370705 | | Y | | 1.0 0.0 1.370705 -175.45024 | | Y |
1170 * | G | = | 1.0 -0.337633 -0.698001 | * | U - 128 | = | 1.0 -0.337633 -0.698001 132.561152 | * | U |
1171 * | B | | 1.0 1.732446 0.0 | | V - 128 | | 1.0 1.732446 0.0 -221.753088 | | V |
1172 * | 1 |
1173 *
1174 * Approximation with 6 bit precision:
1175 * | R | | 64 0 88 | | Y |
1176 * 64 * | G | = | 64 -22 -45 | * | U - 128 |
1177 * | B | | 64 111 0 | | V - 128 |
1178 * </pre>
1179 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_BT601(), transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_Android().
1180 * @return The 3x4 transformation matrix
1181 */
1183
1184 /**
1185 * Returns the color space transformation matrix from full range YVU24 to full range BGR24 similar to BT.601, (analog) YPbPr to analog BGR.
1186 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1187 * @see transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_Android().
1188 * @return The 3x4 transformation matrix
1189 */
1191
1192 /**
1193 * Returns the color space transformation matrix from full range YVU24 to full range RGB24 similar to BT.601, (analog) YPbPr to analog RGB.
1194 * This transformation matrix is close to the official BT.601 standard and used on Android for conversion from Y'UV420sp (NV21).<br>
1195 * The conversion can be found in Android's source code: /media/libstagefright/yuv/YUVImage.cpp<br>
1196 * Below the precise transformation matrices are given:
1197 * <pre>
1198 * YUV input value range: [0, 255]x[0, 255]x[0, 255s]
1199 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1200 *
1201 * | R | | 1.0 1.370705 0.0 | | Y | | 1.0 1.370705 0.0 -175.45024 | | Y |
1202 * | G | = | 1.0 -0.698001 -0.337633 | * | V - 128 | = | 1.0 -0.698001 -0.337633 132.561152 | * | V |
1203 * | B | | 1.0 0.0 1.732446 | | U - 128 | | 1.0 0.0 1.732446 -221.753088 | | U |
1204 * | 1 |
1205 *
1206 * Approximation with 6 bit precision:
1207 * | R | | 64 88 0 | | Y |
1208 * 64 * | G | = | 64 -45 -22 | * | V - 128 |
1209 * | B | | 64 0 111 | | U - 128 |
1210 * </pre>
1211 * @return The 3x4 transformation matrix
1212 */
1214
1215 /**
1216 * Returns the color space transformation matrix from limited range YUV24 to full range RGB24 using BT.601, (digital) YCbCr to analog RGB.
1217 * Below the precise transformation matrices are given:
1218 * <pre>
1219 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
1220 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1221 *
1222 * | R | | 1.1639404296875 0.0 1.595947265625 -222.904296875 | | Y |
1223 * | G | = | 1.1639404296875 -0.3909912109375 -0.81298828125 135.486328125 | * | U |
1224 * | B | | 1.1639404296875 2.0179443359375 0.0 -276.919921875 | | V |
1225 * | 1 |
1226 *
1227 * Approximation with 13 bit precision:
1228 * | R | | 9535 0 13074 | | Y - 16 |
1229 * 8192 * | G | = | 9535 -3203 -6660 | * | U - 128 |
1230 * | B | | 9535 16531 0 | | V - 128 |
1231 *
1232 * Approximation with 10 bit precision:
1233 * | R | | 1192 0 1634 -223 * 1024 | | Y |
1234 * 1024 * | G | = | 1192 -400 -833 135 * 1024 | * | U |
1235 * | B | | 1192 2066 0 -277 * 1024 | | V |
1236 * | 1 |
1237 *
1238 * Approximation with 8 bit precision:
1239 * | R | | 298 0 409 | | Y - 16 |
1240 * 256 * | G | = | 298 -409 -208 | * | U - 128 |
1241 * | B | | 298 516 0 | | V - 128 |
1242 *
1243 * Approximation with 6 bit precision:
1244 * | R | | 75 0 102 | | Y - 16 |
1245 * 64 * | G | = | 75 -25 -52 | * | U - 128 |
1246 * | B | | 75 128 0 | | V - 128 |
1247 * </pre>
1248 * @return The 3x4 transformation matrix
1249 */
1251
1252 /**
1253 * Returns the color space transformation matrix from full range BGR24 to limited range YUV24 using BT.601, analog RGB to (digital) YCbCr.
1254 * <pre>
1255 * BGR input value range: [0, 255]x[0, 255]x[0, 255]
1256 * YUV output value range: [16, 235]x[16, 240]x[16, 240]
1257 * </pre>
1258 * @return The 3x4 transformation matrix
1259 * @see transformationMatrixFullRangeRGB24ToLimitedRangeYUV24_BT601().
1260 */
1262
1263 /**
1264 * Returns the 3x4 color space transformation matrix from full range BGR24 to full range YUV24 using BT.601, analog BGR to (analog) YPbPr.
1265 * Below the precise transformation matrices are given:
1266 * <pre>
1267 * BGR input value range: [0, 255]x[0, 255]x[0, 255]
1268 * YUV output value range: [0, 255]x[0, 255]x[0, 255]
1269 *
1270 * | Y | | 0.114 0.587 0.299 0 | | B |
1271 * | U | = | 0.5 -0.331264 -0.168736 128 | * | G |
1272 * | V | | -0.081312 -0.418688 0.5 128 | | R |
1273 * | 1 |
1274 * Approximation with 7 bit precision:
1275 * | Y | | 15 75 38 0 128 | | B |
1276 * 128 * | U | = | 64 -42 -22 128 * 128 | * | G |
1277 * | V | | -10 -54 64 128 * 128 | | R |
1278 * | 1 |
1279 * </pre>
1280 * @return The 3x4 transformation matrix
1281 * @see transformationMatrix_FullRangeRGB24_To_FullRangeYUV24_BT601().
1282 */
1284
1285 /**
1286 * Returns the 3x4 color space transformation matrix from full range BGR24 to full range YVU24 using BT.601, analog BGR to (analog) YPbPr.
1287 * Below the precise transformation matrices are given:
1288 * <pre>
1289 * BGR input value range: [0, 255]x[0, 255]x[0, 255]
1290 * YVU output value range: [0, 255]x[0, 255]x[0, 255]
1291 * </pre>
1292 * @return The 3x4 transformation matrix
1293 * @see transformationMatrix_FullRangeBGR24_To_FullRangeYUV24_BT601().
1294 */
1296
1297 /**
1298 * Returns the color space transformation matrix from limited range YUV24 to full range BGR24 using BT.601, (digital) YCbCr to analog BGR.
1299 * <pre>
1300 * YUV input value range: [16, 235]x[16, 240]x[16, 240]
1301 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
1302 * </pre>
1303 * @return The 3x4 transformation matrix
1304 * @see transformationMatrixLimitedRangeYUV24ToFullRangeRGB24_BT601().
1305 */
1307
1308 /**
1309 * Returns the color space transformation matrix from limited range YVU24 to full range BGR24 using BT.601, (digital) YCrCb to analog BGR.
1310 * <pre>
1311 * YVU input value range: [16, 235]x[16, 240]x[16, 240]
1312 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
1313 * </pre>
1314 * @return The 3x4 transformation matrix
1315 * @see transformationMatrixLimitedRangeYUV24ToFullRangeRGB24_BT601().
1316 */
1318
1319 /**
1320 * Returns the color space transformation matrix from limited range YVU24 to full range RGB24 using BT.601, (digital) YCrCb to analog RGB.
1321 * <pre>
1322 * YVU input value range: [16, 235]x[16, 240]x[16, 240]
1323 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1324 * </pre>
1325 * @return The 3x4 transformation matrix
1326 * @see transformationMatrixLimitedRangeYUV24ToFullRangeRGB24_BT601().
1327 */
1329
1330 /**
1331 * Returns the color space transformation matrix from full range YVU24 to full range RGB24 using BT.601, (digital) YCrCb to analog RGB.
1332 * <pre>
1333 * YVU input value range: [0, 255]x[0, 255]x[0, 255]
1334 * RGB output value range: [0, 255]x[0, 255]x[0, 255]
1335 * </pre>
1336 * @return The 3x4 transformation matrix
1337 * @see transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_BT601().
1338 */
1340
1341 /**
1342 * Returns the color space transformation matrix from full range YVU24 to full range BGR24 using BT.601, (digital) YCrCb to analog BGR.
1343 * <pre>
1344 * YVU input value range: [0, 255]x[0, 255]x[0, 255]
1345 * BGR output value range: [0, 255]x[0, 255]x[0, 255]
1346 * </pre>
1347 * @return The 3x4 transformation matrix
1348 * @see transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_BT601().
1349 */
1351
1352 /**
1353 * Returns a vector holding all possible conversion flags.
1354 * @return The vector with conversion flags, will be four.
1355 */
1357
1358 /**
1359 * Translates a given conversion flag to a string.
1360 * @param conversionFlag The conversion flag to be translated
1361 * @return The resulting string containing the flag
1362 */
1363 static std::string translateConversionFlag(const ConversionFlag conversionFlag);
1364
1365 protected:
1366
1367 /**
1368 * Casts 16 successive elements from one data type to another data type.
1369 * @param source The 16 source elements that will be casted, must be valid
1370 * @param target The 16 target elements receiving the casted pixel values, must be valid
1371 * @tparam TSource The data type of each pixel channel of the source frame, e.g., 'uint8_t', 'int', 'float', ...
1372 * @tparam TTarget The data type of each pixel channel of the target frame, e.g., 'uint8_t', 'int', 'float', ...
1373 */
1374 template <typename TSource, typename TTarget>
1375 static inline void cast16Elements(const TSource* const source, TTarget* const target);
1376
1377 /**
1378 * Converts a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24, ...) to a frame with generic pixel format (e.g., RGB24, Y8).
1379 * 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.
1380 * @param source The source frame with generic pixel format, must be valid
1381 * @param target The target frame with generic pixel format, must be valid
1382 * @param width The width of the frame, with range [1, infinity)
1383 * @param height The height of the frame, with range [1, infinity)
1384 * @param sourceStrideElements Number of horizontal elements between the start of two source rows, in elements, with range [width * elementsPerSourcePixel, infinity)
1385 * @param targetStrideElements Number of horizontal elements between the start of two target rows, in elements, with range [width * elementsPerTargetPixel, infinity)
1386 * @param flag Determining the type of conversion
1387 * @param rowConversionFunction The function able to convert one row, must be valid
1388 * @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
1389 * @param areContinuous True, if source and target frame have continuous memory (without padding); False, otherwise
1390 * @param options Optional options which are necessary in the row conversion function, otherwise nullptr
1391 * @param worker Optional worker to distribute the computation to several CPU cores
1392 * @tparam TSource The data type of each source pixel element, e.g., 'uint8_t' or 'float'
1393 * @tparam TTarget The data type of each target pixel element, e.g., 'uint8_t' or 'float'
1394 */
1395 template <typename TSource, typename TTarget>
1396 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);
1397
1398 /**
1399 * Converts a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbitrary pixel format.
1400 * This function needs a function pointer that is able to convert multiple rows.
1401 * @param sources The memory pointers defining the source frame, e.g., several individual points to individual blocks in memory, must be valid
1402 * @param targets The memory pointers defining the target frame, e.g., several individual points to individual blocks in memory, must be valid
1403 * @param width The width of the frame, with range [1, infinity)
1404 * @param height The height of the frame, with range [multipleRowsPerIteration, infinity), must be a multiple of 'multipleRowsPerIteration'
1405 * @param flag The conversion type to be applied
1406 * @param multipleRowsPerIteration The number of rows, the specified rows-conversion-functions 'multipleRowsConversionFunction' can handle within one iteration, with range [1, infinity)
1407 * @param multipleRowsConversionFunction The function able to convert several row, must be valid
1408 * @param options Optional options which are necessary in the rows conversion function, otherwise nullptr
1409 * @param worker Optional worker to distribute the computation to several CPU cores
1410 */
1411 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);
1412
1413 /**
1414 * 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).
1415 * 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.
1416 * @param source The source frame with generic pixel format, must be valid
1417 * @param target The target frame with generic pixel format, must be valid
1418 * @param width The width of the frame, with range [1, infinity)
1419 * @param height The height of the frame, with range [1, infinity)
1420 * @param sourceStrideBytes Number of bytes between the start of two source rows, in bytes, with range [width * elementsPerSourcePixel * sizeof(channelElement), infinity)
1421 * @param targetStrideBytes Number of bytes between the start of two target rows, in bytes, with range [width * elementsPerTargetPixel * sizeof(channelElement), infinity)
1422 * @param flag Determining the type of conversion
1423 * @param rowConversionFunction The function able to convert one row, must be valid
1424 * @param targetReversePixelOrderInPlaceFunction The function able to reverse the pixel order in one target row, must be valid
1425 * @param areContinuous True, if source and target frame have continuous memory (without padding); False, otherwise
1426 * @param options Optional options which are necessary in the row conversion function, otherwise nullptr
1427 * @param firstRow The first row to be handled, with range [0, height - 1]
1428 * @param numberRows The number of rows to be handled, with range [1, height - firstRow]
1429 * @see convertGenericPixelFormat<T>().
1430 */
1431 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);
1432
1433 /**
1434 * Converts a subset of a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbitrary pixel format.
1435 * @param sources The memory pointers defining the source frame, e.g., several individual points to individual blocks in memory, must be valid
1436 * @param targets The memory pointers defining the target frame, e.g., several individual points to individual blocks in memory, 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 [multipleRowsPerIteration, infinity), must be a multiple of 'multipleRowsPerIteration'
1439 * @param flag The conversion type to be applied
1440 * @param multipleRowsPerIteration The number of rows, the specified rows-conversion-functions 'multipleRowsConversionFunction' can handle within one iteration, with range [1, infinity)
1441 * @param multipleRowsConversionFunction The function able to convert several row, must be valid
1442 * @param options Optional options which are necessary in the rows conversion function, otherwise nullptr
1443 * @param firstMultipleRow The first multiple-row to be handled, with range [0, height / multipleRowsPerIteration - 1]
1444 * @param numberMultipleRows The number of multiple-rows to be handled, with range [1, height / multipleRowsPerIteration]
1445 * @see convertArbitraryPixelFormat().
1446 */
1447 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);
1448
1449 /**
1450 * This function is not used anymore due to the corresponding 2-row function.
1451 *
1452 * 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.
1453 * 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>
1454 * 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>
1455 * 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>
1456 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1457 * <pre>
1458 * source0: source1:
1459 * --------- ---------
1460 * | Y Y Y Y | | U V U V |
1461 * | Y Y Y Y | | U V U V |
1462 * | Y Y Y Y | ---------
1463 * | Y Y Y Y |
1464 * ---------
1465 * </pre>
1466 *
1467 * The layout of the target image of e.g., a RGB24 image looks like this:
1468 * <pre>
1469 * target:
1470 * ----------------------------
1471 * | R G B R G B R G B R G B |
1472 * | R G B R G B R G B R G B |
1473 * | R G B R G B R G B R G B |
1474 * | R G B R G B R G B R G B |
1475 * ----------------------------
1476 * </pre>
1477 *
1478 * The layout of the options parameters is as follows:
1479 * <pre>
1480 * options[ 0] uint32_t: sourcePlane0PaddingElements
1481 * options[ 1] uint32_t: sourcePlane1PaddingElements
1482 * options[ 2] uint32_t: targetPlanePaddingElements
1483 *
1484 * options[ 3] int32_t: f00
1485 * options[ 4] int32_t: f10
1486 * options[ 5] int32_t: f20
1487 * options[ 6] int32_t: f01
1488 * options[ ] ...
1489 * options[11] int32_t: f22
1490 *
1491 * options[12] int32_t: b0, with range [0, 128]
1492 * options[13] int32_t: b1, with range [0, 128]
1493 * options[14] int32_t: b2, with range [0, 128]
1494 *
1495 * with transformation:
1496 * sb0 = s0 - b0 // source adjusted with bias
1497 * sb1 = s1 - b1
1498 * sb2 = s2 - b2
1499 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
1500 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
1501 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
1502 * </pre>
1503 * @param sources The pointer to the first and second memory block of the source image, must be valid
1504 * @param targets The one pointer to the target image, must be valid
1505 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height 1]
1506 * @param width The width of the frame in pixel, with range [1, infinity), must be even
1507 * @param height The height of the frame in pixel, with range [1, infinity), must be even
1508 * @param conversionFlag The conversion to be applied
1509 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1510 * @see convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit().
1511 */
1512 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);
1513
1514 /**
1515 * This function is not used anymore due to the corresponding 2-row function.
1516 *
1517 * 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.
1518 * 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>
1519 * 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>
1520 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
1521 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1522 * <pre>
1523 * source0: source1:
1524 * --------- ---------
1525 * | Y Y Y Y | | U V U V |
1526 * | Y Y Y Y | | U V U V |
1527 * | Y Y Y Y | ---------
1528 * | Y Y Y Y |
1529 * ---------
1530 * </pre>
1531 *
1532 * The layout of the target image of e.g., a RGB24 image looks like this:
1533 * <pre>
1534 * target:
1535 * ----------------------------
1536 * | R G B R G B R G B R G B |
1537 * | R G B R G B R G B R G B |
1538 * | R G B R G B R G B R G B |
1539 * | R G B R G B R G B R G B |
1540 * ----------------------------
1541 * </pre>
1542 *
1543 * The layout of the options parameters is as follows:
1544 * <pre>
1545 * options[ 0] uint32_t: sourcePlane0PaddingElements
1546 * options[ 1] uint32_t: sourcePlane1PaddingElements
1547 * options[ 2] uint32_t: targetPlanePaddingElements
1548 *
1549 * options[ 3] int32_t: f00
1550 * options[ 4] int32_t: f10
1551 * options[ 5] int32_t: f20
1552 * options[ 6] int32_t: f01
1553 * options[ ] ...
1554 * options[11] int32_t: f22
1555 *
1556 * options[12] int32_t: b0
1557 * options[13] int32_t: b1
1558 * options[14] int32_t: b2
1559 *
1560 * with transformation:
1561 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
1562 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
1563 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
1564 * </pre>
1565 * @param sources The pointer to the first and second memory block of the source image, must be valid
1566 * @param targets The one pointer to the target image, must be valid
1567 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height 1]
1568 * @param width The width of the frame in pixel, with range [1, infinity), must be even
1569 * @param height The height of the frame in pixel, with range [1, infinity), must be even
1570 * @param conversionFlag The conversion to be applied
1571 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1572 * @see convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit().
1573 */
1574 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);
1575
1576 /**
1577 * 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.
1578 * 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>
1579 * 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>
1580 * 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>
1581 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1582 * <pre>
1583 * source0: source1:
1584 * --------- ---------
1585 * | Y Y Y Y | | U V U V |
1586 * | Y Y Y Y | | U V U V |
1587 * | Y Y Y Y | ---------
1588 * | Y Y Y Y |
1589 * ---------
1590 * </pre>
1591 *
1592 * The layout of the target image of e.g., a RGB24 image looks like this:
1593 * <pre>
1594 * target:
1595 * ----------------------------
1596 * | R G B R G B R G B R G B |
1597 * | R G B R G B R G B R G B |
1598 * | R G B R G B R G B R G B |
1599 * | R G B R G B R G B R G B |
1600 * ----------------------------
1601 * </pre>
1602 *
1603 * The layout of the options parameters is as follows:
1604 * <pre>
1605 * options[ 0] uint32_t: sourcePlane0PaddingElements
1606 * options[ 1] uint32_t: sourcePlane1PaddingElements
1607 * options[ 2] uint32_t: targetPlanePaddingElements
1608 *
1609 * options[ 3] int32_t: f00
1610 * options[ 4] int32_t: f10
1611 * options[ 5] int32_t: f20
1612 * options[ 6] int32_t: f01
1613 * options[ ] ...
1614 * options[11] int32_t: f22
1615 *
1616 * options[12] int32_t: b0, with range [0, 128]
1617 * options[13] int32_t: b1, with range [0, 128]
1618 * options[14] int32_t: b2, with range [0, 128]
1619 *
1620 * with transformation:
1621 * sb0 = s0 - b0 // source adjusted with bias
1622 * sb1 = s1 - b1
1623 * sb2 = s2 - b2
1624 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
1625 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
1626 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
1627 * </pre>
1628 * @param sources The pointer to the first and second memory block of the source image, must be valid
1629 * @param targets The one pointer to the target image, must be valid
1630 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1631 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1632 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1633 * @param conversionFlag The conversion to be applied
1634 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1635 */
1636 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);
1637
1638 /**
1639 * 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.
1640 * 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>
1641 * 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>
1642 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
1643 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1644 * <pre>
1645 * source0: source1:
1646 * --------- ---------
1647 * | Y Y Y Y | | U V U V |
1648 * | Y Y Y Y | | U V U V |
1649 * | Y Y Y Y | ---------
1650 * | Y Y Y Y |
1651 * ---------
1652 * </pre>
1653 *
1654 * The layout of the target image of e.g., a RGB24 image looks like this:
1655 * <pre>
1656 * target:
1657 * ----------------------------
1658 * | R G B R G B R G B R G B |
1659 * | R G B R G B R G B R G B |
1660 * | R G B R G B R G B R G B |
1661 * | R G B R G B R G B R G B |
1662 * ----------------------------
1663 * </pre>
1664 *
1665 * The layout of the options parameters is as follows:
1666 * <pre>
1667 * options[ 0] uint32_t: sourcePlane0PaddingElements
1668 * options[ 1] uint32_t: sourcePlane1PaddingElements
1669 * options[ 2] uint32_t: targetPlanePaddingElements
1670 *
1671 * options[ 3] int32_t: f00
1672 * options[ 4] int32_t: f10
1673 * options[ 5] int32_t: f20
1674 * options[ 6] int32_t: f01
1675 * options[ ] ...
1676 * options[11] int32_t: f22
1677 *
1678 * options[12] int32_t: b0
1679 * options[13] int32_t: b1
1680 * options[14] int32_t: b2
1681 *
1682 * with transformation:
1683 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
1684 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
1685 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
1686 * </pre>
1687 * @param sources The pointer to the first and second memory block of the source image, must be valid
1688 * @param targets The one pointer to the target image, must be valid
1689 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1690 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1691 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1692 * @param conversionFlag The conversion to be applied
1693 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1694 */
1695 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);
1696
1697 /**
1698 * 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.
1699 * This function needs a source image with one plane and a target image with two planes.
1700 * 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>
1701 * Note: The bias values (b0-b2) are added AFTER the division by 128.<br>
1702 * The layout of the source image of e.g., a RGB24 image looks like this:
1703 * <pre>
1704 * source:
1705 * ----------------------------
1706 * | R G B R G B R G B R G B |
1707 * | R G B R G B R G B R G B |
1708 * | R G B R G B R G B R G B |
1709 * | R G B R G B R G B R G B |
1710 * ----------------------------
1711 * </pre>
1712 *
1713 * The layout of the target image of e.g., an Y_UV12 image looks like this:
1714 * <pre>
1715 * target0: target1:
1716 * --------- ---------
1717 * | Y Y Y Y | | U V U V |
1718 * | Y Y Y Y | | U V U V |
1719 * | Y Y Y Y | ---------
1720 * | Y Y Y Y |
1721 * ---------
1722 * </pre>
1723 *
1724 * The layout of the options parameters is as follows:
1725 * <pre>
1726 * options[ 0] uint32_t: sourcePlanePaddingElements
1727 * options[ 1] uint32_t: targetPlane0PaddingElements
1728 * options[ 2] uint32_t: targetPlane1PaddingElements
1729 *
1730 * options[ 3] int32_t: f00
1731 * options[ 4] int32_t: f10
1732 * options[ 5] int32_t: f20
1733 * options[ 6] int32_t: f01
1734 * options[ ] ...
1735 * options[11] int32_t: f22
1736 *
1737 * options[12] int32_t: b0, with range [-128, 128]
1738 * options[13] int32_t: b1, with range [-128, 128]
1739 * options[14] int32_t: b2, with range [-128, 128]
1740 *
1741 * with transformation:
1742 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 128 + b0, 255)
1743 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 128 + b1, 255)
1744 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 128 + b2, 255)
1745 * </pre>
1746 * @param sources The pointer to the source plane, must be valid
1747 * @param targets The pointers to the first and second target plane, must be valid
1748 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1749 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1750 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1751 * @param conversionFlag The conversion to be applied
1752 * @param options The 15 options parameters: 3 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1753 */
1754 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);
1755
1756 /**
1757 * 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.
1758 * This function needs a source image with one plane and a target image with three planes.
1759 * 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>
1760 * Note: The bias values (b0-b2) are added AFTER the division by 128.<br>
1761 * The layout of the source image of e.g., a RGB24 image looks like this:
1762 * <pre>
1763 * source:
1764 * ----------------------------
1765 * | R G B R G B R G B R G B |
1766 * | R G B R G B R G B R G B |
1767 * | R G B R G B R G B R G B |
1768 * | R G B R G B R G B R G B |
1769 * ----------------------------
1770 * </pre>
1771 *
1772 * The layout of the target image of e.g., an Y_U_V12 image looks like this:
1773 * <pre>
1774 * target0: target1: target2:
1775 * --------- ----- -----
1776 * | Y Y Y Y | | U U | | V V |
1777 * | Y Y Y Y | | U U | | V V |
1778 * | Y Y Y Y | ----- -----
1779 * | Y Y Y Y |
1780 * ---------
1781 * </pre>
1782 *
1783 * The layout of the options parameters is as follows:
1784 * <pre>
1785 * options[ 0] uint32_t: sourcePlanePaddingElements
1786 * options[ 1] uint32_t: targetPlane0PaddingElements
1787 * options[ 2] uint32_t: targetPlane1PaddingElements
1788 * options[ 3] uint32_t: targetPlane2PaddingElements
1789 *
1790 * options[ 4] int32_t: f00
1791 * options[ 5] int32_t: f10
1792 * options[ 6] int32_t: f20
1793 * options[ 7] int32_t: f01
1794 * options[ ] ...
1795 * options[12] int32_t: f22
1796 *
1797 * options[13] int32_t: b0, with range [-128, 128]
1798 * options[14] int32_t: b1, with range [-128, 128]
1799 * options[15] int32_t: b2, with range [-128, 128]
1800 *
1801 * with transformation:
1802 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 128 + b0, 255)
1803 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 128 + b1, 255)
1804 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 128 + b2, 255)
1805 * </pre>
1806 * @param sources The pointer to the source plane, must be valid
1807 * @param targets The pointers to the first, second, and third target planes, must be valid
1808 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1809 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1810 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1811 * @param conversionFlag The conversion to be applied
1812 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
1813 */
1814 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);
1815
1816 /**
1817 * 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.
1818 * This function needs three source planes each holding one channel.<br>
1819 * The layout of the source image of e.g., an Y_U_V24 image looks like this:
1820 * <pre>
1821 * source0: source1: source2:
1822 * --------- --------- ---------
1823 * | Y Y Y Y | | U U U U | | V V V V |
1824 * | Y Y Y Y | | U U U U | | V V V V |
1825 * | Y Y Y Y | | U U U U | | V V V V |
1826 * | Y Y Y Y | | U U U U | | V V V V |
1827 * --------- --------- ---------
1828 * </pre>
1829 *
1830 * The layout of the target image of e.g., an YUV24 image looks like this:
1831 * <pre>
1832 * target:
1833 * ----------------------------
1834 * | Y U V Y U V Y U V Y U V |
1835 * | Y U V Y U V Y U V Y U V |
1836 * | Y U V Y U V Y U V Y U V |
1837 * | Y U V Y U V Y U V Y U V |
1838 * ----------------------------
1839 * </pre>
1840 *
1841 * The layout of the options parameters is as follows:
1842 * <pre>
1843 * options[0] uint32_t: sourcePlane0PaddingElements
1844 * options[1] uint32_t: sourcePlane1PaddingElements
1845 * options[2] uint32_t: sourcePlane2PaddingElements
1846 * options[2] uint32_t: targetPlanePaddingElements
1847 *
1848 * with transformation:
1849 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1850 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1851 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1852 * </pre>
1853 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
1854 * @param targets The one pointer to the target image, must be valid
1855 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
1856 * @param width The width of the frame in pixel, with range [1, infinity)
1857 * @param height The height of the frame in pixel, with range [1, infinity)
1858 * @param conversionFlag The conversion to be applied
1859 * @param options The 4 options parameters: 4 padding parameters, with ranges [0, infinity), must be valid
1860 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
1861 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
1862 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
1863 */
1864 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
1865 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);
1866
1867 /**
1868 * 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.
1869 * This function needs one source plane holding three channels.<br>
1870 * The layout of the source image of e.g., a RGB24 image looks like this:
1871 * <pre>
1872 * source:
1873 * ----------------------------
1874 * | R G B R G B R G B R G B |
1875 * | R G B R G B R G B R G B |
1876 * | R G B R G B R G B R G B |
1877 * | R G B R G B R G B R G B |
1878 * ----------------------------
1879 * </pre>
1880 *
1881 * The layout of the target image of e.g., a R_G_B24 image looks like this:
1882 * <pre>
1883 * target0: target1: target2:
1884 * --------- --------- ---------
1885 * | R R R R | | G G G G | | B B B B |
1886 * | R R R R | | G G G G | | B B B B |
1887 * | R R R R | | G G G G | | B B B B |
1888 * | R R R R | | G G G G | | B B B B |
1889 * --------- --------- ---------
1890 * </pre>
1891 *
1892 * The layout of the options parameters is as follows:
1893 * <pre>
1894 * options[0] uint32_t: sourcePlanePaddingElements
1895 * options[1] uint32_t: targetPlane0PaddingElements
1896 * options[2] uint32_t: targetPlane1PaddingElements
1897 * options[3] uint32_t: targetPlane2PaddingElements
1898 *
1899 * with transformation:
1900 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1901 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1902 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1903 * </pre>
1904 * @param sources The one pointer to the source image, must be valid
1905 * @param targets The pointer to the first, second, and third memory block of the target image, must be valid
1906 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
1907 * @param width The width of the frame in pixel, with range [1, infinity)
1908 * @param height The height of the frame in pixel, with range [1, infinity)
1909 * @param conversionFlag The conversion to be applied
1910 * @param options The 4 options parameters: 4 padding parameters, with ranges [0, infinity), must be valid
1911 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
1912 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
1913 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
1914 */
1915 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
1916 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);
1917
1918 /**
1919 * 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.
1920 * 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>
1921 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1922 * <pre>
1923 * source0: source1:
1924 * --------- ---------
1925 * | Y Y Y Y | | U V U V |
1926 * | Y Y Y Y | | U V U V |
1927 * | Y Y Y Y | ---------
1928 * | Y Y Y Y |
1929 * ---------
1930 * </pre>
1931 *
1932 * The layout of the target image of e.g., an YUV24 image looks like this:
1933 * <pre>
1934 * target:
1935 * ----------------------------
1936 * | Y U V Y U V Y U V Y U V |
1937 * | Y U V Y U V Y U V Y U V |
1938 * | Y U V Y U V Y U V Y U V |
1939 * | Y U V Y U V Y U V Y U V |
1940 * ----------------------------
1941 * </pre>
1942 *
1943 * The layout of the options parameters is as follows:
1944 * <pre>
1945 * options[0] uint32_t: sourcePlane0PaddingElements
1946 * options[1] uint32_t: sourcePlane1PaddingElements
1947 * options[2] uint32_t: targetPlanePaddingElements
1948 *
1949 * with transformation:
1950 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1951 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1952 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1953 * </pre>
1954 * @param sources The pointer to the first and second memory block of the source image, must be valid
1955 * @param targets The one pointer to the target image, must be valid
1956 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
1957 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1958 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1959 * @param conversionFlag The conversion to be applied
1960 * @param options The 3 options parameters: 3 padding parameters, with ranges [0, infinity), must be valid
1961 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
1962 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
1963 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
1964 */
1965 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
1966 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);
1967
1968 /**
1969 * 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.
1970 * 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>
1971 * The layout of the source image of e.g., an Y_UV12 image looks like this:
1972 * <pre>
1973 * source0: source1:
1974 * --------- ---------
1975 * | Y Y Y Y | | U V U V |
1976 * | Y Y Y Y | | U V U V |
1977 * | Y Y Y Y | ---------
1978 * | Y Y Y Y |
1979 * ---------
1980 * </pre>
1981 *
1982 * The layout of the options parameters is as follows:
1983 * <pre>
1984 * options[0] uint32_t: sourcePlanePaddingElements
1985 * options[1] uint32_t: sourceZippedPaddingElements
1986 * options[2] uint32_t: targetZippedPaddingElements
1987 *
1988 * with transformation:
1989 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
1990 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
1991 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
1992 * </pre>
1993 * @param sources The pointer to the first and second memory block of the source image, must be valid
1994 * @param targets The one pointer to the target image, must be valid
1995 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
1996 * @param width The width of the frame in pixel, with range [2, infinity), must be even
1997 * @param height The height of the frame in pixel, with range [2, infinity), must be even
1998 * @param conversionFlag The conversion to be applied
1999 * @param options The 3 options parameters: 3 padding parameters, with ranges [0, infinity), must be valid
2000 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, 2]
2001 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, 2]
2002 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, 2]
2003 */
2004 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2005 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);
2006
2007 /**
2008 * 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.
2009 * 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>
2010 * 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>
2011 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2012 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2013 * <pre>
2014 * source0: source1: source2:
2015 * --------- ----- -----
2016 * | Y Y Y Y | | U U | | V V |
2017 * | Y Y Y Y | | U U | | V V |
2018 * | Y Y Y Y | ----- -----
2019 * | Y Y Y Y |
2020 * ---------
2021 * </pre>
2022 *
2023 * The layout of the options parameters is as follows:
2024 * <pre>
2025 * options[ 0] uint32_t: sourcePlane0PaddingElements
2026 * options[ 1] uint32_t: sourcePlane1PaddingElements
2027 * options[ 2] uint32_t: sourcePlane2PaddingElements
2028 * options[ 3] uint32_t: targetZippedPaddingElements
2029 *
2030 * options[ 4] int32_t: f00
2031 * options[ 5] int32_t: f10
2032 * options[ 6] int32_t: f20
2033 * options[ 7] int32_t: f01
2034 * options[ ] ...
2035 * options[12] int32_t: f22
2036 *
2037 * options[13] int32_t: b0
2038 * options[14] int32_t: b1
2039 * options[15] int32_t: b2
2040 *
2041 * with transformation:
2042 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2043 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2044 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2045 * </pre>
2046 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2047 * @param targets The one pointer to the target image, must be valid
2048 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2049 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2050 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2051 * @param conversionFlag The conversion to be applied
2052 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2053 */
2054 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);
2055
2056 /**
2057 * 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.
2058 * 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>
2059 * 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>
2060 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2061 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2062 * <pre>
2063 * source0: source1: source2:
2064 * --------- ----- -----
2065 * | Y Y Y Y | | U U | | V V |
2066 * | Y Y Y Y | | U U | | V V |
2067 * | Y Y Y Y | ----- -----
2068 * | Y Y Y Y |
2069 * ---------
2070 * </pre>
2071 *
2072 * The layout of the options parameters is as follows:
2073 * <pre>
2074 * options[ 0] uint32_t: sourcePlane0PaddingElements
2075 * options[ 1] uint32_t: sourcePlane1PaddingElements
2076 * options[ 2] uint32_t: sourcePlane2PaddingElements
2077 * options[ 3] uint32_t: targetZippedPaddingElements
2078 *
2079 * options[ 4] int32_t: f00
2080 * options[ 5] int32_t: f10
2081 * options[ 6] int32_t: f20
2082 * options[ 7] int32_t: f01
2083 * options[ ] ...
2084 * options[12] int32_t: f22
2085 *
2086 * options[13] int32_t: b0
2087 * options[14] int32_t: b1
2088 * options[15] int32_t: b2
2089 *
2090 * with transformation:
2091 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2092 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2093 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2094 * </pre>
2095 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2096 * @param targets The one pointer to the target image, must be valid
2097 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
2098 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2099 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2100 * @param conversionFlag The conversion to be applied
2101 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2102 */
2103 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);
2104
2105 /**
2106 * 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.
2107 * 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>
2108 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2109 * <pre>
2110 * source0: source1: source2:
2111 * --------- ----- -----
2112 * | Y Y Y Y | | U U | | V V |
2113 * | Y Y Y Y | | U U | | V V |
2114 * | Y Y Y Y | ----- -----
2115 * | Y Y Y Y |
2116 * ---------
2117 * </pre>
2118 *
2119 * The layout of the options parameters is as follows:
2120 * <pre>
2121 * options[0] uint32_t: sourcePlane0PaddingElements
2122 * options[1] uint32_t: sourcePlane1PaddingElements
2123 * options[2] uint32_t: sourcePlane2PaddingElements
2124 * options[3] uint32_t: targetZippedPaddingElements
2125 *
2126 * with transformation:
2127 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2128 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2129 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2130 * </pre>
2131 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2132 * @param targets The one pointer to the target image, must be valid
2133 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2134 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2135 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2136 * @param conversionFlag The conversion to be applied
2137 * @param options The 4 options parameters: 4 padding parameters, must be valid
2138 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2139 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2140 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2141 * @see mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel().
2142 */
2143 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2144 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);
2145
2146 /**
2147 * 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.
2148 * 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>
2149 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2150 * <pre>
2151 * source0: source1: source2:
2152 * --------- ----- -----
2153 * | Y Y Y Y | | U U | | V V |
2154 * | Y Y Y Y | | U U | | V V |
2155 * | Y Y Y Y | ----- -----
2156 * | Y Y Y Y |
2157 * ---------
2158 * </pre>
2159 *
2160 * The layout of the options parameters is as follows:
2161 * <pre>
2162 * options[0] uint32_t: sourcePlane0PaddingElements
2163 * options[1] uint32_t: sourcePlane1PaddingElements
2164 * options[2] uint32_t: sourcePlane2PaddingElements
2165 * options[3] uint32_t: targetZippedPaddingElements
2166 *
2167 * with transformation:
2168 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2169 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2170 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2171 * </pre>
2172 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2173 * @param targets The one pointer to the target image, must be valid
2174 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
2175 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2176 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2177 * @param conversionFlag The conversion to be applied
2178 * @param options The 4 options parameters: 4 padding parameters, must be valid
2179 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2180 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2181 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2182 * @see mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel().
2183 */
2184 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2185 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);
2186
2187 /**
2188 * 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.
2189 * This function is mainly the reverse conversion function of mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel().<br>
2190 * The layout of the options parameters is as follows:
2191 * <pre>
2192 * options[0] uint32_t: sourceZippedPaddingElements
2193 * options[1] uint32_t: targetPlane0PaddingElements
2194 * options[2] uint32_t: targetPlane1PaddingElements
2195 * options[3] uint32_t: targetPlane2PaddingElements
2196 *
2197 * with transformation:
2198 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2199 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2200 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2201 * </pre>
2202 * @param sources The one pointer to the source image, must be valid
2203 * @param targets The pointer to the first, second, and third memory block of the target image, must be valid
2204 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height / 2 - 1]
2205 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2206 * @param height The height of the frame in pixel, with range [2, infinity), must be even
2207 * @param conversionFlag The conversion to be applied
2208 * @param options The 4 options parameters: 4 padding parameters, must be valid
2209 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2210 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2211 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2212 * @see mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel().
2213 */
2214 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2215 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);
2216
2217 /**
2218 * 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.
2219 * This function needs three source planes/blocks with three individual channels.
2220 * 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>
2221 * 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>
2222 * The layout of the options parameters is as follows:
2223 * <pre>
2224 * options[ 0] uint32_t: sourcePlane0PaddingElements
2225 * options[ 1] uint32_t: sourcePlane1PaddingElements
2226 * options[ 2] uint32_t: sourcePlane2PaddingElements
2227 * options[ 3] uint32_t: targetZippedPaddingElements
2228 *
2229 * options[ 4] int32_t: f00
2230 * options[ 5] int32_t: f10
2231 * options[ 6] int32_t: f20
2232 * options[ 7] int32_t: f01
2233 * options[ ] ...
2234 * options[12] int32_t: f22
2235 *
2236 * options[13] int32_t: b0, with range [0, 128]
2237 * options[14] int32_t: b1, with range [0, 128]
2238 * options[15] int32_t: b2, with range [0, 128]
2239 *
2240 * with transformation:
2241 * sb0 = s0 - b0 // source adjusted with bias
2242 * sb1 = s1 - b1
2243 * sb2 = s2 - b2
2244 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2245 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2246 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2247 * </pre>
2248 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2249 * @param targets The one pointer to the target image, must be valid
2250 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2251 * @param width The width of the frame in pixel, with range [1, infinity)
2252 * @param height The height of the frame in pixel, with range [1, infinity)
2253 * @param conversionFlag The conversion to be applied
2254 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2255 */
2256 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);
2257
2258 /**
2259 * 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.
2260 * This function needs three source planes/blocks with three individual channels.
2261 * 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>
2262 * 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>
2263 * The layout of the options parameters is as follows:
2264 * <pre>
2265 * options[ 0] uint32_t: sourcePlane0PaddingElements
2266 * options[ 1] uint32_t: sourcePlane1PaddingElements
2267 * options[ 2] uint32_t: sourcePlane2PaddingElements
2268 * options[ 3] uint32_t: targetZippedPaddingElements
2269 *
2270 * options[ 4] int32_t: f00
2271 * options[ 5] int32_t: f10
2272 * options[ 6] int32_t: f20
2273 * options[ 7] int32_t: f01
2274 * options[ ] ...
2275 * options[12] int32_t: f22
2276 *
2277 * options[13] int32_t: b0, with range [0, 128]
2278 * options[14] int32_t: b1, with range [0, 128]
2279 * options[15] int32_t: b2, with range [0, 128]
2280 *
2281 * options[16] int32_t: channelValue3, with range [0, 255]
2282 *
2283 * with transformation:
2284 * sb0 = s0 - b0 // source adjusted with bias
2285 * sb1 = s1 - b1
2286 * sb2 = s2 - b2
2287 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2288 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2289 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2290 * t3 = channelValue3
2291 * </pre>
2292 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2293 * @param targets The one pointer to the target image, must be valid
2294 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2295 * @param width The width of the frame in pixel, with range [1, infinity)
2296 * @param height The height of the frame in pixel, with range [1, infinity)
2297 * @param conversionFlag The conversion to be applied
2298 * @param options The 17 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, one constant channel value, must be valid
2299 */
2300 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);
2301
2302 /**
2303 * 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.
2304 * 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>
2305 * 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>
2306 * 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>
2307 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2308 * <pre>
2309 * source0: source1: source2:
2310 * --------- ----- -----
2311 * | Y Y Y Y | | U U | | V V |
2312 * | Y Y Y Y | | U U | | V V |
2313 * | Y Y Y Y | ----- -----
2314 * | Y Y Y Y |
2315 * ---------
2316 * </pre>
2317 * The layout of the options parameters is as follows:
2318 * <pre>
2319 * options[ 0] uint32_t: sourcePlane0PaddingElements
2320 * options[ 1] uint32_t: sourcePlane1PaddingElements
2321 * options[ 2] uint32_t: sourcePlane2PaddingElements
2322 * options[ 3] uint32_t: targetZippedPaddingElements
2323 *
2324 * options[ 4] int32_t: f00
2325 * options[ 5] int32_t: f10
2326 * options[ 6] int32_t: f20
2327 * options[ 7] int32_t: f01
2328 * options[ ] ...
2329 * options[12] int32_t: f22
2330 *
2331 * options[13] int32_t: b0, with range [0, 128]
2332 * options[14] int32_t: b1, with range [0, 128]
2333 * options[15] int32_t: b2, with range [0, 128]
2334 *
2335 * options[16] int32_t: channelValue3
2336 *
2337 * with transformation:
2338 * sb0 = s0 - b0 // source adjusted with bias
2339 * sb1 = s1 - b1
2340 * sb2 = s2 - b2
2341 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2342 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2343 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2344 * t3 = channelValue3
2345 * </pre>
2346 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2347 * @param targets The one pointer to the target image, must be valid
2348 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2349 * @param width The width of the frame in pixel, with range [1, infinity)
2350 * @param height The height of the frame in pixel, with range [1, infinity)
2351 * @param conversionFlag The conversion to be applied
2352 * @param options The 17 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, one constant channel value, must be valid
2353 */
2354 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);
2355
2356 /**
2357 * 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.
2358 * 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>
2359 * 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>
2360 * 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>
2361 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2362 * <pre>
2363 * source0: source1: source2:
2364 * --------- ----- -----
2365 * | Y Y Y Y | | U U | | V V |
2366 * | Y Y Y Y | | U U | | V V |
2367 * | Y Y Y Y | ----- -----
2368 * | Y Y Y Y |
2369 * ---------
2370 *
2371 * The layout of the target image of e.g., a RGB24 image looks like this:
2372 * <pre>
2373 * target:
2374 * ----------------------------
2375 * | R G B R G B R G B R G B |
2376 * | R G B R G B R G B R G B |
2377 * | R G B R G B R G B R G B |
2378 * | R G B R G B R G B R G B |
2379 * ----------------------------
2380 * </pre>
2381 *
2382 * </pre>
2383 * The layout of the options parameters is as follows:
2384 * <pre>
2385 * options[ 0] uint32_t: sourcePlane0PaddingElements
2386 * options[ 1] uint32_t: sourcePlane1PaddingElements
2387 * options[ 2] uint32_t: sourcePlane2PaddingElements
2388 * options[ 3] uint32_t: targetPlanePaddingElements
2389 *
2390 * options[ 4] int32_t: f00
2391 * options[ 5] int32_t: f10
2392 * options[ 6] int32_t: f20
2393 * options[ 7] int32_t: f01
2394 * options[ ] ...
2395 * options[12] int32_t: f22
2396 *
2397 * options[13] int32_t: b0, with range [0, 128]
2398 * options[14] int32_t: b1, with range [0, 128]
2399 * options[15] int32_t: b2, with range [0, 128]
2400 *
2401 * with transformation:
2402 * sb0 = s0 - b0 // source adjusted with bias
2403 * sb1 = s1 - b1
2404 * sb2 = s2 - b2
2405 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2406 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2407 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2408 * </pre>
2409 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2410 * @param targets The one pointer to the target image, must be valid
2411 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2412 * @param width The width of the frame in pixel, with range [1, infinity)
2413 * @param height The height of the frame in pixel, with range [2, infinity)
2414 * @param conversionFlag The conversion to be applied
2415 * @param options The 16 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2416 */
2417 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);
2418
2419 /**
2420 * 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.
2421 * 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>
2422 * 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>
2423 * 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>
2424 * The layout of the source image of e.g., an Y_U_V12 image looks like this:
2425 * <pre>
2426 * source0: source1: source2:
2427 * --------- ----- -----
2428 * | Y Y Y Y | | U U | | V V |
2429 * | Y Y Y Y | | U U | | V V |
2430 * | Y Y Y Y | ----- -----
2431 * | Y Y Y Y |
2432 * ---------
2433 *
2434 * The layout of the target image of e.g., a RGBA32 image looks like this:
2435 * <pre>
2436 * target:
2437 * ------------------------------------
2438 * | R G B A R G B A R G B A R G B A |
2439 * | R G B A R G B A R G B A R G B A |
2440 * | R G B A R G B A R G B A R G B A |
2441 * | R G B A R G B A R G B A R G B A |
2442 * ------------------------------------
2443 * </pre>
2444 *
2445 * </pre>
2446 * The layout of the options parameters is as follows:
2447 * <pre>
2448 * options[ 0] uint32_t: sourcePlane0PaddingElements
2449 * options[ 1] uint32_t: sourcePlane1PaddingElements
2450 * options[ 2] uint32_t: sourcePlane2PaddingElements
2451 * options[ 3] uint32_t: targetPlanePaddingElements
2452 *
2453 * options[ 4] int32_t: f00
2454 * options[ 5] int32_t: f10
2455 * options[ 6] int32_t: f20
2456 * options[ 7] int32_t: f01
2457 * options[ ] ...
2458 * options[12] int32_t: f22
2459 *
2460 * options[13] int32_t: b0, with range [0, 128]
2461 * options[14] int32_t: b1, with range [0, 128]
2462 * options[15] int32_t: b2, with range [0, 128]
2463 *
2464 * options[16] int32_t: channelValue3, with range [0, 255]
2465 *
2466 * with transformation:
2467 * sb0 = s0 - b0 // source adjusted with bias
2468 * sb1 = s1 - b1
2469 * sb2 = s2 - b2
2470 * t0 = clamp(0, (f00 * sb0 + f01 * sb1 + f02 * sb2) / 64, 255)
2471 * t1 = clamp(0, (f10 * sb0 + f11 * sb1 + f12 * sb2) / 64, 255)
2472 * t2 = clamp(0, (f20 * sb0 + f21 * sb1 + f22 * sb2) / 64, 255)
2473 * t3 = channelValue3
2474 * </pre>
2475 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2476 * @param targets The one pointer to the target image, must be valid
2477 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2478 * @param width The width of the frame in pixel, with range [1, infinity)
2479 * @param height The height of the frame in pixel, with range [2, infinity)
2480 * @param conversionFlag The conversion to be applied
2481 * @param options The 17 options parameters: 4 padding parameters, 9 multiplication parameters, and 3 bias parameters, one constant channel value, must be valid
2482 */
2483 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);
2484
2485 /**
2486 * 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.
2487 * 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>
2488 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2489 * The layout of the options parameters is as follows:
2490 * <pre>
2491 * options[ 0] uint32_t: sourcePaddingElements
2492 * options[ 1] uint32_t: targetPaddingElements
2493 *
2494 * options[ 2] int32_t: f00
2495 * options[ 3] int32_t: f10
2496 * options[ 4] int32_t: f20
2497 * options[ 5] int32_t: f01
2498 * options[ ] ...
2499 * options[10] int32_t: f22
2500 *
2501 * options[11] int32_t: b0
2502 * options[12] int32_t: b1
2503 * options[13] int32_t: b2
2504 *
2505 * with transformation:
2506 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2507 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2508 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2509 * </pre>
2510 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2511 * @param targets The one pointer to the target image, must be valid
2512 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2513 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2514 * @param height The height of the frame in pixel, with range [1, infinity), must be even
2515 * @param conversionFlag The conversion to be applied
2516 * @param options The 14 options parameters: 2 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2517 */
2518 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);
2519
2520 /**
2521 * 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.
2522 * 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>
2523 * Note: The bias values (b0-b2) are added AFTER the division by 1024.<br>
2524 * The layout of the options parameters is as follows:
2525 * <pre>
2526 * options[ 0] uint32_t: sourcePaddingElements
2527 * options[ 1] uint32_t: targetPaddingElements
2528 *
2529 * options[ 2] int32_t: f00
2530 * options[ 3] int32_t: f10
2531 * options[ 4] int32_t: f20
2532 * options[ 5] int32_t: f01
2533 * options[ ] ...
2534 * options[10] int32_t: f22
2535 *
2536 * options[11] int32_t: b0
2537 * options[12] int32_t: b1
2538 * options[13] int32_t: b2
2539 *
2540 * with transformation:
2541 * t0 = clamp(0, (f00 * s0 + f01 * s1 + f02 * s2) / 1024 + b0, 255)
2542 * t1 = clamp(0, (f10 * s0 + f11 * s1 + f12 * s2) / 1024 + b1, 255)
2543 * t2 = clamp(0, (f20 * s0 + f21 * s1 + f22 * s2) / 1024 + b2, 255)
2544 * </pre>
2545 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2546 * @param targets The one pointer to the target image, must be valid
2547 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2548 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2549 * @param height The height of the frame in pixel, with range [1, infinity), must be even
2550 * @param conversionFlag The conversion to be applied
2551 * @param options The 14 options parameters: 2 padding parameters, 9 multiplication parameters, and 3 bias parameters, must be valid
2552 */
2553 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);
2554
2555 /**
2556 * Converts one row of a single-channel image to another single-channel image with 6-bit precision.
2557 * This function supports grayscale range conversions (e.g., Y8_LIMITED_RANGE [16, 235] ↔ Y8_FULL_RANGE [0, 255]).
2558 * 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>
2559 * The layout of the options parameters is as follows:
2560 * <pre>
2561 * options[0] uint32_t: sourcePaddingElements
2562 * options[1] uint32_t: targetPaddingElements
2563 *
2564 * options[2] int32_t: factor (pre-multiplied by 64)
2565 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2566 * options[4] int32_t: biasOutput (added to output after division)
2567 *
2568 * with transformation:
2569 * t = clamp(0, ((s - biasInput) * factor) / 64 + biasOutput, 255)
2570 * </pre>
2571 * @param sources The pointer to the source plane, must be valid
2572 * @param targets The pointer to the target plane, must be valid
2573 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2574 * @param width The width of the frame in pixel, with range [1, infinity)
2575 * @param height The height of the frame in pixel, with range [1, infinity)
2576 * @param conversionFlag The conversion to be applied
2577 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2578 */
2579 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);
2580
2581 /**
2582 * Converts one row of a single-channel image to another single-channel image with 10-bit precision.
2583 * This function supports grayscale range conversions (e.g., Y8_LIMITED_RANGE [16, 235] ↔ Y8_FULL_RANGE [0, 255]).
2584 * 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>
2585 * The layout of the options parameters is as follows:
2586 * <pre>
2587 * options[0] uint32_t: sourcePaddingElements
2588 * options[1] uint32_t: targetPaddingElements
2589 *
2590 * options[2] int32_t: factor (pre-multiplied by 1024)
2591 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2592 * options[4] int32_t: biasOutput (added to output after division)
2593 *
2594 * with transformation:
2595 * t = clamp(0, ((s - biasInput) * factor) / 1024 + biasOutput, 255)
2596 * </pre>
2597 * @param sources The pointer to the source plane, must be valid
2598 * @param targets The pointer to the target plane, must be valid
2599 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2600 * @param width The width of the frame in pixel, with range [1, infinity)
2601 * @param height The height of the frame in pixel, with range [1, infinity)
2602 * @param conversionFlag The conversion to be applied
2603 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2604 */
2605 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);
2606
2607 /**
2608 * Converts one row of a single-channel image to a 3-channel image with 10-bit precision and range conversion.
2609 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGB24 [0, 255].
2610 * This function uses fixed-point arithmetic with 10 fractional bits and replicates the converted value to all 3 channels.<br>
2611 * The layout of the options parameters is as follows:
2612 * <pre>
2613 * options[0] uint32_t: sourcePaddingElements
2614 * options[1] uint32_t: targetPaddingElements
2615 *
2616 * options[2] int32_t: factor (pre-multiplied by 1024)
2617 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2618 * options[4] int32_t: biasOutput (added to output after division)
2619 *
2620 * with transformation:
2621 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 1024 + biasOutput, 255)
2622 *
2623 * Example for Y8_LIMITED_RANGE [16, 235] → RGB24 [0, 255]:
2624 * factor = 1192 (255/219 * 1024), biasInput = 16, biasOutput = 0
2625 * </pre>
2626 * @param sources The pointer to the source plane, must be valid
2627 * @param targets The pointer to the target plane, must be valid
2628 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2629 * @param width The width of the frame in pixel, with range [1, infinity)
2630 * @param height The height of the frame in pixel, with range [1, infinity)
2631 * @param conversionFlag The conversion to be applied
2632 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2633 */
2634 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);
2635
2636 /**
2637 * Converts one row of a single-channel image to a 3-channel image with 6-bit precision and range conversion.
2638 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGB24 [0, 255].
2639 * This function uses fixed-point arithmetic with 6 fractional bits and replicates the converted value to all 3 channels.<br>
2640 * The layout of the options parameters is as follows:
2641 * <pre>
2642 * options[0] uint32_t: sourcePaddingElements
2643 * options[1] uint32_t: targetPaddingElements
2644 *
2645 * options[2] int32_t: factor (pre-multiplied by 64)
2646 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2647 * options[4] int32_t: biasOutput (added to output after division)
2648 *
2649 * with transformation:
2650 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 64 + biasOutput, 255)
2651 *
2652 * Example for Y8_LIMITED_RANGE [16, 235] → RGB24 [0, 255]:
2653 * factor = 75 (255/219 * 64), biasInput = 16, biasOutput = 0
2654 * </pre>
2655 * @param sources The pointer to the source plane, must be valid
2656 * @param targets The pointer to the target plane, must be valid
2657 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2658 * @param width The width of the frame in pixel, with range [1, infinity)
2659 * @param height The height of the frame in pixel, with range [1, infinity)
2660 * @param conversionFlag The conversion to be applied
2661 * @param options The 5 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, must be valid
2662 */
2663 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);
2664
2665 /**
2666 * Converts one row of a single-channel image to a 4-channel image with 10-bit precision and range conversion.
2667 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGBA32 [0, 255].
2668 * This function uses fixed-point arithmetic with 10 fractional bits and replicates the converted value to first 3 channels, with a constant alpha.<br>
2669 * The layout of the options parameters is as follows:
2670 * <pre>
2671 * options[0] uint32_t: sourcePaddingElements
2672 * options[1] uint32_t: targetPaddingElements
2673 *
2674 * options[2] int32_t: factor (pre-multiplied by 1024)
2675 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2676 * options[4] int32_t: biasOutput (added to output after division)
2677 * options[5] int32_t: alphaValue (constant value for alpha channel)
2678 *
2679 * with transformation:
2680 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 1024 + biasOutput, 255)
2681 * t3 = alphaValue
2682 *
2683 * Example for Y8_LIMITED_RANGE [16, 235] → RGBA32 [0, 255]:
2684 * factor = 1192 (255/219 * 1024), biasInput = 16, biasOutput = 0, alphaValue = 255
2685 * </pre>
2686 * @param sources The pointer to the source plane, must be valid
2687 * @param targets The pointer to the target plane, must be valid
2688 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2689 * @param width The width of the frame in pixel, with range [1, infinity)
2690 * @param height The height of the frame in pixel, with range [1, infinity)
2691 * @param conversionFlag The conversion to be applied
2692 * @param options The 6 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, 1 alpha value, must be valid
2693 */
2694 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);
2695
2696 /**
2697 * Converts one row of a single-channel image to a 4-channel image with 6-bit precision and range conversion.
2698 * This function supports conversions like Y8_LIMITED_RANGE [16, 235] to RGBA32 [0, 255].
2699 * This function uses fixed-point arithmetic with 6 fractional bits and replicates the converted value to first 3 channels, with a constant alpha.<br>
2700 * The layout of the options parameters is as follows:
2701 * <pre>
2702 * options[0] uint32_t: sourcePaddingElements
2703 * options[1] uint32_t: targetPaddingElements
2704 *
2705 * options[2] int32_t: factor (pre-multiplied by 64)
2706 * options[3] int32_t: biasInput (subtracted from input before multiplication)
2707 * options[4] int32_t: biasOutput (added to output after division)
2708 * options[5] int32_t: alphaValue (constant value for alpha channel)
2709 *
2710 * with transformation:
2711 * t0 = t1 = t2 = clamp(0, ((s - biasInput) * factor) / 64 + biasOutput, 255)
2712 * t3 = alphaValue
2713 *
2714 * Example for Y8_LIMITED_RANGE [16, 235] → RGBA32 [0, 255]:
2715 * factor = 75 (255/219 * 64), biasInput = 16, biasOutput = 0, alphaValue = 255
2716 * </pre>
2717 * @param sources The pointer to the source plane, must be valid
2718 * @param targets The pointer to the target plane, must be valid
2719 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2720 * @param width The width of the frame in pixel, with range [1, infinity)
2721 * @param height The height of the frame in pixel, with range [1, infinity)
2722 * @param conversionFlag The conversion to be applied
2723 * @param options The 6 options parameters: 2 padding parameters, 1 factor, 2 bias parameters, 1 alpha value, must be valid
2724 */
2725 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);
2726
2727 /**
2728 * 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.
2729 * The layout of the options parameters is as follows:
2730 * <pre>
2731 * options[0] uint32_t: sourcePaddingElements
2732 * options[1] uint32_t: targetPaddingElements
2733 *
2734 * with transformation:
2735 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2736 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2737 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2738 * </pre>
2739 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2740 * @param targets The one pointer to the target image, must be valid
2741 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2742 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2743 * @param height The height of the frame in pixel, with range [1, infinity)
2744 * @param conversionFlag The conversion to be applied
2745 * @param options The 2 options parameters: 2 padding parameters, must be valid
2746 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2747 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2748 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2749 * @see mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel().
2750 */
2751 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2752 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);
2753
2754 /**
2755 * 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.
2756 * The layout of the options parameters is as follows:
2757 * <pre>
2758 * options[0] uint32_t: sourcePaddingElements
2759 * options[1] uint32_t: targetPaddingElements
2760 *
2761 * with transformation:
2762 * t0 = tSourceChannelIndex0 == 0 ? s0, or tSourceChannelIndex0 == 1 ? s1, or tSourceChannelIndex0 == 2 ? s2
2763 * t1 = tSourceChannelIndex1 == 0 ? s0, or tSourceChannelIndex1 == 1 ? s1, or tSourceChannelIndex1 == 2 ? s2
2764 * t2 = tSourceChannelIndex2 == 0 ? s0, or tSourceChannelIndex2 == 1 ? s1, or tSourceChannelIndex2 == 2 ? s2
2765 * </pre>
2766 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2767 * @param targets The one pointer to the target image, must be valid
2768 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2769 * @param width The width of the frame in pixel, with range [2, infinity), must be even
2770 * @param height The height of the frame in pixel, with range [1, infinity)
2771 * @param conversionFlag The conversion to be applied
2772 * @param options The 2 options parameters: 2 padding parameters, must be valid
2773 * @tparam tSourceChannelIndex0 The index of the source channels which will be mapped to the first target channel, with range [0, infinity)
2774 * @tparam tSourceChannelIndex1 The index of the source channels which will be mapped to the second target channel, with range [0, infinity)
2775 * @tparam tSourceChannelIndex2 The index of the source channels which will be mapped to the third target channel, with range [0, infinity)
2776 */
2777 template <unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
2778 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);
2779
2780 /**
2781 * 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.
2782 * The layout of the options parameters is as follows:
2783 * <pre>
2784 * options[0] uint32_t: sourcePaddingElements
2785 * options[1] uint32_t: targetPaddingElements
2786 * </pre>
2787 * @param sources The one pointer to the source image with Bayer mosaic, must be valid
2788 * @param targets The one pointer to the target image, must be valid
2789 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2790 * @param width The width of the frame in pixel, with range [4, infinity), must be a multiple of 4
2791 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
2792 * @param conversionFlag The conversion to be applied
2793 * @param options The 2 options parameters: 2 padding parameters
2794 * @tparam tIndexRed The index of red channel in the target image, with range [0, 2]
2795 * @tparam tIndexGreen The index of green channel in the target image, with range [0, 2]
2796 * @tparam tIndexBlue The index of blue channel in the target image, with range [0, 2]
2797 */
2798 template <unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
2799 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);
2800
2801 /**
2802 * 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.
2803 * The layout of the options parameters is as follows:
2804 * <pre>
2805 * options[0] uint32_t: sourcePaddingElements
2806 * options[1] uint32_t: targetPaddingElements
2807 * </pre>
2808 * @param sources The one pointer to the source image with Bayer mosaic, must be valid
2809 * @param targets The one pointer to the target image, must be valid
2810 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2811 * @param width The width of the frame in pixel, with range [4, infinity), must be a multiple of 4
2812 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
2813 * @param conversionFlag The conversion to be applied
2814 * @param options The 2 options parameters: 2 padding parameters
2815 * @tparam tIndexRed The index of red channel in the target image, with range [0, 2]
2816 * @tparam tIndexGreen The index of green channel in the target image, with range [0, 2]
2817 * @tparam tIndexBlue The index of blue channel in the target image, with range [0, 2]
2818 */
2819 template <unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
2820 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);
2821
2822 /**
2823 * 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
2824 * The layout of the parameters, `options`, is defined in the struct `RGGB10ToRGB24AdvancedOptions`.
2825 * @param sources The pointer to the first, second, and third memory block of the source image, must be valid
2826 * @param targets The one pointer to the target image, must be valid
2827 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height/2 - 1]
2828 * @param width The width of the frame in pixel, with range [4, infinity), must be a multiple of 4
2829 * @param height The height of the frame in pixel, with range [2, infinity), must be a multiple of 2
2830 * @param conversionFlag The conversion to be applied
2831 * @param options The 2 options parameters: 2 padding parameters
2832 * @tparam tIndexRed The index of red channel in the target image, with range [0, 2]
2833 * @tparam tIndexGreen The index of green channel in the target image, with range [0, 2]
2834 * @tparam tIndexBlue The index of blue channel in the target image, with range [0, 2]
2835 */
2836 template <unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
2837 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);
2838
2839 /**
2840 * Maps one row of a 1-plane, 2-channel image to two planes with 1 channels.
2841 * @param sources The pointer to the plane of the source image, must be valid
2842 * @param targets The pointer to the first and second plane of the target image, must be valid
2843 * @param multipleRowIndex The index of the multiple-row to be handled, with range [0, height - 1]
2844 * @param width The width of the frame in pixel, with range [1, infinity)
2845 * @param height The height of the frame in pixel, with range [1, infinity)
2846 * @param conversionFlag The conversion to be applied
2847 * @param options The 3 options parameters: 3 padding parameters
2848 */
2849 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);
2850
2851 /**
2852 * Unpacks 5 elements from a row in a packed Bayer mosaic to 4 pixels values
2853 * The required memory layout of the input: `A B C D X ...`
2854 * Bytes marked as `X` store two bits for each of the previous four elements: `X = AABB CCDD`.
2855 * The memory layout of the output will be: `A B C D` (16 bits per element but only the lowest 10 bits are used)
2856 * This function is compatible with pixel formats like `FrameType::FORMAT_RGGB10_PACKED` or `FrameType::FORMAT_Y10_PACKED`.
2857 * @param packed The packed 5 elements, must be valid
2858 * @param unpacked The resulting 4 unpacked elements, must be valid
2859 */
2860 static OCEAN_FORCE_INLINE void unpack5ElementsBayerMosaicPacked10Bit(const uint8_t* const packed, uint16_t* unpacked);
2861
2862#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
2863
2864 /**
2865 * Unpacks 15 elements from a row in a packed Bayer mosaic to 12 pixels values
2866 * The required memory layout of the input: `A B C D X A B C D X A B C D X A ...`
2867 * Bytes marked as `X` store two bits for each of the previous four elements: `X = AABB CCDD`.
2868 * 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)
2869 * This function is compatible with pixel formats like `FrameType::FORMAT_RGGB10_PACKED` or `FrameType::FORMAT_Y10_PACKED`.
2870 * @param packed The packed 15 elements, must be valid
2871 * @param unpackedAB_u_16x8 The resulting first 8 uint16_t values
2872 * @param unpackedC_u_16x4 The resulting last 4 uint16_t values
2873 * @tparam tAllowLastOverlappingElement True, to allow reading 16 elements from `packed` (if the memory is large enough); False, to force reading only 15 elements
2874 */
2875 template <bool tAllowLastOverlappingElement>
2876 static OCEAN_FORCE_INLINE void unpack15ElementsBayerMosaicPacked10BitNEON(const uint8_t* const packed, uint16x8_t& unpackedAB_u_16x8, uint16x4_t& unpackedC_u_16x4);
2877
2878#endif // OCEAN_HARDWARE_NEON_VERSION
2879};
2880
2881inline FrameConverter::Options::Options(const bool allowApproximation)
2882{
2884 {
2886 }
2887}
2888
2889inline FrameConverter::Options::Options(const uint8_t alphaChannelTargetValue, const bool allowApproximation) :
2890 optionsType_(OT_ALPHA_CHANNEL_TARGET_VALUE),
2891 alphaChannelTargetValue_(alphaChannelTargetValue)
2892{
2894 {
2896 }
2897}
2898
2899inline FrameConverter::Options::Options(const float gamma, const bool allowApproximation) :
2900 optionsType_(OT_GAMMA_CORRECTION),
2901 gamma_(gamma)
2902{
2903 ocean_assert(gamma_ >= 0.0f && gamma_ <= 2.0f);
2904
2906 {
2908 }
2909}
2910
2911inline FrameConverter::Options::Options(const uint16_t blackLevel, const float whiteBalanceRed, const float whiteBalanceGreen, const float whiteBalanceBlue, const float gamma, const bool allowApproximation) :
2912 optionsType_(OT_BLACKLEVEL_WHITEBALANCE_GAMMA),
2913 gamma_(gamma),
2914 blackLevel_(blackLevel)
2915{
2916 ocean_assert(blackLevel_ < 1024u);
2917 ocean_assert(whiteBalanceRed >= 0.0f && whiteBalanceGreen >= 0.0f && whiteBalanceBlue >= 0.0f);
2918 ocean_assert(gamma_ >= 0.0f);
2919
2920 whiteBalance_[0] = whiteBalanceRed;
2921 whiteBalance_[1] = whiteBalanceGreen;
2922 whiteBalance_[2] = whiteBalanceBlue;
2923
2925 {
2927 }
2928}
2929
2931{
2932 return optionsType_;
2933}
2934
2936{
2937 ocean_assert(optionsType_ & OT_ALPHA_CHANNEL_TARGET_VALUE);
2938 return alphaChannelTargetValue_;
2939}
2940
2942{
2943 ocean_assert((optionsType_ & OT_GAMMA_CORRECTION) || (optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA));
2944 return gamma_;
2945}
2946
2948{
2949 ocean_assert(optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA);
2950 return blackLevel_;
2951}
2952
2953inline const float* FrameConverter::Options::whiteBalance() const
2954{
2955 ocean_assert(optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA);
2956 return whiteBalance_;
2957}
2958
2960{
2961 return (optionsType_ & OT_APPROXIMATED) == OT_APPROXIMATED;
2962}
2963
2965{
2966 return size_t(conversionTriple.sourcePixelFormat_ ^ (conversionTriple.targetPixelFormat_ << uint64_t(1u)) ^ (uint64_t(conversionTriple.optionsType_) << uint64_t(2u)));
2967}
2968
2970 sourcePixelFormat_(sourcePixelFormat),
2971 targetPixelFormat_(targetPixelFormat),
2972 optionsType_(optionsType)
2973{
2974 // nothing to do here
2975}
2976
2978{
2979 return sourcePixelFormat_ == conversionTriple.sourcePixelFormat_ && targetPixelFormat_ == conversionTriple.targetPixelFormat_ && optionsType_ == conversionTriple.optionsType_;
2980}
2981
2982inline bool FrameConverter::Comfort::convert(const Frame& source, const FrameType::PixelFormat targetPixelFormat, Frame& target, const bool forceCopy, Worker* worker, const Options& options)
2983{
2984 return convert(source, targetPixelFormat, source.pixelOrigin(), target, forceCopy, worker, options);
2985}
2986
2987inline bool FrameConverter::Comfort::convert(const Frame& source, const FrameType::PixelOrigin targetPixelOrigin, Frame& target, const bool forceCopy, Worker* worker, const Options& options)
2988{
2989 return convert(source, source.pixelFormat(), targetPixelOrigin, target, forceCopy, worker, options);
2990}
2991
2992inline bool FrameConverter::Comfort::change(Frame& frame, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy, Worker* worker, const Options& options)
2993{
2994 ocean_assert(frame.isValid());
2995 ocean_assert(targetPixelFormat != FrameType::FORMAT_UNDEFINED && targetPixelOrigin != FrameType::ORIGIN_INVALID);
2996
2997 if (!frame.isValid())
2998 {
2999 return false;
3000 }
3001
3002 if (frame.pixelFormat() == targetPixelFormat && frame.pixelOrigin() == targetPixelOrigin)
3003 {
3004 return true;
3005 }
3006
3007 Frame tmpFrame;
3008 if (!convert(frame, targetPixelFormat, targetPixelOrigin, tmpFrame, forceCopy, worker, options))
3009 {
3010 return false;
3011 }
3012
3013 // if the intermediate frame could be created without copying the frame data we have to copy the frame data instead
3014 if (frame.isOwner() && !tmpFrame.isOwner())
3015 {
3016 frame.copy(tmpFrame);
3017 }
3018 else
3019 {
3020 frame = std::move(tmpFrame);
3021 }
3022
3023 return true;
3024}
3025
3026inline bool FrameConverter::Comfort::change(Frame& frame, const FrameType::PixelFormat targetPixelFormat, const bool forceCopy, Worker* worker, const Options& options)
3027{
3028 return change(frame, targetPixelFormat, frame.pixelOrigin(), forceCopy, worker, options);
3029}
3030
3031inline bool FrameConverter::Comfort::change(Frame& frame, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy, Worker* worker, const Options& options)
3032{
3033 return change(frame, frame.pixelFormat(), targetPixelOrigin, forceCopy, worker, options);
3034}
3035
3036OCEAN_RE_ENABLE_DOCUMENTATION_DIAGNOSTIC
3037
3038template <typename TSource, typename TTarget>
3039void 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)
3040{
3041 ocean_assert(source != nullptr && target != nullptr);
3042 ocean_assert(width != 0u && height != 0u);
3043 ocean_assert(channels != 0u);
3044
3045 // we will have a small performance benefit when applying as less as possible non-16-block iterations
3046 // thus, we distinguish between an execution with and without padding values
3047
3048 if (sourcePaddingElements == 0u && targetPaddingElements == 0u)
3049 {
3050 if (std::is_same<TSource, TTarget>::value)
3051 {
3052 memcpy(target, source, size_t(width * height * channels) * sizeof(TSource));
3053 }
3054 else
3055 {
3056 const unsigned int elementsPerFrame = width * height * channels;
3057 const unsigned int blocksPerFrame_16 = elementsPerFrame / 16u;
3058
3059 const unsigned int remainingElementsPerFrame = elementsPerFrame - blocksPerFrame_16 * 16u;
3060
3061 for (unsigned int n = 0u; n < blocksPerFrame_16; ++n)
3062 {
3063 cast16Elements<TSource, TTarget>(source, target);
3064
3065 source += 16;
3066 target += 16;
3067 }
3068
3069 for (unsigned int i = 0u; i < remainingElementsPerFrame; ++i)
3070 {
3071 target[i] = TTarget(source[i]);
3072 }
3073 }
3074 }
3075 else
3076 {
3077 if (std::is_same<TSource, TTarget>::value)
3078 {
3079 const unsigned int sourceStrideElements = width * channels + sourcePaddingElements;
3080 const unsigned int targetStrideElements = width * channels + targetPaddingElements;
3081
3082 const size_t bytesPerRowToCopy = size_t(width * channels) * sizeof(TSource);
3083
3084 for (unsigned int y = 0u; y < height; ++y)
3085 {
3086 memcpy(target, source, bytesPerRowToCopy);
3087
3088 source += sourceStrideElements;
3089 target += targetStrideElements;
3090 }
3091 }
3092 else
3093 {
3094 const unsigned int elementsPerRow = width * channels;
3095 const unsigned int blocksPerRow_16 = elementsPerRow / 16u;
3096
3097 const unsigned int remainingElementsPerRow = elementsPerRow - blocksPerRow_16 * 16u;
3098
3099 for (unsigned int y = 0u; y < height; ++y)
3100 {
3101 for (unsigned int x = 0u; x < blocksPerRow_16; ++x)
3102 {
3103 cast16Elements<TSource, TTarget>(source, target);
3104
3105 source += 16;
3106 target += 16;
3107 }
3108
3109 for (unsigned int i = 0u; i < remainingElementsPerRow; ++i)
3110 {
3111 target[i] = TTarget(source[i]);
3112 }
3113
3114 source += remainingElementsPerRow + sourcePaddingElements;
3115 target += remainingElementsPerRow + targetPaddingElements;
3116 }
3117 }
3118 }
3119}
3120
3121template <typename TSource, typename TTarget>
3122void 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)
3123{
3124 ocean_assert(source != nullptr && target != nullptr);
3125 ocean_assert(width != 0u && height != 0u);
3126 ocean_assert(channels != 0u);
3127
3128 // we will have a small performance benefit when applying as little as possible non-16-block iterations
3129 // thus, we distinguish between an execution with and without padding values
3130
3131 if (sourcePaddingElements == 0u && targetPaddingElements == 0u)
3132 {
3133 const unsigned int elementsPerFrame = width * height * channels;
3134 const unsigned int blocksPerFrame_16 = elementsPerFrame / 16u;
3135
3136 const unsigned int remainingElementsPerFrame = elementsPerFrame - blocksPerFrame_16 * 16u;
3137
3138 for (unsigned int n = 0u; n < blocksPerFrame_16; ++n)
3139 {
3140 for (unsigned int i = 0u; i < 16u; ++i)
3141 {
3142 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3143 }
3144
3145 source += 16;
3146 target += 16;
3147 }
3148
3149 for (unsigned int i = 0u; i < remainingElementsPerFrame; ++i)
3150 {
3151 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3152 }
3153 }
3154 else
3155 {
3156 const unsigned int elementsPerRow = width * channels;
3157 const unsigned int blocksPerRow_16 = elementsPerRow / 16u;
3158
3159 const unsigned int remainingElementsPerRow = elementsPerRow - blocksPerRow_16 * 16u;
3160
3161 for (unsigned int y = 0u; y < height; ++y)
3162 {
3163 for (unsigned int n = 0u; n < blocksPerRow_16; ++n)
3164 {
3165 for (unsigned int i = 0u; i < 16u; ++i)
3166 {
3167 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3168 }
3169
3170 source += 16;
3171 target += 16;
3172 }
3173
3174 for (unsigned int i = 0u; i < remainingElementsPerRow; ++i)
3175 {
3176 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3177 }
3178
3179 source += remainingElementsPerRow + sourcePaddingElements;
3180 target += remainingElementsPerRow + targetPaddingElements;
3181 }
3182 }
3183}
3184
3185#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3186
3187template <>
3188OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, float>(const uint8_t* const source, float* const target)
3189{
3190 const uint8x16_t source_8x16 = vld1q_u8(source);
3191
3192 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3193 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3194
3195 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3196 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3197 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3198 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3199
3200 const float32x4_t target_32x4_0 = vcvtq_f32_u32(source_32x4_0);
3201 const float32x4_t target_32x4_1 = vcvtq_f32_u32(source_32x4_1);
3202 const float32x4_t target_32x4_2 = vcvtq_f32_u32(source_32x4_2);
3203 const float32x4_t target_32x4_3 = vcvtq_f32_u32(source_32x4_3);
3204
3205 vst1q_f32(target + 0, target_32x4_0);
3206 vst1q_f32(target + 4, target_32x4_1);
3207 vst1q_f32(target + 8, target_32x4_2);
3208 vst1q_f32(target + 12, target_32x4_3);
3209}
3210
3211template <>
3212OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, uint16_t>(const uint8_t* const source, uint16_t* const target)
3213{
3214 const uint8x16_t source_8x16 = vld1q_u8(source);
3215
3216 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3217 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3218
3219 vst1q_u16(target + 0, source_16x8_0);
3220 vst1q_u16(target + 8, source_16x8_1);
3221}
3222
3223template <>
3224OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, int16_t>(const uint8_t* const source, int16_t* const target)
3225{
3226 const uint8x16_t source_8x16 = vld1q_u8(source);
3227
3228 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3229 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3230
3231 vst1q_s16(target + 0, vreinterpretq_s16_u16(source_16x8_0));
3232 vst1q_s16(target + 8, vreinterpretq_s16_u16(source_16x8_1));
3233}
3234
3235template <>
3236OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, uint32_t>(const uint8_t* const source, uint32_t* const target)
3237{
3238 const uint8x16_t source_8x16 = vld1q_u8(source);
3239
3240 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3241 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3242
3243 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3244 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3245 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3246 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3247
3248 vst1q_u32(target + 0, source_32x4_0);
3249 vst1q_u32(target + 4, source_32x4_1);
3250 vst1q_u32(target + 8, source_32x4_2);
3251 vst1q_u32(target + 12, source_32x4_3);
3252}
3253
3254template <>
3255OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<uint8_t, int32_t>(const uint8_t* const source, int32_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_s32(target + 0, vreinterpretq_s32_u32(source_32x4_0));
3268 vst1q_s32(target + 4, vreinterpretq_s32_u32(source_32x4_1));
3269 vst1q_s32(target + 8, vreinterpretq_s32_u32(source_32x4_2));
3270 vst1q_s32(target + 12, vreinterpretq_s32_u32(source_32x4_3));
3271}
3272
3273template <>
3274OCEAN_FORCE_INLINE void FrameConverter::cast16Elements<float, uint8_t>(const float* const source, uint8_t* const target)
3275{
3276 const float32x4_t source_32x4_0 = vld1q_f32(source + 0);
3277 const float32x4_t source_32x4_1 = vld1q_f32(source + 4);
3278 const float32x4_t source_32x4_2 = vld1q_f32(source + 8);
3279 const float32x4_t source_32x4_3 = vld1q_f32(source + 12);
3280
3281 const uint32x4_t target_32x4_0 = vcvtq_u32_f32(source_32x4_0);
3282 const uint32x4_t target_32x4_1 = vcvtq_u32_f32(source_32x4_1);
3283 const uint32x4_t target_32x4_2 = vcvtq_u32_f32(source_32x4_2);
3284 const uint32x4_t target_32x4_3 = vcvtq_u32_f32(source_32x4_3);
3285
3286 const uint16x8_t target_16x8_0 = vcombine_u16(vmovn_u32(target_32x4_0), vmovn_u32(target_32x4_1));
3287 const uint16x8_t target_16x8_1 = vcombine_u16(vmovn_u32(target_32x4_2), vmovn_u32(target_32x4_3));
3288
3289 const uint8x16_t target_8x16 = vcombine_u8(vmovn_u16(target_16x8_0), vmovn_u16(target_16x8_1));
3290
3291 vst1q_u8(target, target_8x16);
3292}
3293
3294#endif // #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3295
3296template <typename TSource, typename TTarget>
3297OCEAN_FORCE_INLINE void FrameConverter::cast16Elements(const TSource* const source, TTarget* const target)
3298{
3299 for (unsigned int i = 0u; i < 16u; ++i)
3300 {
3301 target[i] = TTarget(source[i]);
3302 }
3303}
3304
3305template <typename T>
3306bool 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)
3307{
3308 ocean_assert(source != nullptr && target != nullptr);
3309
3310 if (sourceLeft + width > sourceWidth || sourceTop + height > sourceHeight || targetLeft + width > targetWidth || targetTop + height > targetHeight)
3311 {
3312 return false;
3313 }
3314
3315 const unsigned int sourceStrideElements = sourceWidth * channels + sourcePaddingElements;
3316 const unsigned int targetStrideElements = targetWidth * channels + targetPaddingElements;
3317
3318 const T* subSource = source + sourceStrideElements * sourceTop + sourceLeft * channels;
3319 T* subTarget = target + targetStrideElements * targetTop + targetLeft * channels;
3320
3321 if (sourcePaddingElements == 0u && targetPaddingElements == 0u && width == sourceWidth && sourceWidth == targetWidth)
3322 {
3323 memcpy(subTarget, subSource, height * width * channels * sizeof(T));
3324 }
3325 else
3326 {
3327 for (unsigned int y = 0u; y < height; ++y)
3328 {
3329 memcpy(subTarget, subSource, width * channels * sizeof(T));
3330
3331 subTarget += targetStrideElements;
3332 subSource += sourceStrideElements;
3333 }
3334 }
3335
3336 return true;
3337}
3338
3339template <typename T>
3340bool 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)
3341{
3342 if (subFrameWidth == 0u || subFrameHeight == 0u)
3343 {
3344 return true;
3345 }
3346
3347 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)
3348 {
3349 ocean_assert(false && "Invalid input");
3350 return false;
3351 }
3352
3353 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);
3354}
3355
3356template <typename T>
3357bool 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)
3358{
3359 ocean_assert(source != nullptr && target != nullptr && mask != nullptr);
3360
3361 if (sourceLeft + subFrameWidth > sourceWidth || sourceTop + subFrameHeight > sourceHeight || targetLeft + subFrameWidth > targetWidth || targetTop + subFrameHeight > targetHeight)
3362 {
3363 ocean_assert(false && "Invalid input");
3364 return false;
3365 }
3366
3367 const unsigned int maskStrideElements = subFrameWidth + maskPaddingElements;
3368
3369 const unsigned int sourceStrideElements = sourceWidth * channels + sourcePaddingElements;
3370 const unsigned int targetStrideElements = targetWidth * channels + targetPaddingElements;
3371
3372 for (unsigned int y = 0u; y < subFrameHeight; ++y)
3373 {
3374 const uint8_t* maskRow = mask + maskStrideElements * y;
3375
3376 const T* subSource = source + sourceStrideElements * (sourceTop + y) + sourceLeft * channels;
3377 T* subTarget = target + targetStrideElements * (targetTop + y) + targetLeft * channels;
3378
3379 for (unsigned int x = 0u; x < subFrameWidth; ++x)
3380 {
3381 if (*maskRow == maskValue)
3382 {
3383 for (unsigned int c = 0u; c < channels; ++c)
3384 {
3385 subTarget[c] = subSource[c];
3386 }
3387 }
3388
3389 maskRow++;
3390
3391 subSource += channels;
3392 subTarget += channels;
3393 }
3394 }
3395
3396 return true;
3397}
3398
3399template <typename T>
3400void 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)
3401{
3402 ocean_assert(source != nullptr && buffer != nullptr);
3403 ocean_assert(width >= patchSize && channels >= 1u);
3404
3405 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
3406 const unsigned int patchSize_2 = patchSize / 2u;
3407
3408 ocean_assert(x >= patchSize_2 && y >= patchSize_2);
3409 ocean_assert(x + patchSize_2 < width);
3410
3411 const unsigned int sourceStrideElements = width * channels + sourcePaddingElements;
3412 const unsigned int bufferStrideElements = patchSize * channels + bufferPaddingElements;
3413
3414 const unsigned int sourceLeft = x - patchSize_2;
3415 const unsigned int sourceTop = y - patchSize_2;
3416
3417 source += sourceTop * sourceStrideElements + sourceLeft * channels;
3418
3419 for (unsigned int row = 0u; row < patchSize; ++row)
3420 {
3421 memcpy(buffer, source, channels * patchSize * sizeof(T));
3422
3423 source += sourceStrideElements;
3424 buffer += bufferStrideElements;
3425 }
3426}
3427
3428template <typename T, unsigned int tChannels>
3429void 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)
3430{
3431 static_assert(tChannels >= 1u, "Invalid number of color channels!");
3432
3433 ocean_assert(source != nullptr && buffer != nullptr);
3434
3435 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
3436 const unsigned int patchSize_2 = patchSize / 2u;
3437
3438 const unsigned int widthPatchSize1 = width - (patchSize - 1u);
3439 ocean_assert(widthPatchSize1 == width - patchSize_2 * 2u);
3440
3441 ocean_assert(width >= patchSize_2 + 1u && height >= patchSize_2 + 1u);
3442
3443 ocean_assert(x < width && y < height);
3444
3445 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
3446
3447 for (int top = int(y - patchSize_2); top <= int(y + patchSize_2); ++top)
3448 {
3449 const T* sourceRow = source + CVUtilities::mirrorIndex(top, height) * int(sourceStrideElements);
3450
3451 for (int left = int(x - patchSize_2); left <= int(x + patchSize_2); ++left)
3452 {
3453 if ((unsigned int)(left) - patchSize_2 < widthPatchSize1)
3454 {
3455 ocean_assert(left >= int(patchSize_2) && left < int(width - patchSize_2));
3456
3457 const T* sourcePixel = sourceRow + left * tChannels;
3458
3459 for (unsigned int n = 0u; n < tChannels; ++n)
3460 {
3461 buffer[n] = sourcePixel[n];
3462 }
3463 }
3464 else
3465 {
3466 ocean_assert((unsigned int)(left) <= patchSize_2 || (unsigned int)(left) >= width - patchSize_2);
3467
3468 const T* sourcePixel = sourceRow + CVUtilities::mirrorIndex(left, width) * tChannels;
3469
3470 for (unsigned int n = 0u; n < tChannels; ++n)
3471 {
3472 buffer[n] = sourcePixel[n];
3473 }
3474 }
3475
3476 buffer += tChannels;
3477 }
3478
3479 buffer += bufferPaddingElements;
3480 }
3481}
3482
3483template <typename TSource, typename TTarget>
3484inline 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)
3485{
3486 ocean_assert(source != nullptr && target != nullptr);
3487 ocean_assert(width >= 1u && height >= 1u);
3488 ocean_assert(sourceStrideElements >= width && targetStrideElements >= width);
3489 ocean_assert(rowConversionFunction != nullptr);
3490 ocean_assert(flag == CONVERT_NORMAL || flag == CONVERT_FLIPPED || targetReversePixelOrderInPlaceFunction != nullptr);
3491
3492 // the internal subset conversion function needs bytes instead of elements
3493
3494 const unsigned int sourceStrideBytes = sourceStrideElements * sizeof(TSource);
3495 const unsigned int targetStrideBytes = targetStrideElements * sizeof(TTarget);
3496
3497 if (worker && height >= 200u)
3498 {
3499 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);
3500 }
3501 else
3502 {
3503 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);
3504 }
3505}
3506
3507inline 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)
3508{
3509 ocean_assert(multipleRowsPerIteration != 0u && height % multipleRowsPerIteration == 0u);
3510
3511 const unsigned int rowIterations = height / multipleRowsPerIteration;
3512
3513 if (worker && rowIterations >= 200u)
3514 {
3515 worker->executeFunction(Worker::Function::createStatic(&FrameConverter::convertArbitraryPixelFormatSubset, sources, targets, width, height, flag, multipleRowsPerIteration, multipleRowsConversionFunction, options, 0u, 0u), 0u, rowIterations, 8u, 9u, 20u);
3516 }
3517 else
3518 {
3519 convertArbitraryPixelFormatSubset(sources, targets, width, height, flag, multipleRowsPerIteration, multipleRowsConversionFunction, options, 0u, rowIterations);
3520 }
3521}
3522
3523OCEAN_FORCE_INLINE void FrameConverter::unpack5ElementsBayerMosaicPacked10Bit(const uint8_t* const packed, uint16_t* unpacked)
3524{
3525 ocean_assert(packed != nullptr);
3526 ocean_assert(unpacked != nullptr);
3527
3528 unpacked[0] = uint16_t(uint16_t(packed[0]) << uint16_t(2) | (uint16_t(packed[4]) & uint16_t(0b00000011)));
3529 unpacked[1] = uint16_t(uint16_t(packed[1]) << uint16_t(2) | ((uint16_t(packed[4]) & uint16_t(0b00001100)) >> uint16_t(2)));
3530 unpacked[2] = uint16_t(uint16_t(packed[2]) << uint16_t(2) | ((uint16_t(packed[4]) & uint16_t(0b00110000)) >> uint16_t(4)));
3531 unpacked[3] = uint16_t(uint16_t(packed[3]) << uint16_t(2) | (uint16_t(packed[4]) >> uint16_t(6)));
3532}
3533
3534#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3535
3536template <bool tAllowLastOverlappingElement>
3537OCEAN_FORCE_INLINE void FrameConverter::unpack15ElementsBayerMosaicPacked10BitNEON(const uint8_t* const packed, uint16x8_t& unpackedAB_u_16x8, uint16x4_t& unpackedC_u_16x4)
3538{
3539 constexpr uint8x8_t shuffleC_u_8x8 = NEON::create_uint8x8(6u, 2u, 6u, 3u, 6u, 4u, 6u, 5u);
3540
3541 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);
3542 constexpr int16x8_t rightShifts_s_16x8 = NEON::create_int16x8(-6, -6, -6, -6, -6, -6, -6, -6);
3543
3544 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
3545
3546 // F E D C B A 9 8 7 6 5 4 3 2 1 0
3547 // 8 9 7 9 6 9 5 9 3 4 2 4 1 4 0 4
3548
3549#ifdef __aarch64__
3550 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);
3551 const uint8x16_t intermediateAB_u_8x16 = vqtbl1q_u8(packed_u_8x16, shuffle_u_8x16);
3552#else
3553 const uint8x8_t packedA_u_8x8 = vget_low_u8(packed_u_8x16);
3554 const uint8x8_t packedB_u_8x8 = vget_low_u8(vextq_u8(packed_u_8x16, packed_u_8x16, 5));
3555
3556 constexpr uint8x8_t shuffleAB_u_8x8 = NEON::create_uint8x8(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u);
3557 const uint8x16_t intermediateAB_u_8x16 = vcombine_u8(vtbl1_u8(packedA_u_8x8, shuffleAB_u_8x8), vtbl1_u8(packedB_u_8x8, shuffleAB_u_8x8));
3558#endif // __aarch64__
3559
3560
3561 // 7 6 5 4 3 2 1 0
3562 // 5 6 4 6 3 6 2 6
3563 const uint8x8_t intermediateC_u_8x8 = vtbl1_u8(vget_high_u8(packed_u_8x16), shuffleC_u_8x8);
3564
3565
3566 // ... XXXXXX99 33333333 44XXXXXX 22222222 XX44XXXX 11111111 XXXX44XX 00000000 XXXXXX44
3567 // ... 99------ 33333333 44------ 22222222 44------ 11111111 44------ 00000000 44------
3568 const uint16x8_t intermediateAB_u_16x8 = vreinterpretq_u16_u8(vshlq_u8(intermediateAB_u_8x16, leftShifts_s_8x16));
3569
3570 const uint16x4_t intermediateC_u_16x4 = vreinterpret_u16_u8(vshl_u8(intermediateC_u_8x8, vget_low_u8(leftShifts_s_8x16)));
3571
3572
3573 // ... 99------ 33333333 44------ 22222222 44------ 11111111 44------ 00000000 44------
3574 // ... 55555599 ------33 33333344 ------22 22222244 ------11 11111144 ------00 00000044
3575 unpackedAB_u_16x8 = vshlq_u16(intermediateAB_u_16x8, rightShifts_s_16x8);
3576
3577 unpackedC_u_16x4 = vshl_u16(intermediateC_u_16x4, vget_low_u8(rightShifts_s_16x8));
3578}
3579
3580#endif // OCEAN_HARDWARE_NEON_VERSION
3581
3582}
3583
3584}
3585
3586#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:2992
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:2977
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:2941
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:2930
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:2935
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:2881
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:2947
const float * whiteBalance() const
Returns the white balance values for a conversion with white balance correction.
Definition FrameConverter.h:2953
bool allowApproximation() const
Returns whether the conversion can be approximated.
Definition FrameConverter.h:2959
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:3523
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:3122
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:3400
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:3340
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:3484
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:3537
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:3306
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:3429
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:3507
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:1879
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:4332
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition Frame.h:4323
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4612
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:4455
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:4206
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:3241
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition Frame.h:3286
uint32_t numberPlanes() const
Returns the number of planes of the pixel format of this frame.
Definition Frame.h:3281
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition Frame.h:3251
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1046
@ ORIGIN_INVALID
Invalid origin type.
Definition Frame.h:1048
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3246
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3271
DataType dataType() const
Returns the data type of the pixel format of this frame.
Definition Frame.h:3261
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:2964
Definition of the parameters used by the function for row-wise conversion of RGGB14_PACKED to RGB24/B...
Definition FrameConverter.h:610