diff --git a/src/Main.cpp b/src/Main.cpp
index 172c325a..5d82b45d 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -31,9 +31,9 @@ int main()
Timeline t(640, 360, Framerate(24,1), 44100, 2);
// Add some clips
- Clip c1(new FFmpegReader("/home/jonathan/Videos/sintel-1024-stereo.mp4"));
- Clip c2(new ImageReader("/home/jonathan/Desktop/logo1.png"));
- Clip c3(new ImageReader("/home/jonathan/Desktop/icon.png"));
+ Clip c1(new FFmpegReader("/home/jonathan/Videos/sintel_trailer-720p.mp4"));
+ Clip c2(new ImageReader("/home/jonathan/Desktop/logo.png"));
+ Clip c3(new ImageReader("/home/jonathan/Desktop/big_logo.png"));
//Clip c3(new FFmpegReader("/home/jonathan/Desktop/IncognitoCory_-_April_Song.mp3"));
c1.Position(0.0);
c1.gravity = GRAVITY_CENTER;
@@ -42,19 +42,22 @@ int main()
c2.Position(0.0);
c2.Layer(2);
- c2.gravity = GRAVITY_LEFT;
+ c2.gravity = GRAVITY_BOTTOM_RIGHT;
c2.scale = SCALE_NONE;
+ c2.alpha.AddPoint(1, 1);
+ c2.alpha.AddPoint(120, 0);
+ c2.location_x.AddPoint(1, -0.01);
+ c2.location_x.AddPoint(300, -1);
+ c2.location_y.AddPoint(1, -0.02);
c2.End(20);
- c3.Layer(1);
+ c3.Layer(3);
c3.End(20);
- c3.location_x.AddPoint(1, 0);
- c3.location_x.AddPoint(300, 1.0);
- c3.gravity = GRAVITY_LEFT;
- c3.scale = SCALE_NONE;
-
- c2.rotation.AddPoint(1, 1);
- c2.rotation.AddPoint(300, 360);
+ c3.gravity = GRAVITY_CENTER;
+ //c3.scale_x.AddPoint(1, 0.1);
+ //c3.scale_x.AddPoint(300, 2.0);
+ //c3.scale_y.AddPoint(1, 0.1);
+ //c3.scale_y.AddPoint(300, 2.0);
//c2.scale_x.AddPoint(1, 1);
//c2.scale_x.AddPoint(300, 3.5);
@@ -71,13 +74,13 @@ int main()
//c1.alpha.AddPoint(1, 1);
//c1.alpha.AddPoint(30, 0);
- c2.alpha.AddPoint(1, 0);
- c2.alpha.AddPoint(100, 1);
- c2.alpha.AddPoint(200, 0);
- c2.alpha.AddPoint(300, 1);
+ //c2.alpha.AddPoint(1, 0);
+ //c2.alpha.AddPoint(100, 1);
+ //c2.alpha.AddPoint(200, 0);
+ //c2.alpha.AddPoint(300, 1);
- c2.location_x.AddPoint(1, 0);
- c2.location_x.AddPoint(300, 1.0);
+ //c2.location_x.AddPoint(1, 0);
+ //c2.location_x.AddPoint(300, 1.0);
//c2.location_y.AddPoint(1, 0);
//c2.location_y.AddPoint(300, 1);
@@ -153,7 +156,7 @@ int main()
// Output stream info
w.OutputStreamInfo();
- for (int frame = 1; frame <= 300; frame++)
+ for (int frame = 1; frame <= 80; frame++)
{
tr1::shared_ptr f = t.GetFrame(frame);
if (f)
diff --git a/src/Timeline.cpp b/src/Timeline.cpp
index d333b9b4..3716227e 100644
--- a/src/Timeline.cpp
+++ b/src/Timeline.cpp
@@ -147,17 +147,28 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, in
y += height * source_clip->location_y.GetValue(clip_frame_number); // move in percentage of final height
float sx = source_clip->scale_x.GetValue(clip_frame_number); // percentage X scale
float sy = source_clip->scale_y.GetValue(clip_frame_number); // percentage Y scale
+ bool is_x_animated = source_clip->location_x.Points.size() > 2;
+ bool is_y_animated = source_clip->location_y.Points.size() > 2;
- // origin X,Y Scale Angle NewX,NewY
- if (source_width != width || source_height != height || round(r) != 0 || round(x) != 0 || round(y) != 0 || round(sx) != 1 || round(sy) != 1)
+ 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 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)
+ {
+ // 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 };
source_image->distort(Magick::ScaleRotateTranslateDistortion, 7, distort_args, false);
}
/* COMPOSITE SOURCE IMAGE (LAYER) ONTO FINAL IMAGE */
tr1::shared_ptr new_image = new_frame->GetImage();
- new_image->composite(*source_image.get(), 0, 0, Magick::OverCompositeOp);
+ new_image->composite(*source_image.get(), offset_x, offset_y, Magick::OverCompositeOp);
}
// Update the list of 'opened' clips