8 #ifndef META_OCEAN_CV_FRAME_CONVERTER_BGRA_32_H
9 #define META_OCEAN_CV_FRAME_CONVERTER_BGRA_32_H
43 static inline void convertBGRA32ToARGB32(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
56 static inline void convertBGRA32ToBGR24(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
69 static inline void convertBGRA32ToBGRA32(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
82 static inline void convertBGRA32ToRGB24(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
95 static inline void convertBGRA32ToRGBA32(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
109 static inline void convertBGRA32ToY8(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker);
123 static inline void convertBGRA32ToYA16(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
136 static inline void convertBGRA32ToYUV24(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
141 ocean_assert(source !=
nullptr && target !=
nullptr);
142 ocean_assert(width >= 1u && height >= 1u);
144 FrameChannels::reverseChannelOrder<uint8_t, 4u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
149 ocean_assert(source !=
nullptr && target !=
nullptr);
150 ocean_assert(width >= 1u && height >= 1u);
152 FrameChannels::removeLastChannel<uint8_t, 4u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
157 ocean_assert(source !=
nullptr && target !=
nullptr);
158 ocean_assert(width >= 1u && height >= 1u);
160 FrameChannels::transformGeneric<uint8_t, 4u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
165 ocean_assert(source !=
nullptr && target !=
nullptr);
166 ocean_assert(width >= 1u && height >= 1u);
172 constexpr
unsigned int shufflePattern = 0x012;
174 FrameChannels::shuffleChannels<uint8_t, 4u, 3u, shufflePattern>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
179 ocean_assert(source !=
nullptr && target !=
nullptr);
180 ocean_assert(width >= 1u && height >= 1u);
186 constexpr
unsigned int shufflePattern = 0x3012;
188 FrameChannels::shuffleChannels<uint8_t, 4u, 4u, shufflePattern>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
193 ocean_assert(source !=
nullptr && target !=
nullptr);
194 ocean_assert(width >= 1u && height >= 1u);
196 const unsigned int sourceStrideElements = width * 4u + sourcePaddingElements;
197 const unsigned int targetStrideElements = width + targetPaddingElements;
199 constexpr
unsigned int channelFactors[4] = {15u, 75u, 38u, 0u};
201 static_assert(channelFactors[0] + channelFactors[1] + channelFactors[2] + channelFactors[3] == 128u,
"Invalid factors!");
203 constexpr
bool useFactorChannel0 = channelFactors[0] != 0u;
204 constexpr
bool useFactorChannel1 = channelFactors[1] != 0u;
205 constexpr
bool useFactorChannel2 = channelFactors[2] != 0u;
206 constexpr
bool useFactorChannel3 = channelFactors[3] != 0u;
208 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
210 FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag, CV::FrameChannels::convertRow4ChannelsTo1Channel8BitPerChannel7BitPrecision<useFactorChannel0, useFactorChannel1, useFactorChannel2, useFactorChannel3>, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 1u>, areContinuous, channelFactors, worker);
215 ocean_assert(source !=
nullptr && target !=
nullptr);
216 ocean_assert(width >= 1u && height >= 1u);
218 const unsigned int sourceStrideElements = width * 4u + sourcePaddingElements;
219 const unsigned int targetStrideElements = width * 2u + targetPaddingElements;
226 constexpr
unsigned int channelFactors[8] = {15u, 0u, 75u, 0u, 38u, 0u, 0u, 128u};
228 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
230 FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag,
CV::FrameChannels::convertRow4ChannelsTo2Channels8BitPerChannel7BitPrecision, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 2u>, areContinuous, channelFactors, worker);
235 ocean_assert(source !=
nullptr && target !=
nullptr);
236 ocean_assert(width >= 1u && height >= 1u);
238 const unsigned int sourceStrideElements = width * 4u + sourcePaddingElements;
239 const unsigned int targetStrideElements = width * 3u + targetPaddingElements;
246 const int parameters[15] = {13, 56, -9, 64, -37, -47, 33, -19, 56, 0, 0, 0, 16, 128, 128};
248 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
250 FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag,
CV::FrameChannels::convertRow4ChannelsTo3Channels8BitPerChannel7BitPrecision, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 3u>, areContinuous, parameters, worker);
static void convertRow4ChannelsTo2Channels8BitPerChannel7BitPrecision(const uint8_t *source, uint8_t *target, const size_t size, const void *multiplicationFactors_128)
Converts a row of pixels with 4 channels to pixels with two channel by a linear combination of the fo...
static void convertRow4ChannelsTo3Channels8BitPerChannel7BitPrecision(const uint8_t *source, uint8_t *target, const size_t size, const void *parameters)
Converts a row of pixels with 3 channels to pixels with 3 channels by a linear combination of the thr...
This class provides functions to convert frames with BGRA pixel format.
Definition: FrameConverterBGRA32.h:29
static void convertBGRA32ToRGBA32(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a BGRA 32 bit frame to a RGBA 32 bit frame.
Definition: FrameConverterBGRA32.h:177
static void convertBGRA32ToBGRA32(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a BGRA 32 bit frame to a BGRA 32 bit frame.
Definition: FrameConverterBGRA32.h:155
static void convertBGRA32ToRGB24(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a BGRA 32 bit frame to a RGB 24 bit frame.
Definition: FrameConverterBGRA32.h:163
static void convertBGRA32ToBGR24(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a BGRA 32 bit frame to a BGR 24 bit frame.
Definition: FrameConverterBGRA32.h:147
static void convertBGRA32ToY8(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker)
Converts a BGRA 32 bit frame to a gray scale frame by the exact conversion.
Definition: FrameConverterBGRA32.h:191
static void convertBGRA32ToARGB32(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a BGRA 32 bit frame to a ARGB 32 bit frame.
Definition: FrameConverterBGRA32.h:139
static void convertBGRA32ToYA16(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a BGRA 32 bit frame to a YA 16 bit frame by the exact conversion.
Definition: FrameConverterBGRA32.h:213
static void convertBGRA32ToYUV24(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a BGRA 32 bit frame to a YUV 24 bit frame by the exact conversion.
Definition: FrameConverterBGRA32.h:233
This is the base class for all frame converter classes.
Definition: FrameConverter.h:32
ConversionFlag
Definition of individual conversion flags.
Definition: FrameConverter.h:39
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
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15