]> git.sesse.net Git - casparcg/commitdiff
2.1.0: -write_frame: Refactored.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 4 Feb 2012 19:50:20 +0000 (19:50 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 4 Feb 2012 19:50:20 +0000 (19:50 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2243 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

18 files changed:
core/core.vcxproj
core/core.vcxproj.filters
core/frame/frame_factory.h
core/frame/write_frame.h [new file with mode: 0644]
core/mixer/gpu/image/image_mixer.cpp
core/mixer/gpu/image/image_mixer.h
core/mixer/gpu/write_frame.cpp
core/mixer/gpu/write_frame.h
core/mixer/image/image_mixer.h
core/mixer/mixer.cpp
core/mixer/mixer.h
core/producer/color/color_producer.h
core/video_channel.cpp
modules/ffmpeg/producer/muxer/frame_muxer.cpp
modules/ffmpeg/producer/muxer/frame_muxer.h
modules/ffmpeg/producer/util/util.cpp
modules/ffmpeg/producer/util/util.h
modules/ffmpeg/producer/video/video_decoder.h

index 6cac3876749467bc4b166a026c3c8327f4d822d8..be7fdd66a767d847d2501509dfa68d9f3d9cd2cb 100644 (file)
     <ClInclude Include="frame\frame_transform.h" />\r
     <ClInclude Include="frame\frame_visitor.h" />\r
     <ClInclude Include="frame\pixel_format.h" />\r
+    <ClInclude Include="frame\write_frame.h" />\r
     <ClInclude Include="mixer\audio\audio_util.h" />\r
     <ClInclude Include="mixer\gpu\device_buffer.h" />\r
     <ClInclude Include="mixer\gpu\host_buffer.h" />\r
index 7c424cb2ff11611437ddf8e19c06903d5c2f2246..5980cbba5b9ab5d1dfa7452729d618e6f0028e1d 100644 (file)
     <ClInclude Include="consumer\cadence_guard.h">\r
       <Filter>source\consumer</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="frame\write_frame.h">\r
+      <Filter>source\frame</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="producer\transition\transition_producer.cpp">\r
index 1cbf276f6ce174a1ba26defe3aa5142ac8158ebf..4411abc6aa04135c1c5f23c6a069fd347742c1b7 100644 (file)
@@ -33,7 +33,7 @@ struct frame_factory : boost::noncopyable
 {\r
        virtual ~frame_factory(){}\r
 \r
-       virtual spl::shared_ptr<class write_frame> create_frame(const void* video_stream_tag, const struct pixel_format_desc& desc) = 0;                \r
+       virtual spl::shared_ptr<struct write_frame> create_frame(const void* video_stream_tag, const struct pixel_format_desc& desc) = 0;               \r
        virtual struct video_format_desc get_video_format_desc() const = 0; // nothrow\r
 };\r
 \r
diff --git a/core/frame/write_frame.h b/core/frame/write_frame.h
new file mode 100644 (file)
index 0000000..538859c
--- /dev/null
@@ -0,0 +1,34 @@
+/*\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG (www.casparcg.com).\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
+* Author: Robert Nagy, ronag89@gmail.com\r
+*/\r
+\r
+#pragma once\r
+\r
+#include "data_frame.h"\r
+#include "draw_frame.h"\r
+\r
+namespace caspar { namespace core {\r
+       \r
+struct write_frame : public draw_frame, public data_frame\r
+{\r
+};\r
+\r
+\r
+}}
\ No newline at end of file
index 218938375af229d98f3a80fcf9d6b3caeb772853..abafb2f1afa02f96dbb245e2a07a659c70c79b58 100644 (file)
@@ -33,6 +33,7 @@
 #include <common/gl/gl_check.h>\r
 #include <common/concurrency/async.h>\r
 \r
+#include <core/frame/write_frame.h>\r
 #include <core/frame/frame_transform.h>\r
 #include <core/frame/pixel_format.h>\r
 #include <core/video_format.h>\r
@@ -267,6 +268,9 @@ public:
                if(frame == nullptr)\r
                        return;\r
 \r
+               if(frame->get_pixel_format_desc().format == core::pixel_format::invalid)\r
+                       return;\r
+\r
                item item;\r
                item.pix_desc   = frame->get_pixel_format_desc();\r
 \r
@@ -293,6 +297,11 @@ public:
        {\r
                return renderer_(std::move(layers_), format_desc);\r
        }\r
+       \r
+       virtual spl::shared_ptr<gpu::write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc)\r
+       {\r
+               return spl::make_shared<gpu::write_frame>(ogl_, tag, desc);\r
+       }\r
 };\r
 \r
 image_mixer::image_mixer(const spl::shared_ptr<accelerator>& ogl) : impl_(new impl(ogl)){}\r
