Compute Library
 21.02
PyramidInfo.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 2017 Arm Limited.
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  */
25 
26 #include "arm_compute/core/Error.h"
28 
29 #include <cmath>
30 
31 using namespace arm_compute;
32 
34  : _num_levels(0), _tensor_shape(), _format(Format::UNKNOWN), _scale(0.0f)
35 {
36 }
37 
39  : PyramidInfo()
40 {
41  init(num_levels, scale, width, height, format);
42 }
43 
45  : PyramidInfo()
46 {
47  init(num_levels, scale, tensor_shape, format);
48 }
49 
50 void PyramidInfo::init(size_t num_levels, float scale, size_t width, size_t height, Format format)
51 {
52  init(num_levels, scale, TensorShape(width, height), format);
53 }
54 
56 {
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());
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)));
70 
71  _num_levels = num_levels;
72  _format = format;
73  _scale = scale;
74  _tensor_shape = tensor_shape;
75 }
76 
78 {
79  return _num_levels;
80 }
81 
82 size_t PyramidInfo::width() const
83 {
84  return _tensor_shape.x();
85 }
86 
87 size_t PyramidInfo::height() const
88 {
89  return _tensor_shape.y();
90 }
91 
93 {
94  return _tensor_shape;
95 }
96 
98 {
99  return _format;
100 }
101 
102 float PyramidInfo::scale() const
103 {
104  return _scale;
105 }
const TensorShape & tensor_shape() const
Return the TensorShape of the o-th level tensor.
Definition: PyramidInfo.cpp:92
A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte.
Shape of a tensor.
Definition: TensorShape.h:39
void init(size_t num_levels, float scale, size_t width, size_t height, Format format)
Initialize pyramid&#39;s metadata for 2D tensors.
Definition: PyramidInfo.cpp:50
Format format() const
Return the image format of all tensor in the pyramid.
Definition: PyramidInfo.cpp:97
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling.
A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling.
Copyright (c) 2017-2021 Arm Limited.
T x() const
Alias to access the size of the first dimension.
Definition: Dimensions.h:87
Format
Image colour formats.
Definition: Types.h:54
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes.
float scale() const
Return the scale factor of the pyramid.
Store the Pyramid&#39;s metadata.
Definition: PyramidInfo.h:35
A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes.
T y() const
Alias to access the size of the second dimension.
Definition: Dimensions.h:92
size_t width() const
Return the width of the 0th level tensor.
Definition: PyramidInfo.cpp:82
size_t num_levels() const
Return the number of the pyramid levels.
Definition: PyramidInfo.cpp:77
PyramidInfo()
Default constructor.
Definition: PyramidInfo.cpp:33
A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes.
size_t height() const
Return the height of the 0th level tensor.
Definition: PyramidInfo.cpp:87