From e7ffa545a261c031601bb3e9ef2c0a6c6e1a0f48 Mon Sep 17 00:00:00 2001 From: ronag Date: Sat, 18 Feb 2012 21:29:04 +0000 Subject: [PATCH] 2.1.0: changed "const_array" and "mutable_array" into generic "array" with const specialization. git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2452 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- accelerator/cpu/image/image_mixer.cpp | 12 +-- accelerator/cpu/image/image_mixer.h | 2 +- accelerator/ogl/image/image_mixer.cpp | 12 +-- accelerator/ogl/image/image_mixer.h | 2 +- accelerator/ogl/util/buffer.cpp | 3 + accelerator/ogl/util/buffer.h | 6 ++ accelerator/ogl/util/device.cpp | 59 +++++++----- accelerator/ogl/util/device.h | 11 ++- accelerator/ogl/util/texture.cpp | 6 +- accelerator/ogl/util/texture.h | 12 ++- common/memory/array.cpp | 70 -------------- common/memory/array.h | 133 ++++++++++++++++++-------- core/frame/frame.cpp | 24 ++--- core/frame/frame.h | 16 ++-- core/mixer/image/image_mixer.h | 2 +- shell/casparcg.config | 2 +- 16 files changed, 190 insertions(+), 182 deletions(-) diff --git a/accelerator/cpu/image/image_mixer.cpp b/accelerator/cpu/image/image_mixer.cpp index 00e4253d8..24659c1a7 100644 --- a/accelerator/cpu/image/image_mixer.cpp +++ b/accelerator/cpu/image/image_mixer.cpp @@ -155,7 +155,7 @@ class image_renderer tbb::concurrent_unordered_map>> sws_devices_; tbb::concurrent_bounded_queue> temp_buffers_; public: - boost::unique_future operator()(std::vector items, const core::video_format_desc& format_desc) + boost::unique_future> operator()(std::vector items, const core::video_format_desc& format_desc) { convert(items, format_desc.width, format_desc.height); @@ -174,7 +174,7 @@ public: return async(launch::deferred, [=] { - return core::const_array(result->data(), format_desc.size, true, result); + return array(result->data(), format_desc.size, true, result); }); } @@ -347,18 +347,18 @@ public: { } - boost::unique_future render(const core::video_format_desc& format_desc) + boost::unique_future> render(const core::video_format_desc& format_desc) { return renderer_(std::move(items_), format_desc); } virtual core::mutable_frame create_frame(const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) { - std::vector buffers; + std::vector> buffers; BOOST_FOREACH(auto& plane, desc.planes) { auto buf = spl::make_shared(plane.size); - buffers.push_back(core::mutable_array(buf->data(), plane.size, true, buf)); + buffers.push_back(array(buf->data(), plane.size, true, buf)); } return core::mutable_frame(std::move(buffers), core::audio_buffer(), tag, desc, frame_rate, field_mode); } @@ -369,7 +369,7 @@ image_mixer::~image_mixer(){} void image_mixer::push(const core::frame_transform& transform){impl_->push(transform);} void image_mixer::visit(const core::const_frame& frame){impl_->visit(frame);} void image_mixer::pop(){impl_->pop();} -boost::unique_future image_mixer::operator()(const core::video_format_desc& format_desc){return impl_->render(format_desc);} +boost::unique_future> image_mixer::operator()(const core::video_format_desc& format_desc){return impl_->render(format_desc);} void image_mixer::begin_layer(core::blend_mode blend_mode){impl_->begin_layer(blend_mode);} void image_mixer::end_layer(){impl_->end_layer();} core::mutable_frame image_mixer::create_frame(const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) {return impl_->create_frame(tag, desc, frame_rate, field_mode);} diff --git a/accelerator/cpu/image/image_mixer.h b/accelerator/cpu/image/image_mixer.h index f09cc3cef..21fe8fd6a 100644 --- a/accelerator/cpu/image/image_mixer.h +++ b/accelerator/cpu/image/image_mixer.h @@ -42,7 +42,7 @@ public: virtual void visit(const core::const_frame& frame); virtual void pop(); - virtual boost::unique_future operator()(const core::video_format_desc& format_desc) override; + virtual boost::unique_future> operator()(const core::video_format_desc& format_desc) override; virtual core::mutable_frame create_frame(const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) override; diff --git a/accelerator/ogl/image/image_mixer.cpp b/accelerator/ogl/image/image_mixer.cpp index 82672c57b..aa0359b12 100644 --- a/accelerator/ogl/image/image_mixer.cpp +++ b/accelerator/ogl/image/image_mixer.cpp @@ -96,18 +96,18 @@ public: { } - boost::unique_future operator()(std::vector layers, const core::video_format_desc& format_desc) + boost::unique_future> operator()(std::vector layers, const core::video_format_desc& format_desc) { if(layers.empty()) { // Bypass GPU with empty frame. auto buffer = spl::make_shared>>(format_desc.size, 0); return async(launch::deferred, [=] { - return core::const_array(buffer->data(), format_desc.size, true, buffer); + return array(buffer->data(), format_desc.size, true, buffer); }); } - return flatten(ogl_->begin_invoke([=]() mutable -> boost::shared_future + return flatten(ogl_->begin_invoke([=]() mutable -> boost::shared_future> { auto draw_buffer = create_mixer_buffer(format_desc.width, format_desc.height, 4); @@ -328,14 +328,14 @@ public: { } - boost::unique_future render(const core::video_format_desc& format_desc) + boost::unique_future> render(const core::video_format_desc& format_desc) { return renderer_(std::move(layers_), format_desc); } virtual core::mutable_frame create_frame(const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) { - std::vector buffers; + std::vector> buffers; BOOST_FOREACH(auto& plane, desc.planes) buffers.push_back(ogl_->create_array(plane.size)); @@ -348,7 +348,7 @@ image_mixer::~image_mixer(){} void image_mixer::push(const core::frame_transform& transform){impl_->push(transform);} void image_mixer::visit(const core::const_frame& frame){impl_->visit(frame);} void image_mixer::pop(){impl_->pop();} -boost::unique_future image_mixer::operator()(const core::video_format_desc& format_desc){return impl_->render(format_desc);} +boost::unique_future> image_mixer::operator()(const core::video_format_desc& format_desc){return impl_->render(format_desc);} void image_mixer::begin_layer(core::blend_mode blend_mode){impl_->begin_layer(blend_mode);} void image_mixer::end_layer(){impl_->end_layer();} core::mutable_frame image_mixer::create_frame(const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) {return impl_->create_frame(tag, desc, frame_rate, field_mode);} diff --git a/accelerator/ogl/image/image_mixer.h b/accelerator/ogl/image/image_mixer.h index d53a62668..4e5b46e11 100644 --- a/accelerator/ogl/image/image_mixer.h +++ b/accelerator/ogl/image/image_mixer.h @@ -54,7 +54,7 @@ public: // Methods - virtual boost::unique_future operator()(const core::video_format_desc& format_desc) override; + virtual boost::unique_future> operator()(const core::video_format_desc& format_desc) override; virtual core::mutable_frame create_frame(const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) override; // core::image_mixer diff --git a/accelerator/ogl/util/buffer.cpp b/accelerator/ogl/util/buffer.cpp index 367283cbd..2c401b2a4 100644 --- a/accelerator/ogl/util/buffer.cpp +++ b/accelerator/ogl/util/buffer.cpp @@ -113,12 +113,15 @@ public: }; buffer::buffer(std::size_t size, usage usage) : impl_(new impl(size, usage)){} +buffer::buffer(buffer&& other) : impl_(std::move(other.impl_)){} buffer::~buffer(){} +buffer& buffer::operator=(buffer&& other){impl_ = std::move(other.impl_); return *this;} uint8_t* buffer::data(){return impl_->data_;} void buffer::map(){impl_->map();} void buffer::unmap(){impl_->unmap();} void buffer::bind() const{impl_->bind();} void buffer::unbind() const{impl_->unbind();} std::size_t buffer::size() const { return impl_->size_; } +int buffer::id() const {return impl_->pbo_;} }}} \ No newline at end of file diff --git a/accelerator/ogl/util/buffer.h b/accelerator/ogl/util/buffer.h index 45d4e6a27..7fcdb8ea6 100644 --- a/accelerator/ogl/util/buffer.h +++ b/accelerator/ogl/util/buffer.h @@ -49,9 +49,12 @@ public: // Constructors buffer(std::size_t size, usage usage); + buffer(buffer&& other); ~buffer(); // Methods + + buffer& operator=(buffer&& other); void map(); void unmap(); @@ -63,6 +66,9 @@ public: uint8_t* data(); std::size_t size() const; + + int id() const; + private: struct impl; spl::unique_ptr impl_; diff --git a/accelerator/ogl/util/device.cpp b/accelerator/ogl/util/device.cpp index 706e6119a..6d1066774 100644 --- a/accelerator/ogl/util/device.cpp +++ b/accelerator/ogl/util/device.cpp @@ -36,7 +36,6 @@ #include #include - #include #include @@ -60,13 +59,13 @@ struct device::impl : public std::enable_shared_from_this { static_assert(std::is_same().impl_), spl::shared_ptr>::value, "impl_ must be shared_ptr"); - tbb::concurrent_hash_map> texture_mapping_; + tbb::concurrent_hash_map> texture_cache_; std::unique_ptr device_; std::unique_ptr host_alloc_device_; - std::array>>, 4> device_pools_; - std::array>>, 2> host_pools_; + std::array>>, 4> device_pools_; + std::array>>, 2> host_pools_; GLuint fbo_; @@ -172,7 +171,7 @@ struct device::impl : public std::enable_shared_from_this }); } - spl::shared_ptr create_buffer(int size, buffer::usage usage) + spl::shared_ptr create_buffer(std::size_t size, buffer::usage usage) { CASPAR_VERIFY(size > 0); @@ -197,7 +196,7 @@ struct device::impl : public std::enable_shared_from_this else buf->unmap(); - self->texture_mapping_.erase(buf.get()); + self->texture_cache_.erase(buf.get()); pool->push(buf); }; @@ -208,46 +207,59 @@ struct device::impl : public std::enable_shared_from_this }); } - core::mutable_array create_array(int size) + array create_array(std::size_t size) { auto buf = create_buffer(size, buffer::usage::write_only); - return core::mutable_array(buf->data(), buf->size(), false, buf); + return array(buf->data(), buf->size(), false, buf); } - boost::unique_future> copy_async(const core::const_array& source, int width, int height, int stride) + boost::unique_future> copy_async(const array& source, int width, int height, int stride) { auto buf = source.storage>(); return render_executor_.begin_invoke([=]() -> spl::shared_ptr { tbb::concurrent_hash_map>::const_accessor a; - if(texture_mapping_.find(a, buf.get())) + if(texture_cache_.find(a, buf.get())) return spl::make_shared_ptr(a->second); auto texture = create_texture(width, height, stride); texture->copy_from(*buf); - texture_mapping_.insert(std::make_pair(buf.get(), texture)); + texture_cache_.insert(std::make_pair(buf.get(), texture)); return texture; }, task_priority::high_priority); } + + boost::unique_future> copy_async(const array& source, int width, int height, int stride) + { + auto buf = source.storage>(); + + return render_executor_.begin_invoke([=]() -> spl::shared_ptr + { + auto texture = create_texture(width, height, stride); + texture->copy_from(*buf); + return texture; + }, task_priority::high_priority); + } - boost::unique_future copy_async(const spl::shared_ptr& source) + boost::unique_future> copy_async(const spl::shared_ptr& source) { - return flatten(render_executor_.begin_invoke([=]() -> boost::shared_future + return flatten(render_executor_.begin_invoke([=]() -> boost::shared_future> { auto buffer = create_buffer(source->size(), buffer::usage::read_only); source->copy_to(*buffer); - return make_shared(async(launch::deferred, [=]() mutable -> core::const_array + auto self = shared_from_this(); + return make_shared(async(launch::deferred, [self, buffer]() mutable -> array { const auto& buf = buffer.get(); if(!buf->data()) - alloc_executor_.invoke(std::bind(&buffer::map, std::ref(buf))); // Defer blocking "map" call until data is needed. + self->alloc_executor_.invoke(std::bind(&buffer::map, std::ref(buf))); // Defer blocking "map" call until data is needed. - return core::const_array(buf->data(), buf->size(), true, buffer); + return array(buf->data(), buf->size(), true, buffer); })); }, task_priority::high_priority)); } @@ -255,15 +267,14 @@ struct device::impl : public std::enable_shared_from_this device::device() : executor_(L"OpenGL Rendering Context.") - , impl_(new impl(executor_)) -{ -} -device::~device(){} + , impl_(new impl(executor_)){} +device::~device(){} spl::shared_ptr device::create_texture(int width, int height, int stride){return impl_->create_texture(width, height, stride);} -core::mutable_array device::create_array(int size){return impl_->create_array(size);} -boost::unique_future> device::copy_async(const core::const_array& source, int width, int height, int stride){return impl_->copy_async(source, width, height, stride);} -boost::unique_future device::copy_async(const spl::shared_ptr& source){return impl_->copy_async(source);} -std::wstring device::version(){return impl_->version();} +array device::create_array(int size){return impl_->create_array(size);} +boost::unique_future> device::copy_async(const array& source, int width, int height, int stride){return impl_->copy_async(source, width, height, stride);} +boost::unique_future> device::copy_async(const array& source, int width, int height, int stride){return impl_->copy_async(source, width, height, stride);} +boost::unique_future> device::copy_async(const spl::shared_ptr& source){return impl_->copy_async(source);} +std::wstring device::version() const{return impl_->version();} }}} diff --git a/accelerator/ogl/util/device.h b/accelerator/ogl/util/device.h index f7e41d3be..f41cc56a1 100644 --- a/accelerator/ogl/util/device.h +++ b/accelerator/ogl/util/device.h @@ -46,12 +46,13 @@ public: ~device(); // Methods - + spl::shared_ptr create_texture(int width, int height, int stride); - core::mutable_array create_array(int size); + array create_array(int size); - boost::unique_future> copy_async(const core::const_array& source, int width, int height, int stride); - boost::unique_future copy_async(const spl::shared_ptr& source); + boost::unique_future> copy_async(const array& source, int width, int height, int stride); + boost::unique_future> copy_async(const array& source, int width, int height, int stride); + boost::unique_future> copy_async(const spl::shared_ptr& source); template auto begin_invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> boost::unique_future // noexcept @@ -67,7 +68,7 @@ public: // Properties - std::wstring version(); + std::wstring version() const; private: struct impl; diff --git a/accelerator/ogl/util/texture.cpp b/accelerator/ogl/util/texture.cpp index f02ff1b0b..a1b7af209 100644 --- a/accelerator/ogl/util/texture.cpp +++ b/accelerator/ogl/util/texture.cpp @@ -49,7 +49,7 @@ static tbb::atomic g_total_count; struct texture::impl : boost::noncopyable { - GLuint id_; + GLuint id_; const int width_; const int height_; @@ -127,7 +127,9 @@ public: }; texture::texture(int width, int height, int stride) : impl_(new impl(width, height, stride)){} +texture::texture(texture&& other) : impl_(std::move(other.impl_)){} texture::~texture(){} +texture& texture::operator=(texture&& other){impl_ = std::move(other.impl_); return *this;} void texture::bind(int index){impl_->bind(index);} void texture::unbind(){impl_->unbind();} void texture::attach(){impl_->attach();} @@ -136,8 +138,8 @@ void texture::copy_from(buffer& source){impl_->copy_from(source);} void texture::copy_to(buffer& dest){impl_->copy_to(dest);} int texture::width() const { return impl_->width_; } int texture::height() const { return impl_->height_; } -int texture::size() const { return impl_->width_*impl_->height_*impl_->stride_; } int texture::stride() const { return impl_->stride_; } +std::size_t texture::size() const { return static_cast(impl_->width_*impl_->height_*impl_->stride_); } int texture::id() const{ return impl_->id_;} }}} \ No newline at end of file diff --git a/accelerator/ogl/util/texture.h b/accelerator/ogl/util/texture.h index 8817a1249..1f05b9c47 100644 --- a/accelerator/ogl/util/texture.h +++ b/accelerator/ogl/util/texture.h @@ -22,9 +22,8 @@ #pragma once #include -#include -FORWARD1(boost, template class unique_future); +#include namespace caspar { namespace accelerator { namespace ogl { @@ -42,9 +41,12 @@ public: // Constructors texture(int width, int height, int stride); + texture(texture&& other); ~texture(); - + // Methods + + texture& operator=(texture&& other); void copy_from(buffer& source); void copy_to(buffer& dest); @@ -58,9 +60,11 @@ public: int width() const; int height() const; - int size() const; int stride() const; + std::size_t size() const; + int id() const; + private: struct impl; spl::unique_ptr impl_; diff --git a/common/memory/array.cpp b/common/memory/array.cpp index f635d0e28..7cb0ab764 100644 --- a/common/memory/array.cpp +++ b/common/memory/array.cpp @@ -26,75 +26,5 @@ #include "../assert.h" namespace caspar { namespace core { - -mutable_array::mutable_array(mutable_array&& other) - : ptr_(other.ptr_) - , size_(other.size_) - , cacheable_(other.cacheable_) - , storage_(std::move(other.storage_)) -{ - CASPAR_ASSERT(storage_); -} - -mutable_array& mutable_array::operator=(mutable_array&& other) -{ - ptr_ = other.ptr_; - size_ = other.size_; - cacheable_ = other.cacheable_; - storage_ = std::move(other.storage_); - - CASPAR_ASSERT(storage_); - - return *this; -} - -std::uint8_t* mutable_array::begin() {return ptr_;} -std::uint8_t* mutable_array::data() {return ptr_;} -std::uint8_t* mutable_array::end() {return ptr_ + size_;} -const std::uint8_t* mutable_array::begin() const {return ptr_;} -const std::uint8_t* mutable_array::data() const {return ptr_;} -const std::uint8_t* mutable_array::end() const {return ptr_ + size_;} -std::size_t mutable_array::size() const {return size_;} -bool mutable_array::empty() const {return size() == 0;} -bool mutable_array::cacheable() const {return cacheable_;} - -const_array::const_array(const const_array& other) - : ptr_(other.ptr_) - , size_(other.size_) - , cacheable_(other.cacheable_) - , storage_(other.storage_) -{ - CASPAR_ASSERT(storage_); -} - -const_array::const_array(mutable_array&& other) - : ptr_(other.ptr_) - , size_(other.size_) - , cacheable_(other.cacheable_) - , storage_(std::move(other.storage_)) -{ - CASPAR_ASSERT(storage_); -} - -const_array& const_array::operator=(const const_array& other) -{ - const_array(other).swap(*this); - return *this; -} - -void const_array::swap(const_array& other) -{ - ptr_ = other.ptr_; - size_ = other.size_; - storage_ = other.storage_; - cacheable_ = other.cacheable_; -} - -const std::uint8_t* const_array::begin() const {return ptr_;} -const std::uint8_t* const_array::data() const {return ptr_;} -const std::uint8_t* const_array::end() const {return ptr_ + size_;} -std::size_t const_array::size() const {return size_;} -bool const_array::empty() const {return size() == 0;} -bool const_array::cacheable() const {return cacheable_;} }} \ No newline at end of file diff --git a/common/memory/array.h b/common/memory/array.h index 90e649e7e..b283e276d 100644 --- a/common/memory/array.h +++ b/common/memory/array.h @@ -10,14 +10,15 @@ FORWARD1(boost, template class shared_future); -namespace caspar { namespace core { +namespace caspar { -class mutable_array +template +class array sealed { - mutable_array(const mutable_array&); - mutable_array& operator=(const mutable_array&); + array(const array&); + array& operator=(const array&); - friend class const_array; + template friend class array; public: // Static Members @@ -25,7 +26,7 @@ public: // Constructors template - explicit mutable_array(std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage) + explicit array(std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage) : ptr_(ptr) , size_(size) , cacheable_(cacheable) @@ -33,23 +34,37 @@ public: { } - mutable_array(mutable_array&& other); + array(array&& other) + : ptr_(other.ptr_) + , size_(other.size_) + , cacheable_(other.cacheable_) + , storage_(std::move(other.storage_)) + { + CASPAR_ASSERT(storage_); + } // Methods + + array& operator=(array&& other) + { + ptr_ = other.ptr_; + size_ = other.size_; + cacheable_ = other.cacheable_; + storage_ = std::move(other.storage_); - mutable_array& operator=(mutable_array&& other); + CASPAR_ASSERT(storage_); - // Properties - - std::uint8_t* begin(); - std::uint8_t* data(); - std::uint8_t* end(); - const std::uint8_t* begin() const; - const std::uint8_t* data() const; - const std::uint8_t* end() const; - std::size_t size() const; - bool empty() const; - bool cacheable() const; + return *this; + } + + // Properties + + T* begin() const {return ptr_;} + T* data() const {return ptr_;} + T* end() const {return reinterpret_cast(reinterpret_cast(ptr_) + size_);} + std::size_t size() const {return size_;} + bool empty() const {return size() == 0;} + bool cacheable() const {return cacheable_;} template T storage() const @@ -57,13 +72,14 @@ public: return boost::any_cast(*storage_); } private: - std::uint8_t* ptr_; - std::size_t size_; - bool cacheable_; + T* ptr_; + std::size_t size_; + bool cacheable_; std::unique_ptr storage_; }; -class const_array +template +class array sealed { public: @@ -72,7 +88,7 @@ public: // Constructors template - explicit const_array(const std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage) + explicit array(const std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage) : ptr_(ptr) , size_(size) , cacheable_(cacheable) @@ -80,23 +96,49 @@ public: { } - const_array(const const_array& other); - const_array(mutable_array&& other); + array(const array& other) + : ptr_(other.ptr_) + , size_(other.size_) + , cacheable_(other.cacheable_) + , storage_(other.storage_) + { + CASPAR_ASSERT(storage_); + } + + array(array&& other) + : ptr_(other.ptr_) + , size_(other.size_) + , cacheable_(other.cacheable_) + , storage_(std::move(other.storage_)) + { + CASPAR_ASSERT(storage_); + } // Methods - const_array& operator=(const const_array& other); - void swap(const_array& other); + array& operator=(array other) + { + other.swap(*this); + return *this; + } - // Properties - - const std::uint8_t* begin() const; - const std::uint8_t* data() const; - const std::uint8_t* end() const; - std::size_t size() const; - bool empty() const; - bool cacheable() const; + void swap(array& other) + { + ptr_ = other.ptr_; + size_ = other.size_; + storage_ = other.storage_; + cacheable_ = other.cacheable_; + } + // Properties + + const T* begin() const {return ptr_;} + const T* data() const {return ptr_;} + const T* end() const {return reinterpret_cast(reinterpret_cast(ptr_) + size_);} + std::size_t size() const {return size_;} + bool empty() const {return size() == 0;} + bool cacheable() const {return cacheable_;} + template T storage() const { @@ -104,10 +146,21 @@ public: } private: - const std::uint8_t* ptr_; - std::size_t size_; - bool cacheable_; + const T* ptr_; + std::size_t size_; + bool cacheable_; std::shared_ptr storage_; }; -}} \ No newline at end of file +} + +namespace std { + +template +void swap(caspar::array& lhs, caspar::array& rhs) +{ + lhs.swap(rhs); +} + +} + diff --git a/core/frame/frame.cpp b/core/frame/frame.cpp index 34ad6887e..31f7cba96 100644 --- a/core/frame/frame.cpp +++ b/core/frame/frame.cpp @@ -36,14 +36,14 @@ namespace caspar { namespace core { struct mutable_frame::impl : boost::noncopyable { - std::vector buffers_; + std::vector> buffers_; core::audio_buffer audio_data_; const core::pixel_format_desc desc_; const void* tag_; double frame_rate_; core::field_mode field_mode_; - impl(std::vector buffers, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) + impl(std::vector> buffers, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) : buffers_(std::move(buffers)) , audio_data_(std::move(audio_buffer)) , desc_(desc) @@ -57,7 +57,7 @@ struct mutable_frame::impl : boost::noncopyable } }; -mutable_frame::mutable_frame(std::vector image_buffers, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) +mutable_frame::mutable_frame(std::vector> image_buffers, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) : impl_(new impl(std::move(image_buffers), std::move(audio_buffer), tag, desc, frame_rate, field_mode)){} mutable_frame::~mutable_frame(){} mutable_frame::mutable_frame(mutable_frame&& other) : impl_(std::move(other.impl_)){} @@ -68,9 +68,9 @@ mutable_frame& mutable_frame::operator=(mutable_frame&& other) } void mutable_frame::swap(mutable_frame& other){impl_.swap(other.impl_);} const core::pixel_format_desc& mutable_frame::pixel_format_desc() const{return impl_->desc_;} -const mutable_array& mutable_frame::image_data(std::size_t index) const{return impl_->buffers_.at(index);} +const array& mutable_frame::image_data(std::size_t index) const{return impl_->buffers_.at(index);} const core::audio_buffer& mutable_frame::audio_data() const{return impl_->audio_data_;} -mutable_array& mutable_frame::image_data(std::size_t index){return impl_->buffers_.at(index);} +array& mutable_frame::image_data(std::size_t index){return impl_->buffers_.at(index);} core::audio_buffer& mutable_frame::audio_data(){return impl_->audio_data_;} double mutable_frame::frame_rate() const{return impl_->frame_rate_;} core::field_mode mutable_frame::field_mode() const{return impl_->field_mode_;} @@ -88,7 +88,7 @@ const const_frame& const_frame::empty() struct const_frame::impl : boost::noncopyable { - mutable std::vector> future_buffers_; + mutable std::vector>> future_buffers_; int id_; core::audio_buffer audio_data_; const core::pixel_format_desc desc_; @@ -104,7 +104,7 @@ struct const_frame::impl : boost::noncopyable { } - impl(boost::shared_future image, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) + impl(boost::shared_future> image, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) : audio_data_(std::move(audio_buffer)) , desc_(desc) , tag_(tag) @@ -128,15 +128,15 @@ struct const_frame::impl : boost::noncopyable { for(std::size_t n = 0; n < desc_.planes.size(); ++n) { - boost::promise p; + boost::promise> p; p.set_value(std::move(other.image_data(n))); future_buffers_.push_back(p.get_future()); } } - const_array image_data(int index) const + array image_data(int index) const { - return tag_ != empty().tag() ? future_buffers_.at(index).get() : const_array(nullptr, 0, true, 0); + return tag_ != empty().tag() ? future_buffers_.at(index).get() : array(nullptr, 0, true, 0); } std::size_t width() const @@ -161,7 +161,7 @@ struct const_frame::impl : boost::noncopyable }; const_frame::const_frame(const void* tag) : impl_(new impl(tag)){} -const_frame::const_frame(boost::shared_future image, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) +const_frame::const_frame(boost::shared_future> image, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) : impl_(new impl(std::move(image), std::move(audio_buffer), tag, desc, frame_rate, field_mode)){} const_frame::const_frame(mutable_frame&& other) : impl_(new impl(std::move(other))){} const_frame::~const_frame(){} @@ -180,7 +180,7 @@ const_frame& const_frame::operator=(const const_frame& other) bool const_frame::operator==(const const_frame& other){return *impl_ == *other.impl_;} bool const_frame::operator!=(const const_frame& other){return !(*this == other);} const core::pixel_format_desc& const_frame::pixel_format_desc()const{return impl_->desc_;} -const_array const_frame::image_data(int index)const{return impl_->image_data(index);} +array const_frame::image_data(int index)const{return impl_->image_data(index);} const core::audio_buffer& const_frame::audio_data()const{return impl_->audio_data_;} double const_frame::frame_rate()const{return impl_->frame_rate_;} core::field_mode const_frame::field_mode()const{return impl_->field_mode_;} diff --git a/core/frame/frame.h b/core/frame/frame.h index ef497f123..056631d95 100644 --- a/core/frame/frame.h +++ b/core/frame/frame.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -16,10 +17,7 @@ FORWARD1(boost, template class shared_future); namespace caspar { namespace core { - -class const_array; -class mutable_array; - + typedef std::vector> audio_buffer; class mutable_frame sealed @@ -32,7 +30,7 @@ public: // Constructors - explicit mutable_frame(std::vector image_buffers, + explicit mutable_frame(std::vector> image_buffers, audio_buffer audio_buffer, const void* tag, const struct pixel_format_desc& desc, @@ -51,10 +49,10 @@ public: const struct pixel_format_desc& pixel_format_desc() const; - const mutable_array& image_data(std::size_t index = 0) const; + const array& image_data(std::size_t index = 0) const; const core::audio_buffer& audio_data() const; - mutable_array& image_data(std::size_t index = 0); + array& image_data(std::size_t index = 0); core::audio_buffer& audio_data(); double frame_rate() const; @@ -81,7 +79,7 @@ public: // Constructors explicit const_frame(const void* tag = nullptr); - explicit const_frame(boost::shared_future image, + explicit const_frame(boost::shared_future> image, audio_buffer audio_buffer, const void* tag, const struct pixel_format_desc& desc, @@ -101,7 +99,7 @@ public: const struct pixel_format_desc& pixel_format_desc() const; - const_array image_data(int index = 0) const; + array image_data(int index = 0) const; const core::audio_buffer& audio_data() const; double frame_rate() const; diff --git a/core/mixer/image/image_mixer.h b/core/mixer/image/image_mixer.h index 9f4c3658a..7f914e203 100644 --- a/core/mixer/image/image_mixer.h +++ b/core/mixer/image/image_mixer.h @@ -64,7 +64,7 @@ public: virtual void begin_layer(blend_mode blend_mode) = 0; virtual void end_layer() = 0; - virtual boost::unique_future operator()(const struct video_format_desc& format_desc) = 0; + virtual boost::unique_future> operator()(const struct video_format_desc& format_desc) = 0; virtual class mutable_frame create_frame(const void* tag, const struct pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) = 0; diff --git a/shell/casparcg.config b/shell/casparcg.config index 2a14bf41e..e63c4212d 100644 --- a/shell/casparcg.config +++ b/shell/casparcg.config @@ -7,7 +7,7 @@ D:\casparcg\_templates\ trace - gpu + auto 4 -- 2.39.2