]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 9 Apr 2011 16:24:40 +0000 (16:24 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 9 Apr 2011 16:24:40 +0000 (16:24 +0000)
14 files changed:
core/producer/color/color_producer.cpp
core/producer/frame/frame_factory.h
core/producer/frame/write_frame.h
mixer/frame_mixer_device.cpp
mixer/frame_mixer_device.h
mixer/gpu/gpu_write_frame.cpp
mixer/gpu/gpu_write_frame.h
modules/decklink/producer/decklink_producer.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/video/video_decoder.cpp
modules/ffmpeg/producer/video/video_decoder.h
modules/flash/producer/flash_producer.cpp
modules/image/producer/image_producer.cpp
modules/silverlight/producer/silverlight_producer.cpp

index ff527d489ee10b1283ccf43f22ece272142a2226..cc540d10cc449be8e56848e67776026257584970 100644 (file)
@@ -41,10 +41,10 @@ public:
                if(color.length() != 9 || color[0] != '#')\r
                        BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("color") << arg_value_info(narrow(color)) << msg_info("Invalid color code"));\r
 \r
-               auto frame = frame_factory->create_frame(1, 1, pixel_format::bgra);\r
+               auto frame = frame_factory->create_frame(this, 1, 1, pixel_format::bgra);\r
                auto& value = *reinterpret_cast<unsigned long*>(frame->image_data().begin());\r
                std::wstringstream str(color_str_.substr(1));\r
-               str >> std::hex >> value;       \r
+               str >> std::hex >> value;\r
                frame_ = std::move(frame);\r
        }\r
                        \r
index 856c9fb6ca0afb8003e28dbaafa3108d4049d28f..1c335301ed4dd5b630626ba86ef81849028c5568 100644 (file)
@@ -33,9 +33,9 @@ struct video_format_desc;
                \r
 struct frame_factory : boost::noncopyable\r
 {\r
-       virtual safe_ptr<write_frame> create_frame(const pixel_format_desc& desc) = 0;\r
-       virtual safe_ptr<write_frame> create_frame(size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra) = 0;           \r
-       virtual safe_ptr<write_frame> create_frame(pixel_format::type pix_fmt = pixel_format::bgra) = 0;\r
+       virtual safe_ptr<write_frame> create_frame(void* tag, const pixel_format_desc& desc) = 0;\r
+       virtual safe_ptr<write_frame> create_frame(void* tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra) = 0;                \r
+       virtual safe_ptr<write_frame> create_frame(void* tag, pixel_format::type pix_fmt = pixel_format::bgra) = 0;\r
        \r
        virtual const video_format_desc& get_video_format_desc() const = 0; // nothrow\r
 };\r
index 1265959d599a6b1313c37c5afe9ecfba1503d463..57bb8f7aa260e1e58b4a16b8dcd4ef1cee8eb2e1 100644 (file)
@@ -23,7 +23,6 @@ public:
 \r
        virtual void accept(frame_visitor& visitor) = 0;\r
 \r
-       virtual void tag(int tag) = 0;\r
        virtual int tag() const = 0;\r
 };\r
 \r
index dee228509f46a7f6b59932ed8ddffcf30a7943c2..e3a1211f2d8c3e303e64bb8f398f748bb9091709 100644 (file)
@@ -162,9 +162,9 @@ public:
                diag_->set_value("input-buffer", static_cast<float>(executor_.size())/static_cast<float>(executor_.capacity()));\r
        }\r
                \r
-       safe_ptr<write_frame> create_frame(const pixel_format_desc& desc)\r
+       safe_ptr<write_frame> create_frame(void* tag, const pixel_format_desc& desc)\r
        {\r
-               return make_safe<gpu_write_frame>(desc, image_mixer_.create_buffers(desc));\r
+               return make_safe<gpu_write_frame>(reinterpret_cast<int>(tag), desc, image_mixer_.create_buffers(desc));\r
        }\r
                                \r
        void set_image_transform(const image_transform& transform, int mix_duration, const std::wstring& tween)\r