@@ -302,5 +311,6 @@ void image_mixer::pop(){impl_->pop();}
 boost::unique_future<boost::iterator_range<const uint8_t*>> image_mixer::operator()(const video_format_desc& format_desc){return impl_->render(format_desc);}\r
 void image_mixer::begin_layer(blend_mode blend_mode){impl_->begin_layer(blend_mode);}\r
 void image_mixer::end_layer(){impl_->end_layer();}\r
+spl::shared_ptr<core::write_frame> image_mixer::create_frame(const void* tag, const pixel_format_desc& desc) {return impl_->create_frame(tag, desc);}\r
 \r
 }}}
\ No newline at end of file
index 702d6f47242c4727b0af81195cfe17344e2c589e..82d088699aa0badb03dc16c997df2c98da098239 100644 (file)
@@ -30,6 +30,8 @@
 #include <core/frame/frame_visitor.h>\r
 \r
 FORWARD1(boost, template<typename> class unique_future);\r
+FORWARD2(caspar, core, struct write_frame);\r
+FORWARD2(caspar, core, struct pixel_format_desc);\r
 \r
 namespace caspar { namespace core { namespace gpu {\r
        \r
@@ -48,6 +50,7 @@ public:
        // NOTE: Content of return future is only valid while future is valid.\r
        virtual boost::unique_future<boost::iterator_range<const uint8_t*>> operator()(const struct video_format_desc& format_desc) override;\r
                \r
+       virtual spl::shared_ptr<core::write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc) override;\r
 private:\r
        struct impl;\r
        spl::shared_ptr<impl> impl_;\r
index 90dfcee33c5d164bd90d92886aadf9248c84ea0a..2d1740e983267fca0b06f22b43a071ed5d3b234b 100644 (file)
@@ -33,7 +33,7 @@
 \r
 #include <boost/lexical_cast.hpp>\r
 \r
-namespace caspar { namespace core {\r
+namespace caspar { namespace core { namespace gpu {\r
                                                                                                                                                                                                                                                                                                                        \r
 struct write_frame::impl : boost::noncopyable\r
 {                      \r
@@ -54,10 +54,13 @@ struct write_frame::impl : boost::noncopyable
                , desc_(desc)\r
                , tag_(tag)\r
        {\r
-               std::transform(desc.planes.begin(), desc.planes.end(), std::back_inserter(buffers_), [&](const core::pixel_format_desc::plane& plane)\r
+               if(desc.format != core::pixel_format::invalid)\r
                {\r
-                       return ogl_->create_host_buffer(plane.size, gpu::host_buffer::usage::write_only);\r
-               });\r
+                       std::transform(desc.planes.begin(), desc.planes.end(), std::back_inserter(buffers_), [&](const core::pixel_format_desc::plane& plane)\r
+                       {\r
+                               return ogl_->create_host_buffer(plane.size, gpu::host_buffer::usage::write_only);\r
+                       });\r
+               }\r
        }\r
                        \r
        void accept(write_frame& self, core::frame_visitor& visitor)\r
@@ -98,5 +101,4 @@ int write_frame::height() const{return impl_->desc_.planes.at(0).height;}
 const void* write_frame::tag() const{return impl_->tag_;}      \r
 std::vector<spl::shared_ptr<gpu::host_buffer>> write_frame::get_buffers(){return impl_->buffers_;}\r
 \r
-\r
-}}
\ No newline at end of file
+}}}
\ No newline at end of file
index 89b83006874254cc2fa9a69ba9925848904ef6c3..38fb992f6a3b34b5bf5b7ca497c31abeca82b6ed 100644 (file)
@@ -24,8 +24,7 @@
 #include <common/spl/memory.h>\r
 #include <common/forward.h>\r
 \r
-#include <core/frame/draw_frame.h>\r
-#include <core/frame/data_frame.h>\r
+#include <core/frame/write_frame.h>\r
 #include <core/video_format.h>\r
 #include <core/mixer/audio/audio_mixer.h>\r
 \r
@@ -37,9 +36,9 @@
 FORWARD3(caspar, core, gpu, class accelerator);\r
 FORWARD3(caspar, core, gpu, class host_buffer);\r
 \r
-namespace caspar { namespace core {\r
+namespace caspar { namespace core { namespace gpu {\r
        \r
-class write_frame sealed : public core::draw_frame, public core::data_frame\r
+class write_frame sealed : public core::write_frame\r
 {\r
        write_frame(const write_frame&);\r
        write_frame& operator=(const write_frame);\r
@@ -81,5 +80,4 @@ private:
        spl::shared_ptr<impl> impl_;\r
 };\r
 \r
-\r
-}}
\ No newline at end of file
+}}}
\ No newline at end of file
index f32fd46889b5ce51d2c62da7b3bae03775d51218..0cac66c2ed0a430efe536ce108b6e616373027aa 100644 (file)
@@ -29,6 +29,8 @@
 #include <core/frame/frame_visitor.h>\r
 \r
 FORWARD1(boost, template<typename> class unique_future);\r
+FORWARD2(caspar, core, struct write_frame);\r
+FORWARD2(caspar, core, struct pixel_format_desc);\r
 \r
 namespace caspar { namespace core {\r
        \r
@@ -44,6 +46,7 @@ struct image_mixer : public frame_visitor
        virtual void end_layer() = 0;\r
                \r
        virtual boost::unique_future<boost::iterator_range<const uint8_t*>> operator()(const struct video_format_desc& format_desc) = 0;\r
+       virtual spl::shared_ptr<core::write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc) = 0;\r
 };\r
 \r
 }}
