Commit Graph

1018 Commits

Author SHA1 Message Date
FeRD (Frank Dana)
7b7f2cc574 Move feature summary to root CMakeLists 2019-12-07 13:04:29 -05:00
Jonathan Thomas
06e6de5c99 Merge pull request #381 from ferdnyc/swig-python
Add repr to openshot.Version
2019-12-06 17:14:56 -06:00
Jonathan Thomas
0347ad2073 Merge pull request #374 from musteresel/new-keyframe-implementation
New Keyframe implementation
2019-12-06 17:10:11 -06:00
Daniel Jour
c940c1f42b Keyframe: Cleanup duplicate binary search code
GetRepeatFraction uses two binary searches; reuse that code!
2019-12-06 01:21:25 +01:00
Daniel Jour
1fbdc521ca Keyframe::GetRepeatFraction(): Binary search, skipping when constant
The old implementation did a linear scan over the values.  This was
slow with slowly changing keyframes.  This new implementation skips
over constant (when rounded) segments and performs binary search
in (possibly long) interpolated segments to find the X coordinates
where a change occurs quickly.
2019-12-06 01:04:47 +01:00
Daniel Jour
f00edbad7e Keyframe interpolation: In own function; only for Y coordinate 2019-12-06 01:03:56 +01:00
FeRD (Frank Dana)
4a5eb20202 Add __repr__ to openshot.Version 2019-12-03 21:30:22 -05:00
Daniel Jour
ed0b081803 Keyframe::IsIncreasing(): Search over points, not values
Searching over the keyframe points is considerably faster than
calculating interpolating values and searching over them.
2019-12-03 17:27:28 +01:00
Daniel Jour
b40fa6922e Keyframe::GetMaxPoint() simplify loop 2019-12-03 16:58:53 +01:00
Daniel Jour
79cb8483f3 Keyframe: Move Bezier code into extra function, parameterise
Bezier interpolation code is now in a dedicated function and can be
used to either find a Y from a known X or a X from a known Y, with a
given allowed error.
2019-12-03 16:56:53 +01:00
Frank Dana
c04dc94cc8 Wrap assignment in conditional with () (#379) 2019-12-02 10:45:06 -05:00
Daniel Jour
65cb3dfde9 Keyframe::GetClosestPoint(): Use binary search 2019-11-30 11:58:51 +01:00
Daniel Jour
54e8e37d2d Keyframe::Contains(): Use binary search instead of linear search 2019-11-30 11:32:52 +01:00
chad3814
27bfbbc24a FFmpegWriter: match option 'rc_buffer_size' (#377) 2019-11-29 19:07:09 -05:00
Daniel Jour
7e2846039e More traditional placement of const specifier, matching casts
As suggested in the code review:

 - More traditional placment of the const specifier, e.g. const unsigned char * instead of unsigned char const *
 - Matching casts to also cast to const unsigned char * instead of of unsigned char *

Co-Authored-By: Frank Dana <ferdnyc@gmail.com>
2019-11-27 23:57:58 +01:00
Daniel Jour
4b76c1eadc Frame.cpp: Avoid unnecessary copy of image data
As mentioned in issue #202 QImage::bits() and QImage::scanLine() make
a deep copy of the source image.  This is completely unnecessary when
read-only access to the pixel data is required.  Changing to
QImage::constBits() and QImage::constScanLine() solves this.  Both
functions were introduced in Qt 4.7.

https://doc.qt.io/qt-5/qimage.html#constBits
2019-11-26 00:56:13 +01:00
Daniel Jour
a67fb9555c Keyframe interpolation selection: Use switch instead of if
Using switch allows (some) compilers to emit a warning if a possible
enum value for the interpolation type has been forgotten.  This is not
the case now, but might guard against future errors (e.g. adding an
interpolation type)
2019-11-25 10:37:51 +01:00
Daniel Jour
b546b6a982 Keyframe: Dedicated Point comparision function instead of lambda's 2019-11-25 10:34:14 +01:00
Daniel Jour
6f71736c6a Keyframe: mark all non-modifying member functions const
Member functions that do not (need to) modify any members or internal
state of the Keyframe class should be declared as const.
2019-11-25 10:29:58 +01:00
Daniel Jour
edf85dda78 Keyframe: use = default to specify default constructor 2019-11-25 10:23:45 +01:00
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