@@ -278,23 +278,23 @@ frame_mixer_device::frame_mixer_device(frame_mixer_device&& other) : impl_(std::
 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::vector<safe_ptr<basic_frame>>& frames){impl_->send(frames);}\r
 const video_format_desc& frame_mixer_device::get_video_format_desc() const { return impl_->format_desc_; }\r
-safe_ptr<write_frame> frame_mixer_device::create_frame(const pixel_format_desc& desc){ return impl_->create_frame(desc); }             \r
-safe_ptr<write_frame> frame_mixer_device::create_frame(size_t width, size_t height, pixel_format::type pix_fmt)\r
+safe_ptr<write_frame> frame_mixer_device::create_frame(void* tag, const pixel_format_desc& desc){ return impl_->create_frame(tag, desc); }             \r
+safe_ptr<write_frame> frame_mixer_device::create_frame(void* tag, size_t width, size_t height, pixel_format::type pix_fmt)\r
 {\r
        // Create bgra frame\r
        pixel_format_desc desc;\r
        desc.pix_fmt = pix_fmt;\r
-       desc.planes.push_back(pixel_format_desc::plane(width, height, 4));\r
-       return create_frame(desc);\r
+       desc.planes.push_back( pixel_format_desc::plane(width, height, 4));\r
+       return create_frame(tag, desc);\r
 }\r
                        \r
-safe_ptr<write_frame> frame_mixer_device::create_frame(pixel_format::type pix_fmt)\r
+safe_ptr<write_frame> frame_mixer_device::create_frame(void* tag, pixel_format::type pix_fmt)\r
 {\r
        // Create bgra frame with output resolution\r
        pixel_format_desc desc;\r
        desc.pix_fmt = pix_fmt;\r
-       desc.planes.push_back(pixel_format_desc::plane(get_video_format_desc().width, get_video_format_desc().height, 4));\r
-       return create_frame(desc);\r
+       desc.planes.push_back( 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 image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_image_transform(transform, mix_duration, tween);}\r
 void frame_mixer_device::set_image_transform(int index, const image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_image_transform(index, transform, mix_duration, tween);}\r
index 5b41b4387755197f139d7b6d437c2073c0ba0c52..141feb1db7ea557a032c52f0ccf08e12bda73153 100644 (file)
@@ -49,9 +49,9 @@ public:
                \r
        void send(const std::vector<safe_ptr<basic_frame>>& frames); // nothrow\r
                \r
-       safe_ptr<write_frame> create_frame(const pixel_format_desc& desc);              \r
-       safe_ptr<write_frame> create_frame(size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra);                       \r
-       safe_ptr<write_frame> create_frame(pixel_format::type pix_fmt = pixel_format::bgra);\r
+       safe_ptr<write_frame> create_frame(void* tag, const pixel_format_desc& desc);           \r
+       safe_ptr<write_frame> create_frame(void* tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra);                    \r
+       safe_ptr<write_frame> create_frame(void* tag, pixel_format::type pix_fmt = pixel_format::bgra);\r
        \r
        const video_format_desc& get_video_format_desc() const; // nothrow\r
 \r
index 23494482bd2d41facf28eddec3029c522d22591d..489768c9aec312bd273e9cfd5717b6ea3684f32d 100644 (file)
@@ -23,10 +23,10 @@ struct gpu_write_frame::implementation : boost::noncopyable
        int tag_;\r
 \r
 public:\r
-       implementation(const pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) \r
+       implementation(int tag, const pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) \r
                : desc_(desc)\r
                , buffers_(buffers)\r
-               , tag_(std::numeric_limits<int>::min()){}\r
+               , tag_(tag){}\r
        \r
        void accept(gpu_write_frame& self, frame_visitor& visitor)\r
        {\r
@@ -52,7 +52,7 @@ public:
        }\r
 };\r
        \r
