]> git.sesse.net Git - mlt/commitdiff
better propogating of producer and transition properties to the frame in pango and...
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 12 Jan 2004 03:21:35 +0000 (03:21 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 12 Jan 2004 03:21:35 +0000 (03:21 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@58 d19143bc-622f-0410-bfdd-b5b2a6649095

mlt/src/inigo/inigo.c
mlt/src/modules/core/transition_composite.c
mlt/src/modules/gtk2/producer_pango.c
mlt/src/modules/gtk2/producer_pango.h
src/inigo/inigo.c
src/modules/core/transition_composite.c
src/modules/gtk2/producer_pango.c
src/modules/gtk2/producer_pango.h

index 29465db954e578b20d7ea9e57bcc41c7144b559e..5fd647ab1d9750403454c076f9db4e712ef8be54 100644 (file)
@@ -27,6 +27,8 @@ mlt_producer create_producer( char *file )
                result = mlt_factory_producer( "pixbuf", file );
        else if ( strstr( file, ".png" ) )
                result = mlt_factory_producer( "pixbuf", file );
+       else if ( strstr( file, ".txt" ) )
+               result = mlt_factory_producer( "pango", file );
 
        // 2nd Line fallbacks
        if ( result == NULL && strstr( file, ".dv" ) )
index f56c6778a6e9cd968f3a319fd36f8e6abebe9685..7bcdfa9fbcdd80a3126c63d72ec58a5393bb28b5 100644 (file)
@@ -81,6 +81,17 @@ static mlt_frame composite_process( mlt_transition this, mlt_frame a_frame, mlt_
 {
        mlt_frame_push_get_image( a_frame, transition_get_image );
        mlt_frame_push_frame( a_frame, b_frame );
+       
+       // Propogate the transition properties to the b frame
+       mlt_properties properties = mlt_transition_properties( this );
+       mlt_properties b_props = mlt_frame_properties( b_frame );
+       if ( mlt_properties_get( properties, "x" ) != NULL )
+               mlt_properties_set_int( b_props, "x", mlt_properties_get_int( properties, "x" ) );
+       if ( mlt_properties_get( properties, "y" ) != NULL )
+               mlt_properties_set_int( b_props, "y", mlt_properties_get_int( properties, "y" ) );
+       if ( mlt_properties_get( properties, "mix" ) != NULL )
+               mlt_properties_set_double( b_props, "mix",  mlt_properties_get_double( properties, "mix" ) );
+
        return a_frame;
 }
 
index 6609ce97756523c4295137c84c7dfec37b8058f6..752ed4a1241fe84b456c6d4cb20c578650188a0b 100644 (file)
@@ -55,7 +55,7 @@ static void pango_draw_background( GdkPixbuf *pixbuf, rgba_color bg );
 static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font,
        rgba_color fg, rgba_color bg, int pad, int align );
 
-mlt_producer producer_pango_init( const char *markup )
+mlt_producer producer_pango_init( const char *filename )
 {
        producer_pango this = calloc( sizeof( struct producer_pango_s ), 1 );
        if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
@@ -77,14 +77,52 @@ mlt_producer producer_pango_init( const char *markup )
                mlt_properties_set_int( properties, "bgcolor", 0x00000000 );
                mlt_properties_set_int( properties, "align", pango_align_left );
                mlt_properties_set_int( properties, "pad", 0 );
-               mlt_properties_set( properties, "markup", ( char * ) ( markup == NULL ? "" : markup ) );
                mlt_properties_set( properties, "text", "" );
                mlt_properties_set( properties, "font", "Sans 48" );
                mlt_properties_set_int( properties, "x", 0 );
                mlt_properties_set_int( properties, "y", 0 );
                mlt_properties_set_double( properties, "mix", 1.0 );
 
-               mlt_properties_set( properties, "resource", "pango" );
+               if ( filename == NULL )
+               {
+                       mlt_properties_set( properties, "resource", "pango" );
+                       mlt_properties_set( properties, "markup", "" );
+               }
+               else
+               {
+                       FILE *f = fopen( filename, "r" );
+                       if ( f != NULL )
+                       {
+                               char line[81];
+                               char *markup = NULL;
+                               size_t size = 0;
+                               line[80] = '\0';
+                               
+                               while ( fgets( line, 80, f ) )
+                               {
+                                       size += strlen( line ) + 1;
+                                       if ( markup )
+                                       {
+                                               realloc( markup, size );
+                                               strcat( markup, line );
+                                       }
+                                       else
+                                       {
+                                               markup = strdup( line );
+                                       }
+                               }
+                               fclose( f );
+                               mlt_properties_set( properties, "resource", ( char * ) filename );
+                               mlt_properties_set( properties, "markup", ( char * ) ( markup == NULL ? "" : markup ) );
+                               if ( markup )
+                                       free( markup );
+                       }
+                       else
+                       {
+                               mlt_properties_set( properties, "resource", "pango" );
+                               mlt_properties_set( properties, "markup", "" );
+                       }
+               }
 
                return producer;
        }
@@ -283,9 +321,12 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                mlt_properties_set_int( properties, "height", this->height );
 
                // Set the compositing properties
-               mlt_properties_set_int( properties, "x", mlt_properties_get_int( producer_props, "x" ) );
-               mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
-               mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
+               if ( mlt_properties_get( producer_props, "x" ) != NULL )
+                       mlt_properties_set_int( properties, "x", mlt_properties_get_int( producer_props, "x" ) );
+               if ( mlt_properties_get( producer_props, "y" ) != NULL )
+                       mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
+               if ( mlt_properties_get( producer_props, "mix" ) != NULL )
+                       mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
 
                // if picture sequence pass the image and alpha data without destructor
                mlt_properties_set_data( properties, "image", this->image, this->width * this->height * 2, NULL, NULL );
index ade19775dcbe4a49c1e5eb0cbad001f852923ed1..fbed05c2d244bb888f9640d4fadd6157328c4bea 100644 (file)
@@ -32,6 +32,6 @@ typedef enum
        pango_align_right
 } pango_align;
 
-extern mlt_producer producer_pango_init( const char *markup );
+extern mlt_producer producer_pango_init( const char *filename );
 
 #endif
index 29465db954e578b20d7ea9e57bcc41c7144b559e..5fd647ab1d9750403454c076f9db4e712ef8be54 100644 (file)
@@ -27,6 +27,8 @@ mlt_producer create_producer( char *file )
                result = mlt_factory_producer( "pixbuf", file );
        else if ( strstr( file, ".png" ) )
                result = mlt_factory_producer( "pixbuf", file );
+       else if ( strstr( file, ".txt" ) )
+               result = mlt_factory_producer( "pango", file );
 
        // 2nd Line fallbacks
        if ( result == NULL && strstr( file, ".dv" ) )
index f56c6778a6e9cd968f3a319fd36f8e6abebe9685..7bcdfa9fbcdd80a3126c63d72ec58a5393bb28b5 100644 (file)
@@ -81,6 +81,17 @@ static mlt_frame composite_process( mlt_transition this, mlt_frame a_frame, mlt_
 {
        mlt_frame_push_get_image( a_frame, transition_get_image );
        mlt_frame_push_frame( a_frame, b_frame );
+       
+       // Propogate the transition properties to the b frame
+       mlt_properties properties = mlt_transition_properties( this );
+       mlt_properties b_props = mlt_frame_properties( b_frame );
+       if ( mlt_properties_get( properties, "x" ) != NULL )
+               mlt_properties_set_int( b_props, "x", mlt_properties_get_int( properties, "x" ) );
+       if ( mlt_properties_get( properties, "y" ) != NULL )
+               mlt_properties_set_int( b_props, "y", mlt_properties_get_int( properties, "y" ) );
+       if ( mlt_properties_get( properties, "mix" ) != NULL )
+               mlt_properties_set_double( b_props, "mix",  mlt_properties_get_double( properties, "mix" ) );
+
        return a_frame;
 }
 
index 6609ce97756523c4295137c84c7dfec37b8058f6..752ed4a1241fe84b456c6d4cb20c578650188a0b 100644 (file)
@@ -55,7 +55,7 @@ static void pango_draw_background( GdkPixbuf *pixbuf, rgba_color bg );
 static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font,
        rgba_color fg, rgba_color bg, int pad, int align );
 
-mlt_producer producer_pango_init( const char *markup )
+mlt_producer producer_pango_init( const char *filename )
 {
        producer_pango this = calloc( sizeof( struct producer_pango_s ), 1 );
        if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
@@ -77,14 +77,52 @@ mlt_producer producer_pango_init( const char *markup )
                mlt_properties_set_int( properties, "bgcolor", 0x00000000 );
                mlt_properties_set_int( properties, "align", pango_align_left );
                mlt_properties_set_int( properties, "pad", 0 );
-               mlt_properties_set( properties, "markup", ( char * ) ( markup == NULL ? "" : markup ) );
                mlt_properties_set( properties, "text", "" );
                mlt_properties_set( properties, "font", "Sans 48" );
                mlt_properties_set_int( properties, "x", 0 );
                mlt_properties_set_int( properties, "y", 0 );
                mlt_properties_set_double( properties, "mix", 1.0 );
 
-               mlt_properties_set( properties, "resource", "pango" );
+               if ( filename == NULL )
+               {
+                       mlt_properties_set( properties, "resource", "pango" );
+                       mlt_properties_set( properties, "markup", "" );
+               }
+               else
+               {
+                       FILE *f = fopen( filename, "r" );
+                       if ( f != NULL )
+                       {
+                               char line[81];
+                               char *markup = NULL;
+                               size_t size = 0;
+                               line[80] = '\0';
+                               
+                               while ( fgets( line, 80, f ) )
+                               {
+                                       size += strlen( line ) + 1;
+                                       if ( markup )
+                                       {
+                                               realloc( markup, size );
+                                               strcat( markup, line );
+                                       }
+                                       else
+                                       {
+                                               markup = strdup( line );
+                                       }
+                               }
+                               fclose( f );
+                               mlt_properties_set( properties, "resource", ( char * ) filename );
+                               mlt_properties_set( properties, "markup", ( char * ) ( markup == NULL ? "" : markup ) );
+                               if ( markup )
+                                       free( markup );
+                       }
+                       else
+                       {
+                               mlt_properties_set( properties, "resource", "pango" );
+                               mlt_properties_set( properties, "markup", "" );
+                       }
+               }
 
                return producer;
        }
@@ -283,9 +321,12 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                mlt_properties_set_int( properties, "height", this->height );
 
                // Set the compositing properties
-               mlt_properties_set_int( properties, "x", mlt_properties_get_int( producer_props, "x" ) );
-               mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
-               mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
+               if ( mlt_properties_get( producer_props, "x" ) != NULL )
+                       mlt_properties_set_int( properties, "x", mlt_properties_get_int( producer_props, "x" ) );
+               if ( mlt_properties_get( producer_props, "y" ) != NULL )
+                       mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
+               if ( mlt_properties_get( producer_props, "mix" ) != NULL )
+                       mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
 
                // if picture sequence pass the image and alpha data without destructor
                mlt_properties_set_data( properties, "image", this->image, this->width * this->height * 2, NULL, NULL );
index ade19775dcbe4a49c1e5eb0cbad001f852923ed1..fbed05c2d244bb888f9640d4fadd6157328c4bea 100644 (file)
@@ -32,6 +32,6 @@ typedef enum
        pango_align_right
 } pango_align;
 
-extern mlt_producer producer_pango_init( const char *markup );
+extern mlt_producer producer_pango_init( const char *filename );
 
 #endif