]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 20 Mar 2011 13:42:06 +0000 (13:42 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 20 Mar 2011 13:42:06 +0000 (13:42 +0000)
16 files changed:
common/common.vcxproj
common/common.vcxproj.filters
common/utility/timer.h
common/utility/tweener.h [new file with mode: 0644]
core/producer/frame/audio_transform.cpp
core/producer/frame/audio_transform.h
core/producer/frame/image_transform.cpp
core/producer/frame/image_transform.h
mixer/frame_mixer_device.cpp
mixer/mixer.vcxproj
mixer/mixer.vcxproj.filters
mixer/tween.h [deleted file]
modules/flash/producer/flash_producer.cpp
modules/oal/consumer/oal_consumer.cpp
modules/ogl/consumer/ogl_consumer.cpp
shell/caspar.config

index c183cef41db252999f9d895f58a9b5c1f9a8a918..948986ae60e2f2afba057d3a414e96dc94c653fa 100644 (file)
     <ClInclude Include="utility\printer.h" />\r
     <ClInclude Include="utility\string.h" />\r
     <ClInclude Include="utility\timer.h" />\r
+    <ClInclude Include="utility\tweener.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="diagnostics\graph.cpp">\r
index 0504c22f9d727ca4b99bbd074f7eeabadd09914d..50380cfded7d05194d3419e37bba247c4d78839b 100644 (file)
@@ -84,5 +84,8 @@
     <ClInclude Include="utility\timer.h">\r
       <Filter>utility</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="utility\tweener.h">\r
+      <Filter>utility</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index 6d5a15dcaa55acbf6a4248ae52ad8ba8d356835e..574391682d057b98d3ea59b3d66a07268721583e 100644 (file)
@@ -7,71 +7,20 @@ namespace caspar {
 class timer\r
 {\r
 public:\r
-       timer()\r
-       {\r
-               QueryPerformanceFrequency(&freq_);\r
-               QueryPerformanceCounter(&time_);\r
-       }\r
+       timer() : time_(timeGetTime()){}\r
 \r
        double elapsed()\r
        {\r
-               LARGE_INTEGER t;\r
-               QueryPerformanceCounter(&t);\r
-               int ticks_passed = static_cast<int>(static_cast<__int64>(t.QuadPart) - static_cast<__int64>(time_.QuadPart));\r
-               return static_cast<double>(ticks_passed)/static_cast<double>(freq_.QuadPart);\r
+               return static_cast<double>(timeGetTime() - time_)/1000.0;\r
        }\r
        \r
        void reset()\r
        {\r
-               QueryPerformanceCounter(&time_);\r
+               time_ = timeGetTime();\r
        }\r
-\r
-       // Author: Ryan M. Geiss\r
-       // http://www.geisswerks.com/ryan/FAQS/timing.html\r
-       void tick(double interval)\r
-       {       \r
-               LARGE_INTEGER t;\r
-               QueryPerformanceCounter(&t);\r
-\r
-               if (time_.QuadPart != 0)\r
-               {\r
-                       int ticks_to_wait = static_cast<int>(static_cast<double>(freq_.QuadPart) * interval);\r
-                       int done = 0;\r
-                       do\r
-                       {\r
-                               QueryPerformanceCounter(&t);\r
-                               \r
-                               int ticks_passed = static_cast<int>(static_cast<__int64>(t.QuadPart) - static_cast<__int64>(time_.QuadPart));\r
-                               int ticks_left = ticks_to_wait - ticks_passed;\r
-\r
-                               if (t.QuadPart < time_.QuadPart)    // time wrap\r
-                                       done = 1;\r
-                               if (ticks_passed >= ticks_to_wait)\r
-                                       done = 1;\r
-                               \r
-                               if (!done)\r
-                               {\r
-                                       // if > 0.002s left, do Sleep(1), which will actually sleep some \r
-                                       //   steady amount, probably 1-2 ms,\r
-                                       //   and do so in a nice way (cpu meter drops; laptop battery spared).\r
-                                       // otherwise, do a few Sleep(0)'s, which just give up the timeslice,\r
-                                       //   but don't really save cpu or battery, but do pass a tiny\r
-                                       //   amount of time.\r
-                                       if (ticks_left > static_cast<int>((freq_.QuadPart*2)/1000))\r
-                                               Sleep(1);\r
-                                       else                        \r
-                                               for (int i = 0; i < 10; ++i) \r
-                                                       Sleep(0);  // causes thread to give up its timeslice\r
-                               }\r
-                       }\r
-                       while (!done);            \r
-               }\r
-\r
-               time_ = t;\r
-       }               \r
+       \r
 private:       \r
-       LARGE_INTEGER freq_;\r
-       LARGE_INTEGER time_;\r
+       DWORD time_;\r
 };\r
 \r
 }
\ No newline at end of file
diff --git a/common/utility/tweener.h b/common/utility/tweener.h
new file mode 100644 (file)
index 0000000..2cb8905
--- /dev/null
@@ -0,0 +1,410 @@
+//Disclaimer for Robert Penner's Easing Equations license:\r
+//\r
+//TERMS OF USE - EASING EQUATIONS\r
+//\r
+//Open source under the BSD License.\r
+//\r
+//Copyright © 2001 Robert Penner\r
+//All rights reserved.\r
+//\r
+//Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\r
+//\r
+//    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\r
+//    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\r
+//    * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.\r
+//\r
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+#pragma once\r
+\r
+#include <boost/assign/list_of.hpp>\r
+#include <unordered_map>\r
+#include <string>\r
+#include <locale>\r
+#include <functional>\r
+\r
+namespace caspar {\r
+\r
+typedef std::function<double(double, double, double, double)> tweener_t;\r
+                       \r
+static const double PI = std::atan(1.0)*4.0;\r
+static const double H_PI = std::atan(1.0)*2.0;\r
+\r
+inline double ease_none (double t, double b, double c, double d) \r
+{\r
+       return c*t/d + b;\r
+}\r
+\r
+inline double ease_in_quad (double t, double b, double c, double d) \r
+{\r
+       return c*(t/=d)*t + b;\r
+}\r
+       \r
+inline double ease_out_quad (double t, double b, double c, double d) \r
+{\r
+       return -c *(t/=d)*(t-2) + b;\r
+}      \r
+\r
+inline double ease_in_out_quad (double t, double b, double c, double d)\r
+{\r
+       if ((t/=d/2) < 1) \r
+               return c/2*t*t + b;\r
+\r
+       return -c/2 * ((--t)*(t-2) - 1) + b;\r
+}      \r
+\r
+inline double ease_out_in_quad (double t, double b, double c, double d)\r
+{\r
+       if (t < d/2) \r
+               return ease_out_quad (t*2, b, c/2, d);\r
+\r
+       return ease_in_quad((t*2)-d, b+c/2, c/2, d);\r
+}\r
+       \r
+inline double ease_in_cubic (double t, double b, double c, double d) \r
+{\r
+       return c*(t/=d)*t*t + b;\r
+}      \r
+\r
+inline double ease_out_cubic (double t, double b, double c, double d) \r
+{\r
+       return c*((t=t/d-1)*t*t + 1) + b;\r
+}\r
+       \r
+inline double ease_in_out_cubic (double t, double b, double c, double d) \r
+{\r
+       if ((t/=d/2) < 1) \r
+               return c/2*t*t*t + b;\r
+\r
+       return c/2*((t-=2)*t*t + 2) + b;\r
+}\r
+       \r
+inline double ease_out_in_cubic (double t, double b, double c, double d) \r
+{\r
+       if (t < d/2) return ease_out_cubic (t*2, b, c/2, d);\r
+       return ease_in_cubic((t*2)-d, b+c/2, c/2, d);\r
+}\r
+       \r
+inline double ease_in_quart (double t, double b, double c, double d) \r
+{\r
+       return c*(t/=d)*t*t*t + b;\r
+}\r
+       \r
+inline double ease_out_quart (double t, double b, double c, double d) \r
+{\r
+       return -c * ((t=t/d-1)*t*t*t - 1) + b;\r
+}      \r
+\r
+inline double ease_in_out_quart (double t, double b, double c, double d) \r
+{\r
+       if ((t/=d/2) < 1)\r
+               return c/2*t*t*t*t + b;\r
+\r
+       return -c/2 * ((t-=2)*t*t*t - 2) + b;\r
+}      \r
+\r
+inline double ease_out_in_quart (double t, double b, double c, double d) \r
+{\r
+       if (t < d/2)\r
+               return ease_out_quart (t*2, b, c/2, d);\r
+\r
+       return ease_in_quart((t*2)-d, b+c/2, c/2, d);\r
+}      \r
+\r
+inline double ease_in_quint (double t, double b, double c, double d) \r
+{\r
+       return c*(t/=d)*t*t*t*t + b;\r
+}\r
+       \r
+inline double ease_out_quint (double t, double b, double c, double d) \r
+{\r
+       return c*((t=t/d-1)*t*t*t*t + 1) + b;\r
+}\r
+       \r
+inline double ease_in_out_quint (double t, double b, double c, double d) \r
+{\r
+       if ((t/=d/2) < 1) \r
+               return c/2*t*t*t*t*t + b;\r
+\r
+       return c/2*((t-=2)*t*t*t*t + 2) + b;\r
+}\r
+       \r
+inline double ease_out_in_quint (double t, double b, double c, double d) \r
+{\r
+       if (t < d/2) \r
+               return ease_out_quint (t*2, b, c/2, d);\r
+\r
+       return ease_in_quint((t*2)-d, b+c/2, c/2, d);\r
+}      \r
+\r
+inline double ease_in_sine (double t, double b, double c, double d) \r
+{\r
+       return -c * std::cos(t/d * (PI/2)) + c + b;\r
+}      \r
+\r
+inline double ease_out_sine (double t, double b, double c, double d) \r
+{\r
+       return c * std::sin(t/d * (PI/2)) + b;\r
+}      \r
+\r
+inline double ease_in_out_sine (double t, double b, double c, double d) \r
+{\r
+       return -c/2 * (std::cos(PI*t/d) - 1) + b;\r
+}      \r
+\r
+inline double ease_out_in_sine (double t, double b, double c, double d)\r
+{\r
+       if (t < d/2) \r
+               return ease_out_sine (t*2, b, c/2, d);\r
+       \r
+       return ease_in_sine((t*2)-d, b+c/2, c/2, d);\r
+}      \r
+\r
+inline double ease_in_expo (double t, double b, double c, double d) \r
+{\r
+       return (t==0) ? b : c * std::pow(2, 10 * (t/d - 1)) + b - c * 0.001;\r
+}      \r
+\r
+inline double ease_out_expo (double t, double b, double c, double d) \r
+{\r
+       return (t==d) ? b+c : c * 1.001 * (-std::pow(2, -10 * t/d) + 1) + b;\r
+}\r
+       \r
+inline double ease_in_out_expo (double t, double b, double c, double d) \r
+{\r
+       if (t==0) \r
+               return b;\r
+       if (t==d) \r
+               return b+c;\r
+       if ((t/=d/2) < 1) \r
+               return c/2 * std::pow(2, 10 * (t - 1)) + b - c * 0.0005;\r
+\r
+       return c/2 * 1.0005 * (-std::pow(2, -10 * --t) + 2) + b;\r
+}\r
+       \r
+inline double ease_out_in_expo (double t, double b, double c, double d) {\r
+       if (t < d/2) \r
+               return ease_out_expo (t*2, b, c/2, d);\r
+\r
+       return ease_in_expo((t*2)-d, b+c/2, c/2, d);\r
+}\r
+       \r
+inline double ease_in_circ (double t, double b, double c, double d) \r
+{\r
+       return -c * (std::sqrt(1 - (t/=d)*t) - 1) + b;\r
+}\r
+       \r
+inline double ease_out_circ (double t, double b, double c, double d) \r
+{\r
+       return c * std::sqrt(1 - (t=t/d-1)*t) + b;\r
+}\r
+       \r
+inline double ease_in_out_circ (double t, double b, double c, double d) \r
+{\r
+       if ((t/=d/2) < 1) \r
+               return -c/2 * (std::sqrt(1 - t*t) - 1) + b;\r
+\r
+       return c/2 * (std::sqrt(1 - (t-=2)*t) + 1) + b;\r
+}\r
+       \r
+inline double ease_out_in_circ (double t, double b, double c, double d) \r
+{\r
+       if (t < d/2) return ease_out_circ(t*2, b, c/2, d);\r
+       return ease_in_circ((t*2)-d, b+c/2, c/2, d);\r
+}\r
+       \r
+inline double ease_in_elastic (double t, double b, double c, double d)\r
+{\r
+       if (t==0) return b;\r
+       if ((t/=d)==1) return b+c;\r
+       //var p:Number = !Boolean(p_params) || isNaN(p_params.period) ? d*.3 : p_params.period;\r
+       //var s:Number;\r
+       //var a:Number = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;\r
+       double p = d*0.3;\r
+       double s;\r
+       double a = 0.0;\r
+       if (a == 0.0 || a < std::abs(c)) \r
+       {\r
+               a = c;\r
+               s = p/4;\r
+       } \r
+       else \r
+               s = p/(2*PI) * std::asin (c/a);\r
+       \r
+       return -(a*std::pow(2,10*(t-=1)) * std::sin( (t*d-s)*(2*PI)/p )) + b;\r
+}\r
+       \r
+inline double ease_out_elastic (double t, double b, double c, double d) \r
+{\r
+       if (t==0) \r
+               return b;\r
+       if ((t/=d)==1) \r
+               return b+c;\r
+       //var p:Number = !Boolean(p_params) || isNaN(p_params.period) ? d*.3 : p_params.period;\r
+       //var s:Number;\r
+       //var a:Number = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;\r
+       double p = d*0.3;\r
+       double s;\r
+       double a = 0.0;\r
+       if (a == 0.0 || a < std::abs(c))\r
+       {\r
+               a = c;\r
+               s = p/4;\r
+       } \r
+       else \r
+               s = p/(2*PI) * std::asin (c/a);\r
+       \r
+       return (a*std::pow(2,-10*t) * std::sin( (t*d-s)*(2*PI)/p ) + c + b);\r
+}      \r
+\r
+inline double ease_in_out_elastic (double t, double b, double c, double d) \r
+{\r
+       if (t==0)\r
+               return b;\r
+       if ((t/=d/2)==2) \r
+               return b+c;\r
+       //var p:Number = !Boolean(p_params) || isNaN(p_params.period) ? d*(.3*1.5) : p_params.period;\r
+       //var s:Number;\r
+       //var a:Number = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;\r
+       double p = d*0.3*1.5;\r
+       double s;\r
+       double a = 0.0;\r
+       if (a == 0.0 || a < std::abs(c)) \r
+       {\r
+               a = c;\r
+               s = p/4;\r
+       }\r
+       else\r
+               s = p/(2*PI) * std::asin (c/a);\r
+       \r
+       if (t < 1) \r
+               return -.5*(a*std::pow(2,10*(t-=1)) * std::sin( (t*d-s)*(2*PI)/p )) + b;\r
+\r
+       return a*std::pow(2,-10*(t-=1)) * std::sin( (t*d-s)*(2*PI)/p )*.5 + c + b;\r
+}\r
+       \r
+inline double ease_out_in_elastic (double t, double b, double c, double d) \r
+{\r
+       if (t < d/2) return ease_out_elastic (t*2, b, c/2, d);\r
+       return ease_in_elastic((t*2)-d, b+c/2, c/2, d);\r
+}\r
+       \r
+inline double ease_in_back (double t, double b, double c, double d) \r
+{\r
+       //var s:Number = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;\r
+       double s = 1.70158;\r
+       return c*(t/=d)*t*((s+1)*t - s) + b;\r
+}\r
+       \r
+inline double ease_out_back (double t, double b, double c, double d)\r
+{\r
+       //var s:Number = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;\r
+       double s = 1.70158;\r
+       return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;\r
+}\r
+       \r
+inline double ease_in_out_back (double t, double b, double c, double d)\r
+{\r
+       //var s:Number = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;\r
+       double s = 1.70158;\r
+       if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;\r
+       return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;\r
+}\r
+       \r
+\r
+inline double ease_out_int_back (double t, double b, double c, double d)\r
+{\r
+       if (t < d/2) return ease_out_back (t*2, b, c/2, d);\r
+       return ease_in_back((t*2)-d, b+c/2, c/2, d);\r
+}\r
+       \r
+\r
+inline double ease_out_bounce (double t, double b, double c, double d) \r
+{\r
+       if ((t/=d) < (1/2.75))\r
+               return c*(7.5625*t*t) + b;\r
+       else if (t < (2/2.75))\r
+               return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;\r
+       else if (t < (2.5/2.75))\r
+               return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;\r
+       else \r
+               return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;    \r
+}\r
+       \r
+inline double ease_in_bounce (double t, double b, double c, double d)\r
+{\r
+       return c - ease_out_bounce (d-t, 0, c, d) + b;\r
+}\r
+\r
+inline double ease_in_out_bounce (double t, double b, double c, double d) \r
+{\r
+       if (t < d/2) return ease_in_bounce (t*2, 0, c, d) * .5 + b;\r
+       else return ease_out_bounce (t*2-d, 0, c, d) * .5 + c*.5 + b;\r
+}\r
+       \r
+\r
+inline double ease_out_in_bounce (double t, double b, double c, double d) \r
+{\r
+       if (t < d/2) return ease_out_bounce (t*2, b, c/2, d);\r
+       return ease_in_bounce((t*2)-d, b+c/2, c/2, d);\r
+}\r
+\r
+inline tweener_t get_tweener(std::wstring name = L"linear")\r
+{\r
+       std::transform(name.begin(), name.end(), name.begin(), std::tolower);\r
+\r
+       static const std::unordered_map<std::wstring, tweener_t> tweens = boost::assign::map_list_of    \r
+               (L"linear",                             ease_none                  )    \r
+               (L"easenone",                   ease_none                  )\r
+               (L"easeinquad",                 ease_in_quad       )\r
+               (L"easeoutquad",                ease_out_quad      )\r
+               (L"easeinoutquad",              ease_in_out_quad   )\r
+               (L"easeoutinquad",              ease_out_in_quad   )\r
+               (L"easeincubic",                ease_in_cubic      )\r
+               (L"easeoutcubic",               ease_out_cubic     )\r
+               (L"easeinoutcubic",             ease_in_out_cubic  )\r
+               (L"easeoutincubic",             ease_out_in_cubic  )\r
+               (L"easeinquart",                ease_in_quart      )\r
+               (L"easeoutquart",               ease_out_quart     )\r
+               (L"easeinoutquart",             ease_in_out_quart  )\r
+               (L"easeoutinquart",             ease_out_in_quart  )\r
+               (L"easeinquint",                ease_in_quint      )\r
+               (L"easeoutquint",               ease_out_quint     )\r
+               (L"easeinoutquint",             ease_in_out_quint  )\r
+               (L"easeoutinquint",             ease_out_in_quint  )\r
+               (L"easeinsine",                 ease_in_sine       )\r
+               (L"easeoutsine",                ease_out_sine      )\r
+               (L"easeinoutsine",              ease_in_out_sine   )\r
+               (L"easeoutinsine",              ease_out_in_sine   )\r
+               (L"easeinexpo",                 ease_in_expo       )\r
+               (L"easeoutexpo",                ease_out_expo      )\r
+               (L"easeinoutexpo",              ease_in_out_expo   )\r
+               (L"easeoutinexpo",              ease_out_in_expo   )\r
+               (L"easeincirc",                 ease_in_circ       )\r
+               (L"easeoutcirc",                ease_out_circ      )\r
+               (L"easeinoutcirc",              ease_in_out_circ   )\r
+               (L"easeoutincirc",              ease_out_in_circ   )\r
+               (L"easeinelastic",              ease_in_elastic    )\r
+               (L"easeoutelastic",             ease_out_elastic   )\r
+               (L"easeinoutelastic",   ease_in_out_elastic)\r
+               (L"easeoutinelastic",   ease_out_in_elastic)\r
+               (L"easeinback",                 ease_in_back       )\r
+               (L"easeoutback",                ease_out_back      )\r
+               (L"easeinoutback",              ease_in_out_back   )\r
+               (L"easeoutintback",             ease_out_int_back  )\r
+               (L"easeoutbounce",              ease_out_bounce    )\r
+               (L"easeinbounce",               ease_in_bounce     )\r
+               (L"easeinoutbounce",    ease_in_out_bounce )\r
+               (L"easeoutinbounce",    ease_out_in_bounce );\r
+\r
+       auto it = tweens.find(name);\r
+       if(it == tweens.end())\r
+       {\r
+               CASPAR_LOG(warning) << L" Invalid tween: " << name << L" fallback to \"linear\".";\r
+               it = tweens.find(L"linear");\r
+       }\r
+\r
+       return it->second;\r
+};\r
+\r
+}
\ No newline at end of file
index 03e5a08e884e9d9806cfe7d33a24669bbc3d6957..7981a26d040b45d6484ccdfcdde228127473b6f2 100644 (file)
@@ -40,11 +40,16 @@ const audio_transform audio_transform::operator*(const audio_transform &other) c
        return audio_transform(*this) *= other;\r
 }\r
 \r
