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;
120 Blob::Ptr createROI(const ROI& roi) const override;
124 * @brief A default constructor
129 * @brief Compound blob container for underlying blobs
131 std::vector<Blob::Ptr> _blobs;
134 * @brief Returns nullptr as CompoundBlob is not allocator-based
136 const std::shared_ptr<IAllocator>& getAllocator() const noexcept override;
139 * @brief Returns nullptr as CompoundBlob is not allocator-based
141 void* getHandle() const noexcept override;
145 * @brief Represents a blob that contains two planes (Y and UV) in NV12 color format
147 class INFERENCE_ENGINE_API_CLASS(NV12Blob): public CompoundBlob {
150 * @brief A smart pointer to the NV12Blob object
152 using Ptr = std::shared_ptr<NV12Blob>;
155 * @brief A smart pointer to the const NV12Blob object
157 using CPtr = std::shared_ptr<const NV12Blob>;
160 * @brief A deleted default constructor
165 * @brief Constructs NV12 blob from two planes Y and UV
167 * @param y Blob object that represents Y plane in NV12 color format
168 * @param uv Blob object that represents UV plane in NV12 color format
170 NV12Blob(const Blob::Ptr& y, const Blob::Ptr& uv);
173 * @brief Constructs NV12 blob from two planes Y and UV
175 * @param y Blob object that represents Y plane in NV12 color format
176 * @param uv Blob object that represents UV plane in NV12 color format
178 NV12Blob(Blob::Ptr&& y, Blob::Ptr&& uv);
181 * @brief A virtual destructor
183 virtual ~NV12Blob() = default;
186 * @brief A copy constructor
188 NV12Blob(const NV12Blob& blob) = default;
191 * @brief A copy assignment operator
193 NV12Blob& operator=(const NV12Blob& blob) = default;
196 * @brief A move constructor
198 NV12Blob(NV12Blob&& blob) = default;
201 * @brief A move assignment operator
203 NV12Blob& operator=(NV12Blob&& blob) = default;
206 * @brief Returns a shared pointer to Y plane
208 virtual Blob::Ptr& y() noexcept;
211 * @brief Returns a shared pointer to Y plane
213 virtual const Blob::Ptr& y() const noexcept;
216 * @brief Returns a shared pointer to UV plane
218 virtual Blob::Ptr& uv() noexcept;
221 * @brief Returns a shared pointer to UV plane
223 virtual const Blob::Ptr& uv() const noexcept;
225 Blob::Ptr createROI(const ROI& roi) const override;
229 * @brief Represents a blob that contains three planes (Y,U and V) in I420 color format
231 class INFERENCE_ENGINE_API_CLASS(I420Blob) : public CompoundBlob {
234 * @brief A smart pointer to the I420Blob object
236 using Ptr = std::shared_ptr<I420Blob>;
239 * @brief A smart pointer to the const I420Blob object
241 using CPtr = std::shared_ptr<const I420Blob>;
244 * @brief A deleted default constructor
249 * @brief Constructs I420 blob from three planes Y, U and V
250 * @param y Blob object that represents Y plane in I420 color format
251 * @param u Blob object that represents U plane in I420 color format
252 * @param v Blob object that represents V plane in I420 color format
254 I420Blob(const Blob::Ptr& y, const Blob::Ptr& u, const Blob::Ptr& v);
257 * @brief Constructs I420 blob from three planes Y, U and V
258 * @param y Blob object that represents Y plane in I420 color format
259 * @param u Blob object that represents U plane in I420 color format
260 * @param v Blob object that represents V plane in I420 color format
262 I420Blob(Blob::Ptr&& y, Blob::Ptr&& u, Blob::Ptr&& v);
265 * @brief A virtual destructor. It is made out of line for RTTI to
266 * work correctly on some platforms.
271 * @brief A copy constructor
273 I420Blob(const I420Blob& blob) = default;
276 * @brief A copy assignment operator
278 I420Blob& operator=(const I420Blob& blob) = default;
281 * @brief A move constructor
283 I420Blob(I420Blob&& blob) = default;
286 * @brief A move assignment operator
288 I420Blob& operator=(I420Blob&& blob) = default;
291 * @brief Returns a reference to shared pointer to Y plane
293 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
294 * the I420Blob object is destroyed.
296 * @return reference to shared pointer object of Y plane
298 Blob::Ptr& y() noexcept;
301 * @brief Returns a constant reference to shared pointer to Y plane
303 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
304 * the I420Blob object is destroyed.
306 * @return constant reference to shared pointer object of Y plane*
308 const Blob::Ptr& y() const noexcept;
311 * @brief Returns a reference to shared pointer to U plane
313 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
314 * the I420Blob object is destroyed.
316 * @return reference to shared pointer object of U plane
318 Blob::Ptr& u() noexcept;
321 * @brief Returns a constant reference to shared pointer to U plane
323 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
324 * the I420Blob object is destroyed.
326 * @return constant reference to shared pointer object of U plane
328 const Blob::Ptr& u() const noexcept;
331 * @brief Returns a reference to shared pointer to V plane
333 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
334 * the I420Blob object is destroyed.
336 * @return reference to shared pointer object of V plane
338 Blob::Ptr& v() noexcept;
341 * @brief Returns a constant reference to shared pointer to V plane
343 * Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
344 * the I420Blob object is destroyed.
346 * @return constant reference to shared pointer object of V plane
348 const Blob::Ptr& v() const noexcept;
350 Blob::Ptr createROI(const ROI& roi) const override;
352 } // namespace InferenceEngine