]> git.sesse.net Git - casparcg/blobdiff - core/producer/frame/basic_frame.cpp
2.0.2: Updated file info headers.
[casparcg] / core / producer / frame / basic_frame.cpp
index 619fc4cf096d42cfa18d0e7615d6538eae0a6b3a..8a3b2327864d86288e55ca5e644d57220ca63f3f 100644 (file)
@@ -1,32 +1,32 @@
 /*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
 *\r
-*  This file is part of CasparCG.\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
+* 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
+* 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
 #include "../../stdafx.h"\r
 \r
 #include "basic_frame.h"\r
 \r
-#include "image_transform.h"\r
-#include "audio_transform.h"\r
-#include "pixel_format.h"\r
+#include "frame_transform.h"\r
 #include "../../video_format.h"\r
 \r
-#include <boost/range/algorithm.hpp>\r
+#include <boost/foreach.hpp>\r
 \r
 namespace caspar { namespace core {\r
                                                                                                                                                                                                                                                                                                                \r
@@ -34,16 +34,25 @@ struct basic_frame::implementation
 {              \r
        std::vector<safe_ptr<basic_frame>> frames_;\r
 \r
-       image_transform image_transform_;       \r
-       audio_transform audio_transform_;\r
+       frame_transform frame_transform_;       \r
        \r
 public:\r
-       implementation(const std::vector<safe_ptr<basic_frame>>& frames) \r
-               : frames_(frames) {}\r
-       implementation(std::vector<safe_ptr<basic_frame>>&& frames) \r
-               : frames_(std::move(frames)){}\r
+       implementation(const std::vector<safe_ptr<basic_frame>>& frames) : frames_(frames) \r
+       {\r
+       }\r
+       implementation(std::vector<safe_ptr<basic_frame>>&& frames) : frames_(std::move(frames))\r
+       {\r
+       }\r
+       implementation(safe_ptr<basic_frame>&& frame) \r
+       {\r
+               frames_.push_back(std::move(frame));\r
+       }\r
+       implementation(const safe_ptr<basic_frame>& frame)              \r
+       { \r
+               frames_.push_back(frame);\r
+       }\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
@@ -53,101 +62,94 @@ public:
 };\r
        \r
 basic_frame::basic_frame() : impl_(new implementation(std::vector<safe_ptr<basic_frame>>())){}\r
-basic_frame::basic_frame(std::vector<safe_ptr<basic_frame>>&& frames) : impl_(new implementation(std::move(frames))){}\r
+basic_frame::basic_frame(const std::vector<safe_ptr<basic_frame>>& frames) : impl_(new implementation(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
-void basic_frame::swap(basic_frame& other){impl_.swap(other.impl_);}\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
+basic_frame::basic_frame(basic_frame&& other) : impl_(std::move(other.impl_)){}\r
 basic_frame& basic_frame::operator=(const basic_frame& other)\r
 {\r
        basic_frame temp(other);\r
        temp.swap(*this);\r
        return *this;\r
 }\r
-basic_frame::basic_frame(basic_frame&& other) : impl_(std::move(other.impl_)){}\r
 basic_frame& basic_frame::operator=(basic_frame&& other)\r
 {\r
        basic_frame temp(std::move(other));\r
        temp.swap(*this);\r
        return *this;\r
 }\r
+void basic_frame::swap(basic_frame& other){impl_.swap(other.impl_);}\r
+\r
+const frame_transform& basic_frame::get_frame_transform() const { return impl_->frame_transform_;}\r
+frame_transform& basic_frame::get_frame_transform() { return impl_->frame_transform_;}\r
 void basic_frame::accept(frame_visitor& visitor){impl_->accept(*this, visitor);}\r
 \r
-const image_transform& basic_frame::get_image_transform() const { return impl_->image_transform_;}\r
-image_transform& basic_frame::get_image_transform() { return impl_->image_transform_;}\r
-const audio_transform& basic_frame::get_audio_transform() const { return impl_->audio_transform_;}\r
-audio_transform& basic_frame::get_audio_transform() { return impl_->audio_transform_;}\r
+safe_ptr<basic_frame> basic_frame::interlace(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2, field_mode::type mode)\r
+{                              \r
+       if(frame1 == basic_frame::eof() || frame2 == basic_frame::eof())\r
+               return basic_frame::eof();\r
 \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
+       if(frame1 == frame2 || mode == field_mode::progressive)\r
                return frame2;\r
 \r
        auto my_frame1 = make_safe<basic_frame>(frame1);\r
        auto my_frame2 = make_safe<basic_frame>(frame2);\r
-       if(mode == video_mode::upper)\r
+       if(mode == field_mode::upper)\r
        {\r
-               my_frame1->get_image_transform().set_mode(video_mode::upper);   \r
-               my_frame2->get_image_transform().set_mode(video_mode::lower);   \r
-       }                                                                                        \r
-       else                                                                             \r
-       {                                                                                        \r
-               my_frame1->get_image_transform().set_mode(video_mode::lower);   \r
-               my_frame2->get_image_transform().set_mode(video_mode::upper);   \r
+               my_frame1->get_frame_transform().field_mode = field_mode::upper;        \r
+               my_frame2->get_frame_transform().field_mode = field_mode::lower;        \r
+       }                                                                        \r
+       else                                                             \r
+       {                                                                        \r
+               my_frame1->get_frame_transform().field_mode = field_mode::lower;        \r
+               my_frame2->get_frame_transform().field_mode = field_mode::upper;        \r
        }\r
 \r
        std::vector<safe_ptr<basic_frame>> frames;\r
        frames.push_back(my_frame1);\r
        frames.push_back(my_frame2);\r
-       return basic_frame(std::move(frames));\r
+       return make_safe<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
+{      \r
+       if(frame1 == basic_frame::eof() || frame2 == basic_frame::eof())\r
                return basic_frame::eof();\r
        \r
+       if(frame1 == basic_frame::empty() && frame2 == basic_frame::empty())\r
+               return basic_frame::empty();\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
+       return make_safe<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
+{      \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
+       if(fill == basic_frame::empty() || key == basic_frame::empty())\r
+               return basic_frame::empty();\r
 \r
        std::vector<safe_ptr<basic_frame>> frames;\r
-       key->get_image_transform().set_is_key(true);\r
+       key->get_frame_transform().is_key = true;\r
        frames.push_back(key);\r
        frames.push_back(fill);\r
-       return basic_frame(std::move(frames));\r
+       return make_safe<basic_frame>(std::move(frames));\r
+}\r
+\r
+safe_ptr<basic_frame> disable_audio(const safe_ptr<basic_frame>& frame)\r
+{\r
+       basic_frame frame2 = frame;\r
+       frame2.get_frame_transform().volume = 0.0;\r
+       return make_safe<basic_frame>(std::move(frame2));\r
 }\r
        \r
 }}
\ No newline at end of file