Ocean
FrameConverterY16.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_CV_FRAME_CONVERTER_Y16_H
9 #define META_OCEAN_CV_FRAME_CONVERTER_Y16_H
10 
11 #include "ocean/cv/CV.h"
13 #include "ocean/cv/FrameChannels.h"
14 
15 namespace Ocean
16 {
17 
18 namespace CV
19 {
20 
21 /**
22  * This class provides functions to convert frames with Y16 pixel format.
23  * @ingroup cv
24  */
26 {
27  public:
28 
29  /**
30  * Converts a Y16 bit frame linearly to a Y8 bit frame.
31  * @param source The source frame, must be valid
32  * @param target The target frame, must be valid
33  * @param width The width of the frame in pixel, with range [1, infinity)
34  * @param height The height of the frame in pixel, with range [1, infinity)
35  * @param conversionFlag Determining the type of conversion
36  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
37  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
38  * @param worker Optional worker object to distribute the computational load
39  */
40  static inline void convertY16ToY8(const uint16_t* source, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker = nullptr);
41 };
42 
43 inline void FrameConverterY16::convertY16ToY8(const uint16_t* source, uint8_t* target, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker* worker)
44 {
45  ocean_assert(source != nullptr && target != nullptr);
46  ocean_assert(width != 0u && height != 0u);
47 
48  FrameChannels::narrow16BitPerChannelTo8BitPerChannel</* tChannels */ 1u>(source, target, width, height, conversionFlag, sourcePaddingElements, targetPaddingElements, worker);
49 }
50 
51 }
52 
53 }
54 
55 #endif // META_OCEAN_CV_FRAME_CONVERTER_Y16_H
static void narrow16BitPerChannelTo8BitPerChannel(const uint16_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Narrows 16 bit channels of a frame to 8 bit channels.
Definition: FrameChannels.h:3938
This is the base class for all frame converter classes.
Definition: FrameConverter.h:32
ConversionFlag
Definition of individual conversion flags.
Definition: FrameConverter.h:39
This class provides functions to convert frames with Y16 pixel format.
Definition: FrameConverterY16.h:26
static void convertY16ToY8(const uint16_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Converts a Y16 bit frame linearly to a Y8 bit frame.
Definition: FrameConverterY16.h:43
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