-audio_transform tween(const audio_transform& lhs, const audio_transform& rhs, const std::function<double(double, double, double)>& tweener, double delta)\r
+audio_transform tween(double time, const audio_transform& source, const audio_transform& dest, double duration, const tweener_t& tweener)\r
 {\r
+       auto do_tween = [](double time, double source, double dest, double duration, const tweener_t& tweener)\r
+       {\r
+               return tweener(time, source, dest-source, duration);\r
+       };\r
+\r
        audio_transform result;\r
-       result.set_gain(tweener(lhs.get_gain(), rhs.get_gain(), delta));\r
-       result.set_has_audio(lhs.get_has_audio() || rhs.get_has_audio());\r
+       result.set_gain(do_tween(time, source.get_gain(), dest.get_gain(), duration, tweener));\r
+       result.set_has_audio(source.get_has_audio() || dest.get_has_audio());\r
        return result;\r
 }\r
 \r
index 7e4fd1aeab79212b89175e5e052b1c1354a5e951..98013099cc86109fb15f2bfb8bfef831faafcbdb 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once\r
 \r
+#include <common/utility/tweener.h>\r
+\r
 namespace caspar { namespace core {\r
 \r
 class audio_transform\r
@@ -20,6 +22,6 @@ private:
        bool audio_;\r
 };\r
 \r
-audio_transform tween(const audio_transform& lhs, const audio_transform& rhs, const std::function<double(double, double, double)>& tweener, double delta);\r
+audio_transform tween(double time, const audio_transform& source, const audio_transform& dest, double duration, const tweener_t& tweener);\r
 \r
 }}
