40 inline std::vector<SimpleTensor<T>> create_image_planes(
const TensorShape &
shape,
Format format)
44 std::vector<SimpleTensor<T>> image_planes;
53 image_planes.emplace_back(image_shape, format);
61 image_planes.emplace_back(image_shape,
Format::U8);
69 image_planes.emplace_back(image_shape,
Format::U8);
70 image_planes.emplace_back(shape_sub2,
Format::U8);
71 image_planes.emplace_back(shape_sub2,
Format::U8);
76 image_planes.emplace_back(image_shape,
Format::U8);
77 image_planes.emplace_back(image_shape,
Format::U8);
78 image_planes.emplace_back(image_shape,
Format::U8);
93 std::vector<SimpleTensor<T>>
dst = create_image_planes<T>(
shape, format);
96 #pragma omp parallel for 98 for(
unsigned int plane_idx = 0; plane_idx < dst.size(); ++plane_idx)
101 const uint32_t num_elements = dst_tensor.
num_elements();
103 for(uint32_t element_idx = 0; element_idx < num_elements; ++element_idx)
113 for(
int channel_idx = 0; channel_idx < dst_tensor.
num_channels(); ++channel_idx)
115 const T &src_value =
reinterpret_cast<const T *
>(image_planes[channel_idx](coord))[0];
116 T &dst_value =
reinterpret_cast<T *
>(dst_tensor(coord))[channel_idx];
118 dst_value = src_value;
128 const T &src0 =
reinterpret_cast<const T *
>(image_planes[0](coord))[0];
129 const T &src1 =
reinterpret_cast<const T *
>(image_planes[1](coord_hori))[0];
132 T &dst0 =
reinterpret_cast<T *
>(dst_tensor(coord))[1 - shift];
133 T &dst1 =
reinterpret_cast<T *
>(dst_tensor(coord))[0 + shift];
140 const T &src2 =
reinterpret_cast<const T *
>(image_planes[0](coord2))[0];
141 const T &src3 =
reinterpret_cast<const T *
>(image_planes[2](coord_hori))[0];
143 T &dst2 =
reinterpret_cast<T *
>(dst_tensor(coord2))[1 - shift];
144 T &dst3 =
reinterpret_cast<T *
>(dst_tensor(coord2))[0 + shift];
157 dst_tensor[element_idx] = image_planes[0][element_idx];
164 const T &src_u0 =
reinterpret_cast<const T *
>(image_planes[1](coord))[0];
165 const T &src_v0 =
reinterpret_cast<const T *
>(image_planes[2](coord))[0];
168 T &dst_u0 =
reinterpret_cast<T *
>(dst_tensor(coord))[0 + shift];
169 T &dst_v0 =
reinterpret_cast<T *
>(dst_tensor(coord))[1 - shift];
182 const T &
src =
reinterpret_cast<const T *
>(image_planes[plane_idx](coord))[0];
183 T &dst =
reinterpret_cast<T *
>(dst_tensor(coord))[0];
A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte.
TensorShape calculate_subsampled_shape(const TensorShape &shape, Format format, Channel channel=Channel::UNKNOWN)
Calculate subsampled shape for a given format and channel.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
1 channel, 1 U8 per channel
A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling.
TensorShape shape() const override
Shape of the tensor.
A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling.
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
T x() const
Alias to access the size of the first dimension.
3 channels, 1 U8 per channel
Format
Image colour formats.
std::vector< SimpleTensor< T > > channel_combine(const TensorShape &shape, const std::vector< SimpleTensor< T >> &image_planes, Format format)
A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes.
Coordinates index2coord(const TensorShape &shape, int index)
Convert a linear index into n-dimensional coordinates.
TensorShape adjust_odd_shape(const TensorShape &shape, Format format)
Adjust tensor shape size if width or height are odd for a given multi-planar format.
A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes.
Simple tensor object that stores elements in a consecutive chunk of memory.
int num_channels() const override
Number of channels of the tensor.
4 channels, 1 U8 per channel
2 channel, 1 U8 per channel
int num_elements() const override
Number of elements of the tensor.
T y() const
Alias to access the size of the second dimension.
A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes.