3 #include "../video_format.h"
\r
5 #include <common/spl/memory.h>
\r
6 #include <common/forward.h>
\r
8 #include <boost/range.hpp>
\r
9 #include <boost/any.hpp>
\r
11 #include <tbb/cache_aligned_allocator.h>
\r
16 FORWARD1(boost, template<typename> class shared_future);
\r
18 namespace caspar { namespace core {
\r
28 template<typename T>
\r
29 explicit const_array(const uint8_t* ptr, std::size_t size, T&& storage)
\r
32 , storage_(new boost::any(std::forward<T>(storage)))
\r
36 const_array(const const_array& other)
\r
38 , size_(other.size_)
\r
39 , storage_(other.storage_)
\r
43 const_array(const_array&& other)
\r
45 , size_(other.size_)
\r
46 , storage_(std::move(other.storage_))
\r
52 const_array& operator=(const_array other)
\r
58 void swap(const_array& other)
\r
60 std::swap(ptr_, other.ptr_);
\r
61 std::swap(size_, other.size_);
\r
62 std::swap(storage_, other.storage_);
\r
67 const uint8_t* begin() const {return ptr_;}
\r
68 const uint8_t* data() const {return ptr_;}
\r
69 const uint8_t* end() const {return ptr_ + size_;}
\r
70 std::size_t size() const {return size_;}
\r
71 bool empty() const {return size() == 0;}
\r
74 const uint8_t* ptr_;
\r
76 spl::shared_ptr<boost::any> storage_;
\r
81 mutable_array(const mutable_array&);
\r
82 mutable_array& operator=(const mutable_array&);
\r
89 template<typename T>
\r
90 explicit mutable_array(uint8_t* ptr, std::size_t size, T&& storage)
\r
93 , storage_(new boost::any(std::forward<T>(storage)))
\r
97 mutable_array(mutable_array&& other)
\r
99 , size_(other.size_)
\r
100 , storage_(std::move(other.storage_))
\r
106 mutable_array& operator=(mutable_array&& other)
\r
109 size_ = other.size_;
\r
110 storage_ = std::move(other.storage_);
\r
116 uint8_t* begin() {return ptr_;}
\r
117 uint8_t* data() {return ptr_;}
\r
118 uint8_t* end() {return ptr_ + size_;}
\r
119 const uint8_t* begin() const {return ptr_;}
\r
120 const uint8_t* data() const {return ptr_;}
\r
121 const uint8_t* end() const {return ptr_ + size_;}
\r
122 std::size_t size() const {return size_;}
\r
123 bool empty() const {return size() == 0;}
\r
124 const boost::any& storage() const {return *storage_;}
\r
129 spl::unique_ptr<boost::any> storage_;
\r
132 typedef std::vector<int32_t, tbb::cache_aligned_allocator<int32_t>> audio_buffer;
\r
134 class const_frame sealed
\r
140 static const const_frame& empty();
\r
144 explicit const_frame(const void* tag = nullptr);
\r
145 explicit const_frame(boost::shared_future<const_array> image,
\r
146 audio_buffer audio_buffer,
\r
148 const struct pixel_format_desc& desc,
\r
149 double frame_rate,
\r
150 core::field_mode field_mode);
\r
155 const_frame(const_frame&& other);
\r
156 const_frame& operator=(const_frame&& other);
\r
157 const_frame(const const_frame&);
\r
158 const_frame& operator=(const const_frame& other);
\r
162 const struct pixel_format_desc& pixel_format_desc() const;
\r
164 const_array image_data() const;
\r
165 const core::audio_buffer& audio_data() const;
\r
167 double frame_rate() const;
\r
168 core::field_mode field_mode() const;
\r
170 std::size_t width() const;
\r
171 std::size_t height() const;
\r
172 std::size_t size() const;
\r
174 const void* tag() const;
\r
176 bool operator==(const const_frame& other);
\r
177 bool operator!=(const const_frame& other);
\r
181 spl::shared_ptr<impl> impl_;
\r
184 class mutable_frame sealed
\r
186 mutable_frame(const mutable_frame&);
\r
187 mutable_frame& operator=(const mutable_frame&);
\r
194 explicit mutable_frame(std::vector<mutable_array> image_buffers,
\r
195 audio_buffer audio_buffer,
\r
197 const struct pixel_format_desc& desc,
\r
198 double frame_rate,
\r
199 core::field_mode field_mode);
\r
204 mutable_frame(mutable_frame&& other);
\r
205 mutable_frame& operator=(mutable_frame&& other);
\r
207 void swap(mutable_frame& other);
\r
211 const struct pixel_format_desc& pixel_format_desc() const;
\r
213 const mutable_array& image_data(std::size_t index = 0) const;
\r
214 const core::audio_buffer& audio_data() const;
\r
216 mutable_array& image_data(std::size_t index = 0);
\r
217 core::audio_buffer& audio_data();
\r
219 double frame_rate() const;
\r
220 core::field_mode field_mode() const;
\r
222 std::size_t width() const;
\r
223 std::size_t height() const;
\r
225 const void* tag() const;
\r
229 spl::unique_ptr<impl> impl_;
\r