aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference/ColorConvert.cpp
diff options
context:
space:
mode:
authorSanghoon Lee <sanghoon.lee@arm.com>2018-04-05 10:57:57 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:52:54 +0000
commit1fad27af728ac73f0635994abf042b6d9e7075c6 (patch)
treecfd3ab5392d8fad50890a48b0abd4f12f15f42a0 /tests/validation/reference/ColorConvert.cpp
parentbdff491b167120ebc91c83ecea420620c965dd8f (diff)
downloadComputeLibrary-1fad27af728ac73f0635994abf042b6d9e7075c6.tar.gz
COMPMID-566: Implement reference and CL/NEON validation for ColorConvert (part 1)
- Image to MultiImage will be in part 2 Change-Id: Id2f22c39fb41a78a360d20d2c3bdecd57cdfd152 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/128321 Reviewed-by: Pablo Tello <pablo.tello@arm.com> Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/reference/ColorConvert.cpp')
-rw-r--r--tests/validation/reference/ColorConvert.cpp134
1 files changed, 134 insertions, 0 deletions
diff --git a/tests/validation/reference/ColorConvert.cpp b/tests/validation/reference/ColorConvert.cpp
new file mode 100644
index 0000000000..bd93eb6a61
--- /dev/null
+++ b/tests/validation/reference/ColorConvert.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2017-2018 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.
+ */
+#include "ColorConvert.h"
+
+#include "arm_compute/core/Types.h"
+#include "tests/validation/FixedPoint.h"
+#include "tests/validation/Helpers.h"
+#include "tests/validation/reference/ColorConvertHelper.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace reference
+{
+namespace
+{
+} // namespace
+
+template <typename T>
+SimpleTensor<uint8_t> color_convert(const TensorShape &shape, const std::vector<SimpleTensor<T>> &tensor_planes, Format src_format, Format dst_format)
+{
+ // Create dst and get src tensor
+ SimpleTensor<T> src = tensor_planes[0];
+ SimpleTensor<T> dst(shape, dst_format);
+
+ switch(src_format)
+ {
+ case Format::RGB888:
+ {
+ switch(dst_format)
+ {
+ case Format::RGBA8888:
+ colorconvert_helper::detail::colorconvert_rgb_to_rgbx(src, dst);
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Not Supported");
+ break;
+ }
+ break;
+ }
+ case Format::RGBA8888:
+ {
+ switch(dst_format)
+ {
+ case Format::RGB888:
+ colorconvert_helper::detail::colorconvert_rgbx_to_rgb(src, dst);
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Not Supported");
+ break;
+ }
+ break;
+ }
+ case Format::UYVY422:
+ case Format::YUYV422:
+ {
+ switch(dst_format)
+ {
+ case Format::RGB888:
+ case Format::RGBA8888:
+ colorconvert_helper::detail::colorconvert_yuyv_to_rgb(src, src_format, dst);
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Not Supported");
+ break;
+ }
+ break;
+ }
+ case Format::IYUV:
+ {
+ switch(dst_format)
+ {
+ case Format::RGB888:
+ case Format::RGBA8888:
+ colorconvert_helper::detail::colorconvert_iyuv_to_rgb(shape, tensor_planes, dst);
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Not Supported");
+ break;
+ }
+ break;
+ }
+ case Format::NV12:
+ case Format::NV21:
+ {
+ switch(dst_format)
+ {
+ case Format::RGB888:
+ case Format::RGBA8888:
+ colorconvert_helper::detail::colorconvert_nv12_to_rgb(shape, src_format, tensor_planes, dst);
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Not Supported");
+ break;
+ }
+ break;
+ }
+ default:
+ ARM_COMPUTE_ERROR("Not supported");
+ break;
+ }
+
+ return dst;
+}
+
+template SimpleTensor<uint8_t> color_convert(const TensorShape &shape, const std::vector<SimpleTensor<uint8_t>> &tensor_planes, Format src_format, Format dst_format);
+} // namespace reference
+} // namespace validation
+} // namespace test
+} // namespace arm_compute