2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Robert Nagy, ronag89@gmail.com
24 #include <common/tweener.h>
25 #include <core/video_format.h>
26 #include <core/mixer/image/blend_modes.h>
28 #include <boost/array.hpp>
30 namespace caspar { namespace core {
34 double min_input = 0.0;
35 double max_input = 1.0;
37 double min_output = 0.0;
38 double max_output = 1.0;
43 boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
44 boost::array<double, 2> ur = boost::array<double, 2> { { 1.0, 0.0 } };
45 boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
46 boost::array<double, 2> ll = boost::array<double, 2> { { 0.0, 1.0 } };
49 struct rectangle final
51 boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
52 boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
55 struct image_transform final
58 double contrast = 1.0;
59 double brightness = 1.0;
60 double saturation = 1.0;
62 // A bug in VS 2013 prevents us from writing:
63 // boost::array<double, 2> fill_translation = { { 0.0, 0.0 } };
64 // See http://blogs.msdn.com/b/vcblog/archive/2014/08/19/the-future-of-non-static-data-member-initialization.aspx
65 boost::array<double, 2> anchor = boost::array<double, 2> { { 0.0, 0.0 } };
66 boost::array<double, 2> fill_translation = boost::array<double, 2> { { 0.0, 0.0 } };
67 boost::array<double, 2> fill_scale = boost::array<double, 2> { { 1.0, 1.0 } };
68 boost::array<double, 2> clip_translation = boost::array<double, 2> { { 0.0, 0.0 } };
69 boost::array<double, 2> clip_scale = boost::array<double, 2> { { 1.0, 1.0 } };
75 core::field_mode field_mode = core::field_mode::progressive;
78 bool is_still = false;
79 bool use_mipmap = false;
80 core::blend_mode blend_mode = core::blend_mode::normal;
83 image_transform& operator*=(const image_transform &other);
84 image_transform operator*(const image_transform &other) const;
86 static image_transform tween(double time, const image_transform& source, const image_transform& dest, double duration, const tweener& tween);
89 bool operator==(const image_transform& lhs, const image_transform& rhs);
90 bool operator!=(const image_transform& lhs, const image_transform& rhs);
92 struct audio_transform final
95 bool is_still = false;
97 audio_transform& operator*=(const audio_transform &other);
98 audio_transform operator*(const audio_transform &other) const;
100 static audio_transform tween(double time, const audio_transform& source, const audio_transform& dest, double duration, const tweener& tween);
103 bool operator==(const audio_transform& lhs, const audio_transform& rhs);
104 bool operator!=(const audio_transform& lhs, const audio_transform& rhs);
106 //__declspec(align(16))
107 struct frame_transform final
112 core::image_transform image_transform;
113 core::audio_transform audio_transform;
115 //char padding[(sizeof(core::image_transform) + sizeof(core::audio_transform)) % 16];
117 frame_transform& operator*=(const frame_transform &other);
118 frame_transform operator*(const frame_transform &other) const;
120 static frame_transform tween(double time, const frame_transform& source, const frame_transform& dest, double duration, const tweener& tween);
123 bool operator==(const frame_transform& lhs, const frame_transform& rhs);
124 bool operator!=(const frame_transform& lhs, const frame_transform& rhs);
126 class tweened_transform
128 frame_transform source_;
129 frame_transform dest_;
140 tweened_transform(const frame_transform& source, const frame_transform& dest, int duration, const tweener& tween)
143 , duration_(duration)
149 frame_transform fetch()
151 return time_ == duration_ ? dest_ : frame_transform::tween(static_cast<double>(time_), source_, dest_, static_cast<double>(duration_), tweener_);
154 frame_transform fetch_and_tick(int num)
156 time_ = std::min(time_+num, duration_);
163 void set_current_aspect_ratio(double aspect_ratio);
164 double get_current_aspect_ratio();