You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Added delta() to a coordinate, to track the change in unique value on the Y axis. This helps in time mapping, to track how many frames have been skipped.
This commit is contained in:
@@ -234,6 +234,28 @@ Fraction Keyframe::GetRepeatFraction(int index)
|
||||
return Fraction(1,1);
|
||||
}
|
||||
|
||||
// Get the change in Y value (from the previous Y value)
|
||||
float Keyframe::GetDelta(int index)
|
||||
{
|
||||
// Check if it needs to be processed
|
||||
if (needs_update)
|
||||
Process();
|
||||
|
||||
// Is index a valid point?
|
||||
if (index >= 0 && index < Values.size())
|
||||
// Return value
|
||||
return Values[index].delta;
|
||||
else if (index < 0 && Values.size() > 0)
|
||||
// Return the minimum value
|
||||
return Values[0].delta;
|
||||
else if (index >= Values.size() && Values.size() > 0)
|
||||
// return the maximum value
|
||||
return Values[Values.size() - 1].delta;
|
||||
else
|
||||
// return a blank coordinate (0,0)
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// Get a point at a specific index
|
||||
Point& Keyframe::GetPoint(int index) throw(OutOfBoundsPoint) {
|
||||
// Is index a valid point?
|
||||
@@ -312,11 +334,11 @@ void Keyframe::PrintValues() {
|
||||
if (needs_update)
|
||||
Process();
|
||||
|
||||
cout << " PRINT ALL VALUES " << endl;
|
||||
cout << "Frame Number (X)\tValue (Y)\tIs Increasing\tRepeat Numerator\tRepeat Denominator\tDelta (Y Difference)" << endl;
|
||||
|
||||
for (vector<Coordinate>::iterator it = Values.begin() + 1; it != Values.end(); it++) {
|
||||
Coordinate c = *it;
|
||||
cout << int(round(c.X)) << "\t" << int(round(c.Y)) << "\t" << c.increasing << "\t" << c.repeated.num << "\t" << c.repeated.den << endl;
|
||||
cout << int(round(c.X)) << "\t" << int(round(c.Y)) << "\t" << c.increasing << "\t" << c.repeated.num << "\t" << c.repeated.den << "\t" << c.delta << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,6 +434,9 @@ void Keyframe::Process() {
|
||||
(*it).repeated.num = repeat_count;
|
||||
(*it).repeated.den = repeat_count + additional_repeats;
|
||||
|
||||
// Set delta (i.e. different from previous unique Y value)
|
||||
(*it).delta = current_value - last_value;
|
||||
|
||||
// track the last value
|
||||
last_value = current_value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user