1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief A header file for CompoundBlob
8 * @file ie_compound_blob.h
12 #include <initializer_list>
18 namespace InferenceEngine {
20 * @brief This class represents a blob that contains other blobs
22 * Compound blob is a wrapper blob over references to underlying blobs. These blobs should share
23 * some properties and can be grouped into a single entity.
25 class INFERENCE_ENGINE_API_CLASS(CompoundBlob): public Blob {
28 * @brief A smart pointer to the CompoundBlob object
30 using Ptr = std::shared_ptr<CompoundBlob>;
33 * @brief A smart pointer to the const CompoundBlob object
35 using CPtr = std::shared_ptr<const CompoundBlob>;
38 * @brief A virtual destructor
40 virtual ~CompoundBlob() = default;
43 * @brief A copy constructor
45 CompoundBlob(const CompoundBlob& blob);
48 * @brief A copy assignment operator
50 CompoundBlob& operator=(const CompoundBlob& blob) = default;
53 * @brief A move constructor
55 CompoundBlob(CompoundBlob&& blob);
58 * @brief A move assignment operator
60 CompoundBlob& operator=(CompoundBlob&& blob) = default;
63 * @brief Constructs a compound blob from a vector of blobs
65 * @param blobs A vector of blobs that is copied to this object
67 explicit CompoundBlob(const std::vector<Blob::Ptr>& blobs);
70 * @brief Constructs a compound blob from a vector of blobs
72 * @param blobs A vector of blobs that is moved to this object
74 explicit CompoundBlob(std::vector<Blob::Ptr>&& blobs);
77 * @brief Always returns 0
79 size_t byteSize() const noexcept override;
82 * @brief Always returns 0
84 size_t element_size() const noexcept override;
87 * @brief No operation is performed. Compound blob does not allocate/deallocate any data
89 void allocate() noexcept override;
92 * @brief No operation is performed. Compound blob does not allocate/deallocate any data
95 bool deallocate() noexcept override;
98 * @brief Always returns an empty LockedMemory object
100 LockedMemory<void> buffer() noexcept override;
103 * @brief Always returns an empty LockedMemory object
105 LockedMemory<const void> cbuffer() const noexcept override;
108 * @brief Returns the number of underlying blobs in the compound blob
110 size_t size() const noexcept override;
113 * @brief Returns an underlying blob at index i
115 * @param i the index of the underlying Blob object
116 * @return A smart pointer to the underlying Blob object or nullptr in case of an error
118 virtual Blob::Ptr getBlob(size_t i) const noexcept;
122 * @brief A default constructor
127 * @brief Compound blob container for underlying blobs
129 std::vector<Blob::Ptr> _blobs;
132 * @brief Returns nullptr as CompoundBlob is not allocator-based
134 const std::shared_ptr<IAllocator>& getAllocator() const noexcept override;
137 * @brief Returns nullptr as CompoundBlob is not allocator-based
139 void* getHandle() const noexcept override;
143 * @brief Represents a blob that contains two planes (Y and UV) in NV12 color format
145 class INFERENCE_ENGINE_API_CLASS(NV12Blob): public CompoundBlob {
148 * @brief A smart pointer to the NV12Blob object
150 using Ptr = std::shared_ptr<NV12Blob>;
153 * @brief A smart pointer to the const NV12Blob object
155 using CPtr = std::shared_ptr<const NV12Blob>;
158 * @brief A deleted default constructor
163 * @brief Constructs NV12 blob from two planes Y and UV
165 * @param y Blob object that represents Y plane in NV12 color format
166 * @param uv Blob object that represents UV plane in NV12 color format
168 NV12Blob(const Blob::Ptr& y, const Blob::Ptr& uv);
171 * @brief Constructs NV12 blob from two planes Y and UV
173 * @param y Blob object that represents Y plane in NV12 color format
174 * @param uv Blob object that represents UV plane in NV12 color format
176 NV12Blob(Blob::Ptr&& y, Blob::Ptr&& uv);
179 * @brief A virtual destructor
181 virtual ~NV12Blob() = default;
184 * @brief A copy constructor
186 NV12Blob(const NV12Blob& blob) = default;
189 * @brief A copy assignment operator
191 NV12Blob& operator=(const NV12Blob& blob) = default;
194 * @brief A move constructor
196 NV12Blob(NV12Blob&& blob) = default;
199 * @brief A move assignment operator
201 NV12Blob& operator=(NV12Blob&& blob) = default;
204 * @brief Returns a shared pointer to Y plane
206 virtual Blob::Ptr& y() noexcept;
209 * @brief Returns a shared pointer to Y plane
211 virtual const Blob::Ptr& y() const noexcept;
214 * @brief Returns a shared pointer to UV plane
216 virtual Blob::Ptr& uv() noexcept;
219 * @brief Returns a shared pointer to UV plane
221 virtual const Blob::Ptr& uv() const noexcept;
225 * @brief Represents a blob that contains three planes (Y,U and V) in I420 color format
227 class INFERENCE_ENGINE_API_CLASS(I420Blob) : public CompoundBlob {
230 * @brief A smart pointer to the I420Blob object
232 using Ptr = std::shared_ptr<I420Blob>;
235 * @brief A smart pointer to the const I420Blob object
237 using CPtr = std::shared_ptr<const I420Blob>;
240 * @brief A deleted default constructor
245 * @brief Constructs I420 blob from three planes Y, U and V
246 * @param y Blob object that represents Y plane in I420 color format
247 * @param u Blob object that represents U plane in I420 color format
248 * @param v Blob object that represents V plane in I420 color format
250 I420Blob(const Blob::Ptr& y, const Blob::Ptr& u, const Blob::Ptr& v);
253 * @brief Constructs I420 blob from three planes Y, U and V
254 * @param y Blob object that represents Y plane in I420 color format
255 * @param u Blob object that represents U plane in I420 color format
256 * @param v Blob object that represents V plane in I420 color format
258 I420Blob(Blob::Ptr&& y, Blob::Ptr&& u, Blob::Ptr&& v);
261 * @brief A virtual destructor. It is made out of line for RTTI to
262 * work correctly on some platforms.
267 * @brief A copy constructor
269 I420Blob(const I420Blob& blob) = default;
272 * @brief A copy assignment operator
274 I420Blob& operator=(const I420Blob& blob) = default;
277 * @brief A move constructor
279 I420Blob(I420Blob&& blob) = default;
282 * @brief A move assignment operator
284 I420Blob& operator=(I420Blob&& blob) = default;
287 * @brief Returns a reference to shared pointer to Y plane
289 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
290 * the I420Blob object is destroyed.
292 * @return reference to shared pointer object of Y plane
294 Blob::Ptr& y() noexcept;
297 * @brief Returns a constant reference to shared pointer to Y plane
299 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
300 * the I420Blob object is destroyed.
302 * @return constant reference to shared pointer object of Y plane*
304 const Blob::Ptr& y() const noexcept;
307 * @brief Returns a reference to shared pointer to U plane
309 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
310 * the I420Blob object is destroyed.
312 * @return reference to shared pointer object of U plane
314 Blob::Ptr& u() noexcept;
317 * @brief Returns a constant reference to shared pointer to U plane
319 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
320 * the I420Blob object is destroyed.
322 * @return constant reference to shared pointer object of U plane
324 const Blob::Ptr& u() const noexcept;
327 * @brief Returns a reference to shared pointer to V plane
329 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
330 * the I420Blob object is destroyed.
332 * @return reference to shared pointer object of V plane
334 Blob::Ptr& v() noexcept;
337 * @brief Returns a constant reference to shared pointer to V plane
339 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
340 * the I420Blob object is destroyed.
342 * @return constant reference to shared pointer object of V plane
344 const Blob::Ptr& v() const noexcept;
346 } // namespace InferenceEngine