\ No newline at end of file
index 45685db362a9605cdb2fd2915f12949dbbad7cb1..6ca2b07b536d2fd3bb7dc8c3f944ca62efa64002 100644 (file)
@@ -113,18 +113,23 @@ const image_transform image_transform::operator*(const image_transform &other) c
        return image_transform(*this) *= other;\r
 }\r
 \r
-image_transform tween(const image_transform& lhs, const image_transform& rhs, const std::function<double(double, double, double)>& tweener, double delta)\r
-{\r
+image_transform tween(double time, const image_transform& source, const image_transform& dest, double duration, const tweener_t& tweener)\r
+{      \r
+       auto do_tween = [](double time, double source, double dest, double duration, const tweener_t& tweener)\r
+       {\r
+               return tweener(time, source, dest-source, duration);\r
+       };\r
+\r
        CASPAR_ASSERT(lhs.get_mode() == rhs.get_mode() || lhs.get_mode() == video_mode::invalid || rhs.get_mode() == video_mode::invalid);\r
 \r
        image_transform result; \r
-       result.set_mode(rhs.get_mode() != video_mode::invalid ? rhs.get_mode() : lhs.get_mode());\r
-       result.set_gain(tweener(lhs.get_gain(), rhs.get_gain(), delta));\r
-       result.set_opacity(tweener(lhs.get_opacity(), rhs.get_opacity(), delta));\r
-       result.set_fill_translation(tweener(lhs.get_fill_translation()[0], rhs.get_fill_translation()[0], delta), tweener(lhs.get_fill_translation()[1], rhs.get_fill_translation()[1], delta));\r
-       result.set_fill_scale(tweener(lhs.get_fill_scale()[0], rhs.get_fill_scale()[0], delta), tweener(lhs.get_fill_scale()[1], rhs.get_fill_scale()[1], delta));\r
-       result.set_key_translation(tweener(lhs.get_key_translation()[0], rhs.get_key_translation()[0], delta), tweener(lhs.get_key_translation()[1], rhs.get_key_translation()[1], delta));\r
-       result.set_key_scale(tweener(lhs.get_key_scale()[0], rhs.get_key_scale()[0], delta), tweener(lhs.get_key_scale()[1], rhs.get_key_scale()[1], delta));\r
+       result.set_mode(dest.get_mode() != video_mode::invalid ? dest.get_mode() : source.get_mode());\r
+       result.set_gain(do_tween(time, source.get_gain(), dest.get_gain(), duration, tweener));\r
+       result.set_opacity(do_tween(time, source.get_opacity(), dest.get_opacity(), duration, tweener));\r
+       result.set_fill_translation(do_tween(time, source.get_fill_translation()[0], dest.get_fill_translation()[0], duration, tweener), do_tween(time, source.get_fill_translation()[1], dest.get_fill_translation()[1], duration, tweener));\r
+       result.set_fill_scale(do_tween(time, source.get_fill_scale()[0], dest.get_fill_scale()[0], duration, tweener), do_tween(time, source.get_fill_scale()[1], dest.get_fill_scale()[1], duration, tweener));\r
+       result.set_key_translation(do_tween(time, source.get_key_translation()[0], dest.get_key_translation()[0], duration, tweener), do_tween(time, source.get_key_translation()[1], dest.get_key_translation()[1], duration, tweener));\r
+       result.set_key_scale(do_tween(time, source.get_key_scale()[0], dest.get_key_scale()[0], duration, tweener), do_tween(time, source.get_key_scale()[1], dest.get_key_scale()[1], duration, tweener));\r
        \r
        return result;\r
 }\r
index c372cfbf99915434b93d63dae8b80a8583189e23..304fc0ffcc202976f0fe866c8a7ea6452e00739b 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once\r
 \r
+#include <common/utility/tweener.h>\r
 #include <core/video_format.h>\r
 \r
 #include <array>\r
@@ -46,7 +47,7 @@ private:
        video_mode::type mode_;\r
 };\r
 \r