-gpu_write_frame::gpu_write_frame(const pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) : impl_(new implementation(desc, buffers)){}\r
+gpu_write_frame::gpu_write_frame(int tag, const 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
@@ -72,7 +72,6 @@ const boost::iterator_range<const short*> gpu_write_frame::audio_data() const
 {\r
        return boost::iterator_range<const short*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
 }\r
-void gpu_write_frame::tag(int tag) { impl_->tag_ = tag;}\r
 int gpu_write_frame::tag() const {return impl_->tag_;}\r
 const 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
index 08309be4dce36dfd39bf56317d79e0bcdec29de8..54884a432068f278f7b5967a73437579f21711bd 100644 (file)
@@ -18,25 +18,25 @@ struct pixel_format_desc;
 class gpu_write_frame : public core::write_frame\r
 {\r
 public:        \r
-       explicit gpu_write_frame(const pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers);\r
+       explicit gpu_write_frame(int tag, const 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 pixel_format_desc& get_pixel_format_desc() const;\r
+       std::vector<safe_ptr<host_buffer>>& get_plane_buffers();\r
                \r
-       boost::iterator_range<unsigned char*> image_data(size_t plane_index = 0);       \r
-       std::vector<short>& audio_data();\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
-       const boost::iterator_range<const unsigned char*> image_data(size_t plane_index = 0) const;\r
-       const boost::iterator_range<const short*> audio_data() const;\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(frame_visitor& visitor);\r
 \r
-       void tag(int tag);\r
-       int tag() const;\r
-\r
-       const pixel_format_desc& get_pixel_format_desc() const;\r
-       std::vector<safe_ptr<host_buffer>>& get_plane_buffers();\r
+       virtual int tag() const;\r
        \r
 private:\r
        struct implementation;\r
index 78049ce3602187cb836272a6707876bfe86a424d..d6d95832a397b26a8d8f8023d7768374eb8f9087 100644 (file)
@@ -173,7 +173,7 @@ public:
                desc.planes.push_back(core::pixel_format_desc::plane(d_mode_->GetWidth(),   d_mode_->GetHeight(), 1));\r
                desc.planes.push_back(core::pixel_format_desc::plane(d_mode_->GetWidth()/2, d_mode_->GetHeight(), 1));\r
                desc.planes.push_back(core::pixel_format_desc::plane(d_mode_->GetWidth()/2, d_mode_->GetHeight(), 1));                  \r
-               auto frame = frame_factory_->create_frame(desc);\r
+               auto frame = frame_factory_->create_frame(this, desc);\r
 \r
                unsigned char* data = reinterpret_cast<unsigned char*>(bytes);\r
                int frame_size = (d_mode_->GetWidth() * 16 / 8) * d_mode_->GetHeight();\r
index 415acb0e0f1b538546626f8d8395ad547a465e90..5a6d7bbfc49861e603fef60b958c4ae16d252eba 100644 (file)
@@ -87,8 +87,7 @@ public:
                                {\r
                                        try\r
                                        {\r
-                                               auto frame = video_decoder_->execute(video_packet);\r
-                                               frame->tag(reinterpret_cast<int>(this));\r
+                                               auto frame = video_decoder_->execute(this, video_packet);\r
                                                video_frame_channel_.push_back(std::move(frame));\r
                                        }\r
                                        catch(...)\r
@@ -131,7 +130,7 @@ public:
                                {\r
                                        if(!frame) // If there is no video create a dummy frame.\r
                                        {\r
-                                               frame = frame_factory_->create_frame(1, 1);\r
+                                               frame = frame_factory_->create_frame(this, 1, 1);\r
                                                std::fill(frame->image_data().begin(), frame->image_data().end(), 0);\r
                                        }\r
                                        \r
index 630d7030d87c10bbf626a05ce431c4432acdfa16..f9b53874d66d3737580064ac8ba68916804f46a2 100644 (file)
@@ -124,7 +124,7 @@ public:
                }\r
        }\r
        \r
-       safe_ptr<core::write_frame> execute(const aligned_buffer& video_packet)\r
+       safe_ptr<core::write_frame> execute(void* tag, const aligned_buffer& video_packet)\r
        {                               \r
                safe_ptr<AVFrame> decoded_frame(avcodec_alloc_frame(), av_free);\r
 \r
@@ -134,7 +134,7 @@ public:
                if(result < 0)\r
                        BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("avcodec_decode_video failed"));\r
                \r
-               auto write = frame_factory_->create_frame(desc_);\r
+               auto write = frame_factory_->create_frame(tag, desc_);\r
                if(sws_context_ == nullptr)\r
                {\r
                        tbb::parallel_for(0, static_cast<int>(desc_.planes.size()), 1, [&](int n)\r
@@ -167,6 +167,6 @@ public:
 };\r
 \r
 video_decoder::video_decoder(AVCodecContext* codec_context, const safe_ptr<core::frame_factory>& frame_factory) : impl_(new implementation(codec_context, frame_factory)){}\r
-safe_ptr<core::write_frame> video_decoder::execute(const aligned_buffer& video_packet){return impl_->execute(video_packet);}\r
+safe_ptr<core::write_frame> video_decoder::execute(void* tag, const aligned_buffer& video_packet){return impl_->execute(tag, video_packet);}\r
 \r
 }
\ No newline at end of file
index 0bc8b41fa57c8397a72c8261b452ad3563669efc..730b573d542ac3880aa2907e1a509271ede17f9b 100644 (file)
@@ -14,7 +14,7 @@ class video_decoder : boost::noncopyable
 {\r
 public:\r
        explicit video_decoder(AVCodecContext* codec_context, const safe_ptr<core::frame_factory>& frame_factory);\r
-       safe_ptr<core::write_frame> execute(const aligned_buffer& video_packet);        \r
+       safe_ptr<core::write_frame> execute(void* tag, const aligned_buffer& video_packet);     \r
 private:\r
        struct implementation;\r
        safe_ptr<implementation> impl_;\r
index d2e8f963e0ece731d9d35ca88db34a0cdccf969f..6cfc5cffe688afee89f6e4787162cb2d0cc2f5f7 100644 (file)
@@ -184,7 +184,7 @@ private:
                        std::fill_n(bmp_data_, format_desc_.size, 0);\r
                        ax_->DrawControl(static_cast<HDC>(hdc_.get()));\r
                \r
-                       auto frame = frame_factory_->create_frame();\r
+                       auto frame = frame_factory_->create_frame(this);\r
                        std::copy_n(bmp_data_, format_desc_.size, frame->image_data().begin());\r
                        head_ = frame;\r
                }               \r
index 98e6233aa3e20b1139254e4ec7c78e8918b5ccd0..fea055589070f4eee6ca664f6221ac2a827dc83e 100644 (file)
@@ -29,7 +29,7 @@ struct image_producer : public core::frame_producer
        {\r
                auto bitmap = load_image(filename_);\r
                FreeImage_FlipVertical(bitmap.get());\r
-               auto frame = frame_factory->create_frame(FreeImage_GetWidth(bitmap.get()), FreeImage_GetHeight(bitmap.get()));\r
+               auto frame = frame_factory->create_frame(this, FreeImage_GetWidth(bitmap.get()), FreeImage_GetHeight(bitmap.get()));\r
                std::copy_n(FreeImage_GetBits(bitmap.get()), frame->image_data().size(), frame->image_data().begin());\r
                frame_ = std::move(frame);\r
        }\r
index e558fc67b1543668cc9320f2d256a30270a26c68..cef09fd3fb9d498e03a73d680d5f8057a7c32553 100644 (file)
@@ -118,7 +118,7 @@ public:
                while (window_.GetEvent(Event)){}\r
                window_.Display();\r
                                \r
-               auto frame = frame_factory_->create_frame();\r
+               auto frame = frame_factory_->create_frame(this);\r
                ::BitBlt(mem_, 0, 0, format_desc_.width, format_desc_.height, screen_, 0, 0, SRCCOPY);          \r
                std::copy_n(bmp_data_, format_desc_.size, frame->image_data().begin());\r
 \r