# FFmpeg custom expressions, made with xfade-easing.sh v. 3.5.3
# by Raymond Luckhurst, https://scriptit.uk, https://github.com/scriptituk/xfade-easing

# Generic easing expressions, script for -/filter_complex filterchains

LINEAR
st(0, ld(0))

QUADRATIC-IN
st(0, ld(0) * ld(0))

QUADRATIC-OUT
st(0, ld(0) * (2 - ld(0)))

QUADRATIC-IN-OUT
st(0, if(lt(ld(0), 0.5), 2 * ld(0) * ld(0), 2 * ld(0) * (2 - ld(0)) - 1))

CUBIC-IN
st(0, ld(0)^3)

CUBIC-OUT
st(0, 1 - (1-ld(0))^3)

CUBIC-IN-OUT
st(0, if(lt(ld(0), 0.5), 4 * ld(0)^3, 1 - 4 * (1-ld(0))^3))

QUARTIC-IN
st(0, ld(0)^4)

QUARTIC-OUT
st(0, 1 - (1-ld(0))^4)

QUARTIC-IN-OUT
st(0, if(lt(ld(0), 0.5), 8 * ld(0)^4, 1 - 8 * (1-ld(0))^4))

QUINTIC-IN
st(0, ld(0)^5)

QUINTIC-OUT
st(0, 1 - (1-ld(0))^5)

QUINTIC-IN-OUT
st(0, if(lt(ld(0), 0.5), 16 * ld(0)^5, 1 - 16 * (1-ld(0))^5))

SINUSOIDAL-IN
st(0, 1 - cos(ld(0) * PI / 2))

SINUSOIDAL-OUT
st(0, sin(ld(0) * PI / 2))

SINUSOIDAL-IN-OUT
st(0, (1 - cos(ld(0) * PI)) / 2)

EXPONENTIAL-IN
st(0, if(lte(ld(0), 0), 0, 2^(10 * ld(0) - 10)))

EXPONENTIAL-OUT
st(0, if(gte(ld(0), 1), 1, 1 - 2^(-10 * ld(0))))

EXPONENTIAL-IN-OUT
st(0,
 if(lt(ld(0), 0.5),
  if(lte(ld(0), 0), 0, 2^(20 * ld(0) - 11)),
  if(gte(ld(0), 1), 1, 1 - 2^(9 - 20 * ld(0)))
 )
)

CIRCULAR-IN
st(0, 1 - sqrt(1 - ld(0) * ld(0)))

CIRCULAR-OUT
st(0, sqrt(ld(0) * (2 - ld(0))))

CIRCULAR-IN-OUT
st(0,
 if(lt(ld(0), 0.5),
  1 - sqrt(1 - 4 * ld(0) * ld(0)),
  1 + sqrt(4 * ld(0) * (2 - ld(0)) - 3)
 ) / 2
)

ELASTIC-IN
st(0, cos((1-ld(0)) * 20.944) / 2^(10 * (1-ld(0))))

ELASTIC-OUT
st(0, 1 - cos(ld(0) * 20.944) / 2^(10 * ld(0)))

ELASTIC-IN-OUT
st(0,
 st(1, cos(st(2, 2 * ld(0) - 1) * 13.9626) / 2);
 st(2, 2^(10 * ld(2)));
 if(lt(ld(0), 0.5), ld(1) * ld(2), 1 - ld(1) / ld(2))
)

BACK-IN
st(0, ld(0) * ld(0) * (ld(0) * 2.70158 - 1.70158))

BACK-OUT
st(0, 1 - (1-ld(0))^2 * (1 - ld(0) * 2.70158))

BACK-IN-OUT
st(0,
 if(lt(ld(0), 0.5),
  2 * ld(0) * ld(0) * (2 * ld(0) * 3.59491 - 2.59491),
  1 - 2 * (1-ld(0))^2 * (4.59491 - 2 * ld(0) * 3.59491)
 )
)

BOUNCE-IN
st(0,
 st(0, 1 - ld(0));
 1 - (
  if(lt(ld(0), 0.363636),
   7.5625 * ld(0) * ld(0),
   if(lt(ld(0), 0.727273),
    7.5625 * (ld(0) - 0.545455)^2 + 0.75,
    if(lt(ld(0), 0.909091),
     7.5625 * (ld(0) - 0.818182)^2 + 0.9375,
     7.5625 * (ld(0) - 0.954545)^2 + 0.954545
    )
   )
  )
 )
)

BOUNCE-OUT
st(0,
  if(lt(ld(0), 0.363636),
   7.5625 * ld(0) * ld(0),
   if(lt(ld(0), 0.727273),
    7.5625 * (ld(0) - 0.545455)^2 + 0.75,
    if(lt(ld(0), 0.909091),
     7.5625 * (ld(0) - 0.818182)^2 + 0.9375,
     7.5625 * (ld(0) - 0.954545)^2 + 0.954545
    )
   )
  )
)

BOUNCE-IN-OUT
st(0,
 st(1,
  st(0, st(2, lt(ld(0), 0.5) * 2 - 1) * (1 - 2 * ld(0)));
  if(lt(ld(0), 0.363636),
   7.5625 * ld(0) * ld(0),
   if(lt(ld(0), 0.727273),
    7.5625 * (ld(0) - 0.545455)^2 + 0.75,
    if(lt(ld(0), 0.909091),
     7.5625 * (ld(0) - 0.818182)^2 + 0.9375,
     7.5625 * (ld(0) - 0.954545)^2 + 0.954545
    )
   )
  )
 );
 (1 - ld(2) * ld(1)) / 2
)

SQUAREROOT-IN
st(0, sqrt(ld(0)))

SQUAREROOT-OUT
st(0, 1 - sqrt((1-ld(0))))

SQUAREROOT-IN-OUT
st(0, if(lt(ld(0), 0.5), sqrt(ld(0) / 2), 1 - sqrt((1-ld(0)) / 2)))

CUBEROOT-IN
st(0, 1 - pow((1-ld(0)), 0.333333))

CUBEROOT-OUT
st(0, pow(ld(0), 0.333333))

CUBEROOT-IN-OUT
st(0, if(lt(ld(0), 0.5), pow(ld(0) / 4, 0.333333), 1 - pow((1-ld(0)) / 4, 0.333333)))

LINEAR
st(0, ld(0))
