8 #ifndef META_OCEAN_CV_FRAME_CONVERTER_RGBA_32_H
9 #define META_OCEAN_CV_FRAME_CONVERTER_RGBA_32_H
40 static inline void convertRGBA32ToABGR32(
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);
53 static inline void convertRGBA32ToARGB32(
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);
66 static inline void convertRGBA32ToBGR24(
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);
80 static inline void convertRGBA32ToBGR32(
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);
93 static inline void convertRGBA32ToBGRA32(
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);
106 static inline void convertRGBA32ToRGBA32(
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);
119 static inline void convertRGBA32ToRGB24(
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);
133 static inline void convertRGBA32ToRGB32(
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);
147 static inline void convertRGBA32ToY8(
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);
161 static inline void convertRGBA32ToYA16(
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);
174 static inline void convertRGBA32ToYUV24(
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);
179 ocean_assert(source !=
nullptr && target !=
nullptr);
180 ocean_assert(width >= 1u && height >= 1u);
182 FrameChannels::reverseChannelOrder<uint8_t, 4u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
187 ocean_assert(source !=
nullptr && target !=
nullptr);
188 ocean_assert(width >= 1u && height >= 1u);
194 constexpr
unsigned int shufflePattern = 0x2103;
196 FrameChannels::shuffleChannels<uint8_t, 4u, 4u, shufflePattern>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
201 ocean_assert(source !=
nullptr && target !=
nullptr);
202 ocean_assert(width >= 1u && height >= 1u);
208 constexpr
unsigned int shufflePattern = 0x012;
210 FrameChannels::shuffleChannels<uint8_t, 4u, 3u, shufflePattern>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
215 ocean_assert(source !=
nullptr && target !=
nullptr);
216 ocean_assert(width >= 1u && height >= 1u);
222 constexpr
unsigned int shufflePattern = 0x012u;
224 FrameChannels::shuffleChannelsAndSetLastChannelValue<uint8_t, 4u, 4u, shufflePattern>(source, 0u, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
229 ocean_assert(source !=
nullptr && target !=
nullptr);
230 ocean_assert(width >= 1u && height >= 1u);
236 constexpr
unsigned int shufflePattern = 0x3012;
238 FrameChannels::shuffleChannels<uint8_t, 4u, 4u, shufflePattern>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
243 ocean_assert(source !=
nullptr && target !=
nullptr);
244 ocean_assert(width >= 1u && height >= 1u);
246 FrameChannels::transformGeneric<uint8_t, 4u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
251 ocean_assert(source !=
nullptr && target !=
nullptr);
252 ocean_assert(width >= 1u && height >= 1u);
254 FrameChannels::removeLastChannel<uint8_t, 4u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
259 ocean_assert(source !=
nullptr && target !=
nullptr);
260 ocean_assert(width >= 1u && height >= 1u);
266 constexpr
unsigned int shufflePattern = 0x210u;
268 FrameChannels::shuffleChannelsAndSetLastChannelValue<uint8_t, 4u, 4u, shufflePattern>(source, 0u, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
273 ocean_assert(source !=
nullptr && target !=
nullptr);
274 ocean_assert(width >= 1u && height >= 1u);
276 const unsigned int sourceStrideElements = width * 4u + sourcePaddingElements;
277 const unsigned int targetStrideElements = width + targetPaddingElements;
279 constexpr
unsigned int channelFactors[4] = {38u, 75u, 15u, 0u};
281 static_assert(channelFactors[0] + channelFactors[1] + channelFactors[2] + channelFactors[3] == 128u,
"Invalid factors!");
283 constexpr
bool useFactorChannel0 = channelFactors[0] != 0u;
284 constexpr
bool useFactorChannel1 = channelFactors[1] != 0u;
285 constexpr
bool useFactorChannel2 = channelFactors[2] != 0u;
286 constexpr
bool useFactorChannel3 = channelFactors[3] != 0u;
288 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
290 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);
295 ocean_assert(source !=
nullptr && target !=
nullptr);
296 ocean_assert(width >= 1u && height >= 1u);
298 const unsigned int sourceStrideElements = width * 4u + sourcePaddingElements;
299 const unsigned int targetStrideElements = width * 2u + targetPaddingElements;
301 constexpr
unsigned int channelFactors[8] = {38u, 0u, 75u, 0u, 15u, 0u, 0u, 128u};
303 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
305 FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag,
CV::FrameChannels::convertRow4ChannelsTo2Channels8BitPerChannel7BitPrecision, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 2u>, areContinuous, channelFactors, worker);
310 ocean_assert(source !=
nullptr && target !=
nullptr);
311 ocean_assert(width >= 1u && height >= 1u);
313 const unsigned int sourceStrideElements = width * 4u + sourcePaddingElements;
314 const unsigned int targetStrideElements = width * 3u + targetPaddingElements;
321 const int parameters[15] = {33, -19, 56, 64, -37, -47, 13, 56, -9, 0, 0, 0, 16, 128, 128};
323 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
325 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 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 provides functions to convert frames with RGBA32 pixel format.
Definition: FrameConverterRGBA32.h:26
static void convertRGBA32ToABGR32(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 an RGBA 32 bit frame to a ABGR 32 bit frame.
Definition: FrameConverterRGBA32.h:177
static void convertRGBA32ToBGR24(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 an RGBA 32 bit frame to a BGR 24 bit frame.
Definition: FrameConverterRGBA32.h:199
static void convertRGBA32ToYA16(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 RGBA 32 bit frame to a YA 16 bit frame by the exact conversion.
Definition: FrameConverterRGBA32.h:293
static void convertRGBA32ToBGRA32(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 an RGBA 32 bit frame to a BGRA 32 bit frame.
Definition: FrameConverterRGBA32.h:227
static void convertRGBA32ToYUV24(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 RGBA 32 bit frame to a YUV 24 bit frame.
Definition: FrameConverterRGBA32.h:308
static void convertRGBA32ToRGBA32(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 an RGBA 32 bit frame to a RGBA 32 bit frame.
Definition: FrameConverterRGBA32.h:241
static void convertRGBA32ToY8(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 RGBA 32 bit frame to a Y 8 bit grayscale frame by the exact conversion.
Definition: FrameConverterRGBA32.h:271
static void convertRGBA32ToBGR32(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 an RGBA 32 bit frame to a BGR 32 bit frame.
Definition: FrameConverterRGBA32.h:213
static void convertRGBA32ToARGB32(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 an RGBA 32 bit frame to a ARGB 32 bit frame.
Definition: FrameConverterRGBA32.h:185
static void convertRGBA32ToRGB32(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 an RGBA 32 bit frame to a RGB 32 bit frame.
Definition: FrameConverterRGBA32.h:257
static void convertRGBA32ToRGB24(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 an RGBA 32 bit frame to a RGB 24 bit frame.
Definition: FrameConverterRGBA32.h:249
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