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>
27 #include <boost/array.hpp>
29 namespace caspar { namespace core {
31 struct levels /* final */
48 struct image_transform /* final */
57 boost::array<double, 2> fill_translation;
58 boost::array<double, 2> fill_scale;
59 boost::array<double, 2> clip_translation;
60 boost::array<double, 2> clip_scale;
63 field_mode field_mode;
68 image_transform& operator*=(const image_transform &other);
69 image_transform operator*(const image_transform &other) const;
71 static image_transform tween(double time, const image_transform& source, const image_transform& dest, double duration, const tweener& tween);
74 bool operator==(const image_transform& lhs, const image_transform& rhs);
75 bool operator!=(const image_transform& lhs, const image_transform& rhs);
77 struct audio_transform /* final */
85 audio_transform& operator*=(const audio_transform &other);
86 audio_transform operator*(const audio_transform &other) const;
88 static audio_transform tween(double time, const audio_transform& source, const audio_transform& dest, double duration, const tweener& tween);
91 bool operator==(const audio_transform& lhs, const audio_transform& rhs);
92 bool operator!=(const audio_transform& lhs, const audio_transform& rhs);
94 //__declspec(align(16))
95 struct frame_transform /* final */
100 image_transform image_transform;
101 audio_transform audio_transform;
103 //char padding[(sizeof(core::image_transform) + sizeof(core::audio_transform)) % 16];
105 frame_transform& operator*=(const frame_transform &other);
106 frame_transform operator*(const frame_transform &other) const;
108 static frame_transform tween(double time, const frame_transform& source, const frame_transform& dest, double duration, const tweener& tween);
111 bool operator==(const frame_transform& lhs, const frame_transform& rhs);
112 bool operator!=(const frame_transform& lhs, const frame_transform& rhs);
114 class tweened_transform
116 frame_transform source_;
117 frame_transform dest_;
128 tweened_transform(const frame_transform& source, const frame_transform& dest, int duration, const tweener& tween)
131 , duration_(duration)
137 frame_transform fetch()
139 return time_ == duration_ ? dest_ : frame_transform::tween(static_cast<double>(time_), source_, dest_, static_cast<double>(duration_), tweener_);
142 frame_transform fetch_and_tick(int num)
144 time_ = std::min(time_+num, duration_);