\ No newline at end of file
index 0f6de3956f14b3daae0687750f959a1b553ce3b5..9c8cd5d35f1976bd40afb56b2f313621f9bc9645 100644 (file)
@@ -197,4 +197,5 @@ mixer::mixer(const spl::shared_ptr<gpu::accelerator>& ogl)
 void mixer::set_blend_mode(int index, blend_mode value){impl_->set_blend_mode(index, value);}\r
 boost::unique_future<boost::property_tree::wptree> mixer::info() const{return impl_->info();}\r
 spl::shared_ptr<const data_frame> mixer::operator()(std::map<int, spl::shared_ptr<draw_frame>> frames, const struct video_format_desc& format_desc){return (*impl_)(std::move(frames), format_desc);}\r
+spl::shared_ptr<write_frame> mixer::create_frame(const void* tag, const core::pixel_format_desc& desc) {return impl_->image_mixer_->create_frame(tag, desc);}\r
 }}
\ No newline at end of file
index 12bdb07137a1a026ab745c373efcc154e9d2aa78..3929ae703ea6b2d7260a677b7c0b6ffac0c32f68 100644 (file)
@@ -35,6 +35,8 @@
 FORWARD1(boost, template<typename> class unique_future);\r
 FORWARD2(caspar, diagnostics, class graph);\r
 FORWARD3(caspar, core, gpu, class accelerator);\r
+FORWARD2(caspar, core, struct write_frame);\r
+FORWARD2(caspar, core, struct pixel_format_desc);\r
 \r
 namespace caspar { namespace core {\r
        \r
@@ -48,6 +50,8 @@ public:
        void set_blend_mode(int index, blend_mode value);\r
 \r
        boost::unique_future<boost::property_tree::wptree> info() const;\r
+\r
+       spl::shared_ptr<core::write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc);\r
 private:\r
        struct impl;\r
        spl::shared_ptr<impl> impl_;\r
index 05935baee098c348db72379498bce46ce9b637ba..8b4277e417e01a0d6155201feda5a33c77b06430 100644 (file)
@@ -29,6 +29,6 @@
 namespace caspar { namespace core {\r
        \r
 spl::shared_ptr<struct frame_producer> create_color_producer(const spl::shared_ptr<struct frame_factory>& frame_factory, const std::vector<std::wstring>& params);\r
-spl::shared_ptr<class write_frame> create_color_frame(void* tag, const spl::shared_ptr<struct frame_factory>& frame_factory, const std::wstring& color);\r
+spl::shared_ptr<struct write_frame> create_color_frame(void* tag, const spl::shared_ptr<struct frame_factory>& frame_factory, const std::wstring& color);\r
 \r
 }}\r
index 9d796582fe74cefecac93ee4ae0bc84bbfe02dd6..fdb1043e23462ac78b116641e9213cf4e3a26ea9 100644 (file)
@@ -92,7 +92,7 @@ public:
                                                \r
        virtual spl::shared_ptr<write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc) override\r
        {               \r
-               return spl::make_shared<write_frame>(ogl_, tag, desc);\r
+               return mixer_->create_frame(tag, desc);\r
        }\r
        \r
        virtual core::video_format_desc get_video_format_desc() const override\r
