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