diff options
author | Manuel Bottini <manuel.bottini@arm.com> | 2018-09-26 15:33:15 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:55:19 +0000 |
commit | 4284bfab4594d4babb23123001ef63db7bebeccb (patch) | |
tree | 2ec8c120cf74e1c4accb3f88e4df0664cf386779 /tests/validation/reference/ColorConvertHelper.h | |
parent | 7c9541ccd4c98d7e9a456ee67c3ceecce8531ffb (diff) | |
download | ComputeLibrary-4284bfab4594d4babb23123001ef63db7bebeccb.tar.gz |
COMPMID-287: NEON colour convert to U8
Change-Id: I47033fa70881fd32b13266adb6ccbf10c202aabc
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/150344
Tested-by: bsgcomp <bsgcomp@arm.com>
Reviewed-by: Pablo Tello <pablo.tello@arm.com>
Diffstat (limited to 'tests/validation/reference/ColorConvertHelper.h')
-rw-r--r-- | tests/validation/reference/ColorConvertHelper.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/validation/reference/ColorConvertHelper.h b/tests/validation/reference/ColorConvertHelper.h index 7a8b547486..b2ae6f2f80 100644 --- a/tests/validation/reference/ColorConvertHelper.h +++ b/tests/validation/reference/ColorConvertHelper.h @@ -48,6 +48,10 @@ constexpr float rgb2yuv_bt709_cu = 0.5389f; // C_v = 1 / (2 * (1 - K_r)) constexpr float rgb2yuv_bt709_cv = 0.6350f; +constexpr float rgb2u8_red_coef = 0.2126f; +constexpr float rgb2u8_green_coef = 0.7152f; +constexpr float rgb2u8_blue_coef = 0.0722f; + template <typename T> inline void store_rgb_from_src(const SimpleTensor<T> src, SimpleTensor<T> &rvec, SimpleTensor<T> &gvec, SimpleTensor<T> &bvec) { @@ -219,6 +223,29 @@ inline void colorconvert_rgb_to_rgbx(const SimpleTensor<T> src, SimpleTensor<T> } template <typename T> +inline void colorconvert_rgb_to_u8(const SimpleTensor<T> src, SimpleTensor<T> &dst) +{ + const int width = dst.shape().x(); + const int height = dst.shape().y(); + + for(int y = 0; y < height; ++y) + { + for(int x = 0; x < width; ++x) + { + const Coordinates src_coord{ x, y }; + const Coordinates dst_coord{ x, y }; + + const auto *src_pixel = reinterpret_cast<const T *>(src(src_coord)); + auto *dst_pixel = reinterpret_cast<T *>(dst(dst_coord)); + + const float result = rgb2u8_red_coef * src_pixel[0] + rgb2u8_green_coef * src_pixel[1] + rgb2u8_blue_coef * src_pixel[2]; + + dst_pixel[0] = utility::clamp<float>(result, 0, 255); + } + } +} + +template <typename T> inline void colorconvert_rgbx_to_rgb(const SimpleTensor<T> src, SimpleTensor<T> &dst) { for(int channel_idx = 0; channel_idx < dst.num_channels(); ++channel_idx) |