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/property_tree/ptree.hpp>
33 namespace caspar { namespace core {
44 type key = type::none;
45 double threshold = 0.0;
46 double softness = 0.0;
52 double min_input = 0.0;
53 double max_input = 1.0;
55 double min_output = 0.0;
56 double max_output = 1.0;
61 boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
62 boost::array<double, 2> ur = boost::array<double, 2> { { 1.0, 0.0 } };
63 boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
64 boost::array<double, 2> ll = boost::array<double, 2> { { 0.0, 1.0 } };
67 struct rectangle final
69 boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
70 boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
73 struct image_transform final
76 double contrast = 1.0;
77 double brightness = 1.0;
78 double saturation = 1.0;
80 // A bug in VS 2013 prevents us from writing:
81 // boost::array<double, 2> fill_translation = { { 0.0, 0.0 } };
82 // See http://blogs.msdn.com/b/vcblog/archive/2014/08/19/the-future-of-non-static-data-member-initialization.aspx
83 boost::array<double, 2> anchor = boost::array<double, 2> { { 0.0, 0.0 } };
84 boost::array<double, 2> fill_translation = boost::array<double, 2> { { 0.0, 0.0 } };
85 boost::array<double, 2> fill_scale = boost::array<double, 2> { { 1.0, 1.0 } };
86 boost::array<double, 2> clip_translation = boost::array<double, 2> { { 0.0, 0.0 } };
87 boost::array<double, 2> clip_scale = boost::array<double, 2> { { 1.0, 1.0 } };
94 core::field_mode field_mode = core::field_mode::progressive;
97 bool is_still = false;
98 bool use_mipmap = false;
99 core::blend_mode blend_mode = core::blend_mode::normal;
102 image_transform& operator*=(const image_transform &other);
103 image_transform operator*(const image_transform &other) const;
105 static image_transform tween(double time, const image_transform& source, const image_transform& dest, double duration, const tweener& tween);
108 bool operator==(const image_transform& lhs, const image_transform& rhs);
109 bool operator!=(const image_transform& lhs, const image_transform& rhs);
111 struct audio_transform final
114 bool is_still = false;
116 audio_transform& operator*=(const audio_transform &other);
117 audio_transform operator*(const audio_transform &other) const;
119 static audio_transform tween(double time, const audio_transform& source, const audio_transform& dest, double duration, const tweener& tween);
122 bool operator==(const audio_transform& lhs, const audio_transform& rhs);
123 bool operator!=(const audio_transform& lhs, const audio_transform& rhs);
125 //__declspec(align(16))
126 struct frame_transform final
131 core::image_transform image_transform;
132 core::audio_transform audio_transform;
134 //char padding[(sizeof(core::image_transform) + sizeof(core::audio_transform)) % 16];
136 frame_transform& operator*=(const frame_transform &other);
137 frame_transform operator*(const frame_transform &other) const;
139 static frame_transform tween(double time, const frame_transform& source, const frame_transform& dest, double duration, const tweener& tween);
142 bool operator==(const frame_transform& lhs, const frame_transform& rhs);
143 bool operator!=(const frame_transform& lhs, const frame_transform& rhs);
145 class tweened_transform
147 frame_transform source_;
148 frame_transform dest_;
157 dest_.image_transform.use_mipmap = env::properties().get(L"configuration.mixer.mipmapping_default_on", false);
160 tweened_transform(const frame_transform& source, const frame_transform& dest, int duration, const tweener& tween)
163 , duration_(duration)
169 const frame_transform& dest() const
174 frame_transform fetch()
176 return time_ == duration_ ? dest_ : frame_transform::tween(static_cast<double>(time_), source_, dest_, static_cast<double>(duration_), tweener_);
179 frame_transform fetch_and_tick(int num)
181 time_ = std::min(time_+num, duration_);
186 chroma::type get_chroma_mode(const std::wstring& str);
187 std::wstring get_chroma_mode(chroma::type type);
191 void set_current_aspect_ratio(double aspect_ratio);
192 double get_current_aspect_ratio();