]> git.sesse.net Git - casparcg/blobdiff - core/producer/frame/basic_frame.cpp
2.0.0.2: ffmpeg-producer: Updated with "auto-mode" which will try to convert files...
[casparcg] / core / producer / frame / basic_frame.cpp
index 79621d4feeee21cd808af1197d60383a2849f560..3c9cd776d6e449cec821eeb43521e36b87493bd8 100644 (file)
@@ -1,3 +1,22 @@
+/*\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 "basic_frame.h"\r
@@ -23,8 +42,12 @@ public:
                : frames_(frames) {}\r
        implementation(std::vector<safe_ptr<basic_frame>>&& frames) \r
                : frames_(std::move(frames)){}\r
+       implementation(safe_ptr<basic_frame>&& frame) \r
+               { frames_.push_back(std::move(frame));}\r
+       implementation(const safe_ptr<basic_frame>& frame) \r
+               { frames_.push_back(frame);}\r
        \r
-       void accept(const basic_frame& self, frame_visitor& visitor)\r
+       void accept(basic_frame& self, frame_visitor& visitor)\r
        {\r
                visitor.begin(self);\r
                BOOST_FOREACH(auto frame, frames_)\r
@@ -34,36 +57,10 @@ public:
 };\r
        \r
 basic_frame::basic_frame() : impl_(new implementation(std::vector<safe_ptr<basic_frame>>())){}\r
-basic_frame::basic_frame(const std::vector<safe_ptr<basic_frame>>& frames) : impl_(new implementation(frames)){}\r
-basic_frame::basic_frame(std::vector<safe_ptr<basic_frame>>&& frames) : impl_(new implementation(std::move(frames))){}\r
 basic_frame::basic_frame(const basic_frame& other) : impl_(new implementation(*other.impl_)){}\r
-basic_frame::basic_frame(const safe_ptr<basic_frame>& frame)\r
-{\r
-       std::vector<safe_ptr<basic_frame>> frames;\r
-       frames.push_back(frame);\r
-       impl_.reset(new implementation(std::move(frames)));\r
-}\r
-basic_frame::basic_frame(safe_ptr<basic_frame>&& frame)\r
-{\r
-       std::vector<safe_ptr<basic_frame>> frames;\r
-       frames.push_back(std::move(frame));\r
-       impl_.reset(new implementation(std::move(frames)));\r
-}\r
-basic_frame::basic_frame(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2)\r
-{\r
-       std::vector<safe_ptr<basic_frame>> frames;\r
-       frames.push_back(frame1);\r
-       frames.push_back(frame2);\r
-       impl_.reset(new implementation(std::move(frames)));\r
-}\r
-basic_frame::basic_frame(safe_ptr<basic_frame>&& frame1, safe_ptr<basic_frame>&& frame2)\r
-{\r
-       std::vector<safe_ptr<basic_frame>> frames;\r
-       frames.push_back(std::move(frame1));\r
-       frames.push_back(std::move(frame2));\r
-       impl_.reset(new implementation(std::move(frames)));\r
-}\r
-\r
+basic_frame::basic_frame(std::vector<safe_ptr<basic_frame>>&& frames) : impl_(new implementation(frames)){}\r
+basic_frame::basic_frame(const safe_ptr<basic_frame>& frame) : impl_(new implementation(frame)){}\r
+basic_frame::basic_frame(safe_ptr<basic_frame>&& frame)  : impl_(new implementation(std::move(frame))){}\r
 void basic_frame::swap(basic_frame& other){impl_.swap(other.impl_);}\r
 basic_frame& basic_frame::operator=(const basic_frame& other)\r
 {\r
@@ -87,6 +84,12 @@ audio_transform& basic_frame::get_audio_transform() { return impl_->audio_transf
 \r
 safe_ptr<basic_frame> basic_frame::interlace(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2, video_mode::type mode)\r
 {                      \r
+       if(frame1 == basic_frame::empty() && frame2 == basic_frame::empty())\r
+               return basic_frame::empty();\r
+       \r
+       if(frame1 == basic_frame::eof() || frame2 == basic_frame::eof())\r
+               return basic_frame::eof();\r
+       \r
        if(frame1 == frame2 || mode == video_mode::progressive)\r
                return frame2;\r
 \r
@@ -106,7 +109,39 @@ safe_ptr<basic_frame> basic_frame::interlace(const safe_ptr<basic_frame>& frame1
        std::vector<safe_ptr<basic_frame>> frames;\r
        frames.push_back(my_frame1);\r
        frames.push_back(my_frame2);\r
-       return make_safe<basic_frame>(frames);\r
+       return basic_frame(std::move(frames));\r
+}\r
+\r
+safe_ptr<basic_frame> basic_frame::combine(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2)\r
+{\r
+       if(frame1 == basic_frame::empty() && frame2 == basic_frame::empty())\r
+               return basic_frame::empty();\r
+       \r
+       if(frame1 == basic_frame::eof() && frame2 == basic_frame::eof())\r
+               return basic_frame::eof();\r
+       \r
+       std::vector<safe_ptr<basic_frame>> frames;\r
+       frames.push_back(frame1);\r
+       frames.push_back(frame2);\r
+       return basic_frame(std::move(frames));\r
+}\r
+\r
+safe_ptr<basic_frame> basic_frame::fill_and_key(const safe_ptr<basic_frame>& fill, const safe_ptr<basic_frame>& key)\r
+{\r
+       if(fill == basic_frame::empty() && key == basic_frame::empty())\r
+               return basic_frame::empty();\r
+       \r
+       if(fill == basic_frame::eof() && key == basic_frame::eof())\r
+               return basic_frame::eof();\r
+\r
+       if(key == basic_frame::empty() || key == basic_frame::eof())\r
+               return fill;\r
+\r
+       std::vector<safe_ptr<basic_frame>> frames;\r
+       key->get_image_transform().set_is_key(true);\r
+       frames.push_back(key);\r
+       frames.push_back(fill);\r
+       return basic_frame(std::move(frames));\r
 }\r
        \r
 }}
\ No newline at end of file