diff --git a/include/Timeline.h b/include/Timeline.h index 3cbd4a99..1c67a5e0 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -49,14 +49,17 @@ namespace openshot { map open_clips; /// new_frame, Clip* source_clip, int clip_frame_number); + /// Calculate time of a frame number, based on a framerate float calculate_time(int number, Framerate rate); /// Calculate the # of samples per video frame (for a specific frame number) int GetSamplesPerFrame(int frame_number); - /// Process a new layer of video or audio - void add_layer(tr1::shared_ptr new_frame, Clip* source_clip, int clip_frame_number); + /// Compare 2 floating point numbers for equality + bool isEqual(double a, double b); /// Update the list of 'opened' clips void update_open_clips(Clip *clip, bool is_open); diff --git a/src/Main.cpp b/src/Main.cpp index 8aeb9a1f..a01e6581 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -159,8 +159,8 @@ int main() // c1.time.PrintValues(); // Add clips - t.AddClip(&c1); - t.AddClip(&c2); + //t.AddClip(&c1); + //t.AddClip(&c2); t.AddClip(&c3); diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 664f76e8..a3fe32ad 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -152,14 +152,16 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, in int offset_x = 0; int offset_y = 0; - if ((round(x) != 0 || round(y) != 0) && (round(r) == 0 && round(sx) == 1 && round(sy) == 1 && !is_x_animated && !is_y_animated)) + if ((!isEqual(x, 0) || !isEqual(y, 0)) && (isEqual(r, 0) && isEqual(sx, 1) && isEqual(sy, 1) && !is_x_animated && !is_y_animated)) { + cout << "SIMPLE" << endl; // If only X and Y are different, and no animation is being used (just set the offset for speed) offset_x = round(x); offset_y = round(y); - } else if (round(r) != 0 || round(x) != 0 || round(y) != 0 || round(sx) != 1 || round(sy) != 1) + } else if (!isEqual(r, 0) || !isEqual(x, 0) || !isEqual(y, 0) || !isEqual(sx, 1) || !isEqual(sy, 1)) { + cout << "COMPLEX" << endl; // Use the distort operator, which is very CPU intensive // origin X,Y Scale Angle NewX,NewY double distort_args[7] = {0,0, sx,sy, r, x-1,y-1 }; @@ -237,6 +239,11 @@ int Timeline::GetSamplesPerFrame(int frame_number) return samples_per_frame; } +// Compare 2 floating point numbers for equality +bool Timeline::isEqual(double a, double b) +{ + return fabs(a - b) < 0.000001; +} // Get an openshot::Frame object for a specific frame number of this reader. tr1::shared_ptr Timeline::GetFrame(int requested_frame) throw(ReaderClosed) @@ -262,7 +269,7 @@ tr1::shared_ptr Timeline::GetFrame(int requested_frame) throw(ReaderClose // Loop through all requested frames for (int frame_number = requested_frame; frame_number < requested_frame + minimum_frames; frame_number++) { - #pragma xxx omp task firstprivate(frame_number) + #pragma omp task firstprivate(frame_number) { // Create blank frame (which will become the requested frame) tr1::shared_ptr new_frame(tr1::shared_ptr(new Frame(frame_number, width, height, "#000000", GetSamplesPerFrame(frame_number), channels)));