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