Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 Arm Limited. |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 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: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 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 |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/runtime/CL/CLMultiImage.h" |
| 25 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 26 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 27 | #include "arm_compute/runtime/CL/functions/CLColorConvert.h" |
| 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/datasets/ShapeDatasets.h" |
| 30 | #include "tests/framework/Asserts.h" |
| 31 | #include "tests/framework/Macros.h" |
| 32 | #include "tests/validation/Validation.h" |
| 33 | #include "tests/validation/fixtures/ColorConvertFixture.h" |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace test |
| 38 | { |
| 39 | namespace validation |
| 40 | { |
| 41 | namespace |
| 42 | { |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 43 | constexpr AbsoluteTolerance<uint8_t> tolerance_nv(2); |
Michele Di Giorgio | ca0ffa6 | 2020-02-17 16:21:48 +0000 | [diff] [blame] | 44 | constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1); |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 45 | |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 46 | // Input data sets |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 47 | const auto RGBDataset = framework::dataset::make("FormatType", { Format::RGB888, Format::RGBA8888 }); |
| 48 | const auto YUYVDataset = framework::dataset::make("FormatType", { Format::YUYV422, Format::UYVY422 }); |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 49 | |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 50 | const auto ColorConvert_RGBA_to_RGB = combine(framework::dataset::make("FormatType", { Format::RGBA8888 }), |
| 51 | framework::dataset::make("FormatType", { Format::RGB888 })); |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 52 | |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 53 | const auto ColorConvert_RGB_to_RGBA = combine(framework::dataset::make("FormatType", { Format::RGB888 }), |
| 54 | framework::dataset::make("FormatType", { Format::RGBA8888 })); |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 55 | |
Manuel Bottini | acaf21d | 2018-09-26 17:38:19 +0100 | [diff] [blame] | 56 | const auto ColorConvert_RGB_to_U8 = combine(framework::dataset::make("FormatType", { Format::RGB888 }), |
| 57 | framework::dataset::make("FormatType", { Format::U8 })); |
| 58 | |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 59 | const auto ColorConvert_YUYV_to_RGBDataset = combine(YUYVDataset, |
| 60 | RGBDataset); |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 61 | |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 62 | const auto ColorConvert_YUVPlanar_to_RGBDataset = combine(framework::dataset::make("FormatType", { Format::IYUV, Format::NV12, Format::NV21 }), |
| 63 | RGBDataset); |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 64 | |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 65 | const auto ColorConvert_RGBDataset_to_NVDataset = combine(RGBDataset, |
| 66 | framework::dataset::make("FormatType", { Format::NV12, Format::IYUV, Format::YUV444 })); |
| 67 | |
| 68 | const auto ColorConvert_YUYVDataset_to_NVDataset = combine(YUYVDataset, |
| 69 | framework::dataset::make("FormatType", { Format::NV12, Format::IYUV })); |
| 70 | |
| 71 | const auto ColorConvert_NVDataset_to_YUVDataset = combine(framework::dataset::make("FormatType", { Format::NV12, Format::NV21 }), |
| 72 | framework::dataset::make("FormatType", { Format::IYUV, Format::YUV444 })); |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 73 | |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 74 | } // namespace |
| 75 | |
| 76 | TEST_SUITE(CL) |
| 77 | TEST_SUITE(ColorConvert) |
| 78 | |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 79 | template <typename T> |
| 80 | using CLColorConvertFixture = ColorConvertValidationFixture<CLMultiImage, CLTensor, CLAccessor, CLColorConvert, T>; |
| 81 | |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 82 | TEST_SUITE(RGBA) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 83 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_RGBA_to_RGB)) |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 84 | { |
| 85 | // Validate output |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 86 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 87 | { |
| 88 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 89 | } |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 90 | } |
| 91 | |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 92 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_RGBA_to_RGB)) |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 93 | { |
| 94 | // Validate output |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 95 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 96 | { |
| 97 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 98 | } |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 99 | } |
| 100 | TEST_SUITE_END() |
| 101 | |
| 102 | TEST_SUITE(RGB) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 103 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_RGB_to_RGBA)) |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 104 | { |
| 105 | // Validate output |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 106 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 107 | { |
| 108 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 109 | } |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 110 | } |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 111 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_RGB_to_RGBA)) |
| 112 | { |
| 113 | // Validate output |
| 114 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 115 | { |
| 116 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 117 | } |
| 118 | } |
| 119 | TEST_SUITE_END() |
| 120 | |
Manuel Bottini | acaf21d | 2018-09-26 17:38:19 +0100 | [diff] [blame] | 121 | TEST_SUITE(RGBtoU8) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 122 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_RGB_to_U8)) |
Manuel Bottini | acaf21d | 2018-09-26 17:38:19 +0100 | [diff] [blame] | 123 | { |
| 124 | // Validate output |
| 125 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 126 | { |
Michele Di Giorgio | ca0ffa6 | 2020-02-17 16:21:48 +0000 | [diff] [blame] | 127 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx], tolerance_u8); |
Manuel Bottini | acaf21d | 2018-09-26 17:38:19 +0100 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_RGB_to_U8)) |
| 131 | { |
| 132 | // Validate output |
| 133 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 134 | { |
Michele Di Giorgio | ca0ffa6 | 2020-02-17 16:21:48 +0000 | [diff] [blame] | 135 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx], tolerance_u8); |
Manuel Bottini | acaf21d | 2018-09-26 17:38:19 +0100 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | TEST_SUITE_END() |
| 139 | |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 140 | TEST_SUITE(YUV) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 141 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_YUYV_to_RGBDataset)) |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 142 | { |
| 143 | // Validate output |
| 144 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 145 | { |
| 146 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 147 | } |
| 148 | } |
| 149 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_YUYV_to_RGBDataset)) |
| 150 | { |
| 151 | // Validate output |
| 152 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 153 | { |
| 154 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 155 | } |
| 156 | } |
| 157 | TEST_SUITE_END() |
| 158 | |
| 159 | TEST_SUITE(YUVPlanar) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 160 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_YUVPlanar_to_RGBDataset)) |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 161 | { |
| 162 | // Validate output |
| 163 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 164 | { |
| 165 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 166 | } |
| 167 | } |
| 168 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_YUVPlanar_to_RGBDataset)) |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 169 | { |
| 170 | // Validate output |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 171 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 172 | { |
| 173 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 174 | } |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 175 | } |
| 176 | TEST_SUITE_END() |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 177 | |
| 178 | TEST_SUITE(NV) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 179 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_RGBDataset_to_NVDataset)) |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 180 | { |
| 181 | // Validate output |
| 182 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 183 | { |
| 184 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx], tolerance_nv); |
| 185 | } |
| 186 | } |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 187 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_RGBDataset_to_NVDataset)) |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 188 | { |
| 189 | // Validate output |
| 190 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 191 | { |
| 192 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx], tolerance_nv); |
| 193 | } |
| 194 | } |
| 195 | TEST_SUITE_END() |
| 196 | |
| 197 | TEST_SUITE(YUYVtoNV) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 198 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_YUYVDataset_to_NVDataset)) |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 199 | { |
| 200 | // Validate output |
| 201 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 202 | { |
| 203 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 204 | } |
| 205 | } |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 206 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_YUYVDataset_to_NVDataset)) |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 207 | { |
| 208 | // Validate output |
| 209 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 210 | { |
| 211 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | TEST_SUITE_END() |
| 216 | |
| 217 | TEST_SUITE(NVtoYUV) |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 218 | FIXTURE_DATA_TEST_CASE(RunSmall, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Small2DShapes(), ColorConvert_NVDataset_to_YUVDataset)) |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 219 | { |
| 220 | // Validate output |
| 221 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 222 | { |
| 223 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 224 | } |
| 225 | } |
Sanghoon Lee | c7b82f1 | 2018-07-06 13:27:27 +0100 | [diff] [blame] | 226 | FIXTURE_DATA_TEST_CASE(RunLarge, CLColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvert_NVDataset_to_YUVDataset)) |
Sanghoon Lee | dec32a9 | 2018-06-29 10:52:57 +0100 | [diff] [blame] | 227 | { |
| 228 | // Validate output |
| 229 | for(unsigned int plane_idx = 0; plane_idx < _dst_num_planes; ++plane_idx) |
| 230 | { |
| 231 | validate(CLAccessor(*_target.cl_plane(plane_idx)), _reference[plane_idx]); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | TEST_SUITE_END() |
| 236 | |
Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [diff] [blame] | 237 | TEST_SUITE_END() |
| 238 | TEST_SUITE_END() |
| 239 | } // namespace validation |
| 240 | } // namespace test |
| 241 | } // namespace arm_compute |