8 #ifndef META_OCEAN_CV_FRAME_CONVERTER_BGR_24_H
9 #define META_OCEAN_CV_FRAME_CONVERTER_BGR_24_H
43 static inline void convertBGR24ToBGR24(
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);
57 static inline void convertBGR24ToBGRA32(
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,
const uint8_t alphaValue = 0xFF,
Worker* worker =
nullptr);
70 static inline void convertBGR24ToRGB24(
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);
84 static inline void convertBGR24ToRGBA32(
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,
const uint8_t alphaValue = 0xFF,
Worker* worker =
nullptr);
98 static inline void convertBGR24ToY8(
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);
111 static inline void convertBGR24ToYUV24(
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);
132 static inline void convertBGR24FullRangeToY_U_V12LimitedRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int uTargetPaddingElements,
const unsigned int vTargetPaddingElements,
Worker* worker =
nullptr);
153 static inline void convertBGR24FullRangeToY_V_U12LimitedRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int vTargetPaddingElements,
const unsigned int uTargetPaddingElements,
Worker* worker =
nullptr);
174 static inline void convertBGR24FullRangeToY_U_V12FullRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int uTargetPaddingElements,
const unsigned int vTargetPaddingElements,
Worker* worker =
nullptr);
195 static inline void convertBGR24FullRangeToY_V_U12FullRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int vTargetPaddingElements,
const unsigned int uTargetPaddingElements,
Worker* worker =
nullptr);
200 ocean_assert(source !=
nullptr && target !=
nullptr);
201 ocean_assert(width >= 1u && height >= 1u);
203 FrameChannels::transformGeneric<uint8_t, 3u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
208 ocean_assert(source !=
nullptr && target !=
nullptr);
209 ocean_assert(width >= 1u && height >= 1u);
211 FrameChannels::addLastChannelValue<uint8_t, 3u>(source, alphaValue, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
216 ocean_assert(source !=
nullptr && target !=
nullptr);
217 ocean_assert(width >= 1u && height >= 1u);
219 FrameChannels::reverseChannelOrder<uint8_t, 3u>(source, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
224 ocean_assert(source !=
nullptr && target !=
nullptr);
225 ocean_assert(width >= 1u && height >= 1u);
231 constexpr
unsigned int shufflePattern = 0x012u;
233 FrameChannels::shuffleChannelsAndSetLastChannelValue<uint8_t, 3u, 4u, shufflePattern>(source, alphaValue, target, width, height, flag, sourcePaddingElements, targetPaddingElements, worker);
238 ocean_assert(source !=
nullptr && target !=
nullptr);
239 ocean_assert(width >= 1u && height >= 1u);
241 const unsigned int sourceStrideElements = width * 3u + sourcePaddingElements;
242 const unsigned int targetStrideElements = width + targetPaddingElements;
244 constexpr
unsigned int channelFactors[3] = {15u, 75u, 38u};
246 static_assert(channelFactors[0] + channelFactors[1] + channelFactors[2] == 128u,
"Invalid factors!");
248 constexpr
bool useFactorChannel0 = channelFactors[0] != 0u;
249 constexpr
bool useFactorChannel1 = channelFactors[1] != 0u;
250 constexpr
bool useFactorChannel2 = channelFactors[2] != 0u;
252 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
254 FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag, CV::FrameChannels::convertRow3ChannelsTo1Channel8BitPerChannel7BitPrecision<useFactorChannel0, useFactorChannel1, useFactorChannel2>, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 1u>, areContinuous, channelFactors, worker);
259 ocean_assert(source !=
nullptr && target !=
nullptr);
260 ocean_assert(width >= 1u && height >= 1u);
262 const unsigned int sourceStrideElements = width * 3u + sourcePaddingElements;
263 const unsigned int targetStrideElements = width * 3u + targetPaddingElements;
270 const int parameters[12] = {13, 56, -9, 64, -37, -47, 33, -19, 56, 16, 128, 128};
272 const bool areContinuous = sourcePaddingElements == 0u && targetPaddingElements == 0u;
274 FrameConverter::convertGenericPixelFormat(source, target, width, height, sourceStrideElements, targetStrideElements, flag,
CV::FrameChannels::convertRow3ChannelsTo3Channels8BitPerChannel7BitPrecision, CV::FrameChannels::reverseRowPixelOrderInPlace<uint8_t, 3u>, areContinuous, parameters, worker);
277 inline void FrameConverterBGR24::convertBGR24FullRangeToY_U_V12LimitedRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int uTargetPaddingElements,
const unsigned int vTargetPaddingElements,
Worker* worker)
279 ocean_assert(source !=
nullptr && yTarget !=
nullptr && uTarget !=
nullptr && vTarget !=
nullptr);
281 ocean_assert(width >= 2u && width % 2u == 0u);
282 ocean_assert(height >= 2u && height % 2u == 0u);
284 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
304 const int options[4 + 9 + 3] =
307 int(sourcePaddingElements), int(yTargetPaddingElements), int(uTargetPaddingElements), int(vTargetPaddingElements),
310 13, 56, -9, 64, -37, -47, 33, -19, 56,
326 inline void FrameConverterBGR24::convertBGR24FullRangeToY_V_U12LimitedRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int vTargetPaddingElements,
const unsigned int uTargetPaddingElements,
Worker* worker)
330 convertBGR24FullRangeToY_U_V12LimitedRange(source, yTarget, uTarget, vTarget, width, height, flag, sourcePaddingElements, yTargetPaddingElements, uTargetPaddingElements, vTargetPaddingElements, worker);
333 inline void FrameConverterBGR24::convertBGR24FullRangeToY_U_V12FullRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* uTarget, uint8_t* vTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int uTargetPaddingElements,
const unsigned int vTargetPaddingElements,
Worker* worker)
335 ocean_assert(source !=
nullptr && yTarget !=
nullptr && uTarget !=
nullptr && vTarget !=
nullptr);
337 ocean_assert(width >= 2u && width % 2u == 0u);
338 ocean_assert(height >= 2u && height % 2u == 0u);
340 if (width < 2u || height < 2u || width % 2u != 0u || height % 2u != 0u)
360 const int options[4 + 9 + 3] =
363 int(sourcePaddingElements), int(yTargetPaddingElements), int(uTargetPaddingElements), int(vTargetPaddingElements),
366 15, 64, -10, 75, -42, -54, 38, -22, 64,
382 inline void FrameConverterBGR24::convertBGR24FullRangeToY_V_U12FullRange(
const uint8_t* source, uint8_t* yTarget, uint8_t* vTarget, uint8_t* uTarget,
const unsigned int width,
const unsigned int height,
const ConversionFlag flag,
const unsigned int sourcePaddingElements,
const unsigned int yTargetPaddingElements,
const unsigned int vTargetPaddingElements,
const unsigned int uTargetPaddingElements,
Worker* worker)
386 convertBGR24FullRangeToY_U_V12FullRange(source, yTarget, uTarget, vTarget, width, height, flag, sourcePaddingElements, yTargetPaddingElements, uTargetPaddingElements, vTargetPaddingElements, worker);
static void convertRow3ChannelsTo3Channels8BitPerChannel7BitPrecision(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 BGR pixel format.
Definition: FrameConverterBGR24.h:29
static void convertBGR24FullRangeToY_U_V12FullRange(const uint8_t *source, uint8_t *yTarget, uint8_t *uTarget, uint8_t *vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a full range Y_U_V12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:333
static void convertBGR24ToRGBA32(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, const uint8_t alphaValue=0xFF, Worker *worker=nullptr)
Converts a BGR 24 bit frame to a RGBA 32 bit frame.
Definition: FrameConverterBGR24.h:222
static void convertBGR24ToBGRA32(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, const uint8_t alphaValue=0xFF, Worker *worker=nullptr)
Converts a BGR 24 bit frame to a BGR 24 bit frame.
Definition: FrameConverterBGR24.h:206
static void convertBGR24ToYUV24(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 BGR 24 bit frame to a YUV 24 bit frame by the exact conversion.
Definition: FrameConverterBGR24.h:257
static void convertBGR24FullRangeToY_V_U12LimitedRange(const uint8_t *source, uint8_t *yTarget, uint8_t *vTarget, uint8_t *uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a limited range Y_V_U12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:326
static void convertBGR24FullRangeToY_U_V12LimitedRange(const uint8_t *source, uint8_t *yTarget, uint8_t *uTarget, uint8_t *vTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uTargetPaddingElements, const unsigned int vTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a limited range Y_U_V12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:277
static void convertBGR24ToRGB24(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 BGR 24 bit frame to a RGB 24 bit frame.
Definition: FrameConverterBGR24.h:214
static void convertBGR24ToBGR24(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 BGR 24 bit frame to a BGR 24 bit frame.
Definition: FrameConverterBGR24.h:198
static void convertBGR24FullRangeToY_V_U12FullRange(const uint8_t *source, uint8_t *yTarget, uint8_t *vTarget, uint8_t *uTarget, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int sourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int vTargetPaddingElements, const unsigned int uTargetPaddingElements, Worker *worker=nullptr)
Converts a full range BGR24 frame to a full range Y_V_U12 frame with 7-bit precision using BT....
Definition: FrameConverterBGR24.h:382
static void convertBGR24ToY8(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 BGR 24 bit frame to a gray scale frame.
Definition: FrameConverterBGR24.h:236
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
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 convertArbitraryPixelFormat(const void **sources, void **targets, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int multipleRowsPerIteration, const MultipleRowsConversionFunction multipleRowsConversionFunction, const void *options, Worker *worker)
Converts a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbi...
Definition: FrameConverter.h:3234
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