1 #include "../../stdafx.h"
\r
3 #include "basic_frame.h"
\r
5 #include "image_transform.h"
\r
6 #include "audio_transform.h"
\r
7 #include "pixel_format.h"
\r
8 #include "../../video_format.h"
\r
10 #include <boost/range/algorithm.hpp>
\r
12 namespace caspar { namespace core {
\r
14 struct basic_frame::implementation
\r
16 std::vector<safe_ptr<basic_frame>> frames_;
\r
18 image_transform image_transform_;
\r
19 audio_transform audio_transform_;
\r
24 implementation(const std::vector<safe_ptr<basic_frame>>& frames)
\r
26 , index_(std::numeric_limits<int>::min()) {}
\r
27 implementation(std::vector<safe_ptr<basic_frame>>&& frames)
\r
28 : frames_(std::move(frames))
\r
29 , index_(std::numeric_limits<int>::min()) {}
\r
31 void accept(basic_frame& self, frame_visitor& visitor)
\r
33 visitor.begin(self);
\r
34 BOOST_FOREACH(auto frame, frames_)
\r
35 frame->accept(visitor);
\r
40 basic_frame::basic_frame() : impl_(new implementation(std::vector<safe_ptr<basic_frame>>())){}
\r
41 basic_frame::basic_frame(const std::vector<safe_ptr<basic_frame>>& frames) : impl_(new implementation(frames)){}
\r
42 basic_frame::basic_frame(std::vector<safe_ptr<basic_frame>>&& frames) : impl_(new implementation(std::move(frames))){}
\r
43 basic_frame::basic_frame(const basic_frame& other) : impl_(new implementation(*other.impl_)){}
\r
44 basic_frame::basic_frame(const safe_ptr<basic_frame>& frame)
\r
46 std::vector<safe_ptr<basic_frame>> frames;
\r
47 frames.push_back(frame);
\r
48 impl_.reset(new implementation(std::move(frames)));
\r
50 basic_frame::basic_frame(safe_ptr<basic_frame>&& frame)
\r
52 std::vector<safe_ptr<basic_frame>> frames;
\r
53 frames.push_back(std::move(frame));
\r
54 impl_.reset(new implementation(std::move(frames)));
\r
56 basic_frame::basic_frame(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2)
\r
58 std::vector<safe_ptr<basic_frame>> frames;
\r
59 frames.push_back(frame1);
\r
60 frames.push_back(frame2);
\r
61 impl_.reset(new implementation(std::move(frames)));
\r
63 basic_frame::basic_frame(safe_ptr<basic_frame>&& frame1, safe_ptr<basic_frame>&& frame2)
\r
65 std::vector<safe_ptr<basic_frame>> frames;
\r
66 frames.push_back(std::move(frame1));
\r
67 frames.push_back(std::move(frame2));
\r
68 impl_.reset(new implementation(std::move(frames)));
\r
71 void basic_frame::swap(basic_frame& other){impl_.swap(other.impl_);}
\r
72 basic_frame& basic_frame::operator=(const basic_frame& other)
\r
74 basic_frame temp(other);
\r
78 basic_frame::basic_frame(basic_frame&& other) : impl_(std::move(other.impl_)){}
\r
79 basic_frame& basic_frame::operator=(basic_frame&& other)
\r
81 basic_frame temp(std::move(other));
\r
85 void basic_frame::accept(frame_visitor& visitor){impl_->accept(*this, visitor);}
\r
87 const image_transform& basic_frame::get_image_transform() const { return impl_->image_transform_;}
\r
88 image_transform& basic_frame::get_image_transform() { return impl_->image_transform_;}
\r
89 const audio_transform& basic_frame::get_audio_transform() const { return impl_->audio_transform_;}
\r
90 audio_transform& basic_frame::get_audio_transform() { return impl_->audio_transform_;}
\r
92 safe_ptr<basic_frame> basic_frame::interlace(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2, video_mode::type mode)
\r
94 if(frame1 == frame2 || mode == video_mode::progressive)
\r
97 auto my_frame1 = make_safe<basic_frame>(frame1);
\r
98 auto my_frame2 = make_safe<basic_frame>(frame2);
\r
99 if(mode == video_mode::upper)
\r
101 my_frame1->get_image_transform().set_mode(video_mode::upper);
\r
102 my_frame2->get_image_transform().set_mode(video_mode::lower);
\r
106 my_frame1->get_image_transform().set_mode(video_mode::lower);
\r
107 my_frame2->get_image_transform().set_mode(video_mode::upper);
\r
110 std::vector<safe_ptr<basic_frame>> frames;
\r
111 frames.push_back(my_frame1);
\r
112 frames.push_back(my_frame2);
\r
113 return make_safe<basic_frame>(frames);
\r
116 void basic_frame::set_layer_index(int index) { impl_->index_ = index; }
\r
117 int basic_frame::get_layer_index() const { return impl_->index_; }
\r