\r
static void* fast_memcpy(void* dest, const void* source, size_t num)\r
{ \r
+ if(num < 2048)\r
+ return memcpy(dest, source, num);\r
+\r
tbb::affinity_partitioner ap;\r
tbb::parallel_for(tbb::blocked_range<size_t>(0, num/128), [&](const tbb::blocked_range<size_t>& r)\r
{ \r
diag_->add_guide("frame-time", 0.5f); \r
diag_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
diag_->set_color("tick-time", diagnostics::color(0.1f, 0.7f, 0.8f));\r
- diag_->set_color("input-buffer", diagnostics::color(1.0f, 1.0f, 0.0f)); \r
+ diag_->set_color("input-buffer", diagnostics::color(1.0f, 1.0f, 0.0f)); \r
+ executor_.set_capacity(2); \r
executor_.start();\r
- executor_.set_capacity(2);\r
CASPAR_LOG(info) << print() << L" Successfully initialized."; \r
}\r
\r
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
- \r
-// stdafx.cpp : source file that includes just the standard includes\r
-// dma.pch will be the pre-compiled header\r
-// stdafx.obj will contain the pre-compiled type information\r
-\r
-#include "stdafx.h"\r
-\r
-// TODO: reference any additional headers you need in STDAFX.H\r
-// and not in this file\r
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
- \r
-// stdafx.h : include file for standard system include files,\r
-// or project specific include files that are used frequently, but\r
-// are changed infrequently\r
-//\r
-\r
-#pragma once\r
-\r
-#include "../common/compiler/vs/disable_silly_warnings.h"\r
-\r
-#define NOMINMAX\r
-\r
-#if defined(_MSC_VER)\r
-# ifndef _SCL_SECURE_NO_WARNINGS\r
-# define _SCL_SECURE_NO_WARNINGS\r
-# endif\r
-# ifndef _CRT_SECURE_NO_WARNINGS\r
-# define _CRT_SECURE_NO_WARNINGS\r
-# endif\r
-#endif\r
-\r
-#define BOOST_PARAMETER_MAX_ARITY 7\r
-\r
-#ifdef _DEBUG\r
-#include <crtdbg.h>\r
-#endif\r
-\r
-#include <memory>\r
-#include <functional>\r
-#include <algorithm>\r
-#include <vector>\r
-#include <deque>\r
-#include <queue>\r
-#include <string>\r
-#include <math.h>\r
-\r
-#include <tbb/atomic.h>\r
-#include <tbb/concurrent_queue.h>\r
-#include <tbb/concurrent_unordered_map.h>\r
-#include <tbb/parallel_invoke.h>\r
-#include <tbb/parallel_for.h>\r
-#include <tbb/parallel_for_each.h>\r
-\r
-#include <boost/assign.hpp>\r
-#include <boost/filesystem.hpp>\r
-#include <boost/foreach.hpp>\r
-#include <boost/range/algorithm.hpp>\r
-#include <boost/signals2.hpp>\r
-\r
-#include <common/utility/string.h>\r
-#include <common/memory/safe_ptr.h>\r
-//#include <common/concurrency/executor.h> // Can't include this due to MSVC lambda bug\r
-\r
-#include <common/log/Log.h>\r
-#include <common/exception/exceptions.h>\r
-#include <common/exception/win32_exception.h>\r
-#include <common/utility/assert.h>\r
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "audio_mixer.h"\r
-\r
-#include "../gpu/gpu_write_frame.h"\r
-\r
-#include <core/producer/frame/audio_transform.h>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-struct audio_mixer::implementation\r
-{\r
- std::vector<short> audio_data_;\r
- std::stack<core::audio_transform> transform_stack_;\r
-\r
- std::map<int, core::audio_transform> prev_audio_transforms_;\r
- std::map<int, core::audio_transform> next_audio_transforms_;\r
-\r
-public:\r
- implementation()\r
- {\r
- transform_stack_.push(core::audio_transform());\r
- }\r
- \r
- void begin(const core::basic_frame& frame)\r
- {\r
- transform_stack_.push(transform_stack_.top()*frame.get_audio_transform());\r
- }\r
-\r
- void visit(const core::write_frame& frame)\r
- {\r
- if(!transform_stack_.top().get_has_audio())\r
- return;\r
-\r
- auto& audio_data = frame.audio_data();\r
- auto tag = frame.tag(); // Get the identifier for the audio-stream.\r
-\r
- if(audio_data_.empty())\r
- audio_data_.resize(audio_data.size(), 0);\r
- \r
- auto next = transform_stack_.top();\r
- auto prev = next;\r
-\r
- auto it = prev_audio_transforms_.find(tag);\r
- if(it != prev_audio_transforms_.end())\r
- prev = it->second;\r
- \r
- next_audio_transforms_[tag] = next; // Store all active tags, inactive tags will be removed in end_pass.\r
- \r
- auto next_gain = next.get_gain();\r
- auto prev_gain = prev.get_gain();\r
- \r
- if(next_gain < 0.001 && prev_gain < 0.001)\r
- return;\r
-\r
- tbb::parallel_for\r
- (\r
- tbb::blocked_range<size_t>(0, audio_data.size()),\r
- [&](const tbb::blocked_range<size_t>& r)\r
- {\r
- for(size_t n = r.begin(); n < r.end(); ++n)\r
- {\r
- double alpha = static_cast<double>(n)/static_cast<double>(audio_data_.size());\r
- double sample_gain = prev_gain * (1.0 - alpha) + next_gain * alpha;\r
- int sample = static_cast<int>(audio_data[n]);\r
- sample = (static_cast<int>(sample_gain*static_cast<double>(1<<15))*sample)>>15;\r
- audio_data_[n] = static_cast<short>((static_cast<int>(audio_data_[n]) + sample) & 0xFFFF);\r
- }\r
- }\r
- );\r
- }\r
-\r
-\r
- void begin(const core::audio_transform& transform)\r
- {\r
- transform_stack_.push(transform_stack_.top()*transform);\r
- }\r
- \r
- void end()\r
- {\r
- transform_stack_.pop();\r
- }\r
-\r
- std::vector<short> begin_pass()\r
- {\r
- return std::move(audio_data_);\r
- }\r
-\r
- void end_pass()\r
- {\r
- prev_audio_transforms_ = std::move(next_audio_transforms_);\r
- }\r
-};\r
-\r
-audio_mixer::audio_mixer() : impl_(new implementation()){}\r
-void audio_mixer::begin(const core::basic_frame& frame){impl_->begin(frame);}\r
-void audio_mixer::visit(core::write_frame& frame){impl_->visit(frame);}\r
-void audio_mixer::end(){impl_->end();}\r
-std::vector<short> audio_mixer::begin_pass(){return impl_->begin_pass();} \r
-void audio_mixer::end_pass(){impl_->end_pass();}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include <core/producer/frame/frame_visitor.h>\r
-#include <core/producer/frame/audio_transform.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class audio_mixer : public core::frame_visitor, boost::noncopyable\r
-{\r
-public:\r
- audio_mixer();\r
-\r
- virtual void begin(const core::basic_frame& frame);\r
- virtual void visit(core::write_frame& frame);\r
- virtual void end();\r
-\r
- std::vector<short> begin_pass();\r
- void end_pass();\r
-\r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "StdAfx.h"\r
-\r
-#include "frame_mixer_device.h"\r
-\r
-#include "gpu/gpu_read_frame.h"\r
-#include "gpu/gpu_write_frame.h"\r
-\r
-#include "audio/audio_mixer.h"\r
-#include "image/image_mixer.h"\r
-\r
-#include <common/exception/exceptions.h>\r
-#include <common/concurrency/executor.h>\r
-#include <common/diagnostics/graph.h>\r
-#include <common/utility/assert.h>\r
-#include <common/utility/timer.h>\r
-#include <common/utility/tweener.h>\r
-\r
-#include <core/producer/frame/audio_transform.h>\r
-#include <core/producer/frame/image_transform.h>\r
-\r
-#include <core/video_format.h>\r
-\r
-#include <boost/fusion/container/map.hpp>\r
-#include <boost/fusion/include/at_key.hpp>\r
-\r
-#include <unordered_map>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-template<typename T>\r
-class tweened_transform\r
-{\r
- T source_;\r
- T dest_;\r
- int duration_;\r
- int time_;\r
- tweener_t tweener_;\r
-public: \r
- tweened_transform()\r
- : duration_(0)\r
- , time_(0)\r
- , tweener_(get_tweener(L"linear")){}\r
- tweened_transform(const T& source, const T& dest, int duration, const std::wstring& tween = L"linear")\r
- : source_(source)\r
- , dest_(dest)\r
- , duration_(duration)\r
- , time_(0)\r
- , tweener_(get_tweener(tween)){}\r
- \r
- T fetch()\r
- {\r
- return time_ == duration_ ? dest_ : tween(static_cast<double>(time_), source_, dest_, static_cast<double>(duration_), tweener_);\r
- }\r
-\r
- T fetch_and_tick(int num)\r
- { \r
- time_ = std::min(time_+num, duration_);\r
- return fetch();\r
- }\r
-};\r
-\r
-struct frame_mixer_device::implementation : boost::noncopyable\r
-{ \r
- const core::video_format_desc format_desc_;\r
-\r
- safe_ptr<diagnostics::graph> diag_;\r
- timer perf_timer_;\r
- timer wait_perf_timer_;\r
-\r
- audio_mixer audio_mixer_;\r
- image_mixer image_mixer_;\r
-\r
- output_t output_;\r
- \r
- typedef std::unordered_map<int, tweened_transform<core::image_transform>> image_transforms;\r
- typedef std::unordered_map<int, tweened_transform<core::audio_transform>> audio_transforms;\r
-\r
- boost::fusion::map<boost::fusion::pair<core::image_transform, image_transforms>,\r
- boost::fusion::pair<core::audio_transform, audio_transforms>> transforms_;\r
- \r
- boost::fusion::map<boost::fusion::pair<core::image_transform, tweened_transform<core::image_transform>>,\r
- boost::fusion::pair<core::audio_transform, tweened_transform<core::audio_transform>>> root_transforms_;\r
-\r
- executor executor_;\r
-public:\r
- implementation(const core::video_format_desc& format_desc) \r
- : format_desc_(format_desc)\r
- , diag_(diagnostics::create_graph(narrow(print())))\r
- , image_mixer_(format_desc)\r
- , executor_(L"frame_mixer_device")\r
- {\r
- diag_->add_guide("frame-time", 0.5f); \r
- diag_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
- diag_->set_color("tick-time", diagnostics::color(0.1f, 0.7f, 0.8f));\r
- diag_->set_color("input-buffer", diagnostics::color(1.0f, 1.0f, 0.0f)); \r
- executor_.start();\r
- executor_.set_capacity(2);\r
- CASPAR_LOG(info) << print() << L" Successfully initialized."; \r
- }\r
-\r
- boost::signals2::connection connect(const output_t::slot_type& subscriber)\r
- {\r
- return output_.connect(subscriber);\r
- }\r
-\r
- boost::unique_future<safe_ptr<const host_buffer>> mix_image(std::map<int, safe_ptr<core::basic_frame>> frames)\r
- { \r
- auto& root_image_transform = boost::fusion::at_key<core::image_transform>(root_transforms_);\r
- auto& image_transforms = boost::fusion::at_key<core::image_transform>(transforms_);\r
-\r
- auto image = image_mixer_.begin_pass();\r
- BOOST_FOREACH(auto& frame, frames)\r
- {\r
- if(format_desc_.mode != core::video_mode::progressive)\r
- {\r
- auto frame1 = make_safe<core::basic_frame>(frame.second);\r
- auto frame2 = make_safe<core::basic_frame>(frame.second);\r
- \r
- frame1->get_image_transform() = root_image_transform.fetch_and_tick(1)*image_transforms[frame.first].fetch_and_tick(1);\r
- frame2->get_image_transform() = root_image_transform.fetch_and_tick(1)*image_transforms[frame.first].fetch_and_tick(1);\r
-\r
- if(frame1->get_image_transform() != frame2->get_image_transform())\r
- core::basic_frame::interlace(frame1, frame2, format_desc_.mode)->accept(image_mixer_);\r
- else\r
- frame2->accept(image_mixer_);\r
- }\r
- else\r
- {\r
- auto frame1 = make_safe<core::basic_frame>(frame.second);\r
- frame1->get_image_transform() = root_image_transform.fetch_and_tick(1)*image_transforms[frame.first].fetch_and_tick(1);\r
- frame1->accept(image_mixer_);\r
- }\r
- }\r
- image_mixer_.end_pass();\r
- return std::move(image);\r
- }\r
-\r
- std::vector<short> mix_audio(const std::map<int, safe_ptr<core::basic_frame>>& frames)\r
- {\r
- auto& root_audio_transform = boost::fusion::at_key<core::audio_transform>(root_transforms_);\r
- auto& audio_transforms = boost::fusion::at_key<core::audio_transform>(transforms_);\r
-\r
- auto audio = audio_mixer_.begin_pass();\r
- BOOST_FOREACH(auto& frame, frames)\r
- {\r
- int num = format_desc_.mode == core::video_mode::progressive ? 1 : 2;\r
-\r
- auto frame1 = make_safe<core::basic_frame>(frame.second);\r
- frame1->get_audio_transform() = root_audio_transform.fetch_and_tick(num)*audio_transforms[frame.first].fetch_and_tick(num);\r
- frame1->accept(audio_mixer_);\r
- }\r
- audio_mixer_.end_pass();\r
- return audio;\r
- }\r
- \r
- void send(const std::map<int, safe_ptr<core::basic_frame>>& frames)\r
- { \r
- executor_.begin_invoke([=]\r
- { \r
- perf_timer_.reset();\r
-\r
- auto image_future = mix_image(frames);\r
- auto audio = mix_audio(frames);\r
- auto image = image_future.get();\r
-\r
- diag_->update_value("frame-time", static_cast<float>(perf_timer_.elapsed()/format_desc_.interval*0.5));\r
-\r
- output_(make_safe<const gpu_read_frame>(std::move(image), std::move(audio)));\r
-\r
- diag_->update_value("tick-time", static_cast<float>(wait_perf_timer_.elapsed()/format_desc_.interval*0.5));\r
- wait_perf_timer_.reset();\r
-\r
- diag_->set_value("input-buffer", static_cast<float>(executor_.size())/static_cast<float>(executor_.capacity()));\r
- });\r
- diag_->set_value("input-buffer", static_cast<float>(executor_.size())/static_cast<float>(executor_.capacity()));\r
- }\r
- \r
- safe_ptr<core::write_frame> create_frame(void* tag, const core::pixel_format_desc& desc)\r
- {\r
- return make_safe<gpu_write_frame>(reinterpret_cast<int>(tag), desc, image_mixer_.create_buffers(desc));\r
- }\r
- \r
- template<typename T> \r
- void set_transform(const T& transform, int mix_duration, const std::wstring& tween)\r
- {\r
- executor_.invoke([&]\r
- {\r
- auto& root = boost::fusion::at_key<T>(root_transforms_);\r
-\r
- auto src = root.fetch();\r
- auto dst = transform;\r
- root = tweened_transform<T>(src, dst, mix_duration, tween);\r
- });\r
- }\r
- \r
- template<typename T>\r
- void set_transform(int index, const T& transform, int mix_duration, const std::wstring& tween)\r
- {\r
- executor_.invoke([&]\r
- {\r
- auto& transforms = boost::fusion::at_key<T>(transforms_);\r
-\r
- auto src = transforms[index].fetch();\r
- auto dst = transform;\r
- transforms[index] = tweened_transform<T>(src, dst, mix_duration, tween);\r
- });\r
- }\r
- \r
- template<typename T>\r
- void apply_transform(const std::function<T(const T&)>& transform, int mix_duration, const std::wstring& tween)\r
- {\r
- return executor_.invoke([&]\r
- {\r
- auto& root = boost::fusion::at_key<T>(root_transforms_);\r
-\r
- auto src = root.fetch();\r
- auto dst = transform(src);\r
- root = tweened_transform<T>(src, dst, mix_duration, tween);\r
- });\r
- }\r
- \r
- template<typename T>\r
- void apply_transform(int index, const std::function<T(T)>& transform, int mix_duration, const std::wstring& tween)\r
- {\r
- executor_.invoke([&]\r
- {\r
- auto& transforms = boost::fusion::at_key<T>(transforms_);\r
-\r
- auto src = transforms[index].fetch();\r
- auto dst = transform(src);\r
- transforms[index] = tweened_transform<T>(src, dst, mix_duration, tween);\r
- });\r
- }\r
-\r
- template<typename T>\r
- void reset_transform(int mix_duration, const std::wstring& tween)\r
- {\r
- executor_.invoke([&]\r
- {\r
- auto& transforms = boost::fusion::at_key<T>(transforms_);\r
-\r
- BOOST_FOREACH(auto& t, transforms) \r
- t.second = tweened_transform<T>(t.second.fetch(), T(), mix_duration, tween); \r
- set_transform(T(), mix_duration, tween);\r
- });\r
- }\r
-\r
- template<typename T>\r
- void reset_transform(int index, int mix_duration, const std::wstring& tween)\r
- {\r
- executor_.invoke([&]\r
- { \r
- set_transform(T(), mix_duration, tween);\r
- });\r
- }\r
- \r
- std::wstring print() const\r
- {\r
- return L"frame_mixer_device";\r
- }\r
-};\r
- \r
-frame_mixer_device::frame_mixer_device(const core::video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
-frame_mixer_device::frame_mixer_device(frame_mixer_device&& other) : impl_(std::move(other.impl_)){}\r
-boost::signals2::connection frame_mixer_device::connect(const output_t::slot_type& subscriber){return impl_->connect(subscriber);}\r
-void frame_mixer_device::send(const std::map<int, safe_ptr<core::basic_frame>>& frames){impl_->send(frames);}\r
-const core::video_format_desc& frame_mixer_device::get_video_format_desc() const { return impl_->format_desc_; }\r
-safe_ptr<core::write_frame> frame_mixer_device::create_frame(void* tag, const core::pixel_format_desc& desc){ return impl_->create_frame(tag, desc); } \r
-safe_ptr<core::write_frame> frame_mixer_device::create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt)\r
-{\r
- // Create bgra frame\r
- core::pixel_format_desc desc;\r
- desc.pix_fmt = pix_fmt;\r
- desc.planes.push_back( core::pixel_format_desc::plane(width, height, 4));\r
- return create_frame(tag, desc);\r
-}\r
- \r
-safe_ptr<core::write_frame> frame_mixer_device::create_frame(void* tag, core::pixel_format::type pix_fmt)\r
-{\r
- // Create bgra frame with output resolution\r
- core::pixel_format_desc desc;\r
- desc.pix_fmt = pix_fmt;\r
- desc.planes.push_back( core::pixel_format_desc::plane(get_video_format_desc().width, get_video_format_desc().height, 4));\r
- return create_frame(tag, desc);\r
-}\r
-void frame_mixer_device::set_image_transform(const core::image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_transform<core::image_transform>(transform, mix_duration, tween);}\r
-void frame_mixer_device::set_image_transform(int index, const core::image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_transform<core::image_transform>(index, transform, mix_duration, tween);}\r
-void frame_mixer_device::set_audio_transform(const core::audio_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_transform<core::audio_transform>(transform, mix_duration, tween);}\r
-void frame_mixer_device::set_audio_transform(int index, const core::audio_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_transform<core::audio_transform>(index, transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_image_transform(const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_transform<core::image_transform>(transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_image_transform(int index, const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_transform<core::image_transform>(index, transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_audio_transform(const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_transform<core::audio_transform>(transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_audio_transform(int index, const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_transform<core::audio_transform>(index, transform, mix_duration, tween);}\r
-void frame_mixer_device::reset_image_transform(int mix_duration, const std::wstring& tween){impl_->reset_transform<core::image_transform>(mix_duration, tween);}\r
-void frame_mixer_device::reset_image_transform(int index, int mix_duration, const std::wstring& tween){impl_->reset_transform<core::image_transform>(index, mix_duration, tween);}\r
-void frame_mixer_device::reset_audio_transform(int mix_duration, const std::wstring& tween){impl_->reset_transform<core::audio_transform>(mix_duration, tween);}\r
-void frame_mixer_device::reset_audio_transform(int index, int mix_duration, const std::wstring& tween){impl_->reset_transform<core::audio_transform>(index, mix_duration, tween);}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include <core/consumer/frame/read_frame.h>\r
-#include <core/producer/frame/write_frame.h>\r
-#include <core/producer/frame/frame_factory.h>\r
-#include <core/producer/frame/pixel_format.h>\r
-\r
-#include "image/image_mixer.h"\r
-#include "audio/audio_mixer.h"\r
-\r
-#include <common/memory/safe_ptr.h>\r
-\r
-#include <boost/signals2.hpp>\r
-\r
-#include <functional>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class frame_mixer_device : public core::frame_factory\r
-{\r
-public:\r
- typedef boost::signals2::signal<void(const safe_ptr<const core::read_frame>&)> output_t;\r
- \r
- boost::signals2::connection connect(const output_t::slot_type& subscriber);\r
- \r
- frame_mixer_device(const core::video_format_desc& format_desc);\r
- frame_mixer_device(frame_mixer_device&& other); // nothrow\r
- \r
- void send(const std::map<int, safe_ptr<core::basic_frame>>& frames); // nothrow\r
- \r
- safe_ptr<core::write_frame> create_frame(void* tag, const core::pixel_format_desc& desc); \r
- safe_ptr<core::write_frame> create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt = core::pixel_format::bgra); \r
- safe_ptr<core::write_frame> create_frame(void* tag, core::pixel_format::type pix_fmt = core::pixel_format::bgra);\r
- \r
- const core::video_format_desc& get_video_format_desc() const; // nothrow\r
-\r
- void set_image_transform(const core::image_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void set_image_transform(int index, const core::image_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
-\r
- void set_audio_transform(const core::audio_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void set_audio_transform(int index, const core::audio_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- \r
- void apply_image_transform(const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void apply_image_transform(int index, const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
-\r
- void apply_audio_transform(const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void apply_audio_transform(int index, const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
-\r
- void reset_image_transform(int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void reset_image_transform(int index, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void reset_audio_transform(int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void reset_audio_transform(int index, int mix_duration = 0, const std::wstring& tween = L"linear");\r
-\r
-private:\r
- struct implementation;\r
- safe_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "device_buffer.h"\r
-\r
-#include <common/gl/gl_check.h>\r
-namespace caspar { namespace mixer {\r
- \r
-GLenum FORMAT[] = {0, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGR, GL_BGRA};\r
-GLenum INTERNAL_FORMAT[] = {0, GL_LUMINANCE8, GL_LUMINANCE8_ALPHA8, GL_RGB8, GL_RGBA8}; \r
-\r
-struct device_buffer::implementation : boost::noncopyable\r
-{\r
- GLuint id_;\r
-\r
- const size_t width_;\r
- const size_t height_;\r
- const size_t stride_;\r
-\r
-public:\r
- implementation(size_t width, size_t height, size_t stride) \r
- : width_(width)\r
- , height_(height)\r
- , stride_(stride)\r
- { \r
- GL(glGenTextures(1, &id_));\r
- GL(glBindTexture(GL_TEXTURE_2D, id_));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
- GL(glTexImage2D(GL_TEXTURE_2D, 0, INTERNAL_FORMAT[stride_], width_, height_, 0, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL));\r
- GL(glBindTexture(GL_TEXTURE_2D, 0));\r
- //CASPAR_LOG(trace) << "[device_buffer] allocated size:" << width*height*stride; \r
- } \r
-\r
- ~implementation()\r
- {\r
- GL(glDeleteTextures(1, &id_));\r
- }\r
- \r
- void bind()\r
- {\r
- GL(glBindTexture(GL_TEXTURE_2D, id_));\r
- }\r
-\r
- void unbind()\r
- {\r
- GL(glBindTexture(GL_TEXTURE_2D, 0));\r
- }\r
-\r
- void read(host_buffer& source)\r
- {\r
- GL(glBindTexture(GL_TEXTURE_2D, id_));\r
- source.unmap();\r
- source.bind();\r
- GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL));\r
- source.unbind();\r
- GL(glBindTexture(GL_TEXTURE_2D, 0));\r
- }\r
- \r
- void write(host_buffer& target)\r
- {\r
- GL(glBindTexture(GL_TEXTURE_2D, id_));\r
- target.unmap();\r
- target.bind();\r
- GL(glReadPixels(0, 0, width_, height_, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL));\r
- target.unbind();\r
- GL(glBindTexture(GL_TEXTURE_2D, 0));\r
- }\r
-\r
- void attach(int index)\r
- {\r
- GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, GL_TEXTURE_2D, id_, 0));\r
- }\r
-};\r
-\r
-device_buffer::device_buffer(size_t width, size_t height, size_t stride) : impl_(new implementation(width, height, stride)){}\r
-size_t device_buffer::stride() const { return impl_->stride_; }\r
-size_t device_buffer::width() const { return impl_->width_; }\r
-size_t device_buffer::height() const { return impl_->height_; }\r
-void device_buffer::attach(int index){impl_->attach(index);}\r
-void device_buffer::bind(){impl_->bind();}\r
-void device_buffer::unbind(){impl_->unbind();}\r
-void device_buffer::read(host_buffer& source){impl_->read(source);}\r
-void device_buffer::write(host_buffer& target){impl_->write(target);}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include "../gpu/host_buffer.h"\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <memory>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class device_buffer : boost::noncopyable\r
-{\r
-public:\r
- device_buffer(size_t width, size_t height, size_t stride);\r
- \r
- size_t stride() const; \r
- size_t width() const;\r
- size_t height() const;\r
- \r
- void bind();\r
- void unbind();\r
-\r
- void attach(int index);\r
- void read(host_buffer& source);\r
- void write(host_buffer& target);\r
- \r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "gpu_read_frame.h"\r
-\r
-#include "../gpu/host_buffer.h"\r
-\r
-#include <common/gl/gl_check.h>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-struct gpu_read_frame::implementation : boost::noncopyable\r
-{\r
- safe_ptr<const host_buffer> image_data_;\r
- std::vector<short> audio_data_;\r
-\r
-public:\r
- implementation(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data) \r
- : image_data_(std::move(image_data))\r
- , audio_data_(std::move(audio_data)){} \r
-};\r
-\r
-gpu_read_frame::gpu_read_frame(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data) : impl_(new implementation(std::move(image_data), std::move(audio_data))){}\r
-\r
-const boost::iterator_range<const unsigned char*> gpu_read_frame::image_data() const\r
-{\r
- if(!impl_->image_data_->data())\r
- return boost::iterator_range<const unsigned char*>();\r
- auto ptr = static_cast<const unsigned char*>(impl_->image_data_->data());\r
- return boost::iterator_range<const unsigned char*>(ptr, ptr + impl_->image_data_->size());\r
-}\r
-const boost::iterator_range<const short*> gpu_read_frame::audio_data() const\r
-{\r
- return boost::iterator_range<const short*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
-}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include "../gpu/host_buffer.h" \r
-\r
-#include <core/consumer/frame/read_frame.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-#include <boost/range/iterator_range.hpp>\r
-\r
-#include <memory>\r
-#include <vector>\r
-\r
-#include <common/memory/safe_ptr.h>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class gpu_read_frame : public core::read_frame\r
-{\r
-public:\r
- gpu_read_frame(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data);\r
-\r
- const boost::iterator_range<const unsigned char*> image_data() const;\r
- const boost::iterator_range<const short*> audio_data() const;\r
- \r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "gpu_write_frame.h"\r
-\r
-#include <core/producer/frame/pixel_format.h>\r
-\r
-#include "../image/image_mixer.h"\r
-#include "../audio/audio_mixer.h"\r
-\r
-#include "../gpu/host_buffer.h"\r
-\r
-#include <common/gl/gl_check.h>\r
-\r
-#include <boost/range/algorithm.hpp>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-struct gpu_write_frame::implementation : boost::noncopyable\r
-{ \r
- std::vector<safe_ptr<host_buffer>> buffers_;\r
- std::vector<short> audio_data_;\r
- const core::pixel_format_desc desc_;\r
- int tag_;\r
-\r
-public:\r
- implementation(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) \r
- : desc_(desc)\r
- , buffers_(buffers)\r
- , tag_(tag){}\r
- \r
- void accept(gpu_write_frame& self, core::frame_visitor& visitor)\r
- {\r
- visitor.begin(self);\r
- visitor.visit(self);\r
- visitor.end();\r
- }\r
-\r
- boost::iterator_range<unsigned char*> image_data(size_t index)\r
- {\r
- if(index >= buffers_.size() || !buffers_[index]->data())\r
- return boost::iterator_range<const unsigned char*>();\r
- auto ptr = static_cast<unsigned char*>(buffers_[index]->data());\r
- return boost::iterator_range<unsigned char*>(ptr, ptr+buffers_[index]->size());\r
- }\r
-\r
- const boost::iterator_range<const unsigned char*> image_data(size_t index) const\r
- {\r
- if(index >= buffers_.size() || !buffers_[index]->data())\r
- return boost::iterator_range<const unsigned char*>();\r
- auto ptr = static_cast<const unsigned char*>(buffers_[index]->data());\r
- return boost::iterator_range<const unsigned char*>(ptr, ptr+buffers_[index]->size());\r
- }\r
-};\r
- \r
-gpu_write_frame::gpu_write_frame(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) : impl_(new implementation(tag, desc, buffers)){}\r
-gpu_write_frame::gpu_write_frame(gpu_write_frame&& other) : impl_(std::move(other.impl_)){}\r
-void gpu_write_frame::swap(gpu_write_frame& other){impl_.swap(other.impl_);}\r
-gpu_write_frame& gpu_write_frame::operator=(gpu_write_frame&& other)\r
-{\r
- gpu_write_frame temp(std::move(other));\r
- temp.swap(*this);\r
- return *this;\r
-}\r
-void gpu_write_frame::accept(core::frame_visitor& visitor){impl_->accept(*this, visitor);}\r
-boost::iterator_range<unsigned char*> gpu_write_frame::image_data(size_t index){return impl_->image_data(index);}\r
-std::vector<short>& gpu_write_frame::audio_data() { return impl_->audio_data_; }\r
-const boost::iterator_range<const unsigned char*> gpu_write_frame::image_data(size_t index) const\r
-{\r
- return boost::iterator_range<const unsigned char*>(impl_->image_data(index).begin(), impl_->image_data(index).end());\r
-}\r
-const boost::iterator_range<const short*> gpu_write_frame::audio_data() const\r
-{\r
- return boost::iterator_range<const short*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
-}\r
-int gpu_write_frame::tag() const {return impl_->tag_;}\r
-const core::pixel_format_desc& gpu_write_frame::get_pixel_format_desc() const{return impl_->desc_;}\r
-std::vector<safe_ptr<host_buffer>>& gpu_write_frame::get_plane_buffers(){return impl_->buffers_;}\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include <common/memory/safe_ptr.h>\r
-#include <core/producer/frame/write_frame.h>\r
-#include <core/producer/frame/pixel_format.h>\r
-\r
-#include "../gpu/host_buffer.h"\r
-\r
-#include <boost/noncopyable.hpp>\r
-#include <boost/range/iterator_range.hpp>\r
-\r
-#include <memory>\r
-#include <vector>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class gpu_write_frame : public core::write_frame\r
-{\r
-public: \r
- explicit gpu_write_frame(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers);\r
- gpu_write_frame(gpu_write_frame&& other);\r
- gpu_write_frame& operator=(gpu_write_frame&& other);\r
- \r
- void swap(gpu_write_frame& other);\r
-\r
- const core::pixel_format_desc& get_pixel_format_desc() const;\r
- std::vector<safe_ptr<host_buffer>>& get_plane_buffers();\r
- \r
- // core::write_frame\r
- virtual boost::iterator_range<unsigned char*> image_data(size_t plane_index = 0); \r
- virtual std::vector<short>& audio_data();\r
- \r
- virtual const boost::iterator_range<const unsigned char*> image_data(size_t plane_index = 0) const;\r
- virtual const boost::iterator_range<const short*> audio_data() const;\r
-\r
- virtual void accept(core::frame_visitor& visitor);\r
-\r
- virtual int tag() const;\r
- \r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-typedef std::shared_ptr<gpu_write_frame> gpu_write_frame_impl_ptr;\r
-\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "../gpu/host_buffer.h"\r
-\r
-#include <common/gl/gl_check.h>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-struct host_buffer::implementation : boost::noncopyable\r
-{ \r
- GLuint pbo_;\r
-\r
- const size_t size_;\r
-\r
- void* data_;\r
- GLenum usage_;\r
- GLenum target_;\r
-\r
-public:\r
- implementation(size_t size, usage_t usage) \r
- : size_(size)\r
- , data_(nullptr)\r
- , pbo_(0)\r
- , target_(usage == write_only ? GL_PIXEL_UNPACK_BUFFER : GL_PIXEL_PACK_BUFFER)\r
- , usage_(usage == write_only ? GL_STREAM_DRAW : GL_STREAM_READ)\r
- {\r
- GL(glGenBuffers(1, &pbo_));\r
- GL(glBindBuffer(target_, pbo_));\r
- GL(glBufferData(target_, size_, NULL, usage_)); \r
- GL(glBindBuffer(target_, 0));\r
-\r
- if(!pbo_)\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to allocate buffer."));\r
-\r
- //CASPAR_LOG(trace) << "[host_buffer] allocated size:" << size_ << " usage: " << (usage == write_only ? "write_only" : "read_only");\r
- } \r
-\r
- ~implementation()\r
- {\r
- GL(glDeleteBuffers(1, &pbo_));\r
- }\r
-\r
- void map()\r
- {\r
- if(data_)\r
- return;\r
- \r
- GL(glBindBuffer(target_, pbo_));\r
- data_ = glMapBuffer(target_, usage_ == GL_STREAM_DRAW ? GL_WRITE_ONLY : GL_READ_ONLY); \r
- GL(glBindBuffer(target_, 0)); \r
- if(!data_)\r
- BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Failed to map target_ OpenGL Pixel Buffer Object."));\r
- }\r
-\r
- void unmap()\r
- {\r
- if(!data_)\r
- return;\r
- \r
- GL(glBindBuffer(target_, pbo_));\r
- GL(glUnmapBuffer(target_)); \r
- data_ = nullptr; \r
- GL(glBindBuffer(target_, 0));\r
- }\r
-\r
- void bind()\r
- {\r
- GL(glBindBuffer(target_, pbo_));\r
- }\r
-\r
- void unbind()\r
- {\r
- GL(glBindBuffer(target_, 0));\r
- }\r
-};\r
-\r
-host_buffer::host_buffer(size_t size, usage_t usage) : impl_(new implementation(size, usage)){}\r
-const void* host_buffer::data() const {return impl_->data_;}\r
-void* host_buffer::data() {return impl_->data_;}\r
-void host_buffer::map(){impl_->map();}\r
-void host_buffer::unmap(){impl_->unmap();}\r
-void host_buffer::bind(){impl_->bind();}\r
-void host_buffer::unbind(){impl_->unbind();}\r
-\r
-size_t host_buffer::size() const { return impl_->size_; }\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <memory>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class host_buffer : boost::noncopyable\r
-{\r
-public:\r
- enum usage_t\r
- {\r
- write_only,\r
- read_only\r
- };\r
- host_buffer(size_t size, usage_t usage);\r
- \r
- const void* data() const;\r
- void* data();\r
- size_t size() const; \r
- \r
- void bind();\r
- void unbind();\r
- void unmap();\r
- void map();\r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "ogl_device.h"\r
-\r
-#include <common/utility/assert.h>\r
-\r
-#include <Glee.h>\r
-#include <SFML/Window.hpp>\r
-\r
-#include <boost/foreach.hpp>\r
-\r
-namespace caspar { namespace mixer {\r
-\r
-ogl_device::ogl_device() : executor_(L"ogl_device")\r
-{\r
- executor_.start();\r
- invoke([=]\r
- {\r
- context_.reset(new sf::Context());\r
- context_->SetActive(true);\r
- });\r
-}\r
-\r
-ogl_device::~ogl_device()\r
-{\r
- invoke([=]\r
- {\r
- BOOST_FOREACH(auto& pool, device_pools_)\r
- pool.clear();\r
- BOOST_FOREACH(auto& pool, host_pools_)\r
- pool.clear();\r
- });\r
-}\r
- \r
-safe_ptr<device_buffer> ogl_device::create_device_buffer(size_t width, size_t height, size_t stride)\r
-{\r
- CASPAR_VERIFY(stride > 0 && stride < 5);\r
- CASPAR_VERIFY(width > 0 && height > 0);\r
- auto pool = &device_pools_[stride-1][((width << 16) & 0xFFFF0000) | (height & 0x0000FFFF)];\r
- std::shared_ptr<device_buffer> buffer;\r
- if(!pool->try_pop(buffer)) \r
- {\r
- executor_.invoke([&]\r
- {\r
- buffer = std::make_shared<device_buffer>(width, height, stride);\r
- }); \r
- }\r
- \r
- return safe_ptr<device_buffer>(buffer.get(), [=](device_buffer*){pool->push(buffer);});\r
-}\r
- \r
-safe_ptr<host_buffer> ogl_device::create_host_buffer(size_t size, host_buffer::usage_t usage)\r
-{\r
- CASPAR_VERIFY(usage == host_buffer::write_only || usage == host_buffer::read_only);\r
- CASPAR_VERIFY(size > 0);\r
- auto pool = &host_pools_[usage][size];\r
- std::shared_ptr<host_buffer> buffer;\r
- if(!pool->try_pop(buffer))\r
- {\r
- executor_.invoke([&]\r
- {\r
- buffer = std::make_shared<host_buffer>(size, usage);\r
- if(usage == host_buffer::write_only)\r
- buffer->map();\r
- else\r
- buffer->unmap();\r
- }); \r
- }\r
-\r
- return safe_ptr<host_buffer>(buffer.get(), [=](host_buffer*)\r
- {\r
- executor_.begin_invoke([=]\r
- {\r
- if(usage == host_buffer::write_only)\r
- buffer->map();\r
- else\r
- buffer->unmap();\r
- pool->push(buffer);\r
- });\r
- });\r
-}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include "host_buffer.h"\r
-#include "device_buffer.h"\r
-\r
-#include <common/concurrency/executor.h>\r
-#include <common/memory/safe_ptr.h>\r
-\r
-#include <tbb/concurrent_unordered_map.h>\r
-#include <tbb/concurrent_queue.h>\r
-\r
-#include <boost/thread/future.hpp>\r
-\r
-#include <array>\r
-\r
-#include <SFML/Window/Context.hpp>\r
-\r
-namespace caspar { namespace mixer {\r
-\r
-class ogl_device\r
-{ \r
- std::unique_ptr<sf::Context> context_;\r
- \r
- std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<device_buffer>>>, 4> device_pools_;\r
- std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<host_buffer>>>, 2> host_pools_;\r
-\r
- executor executor_;\r
-\r
- ogl_device();\r
-public: \r
- virtual ~ogl_device();\r
-\r
- static safe_ptr<ogl_device> create()\r
- {\r
- static safe_ptr<ogl_device> instance(new ogl_device()); // Use the same ogl-device for all channels inorder to ensure that frames are always valid for all "context".\r
- return instance;\r
- }\r
-\r
- template<typename Func>\r
- auto begin_invoke(Func&& func) -> boost::unique_future<decltype(func())> // noexcept\r
- { \r
- return executor_.begin_invoke(std::forward<Func>(func));\r
- }\r
- \r
- template<typename Func>\r
- auto invoke(Func&& func) -> decltype(func())\r
- {\r
- return executor_.invoke(std::forward<Func>(func));\r
- }\r
- \r
- safe_ptr<device_buffer> create_device_buffer(size_t width, size_t height, size_t stride);\r
- safe_ptr<host_buffer> create_host_buffer(size_t size, host_buffer::usage_t usage);\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "image_kernel.h"\r
-\r
-#include <common/exception/exceptions.h>\r
-#include <common/gl/gl_check.h>\r
-\r
-#include <core/video_format.h>\r
-#include <core/producer/frame/pixel_format.h>\r
-#include <core/producer/frame/image_transform.h>\r
-\r
-#include <Glee.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <unordered_map>\r
-\r
-namespace caspar { namespace mixer {\r
-\r
-class shader_program : boost::noncopyable\r
-{\r
- GLuint program_;\r
-public:\r
-\r
- shader_program() : program_(0) {}\r
- shader_program(shader_program&& other) : program_(other.program_){other.program_ = 0;}\r
- shader_program(const std::string& vertex_source_str, const std::string& fragment_source_str) : program_(0)\r
- {\r
- GLint success;\r
- \r
- const char* vertex_source = vertex_source_str.c_str();\r
- \r
- auto vertex_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);\r
- \r
- GL(glShaderSourceARB(vertex_shader, 1, &vertex_source, NULL));\r
- GL(glCompileShaderARB(vertex_shader));\r
-\r
- GL(glGetObjectParameterivARB(vertex_shader, GL_OBJECT_COMPILE_STATUS_ARB, &success));\r
- if (success == GL_FALSE)\r
- {\r
- char info[2048];\r
- GL(glGetInfoLogARB(vertex_shader, sizeof(info), 0, info));\r
- GL(glDeleteObjectARB(vertex_shader));\r
- std::stringstream str;\r
- str << "Failed to compile vertex shader:" << std::endl << info << std::endl;\r
- BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
- }\r
- \r
- const char* fragment_source = fragment_source_str.c_str();\r
- \r
- auto fragmemt_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);\r
- \r
- GL(glShaderSourceARB(fragmemt_shader, 1, &fragment_source, NULL));\r
- GL(glCompileShaderARB(fragmemt_shader));\r
-\r
- GL(glGetObjectParameterivARB(fragmemt_shader, GL_OBJECT_COMPILE_STATUS_ARB, &success));\r
- if (success == GL_FALSE)\r
- {\r
- char info[2048];\r
- GL(glGetInfoLogARB(fragmemt_shader, sizeof(info), 0, info));\r
- GL(glDeleteObjectARB(fragmemt_shader));\r
- std::stringstream str;\r
- str << "Failed to compile fragment shader:" << std::endl << info << std::endl;\r
- BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
- }\r
- \r
- program_ = glCreateProgramObjectARB();\r
- \r
- GL(glAttachObjectARB(program_, vertex_shader));\r
- GL(glAttachObjectARB(program_, fragmemt_shader));\r
-\r
- GL(glLinkProgramARB(program_));\r
- \r
- GL(glDeleteObjectARB(vertex_shader));\r
- GL(glDeleteObjectARB(fragmemt_shader));\r
-\r
- GL(glGetObjectParameterivARB(program_, GL_OBJECT_LINK_STATUS_ARB, &success));\r
- if (success == GL_FALSE)\r
- {\r
- char info[2048];\r
- GL(glGetInfoLogARB(program_, sizeof(info), 0, info));\r
- GL(glDeleteObjectARB(program_));\r
- std::stringstream str;\r
- str << "Failed to link shader program:" << std::endl << info << std::endl;\r
- BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
- }\r
- GL(glUseProgramObjectARB(program_));\r
- glUniform1i(glGetUniformLocation(program_, "plane[0]"), 0);\r
- glUniform1i(glGetUniformLocation(program_, "plane[1]"), 1);\r
- glUniform1i(glGetUniformLocation(program_, "plane[2]"), 2);\r
- glUniform1i(glGetUniformLocation(program_, "plane[3]"), 3);\r
- }\r
-\r
- GLint get_location(const char* name)\r
- {\r
- GLint loc = glGetUniformLocation(program_, name);\r
- return loc;\r
- }\r
-\r
- shader_program& operator=(shader_program&& other) \r
- {\r
- program_ = other.program_; \r
- other.program_ = 0; \r
- return *this;\r
- }\r
-\r
- ~shader_program()\r
- {\r
- glDeleteProgram(program_);\r
- }\r
-\r
- void use()\r
- { \r
- GL(glUseProgramObjectARB(program_)); \r
- }\r
-};\r
-\r
-GLubyte progressive_pattern[] = {\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
- \r
-GLubyte upper_pattern[] = {\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};\r
- \r
-GLubyte lower_pattern[] = {\r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff};\r
-\r
-struct image_kernel::implementation : boost::noncopyable\r
-{ \r
- std::unordered_map<core::pixel_format::type, shader_program> shaders_;\r
-\r
-public:\r
- std::unordered_map<core::pixel_format::type, shader_program>& shaders()\r
- {\r
- GL(glEnable(GL_POLYGON_STIPPLE));\r
- GL(glEnable(GL_BLEND));\r
- GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); \r
-\r
- if(shaders_.empty())\r
- {\r
- std::string common_vertex = \r
- "void main() "\r
- "{ "\r
- " gl_TexCoord[0] = gl_MultiTexCoord0; "\r
- " gl_FrontColor = gl_Color; "\r
- " gl_Position = ftransform(); "\r
- "} ";\r
-\r
- std::string common_fragment = \r
- "uniform sampler2D plane[4]; "\r
- "uniform float gain; "\r
- "uniform bool HD; "\r
- \r
- // NOTE: YCbCr, ITU-R, http://www.intersil.com/data/an/an9717.pdf \r
- // TODO: Support for more yuv formats might be needed. \r
- "vec4 ycbcra_to_bgra_sd(float y, float cb, float cr, float a) "\r
- "{ "\r
- " cb -= 0.5; "\r
- " cr -= 0.5; "\r
- " y = 1.164*(y-0.0625); "\r
- " "\r
- " vec4 color; "\r
- " color.r = y + 1.596 * cr; "\r
- " color.g = y - 0.813 * cr - 0.391 * cb; "\r
- " color.b = y + 2.018 * cb; "\r
- " color.a = a; "\r
- " "\r
- " return color; "\r
- "} " \r
- " "\r
-\r
- "vec4 ycbcra_to_bgra_hd(float y, float cb, float cr, float a) "\r
- "{ "\r
- " cb -= 0.5; "\r
- " cr -= 0.5; "\r
- " y = 1.164*(y-0.0625); "\r
- " "\r
- " vec4 color; "\r
- " color.r = y + 1.793 * cr; "\r
- " color.g = y - 0.534 * cr - 0.213 * cb; "\r
- " color.b = y + 2.115 * cb; "\r
- " color.a = a; "\r
- " "\r
- " return color; "\r
- "} " \r
- " ";\r
- \r
- shaders_[core::pixel_format::abgr] = shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " vec4 abgr = texture2D(plane[0], gl_TexCoord[0].st); "\r
- " gl_FragColor = abgr.argb * gain; "\r
- "} ");\r
- \r
- shaders_[core::pixel_format::argb]= shader_program(common_vertex, common_fragment +\r
-\r
- "void main() " \r
- "{ "\r
- " vec4 argb = texture2D(plane[0], gl_TexCoord[0].st); "\r
- " gl_FragColor = argb.grab * gl_Color * gain; "\r
- "} ");\r
- \r
- shaders_[core::pixel_format::bgra]= shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " vec4 bgra = texture2D(plane[0], gl_TexCoord[0].st); "\r
- " gl_FragColor = bgra.rgba * gl_Color * gain; "\r
- "} ");\r
- \r
- shaders_[core::pixel_format::rgba] = shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " vec4 rgba = texture2D(plane[0], gl_TexCoord[0].st); "\r
- " gl_FragColor = rgba.bgra * gl_Color * gain; "\r
- "} ");\r
- \r
- shaders_[core::pixel_format::ycbcr] = shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " float y = texture2D(plane[0], gl_TexCoord[0].st).r; "\r
- " float cb = texture2D(plane[1], gl_TexCoord[0].st).r; "\r
- " float cr = texture2D(plane[2], gl_TexCoord[0].st).r; "\r
- " float a = 1.0; " \r
- " if(HD) "\r
- " gl_FragColor = ycbcra_to_bgra_hd(y, cb, cr, a) * gl_Color * gain;"\r
- " else "\r
- " gl_FragColor = ycbcra_to_bgra_sd(y, cb, cr, a) * gl_Color * gain;"\r
- "} ");\r
- \r
- shaders_[core::pixel_format::ycbcra] = shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " float y = texture2D(plane[0], gl_TexCoord[0].st).r; "\r
- " float cb = texture2D(plane[1], gl_TexCoord[0].st).r; "\r
- " float cr = texture2D(plane[2], gl_TexCoord[0].st).r; "\r
- " float a = texture2D(plane[3], gl_TexCoord[0].st).r; "\r
- " if(HD) "\r
- " gl_FragColor = ycbcra_to_bgra_hd(y, cb, cr, a) * gl_Color * gain;"\r
- " else "\r
- " gl_FragColor = ycbcra_to_bgra_sd(y, cb, cr, a) * gl_Color * gain;"\r
- "} ");\r
- }\r
- return shaders_;\r
- }\r
-};\r
-\r
-image_kernel::image_kernel() : impl_(new implementation()){}\r
-\r
-void image_kernel::apply(const core::pixel_format_desc& pix_desc, const core::image_transform& transform)\r
-{\r
- impl_->shaders()[pix_desc.pix_fmt].use();\r
-\r
- GL(glUniform1f(impl_->shaders()[pix_desc.pix_fmt].get_location("gain"), static_cast<GLfloat>(transform.get_gain())));\r
- GL(glUniform1i(impl_->shaders()[pix_desc.pix_fmt].get_location("HD"), pix_desc.planes.at(0).height > 700 ? 1 : 0));\r
-\r
- if(transform.get_mode() == core::video_mode::upper)\r
- glPolygonStipple(upper_pattern);\r
- else if(transform.get_mode() == core::video_mode::lower)\r
- glPolygonStipple(lower_pattern);\r
- else\r
- glPolygonStipple(progressive_pattern);\r
-}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include <memory>\r
-\r
-#include <core/producer/frame/pixel_format.h>\r
-#include <core/producer/frame/image_transform.h>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class image_kernel\r
-{\r
-public:\r
- image_kernel();\r
- void apply(const core::pixel_format_desc& pix_desc, const core::image_transform& mode);\r
-\r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "image_mixer.h"\r
-#include "image_kernel.h"\r
-\r
-#include "../gpu/ogl_device.h"\r
-#include "../gpu/host_buffer.h"\r
-#include "../gpu/device_buffer.h"\r
-#include "../gpu/gpu_write_frame.h"\r
-\r
-#include <common/concurrency/executor.h>\r
-#include <common/exception/exceptions.h>\r
-#include <common/gl/gl_check.h>\r
-\r
-#include <core/producer/frame/image_transform.h>\r
-#include <core/producer/frame/pixel_format.h>\r
-#include <core/video_format.h>\r
-\r
-#include <boost/cast.hpp>\r
-\r
-#include <Glee.h>\r
-#include <SFML/Window/Context.hpp>\r
-\r
-#include <array>\r
-#include <unordered_map>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-struct image_mixer::implementation : boost::noncopyable\r
-{ \r
- const core::video_format_desc format_desc_;\r
- \r
- std::stack<core::image_transform> transform_stack_;\r
-\r
- GLuint fbo_;\r
- std::array<std::shared_ptr<device_buffer>, 2> render_targets_;\r
-\r
- std::shared_ptr<host_buffer> reading_;\r
-\r
- image_kernel kernel_;\r
-\r
- safe_ptr<ogl_device> context_;\r
-\r
-public:\r
- implementation(const core::video_format_desc& format_desc) \r
- : format_desc_(format_desc)\r
- , context_(ogl_device::create())\r
- {\r
- context_->invoke([]\r
- {\r
- if(!GLEE_VERSION_3_0)\r
- BOOST_THROW_EXCEPTION(not_supported() << msg_info("Missing OpenGL 3.0 support."));\r
- });\r
- \r
- context_->begin_invoke([=]\r
- {\r
- transform_stack_.push(core::image_transform());\r
- transform_stack_.top().set_mode(core::video_mode::progressive);\r
-\r
- GL(glEnable(GL_TEXTURE_2D));\r
- GL(glDisable(GL_DEPTH_TEST)); \r
-\r
- render_targets_[0] = context_->create_device_buffer(format_desc.width, format_desc.height, 4);\r
- render_targets_[1] = context_->create_device_buffer(format_desc.width, format_desc.height, 4);\r
- \r
- GL(glGenFramebuffers(1, &fbo_)); \r
- GL(glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo_));\r
- GL(glReadBuffer(GL_COLOR_ATTACHMENT0_EXT));\r
-\r
- reading_ = context_->create_host_buffer(format_desc_.size, host_buffer::read_only);\r
- });\r
- }\r
-\r
- ~implementation()\r
- {\r
- glDeleteFramebuffersEXT(1, &fbo_);\r
- }\r
-\r
- void begin(const core::basic_frame& frame)\r
- {\r
- transform_stack_.push(transform_stack_.top()*frame.get_image_transform());\r
- }\r
- \r
- void visit(core::write_frame& frame)\r
- {\r
- auto gpu_frame = boost::polymorphic_downcast<gpu_write_frame*>(&frame);\r
- auto& desc = gpu_frame->get_pixel_format_desc();\r
- auto& buffers = gpu_frame->get_plane_buffers();\r
-\r
- auto transform = transform_stack_.top();\r
- context_->begin_invoke([=]\r
- {\r
- GL(glColor4d(1.0, 1.0, 1.0, transform.get_opacity()));\r
- GL(glViewport(0, 0, format_desc_.width, format_desc_.height));\r
- kernel_.apply(desc, transform);\r
-\r
- std::vector<safe_ptr<device_buffer>> device_buffers;\r
- for(size_t n = 0; n < buffers.size(); ++n)\r
- {\r
- auto texture = context_->create_device_buffer(desc.planes[n].width, desc.planes[n].height, desc.planes[n].channels);\r
- texture->read(*buffers[n]);\r
- device_buffers.push_back(texture);\r
- }\r
-\r
- for(size_t n = 0; n < buffers.size(); ++n)\r
- {\r
- GL(glActiveTexture(GL_TEXTURE0+n));\r
- device_buffers[n]->bind();\r
- }\r
-\r
- auto m_p = transform.get_key_translation();\r
- auto m_s = transform.get_key_scale();\r
- double w = static_cast<double>(format_desc_.width);\r
- double h = static_cast<double>(format_desc_.height);\r
- \r
- GL(glEnable(GL_SCISSOR_TEST));\r
- GL(glScissor(static_cast<size_t>(m_p[0]*w), static_cast<size_t>(m_p[1]*h), static_cast<size_t>(m_s[0]*w), static_cast<size_t>(m_s[1]*h)));\r
- \r
- auto f_p = transform.get_fill_translation();\r
- auto f_s = transform.get_fill_scale();\r
- \r
- glBegin(GL_QUADS);\r
- glTexCoord2d(0.0, 0.0); glVertex2d( f_p[0] *2.0-1.0, f_p[1] *2.0-1.0);\r
- glTexCoord2d(1.0, 0.0); glVertex2d((f_p[0]+f_s[0])*2.0-1.0, f_p[1] *2.0-1.0);\r
- glTexCoord2d(1.0, 1.0); glVertex2d((f_p[0]+f_s[0])*2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0);\r
- glTexCoord2d(0.0, 1.0); glVertex2d( f_p[0] *2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0);\r
- glEnd();\r
- GL(glDisable(GL_SCISSOR_TEST));\r
- });\r
- }\r
-\r
- void end()\r
- {\r
- transform_stack_.pop();\r
- }\r
-\r
- boost::unique_future<safe_ptr<const host_buffer>> begin_pass()\r
- {\r
- return context_->begin_invoke([=]() -> safe_ptr<const host_buffer>\r
- {\r
- reading_->map();\r
- render_targets_[0]->attach(0);\r
- GL(glClear(GL_COLOR_BUFFER_BIT));\r
- return safe_ptr<const host_buffer>(reading_);\r
- });\r
- }\r
-\r
- void end_pass()\r
- {\r
- context_->begin_invoke([=]\r
- {\r
- reading_ = context_->create_host_buffer(format_desc_.size, host_buffer::read_only);\r
- render_targets_[0]->write(*reading_);\r
- std::rotate(render_targets_.begin(), render_targets_.begin() + 1, render_targets_.end());\r
- });\r
- }\r
- \r
- std::vector<safe_ptr<host_buffer>> create_buffers(const core::pixel_format_desc& format)\r
- {\r
- std::vector<safe_ptr<host_buffer>> buffers;\r
- std::transform(format.planes.begin(), format.planes.end(), std::back_inserter(buffers), [&](const core::pixel_format_desc::plane& plane)\r
- {\r
- return context_->create_host_buffer(plane.size, host_buffer::write_only);\r
- });\r
- return buffers;\r
- }\r
-};\r
-\r
-image_mixer::image_mixer(const core::video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
-void image_mixer::begin(const core::basic_frame& frame){impl_->begin(frame);}\r
-void image_mixer::visit(core::write_frame& frame){impl_->visit(frame);}\r
-void image_mixer::end(){impl_->end();}\r
-boost::unique_future<safe_ptr<const host_buffer>> image_mixer::begin_pass(){ return impl_->begin_pass();}\r
-void image_mixer::end_pass(){impl_->end_pass();}\r
-std::vector<safe_ptr<host_buffer>> image_mixer::create_buffers(const core::pixel_format_desc& format){return impl_->create_buffers(format);}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include <core/video_format.h>\r
-#include <core/producer/frame/frame_visitor.h>\r
-#include <core/producer/frame/pixel_format.h>\r
-\r
-#include "../gpu/host_buffer.h"\r
-\r
-#include <boost/noncopyable.hpp>\r
-#include <boost/thread/future.hpp>\r
-\r
-#include <memory>\r
-#include <vector>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-class image_mixer : public core::frame_visitor, boost::noncopyable\r
-{\r
-public:\r
- image_mixer(const core::video_format_desc& format_desc);\r
- \r
- virtual void begin(const core::basic_frame& frame);\r
- virtual void visit(core::write_frame& frame);\r
- virtual void end();\r
-\r
- boost::unique_future<safe_ptr<const host_buffer>> begin_pass();\r
- void end_pass();\r
-\r
- std::vector<safe_ptr<host_buffer>> create_buffers(const core::pixel_format_desc& format);\r
-\r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <ItemGroup Label="ProjectConfigurations">\r
- <ProjectConfiguration Include="Profile|Win32">\r
- <Configuration>Profile</Configuration>\r
- <Platform>Win32</Platform>\r
- </ProjectConfiguration>\r
- <ProjectConfiguration Include="Debug|Win32">\r
- <Configuration>Debug</Configuration>\r
- <Platform>Win32</Platform>\r
- </ProjectConfiguration>\r
- <ProjectConfiguration Include="Develop|Win32">\r
- <Configuration>Develop</Configuration>\r
- <Platform>Win32</Platform>\r
- </ProjectConfiguration>\r
- <ProjectConfiguration Include="Release|Win32">\r
- <Configuration>Release</Configuration>\r
- <Platform>Win32</Platform>\r
- </ProjectConfiguration>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <ClCompile Include="audio\audio_mixer.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="frame_mixer_device.cpp" />\r
- <ClCompile Include="gpu\device_buffer.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="gpu\gpu_read_frame.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="gpu\gpu_write_frame.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="gpu\host_buffer.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="gpu\ogl_device.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="image\image_kernel.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="image\image_mixer.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="StdAfx.cpp">\r
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>\r
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">Create</PrecompiledHeader>\r
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">Create</PrecompiledHeader>\r
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>\r
- </ClCompile>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <ClInclude Include="audio\audio_mixer.h" />\r
- <ClInclude Include="frame_mixer_device.h" />\r
- <ClInclude Include="gpu\device_buffer.h" />\r
- <ClInclude Include="gpu\gpu_read_frame.h" />\r
- <ClInclude Include="gpu\gpu_write_frame.h" />\r
- <ClInclude Include="gpu\host_buffer.h" />\r
- <ClInclude Include="gpu\ogl_device.h" />\r
- <ClInclude Include="image\image_kernel.h" />\r
- <ClInclude Include="image\image_mixer.h" />\r
- <ClInclude Include="StdAfx.h" />\r
- </ItemGroup>\r
- <ItemGroup>\r
- <ProjectReference Include="..\common\common.vcxproj">\r
- <Project>{02308602-7fe0-4253-b96e-22134919f56a}</Project>\r
- </ProjectReference>\r
- </ItemGroup>\r
- <PropertyGroup Label="Globals">\r
- <ProjectGuid>{477E12A4-1B28-4FF7-B46D-76606BDD1891}</ProjectGuid>\r
- <Keyword>Win32Proj</Keyword>\r
- <RootNamespace>mixer</RootNamespace>\r
- </PropertyGroup>\r
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
- <ConfigurationType>StaticLibrary</ConfigurationType>\r
- <UseDebugLibraries>true</UseDebugLibraries>\r
- <CharacterSet>Unicode</CharacterSet>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
- <ConfigurationType>StaticLibrary</ConfigurationType>\r
- <UseDebugLibraries>false</UseDebugLibraries>\r
- <WholeProgramOptimization>true</WholeProgramOptimization>\r
- <CharacterSet>Unicode</CharacterSet>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'" Label="Configuration">\r
- <ConfigurationType>StaticLibrary</ConfigurationType>\r
- <UseDebugLibraries>false</UseDebugLibraries>\r
- <WholeProgramOptimization>true</WholeProgramOptimization>\r
- <CharacterSet>Unicode</CharacterSet>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'" Label="Configuration">\r
- <ConfigurationType>StaticLibrary</ConfigurationType>\r
- <UseDebugLibraries>false</UseDebugLibraries>\r
- <WholeProgramOptimization>true</WholeProgramOptimization>\r
- <CharacterSet>Unicode</CharacterSet>\r
- </PropertyGroup>\r
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
- <ImportGroup Label="ExtensionSettings">\r
- </ImportGroup>\r
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
- </ImportGroup>\r
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
- </ImportGroup>\r
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'" Label="PropertySheets">\r
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
- </ImportGroup>\r
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'" Label="PropertySheets">\r
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
- </ImportGroup>\r
- <PropertyGroup Label="UserMacros" />\r
- <PropertyGroup>\r
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)tmp\$(Configuration)\</IntDir>\r
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)tmp\$(Configuration)\</IntDir>\r
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(ProjectDir)tmp\$(Configuration)\</IntDir>\r
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">$(ProjectDir)tmp\$(Configuration)\</IntDir>\r
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\;..\common;..\dependencies\BluefishSDK_V5_8_0_31\Inc\;..\dependencies\boost_1_44_0\;..\dependencies\ffmpeg 0.6\include\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\include\;..\dependencies\tbb30_20100406oss\include\;$(IncludePath)</IncludePath>\r
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\;..\common;..\dependencies\BluefishSDK_V5_8_0_31\Inc\;..\dependencies\boost_1_44_0\;..\dependencies\ffmpeg 0.6\include\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\include\;..\dependencies\tbb30_20100406oss\include\;$(IncludePath)</IncludePath>\r
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">..\;..\common;..\dependencies\BluefishSDK_V5_8_0_31\Inc\;..\dependencies\boost_1_44_0\;..\dependencies\ffmpeg 0.6\include\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\include\;..\dependencies\tbb30_20100406oss\include\;$(IncludePath)</IncludePath>\r
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">..\;..\common;..\dependencies\BluefishSDK_V5_8_0_31\Inc\;..\dependencies\boost_1_44_0\;..\dependencies\ffmpeg 0.6\include\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\include\;..\dependencies\tbb30_20100406oss\include\;$(IncludePath)</IncludePath>\r
- <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\dependencies\BluefishSDK_V5_8_0_31\Lib\;..\dependencies\boost_1_44_0\stage\lib\;..\dependencies\ffmpeg 0.6\lib\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\lib\;..\dependencies\tbb30_20100406oss\lib\ia32\vc10\;$(LibraryPath)</LibraryPath>\r
- <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\dependencies\BluefishSDK_V5_8_0_31\Lib\;..\dependencies\boost_1_44_0\stage\lib\;..\dependencies\ffmpeg 0.6\lib\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\lib\;..\dependencies\tbb30_20100406oss\lib\ia32\vc10\;$(LibraryPath)</LibraryPath>\r
- <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">..\dependencies\BluefishSDK_V5_8_0_31\Lib\;..\dependencies\boost_1_44_0\stage\lib\;..\dependencies\ffmpeg 0.6\lib\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\lib\;..\dependencies\tbb30_20100406oss\lib\ia32\vc10\;$(LibraryPath)</LibraryPath>\r
- <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">..\dependencies\BluefishSDK_V5_8_0_31\Lib\;..\dependencies\boost_1_44_0\stage\lib\;..\dependencies\ffmpeg 0.6\lib\;..\dependencies\FreeImage\Dist\;..\dependencies\GLee5_4\;..\dependencies\SFML-1.6\lib\;..\dependencies\tbb30_20100406oss\lib\ia32\vc10\;$(LibraryPath)</LibraryPath>\r
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)bin\$(Configuration)\</OutDir>\r
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)bin\$(Configuration)\</OutDir>\r
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(ProjectDir)bin\$(Configuration)\</OutDir>\r
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">$(ProjectDir)bin\$(Configuration)\</OutDir>\r
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)</TargetName>\r
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)</TargetName>\r
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(ProjectName)</TargetName>\r
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">$(ProjectName)</TargetName>\r
- </PropertyGroup>\r
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <ClCompile>\r
- <PrecompiledHeader>Use</PrecompiledHeader>\r
- <WarningLevel>Level4</WarningLevel>\r
- <Optimization>Disabled</Optimization>\r
- <PreprocessorDefinitions>TBB_USE_CAPTURED_EXCEPTION=0;TBB_USE_ASSERT=1;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
- <FloatingPointModel>Fast</FloatingPointModel>\r
- <MultiProcessorCompilation>true</MultiProcessorCompilation>\r
- <MinimalRebuild>false</MinimalRebuild>\r
- <ExceptionHandling>Async</ExceptionHandling>\r
- <ForcedIncludeFiles>common/compiler/vs/disable_silly_warnings.h</ForcedIncludeFiles>\r
- <TreatWarningAsError>true</TreatWarningAsError>\r
- </ClCompile>\r
- <Link>\r
- <SubSystem>Windows</SubSystem>\r
- <GenerateDebugInformation>true</GenerateDebugInformation>\r
- </Link>\r
- <Lib />\r
- </ItemDefinitionGroup>\r
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <ClCompile>\r
- <WarningLevel>Level4</WarningLevel>\r
- <PrecompiledHeader>Use</PrecompiledHeader>\r
- <Optimization>MaxSpeed</Optimization>\r
- <FunctionLevelLinking>true</FunctionLevelLinking>\r
- <IntrinsicFunctions>true</IntrinsicFunctions>\r
- <PreprocessorDefinitions>TBB_USE_CAPTURED_EXCEPTION=0;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
- <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\r
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
- <FloatingPointModel>Fast</FloatingPointModel>\r
- <MultiProcessorCompilation>true</MultiProcessorCompilation>\r
- <MinimalRebuild>false</MinimalRebuild>\r
- <ExceptionHandling>Async</ExceptionHandling>\r
- <ForcedIncludeFiles>common/compiler/vs/disable_silly_warnings.h</ForcedIncludeFiles>\r
- <TreatWarningAsError>true</TreatWarningAsError>\r
- </ClCompile>\r
- <Link>\r
- <SubSystem>Windows</SubSystem>\r
- <GenerateDebugInformation>true</GenerateDebugInformation>\r
- <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
- <OptimizeReferences>true</OptimizeReferences>\r
- </Link>\r
- <Lib>\r
- <LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>\r
- </Lib>\r
- </ItemDefinitionGroup>\r
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">\r
- <ClCompile>\r
- <WarningLevel>Level4</WarningLevel>\r
- <PrecompiledHeader>Use</PrecompiledHeader>\r
- <Optimization>MaxSpeed</Optimization>\r
- <FunctionLevelLinking>true</FunctionLevelLinking>\r
- <IntrinsicFunctions>true</IntrinsicFunctions>\r
- <PreprocessorDefinitions>TBB_USE_CAPTURED_EXCEPTION=0;TBB_USE_THREADING_TOOLS=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
- <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>\r
- <WholeProgramOptimization>false</WholeProgramOptimization>\r
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
- <FloatingPointModel>Fast</FloatingPointModel>\r
- <MultiProcessorCompilation>true</MultiProcessorCompilation>\r
- <MinimalRebuild>false</MinimalRebuild>\r
- <ExceptionHandling>Async</ExceptionHandling>\r
- <ForcedIncludeFiles>common/compiler/vs/disable_silly_warnings.h</ForcedIncludeFiles>\r
- <TreatWarningAsError>true</TreatWarningAsError>\r
- </ClCompile>\r
- <Link>\r
- <SubSystem>Windows</SubSystem>\r
- <GenerateDebugInformation>true</GenerateDebugInformation>\r
- <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
- <OptimizeReferences>true</OptimizeReferences>\r
- </Link>\r
- <Lib />\r
- </ItemDefinitionGroup>\r
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">\r
- <ClCompile>\r
- <WarningLevel>Level4</WarningLevel>\r
- <PrecompiledHeader>Use</PrecompiledHeader>\r
- <Optimization>Disabled</Optimization>\r
- <FunctionLevelLinking>true</FunctionLevelLinking>\r
- <IntrinsicFunctions>true</IntrinsicFunctions>\r
- <PreprocessorDefinitions>TBB_USE_CAPTURED_EXCEPTION=0;TBB_USE_ASSERT=1;TBB_USE_PERFORMANCE_WARNINGS=1;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
- <MultiProcessorCompilation>true</MultiProcessorCompilation>\r
- <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\r
- <WholeProgramOptimization>false</WholeProgramOptimization>\r
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
- <FloatingPointModel>Fast</FloatingPointModel>\r
- <MinimalRebuild>false</MinimalRebuild>\r
- <ExceptionHandling>Async</ExceptionHandling>\r
- <ForcedIncludeFiles>common/compiler/vs/disable_silly_warnings.h</ForcedIncludeFiles>\r
- <TreatWarningAsError>true</TreatWarningAsError>\r
- </ClCompile>\r
- <Link>\r
- <SubSystem>Windows</SubSystem>\r
- <GenerateDebugInformation>true</GenerateDebugInformation>\r
- <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
- <OptimizeReferences>true</OptimizeReferences>\r
- </Link>\r
- <Lib />\r
- </ItemDefinitionGroup>\r
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
- <ImportGroup Label="ExtensionTargets">\r
- </ImportGroup>\r
-</Project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <ItemGroup>\r
- <Filter Include="audio">\r
- <UniqueIdentifier>{ad4b4d9e-2c3d-48fb-977f-edce86b653e1}</UniqueIdentifier>\r
- </Filter>\r
- <Filter Include="gpu">\r
- <UniqueIdentifier>{3c5b1ceb-6788-4278-98cc-0c5865cda30a}</UniqueIdentifier>\r
- </Filter>\r
- <Filter Include="image">\r
- <UniqueIdentifier>{54ed246e-98e3-4544-bfbb-71912a901e8e}</UniqueIdentifier>\r
- </Filter>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <ClCompile Include="audio\audio_mixer.cpp">\r
- <Filter>audio</Filter>\r
- </ClCompile>\r
- <ClCompile Include="gpu\host_buffer.cpp">\r
- <Filter>gpu</Filter>\r
- </ClCompile>\r
- <ClCompile Include="gpu\ogl_device.cpp">\r
- <Filter>gpu</Filter>\r
- </ClCompile>\r
- <ClCompile Include="gpu\device_buffer.cpp">\r
- <Filter>gpu</Filter>\r
- </ClCompile>\r
- <ClCompile Include="frame_mixer_device.cpp" />\r
- <ClCompile Include="StdAfx.cpp" />\r
- <ClCompile Include="image\image_kernel.cpp">\r
- <Filter>image</Filter>\r
- </ClCompile>\r
- <ClCompile Include="image\image_mixer.cpp">\r
- <Filter>image</Filter>\r
- </ClCompile>\r
- <ClCompile Include="gpu\gpu_read_frame.cpp">\r
- <Filter>gpu</Filter>\r
- </ClCompile>\r
- <ClCompile Include="gpu\gpu_write_frame.cpp">\r
- <Filter>gpu</Filter>\r
- </ClCompile>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <ClInclude Include="audio\audio_mixer.h">\r
- <Filter>audio</Filter>\r
- </ClInclude>\r
- <ClInclude Include="gpu\device_buffer.h">\r
- <Filter>gpu</Filter>\r
- </ClInclude>\r
- <ClInclude Include="gpu\host_buffer.h">\r
- <Filter>gpu</Filter>\r
- </ClInclude>\r
- <ClInclude Include="gpu\ogl_device.h">\r
- <Filter>gpu</Filter>\r
- </ClInclude>\r
- <ClInclude Include="StdAfx.h" />\r
- <ClInclude Include="frame_mixer_device.h" />\r
- <ClInclude Include="image\image_kernel.h">\r
- <Filter>image</Filter>\r
- </ClInclude>\r
- <ClInclude Include="image\image_mixer.h">\r
- <Filter>image</Filter>\r
- </ClInclude>\r
- <ClInclude Include="gpu\gpu_write_frame.h">\r
- <Filter>gpu</Filter>\r
- </ClInclude>\r
- <ClInclude Include="gpu\gpu_read_frame.h">\r
- <Filter>gpu</Filter>\r
- </ClInclude>\r
- </ItemGroup>\r
-</Project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-</Project>
\ No newline at end of file
#include "video_decoder.h"\r
\r
#include <common/memory/safe_ptr.h>\r
+#include <common/memory/memcpy.h>\r
\r
#include <core/video_format.h>\r
-\r
#include <core/producer/frame/basic_frame.h>\r
#include <core/producer/frame/write_frame.h>\r
#include <core/producer/frame/image_transform.h>\r
\r
tbb::parallel_for(0, static_cast<int>(desc_.planes[n].height), 1, [&](int y)\r
{\r
- std::copy_n(decoded + y*decoded_linesize, plane.linesize, result + y*plane.linesize);\r
+ fast_memcpy(result + y*plane.linesize, decoded + y*decoded_linesize, plane.linesize);\r
});\r
});\r
}\r