8 #ifndef META_OCEAN_CV_FRAME_INVERTER_H
9 #define META_OCEAN_CV_FRAME_INVERTER_H
56 template <
unsigned int tChannel,
unsigned int tChannels>
57 static inline void invert8BitChannel(uint8_t* frame,
const unsigned int width,
const unsigned int height,
Worker* worker =
nullptr);
69 template <
unsigned int tChannel,
unsigned int tChannels>
70 static inline void invert8BitChannel(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
Worker* worker =
nullptr);
82 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
83 static inline void invert8BitChannels(uint8_t* frame,
const unsigned int width,
const unsigned int height,
Worker* worker =
nullptr);
96 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
97 static inline void invert8BitChannels(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
Worker* worker =
nullptr);
110 static inline void invert8BitPerChannel(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
124 template <
unsigned int tChannel,
unsigned int tChannels>
125 static void invert8BitChannelSubset(uint8_t* frame,
const unsigned int width,
const unsigned int height,
const unsigned int firstRow,
const unsigned int numberRows);
138 template <
unsigned int tChannel,
unsigned int tChannels>
139 static void invert8BitChannelSubset(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int firstRow,
const unsigned int numberRows);
152 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
153 static void invert8BitChannelsSubset(uint8_t* frame,
const unsigned int width,
const unsigned int height,
const unsigned int firstRow,
const unsigned int numberRows);
167 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
168 static void invert8BitChannelsSubset(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int firstRow,
const unsigned int numberRows);
180 static void invert8BitPerChannelSubset(
const uint8_t* source, uint8_t* target,
const unsigned int horizontalElements,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
182 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
194 static void invert8BitPerChannelSubsetNEON(
const uint8_t* source, uint8_t* target,
const unsigned int horizontalElements,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
200 template <
unsigned int tChannel,
unsigned int tChannels>
211 invert8BitChannelSubset<tChannel, tChannels>(frame, width, height, 0u, height);
215 template <
unsigned int tChannel,
unsigned int tChannels>
218 ocean_assert(source && target);
226 invert8BitChannelSubset<tChannel, tChannels>(source, target, width, height, 0u, height);
230 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
241 invert8BitChannelsSubset<tChannelFirst, tChannelLast, tChannels>(frame, width, height, 0u, height);
245 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
248 ocean_assert(source && target);
252 worker->
executeFunction(
Worker::Function::createStatic(&invert8BitChannelsSubset<tChannelFirst, tChannelLast, tChannels>, source, target, width, height, 0u, 0u), 0u, height);
256 invert8BitChannelsSubset<tChannelFirst, tChannelLast, tChannels>(source, target, width, height, 0u, height);
260 inline void FrameInverter::invert8BitPerChannel(
const uint8_t* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
262 ocean_assert(source !=
nullptr && target !=
nullptr);
263 ocean_assert(width != 0u && height != 0u);
264 ocean_assert(channels != 0u);
266 const unsigned int horizontalElements = width * channels;
268 if (worker && width * height > 1920u * 1080u)
270 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
271 if (width * channels >= 32u)
273 worker->
executeFunction(
Worker::Function::createStatic(&
FrameInverter::invert8BitPerChannelSubsetNEON, source, target, horizontalElements, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 5u, 6u, 20u);
278 worker->
executeFunction(
Worker::Function::createStatic(&
FrameInverter::invert8BitPerChannelSubset, source, target, horizontalElements, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 5u, 6u, 20u);
282 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
283 if (width * channels >= 32u)
294 template <
unsigned int tChannel,
unsigned int tChannels>
297 static_assert(tChannels >= 1u,
"Invalid channel number!");
298 static_assert(tChannel < tChannels,
"Invalid channel index!");
300 ocean_assert(frame !=
nullptr);
301 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
303 frame += firstRow * width * tChannels + tChannel;
305 uint8_t*
const frameEnd = frame + numberRows * width * tChannels;
307 while (frame != frameEnd)
309 ocean_assert(frame < frameEnd);
311 *frame = 0xFF - *frame;
316 template <
unsigned int tChannel,
unsigned int tChannels>
319 static_assert(tChannels >= 1u,
"Invalid channel number!");
320 static_assert(tChannel < tChannels,
"Invalid channel index!");
322 ocean_assert(source && target);
323 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
325 source += firstRow * width * tChannels + tChannel;
326 target += firstRow * width * tChannels + tChannel;
328 const uint8_t*
const sourceEnd = source + numberRows * width * tChannels;
330 while (source != sourceEnd)
332 ocean_assert(source < sourceEnd);
334 *target = 0xFF - *source;
341 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
344 static_assert(tChannels >= 1u,
"Invalid channel number!");
345 static_assert(tChannelFirst < tChannels,
"Invalid channel index!");
346 static_assert(tChannelFirst <= tChannelLast,
"Invalid channel index!");
347 static_assert(tChannelLast < tChannels,
"Invalid channel index!");
350 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
352 frame += firstRow * width * tChannels + tChannelFirst;
354 uint8_t*
const frameEnd = frame + numberRows * width * tChannels;
356 while (frame != frameEnd)
358 ocean_assert(frame < frameEnd);
360 for (
unsigned int n = 0u; n < tChannelLast - tChannelFirst + 1u; ++n)
361 frame[n] = 0xFF - frame[n];
367 template <
unsigned int tChannelFirst,
unsigned int tChannelLast,
unsigned int tChannels>
370 static_assert(tChannels >= 1u,
"Invalid channel number!");
371 static_assert(tChannelFirst < tChannels,
"Invalid channel index!");
372 static_assert(tChannelFirst <= tChannelLast,
"Invalid channel index!");
373 static_assert(tChannelLast < tChannels,
"Invalid channel index!");
375 ocean_assert(source && target);
376 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
378 source += firstRow * width * tChannels + tChannelFirst;
379 target += firstRow * width * tChannels + tChannelFirst;
381 const uint8_t*
const sourceEnd = source + numberRows * width * tChannels;
383 while (source != sourceEnd)
385 ocean_assert(source < sourceEnd);
387 for (
unsigned int n = 0u; n < tChannelLast - tChannelFirst + 1u; ++n)
388 target[n] = 0xFF - source[n];
This class implements a frame inverter inverting the internal frame data.
Definition: FrameInverter.h:27
static void invert8BitPerChannelSubset(const uint8_t *source, uint8_t *target, const unsigned int horizontalElements, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Inverts the pixel values of a subset of a given frame.
static void invert8BitChannelsSubset(uint8_t *frame, const unsigned int width, const unsigned int height, const unsigned int firstRow, const unsigned int numberRows)
Inverts several channels of a subset of an 8 bit per channel frame.
Definition: FrameInverter.h:342
static bool invert(const Frame &source, Frame &target, Worker *worker=nullptr)
Inverts the pixel values of a given frame.
static void invert8BitPerChannelSubsetNEON(const uint8_t *source, uint8_t *target, const unsigned int horizontalElements, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Inverts the pixel values of a subset of a given frame.
static void invert8BitChannelSubset(uint8_t *frame, const unsigned int width, const unsigned int height, const unsigned int firstRow, const unsigned int numberRows)
Inverts one channel of a subset of an 8 bit per channel frame.
Definition: FrameInverter.h:295
static void invert8BitChannel(uint8_t *frame, const unsigned int width, const unsigned int height, Worker *worker=nullptr)
Inverts one channel of an 8 bit per channel frame.
Definition: FrameInverter.h:201
static bool invert(Frame &frame, Worker *worker=nullptr)
Inverts the pixel values of a given frame.
static void invert8BitChannels(uint8_t *frame, const unsigned int width, const unsigned int height, Worker *worker=nullptr)
Inverts several channels of an 8 bit per channel frame.
Definition: FrameInverter.h:231
static void invert8BitPerChannel(const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Inverts an 8 bit per channel frame.
Definition: FrameInverter.h:260
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition: Caller.h:2876
This class implements Ocean's image class.
Definition: Frame.h:1792
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