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 <common/env.h>
27 #include <core/video_format.h>
28 #include <core/mixer/image/blend_modes.h>
30 #include <boost/array.hpp>
31 #include <boost/optional.hpp>
32 #include <boost/property_tree/ptree.hpp>
34 namespace caspar { namespace core {
38 enum class legacy_type
46 bool show_mask = false;
47 double target_hue = 0.0;
48 double hue_width = 0.0;
49 double min_saturation = 0.0;
50 double min_brightness = 0.0;
51 double softness = 0.0;
52 double spill_suppress = 0.0;
53 double spill_suppress_saturation = 1.0;
58 double min_input = 0.0;
59 double max_input = 1.0;
61 double min_output = 0.0;
62 double max_output = 1.0;
67 boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
68 boost::array<double, 2> ur = boost::array<double, 2> { { 1.0, 0.0 } };
69 boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
70 boost::array<double, 2> ll = boost::array<double, 2> { { 0.0, 1.0 } };
73 struct rectangle final
75 boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
76 boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
79 struct image_transform final
82 double contrast = 1.0;
83 double brightness = 1.0;
84 double saturation = 1.0;
86 // A bug in VS 2013 prevents us from writing:
87 // boost::array<double, 2> fill_translation = { { 0.0, 0.0 } };
88 // See http://blogs.msdn.com/b/vcblog/archive/2014/08/19/the-future-of-non-static-data-member-initialization.aspx
89 boost::array<double, 2> anchor = boost::array<double, 2> { { 0.0, 0.0 } };
90 boost::array<double, 2> fill_translation = boost::array<double, 2> { { 0.0, 0.0 } };
91 boost::array<double, 2> fill_scale = boost::array<double, 2> { { 1.0, 1.0 } };
92 boost::array<double, 2> clip_translation = boost::array<double, 2> { { 0.0, 0.0 } };
93 boost::array<double, 2> clip_scale = boost::array<double, 2> { { 1.0, 1.0 } };
100 core::field_mode field_mode = core::field_mode::progressive;
103 bool is_still = false;
104 bool use_mipmap = false;
105 core::blend_mode blend_mode = core::blend_mode::normal;
108 image_transform& operator*=(const image_transform &other);
109 image_transform operator*(const image_transform &other) const;
111 static image_transform tween(double time, const image_transform& source, const image_transform& dest, double duration, const tweener& tween);
114 bool operator==(const image_transform& lhs, const image_transform& rhs);
115 bool operator!=(const image_transform& lhs, const image_transform& rhs);
117 struct audio_transform final
120 bool is_still = false;
122 audio_transform& operator*=(const audio_transform &other);
123 audio_transform operator*(const audio_transform &other) const;
125 static audio_transform tween(double time, const audio_transform& source, const audio_transform& dest, double duration, const tweener& tween);
128 bool operator==(const audio_transform& lhs, const audio_transform& rhs);
129 bool operator!=(const audio_transform& lhs, const audio_transform& rhs);
131 //__declspec(align(16))
132 struct frame_transform final
137 core::image_transform image_transform;
138 core::audio_transform audio_transform;
140 //char padding[(sizeof(core::image_transform) + sizeof(core::audio_transform)) % 16];
142 frame_transform& operator*=(const frame_transform &other);
143 frame_transform operator*(const frame_transform &other) const;
145 static frame_transform tween(double time, const frame_transform& source, const frame_transform& dest, double duration, const tweener& tween);
148 bool operator==(const frame_transform& lhs, const frame_transform& rhs);
149 bool operator!=(const frame_transform& lhs, const frame_transform& rhs);
151 class tweened_transform
153 frame_transform source_;
154 frame_transform dest_;
163 dest_.image_transform.use_mipmap = env::properties().get(L"configuration.mixer.mipmapping-default-on", false);
166 tweened_transform(const frame_transform& source, const frame_transform& dest, int duration, const tweener& tween)
169 , duration_(duration)
175 const frame_transform& dest() const
180 frame_transform fetch()
182 return time_ == duration_ ? dest_ : frame_transform::tween(static_cast<double>(time_), source_, dest_, static_cast<double>(duration_), tweener_);
185 frame_transform fetch_and_tick(int num)
187 time_ = std::min(time_+num, duration_);
192 boost::optional<chroma::legacy_type> get_chroma_mode(const std::wstring& str);
196 void set_current_aspect_ratio(double aspect_ratio);
197 double get_current_aspect_ratio();