Commit Graph

998 Commits

Author SHA1 Message Date
Daniel Jour
3b2e262821 Keyframe: New implementation calculating values ondemand
- GetValue() calculates the value at the given position now ondemand,
  without caching values as previously.  First, it uses binary search
  to find the segment (start and end point) containing the given
  position.  Constant and linear interpolation are straightforward,
  bezier curves are calculating by binary search between the end
  points until a point on the curve is found with a X coordinate close
  enough to the given position. That points Y coordinate is returned.

- IsIncreasing(), GetRepeatFraction(), GetDelta() use GetValue()
  instead of accessing the (removed) Values vector.

- Removed now unused private functions, and the unused public
  Process().

First test results show good performance improvements for the
"rendering case" (setting up the keyframe points at once, then getting
all values) and drastic performance improvements for the "preview
case" (changing keyframe points, mixed with getting values).
2019-11-22 22:37:06 +01:00
Daniel Jour
6d81033bff Keyframe::GetPoint() returns a constant reference now
Returning a non constant reference is not possible; this allows
outside code to invalidate internal invariants (sorted order of
points) by modifying the returned point.  To make updates the current
best approach is to remove the point by index, and then add it again.
2019-11-22 00:36:52 +01:00
Daniel Jour
6bc3428307 Keyframe::AddPoint() fix: reallocation invalidates iterator
Points.push_back can (and will) cause reallocation, which invalidates
the candidate iterator.  Thus better use an (integer) index.
2019-11-21 11:35:23 +01:00
Daniel Jour
504ea0c1ff Make Keyframe::Values and Keyframe::Points vectors private
The Values vector should only be accessed from the outside through the
GetValue() function.  The Points vector should only be accessed using
the AddPoint(), RemovePoint(), .. functions.

This helps maintain internal invariants (e.g. keeping Points sorted)
and allows for future removal / lazy evaluation of Values.

The size() of the vectors had been accessed from various parts of the
code; the GetLength() (for Values) and GetCount() (for Points) member
functions provide access to this information and are already part of
the public API.
2019-11-19 23:43:28 +01:00
Daniel Jour
cb5574180e Keyframe::AddPoint() add at correct index, keeping Points ordered
AddPoint() now searches (binary search) for the best place to insert a
new point, thus always maintaining the order of Points.  Therefore,
ReorderPoints() is no longer needed.

CAVEAT: This breaks if some outside code changes (the public member)
Points!
2019-11-19 22:43:34 +01:00
Daniel Jour
d9322c100c Keyframe::ReorderPoints() use std::sort instead of selection sort
With few points the performance doesn't differ that much; using
std::sort removes the possibility of introducing bugs into the
handmade sorting algorithm, though.
2019-11-19 22:43:34 +01:00
Daniel Jour
5ba0ecfb2b Keyframe::GetInt() and Keyframe::GetLong() use GetValue
GetInt(), GetLong() are exactly the same as GetValue() except that
their result is rounded and converted to the repsective data type.
Thus avoid code duplication and use GetValue().
2019-11-19 22:43:34 +01:00
Daniel Jour
280504f007 Keyframe::IsIncreasing() remove loop to previous values and counter
The previous values do not influence the return value of the function
nor does looping over them have any side effect.

The next_repeats value is not used in any way, thus it doesn't need to
be calculated.
2019-11-19 22:43:34 +01:00
Daniel Jour
d47c40dc14 Keyframe::GetDelta() removed unused loop and variables 2019-11-19 22:43:34 +01:00
Daniel Jour
5f7766e49e Keyframe::RemovePoint() only set needs_update if a point was removed 2019-11-19 22:43:34 +01:00
Daniel Jour
6226e9d8e9 Keyframe::UpdatePoint() removed redundant code
needs_update = true is set both by RemovePoint() and AddPoint(),
ReorderPoints() is called by AddPoint().
2019-11-19 22:43:34 +01:00
Daniel Jour
2b18ad099b Keyframe::ScalePoints() skip first point without branch in loop 2019-11-19 22:43:34 +01:00
Daniel Jour
5ddc6a3b3a Keyframe::FlipPoints() without temporary vector
The Y coordinate of each point is adjusted inplace; reduces memory
overhead and iteration count for the loop.
2019-11-19 22:43:34 +01:00
Jonathan Thomas
d539e468ca Merge pull request #366 from OpenShot/high-quality-scaling-bi-cubic
Change high quality scaling to use SWS_BICUBIC
2019-11-17 16:58:35 -06:00
Jonathan Thomas
099c8cbb6d Fixing missing impementation of high quality scale mode in FFmpegWriter 2019-11-17 16:36:31 -06:00
Jonathan Thomas
d6a4cb1dec Moving back to SWS_BICUBIC for high quality mode (during export mostly). This provides a sharper image when enlarging images than SWS_LANCZOS, and only has a slight performance disadvantage. 2019-11-17 16:34:50 -06:00
Jonathan Thomas
23ee6eb36f Merge pull request #360 from OpenShot/qt-targets
CMake: Use targets for QT, AUTOMOC sources, eliminate source globbing
2019-11-17 16:22:11 -06:00
Jonathan Thomas
272f004c0e Merge pull request #296 from OpenShot/std-prefixes
Remove all 'using namespace' directives from headers
2019-11-17 16:18:14 -06:00
FeRD (Frank Dana)
c131c82be3 Reverse order of Python detection
Detecting PythonLibs before PythonInterp can cause a non-default Python
library to be picked up, which then won't match the PythonInterp version
(which always matches the version of the `python3` command).
2019-11-16 23:52:36 -05:00
FeRD (Frank Dana)
e7a9c11fd6 Merge branch 'develop' into qt-targets 2019-11-04 04:58:57 -05:00
FeRD (Frank Dana)
bc12995115 Lose the generator expressions 2019-11-04 04:38:57 -05:00
FeRD (Frank Dana)
c7ec690c55 CMake: Update linking, no more REQUIRED_LIBRARIES
- All linking is done after target creation
- Use BOOL generator expressions for conditional linking
2019-11-04 04:30:41 -05:00
FeRD (Frank Dana)
750677c0c5 CMake: Manage sources and includes better
- Switch to AUTOMOC for Qt classes
- Eliminate globbing of source subdirs
- Call `include_directories()` in top-level CMakeLists
- Make header files PUBLIC library sources
- Make other sources PRIVATE
2019-11-04 03:59:34 -05:00
FeRD (Frank Dana)
dad3cad621 CMake: Switch to targets for Qt modules 2019-11-04 03:31:16 -05:00
SuslikV
87c06feda1 Clarify some comments 2019-11-02 20:04:58 +02:00