aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/PixelValue.h
diff options
context:
space:
mode:
authorAnthony Barbier <anthony.barbier@arm.com>2017-09-04 18:44:23 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 13:03:09 +0100
commit6ff3b19ee6120edf015fad8caab2991faa3070af (patch)
treea7a6dcd16dfd56d79fa1b56a313caeebcc939b68 /arm_compute/core/PixelValue.h
downloadComputeLibrary-6ff3b19ee6120edf015fad8caab2991faa3070af.tar.gz
COMPMID-344 Updated doxygen
Change-Id: I32f7b84daa560e460b77216add529c8fa8b327ae
Diffstat (limited to 'arm_compute/core/PixelValue.h')
-rw-r--r--arm_compute/core/PixelValue.h168
1 files changed, 168 insertions, 0 deletions
diff --git a/arm_compute/core/PixelValue.h b/arm_compute/core/PixelValue.h
new file mode 100644
index 0000000000..b4912ce15a
--- /dev/null
+++ b/arm_compute/core/PixelValue.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2016, 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_PIXELVALUE_H__
+#define __ARM_COMPUTE_PIXELVALUE_H__
+
+#include <cstdint>
+
+namespace arm_compute
+{
+/** Class describing the value of a pixel for any image format. */
+class PixelValue
+{
+public:
+ /** Default constructor: value initialized to 0 */
+ PixelValue()
+ : value{ { 0 } }
+ {
+ }
+ /** Initialize the union with a U8 pixel value
+ *
+ * @param[in] v U8 value.
+ */
+ PixelValue(uint8_t v)
+ : PixelValue()
+ {
+ value.u8 = v;
+ }
+ /** Initialize the union with a U16 pixel value
+ *
+ * @param[in] v U16 value.
+ */
+ PixelValue(uint16_t v)
+ : PixelValue()
+ {
+ value.u16 = v;
+ }
+ /** Initialize the union with a S16 pixel value
+ *
+ * @param[in] v S16 value.
+ */
+ PixelValue(int16_t v)
+ : PixelValue()
+ {
+ value.s16 = v;
+ }
+ /** Initialize the union with a U32 pixel value
+ *
+ * @param[in] v U32 value.
+ */
+ PixelValue(uint32_t v)
+ : PixelValue()
+ {
+ value.u32 = v;
+ }
+ /** Initialize the union with a S32 pixel value
+ *
+ * @param[in] v S32 value.
+ */
+ PixelValue(int32_t v)
+ : PixelValue()
+ {
+ value.s32 = v;
+ }
+ /** Initialize the union with a F32 pixel value
+ *
+ * @param[in] v F32 value.
+ */
+ PixelValue(float v)
+ : PixelValue()
+ {
+ value.f32 = v;
+ }
+ /** Union which describes the value of a pixel for any image format.
+ * Use the field corresponding to the image format
+ */
+ union
+ {
+ uint8_t rgb[3]; /**< 3 channels: RGB888 */
+ uint8_t yuv[3]; /**< 3 channels: Any YUV format */
+ uint8_t rgbx[4]; /**< 4 channels: RGBX8888 */
+ float f32; /**< Single channel float 32 */
+ uint8_t u8; /**< Single channel U8 */
+ int8_t s8; /**< Single channel S8 */
+ uint16_t u16; /**< Single channel U16 */
+ int16_t s16; /**< Single channel S16 */
+ uint32_t u32; /**< Single channel U32 */
+ int32_t s32; /**< Single channel S32 */
+ } value;
+ /** Interpret the pixel value as a U8
+ *
+ * @param[out] v Returned value
+ */
+ void get(uint8_t &v) const
+ {
+ v = value.u8;
+ }
+ /** Interpret the pixel value as a S8
+ *
+ * @param[out] v Returned value
+ */
+ void get(int8_t &v) const
+ {
+ v = value.s8;
+ }
+ /** Interpret the pixel value as a U16
+ *
+ * @param[out] v Returned value
+ */
+ void get(uint16_t &v) const
+ {
+ v = value.u16;
+ }
+ /** Interpret the pixel value as a S16
+ *
+ * @param[out] v Returned value
+ */
+ void get(int16_t &v) const
+ {
+ v = value.s16;
+ }
+ /** Interpret the pixel value as a U32
+ *
+ * @param[out] v Returned value
+ */
+ void get(uint32_t &v) const
+ {
+ v = value.u32;
+ }
+ /** Interpret the pixel value as a S32
+ *
+ * @param[out] v Returned value
+ */
+ void get(int32_t &v) const
+ {
+ v = value.s32;
+ }
+ /** Interpret the pixel value as a F32
+ *
+ * @param[out] v Returned value
+ */
+ void get(float &v) const
+ {
+ v = value.f32;
+ }
+};
+}
+#endif /* __ARM_COMPUTE_PIXELVALUE_H__ */