]> git.sesse.net Git - mlt/commitdiff
Fix behaviour of title clips when in and out points are given
authorj-b-m <jb@kdenlive.org>
Sat, 3 Oct 2009 23:08:15 +0000 (01:08 +0200)
committerj-b-m <jb@kdenlive.org>
Sat, 3 Oct 2009 23:08:15 +0000 (01:08 +0200)
modified:   src/modules/qimage/kdenlivetitle_wrapper.cpp
modified:   src/modules/qimage/producer_kdenlivetitle.c

src/modules/qimage/kdenlivetitle_wrapper.cpp
src/modules/qimage/producer_kdenlivetitle.c

index 8a7e2bb6863659a5d3c588d9f7b2473f32a42d96..42f973b1e58041c367e9bae351ef2c7ceaa739f8 100644 (file)
@@ -143,6 +143,13 @@ void loadFromXml( mlt_producer producer, QGraphicsScene *scene, const char *temp
             originalWidth = scene->sceneRect().width();
             originalHeight = scene->sceneRect().height();
         }
+        if ( title.hasAttribute( "out" ) ) {
+            mlt_properties_set_position( producer_props, "_animation_out", title.attribute( "out" ).toDouble() );
+        }
+        else {
+            mlt_properties_set_position( producer_props, "_animation_out", mlt_producer_get_out( producer ) );
+        }
+        
        mlt_properties_set_int( producer_props, "_original_width", originalWidth );
        mlt_properties_set_int( producer_props, "_original_height", originalHeight );
 
@@ -357,14 +364,19 @@ void drawKdenliveTitle( producer_ktitle self, mlt_frame frame, int width, int he
                p1.begin( &img );
                p1.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing );
                //| QPainter::SmoothPixmapTransform );
+                mlt_position anim_out = mlt_properties_get_position( producer_props, "_animation_out" );
+                
                if (end.isNull())
                {
                        scene->render( &p1, source, start, Qt::IgnoreAspectRatio );
                }
-               else
-               {
-                       QPointF topleft = start.topLeft() + ( end.topLeft() - start.topLeft() ) * position;
-                       QPointF bottomRight = start.bottomRight() + ( end.bottomRight() - start.bottomRight() ) * position;
+               else if ( position > anim_out ) {
+                        scene->render( &p1, source, end, Qt::IgnoreAspectRatio );
+                }
+               else {
+                        double percentage = position / anim_out;
+                       QPointF topleft = start.topLeft() + ( end.topLeft() - start.topLeft() ) * percentage;
+                       QPointF bottomRight = start.bottomRight() + ( end.bottomRight() - start.bottomRight() ) * percentage;
                        const QRectF r1( topleft, bottomRight );
                        scene->render( &p1, source, r1, Qt::IgnoreAspectRatio );
                }
index 5e914e25d6a2c4c1724f46e4df772e2ee6781b57..6e356cc1135e4fad7060de87edcecc47c4e1775a 100644 (file)
@@ -65,16 +65,13 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 
        /* Allocate the image */
        *format = mlt_image_rgb24a;
-       mlt_position in = mlt_producer_get_in( &this->parent );
-       mlt_position out = mlt_producer_get_out( &this->parent );
-       mlt_position time = mlt_producer_position( &this->parent );
-       double position = ( double )( time - in ) / ( double )( out - in + 1 );
+       mlt_position time = mlt_producer_position( &this->parent ) + mlt_producer_get_in( &this->parent );
        if ( mlt_properties_get_int( producer_props, "force_reload" ) ) {
                if (mlt_properties_get_int( producer_props, "force_reload" ) > 1) read_xml(producer_props);
                mlt_properties_set_int( producer_props, "force_reload", 0 );
-               drawKdenliveTitle( this, frame, *width, *height, position, 1);
+               drawKdenliveTitle( this, frame, *width, *height, time, 1);
        }
-       else drawKdenliveTitle( this, frame, *width, *height, position, 0);
+       else drawKdenliveTitle( this, frame, *width, *height, time, 0);
 
        // Get width and height (may have changed during the refresh)
        *width = mlt_properties_get_int( properties, "width" );