2 * Copyright (c) 2016, 2017 ARM Limited.
4 * SPDX-License-Identifier: MIT
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #ifndef __ARM_COMPUTE_PIXELVALUE_H__
25 #define __ARM_COMPUTE_PIXELVALUE_H__
27 #include "arm_compute/core/Types.h"
33 /** Class describing the value of a pixel for any image format. */
37 /** Default constructor: value initialized to 0 */
42 /** Initialize the union with a U8 pixel value
44 * @param[in] v U8 value.
51 /** Initialize the union with a U16 pixel value
53 * @param[in] v U16 value.
55 PixelValue(uint16_t v)
60 /** Initialize the union with a S16 pixel value
62 * @param[in] v S16 value.
69 /** Initialize the union with a U32 pixel value
71 * @param[in] v U32 value.
73 PixelValue(uint32_t v)
78 /** Initialize the union with a S32 pixel value
80 * @param[in] v S32 value.
88 /** Initialize the union with a U64 pixel value
90 * @param[in] v U64 value.
92 PixelValue(uint64_t v)
97 /** Initialize the union with a S64 pixel value
99 * @param[in] v S64 value.
101 PixelValue(int64_t v)
106 /** Initialize the union with a F16 pixel value
108 * @param[in] v F16 value.
115 /** Initialize the union with a F32 pixel value
117 * @param[in] v F32 value.
124 /** Initialize the union with a F64 pixel value
126 * @param[in] v F64 value.
133 /** Union which describes the value of a pixel for any image format.
134 * Use the field corresponding to the image format
138 uint8_t rgb[3]; /**< 3 channels: RGB888 */
139 uint8_t yuv[3]; /**< 3 channels: Any YUV format */
140 uint8_t rgbx[4]; /**< 4 channels: RGBX8888 */
141 double f64; /**< Single channel double */
142 float f32; /**< Single channel float 32 */
143 half f16; /**< Single channel F16 */
144 uint8_t u8; /**< Single channel U8 */
145 int8_t s8; /**< Single channel S8 */
146 uint16_t u16; /**< Single channel U16 */
147 int16_t s16; /**< Single channel S16 */
148 uint32_t u32; /**< Single channel U32 */
149 int32_t s32; /**< Single channel S32 */
150 uint64_t u64; /**< Single channel U64 */
151 int64_t s64; /**< Single channel S64 */
153 /** Interpret the pixel value as a U8
155 * @param[out] v Returned value
157 void get(uint8_t &v) const
161 /** Interpret the pixel value as a S8
163 * @param[out] v Returned value
165 void get(int8_t &v) const
169 /** Interpret the pixel value as a U16
171 * @param[out] v Returned value
173 void get(uint16_t &v) const
177 /** Interpret the pixel value as a S16
179 * @param[out] v Returned value
181 void get(int16_t &v) const
185 /** Interpret the pixel value as a U32
187 * @param[out] v Returned value
189 void get(uint32_t &v) const
193 /** Interpret the pixel value as a S32
195 * @param[out] v Returned value
197 void get(int32_t &v) const
201 /** Interpret the pixel value as a U64
203 * @param[out] v Returned value
205 void get(uint64_t &v) const
209 /** Interpret the pixel value as a S64
211 * @param[out] v Returned value
213 void get(int64_t &v) const
217 /** Interpret the pixel value as a F16
219 * @param[out] v Returned value
221 void get(half &v) const
225 /** Interpret the pixel value as a F32
227 * @param[out] v Returned value
229 void get(float &v) const
233 /** Interpret the pixel value as a double
235 * @param[out] v Returned value
237 void get(double &v) const
241 /** Get the pixel value
243 * @return Pixel value
245 template <typename T>
254 #endif /* __ARM_COMPUTE_PIXELVALUE_H__ */