]> git.sesse.net Git - casparcg/commitdiff
2.1.0: Refactored draw_frame.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 29 Jan 2012 20:39:16 +0000 (20:39 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 29 Jan 2012 20:39:16 +0000 (20:39 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2169 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/core.vcxproj
core/core.vcxproj.filters
core/frame/data_frame.cpp [new file with mode: 0644]
core/frame/data_frame.h
core/frame/draw_frame.cpp
core/frame/draw_frame.h
core/frame/frame_transform.cpp
core/producer/layer.cpp
core/producer/separated/separated_producer.cpp
core/producer/transition/transition_producer.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp

index b8429192576f3dd12905a11a33f1b66a74fb1e7e..d6f2f2a1bc09e7d5070b523bb03d3b8d6d368499 100644 (file)
     <ClInclude Include="StdAfx.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <ClCompile Include="frame\data_frame.cpp">\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
+    </ClCompile>\r
     <ClCompile Include="frame\draw_frame.cpp">\r
-      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
-      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
     </ClCompile>\r
     <ClCompile Include="frame\frame_transform.cpp">\r
-      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
-      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
     </ClCompile>\r
     <ClCompile Include="mixer\gpu\device_buffer.cpp">\r
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
index a30067b855d8d763ea083124347a03edad9c7428..e7db5e71e3028c726c4b29eb313c2d1a998ed4e1 100644 (file)
     <ClCompile Include="frame\draw_frame.cpp">\r
       <Filter>source\frame</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="frame\data_frame.cpp">\r
+      <Filter>source\frame</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
diff --git a/core/frame/data_frame.cpp b/core/frame/data_frame.cpp
new file mode 100644 (file)
index 0000000..0675953
--- /dev/null
@@ -0,0 +1,65 @@
+#include "../StdAfx.h"\r
+\r
+#include "data_frame.h"\r
+\r
+#include "pixel_format.h"\r
+\r
+namespace caspar { namespace core {\r
+\r
+data_frame::~data_frame()\r
+{\r
+}\r
+\r
+safe_ptr<data_frame> data_frame::empty()\r
+{\r
+       struct empty_frame : public data_frame\r
+       {\r
+               virtual const struct  video_format_desc& get_video_format_desc() const\r
+               {\r
+                       static video_format_desc invalid;\r
+                       return invalid;\r
+               }\r
+               virtual const struct  pixel_format_desc& get_pixel_format_desc() const \r
+               {\r
+                       static pixel_format_desc invalid;\r
+                       return invalid;\r
+               }\r
+               virtual const boost::iterator_range<const uint8_t*> image_data() const \r
+               {\r
+                       return boost::iterator_range<const uint8_t*>();\r
+               }\r
+               virtual const boost::iterator_range<const int32_t*> audio_data() const \r
+               {\r
+                       return boost::iterator_range<const int32_t*>();\r
+               }\r
+               const boost::iterator_range<uint8_t*> image_data()\r
+               {\r
+                       return boost::iterator_range<uint8_t*>();\r
+               }\r
+               const boost::iterator_range<int32_t*> audio_data()\r
+               {\r
+                       return boost::iterator_range<int32_t*>();\r
+               }\r
+               virtual double get_frame_rate() const\r
+               {\r
+                       return 0.0;\r
+               }\r
+               virtual field_mode get_field_mode() const\r
+               {\r
+                       return field_mode::empty;\r
+               }\r
+               virtual int width() const\r
+               {\r
+                       return 0;\r
+               }\r
+               virtual int height() const\r
+               {\r
+                       return 0;\r
+               }\r
+       };\r
+\r
+       static safe_ptr<empty_frame> empty;\r
+       return empty;\r
+}\r
+\r
+}}
\ No newline at end of file
index 091fbc575e345ca49ced4865a0cd3c03890fb144..f8c9ed9677caef216b3a97c4527d6a7e68fe5b41 100644 (file)
@@ -1,20 +1,21 @@
 #pragma once\r
 \r
+#include <common/memory/safe_ptr.h>\r
+\r
 #include <boost/noncopyable.hpp>\r
 #include <boost/range.hpp>\r
 \r
 #include <stdint.h>\r
 \r
-#include "pixel_format.h"\r
 #include "../video_format.h"\r
 \r
 namespace caspar { namespace core {\r
 \r
+struct pixel_format_desc;\r
+\r
 struct data_frame : boost::noncopyable\r
 {\r
-       virtual ~data_frame()\r
-       {\r
-       }\r
+       virtual ~data_frame();\r
 \r
        virtual const struct  pixel_format_desc& get_pixel_format_desc() const = 0;\r
 \r
@@ -30,57 +31,7 @@ struct data_frame : boost::noncopyable
        virtual int width() const = 0;\r
        virtual int height() const = 0;\r
 \r
-       static safe_ptr<data_frame> empty()\r
-       {\r
-               struct empty_frame : public data_frame\r
-               {\r
-                       virtual const struct  video_format_desc& get_video_format_desc() const\r
-                       {\r
-                               static video_format_desc invalid;\r
-                               return invalid;\r
-                       }\r
-                       virtual const struct  pixel_format_desc& get_pixel_format_desc() const \r
-                       {\r
-                               static pixel_format_desc invalid;\r
-                               return invalid;\r
-                       }\r
-                       virtual const boost::iterator_range<const uint8_t*> image_data() const \r
-                       {\r
-                               return boost::iterator_range<const uint8_t*>();\r
-                       }\r
-                       virtual const boost::iterator_range<const int32_t*> audio_data() const \r
-                       {\r
-                               return boost::iterator_range<const int32_t*>();\r
-                       }\r
-                       const boost::iterator_range<uint8_t*> image_data()\r
-                       {\r
-                               return boost::iterator_range<uint8_t*>();\r
-                       }\r
-                       const boost::iterator_range<int32_t*> audio_data()\r
-                       {\r
-                               return boost::iterator_range<int32_t*>();\r
-                       }\r
-                       virtual double get_frame_rate() const\r
-                       {\r
-                               return 0.0;\r
-                       }\r
-                       virtual field_mode get_field_mode() const\r
-                       {\r
-                               return field_mode::empty;\r
-                       }\r
-                       virtual int width() const\r
-                       {\r
-                               return 0;\r
-                       }\r
-                       virtual int height() const\r
-                       {\r
-                               return 0;\r
-                       }\r
-               };\r
-\r
-               static safe_ptr<empty_frame> empty;\r
-               return empty;\r
-       }\r
+       static safe_ptr<data_frame> empty();\r
 };\r
 \r
 }}
\ No newline at end of file
index 5bf6956907e914f57fa25779aa9cc069e302eca0..ae6ab32cf9937cc0afde0729da9255bf8da9acbd 100644 (file)
@@ -19,7 +19,7 @@
 * Author: Robert Nagy, ronag89@gmail.com\r
 */\r
 \r
-#include "../../stdafx.h"\r
+#include "../stdafx.h"\r
 \r
 #include "draw_frame.h"\r
 \r
@@ -110,7 +110,7 @@ safe_ptr<draw_frame> draw_frame::interlace(const safe_ptr<draw_frame>& frame1, c
        return make_safe<draw_frame>(std::move(frames));\r
 }\r
 \r
-safe_ptr<draw_frame> draw_frame::combine(const safe_ptr<draw_frame>& frame1, const safe_ptr<draw_frame>& frame2)\r
+safe_ptr<draw_frame> draw_frame::over(const safe_ptr<draw_frame>& frame1, const safe_ptr<draw_frame>& frame2)\r
 {      \r
        if(frame1 == draw_frame::eof() || frame2 == draw_frame::eof())\r
                return draw_frame::eof();\r
@@ -124,7 +124,7 @@ safe_ptr<draw_frame> draw_frame::combine(const safe_ptr<draw_frame>& frame1, con
        return make_safe<draw_frame>(std::move(frames));\r
 }\r
 \r
-safe_ptr<draw_frame> draw_frame::fill_and_key(const safe_ptr<draw_frame>& fill, const safe_ptr<draw_frame>& key)\r
+safe_ptr<draw_frame> draw_frame::mask(const safe_ptr<draw_frame>& fill, const safe_ptr<draw_frame>& key)\r
 {      \r
        if(fill == draw_frame::eof() || key == draw_frame::eof())\r
                return draw_frame::eof();\r
@@ -139,11 +139,30 @@ safe_ptr<draw_frame> draw_frame::fill_and_key(const safe_ptr<draw_frame>& fill,
        return make_safe<draw_frame>(std::move(frames));\r
 }\r
        \r
-safe_ptr<draw_frame> disable_audio(const safe_ptr<draw_frame>& frame)\r
+safe_ptr<draw_frame> draw_frame::silence(const safe_ptr<draw_frame>& frame)\r
 {\r
        auto frame2 = make_safe<draw_frame>(frame);\r
        frame2->get_frame_transform().volume = 0.0;\r
        return frame2;\r
 }\r
+\r
+const safe_ptr<draw_frame>& draw_frame::eof()\r
+{\r
+       static safe_ptr<draw_frame> frame = make_safe<draw_frame>();\r
+       return frame;\r
+}\r
+\r
+const safe_ptr<draw_frame>& draw_frame::empty()\r
+{\r
+       static safe_ptr<draw_frame> frame = make_safe<draw_frame>();\r
+       return frame;\r
+}\r
+\r
+const safe_ptr<draw_frame>& draw_frame::late()\r
+{\r
+       static safe_ptr<draw_frame> frame = make_safe<draw_frame>();\r
+       return frame;\r
+}\r
        \r
+\r
 }}
\ No newline at end of file
index 346c4a184879554ee0a1c6631f984a77458a014a..600dfd469329b553b8a808ce7fb73e5dcd2797fe 100644 (file)
@@ -35,48 +35,35 @@ class draw_frame
 {\r
 public:\r
        draw_frame();   \r
+       draw_frame(const draw_frame& other);\r
+       draw_frame(draw_frame&& other);\r
+       draw_frame& operator=(draw_frame other);\r
+\r
        draw_frame(const safe_ptr<draw_frame>& frame);\r
        draw_frame(safe_ptr<draw_frame>&& frame);\r
        draw_frame(const std::vector<safe_ptr<draw_frame>>& frames);\r
        draw_frame(std::vector<safe_ptr<draw_frame>>&& frames);\r
-       draw_frame(const draw_frame& other);\r
-       draw_frame(draw_frame&& other);\r
-\r
-       draw_frame& operator=(draw_frame other);\r
-       \r
+               \r
        void swap(draw_frame& other);\r
 \r
        const struct frame_transform& get_frame_transform() const;\r
        struct frame_transform& get_frame_transform();\r
                                \r
        static safe_ptr<draw_frame> interlace(const safe_ptr<draw_frame>& frame1, const safe_ptr<draw_frame>& frame2, field_mode mode);\r
-       static safe_ptr<draw_frame> combine(const safe_ptr<draw_frame>& frame1, const safe_ptr<draw_frame>& frame2);\r
-       static safe_ptr<draw_frame> fill_and_key(const safe_ptr<draw_frame>& fill, const safe_ptr<draw_frame>& key);\r
+       static safe_ptr<draw_frame> over(const safe_ptr<draw_frame>& frame1, const safe_ptr<draw_frame>& frame2);\r
+       static safe_ptr<draw_frame> mask(const safe_ptr<draw_frame>& fill, const safe_ptr<draw_frame>& key);\r
+       static safe_ptr<draw_frame> silence(const safe_ptr<draw_frame>& frame);\r
                \r
-       static const safe_ptr<draw_frame>& eof()\r
-       {\r
-               static safe_ptr<draw_frame> frame = make_safe<draw_frame>();\r
-               return frame;\r
-       }\r
-\r
-       static const safe_ptr<draw_frame>& empty()\r
-       {\r
-               static safe_ptr<draw_frame> frame = make_safe<draw_frame>();\r
-               return frame;\r
-       }\r
-\r
-       static const safe_ptr<draw_frame>& late()\r
-       {\r
-               static safe_ptr<draw_frame> frame = make_safe<draw_frame>();\r
-               return frame;\r
-       }\r
+       static const safe_ptr<draw_frame>& eof();\r
+       static const safe_ptr<draw_frame>& empty();\r
+       static const safe_ptr<draw_frame>& late();\r
        \r
+\r
        virtual void accept(frame_visitor& visitor);\r
 private:\r
        struct impl;\r
        safe_ptr<impl> impl_;\r
 };\r
        \r
-safe_ptr<draw_frame> disable_audio(const safe_ptr<draw_frame>& frame);\r
 \r
 }}
