]> git.sesse.net Git - casparcg/blobdiff - common/tweener.h
[framerate_producer] Fixed bug where second frame instead of first frame was shown...
[casparcg] / common / tweener.h
index 25833b5030a6e0631b4e40fe941edc1383a51a17..b5231f816375646711c21b6a66760ade521f61d9 100644 (file)
@@ -1,80 +1,83 @@
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#pragma once\r
-\r
-#include <functional>\r
-#include <vector>\r
-\r
-namespace caspar { namespace core {\r
-\r
-/**\r
- * A tweener can be used for creating any kind of (image position, image fade\r
- * in/out, audio volume etc) transition, by invoking it for each temporal\r
- * timepoint when a tweened value is needed.\r
- *\r
- * For video the temporal resolution will usually be each frame or field (for\r
- * interlaced material).\r
- *\r
- * For audio the smoothest transitions will be generated by using the samplerate\r
- * as temporal resolution, but using the video frame/field rate is probably fine\r
- * most of the times and much less time consuming.\r
- */\r
-class tweener\r
-{\r
-public:\r
-       /**\r
-        * Constructor.\r
-        *\r
-        * @param name The name of the tween function to use.\r
-        */\r
-       tweener(const std::wstring& name = L"linear");\r
-       tweener(const wchar_t* name);\r
-\r
-       /**\r
-        * @return The possible tween function names. Some of them may also support\r
-        *                 additional parameters appended to the name.\r
-        */\r
-       static const std::vector<std::wstring>& names();\r
-\r
-       /**\r
-        * Calculate a tweened value given a timepoint within the total duration\r
-        * and the starting value and the destination delta value.\r
-        *\r
-        * Usually b, c and d remains constant during a transition, while t changes\r
-        * for each temporal tweened value.\r
-        * \r
-        * @param t     The timepoint within the total duration (0 <= n <= d).\r
-        * @param b     The starting value.\r
-        * @param c     The destination value delta from the starting value\r
-        *              (absolute destination value - b).\r
-        * @param d The total duration (when t = d, the destination value should\r
-        *              have been reached).\r
-        *\r
-        * @return The tweened value for the given timepoint. Can sometimes be less\r
-        *             than b or greater than b + c for some tweener functions.\r
-        */\r
-       double operator()(double t, double b , double c, double d) const;\r
-private:\r
-       std::function<double(double, double, double, double)> func_;\r
-};\r
-\r
-}}
\ No newline at end of file
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+#include <functional>
+#include <vector>
+
+namespace caspar {
+
+/**
+ * A tweener can be used for creating any kind of (image position, image fade
+ * in/out, audio volume etc) transition, by invoking it for each temporal
+ * timepoint when a tweened value is needed.
+ *
+ * For video the temporal resolution will usually be each frame or field (for
+ * interlaced material).
+ *
+ * For audio the smoothest transitions will be generated by using the samplerate
+ * as temporal resolution, but using the video frame/field rate is probably fine
+ * most of the times and much less time consuming.
+ */
+class tweener
+{
+public:
+       /**
+        * Constructor.
+        *
+        * @param name The name of the tween function to use.
+        */
+       tweener(const std::wstring& name = L"linear");
+
+       /**
+        * @return The possible tween function names. Some of them may also support
+        *                 additional parameters appended to the name.
+        */
+       static const std::vector<std::wstring>& names();
+
+       /**
+        * Calculate a tweened value given a timepoint within the total duration
+        * and the starting value and the destination delta value.
+        *
+        * Usually b, c and d remains constant during a transition, while t changes
+        * for each temporal tweened value.
+        * 
+        * @param t     The timepoint within the total duration (0 <= n <= d).
+        * @param b     The starting value.
+        * @param c     The destination value delta from the starting value
+        *              (absolute destination value - b).
+        * @param d The total duration (when t = d, the destination value should
+        *              have been reached).
+        *
+        * @return The tweened value for the given timepoint. Can sometimes be less
+        *             than b or greater than b + c for some tweener functions.
+        */
+       double operator()(double t, double b , double c, double d) const;
+
+       bool operator==(const tweener& other) const;
+       bool operator!=(const tweener& other) const;
+private:
+       std::function<double(double, double, double, double)>   func_;
+       std::wstring                                                                                    name_;
+};
+
+}