\r
#include "image_transform.h"\r
#include "audio_transform.h"\r
-#include "pixel_format.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
audio_transform audio_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
frame->accept(visitor);\r
visitor.end();\r
} \r
+\r
+ std::wstring print() const\r
+ {\r
+ std::wstring str = L"\tbasic_frame[\n";\r
+ BOOST_FOREACH(auto& frame, frames_)\r
+ str += frame->print() + L"\n";\r
+ str += L"\n]";\r
+ return str;\r
+ }\r
};\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::accept(frame_visitor& visitor){impl_->accept(*this, visitor);}\r
+void basic_frame::swap(basic_frame& other){impl_.swap(other.impl_);}\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
\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
+std::wstring basic_frame::print() const{return impl_->print();}\r
+void basic_frame::accept(frame_visitor& visitor){impl_->accept(*this, visitor);}\r
+\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
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
+ my_frame1->get_image_transform().set_field_mode(field_mode::upper); \r
+ my_frame2->get_image_transform().set_field_mode(field_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_image_transform().set_field_mode(field_mode::lower); \r
+ my_frame2->get_image_transform().set_field_mode(field_mode::upper); \r
}\r
\r
std::vector<safe_ptr<basic_frame>> 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
}\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())\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
frames.push_back(fill);\r
return 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_audio_transform().set_has_audio(false);\r
+ return std::move(frame2);\r
+}\r
\r
}}
\ No newline at end of file