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 #include "arm_compute/core/PyramidInfo.h"
26 #include "arm_compute/core/Error.h"
27 #include "arm_compute/core/TensorShape.h"
31 using namespace arm_compute;
33 PyramidInfo::PyramidInfo()
34 : _num_levels(0), _tensor_shape(), _format(Format::UNKNOWN), _scale(0.0f)
38 PyramidInfo::PyramidInfo(size_t num_levels, float scale, size_t width, size_t height, Format format)
41 init(num_levels, scale, width, height, format);
44 PyramidInfo::PyramidInfo(size_t num_levels, float scale, const TensorShape &tensor_shape, Format format)
47 init(num_levels, scale, tensor_shape, format);
50 void PyramidInfo::init(size_t num_levels, float scale, size_t width, size_t height, Format format)
52 init(num_levels, scale, TensorShape(width, height), format);
55 void PyramidInfo::init(size_t num_levels, float scale, const TensorShape &tensor_shape, Format format)
57 ARM_COMPUTE_ERROR_ON(0 == num_levels);
58 ARM_COMPUTE_ERROR_ON(0.0f == scale);
59 ARM_COMPUTE_ERROR_ON(0 == tensor_shape.x());
60 ARM_COMPUTE_ERROR_ON(0 == tensor_shape.y());
61 ARM_COMPUTE_ERROR_ON(Format::IYUV == format);
62 ARM_COMPUTE_ERROR_ON(Format::NV12 == format);
63 ARM_COMPUTE_ERROR_ON(Format::NV21 == format);
64 ARM_COMPUTE_ERROR_ON(Format::UYVY422 == format);
65 ARM_COMPUTE_ERROR_ON(Format::YUV444 == format);
66 ARM_COMPUTE_ERROR_ON(Format::YUYV422 == format);
67 ARM_COMPUTE_ERROR_ON_MSG(0 != _num_levels, "PyramidInfo already initialized");
68 ARM_COMPUTE_ERROR_ON(0 == (tensor_shape.x() * pow(scale, num_levels)));
69 ARM_COMPUTE_ERROR_ON(0 == (tensor_shape.y() * pow(scale, num_levels)));
71 _num_levels = num_levels;
74 _tensor_shape = tensor_shape;
77 size_t PyramidInfo::num_levels() const
82 size_t PyramidInfo::width() const
84 return _tensor_shape.x();
87 size_t PyramidInfo::height() const
89 return _tensor_shape.y();
92 const TensorShape &PyramidInfo::tensor_shape() const
97 Format PyramidInfo::format() const
102 float PyramidInfo::scale() const