8#ifndef META_OCEAN_CV_FRAME_CONVERTER_H
9#define META_OCEAN_CV_FRAME_CONVERTER_H
26OCEAN_DISABLE_DOCUMENTATION_DIAGNOSTIC
83 CONVERT_FLIPPED_AND_MIRRORED
97 CP_AVOID_COPY_IF_POSSIBLE =
false,
117 OT_ALPHA_CHANNEL_TARGET_VALUE = 1u << 0u,
119 OT_GAMMA_CORRECTION = 1u << 1u,
121 OT_BLACKLEVEL_WHITEBALANCE_GAMMA = 1u << 2u,
123 OT_APPROXIMATED = 1u << 2u,
132 explicit inline Options(
const bool allowApproximation =
false);
139 explicit inline Options(
const uint8_t alphaChannelTargetValue,
const bool allowApproximation =
false);
146 explicit inline Options(
const float gamma,
const bool allowApproximation =
false);
158 explicit inline Options(
const uint16_t blackLevel,
const float whiteBalanceRed,
const float whiteBalanceGreen,
const float whiteBalanceBlue,
const float gamma,
const bool allowApproximation =
false);
164 inline OptionsType optionsType()
const;
170 inline uint8_t alphaChannelTargetValue()
const;
176 inline float gamma()
const;
182 inline uint16_t blackLevel()
const;
188 inline const float* whiteBalance()
const;
194 inline bool allowApproximation()
const;
202 uint8_t alphaChannelTargetValue_ = 0xFFu;
208 uint16_t blackLevel_ = 0u;
211 float whiteBalance_[3] = { 1.0f, 1.0f, 1.0f };
267 FT_3_UINT8_TO_3_UINT8
273 template <
typename TSource,
typename TTarget>
279 template <
typename TSource,
typename TTarget>
285 template <
typename TSource,
typename TTarget>
291 template <
typename TSource,
typename TTarget>
292 using OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction = void(*)(
const TSource* source, TTarget* target,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint16_t blackLevelValue,
const float* whiteBalanceValues,
const float gamma,
const uint32_t sourcePaddingElements,
const uint32_t targetPaddingElements,
Worker* worker);
297 template <
typename TSource,
typename TTarget>
298 using OneSourceTwoTargetsConversionFunction = void(*)(
const TSource* source, TTarget* target0, TTarget* target1,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t sourcePaddingElements,
const uint32_t target0PaddingElements,
const uint32_t target1PaddingElements,
Worker* worker);
303 template <
typename TSource,
typename TTarget>
304 using OneSourceThreeTargetsConversionFunction = void(*)(
const TSource* source, TTarget* target0, TTarget* target1, TTarget* target2,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t sourcePaddingElements,
const uint32_t target0PaddingElements,
const uint32_t target1PaddingElements,
const uint32_t target2PaddingElements,
Worker* worker);
309 template <
typename TSource,
typename TTarget>
310 using TwoSourcesOneTargetConversionFunction = void(*)(
const TSource* source0,
const TSource* source1, TTarget* target,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t source0PaddingElements,
const uint32_t source1PaddingElements,
const uint32_t targetPaddingElements,
Worker* worker);
315 template <
typename TSource,
typename TTarget>
316 using TwoSourcesOneTargetAlphaConversionFunction = void(*)(
const TSource* source0,
const TSource* source1, TTarget* target,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t source0PaddingElements,
const uint32_t source1PaddingElements,
const uint32_t targetPaddingElements,
const uint8_t alphaValue,
Worker* worker);
321 template <
typename TSource,
typename TTarget>
322 using TwoSourcesTwoTargetConversionFunction = void(*)(
const TSource* source0,
const TSource* source1, TTarget* target0, TTarget* target1,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t source0PaddingElements,
const uint32_t source1PaddingElements,
const uint32_t target0PaddingElements,
const uint32_t target1PaddingElements,
Worker* worker);
327 template <
typename TSource,
typename TTarget>
328 using TwoSourcesThreeTargetConversionFunction = void(*)(
const TSource* source0,
const TSource* source1, TTarget* target0, TTarget* target1, TTarget* target2,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t source0PaddingElements,
const uint32_t source1PaddingElements,
const uint32_t targetPaddingElements0,
const uint32_t targetPaddingElements1,
const uint32_t targetPaddingElements2,
Worker* worker);
333 template <
typename TSource,
typename TTarget>
334 using ThreeSourcesOneTargetConversionFunction = void(*)(
const TSource* source0,
const TSource* source1,
const TSource* source2, TTarget* target,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t source0PaddingElements,
const uint32_t source1PaddingElements,
const uint32_t source2PaddingElements,
const uint32_t targetPaddingElements,
Worker* worker);
339 template <
typename TSource,
typename TTarget>
340 using ThreeSourcesOneTargetAlphaConversionFunction = void(*)(
const TSource* source0,
const TSource* source1,
const TSource* source2, TTarget* target,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t source0PaddingElements,
const uint32_t source1PaddingElements,
const uint32_t source2PaddingElements,
const uint32_t targetPaddingElements,
const uint8_t alphaValue,
Worker* worker);
345 template <
typename TSource,
typename TTarget>
346 using ThreeSourcesThreeTargetConversionFunction = void(*)(
const TSource* source0,
const TSource* source1,
const TSource* source2, TTarget* target0, TTarget* target1, TTarget* target2,
const uint32_t width,
const uint32_t height,
const ConversionFlag conversionFlag,
const uint32_t source0PaddingElements,
const uint32_t source1PaddingElements,
const uint32_t source2PaddingElements,
const uint32_t targetPaddingElements0,
const uint32_t targetPaddingElements1,
const uint32_t targetPaddingElements2,
Worker* worker);
572 template <
typename TSource,
typename TTarget>
573 using RowConversionFunction = void (*)(
const TSource* sourceRow, TTarget* targetRow,
const size_t width,
const void* options);
585 using MultipleRowsConversionFunction = void (*)(
const void** sources,
void** targets,
const unsigned int multipleRowIndex,
const unsigned int width,
const unsigned int height,
const ConversionFlag conversionFlag,
const void* options);
594 template <
typename T>
603 template <
typename T>
612 uint16_t blackLevel = 0u;
615 unsigned int whiteBalance7[3] = { 128u, 128u, 128u };
618 const uint8_t* gammaLookupValues =
nullptr;
621 unsigned int sourcePaddingElements = 0u;
624 unsigned int targetPaddingElements = 0u;
889 template <
typename TSource,
typename TTarget>
890 static void cast(
const TSource* __restrict source, TTarget* __restrict target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements);
935 template <
typename TSource,
typename TTarget>
936 static void normalizedCast(
const TSource* __restrict source, TTarget* __restrict target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const TTarget multiplicationFactor,
const TTarget offset,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements);
959 template <
typename T>
960 static bool subFrame(
const T* source, T* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int channels,
const unsigned int sourceLeft,
const unsigned int sourceTop,
const unsigned int targetLeft,
const unsigned int targetTop,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements);
982 template <
typename T>
983 static bool subFrameMask(
const Frame& sourceFrame,
Frame& targetFrame,
const Frame& maskFrame,
const uint32_t sourceLeft,
const uint32_t sourceTop,
const uint32_t targetLeft,
const uint32_t targetTop,
const uint32_t subFrameWidth,
const uint32_t subFrameHeight,
const uint8_t maskValue = 0u);
1013 template <
typename T>
1014 static bool subFrameMask(
const T* source, T* target,
const uint8_t* mask,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int channels,
const unsigned int sourceLeft,
const unsigned int sourceTop,
const unsigned int targetLeft,
const unsigned int targetTop,
const unsigned int subFrameWidth,
const unsigned int subFrameHeight,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int maskPaddingElements,
const uint8_t maskValue = 0u);
1029 template <
typename T>
1030 static inline void patchFrame(
const T* source, T* buffer,
const unsigned int width,
const unsigned int channels,
const unsigned int x,
const unsigned int y,
const unsigned int patchSize,
const unsigned int sourcePaddingElements,
const unsigned int bufferPaddingElements);
1047 template <
typename T,
unsigned int tChannels>
1048 static void patchFrameMirroredBorder(
const T* source, T* buffer,
const unsigned int width,
const unsigned int height,
const unsigned int x,
const unsigned int y,
const unsigned int patchSize,
const unsigned int sourcePaddingElements,
const unsigned int bufferPaddingElements);
1393 template <
typename TSource,
typename TTarget>
1394 static inline void cast16Elements(
const TSource*
const source, TTarget*
const target);
1414 template <
typename TSource,
typename TTarget>
1415 static inline void convertGenericPixelFormat(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourceStrideElements,
const unsigned int targetStrideElements,
const ConversionFlag flag,
const RowConversionFunction<TSource, TTarget> rowConversionFunction,
const RowReversePixelOrderInPlaceFunction<TTarget> targetReversePixelOrderInPlaceFunction,
const bool areContinuous,
const void* options,
Worker* worker);
1430 static inline void convertArbitraryPixelFormat(
const void** sources,
void** targets,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int multipleRowsPerIteration,
const MultipleRowsConversionFunction multipleRowsConversionFunction,
const void* options,
Worker* worker);
1450 static void convertGenericPixelFormatSubset(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourceStrideBytes,
const unsigned int targetStrideBytes,
const ConversionFlag flag,
const RowConversionFunction<uint8_t, uint8_t> rowConversionFunction,
const RowReversePixelOrderInPlaceFunction<uint8_t> targetReversePixelOrderInPlaceFunction,
const bool areContinuous,
const void* options,
const unsigned int firstRow,
const unsigned int numberRows);
1883 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
1934 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
1984 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
2023 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
2162 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
2203 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
2233 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
2770 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
2796 template <
unsigned int tSourceChannelIndex0,
unsigned int tSourceChannelIndex1,
unsigned int tSourceChannelIndex2>
2817 template <
unsigned int tIndexRed,
unsigned int tIndexGreen,
unsigned int tIndexBlue>
2838 template <
unsigned int tIndexRed,
unsigned int tIndexGreen,
unsigned int tIndexBlue>
2855 template <
unsigned int tIndexRed,
unsigned int tIndexGreen,
unsigned int tIndexBlue>
2879 static OCEAN_FORCE_INLINE
void unpack5ElementsBayerMosaicPacked10Bit(
const uint8_t*
const packed, uint16_t* unpacked);
2881#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
2894 template <
bool tAllowLastOverlappingElement>
2895 static OCEAN_FORCE_INLINE
void unpack15ElementsBayerMosaicPacked10BitNEON(
const uint8_t*
const packed, uint16x8_t& unpackedAB_u_16x8, uint16x4_t& unpackedC_u_16x4);
2909 optionsType_(OT_ALPHA_CHANNEL_TARGET_VALUE),
2910 alphaChannelTargetValue_(alphaChannelTargetValue)
2919 optionsType_(OT_GAMMA_CORRECTION),
2930inline FrameConverter::Options::Options(
const uint16_t blackLevel,
const float whiteBalanceRed,
const float whiteBalanceGreen,
const float whiteBalanceBlue,
const float gamma,
const bool allowApproximation) :
2931 optionsType_(OT_BLACKLEVEL_WHITEBALANCE_GAMMA),
2933 blackLevel_(blackLevel)
2936 ocean_assert(whiteBalanceRed >= 0.0f && whiteBalanceGreen >= 0.0f && whiteBalanceBlue >= 0.0f);
2937 ocean_assert(
gamma_ >= 0.0f);
2951 return optionsType_;
2956 ocean_assert(optionsType_ & OT_ALPHA_CHANNEL_TARGET_VALUE);
2957 return alphaChannelTargetValue_;
2962 ocean_assert((optionsType_ & OT_GAMMA_CORRECTION) || (optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA));
2968 ocean_assert(optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA);
2974 ocean_assert(optionsType_ & OT_BLACKLEVEL_WHITEBALANCE_GAMMA);
2975 return whiteBalance_;
2980 return (optionsType_ & OT_APPROXIMATED) == OT_APPROXIMATED;
2989 sourcePixelFormat_(sourcePixelFormat),
2990 targetPixelFormat_(targetPixelFormat),
2991 optionsType_(optionsType)
3003 return convert(source, targetPixelFormat, source.
pixelOrigin(), target, forceCopy, worker, options);
3008 return convert(source, source.
pixelFormat(), targetPixelOrigin, target, forceCopy, worker, options);
3013 ocean_assert(frame.
isValid());
3027 if (!convert(frame, targetPixelFormat, targetPixelOrigin, tmpFrame, forceCopy, worker, options))
3035 frame.
copy(tmpFrame);
3039 frame = std::move(tmpFrame);
3047 return change(frame, targetPixelFormat, frame.
pixelOrigin(), forceCopy, worker, options);
3052 return change(frame, frame.
pixelFormat(), targetPixelOrigin, forceCopy, worker, options);
3055OCEAN_RE_ENABLE_DOCUMENTATION_DIAGNOSTIC
3057template <
typename TSource,
typename TTarget>
3058void FrameConverter::cast(
const TSource* __restrict source, TTarget* __restrict target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements)
3060 ocean_assert(source !=
nullptr && target !=
nullptr);
3061 ocean_assert(width != 0u && height != 0u);
3062 ocean_assert(channels != 0u);
3067 if (sourcePaddingElements == 0u && targetPaddingElements == 0u)
3069 if (std::is_same<TSource, TTarget>::value)
3071 memcpy(target, source,
size_t(width * height * channels) *
sizeof(TSource));
3075 const unsigned int elementsPerFrame = width * height * channels;
3076 const unsigned int blocksPerFrame_16 = elementsPerFrame / 16u;
3078 const unsigned int remainingElementsPerFrame = elementsPerFrame - blocksPerFrame_16 * 16u;
3080 for (
unsigned int n = 0u; n < blocksPerFrame_16; ++n)
3082 cast16Elements<TSource, TTarget>(source, target);
3088 for (
unsigned int i = 0u; i < remainingElementsPerFrame; ++i)
3090 target[i] = TTarget(source[i]);
3096 if (std::is_same<TSource, TTarget>::value)
3098 const unsigned int sourceStrideElements = width * channels + sourcePaddingElements;
3099 const unsigned int targetStrideElements = width * channels + targetPaddingElements;
3101 const size_t bytesPerRowToCopy =
size_t(width * channels) *
sizeof(TSource);
3103 for (
unsigned int y = 0u; y < height; ++y)
3105 memcpy(target, source, bytesPerRowToCopy);
3107 source += sourceStrideElements;
3108 target += targetStrideElements;
3113 const unsigned int elementsPerRow = width * channels;
3114 const unsigned int blocksPerRow_16 = elementsPerRow / 16u;
3116 const unsigned int remainingElementsPerRow = elementsPerRow - blocksPerRow_16 * 16u;
3118 for (
unsigned int y = 0u; y < height; ++y)
3120 for (
unsigned int x = 0u; x < blocksPerRow_16; ++x)
3122 cast16Elements<TSource, TTarget>(source, target);
3128 for (
unsigned int i = 0u; i < remainingElementsPerRow; ++i)
3130 target[i] = TTarget(source[i]);
3133 source += remainingElementsPerRow + sourcePaddingElements;
3134 target += remainingElementsPerRow + targetPaddingElements;
3140template <
typename TSource,
typename TTarget>
3141void FrameConverter::normalizedCast(
const TSource* __restrict source, TTarget* __restrict target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const TTarget multiplicationFactor,
const TTarget offset,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements)
3143 ocean_assert(source !=
nullptr && target !=
nullptr);
3144 ocean_assert(width != 0u && height != 0u);
3145 ocean_assert(channels != 0u);
3150 if (sourcePaddingElements == 0u && targetPaddingElements == 0u)
3152 const unsigned int elementsPerFrame = width * height * channels;
3153 const unsigned int blocksPerFrame_16 = elementsPerFrame / 16u;
3155 const unsigned int remainingElementsPerFrame = elementsPerFrame - blocksPerFrame_16 * 16u;
3157 for (
unsigned int n = 0u; n < blocksPerFrame_16; ++n)
3159 for (
unsigned int i = 0u; i < 16u; ++i)
3161 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3168 for (
unsigned int i = 0u; i < remainingElementsPerFrame; ++i)
3170 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3175 const unsigned int elementsPerRow = width * channels;
3176 const unsigned int blocksPerRow_16 = elementsPerRow / 16u;
3178 const unsigned int remainingElementsPerRow = elementsPerRow - blocksPerRow_16 * 16u;
3180 for (
unsigned int y = 0u; y < height; ++y)
3182 for (
unsigned int n = 0u; n < blocksPerRow_16; ++n)
3184 for (
unsigned int i = 0u; i < 16u; ++i)
3186 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3193 for (
unsigned int i = 0u; i < remainingElementsPerRow; ++i)
3195 target[i] = TTarget(source[i]) * multiplicationFactor + offset;
3198 source += remainingElementsPerRow + sourcePaddingElements;
3199 target += remainingElementsPerRow + targetPaddingElements;
3204#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3207OCEAN_FORCE_INLINE
void FrameConverter::cast16Elements<uint8_t, float>(
const uint8_t*
const source,
float*
const target)
3209 const uint8x16_t source_8x16 = vld1q_u8(source);
3211 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3212 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3214 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3215 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3216 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3217 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3219 const float32x4_t target_32x4_0 = vcvtq_f32_u32(source_32x4_0);
3220 const float32x4_t target_32x4_1 = vcvtq_f32_u32(source_32x4_1);
3221 const float32x4_t target_32x4_2 = vcvtq_f32_u32(source_32x4_2);
3222 const float32x4_t target_32x4_3 = vcvtq_f32_u32(source_32x4_3);
3224 vst1q_f32(target + 0, target_32x4_0);
3225 vst1q_f32(target + 4, target_32x4_1);
3226 vst1q_f32(target + 8, target_32x4_2);
3227 vst1q_f32(target + 12, target_32x4_3);
3231OCEAN_FORCE_INLINE
void FrameConverter::cast16Elements<uint8_t, uint16_t>(
const uint8_t*
const source, uint16_t*
const target)
3233 const uint8x16_t source_8x16 = vld1q_u8(source);
3235 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3236 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3238 vst1q_u16(target + 0, source_16x8_0);
3239 vst1q_u16(target + 8, source_16x8_1);
3243OCEAN_FORCE_INLINE
void FrameConverter::cast16Elements<uint8_t, int16_t>(
const uint8_t*
const source, int16_t*
const target)
3245 const uint8x16_t source_8x16 = vld1q_u8(source);
3247 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3248 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3250 vst1q_s16(target + 0, vreinterpretq_s16_u16(source_16x8_0));
3251 vst1q_s16(target + 8, vreinterpretq_s16_u16(source_16x8_1));
3255OCEAN_FORCE_INLINE
void FrameConverter::cast16Elements<uint8_t, uint32_t>(
const uint8_t*
const source, uint32_t*
const target)
3257 const uint8x16_t source_8x16 = vld1q_u8(source);
3259 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3260 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3262 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3263 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3264 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3265 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3267 vst1q_u32(target + 0, source_32x4_0);
3268 vst1q_u32(target + 4, source_32x4_1);
3269 vst1q_u32(target + 8, source_32x4_2);
3270 vst1q_u32(target + 12, source_32x4_3);
3274OCEAN_FORCE_INLINE
void FrameConverter::cast16Elements<uint8_t, int32_t>(
const uint8_t*
const source, int32_t*
const target)
3276 const uint8x16_t source_8x16 = vld1q_u8(source);
3278 const uint16x8_t source_16x8_0 = vmovl_u8(vget_low_u8(source_8x16));
3279 const uint16x8_t source_16x8_1 = vmovl_u8(vget_high_u8(source_8x16));
3281 const uint32x4_t source_32x4_0 = vmovl_u16(vget_low_u16(source_16x8_0));
3282 const uint32x4_t source_32x4_1 = vmovl_u16(vget_high_u16(source_16x8_0));
3283 const uint32x4_t source_32x4_2 = vmovl_u16(vget_low_u16(source_16x8_1));
3284 const uint32x4_t source_32x4_3 = vmovl_u16(vget_high_u16(source_16x8_1));
3286 vst1q_s32(target + 0, vreinterpretq_s32_u32(source_32x4_0));
3287 vst1q_s32(target + 4, vreinterpretq_s32_u32(source_32x4_1));
3288 vst1q_s32(target + 8, vreinterpretq_s32_u32(source_32x4_2));
3289 vst1q_s32(target + 12, vreinterpretq_s32_u32(source_32x4_3));
3293OCEAN_FORCE_INLINE
void FrameConverter::cast16Elements<float, uint8_t>(
const float*
const source, uint8_t*
const target)
3295 const float32x4_t source_32x4_0 = vld1q_f32(source + 0);
3296 const float32x4_t source_32x4_1 = vld1q_f32(source + 4);
3297 const float32x4_t source_32x4_2 = vld1q_f32(source + 8);
3298 const float32x4_t source_32x4_3 = vld1q_f32(source + 12);
3300 const uint32x4_t target_32x4_0 = vcvtq_u32_f32(source_32x4_0);
3301 const uint32x4_t target_32x4_1 = vcvtq_u32_f32(source_32x4_1);
3302 const uint32x4_t target_32x4_2 = vcvtq_u32_f32(source_32x4_2);
3303 const uint32x4_t target_32x4_3 = vcvtq_u32_f32(source_32x4_3);
3305 const uint16x8_t target_16x8_0 = vcombine_u16(vmovn_u32(target_32x4_0), vmovn_u32(target_32x4_1));
3306 const uint16x8_t target_16x8_1 = vcombine_u16(vmovn_u32(target_32x4_2), vmovn_u32(target_32x4_3));
3308 const uint8x16_t target_8x16 = vcombine_u8(vmovn_u16(target_16x8_0), vmovn_u16(target_16x8_1));
3310 vst1q_u8(target, target_8x16);
3315template <
typename TSource,
typename TTarget>
3318 for (
unsigned int i = 0u; i < 16u; ++i)
3320 target[i] = TTarget(source[i]);
3324template <
typename T>
3325bool FrameConverter::subFrame(
const T* source, T* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int channels,
const unsigned int sourceLeft,
const unsigned int sourceTop,
const unsigned int targetLeft,
const unsigned int targetTop,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements)
3327 ocean_assert(source !=
nullptr && target !=
nullptr);
3333 if (uint64_t(sourceLeft) + width > sourceWidth || uint64_t(sourceTop) + height > sourceHeight || uint64_t(targetLeft) + width > targetWidth || uint64_t(targetTop) + height > targetHeight)
3338 const unsigned int sourceStrideElements = sourceWidth * channels + sourcePaddingElements;
3339 const unsigned int targetStrideElements = targetWidth * channels + targetPaddingElements;
3343 const T* subSource = source +
size_t(sourceStrideElements) * sourceTop +
size_t(sourceLeft) * channels;
3344 T* subTarget = target +
size_t(targetStrideElements) * targetTop +
size_t(targetLeft) * channels;
3346 if (sourcePaddingElements == 0u && targetPaddingElements == 0u && width == sourceWidth && sourceWidth == targetWidth)
3348 memcpy(subTarget, subSource, height * width * channels *
sizeof(T));
3352 for (
unsigned int y = 0u; y < height; ++y)
3354 memcpy(subTarget, subSource, width * channels *
sizeof(T));
3356 subTarget += targetStrideElements;
3357 subSource += sourceStrideElements;
3364template <
typename T>
3365bool FrameConverter::subFrameMask(
const Frame& sourceFrame,
Frame& targetFrame,
const Frame& maskFrame,
const uint32_t sourceLeft,
const uint32_t sourceTop,
const uint32_t targetLeft,
const uint32_t targetTop,
const uint32_t subFrameWidth,
const uint32_t subFrameHeight,
const uint8_t maskValue)
3367 if (subFrameWidth == 0u || subFrameHeight == 0u)
3374 ocean_assert(
false &&
"Invalid input");
3378 return subFrameMask<T>(sourceFrame.
constdata<T>(), targetFrame.
data<T>(), maskFrame.
constdata<uint8_t>(), sourceFrame.
width(), sourceFrame.
height(), targetFrame.
width(), targetFrame.
height(), sourceFrame.
channels(), sourceLeft, sourceTop, targetLeft, targetTop, subFrameWidth, subFrameHeight, sourceFrame.
paddingElements(), targetFrame.
paddingElements(), maskFrame.
paddingElements(), maskValue);
3381template <
typename T>
3382bool FrameConverter::subFrameMask(
const T* source, T* target,
const uint8_t* mask,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int channels,
const unsigned int sourceLeft,
const unsigned int sourceTop,
const unsigned int targetLeft,
const unsigned int targetTop,
const unsigned int subFrameWidth,
const unsigned int subFrameHeight,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int maskPaddingElements,
const uint8_t maskValue)
3384 ocean_assert(source !=
nullptr && target !=
nullptr && mask !=
nullptr);
3386 if (sourceLeft + subFrameWidth > sourceWidth || sourceTop + subFrameHeight > sourceHeight || targetLeft + subFrameWidth > targetWidth || targetTop + subFrameHeight > targetHeight)
3388 ocean_assert(
false &&
"Invalid input");
3392 const unsigned int maskStrideElements = subFrameWidth + maskPaddingElements;
3394 const unsigned int sourceStrideElements = sourceWidth * channels + sourcePaddingElements;
3395 const unsigned int targetStrideElements = targetWidth * channels + targetPaddingElements;
3397 for (
unsigned int y = 0u; y < subFrameHeight; ++y)
3399 const uint8_t* maskRow = mask + maskStrideElements * y;
3401 const T* subSource = source + sourceStrideElements * (sourceTop + y) + sourceLeft * channels;
3402 T* subTarget = target + targetStrideElements * (targetTop + y) + targetLeft * channels;
3404 for (
unsigned int x = 0u; x < subFrameWidth; ++x)
3406 if (*maskRow == maskValue)
3408 for (
unsigned int c = 0u; c < channels; ++c)
3410 subTarget[c] = subSource[c];
3416 subSource += channels;
3417 subTarget += channels;
3424template <
typename T>
3425void FrameConverter::patchFrame(
const T* source, T* buffer,
const unsigned int width,
const unsigned int channels,
const unsigned int x,
const unsigned int y,
const unsigned int patchSize,
const unsigned int sourcePaddingElements,
const unsigned int bufferPaddingElements)
3427 ocean_assert(source !=
nullptr && buffer !=
nullptr);
3428 ocean_assert(width >= patchSize && channels >= 1u);
3430 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
3431 const unsigned int patchSize_2 = patchSize / 2u;
3433 ocean_assert(x >= patchSize_2 && y >= patchSize_2);
3434 ocean_assert(x + patchSize_2 < width);
3436 const unsigned int sourceStrideElements = width * channels + sourcePaddingElements;
3437 const unsigned int bufferStrideElements = patchSize * channels + bufferPaddingElements;
3439 const unsigned int sourceLeft = x - patchSize_2;
3440 const unsigned int sourceTop = y - patchSize_2;
3442 source += sourceTop * sourceStrideElements + sourceLeft * channels;
3444 for (
unsigned int row = 0u; row < patchSize; ++row)
3446 memcpy(buffer, source, channels * patchSize *
sizeof(T));
3448 source += sourceStrideElements;
3449 buffer += bufferStrideElements;
3453template <
typename T,
unsigned int tChannels>
3454void FrameConverter::patchFrameMirroredBorder(
const T* source, T* buffer,
const unsigned int width,
const unsigned int height,
const unsigned int x,
const unsigned int y,
const unsigned int patchSize,
const unsigned int sourcePaddingElements,
const unsigned int bufferPaddingElements)
3456 static_assert(tChannels >= 1u,
"Invalid number of color channels!");
3458 ocean_assert(source !=
nullptr && buffer !=
nullptr);
3460 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
3461 const unsigned int patchSize_2 = patchSize / 2u;
3463 const unsigned int widthPatchSize1 = width - (patchSize - 1u);
3464 ocean_assert(widthPatchSize1 == width - patchSize_2 * 2u);
3466 ocean_assert(width >= patchSize_2 + 1u && height >= patchSize_2 + 1u);
3468 ocean_assert(x < width && y < height);
3470 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
3472 for (
int top =
int(y - patchSize_2); top <= int(y + patchSize_2); ++top)
3476 for (
int left =
int(x - patchSize_2); left <= int(x + patchSize_2); ++left)
3478 if ((
unsigned int)(left) - patchSize_2 < widthPatchSize1)
3480 ocean_assert(left >=
int(patchSize_2) && left <
int(width - patchSize_2));
3482 const T* sourcePixel = sourceRow + left * tChannels;
3484 for (
unsigned int n = 0u; n < tChannels; ++n)
3486 buffer[n] = sourcePixel[n];
3491 ocean_assert((
unsigned int)(left) <= patchSize_2 || (
unsigned int)(left) >= width - patchSize_2);
3495 for (
unsigned int n = 0u; n < tChannels; ++n)
3497 buffer[n] = sourcePixel[n];
3501 buffer += tChannels;
3504 buffer += bufferPaddingElements;
3508template <
typename TSource,
typename TTarget>
3509inline void FrameConverter::convertGenericPixelFormat(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourceStrideElements,
const unsigned int targetStrideElements,
const ConversionFlag flag,
const RowConversionFunction<TSource, TTarget> rowConversionFunction,
const RowReversePixelOrderInPlaceFunction<TTarget> targetReversePixelOrderInPlaceFunction,
const bool areContinuous,
const void* options,
Worker* worker)
3511 ocean_assert(source !=
nullptr && target !=
nullptr);
3512 ocean_assert(width >= 1u && height >= 1u);
3513 ocean_assert(sourceStrideElements >= width && targetStrideElements >= width);
3514 ocean_assert(rowConversionFunction !=
nullptr);
3519 const unsigned int sourceStrideBytes = sourceStrideElements *
sizeof(TSource);
3520 const unsigned int targetStrideBytes = targetStrideElements *
sizeof(TTarget);
3522 if (worker && height >= 200u)
3524 worker->
executeFunction(
Worker::Function::createStatic(&
FrameConverter::convertGenericPixelFormatSubset, (
const uint8_t*)(source), (uint8_t*)(target), width, height, sourceStrideBytes, targetStrideBytes, flag, (
const RowConversionFunction<uint8_t, uint8_t>)rowConversionFunction, (
const RowReversePixelOrderInPlaceFunction<uint8_t>)targetReversePixelOrderInPlaceFunction, areContinuous, options, 0u, 0u), 0u, height, 11u, 12u, 20u);
3528 convertGenericPixelFormatSubset((
const uint8_t*)(source), (uint8_t*)(target), width, height, sourceStrideBytes, targetStrideBytes, flag, (
const RowConversionFunction<uint8_t, uint8_t>)rowConversionFunction, (
const RowReversePixelOrderInPlaceFunction<uint8_t>)targetReversePixelOrderInPlaceFunction, areContinuous, options, 0u, height);
3534 ocean_assert(multipleRowsPerIteration != 0u && height % multipleRowsPerIteration == 0u);
3536 const unsigned int rowIterations = height / multipleRowsPerIteration;
3538 if (worker && rowIterations >= 200u)
3540 worker->
executeFunction(
Worker::Function::createStatic(&
FrameConverter::convertArbitraryPixelFormatSubset, sources, targets, width, height, flag, multipleRowsPerIteration, multipleRowsConversionFunction, options, 0u, 0u), 0u, rowIterations, 8u, 9u, 20u);
3550 ocean_assert(packed !=
nullptr);
3551 ocean_assert(unpacked !=
nullptr);
3553 unpacked[0] = uint16_t(uint16_t(packed[0]) << uint16_t(2) | (uint16_t(packed[4]) & uint16_t(0b00000011)));
3554 unpacked[1] = uint16_t(uint16_t(packed[1]) << uint16_t(2) | ((uint16_t(packed[4]) & uint16_t(0b00001100)) >> uint16_t(2)));
3555 unpacked[2] = uint16_t(uint16_t(packed[2]) << uint16_t(2) | ((uint16_t(packed[4]) & uint16_t(0b00110000)) >> uint16_t(4)));
3556 unpacked[3] = uint16_t(uint16_t(packed[3]) << uint16_t(2) | (uint16_t(packed[4]) >> uint16_t(6)));
3559#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
3561template <
bool tAllowLastOverlappingElement>
3566 constexpr int8x16_t leftShifts_s_8x16 =
NEON::create_int8x16(6, 0, 4, 0, 2, 0, 0, 0, 6, 0, 4, 0, 2, 0, 0, 0);
3569 const uint8x16_t packed_u_8x16 = tAllowLastOverlappingElement ? vld1q_u8(packed) : vcombine_u8(vld1_u8(packed), vext_u8(vld1_u8(packed + 7), shuffleC_u_8x8, 1));
3575 constexpr uint8x16_t shuffle_u_8x16 =
NEON::create_uint8x16(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u, 9u, 5u, 9u, 6u, 9u, 7u, 9u, 8u);
3576 const uint8x16_t intermediateAB_u_8x16 = vqtbl1q_u8(packed_u_8x16, shuffle_u_8x16);
3578 const uint8x8_t packedA_u_8x8 = vget_low_u8(packed_u_8x16);
3579 const uint8x8_t packedB_u_8x8 = vget_low_u8(vextq_u8(packed_u_8x16, packed_u_8x16, 5));
3582 const uint8x16_t intermediateAB_u_8x16 = vcombine_u8(vtbl1_u8(packedA_u_8x8, shuffleAB_u_8x8), vtbl1_u8(packedB_u_8x8, shuffleAB_u_8x8));
3588 const uint8x8_t intermediateC_u_8x8 = vtbl1_u8(vget_high_u8(packed_u_8x16), shuffleC_u_8x8);
3593 const uint16x8_t intermediateAB_u_16x8 = vreinterpretq_u16_u8(vshlq_u8(intermediateAB_u_8x16, leftShifts_s_8x16));
3595 const uint16x4_t intermediateC_u_16x4 = vreinterpret_u16_u8(vshl_u8(intermediateC_u_8x8, vget_low_u8(leftShifts_s_8x16)));
3600 unpackedAB_u_16x8 = vshlq_u16(intermediateAB_u_16x8, rightShifts_s_16x8);
3602 unpackedC_u_16x4 = vshl_u16(intermediateC_u_16x4, vget_low_u8(rightShifts_s_16x8));
static OCEAN_FORCE_INLINE unsigned int mirrorIndex(const int index, const unsigned int elements)
Returns the mirrored index for a given index.
Definition CVUtilities.h:459
The following comfort class provides comfortable functions simplifying prototyping applications but a...
Definition FrameConverter.h:635
static bool isSupported(const FrameType &sourceType, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin=FrameType::ORIGIN_INVALID, const Options &options=Options())
Returns whether the convert function of this class supports the conversion of a frame with one pixel ...
static bool convert(const Frame &source, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, Frame &target, const bool forceCopy=true, Worker *worker=nullptr, const Options &options=Options())
Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same d...
static bool convertWithConversionFunction(const Frame &source, const FrameType &targetType, Frame &target, const Options &options, Worker *worker)
Converts frames using a registered conversion function from the ConversionFunctionMap.
static bool convertAndCopy(const Frame &source, Frame &target, Worker *worker=nullptr, const Options &options=Options())
Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same d...
static bool convertCompatibleFormats(const Frame &source, const FrameType &targetType, Frame &target, const bool forceCopy)
Converts frames with compatible formats that do not require an actual conversion, either memory is co...
static bool change(Frame &frame, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, const bool forceCopy=true, Worker *worker=nullptr, const Options &options=Options())
Converts / changes a frame with arbitrary dimension, pixel format and pixel origin into a frame with ...
Definition FrameConverter.h:3011
static bool convertGenericFormats(const Frame &source, const FrameType &targetType, Frame &target, Worker *worker)
Converts frames with generic pixel formats.
This class combines source pixel format, target pixel format, and options types.
Definition FrameConverter.h:354
bool operator==(const ConversionTriple &conversionTriple) const
Returns whether two objects are identical.
Definition FrameConverter.h:2996
FrameType::PixelFormat sourcePixelFormat_
The pixel format of the source frame, must be valid.
Definition FrameConverter.h:396
Options::OptionsType optionsType_
The type of the options for which the conversion is defined.
Definition FrameConverter.h:402
ConversionTriple()=default
Default constructor.
FrameType::PixelFormat targetPixelFormat_
The pixel format of the target frame, must be valid.
Definition FrameConverter.h:399
This class is a wrapper for function pointers.
Definition FrameConverter.h:409
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint32_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT8 function.
FunctionWrapper(const ThreeSourcesOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8_ALPHA function.
FunctionWrapper(const TwoSourcesTwoTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_2_UINT8 function.
FunctionWrapper(const OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHIT...
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint16_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT16 function.
FunctionWrapper(const ThreeSourcesOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8 function.
FunctionWrapper(const TwoSourcesOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint32_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT16 function.
FunctionWrapper(const TwoSourcesOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8_ALPHA function.
FunctionWrapper(const OneSourceGammaOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_GAMMA_TO_1_UINT8 function.
FunctionWrapper(const OneSourceOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_ALPHA function.
const FunctionType functionType_
The type of the conversion function.
Definition FrameConverter.h:528
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint16_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT8 function.
const void * function_
The function pointer of the conversion function.
Definition FrameConverter.h:525
FunctionWrapper(const ThreeSourcesThreeTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceThreeTargetsConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint8_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT16 function.
FunctionWrapper(const TwoSourcesThreeTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceTwoTargetsConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_2_UINT8 function.
This class implements a singleton-based map for function pointers of conversion functions.
Definition FrameConverter.h:220
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker *worker) OneSourceOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane ...
Definition FrameConverter.h:286
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker *worker) ThreeSourcesOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with three source planes and one target pla...
Definition FrameConverter.h:340
const void * function(const FrameType::PixelFormat &sourcePixelFormat, const FrameType::PixelFormat &targetPixelFormat, FunctionType &functionType, const Options &options) const
Returns the function pointer for a source and target pixel format.
void(*)(const TSource *source, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, const uint32_t target2PaddingElements, Worker *worker) OneSourceThreeTargetsConversionFunction
Definition of a function pointer to a conversion function with one source plane and three target plan...
Definition FrameConverter.h:304
void(*)(const TSource *source0, const TSource *source1, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker *worker) TwoSourcesThreeTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and three target pla...
Definition FrameConverter.h:328
void(*)(const TSource *source0, const TSource *source1, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, Worker *worker) TwoSourcesOneTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and one target plane...
Definition FrameConverter.h:310
void(*)(const TSource *source0, const TSource *source1, TTarget *target0, TTarget *target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker *worker) TwoSourcesTwoTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and two target plane...
Definition FrameConverter.h:322
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker *worker) ThreeSourcesThreeTargetConversionFunction
Definition of a function pointer to a conversion function with three source planes and three target p...
Definition FrameConverter.h:346
FormatPair2FunctionWrapperMap formatPair2FunctionWrapperMap_
The map mapping pairs or pixel formats to function pointers.
Definition FrameConverter.h:558
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceGammaOneTargetConversionFunction
Definition of a function pointer to a conversion function with one source plane with gamma correction...
Definition FrameConverter.h:280
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint16_t blackLevelValue, const float *whiteBalanceValues, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane ...
Definition FrameConverter.h:292
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceOneTargetConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane.
Definition FrameConverter.h:274
FunctionType
Definition of individual types of conversion functions.
Definition FrameConverter.h:229
@ FT_2_UINT8_TO_1_UINT8_ALPHA
2-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
Definition FrameConverter.h:257
@ FT_1_UINT8_TO_1_UINT8_ALPHA
1-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
Definition FrameConverter.h:237
@ FT_1_UINT8_TO_2_UINT8
1-plane uint8 to 2-plane uint8 conversion function.
Definition FrameConverter.h:251
@ FT_2_UINT8_TO_2_UINT8
2-plane uint8 to 2-plane uint8 conversion function.
Definition FrameConverter.h:259
@ FT_1_UINT32_TO_1_UINT16
1-plane uint32 to 1-plane uint16 conversion function.
Definition FrameConverter.h:249
@ FT_3_UINT8_TO_1_UINT8
3-plane uint8 to 1-plane uint8 conversion function.
Definition FrameConverter.h:263
@ FT_3_UINT8_TO_1_UINT8_ALPHA
3-plane uint8 to 1-plane uint8 with constant alpha channel conversion function.
Definition FrameConverter.h:265
@ FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHITEBALANCE_GAMMA
1-plane uint8 to 1-plane uint8 conversion function with constant black level, white balance,...
Definition FrameConverter.h:239
@ FT_2_UINT8_TO_1_UINT8
2-plane uint8 to 1-plane uint8 conversion function.
Definition FrameConverter.h:255
@ FT_1_UINT16_TO_1_UINT16
1-plane uint16 to 1-plane uint16 conversion function.
Definition FrameConverter.h:245
@ FT_1_UINT8_GAMMA_TO_1_UINT8
1-plane uint8 with constant gamma correction to 1-plane uint8 conversion function.
Definition FrameConverter.h:235
@ FT_1_UINT16_TO_1_UINT8
1-plane uint16 to 1-plane uint8 conversion function.
Definition FrameConverter.h:243
@ FT_1_UINT8_TO_1_UINT16
1-plane uint8 to 1-plane uint16 conversion function.
Definition FrameConverter.h:241
@ FT_1_UINT8_TO_3_UINT8
1-plane uint8 to 3-plane uint8 conversion function.
Definition FrameConverter.h:253
@ FT_2_UINT8_TO_3_UINT8
2-plane uint8 to 3-plane uint8 conversion function.
Definition FrameConverter.h:261
@ FT_1_UINT32_TO_1_UINT8
1-plane uint32 to 1-plane uint8 conversion function.
Definition FrameConverter.h:247
@ FT_1_UINT8_TO_1_UINT8
1-plane uint8 to 1-plane uint8 conversion function.
Definition FrameConverter.h:233
std::unordered_map< ConversionTriple, FunctionWrapper, ConversionTriple::Hash > FormatPair2FunctionWrapperMap
Definition of a map mapping pairs or pixel formats to function pointers.
Definition FrameConverter.h:534
void(*)(const TSource *source0, const TSource *source1, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, const uint8_t alphaValue, Worker *worker) TwoSourcesOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with two source planes and one target plane...
Definition FrameConverter.h:316
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, Worker *worker) ThreeSourcesOneTargetConversionFunction
Definition of a function pointer to a conversion function with three source planes and one target pla...
Definition FrameConverter.h:334
void(*)(const TSource *source, TTarget *target0, TTarget *target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker *worker) OneSourceTwoTargetsConversionFunction
Definition of a function pointer to a conversion function with one source plane and two target planes...
Definition FrameConverter.h:298
ConversionFunctionMap()
Creates a new map object and initializes all function pointers.
Definition of a class storing options for frame conversions.
Definition FrameConverter.h:106
float gamma() const
Returns the gamma value for a conversion with gamma correction/encoding.
Definition FrameConverter.h:2960
OptionsType optionsType_
The options type.
Definition FrameConverter.h:199
OptionsType
Definition of individual types of options.
Definition FrameConverter.h:113
@ OT_APPROXIMATED
Approximated conversion.
Definition FrameConverter.h:123
OptionsType optionsType() const
Returns the options type.
Definition FrameConverter.h:2949
uint8_t alphaChannelTargetValue() const
Returns the uint8_t alpha channel value for the target image if the source image does not contain an ...
Definition FrameConverter.h:2954
uint16_t blackLevel_
The black level value that is subtracted from each element of the raw image before any other operatio...
Definition FrameConverter.h:208
float gamma_
The gamma value for a conversion with gamma correction/encoding, with range (0, 2) (OT_GAMMA_CORRECTI...
Definition FrameConverter.h:205
Options(const bool allowApproximation=false)
Default constructor.
Definition FrameConverter.h:2900
float whiteBalance_[3]
The white balancing scalars of the red, green, and blue channels (in that order), with range [0,...
Definition FrameConverter.h:211
uint16_t blackLevel() const
Returns the black level value for a conversion with black level correction.
Definition FrameConverter.h:2966
const float * whiteBalance() const
Returns the white balance values for a conversion with white balance correction.
Definition FrameConverter.h:2972
bool allowApproximation() const
Returns whether the conversion can be approximated.
Definition FrameConverter.h:2978
This is the base class for all frame converter classes.
Definition FrameConverter.h:33
static MatrixD transformationMatrix_FullRangeRGB24_To_LimitedRangeYUV24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YUV24 using ...
static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
This function is not used anymore due to the corresponding 2-row function.
ConversionFlag
Definition of individual conversion flags.
Definition FrameConverter.h:40
@ CONVERT_NORMAL
Normal conversion, neither flips nor mirrors the image.
Definition FrameConverter.h:50
@ CONVERT_MIRRORED
Mirrored conversion, exchanges left and right of the image (like in a mirror, mirroring around the y-...
Definition FrameConverter.h:72
@ CONVERT_FLIPPED
Flipped conversion, exchanges top and bottom of the image (flipping around the x-axis).
Definition FrameConverter.h:61
std::vector< ConversionFlag > ConversionFlags
Definition of a vector holding conversion flags.
Definition FrameConverter.h:89
static void mapOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e....
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8BitAdvanced(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel value...
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from full range YUV24 to full range BGR24 using BT....
static void convertOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e....
static OCEAN_FORCE_INLINE void unpack5ElementsBayerMosaicPacked10Bit(const uint8_t *const packed, uint16_t *unpacked)
Unpacks 5 elements from a row in a packed Bayer mosaic to 4 pixels values The required memory layout ...
Definition FrameConverter.h:3548
static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a YUYV16 pixel format to one row of an image with e....
void(*)(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options) MultipleRowsConversionFunction
Definition of a function pointer to a function able to convert multiple image row from an arbitrary p...
Definition FrameConverter.h:585
void(*)(const TSource *sourceRow, TTarget *targetRow, const size_t width, const void *options) RowConversionFunction
Definition of a function pointer to a function able to convert one image row from one generic pixel f...
Definition FrameConverter.h:573
static void normalizedCast(const TSource *__restrict source, TTarget *__restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const TTarget multiplicationFactor, const TTarget offset, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
Casts the pixel values from one frame type to another frame type but also normalizes the casted sourc...
Definition FrameConverter.h:3141
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_Android()
Returns the color space transformation matrix from full range YUV24 to full range BGR24 similar to BT...
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from full range YUV24 to full range RGB24 using BT....
static void convertOneRow_1Plane1Channel_To_1Plane4Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of a single-channel image to a 4-channel image with 10-bit precision and range conve...
static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e....
static const ConversionFlags & conversionFlags()
Returns a vector holding all possible conversion flags.
static void patchFrame(const T *source, T *buffer, const unsigned int width, const unsigned int channels, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
Copies a small patch area of a given frame into a buffer holding only the entire patch.
Definition FrameConverter.h:3425
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android()
Returns the color space transformation matrix from full range YUV24 to full range RGB24 similar to BT...
static void mapOneRow_1Plane3Channels_To_3Plane1Channel_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (maps) one row of an image with e.g., a RGB24 pixel format to one row of an image with e....
static void convertOneRow_1Plane1Channel_To_1Plane4Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of a single-channel image to a 4-channel image with 6-bit precision and range conver...
static bool subFrameMask(const Frame &sourceFrame, Frame &targetFrame, const Frame &maskFrame, const uint32_t sourceLeft, const uint32_t sourceTop, const uint32_t targetLeft, const uint32_t targetTop, const uint32_t subFrameWidth, const uint32_t subFrameHeight, const uint8_t maskValue=0u)
Copies pixels from one sub-frame to another if the pixels are part of a mask; input may use padding.
Definition FrameConverter.h:3365
static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
This function is not used anymore due to the corresponding 2-row function.
static void mapOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (matches) one row of an image with e.g., a Y_UV12 pixel format to one row of an image with e...
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from full range YVU24 to full range RGB24 using BT....
static void mapOneRow_3Plane1Channel_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (maps) one row of an image with e.g., a Y_U_V24 pixel format to one row of an image with e....
static void convertOneRow_3Planes1Channel_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a Y_U_V24 pixel format to one rows of an image with e....
static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a UYVY16 pixel format to one row of an image with e....
static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a YUYV16 pixel format to one row of an image with e....
static void mapOneRow_1Plane2Channels_To_2Planes1Channel_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Maps one row of a 1-plane, 2-channel image to two planes with 1 channels.
static std::string translateConversionFlag(const ConversionFlag conversionFlag)
Translates a given conversion flag to a string.
static MatrixD transformationMatrix_FullRangeBGR24_To_FullRangeYVU24_BT601()
Returns the 3x4 color space transformation matrix from full range BGR24 to full range YVU24 using BT....
static void convertArbitraryPixelFormatSubset(const void **sources, void **targets, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int multipleRowsPerIteration, const MultipleRowsConversionFunction multipleRowsConversionFunction, const void *options, const unsigned int firstMultipleRow, const unsigned int numberMultipleRows)
Converts a subset of a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16,...
static void convertGenericPixelFormat(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const unsigned int sourceStrideElements, const unsigned int targetStrideElements, const ConversionFlag flag, const RowConversionFunction< TSource, TTarget > rowConversionFunction, const RowReversePixelOrderInPlaceFunction< TTarget > targetReversePixelOrderInPlaceFunction, const bool areContinuous, const void *options, Worker *worker)
Converts a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24, ...) to a frame with generic ...
Definition FrameConverter.h:3509
static void convertOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane4Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e....
static MatrixD transformationMatrix_FullRangeRGB24_To_FullRangeYVU24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to full range YVU24 using BT....
void(*)(T *row, const size_t width) RowReversePixelOrderInPlaceFunction
Definition of a function pointer to a function able to reverse the order of pixels in an image row wi...
Definition FrameConverter.h:604
static void convertOneRow_1Plane1Channel_To_1Plane1Channel_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of a single-channel image to another single-channel image with 10-bit precision.
static void convertOneRow_1Plane1Channel_To_1Plane1Channel_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of a single-channel image to another single-channel image with 6-bit precision.
static MatrixD transformationMatrix_FullRangeRGB24_To_FullRangeYUV24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to full range YUV24 using BT....
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeBGR24_Android()
Returns the color space transformation matrix from full range YVU24 to full range BGR24 similar to BT...
static OCEAN_FORCE_INLINE void unpack15ElementsBayerMosaicPacked10BitNEON(const uint8_t *const packed, uint16x8_t &unpackedAB_u_16x8, uint16x4_t &unpackedC_u_16x4)
Unpacks 15 elements from a row in a packed Bayer mosaic to 12 pixels values The required memory layou...
Definition FrameConverter.h:3562
static void cast(const TSource *__restrict source, TTarget *__restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
Casts the pixel values from one frame type to another frame type.
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels16Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel value...
static void convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane4Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e....
static void cast16Elements(const TSource *const source, TTarget *const target)
Casts 16 successive elements from one data type to another data type.
static void mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e....
CopyPreference
Definition of a boolean enum for copy preferences (to improve code readability).
Definition FrameConverter.h:95
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_Android()
Returns the color space transformation matrix from full range YVU24 to full range RGB24 similar to BT...
static bool subFrame(const T *source, T *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
Copies a sub-frame of a given frame into a second frame while both frames might have an individual nu...
Definition FrameConverter.h:3325
static void convertGenericPixelFormatSubset(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourceStrideBytes, const unsigned int targetStrideBytes, const ConversionFlag flag, const RowConversionFunction< uint8_t, uint8_t > rowConversionFunction, const RowReversePixelOrderInPlaceFunction< uint8_t > targetReversePixelOrderInPlaceFunction, const bool areContinuous, const void *options, const unsigned int firstRow, const unsigned int numberRows)
Converts a subset of a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24,...
static MatrixD transformationMatrix_FullRangeRGB24_To_LimitedRangeYVU24_BT601()
Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YVU24 using ...
static void convertOneRow_3Planes1Channel_To_1Plane4Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a Y_U_V24 pixel format to one rows of an image with e....
static MatrixD transformationMatrix_LimitedRangeYVU24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from limited range YVU24 to full range BGR24 using BT....
static void convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e....
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from full range YVU24 to full range BGR24 using BT....
static void convertOneRow_1Plane1Channel_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of a single-channel image to a 3-channel image with 6-bit precision and range conver...
static void patchFrameMirroredBorder(const T *source, T *buffer, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
Copies a small patch area of a frame into a buffer holding only the entire patch.
Definition FrameConverter.h:3454
void(*)(const T *inputRow, T *targetRow, const size_t width) RowReversePixelOrderFunction
Definition of a function pointer to a function able to reverse the order of pixels in an image row wi...
Definition FrameConverter.h:595
static void convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelsDownsampled2x2_8BitPerChannel_Precision7Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a RGB pixel format to two rows of an image with e....
static void mapTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts (matches) two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with...
static void convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_8BitPerChannel_Precision7Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a RGB pixel format to two rows of an image with e....
static MatrixD transformationMatrix_LimitedRangeYVU24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from limited range YVU24 to full range RGB24 using BT....
static void mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a YUV24 pixel format to two rows of an image with e....
static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of an image with e.g., a UYVY16 pixel format to one row of an image with e....
static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e....
static MatrixD transformationMatrix_LimitedRangeYUV24_To_FullRangeBGR24_BT601()
Returns the color space transformation matrix from limited range YUV24 to full range BGR24 using BT....
static void convertArbitraryPixelFormat(const void **sources, void **targets, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int multipleRowsPerIteration, const MultipleRowsConversionFunction multipleRowsConversionFunction, const void *options, Worker *worker)
Converts a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbi...
Definition FrameConverter.h:3532
static void convertOneRow_1Plane1Channel_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts one row of a single-channel image to a 3-channel image with 10-bit precision and range conve...
static void convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e....
static MatrixD transformationMatrix_FullRangeBGR24_To_LimitedRangeYUV24_BT601()
Returns the color space transformation matrix from full range BGR24 to limited range YUV24 using BT....
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8Bit(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel value...
static MatrixD transformationMatrix_LimitedRangeYUV24_To_FullRangeRGB24_BT601()
Returns the color space transformation matrix from limited range YUV24 to full range RGB24 using BT....
static MatrixD transformationMatrix_FullRangeBGR24_To_FullRangeYUV24_BT601()
Returns the 3x4 color space transformation matrix from full range BGR24 to full range YUV24 using BT....
static constexpr int8x16_t create_int8x16(const int8_t v0, const int8_t v1, const int8_t v2, const int8_t v3, const int8_t v4, const int8_t v5, const int8_t v6, const int8_t v7, const int8_t v8, const int8_t v9, const int8_t v10, const int8_t v11, const int8_t v12, const int8_t v13, const int8_t v14, const int8_t v15)
Creates an int8x16_t vector from 16 individual int8_t values.
Definition NEON.h:609
static constexpr int16x8_t create_int16x8(const int16_t v0, const int16_t v1, const int16_t v2, const int16_t v3, const int16_t v4, const int16_t v5, const int16_t v6, const int16_t v7)
Creates an int16x8_t vector from 8 individual int16_t values.
Definition NEON.h:618
static constexpr uint8x8_t create_uint8x8(const uint8_t v0, const uint8_t v1, const uint8_t v2, const uint8_t v3, const uint8_t v4, const uint8_t v5, const uint8_t v6, const uint8_t v7)
Creates a uint8x8_t vector from 8 individual uint8_t values.
Definition NEON.h:591
static constexpr uint8x16_t create_uint8x16(const uint8_t v0, const uint8_t v1, const uint8_t v2, const uint8_t v3, const uint8_t v4, const uint8_t v5, const uint8_t v6, const uint8_t v7, const uint8_t v8, const uint8_t v9, const uint8_t v10, const uint8_t v11, const uint8_t v12, const uint8_t v13, const uint8_t v14, const uint8_t v15)
Creates a uint8x16_t vector from 16 individual uint8_t values.
Definition NEON.h:600
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition Caller.h:2877
This class implements Ocean's image class.
Definition Frame.h:1969
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition Frame.h:4425
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition Frame.h:4416
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4705
bool copy(const Frame &source, const bool copyTimestamp=true)
Deprecated.
bool isOwner() const
Returns whether the frame is the owner of the internal frame data.
Definition Frame.h:4548
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition Frame.h:4299
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
@ FORMAT_UNDEFINED
Undefined pixel format.
Definition Frame.h:187
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3334
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition Frame.h:3379
uint32_t numberPlanes() const
Returns the number of planes of the pixel format of this frame.
Definition Frame.h:3374
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition Frame.h:3344
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1136
@ ORIGIN_INVALID
Invalid origin type.
Definition Frame.h:1138
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3339
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3364
DataType dataType() const
Returns the data type of the pixel format of this frame.
Definition Frame.h:3354
This class implements a matrix with arbitrary size.
Definition Matrix.h:63
This template class is the base class for all singleton objects.
Definition Singleton.h:71
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Helper class for a hash function.
Definition FrameConverter.h:362
size_t operator()(const ConversionTriple &conversionTriple) const
Hash function.
Definition FrameConverter.h:2983
Definition of the parameters used by the function for row-wise conversion of RGGB14_PACKED to RGB24/B...
Definition FrameConverter.h:610