\ No newline at end of file
index dd8d3c5afe07613e1df98d17780de4dc08780f5b..6935578466a2135ef0e369819f63d5a4c158a655 100644 (file)
@@ -19,7 +19,7 @@
 * Author: Robert Nagy, ronag89@gmail.com\r
 */\r
 \r
-#include "../../stdafx.h"\r
+#include "../stdafx.h"\r
 \r
 #include "frame_transform.h"\r
 \r
index 2b74e5d95631042ec8082ae3077f65c044d07720..a8b498c32640b1b84dcac165f3519bfc6b28990e 100644 (file)
@@ -106,11 +106,11 @@ public:
                try\r
                {\r
                        if(is_paused_)\r
-                               return disable_audio(foreground_->last_frame());\r
+                               return draw_frame::silence(foreground_->last_frame());\r
                \r
                        auto frame = receive_and_follow(foreground_, flags);\r
                        if(frame == core::draw_frame::late())\r
-                               return disable_audio(foreground_->last_frame());\r
+                               return draw_frame::silence(foreground_->last_frame());\r
 \r
                        if(auto_play_delta_)\r
                        {\r
index 44585627d50b99298d5acb91b78094a1ceb6fe97..b2ce80642a8d93a83922f504f46e57e7855982d2 100644 (file)
@@ -69,7 +69,7 @@ struct separated_producer : public frame_producer
                if(fill_ == core::draw_frame::late() || key_ == core::draw_frame::late()) // One of the producers is lagging, keep them in sync.\r
                        return core::draw_frame::late();\r
                \r
-               auto frame = draw_frame::fill_and_key(fill_, key_);\r
+               auto frame = draw_frame::mask(fill_, key_);\r
 \r
                fill_ = draw_frame::late();\r
                key_  = draw_frame::late();\r
index 4531215486867d4614e56d8010080a3376b18890..f4fcfeaba7a90371cf02c36966e1f9585eacf662 100644 (file)
@@ -172,9 +172,9 @@ struct transition_producer : public frame_producer
                const auto s_frame = s_frame1->get_frame_transform() == s_frame2->get_frame_transform() ? s_frame2 : draw_frame::interlace(s_frame1, s_frame2, mode_);\r
                const auto d_frame = d_frame1->get_frame_transform() == d_frame2->get_frame_transform() ? d_frame2 : draw_frame::interlace(d_frame1, d_frame2, mode_);\r
                \r
-               last_frame_ = draw_frame::combine(s_frame2, d_frame2);\r
+               last_frame_ = draw_frame::over(s_frame2, d_frame2);\r
 \r
-               return draw_frame::combine(s_frame, d_frame);\r
+               return draw_frame::over(s_frame, d_frame);\r
        }\r
 };\r
 \r
index 1d38e92c26240b15ef67441d1a5faef448ce591c..fe9b15e216c32d46ab5e90e7cb5329cd1996360f 100644 (file)
@@ -152,7 +152,7 @@ public:
                graph_->set_value("frame-time", frame_timer_.elapsed()*format_desc_.fps*0.5);\r
                                \r
                if(frame_buffer_.empty() && input_.eof())\r
-                       return disable_audio(last_frame());\r
+                       return last_frame();\r
 \r
                if(frame_buffer_.empty())\r
                {\r
@@ -173,7 +173,7 @@ public:
 \r
        virtual safe_ptr<core::draw_frame> last_frame() const override\r
        {\r
-               return last_frame_;\r
+               return core::draw_frame::silence(last_frame_);\r
        }\r
 \r
        virtual uint32_t nb_frames() const override\r