blob: 94bddac6ef3b88204b4c5c6c51fa08a8d1b33e61 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
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 */
24#ifndef __ARM_COMPUTE_NECHANNELCOMBINEKERNEL_H__
25#define __ARM_COMPUTE_NECHANNELCOMBINEKERNEL_H__
26
27#include "arm_compute/core/NEON/INEKernel.h"
28
29#include <array>
30#include <cstdint>
31
32namespace arm_compute
33{
34class IMultiImage;
35class ITensor;
36using IImage = ITensor;
37
38/** Interface for the channel combine kernel */
39class NEChannelCombineKernel : public INEKernel
40{
41public:
42 /** Default constructor */
43 NEChannelCombineKernel();
44 /** Prevent instances of this class from being copied (As this class contains pointers) */
45 NEChannelCombineKernel(const NEChannelCombineKernel &) = delete;
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 NEChannelCombineKernel &operator=(const NEChannelCombineKernel &) = delete;
48 /** Allow instances of this class to be moved */
49 NEChannelCombineKernel(NEChannelCombineKernel &&) = default;
50 /** Allow instances of this class to be moved */
51 NEChannelCombineKernel &operator=(NEChannelCombineKernel &&) = default;
52 /** Default destructor */
53 ~NEChannelCombineKernel() = default;
54
55 /** Configure function's inputs and outputs.
56 *
57 * @param[in] plane0 The 2D plane that forms channel 0. Data type supported: U8
58 * @param[in] plane1 The 2D plane that forms channel 1. Data type supported: U8
59 * @param[in] plane2 The 2D plane that forms channel 2. Data type supported: U8
60 * @param[in] plane3 The 2D plane that forms channel 3. Data type supported: U8
61 * @param[out] output The single planar output tensor. Formats supported: RGB888/RGBA8888/UYVY422/YUYV422
62 */
63 void configure(const ITensor *plane0, const ITensor *plane1, const ITensor *plane2, const ITensor *plane3, ITensor *output);
64 /** Configure function's inputs and outputs.
65 *
66 * @param[in] plane0 The 2D plane that forms channel 0. Data type supported: U8
67 * @param[in] plane1 The 2D plane that forms channel 1. Data type supported: U8
68 * @param[in] plane2 The 2D plane that forms channel 2. Data type supported: U8
69 * @param[out] output The multi planar output tensor. Formats supported: NV12/NV21/IYUV/YUV444
70 */
71 void configure(const IImage *plane0, const IImage *plane1, const IImage *plane2, IMultiImage *output);
72
73 // Inherited methods overridden:
Moritz Pflanzerc186b572017-09-07 09:48:04 +010074 void run(const Window &window, const ThreadInfo &info) override;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010075 bool is_parallelisable() const override;
76
77private:
78 /** Combine 3 planes to form a three channel single plane tensor.
79 *
80 * @param[in] win Region on which to execute the kernel.
81 */
82 void combine_3C(const Window &win);
83 /** Combine 4 planes to form a four channel single plane tensor.
84 *
85 * @param[in] win Region on which to execute the kernel.
86 */
87 void combine_4C(const Window &win);
88 /** Combine 3 planes to form a single plane YUV tensor.
89 *
90 * @param[in] win Region on which to execute the kernel.
91 */
92 template <bool is_yuyv>
93 void combine_YUV_1p(const Window &win);
94 /** Combine 3 planes to form a two plane YUV tensor.
95 *
96 * @param[in] win Region on which to execute the kernel.
97 */
98 void combine_YUV_2p(const Window &win);
99 /** Combine 3 planes to form a three plane YUV tensor.
100 *
101 * @param[in] win Region on which to execute the kernel.
102 */
103 void combine_YUV_3p(const Window &win);
104 /** Copies a full plane to the output tensor.
105 *
106 * @param[in] win Region on which to execute the kernel.
107 */
108 void copy_plane(const Window &win, uint32_t plane_id);
109 /** Common signature for all the specialised ChannelCombine functions
110 *
111 * @param[in] window Region on which to execute the kernel.
112 */
113 using ChannelCombineFunction = void (NEChannelCombineKernel::*)(const Window &window);
114 /** ChannelCombine function to use for the particular tensor types passed to configure() */
115 ChannelCombineFunction _func;
116 std::array<const ITensor *, 4> _planes;
117 ITensor *_output;
118 IMultiImage *_output_multi;
119 std::array<uint32_t, 3> _x_subsampling;
120 std::array<uint32_t, 3> _y_subsampling;
121 unsigned int _num_elems_processed_per_iteration;
122 bool _is_parallelizable;
123};
124}
125#endif /* __ARM_COMPUTE_NECHANNELCOMBINEKERNEL_H__ */