index ad6cccb0a2d768ca6dece13e05f7ff82e336a025..3198b7538d61b044ec0090ca6dd5d3ad5673f716 100644 (file)
@@ -114,7 +114,8 @@ struct frame_muxer::impl : boost::noncopyable
                }\r
                else if(video_frame == empty_video())\r
                {\r
-                       video_streams_.back().push(spl::make_shared<core::write_frame>(this));\r
+                       auto empty_frame = frame_factory_->create_frame(this, core::pixel_format_desc(core::pixel_format::invalid));\r
+                       video_streams_.back().push(empty_frame);\r
                        display_mode_ = display_mode::simple;\r
                }\r
                else\r
index 4f0a480a0def8877a143d8c4dbfe6f85b45c3e22..982d7eb76a87f56d847f622d08a8231f7743dcff 100644 (file)
@@ -23,6 +23,7 @@
 \r
 #include "display_mode.h"\r
 \r
+#include <common/forward.h>\r
 #include <common/spl/memory.h>\r
 \r
 #include <core/mixer/audio/audio_mixer.h>\r
 \r
 struct AVFrame;\r
 \r
-namespace caspar { \r
-       \r
-namespace core {\r
-\r
-class write_frame;\r
-class draw_frame;\r
-struct frame_factory;\r
-\r
-}\r
+FORWARD2(caspar, core, struct pixel_format_desc);\r
+FORWARD2(caspar, core, struct write_frame);\r
+FORWARD2(caspar, core, struct frame_factory);\r
+FORWARD2(caspar, core, class draw_frame);\r
 \r
-namespace ffmpeg {\r
+namespace caspar { namespace ffmpeg {\r
 \r
 class frame_muxer : boost::noncopyable\r
 {\r
index 4df89a12b50553141a52b6e9cb7409a802247a2c..9eb61fb8916811f95d5dbf331d952bbae5ef35d7 100644 (file)
@@ -176,7 +176,7 @@ spl::shared_ptr<core::write_frame> make_write_frame(const void* tag, const spl::
        static tbb::concurrent_unordered_map<int, tbb::concurrent_queue<std::shared_ptr<SwsContext>>> sws_contexts_;\r
        \r
        if(decoded_frame->width < 1 || decoded_frame->height < 1)\r
-               return spl::make_shared<core::write_frame>(tag);\r
+               return frame_factory->create_frame(tag, core::pixel_format_desc(core::pixel_format::invalid));\r
 \r
        const auto width  = decoded_frame->width;\r
        const auto height = decoded_frame->height;\r
index b17019c66b207e7a89147d27c92f7a3561421c01..6be7e209cd32378d5c8b14758997e684f3008a76 100644 (file)
@@ -21,6 +21,7 @@
 \r
 #pragma once\r
 \r
+#include <common/forward.h>\r
 #include <common/spl/memory.h>\r
 \r
 #include <core/video_format.h>\r
@@ -34,17 +35,11 @@ struct AVPacket;
 struct AVRational;\r
 struct AVCodecContext;\r
 \r
-namespace caspar {\r
+FORWARD2(caspar, core, struct pixel_format_desc);\r
+FORWARD2(caspar, core, struct write_frame);\r
+FORWARD2(caspar, core, struct frame_factory);\r
 \r
-namespace core {\r
-\r
-struct pixel_format_desc;\r
-class write_frame;\r
-struct frame_factory;\r
-\r
-}\r
-\r
-namespace ffmpeg {\r
+namespace caspar { namespace ffmpeg {\r
                \r
 std::shared_ptr<core::audio_buffer> flush_audio();\r
 std::shared_ptr<core::audio_buffer> empty_audio();\r
index 4d7d37855a27b5b286f540999137739cc177a51e..a71f3e457e2506cd84020a7283790e7268468f01 100644 (file)
@@ -22,6 +22,7 @@
 #pragma once\r
 \r
 #include <common/spl/memory.h>\r
+#include <common/forward.h>\r
 \r
 #include <boost/noncopyable.hpp>\r
 \r
@@ -29,14 +30,10 @@ struct AVFormatContext;
 struct AVFrame;\r
 struct AVPacket;\r
 \r
-namespace caspar {\r
+FORWARD2(caspar, core, struct write_frame);\r
+FORWARD2(caspar, core, struct frame_factory);\r
 \r
-namespace core {\r
-       struct frame_factory;\r
-       class write_frame;\r
-}\r
-\r
-namespace ffmpeg {\r
+namespace caspar { namespace ffmpeg {\r
 \r
 class video_decoder : boost::noncopyable\r
 {\r