-image_transform tween(const image_transform& lhs, const image_transform& rhs, const std::function<double(double, double, double)>& tweener, double delta);\r
+image_transform tween(double time, const image_transform& source, const image_transform& dest, double duration, const tweener_t& tweener);\r
 \r
 inline bool operator==(const image_transform& lhs, const image_transform& rhs)\r
 {\r
index 6d779a5f563af950788456fed1f42a47efbf3de9..f423220064af1f78ccf8f36c3365e2fc2737c518 100644 (file)
@@ -8,7 +8,6 @@
 #include <core/producer/frame/audio_transform.h>\r
 #include <core/producer/frame/image_transform.h>\r
 \r
-#include "tween.h"\r
 #include "audio/audio_mixer.h"\r
 #include "image/image_mixer.h"\r
 \r
@@ -17,6 +16,7 @@
 #include <common/diagnostics/graph.h>\r
 #include <common/utility/assert.h>\r
 #include <common/utility/timer.h>\r
+#include <common/utility/tweener.h>\r
 \r
 #include <core/video_format.h>\r
 \r
@@ -31,22 +31,22 @@ class tweened_transform
        T dest_;\r
        int duration_;\r
        int time_;\r
-       std::function<double(double,double,double)> tweener_;\r
+       tweener_t tweener_;\r
 public:        \r
        tweened_transform()\r
                : duration_(0)\r
                , time_(0)\r
-               , tweener_(get_tweener<double>(L"linear")){}\r
+               , tweener_(get_tweener(L"linear")){}\r
        tweened_transform(const T& source, const T& dest, int duration, const std::wstring& tween = L"linear")\r
                : source_(source)\r
                , dest_(dest)\r
                , duration_(duration)\r
                , time_(0)\r
-               , tweener_(get_tweener<double>(tween)){}\r
+               , tweener_(get_tweener(tween)){}\r
        \r
        virtual T fetch()\r
        {\r
-               return tween(source_, dest_, tweener_, duration_ < 1 ? 1.0f : static_cast<float>(time_)/static_cast<float>(duration_));\r
+               return tween(static_cast<double>(time_), source_, dest_, static_cast<double>(duration_)+0.000001, tweener_);\r
        }\r
        virtual T fetch_and_tick(int num)\r
        {                                               \r
index 1385d61e36ec1b3cf6a0b0628a9b6ed65eaad390..59e6251059f8fe6a715e6785913719fc58c4e726 100644 (file)
@@ -86,7 +86,6 @@
     <ClInclude Include="image\image_kernel.h" />\r
     <ClInclude Include="image\image_mixer.h" />\r
     <ClInclude Include="StdAfx.h" />\r
-    <ClInclude Include="tween.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ProjectReference Include="..\common\common.vcxproj">\r
index 68bfd02384f7aa587c4925873c2d6060db556bee..69ea9fc8aad0638998a7160ed559e56cdc066fdc 100644 (file)
@@ -66,6 +66,5 @@
     <ClInclude Include="gpu\gpu_read_frame.h">\r
       <Filter>gpu</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="tween.h" />\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
diff --git a/mixer/tween.h b/mixer/tween.h
deleted file mode 100644 (file)
index 9441685..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-#pragma once\r
-\r
-#include <boost/assign/list_of.hpp>\r
-#include <unordered_map>\r
-#include <string>\r
-#include <locale>\r
-\r
-namespace caspar {\r
-                       \r
-static const double PI = std::atan(1.0)*4.0;\r
-static const double H_PI = std::atan(1.0)*2.0;\r
-\r
-template<typename T>\r
-inline T ease_none(T b, T e, T d) \r
-{\r
-       return b + (e-b)*d;\r
-}\r
-\r
-template<typename T>\r
-inline T ease_in_sine(T b, T e, T d)  \r
-{\r
-       return -(e-b) * std::cos(d * H_PI) + (e-b) + b;\r
-}\r
-\r
-template<typename T>\r
-inline T ease_out_sine(T b, T e, T d)  \r
-{ \r
-       return (e-b) * std::sin(d * H_PI) + b;\r
-}\r
-\r
-template<typename T>\r
-inline T ease_in_out_sine(T b, T e, T d)  \r
-{ \r
-       return -(e-b)/2 * (std::cos(PI*d) - 1.0) + b;\r
-}\r
-\r
-template<typename T>\r
-inline T ease_out_in_sine(T b, T e, T d)  \r
-{\r
-       return d < 0.5 ? ease_out_sine(b, e+(e-b)*0.5, d*2.0) : ease_out_sine(b+(e-b)*0.5, e, d*2.0-1.0);\r
-}\r
-\r
-template<typename T>\r
-inline T ease_in_cubic(T b, T e, T d)  \r
-{ \r
-       return (e-b) * std::pow(d, 3) + b;\r
-}\r
-\r
-template<typename T>\r
-inline T ease_out_cubic(T b, T e, T d)  \r
-{ \r
-       return (e-b) * (std::pow(d-1.0, 3)+1.0) + b;\r
-}\r
-       \r
-template<typename T>\r
-inline T ease_in_out_cubic(T b, T e, T d)  \r
-{ \r
-       return d < 0.5 ? (e-b)*0.5 * std::pow(d*2.0, 3) + b : (e-b)*0.5 * (std::pow(d*2.0-2.0, 3)+2.0)+ b;\r
-}\r
-\r
-template<typename T>\r
-inline T ease_out_in_cubic(T b, T e, T d)  \r
-{ \r
-       return d < 0.5 ? ease_out_cubic(b, e+(e-b)*0.5, d*2.0) : ease_in_cubic(b+(e-b)*0.5, e, d*2.0-1.0);\r
-}\r
-\r
-template<typename T>\r
-inline std::function<T(T,T,T)> get_tweener(std::wstring name = L"linear")\r
-{\r
-       std::transform(name.begin(), name.end(), name.begin(), std::tolower);\r
-\r
-       typedef std::function<T(T,T,T)> tween_func;\r
-       static const std::unordered_map<std::wstring, tween_func> tweens = boost::assign::map_list_of\r
-               (L"linear", ease_none<T>)\r
-               (L"easenone", ease_none<T>)\r
-               (L"easeinsine", ease_in_sine<T>)\r
-               (L"easeoutsine", ease_out_sine<T>)\r
-               (L"easeinoutsine", ease_in_out_sine<T>)\r
-               (L"easeoutinsine", ease_out_in_sine<T>)\r
-               (L"easeincubic", ease_in_cubic<T>)\r
-               (L"easeoutcubic", ease_out_cubic<T>)\r
-               (L"easeinoutcubic", ease_in_out_cubic<T>)\r
-               (L"easeoutincubic", ease_out_in_cubic<T>);\r
-\r
-       auto it = tweens.find(name);\r
-       if(it == tweens.end())\r
-       {\r
-               CASPAR_LOG(warning) << L" Invalid tween: " << name << L" fallback to \"linear\".";\r
-               it = tweens.find(L"linear");\r
-       }\r
-\r
-       return it->second;\r
-};\r
-\r
-}
\ No newline at end of file
index 033a5d9ced15f04530bee6f0e7687a0008b80e74..a7132c23b8682765498d340e7af328f49d6b3301 100644 (file)
@@ -69,8 +69,6 @@ class flash_renderer
        CComObject<caspar::flash::FlashAxContainer>* ax_;\r
        safe_ptr<core::basic_frame> head_;\r
        \r
-       timer timer_;\r
-\r
        safe_ptr<diagnostics::graph> graph_;\r
        timer perf_timer_;\r
        \r
@@ -176,8 +174,7 @@ private:
                if(underflow)\r
                        graph_->add_tag("underflow");\r
 \r
-               double frame_time = 1.0/ax_->GetFPS()*(underflow ? 0.90 : 1.0); // Reduce sync-time if in underflow.\r
-               timer_.tick(frame_time); // Tick doesnt work on nested timelines, force an actual sync\r
+               double frame_time = 1.0/ax_->GetFPS();\r
 \r
                perf_timer_.reset();\r
                ax_->Tick();\r
index d32673dfa99594ec4da380a3dec413565d504f09..baa97e57813d7ead89a92ec44c8b1c2520f9d1fd 100644 (file)
@@ -21,8 +21,8 @@
 #include "oal_consumer.h"\r
 \r
 #include <common/diagnostics/graph.h>\r
-#include <common/utility/timer.h>\r
 #include <common/log/log.h>\r
+#include <common/utility/timer.h>\r
 \r
 #include <core/video_format.h>\r
 \r
@@ -55,6 +55,7 @@ public:
                graph_->add_guide("tick-time", 0.5);\r
                graph_->set_color("tick-time", diagnostics::color(0.1f, 0.7f, 0.8f));\r
                is_running_ = true;\r
+               input_.set_capacity(4);\r
        }\r
 \r
        ~implementation()\r
index 8cbb6f759c45cc274deb17b0559ba8f780bcc36e..de26bbdebf25ba233eb9a7cce295e7f5ec8a58b3 100644 (file)
@@ -268,8 +268,6 @@ public:
                glBindTexture(GL_TEXTURE_2D, 0);\r
 \r
                std::rotate(pbos_.begin(), pbos_.begin() + 1, pbos_.end());\r
-\r
-               clock_.tick(1.0/format_desc_.fps);\r
        }\r
                \r
        void send(const safe_ptr<const core::read_frame>& frame)\r
index de9ae38b4611d2ec62ed41c2503d73a4b26d1d64..b518723582a00351950636de759cdaf1279e36ce 100644 (file)
@@ -19,7 +19,7 @@
           <stretch>uniform</stretch>\r
           <windowed>true</windowed>\r
         </ogl>\r
-        <!--<audio/>-->\r
+        <audio/>\r
         <!--decklink>\r
           <device>1</device>\r
           <embedded-audio>true</embedded-audio>\r