]> git.sesse.net Git - mlt/commitdiff
add luma to composite.
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 9 Mar 2004 04:57:16 +0000 (04:57 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 9 Mar 2004 04:57:16 +0000 (04:57 +0000)
rework aspect handling to use sample aspect.
workaround westley segfault when another instance of libxml2 is used.
improved inline xml handling in westley - pango and svg.

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@196 d19143bc-622f-0410-bfdd-b5b2a6649095

14 files changed:
src/framework/mlt_consumer.c
src/framework/mlt_frame.c
src/framework/mlt_producer.c
src/modules/avformat/producer_avformat.c
src/modules/core/filter_resize.c
src/modules/core/producer_ppm.c
src/modules/core/transition_composite.c
src/modules/core/transition_luma.c
src/modules/dv/producer_libdv.c
src/modules/gtk2/filter_rescale.c
src/modules/gtk2/producer_pango.c
src/modules/gtk2/producer_pixbuf.c
src/modules/sdl/consumer_sdl.c
src/modules/westley/producer_westley.c

index a04863de8da909f66741fbdb88e889e45b4ad5f7..ac84f90ed158f55fa246a257d6544e0b4567b3b1 100644 (file)
@@ -53,6 +53,7 @@ int mlt_consumer_init( mlt_consumer this, void *child )
                        mlt_properties_set_int( properties, "width", 720 );
                        mlt_properties_set_int( properties, "height", 576 );
                        mlt_properties_set_int( properties, "progressive", 0 );
+                       mlt_properties_set_double( properties, "aspect_ratio", 128.0 / 117.0 );
                }
                else
                {
@@ -61,11 +62,9 @@ int mlt_consumer_init( mlt_consumer this, void *child )
                        mlt_properties_set_int( properties, "width", 720 );
                        mlt_properties_set_int( properties, "height", 480 );
                        mlt_properties_set_int( properties, "progressive", 0 );
+                       mlt_properties_set_double( properties, "aspect_ratio", 72.0 / 79.0 );
                }
 
-               // Default aspect ratio
-               mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 );
-
                // Default rescaler for all consumers
                mlt_properties_set( properties, "rescale", "bilinear" );
 
@@ -399,4 +398,3 @@ void mlt_consumer_close( mlt_consumer this )
        else
                mlt_service_close( &this->parent );
 }
-
index 544bea3ee5888405d33a9fd1ab6f06ad5b95e01f..39055606a99643a7f8397e137342f701a23105fd 100644 (file)
@@ -53,6 +53,7 @@ mlt_frame mlt_frame_init( )
                        mlt_properties_set_int( properties, "height", 576 );
                        mlt_properties_set_int( properties, "normalised_width", 720 );
                        mlt_properties_set_int( properties, "normalised_height", 576 );
+                       mlt_properties_set_double( properties, "aspect_ratio", 72.0/79.0 );
                }
                else
                {
@@ -60,9 +61,9 @@ mlt_frame mlt_frame_init( )
                        mlt_properties_set_int( properties, "height", 480 );
                        mlt_properties_set_int( properties, "normalised_width", 720 );
                        mlt_properties_set_int( properties, "normalised_height", 480 );
+                       mlt_properties_set_double( properties, "aspect_ratio", 128.0/117.0 );
                }
 
-               mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 );
                mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL );
                mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL );
 
@@ -204,7 +205,6 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
                {
                        mlt_properties test_properties = mlt_frame_properties( test_frame );
                        mlt_properties_set_double( test_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "consumer_aspect_ratio" ) );
-                       mlt_properties_set_double( test_properties, "consumer_scale", mlt_properties_get_double( properties, "consumer_scale" ) );
                        mlt_properties_set( test_properties, "rescale.interp", "nearest" );
                        mlt_frame_get_image( test_frame, buffer, format, width, height, writable );
                        mlt_properties_set_data( properties, "test_card_frame", test_frame, 0, ( mlt_destructor )mlt_frame_close, NULL );
@@ -746,4 +746,3 @@ int mlt_sample_calculator( float fps, int frequency, int64_t position )
 
        return samples;
 }
-
index e74724b9808c1fa688bd5ef8b67acca0dd9d264b..69b02337f85aed4efcd446cee8145c3b379c9b5b 100644 (file)
@@ -73,7 +73,7 @@ int mlt_producer_init( mlt_producer this, void *child )
                        mlt_properties_set_position( properties, "in", 0 );
                        mlt_properties_set_position( properties, "out", 14999 );
                        mlt_properties_set_position( properties, "length", 15000 );
-                       mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 );
+                       mlt_properties_set_double( properties, "aspect_ratio", 128.0 / 117.0 );
                        mlt_properties_set( properties, "eof", "pause" );
                        mlt_properties_set( properties, "resource", "<producer>" );
 
index 8400f41e320334f356f085df86044a8842cfc5d2..2e39825a5d7372d8942c84747c5cfb9526cde01b 100644 (file)
@@ -586,21 +586,15 @@ static void producer_set_up_video( mlt_producer this, mlt_frame frame )
                // No codec, no show...
                if ( codec != NULL )
                {
-                       double aspect_ratio = 0;
+                       double aspect_ratio = 1;
                        double source_fps = 0;
 
                        // Set aspect ratio
-                       if ( codec_context->sample_aspect_ratio.num == 0 )
-                               aspect_ratio = 0;
-                       else
-                               aspect_ratio = av_q2d( codec_context->sample_aspect_ratio ) * codec_context->width / codec_context->height;
+                       if ( codec_context->sample_aspect_ratio.num > 0 )
+                               aspect_ratio = av_q2d( codec_context->sample_aspect_ratio );
 
-                       // XXX: This assumes square pixels!
-                       if (aspect_ratio <= 0.0)
-                               aspect_ratio = ( double )codec_context->width / ( double )codec_context->height;
-                               
                        mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio );
-                       //fprintf( stderr, "AVFORMAT: sample aspect %f computed display aspect %f\n", av_q2d( codec_context->sample_aspect_ratio ), aspect_ratio );
+                       //fprintf( stderr, "AVFORMAT: sample aspect %f %dx%d\n", av_q2d( codec_context->sample_aspect_ratio ), codec_context->width, codec_context->height );
 
                        // Determine the fps
                        source_fps = ( double )codec_context->frame_rate / codec_context->frame_rate_base;
@@ -608,10 +602,13 @@ static void producer_set_up_video( mlt_producer this, mlt_frame frame )
                        // We'll use fps if it's available
                        if ( source_fps > 0 && source_fps < 30 )
                                mlt_properties_set_double( properties, "source_fps", source_fps );
+                       
+                       // Set the width and height
+                       mlt_properties_set_int( frame_properties, "width", codec_context->width );
+                       mlt_properties_set_int( frame_properties, "height", codec_context->height );
 
                        mlt_frame_push_get_image( frame, producer_get_image );
                        mlt_properties_set_data( frame_properties, "avformat_producer", this, 0, NULL, NULL );
-
                }
                else
                {
index 4122d8f373a51d1ca091ac637d94aa229c2df26b..7a1f5ddb60a6ac2dbe9566262c543c9bdd882768 100644 (file)
@@ -53,18 +53,24 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                // Normalise the input and out display aspect
                int normalised_width = mlt_properties_get_int( properties, "normalised_width" );
                int normalised_height = mlt_properties_get_int( properties, "normalised_height" );
-               double input_ar = mlt_frame_get_aspect_ratio( this );
-               double output_ar = mlt_properties_get_double( properties, "consumer_aspect_ratio" );
+               int real_width = mlt_properties_get_int( properties, "real_width" );
+               int real_height = mlt_properties_get_int( properties, "real_height" );
+               if ( real_width == 0 )
+                       real_width = mlt_properties_get_int( properties, "width" );
+               if ( real_height == 0 )
+                       real_height = mlt_properties_get_int( properties, "height" );
+               double input_ar = mlt_frame_get_aspect_ratio( this ) * real_width / real_height;
+               double output_ar = mlt_properties_get_double( properties, "consumer_aspect_ratio" ) * owidth / oheight;
                
                // Optimised for the input_ar > output_ar case (e.g. widescreen on standard)
-               int scaled_width = normalised_width;
-               int scaled_height = output_ar / input_ar * normalised_height;
+               int scaled_width = input_ar / output_ar * normalised_width + 0.5;
+               int scaled_height = normalised_height;
 
-               // Now ensure that our images fit in the normalised frame
-               if ( scaled_height > normalised_height )
+               // Now ensure that our images fit in the output frame
+               if ( scaled_width > normalised_width )
                {
-                       scaled_width = input_ar / output_ar * normalised_width;
-                       scaled_height = normalised_height;
+                       scaled_width = normalised_width;
+                       scaled_height = output_ar / input_ar * normalised_height + 0.5;
                }
        
                // Now calculate the actual image size that we want
@@ -154,4 +160,3 @@ mlt_filter filter_resize_init( char *arg )
        }
        return this;
 }
-
index 9865f80a05943760e4e5b26ebd8928d61b0dcc5e..4155783b377cb0daccfca30ccea0cf87ebf1ff06 100644 (file)
@@ -234,7 +234,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                mlt_properties_set_int( properties, "height", height );
                mlt_properties_set_int( properties, "has_image", 1 );
                mlt_properties_set_int( properties, "progressive", 1 );
-               mlt_properties_set_double( properties, "aspect_ratio", ( double )width  / height );
+               mlt_properties_set_double( properties, "aspect_ratio", 1 );
 
                // Push the image callback
                mlt_frame_push_get_image( *frame, producer_get_image );
@@ -272,4 +272,3 @@ static void producer_close( mlt_producer parent )
        mlt_producer_close( parent );
        free( this );
 }
-
index 42f23eba1699024b871d485eee272a350e2136d2..4d819e1003acc1c6adc6cf967df9add516fb2555 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "transition_composite.h"
-#include <framework/mlt_frame.h>
+#include <framework/mlt.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -322,10 +322,169 @@ static int get_value( mlt_properties properties, char *preferred, char *fallback
        return value;
 }
 
+/** A linear threshold determination function.
+*/
+
+static inline int32_t linearstep( int32_t edge1, int32_t edge2, int32_t a )
+{
+       if ( a < edge1 )
+               return 0;
+
+       if ( a >= edge2 )
+               return 0x10000;
+
+       return ( ( a - edge1 ) << 16 ) / ( edge2 - edge1 );
+}
+
+/** A smoother, non-linear threshold determination function.
+*/
+
+static inline int32_t smoothstep( int32_t edge1, int32_t edge2, uint32_t a )
+{
+       if ( a < edge1 )
+               return 0;
+
+       if ( a >= edge2 )
+               return 0x10000;
+
+       a = ( ( a - edge1 ) << 16 ) / ( edge2 - edge1 );
+
+       return ( ( ( a * a ) >> 16 )  * ( ( 3 << 16 ) - ( 2 * a ) ) ) >> 16;
+}
+
+/** Load the luma map from PGM stream.
+*/
+
+static void luma_read_pgm( FILE *f, uint16_t **map, int *width, int *height )
+{
+       uint8_t *data = NULL;
+       while (1)
+       {
+               char line[128];
+               char comment[128];
+               int i = 2;
+               int maxval;
+               int bpp;
+               uint16_t *p;
+
+               line[127] = '\0';
+
+               // get the magic code
+               if ( fgets( line, 127, f ) == NULL )
+                       break;
+
+               // skip comments
+               while ( sscanf( line, " #%s", comment ) > 0 )
+                       if ( fgets( line, 127, f ) == NULL )
+                               break;
+
+               if ( line[0] != 'P' || line[1] != '5' )
+                       break;
+
+               // skip white space and see if a new line must be fetched
+               for ( i = 2; i < 127 && line[i] != '\0' && isspace( line[i] ); i++ );
+               if ( ( line[i] == '\0' || line[i] == '#' ) && fgets( line, 127, f ) == NULL )
+                       break;
+
+               // skip comments
+               while ( sscanf( line, " #%s", comment ) > 0 )
+                       if ( fgets( line, 127, f ) == NULL )
+                               break;
+
+               // get the dimensions
+               if ( line[0] == 'P' )
+                       i = sscanf( line, "P5 %d %d %d", width, height, &maxval );
+               else
+                       i = sscanf( line, "%d %d %d", width, height, &maxval );
+
+               // get the height value, if not yet
+               if ( i < 2 )
+               {
+                       if ( fgets( line, 127, f ) == NULL )
+                               break;
+
+                       // skip comments
+                       while ( sscanf( line, " #%s", comment ) > 0 )
+                               if ( fgets( line, 127, f ) == NULL )
+                                       break;
+
+                       i = sscanf( line, "%d", height );
+                       if ( i == 0 )
+                               break;
+                       else
+                               i = 2;
+               }
+
+               // get the maximum gray value, if not yet
+               if ( i < 3 )
+               {
+                       if ( fgets( line, 127, f ) == NULL )
+                               break;
+
+                       // skip comments
+                       while ( sscanf( line, " #%s", comment ) > 0 )
+                               if ( fgets( line, 127, f ) == NULL )
+                                       break;
+
+                       i = sscanf( line, "%d", &maxval );
+                       if ( i == 0 )
+                               break;
+               }
+
+               // determine if this is one or two bytes per pixel
+               bpp = maxval > 255 ? 2 : 1;
+
+               // allocate temporary storage for the raw data
+               data = mlt_pool_alloc( *width * *height * bpp );
+               if ( data == NULL )
+                       break;
+
+               // read the raw data
+               if ( fread( data, *width * *height * bpp, 1, f ) != 1 )
+                       break;
+
+               // allocate the luma bitmap
+               *map = p = (uint16_t*)mlt_pool_alloc( *width * *height * sizeof( uint16_t ) );
+               if ( *map == NULL )
+                       break;
+
+               // proces the raw data into the luma bitmap
+               for ( i = 0; i < *width * *height * bpp; i += bpp )
+               {
+                       if ( bpp == 1 )
+                               *p++ = data[ i ] << 8;
+                       else
+                               *p++ = ( data[ i ] << 8 ) + data[ i+1 ];
+               }
+
+               break;
+       }
+
+       if ( data != NULL )
+               mlt_pool_release( data );
+}
+
+/** Generate a luma map from any YUV image.
+*/
+
+static void luma_read_yuv422( uint8_t *image, uint16_t **map, int width, int height )
+{
+       int i;
+       
+       // allocate the luma bitmap
+       uint16_t *p = *map = ( uint16_t* )mlt_pool_alloc( width * height * sizeof( uint16_t ) );
+       if ( *map == NULL )
+               return;
+
+       // proces the image data into the luma bitmap
+       for ( i = 0; i < width * height * 2; i += 2 )
+               *p++ = ( image[ i ] - 16 ) * 299; // 299 = 65535 / 219
+}
+
 /** Composite function.
 */
 
-static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, int bpp, uint8_t *p_src, int width_src, int height_src, uint8_t *p_alpha, struct geometry_s geometry, int field )
+static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, int bpp, uint8_t *p_src, int width_src, int height_src, uint8_t *p_alpha, struct geometry_s geometry, int field, uint16_t *p_luma, int32_t softness )
 {
        int ret = 0;
        int i, j;
@@ -380,6 +539,10 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, int
        if ( p_alpha )
                p_alpha += x_src + y_src * stride_src / bpp;
 
+       // offset pointer into luma channel based upon cropping
+       if ( p_luma )
+               p_luma += x_src + y_src * stride_src / bpp;
+       
        // Assuming lower field first
        // Special care is taken to make sure the b_frame is aligned to the correct field.
        // field 0 = lower field and y should be odd (y is 0-based).
@@ -405,9 +568,11 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, int
        uint8_t *p = p_src;
        uint8_t *q = p_dest;
        uint8_t *o = p_dest;
+       uint16_t *l = p_luma;
        uint8_t *z = p_alpha;
 
        uint8_t a;
+       int32_t current_weight;
        int32_t value;
        int step = ( field > -1 ) ? 2 : 1;
 
@@ -421,12 +586,14 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, int
                p = p_src;
                q = p_dest;
                o = q;
+               l = p_luma;
                z = p_alpha;
 
                for ( j = 0; j < width_src; j ++ )
                {
                        a = ( z == NULL ) ? 255 : *z ++;
-                       value = ( weight * ( a + 1 ) ) >> 8;
+                       current_weight = ( l == NULL ) ? weight : linearstep( l[ j ], l[ j ] + softness, weight );
+                       value = ( current_weight * ( a + 1 ) ) >> 8;
                        *o ++ = ( *p++ * value + *q++ * ( ( 1 << 16 ) - value ) ) >> 16;
                        *o ++ = ( *p++ * value + *q++ * ( ( 1 << 16 ) - value ) ) >> 16;
                }
@@ -435,11 +602,103 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, int
                p_dest += stride_dest;
                if ( p_alpha )
                        p_alpha += alpha_stride;
+               if ( p_luma )
+                       p_luma += alpha_stride;
        }
 
        return ret;
 }
 
+static uint16_t* get_luma( mlt_properties properties, int width, int height )
+{
+       // The cached luma map information
+       int luma_width = mlt_properties_get_int( properties, "_luma.width" );
+       int luma_height = mlt_properties_get_int( properties, "_luma.height" );
+       uint16_t *luma_bitmap = mlt_properties_get_data( properties, "_luma.bitmap", NULL );
+       
+       // If the filename property changed, reload the map
+       char *resource = mlt_properties_get( properties, "luma" );
+
+       if ( luma_bitmap == NULL && resource != NULL )
+       {
+               char *extension = extension = strrchr( resource, '.' );
+
+               // See if it is a PGM
+               if ( extension != NULL && strcmp( extension, ".pgm" ) == 0 )
+               {
+                       // Open PGM
+                       FILE *f = fopen( resource, "r" );
+                       if ( f != NULL )
+                       {
+                               // Load from PGM
+                               luma_read_pgm( f, &luma_bitmap, &luma_width, &luma_height );
+                               fclose( f );
+
+                               // Set the transition properties
+                               mlt_properties_set_int( properties, "_luma.width", luma_width );
+                               mlt_properties_set_int( properties, "_luma.height", luma_height );
+                               mlt_properties_set_data( properties, "_luma.bitmap", luma_bitmap, luma_width * luma_height * 2, mlt_pool_release, NULL );
+                       }
+               }
+               else
+               {
+                       // Get the factory producer service
+                       char *factory = mlt_properties_get( properties, "factory" );
+
+                       // Create the producer
+                       mlt_producer producer = mlt_factory_producer( factory, resource );
+
+                       // If we have one
+                       if ( producer != NULL )
+                       {
+                               // Get the producer properties
+                               mlt_properties producer_properties = mlt_producer_properties( producer );
+
+                               // Ensure that we loop
+                               mlt_properties_set( producer_properties, "eof", "loop" );
+
+                               // Now pass all producer. properties on the transition down
+                               mlt_properties_pass( producer_properties, properties, "luma." );
+
+                               // We will get the alpha frame from the producer
+                               mlt_frame luma_frame = NULL;
+
+                               // Get the luma frame
+                               if ( mlt_service_get_frame( mlt_producer_service( producer ), &luma_frame, 0 ) == 0 )
+                               {
+                                       uint8_t *luma_image;
+                                       mlt_image_format luma_format = mlt_image_yuv422;
+
+                                       // Request a luma image the size of transition image request
+                                       luma_width = width;
+                                       luma_height = height;
+
+                                       // Get image from the luma producer
+                                       mlt_properties_set( mlt_frame_properties( luma_frame ), "distort", "true" );
+                                       mlt_frame_get_image( luma_frame, &luma_image, &luma_format, &luma_width, &luma_height, 0 );
+
+                                       // Generate the luma map
+                                       if ( luma_image != NULL && luma_format == mlt_image_yuv422 )
+                                       {
+                                               luma_read_yuv422( luma_image, &luma_bitmap, luma_width, luma_height );
+                                       
+                                               // Set the transition properties
+                                               mlt_properties_set_int( properties, "_luma.width", luma_width );
+                                               mlt_properties_set_int( properties, "_luma.height", luma_height );
+                                               mlt_properties_set_data( properties, "_luma.bitmap", luma_bitmap, luma_width * luma_height * 2, mlt_pool_release, NULL );
+                                       }
+
+                                       // Cleanup the luma frame
+                                       mlt_frame_close( luma_frame );
+                               }
+
+                               // Cleanup the luma producer
+                               mlt_producer_close( producer );
+                       }
+               }
+       }
+       return luma_bitmap;
+}
 
 /** Get the properly sized image from b_frame.
 */
@@ -462,13 +721,8 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t **
                int real_height = get_value( b_props, "real_height", "height" );
                double input_ar = mlt_frame_get_aspect_ratio( b_frame );
                double output_ar = mlt_properties_get_double( b_props, "consumer_aspect_ratio" );
-               int scaled_width = real_width;
+               int scaled_width = input_ar / output_ar * real_width;
                int scaled_height = real_height;
-               double output_sar = ( double ) geometry->nw / geometry->nh / output_ar;
-
-               // If the output is fat pixels (NTSC) then stretch our input horizontally
-               // derived from: output_sar / input_sar * real_width
-               scaled_width = output_sar * real_height * input_ar;
                        
                // Now ensure that our images fit in the normalised frame
                if ( scaled_width > normalised_width )
@@ -671,11 +925,14 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
 
                // Do the calculation
                struct geometry_s *start = composite_calculate( &result, this, a_frame, position );
+               
+               // Optimisation - no compositing required
+               if ( result.mix == 0 )
+                       return 0;
 
                // Since we are the consumer of the b_frame, we must pass along these
                // consumer properties from the a_frame
                mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) );
-               mlt_properties_set_double( b_props, "consumer_scale", mlt_properties_get_double( a_props, "consumer_scale" ) );
 
                // Get the image from the b frame
                uint8_t *image_b = NULL;
@@ -692,6 +949,9 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
                                        mlt_properties_get_int( a_props, "consumer_progressive" ) ||
                                        mlt_properties_get_int( properties, "progressive" );
                        int field;
+                       
+                       int32_t luma_softness = mlt_properties_get_double( properties, "softness" ) * ( 1 << 16 );
+                       uint16_t *luma_bitmap = get_luma( properties, width_b, height_b );
 
                        for ( field = 0; field < ( progressive ? 1 : 2 ); field++ )
                        {
@@ -705,7 +965,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
                                alignment_calculate( &result );
 
                                // Composite the b_frame on the a_frame
-                               composite_yuv( dest, *width, *height, bpp, src, width_b, height_b, alpha, result, progressive ? -1 : field );
+                               composite_yuv( dest, *width, *height, bpp, src, width_b, height_b, alpha, result, progressive ? -1 : field, luma_bitmap, luma_softness );
                        }
                }
        }
@@ -736,7 +996,9 @@ mlt_transition transition_composite_init( char *arg )
        {
                this->process = composite_process;
                mlt_properties_set( mlt_transition_properties( this ), "start", arg != NULL ? arg : "85%,5%:10%x10%" );
+               
+               // Default factory
+               mlt_properties_set( mlt_transition_properties( this ), "factory", "fezzik" );
        }
        return this;
 }
-
index 8db5d4df732a3f88266b3838343c9a9216b4aba1..66cd4258222386d59981a1e87ea249b7ddbea42c 100644 (file)
@@ -412,6 +412,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
                                        luma_height = *height;
 
                                        // Get image from the luma producer
+                                       mlt_properties_set( mlt_frame_properties( luma_frame ), "distort", "true" );
                                        mlt_frame_get_image( luma_frame, &luma_image, &luma_format, &luma_width, &luma_height, 0 );
 
                                        // Generate the luma map
index 8b77b2ba25e520ffcd4baaa076254c79d3586d47..3d4f2439d063845544fac85c2941a51ec581b5ac 100644 (file)
@@ -153,7 +153,8 @@ static int producer_collect_info( producer_libdv this )
 
                        // Parse the header for meta info
                        dv_parse_header( this->dv_decoder, dv_data );
-                       mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 );
+                       mlt_properties_set_double( properties, "aspect_ratio", 
+                               dv_format_wide( this->dv_decoder ) ? ( this->is_pal ? 512/351 : 96/79 ) : ( this->is_pal ? 128/117 : 72/79 ) );
                }
 
                mlt_pool_release( dv_data );
@@ -316,7 +317,8 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                // Parse the header for meta info
                dv_parse_header( this->dv_decoder, data );
                mlt_properties_set_int( properties, "progressive", dv_is_progressive( this->dv_decoder ) );
-               mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 );
+               mlt_properties_set_double( properties, "aspect_ratio", 
+                       dv_format_wide( this->dv_decoder ) ? ( this->is_pal ? 512.0/351.0 : 96.0/79.0 ) : ( this->is_pal ? 128.0/117.0 : 72.0/79.0 ) );
 
                // Hmm - register audio callback
                ( *frame )->get_audio = producer_get_audio;
@@ -357,4 +359,3 @@ static void producer_close( mlt_producer parent )
        // Free the memory
        free( this );
 }
-
index 02b76442a769f6a27b30247b947baa48911a5bf2..5151a059b46043bfde9448721386842f0809421f 100644 (file)
@@ -220,4 +220,3 @@ mlt_filter filter_rescale_init( char *arg )
        }
        return this;
 }
-
index c26e61a5977be9e9065b1ccb5148467ae5b152f3..a7ac1fa0b5b5e583c3d7a0276df8a9ecc34c6b7e 100644 (file)
@@ -419,7 +419,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
 
        // Set producer-specific frame properties
        mlt_properties_set_int( properties, "progressive", 1 );
-       mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( properties, "real_width" ) / mlt_properties_get_double( properties, "real_height" ) );
+       mlt_properties_set_double( properties, "aspect_ratio", 1 );
 
        // Set alpha call back
        ( *frame )->get_alpha_mask = producer_get_alpha_mask;
@@ -535,4 +535,3 @@ static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const
 
        return pixbuf;
 }
-
index 88355b9a2e093d14b1bf6b03cc8175f49e512db2..d6eeb4220e1c004c73b25a56fb2b1d372cf25cd3 100644 (file)
@@ -274,8 +274,39 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                mlt_properties properties = mlt_producer_properties( producer );
                char *filename = mlt_properties_get( properties, "resource" );
                
+               // Read xml string
+               if ( strstr( filename, "<svg" ) )
+               {
+                       // Generate a temporary file for the svg
+                       char fullname[ 1024 ] = "/tmp/mlt.XXXXXX";
+                       int fd = mkstemp( fullname );
+
+                       if ( fd > -1 )
+                       {
+                               // Write the svg into the temp file
+                               ssize_t remaining_bytes;
+                               char *xml = filename;
+                               
+                               // Strip leading crap
+                               while ( xml[0] != '<' )
+                                       xml++;
+                               
+                               remaining_bytes = strlen( xml );
+                               while ( remaining_bytes > 0 )
+                                       remaining_bytes -= write( fd, xml + strlen( xml ) - remaining_bytes, remaining_bytes );
+                               close( fd );
+
+                               this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) );
+                               this->filenames[ this->count ++ ] = strdup( fullname );
+
+                               mlt_properties_set_position( properties, "out", 250 );
+
+                               // Teehe - when the producer closes, delete the temp file and the space allo
+                               mlt_properties_set_data( properties, "__temporary_file__", this->filenames[ this->count - 1 ], 0, ( mlt_destructor )unlink, NULL );
+                       }
+               }
                // Obtain filenames
-               if ( strchr( filename, '%' ) != NULL )
+               else if ( strchr( filename, '%' ) != NULL )
                {
                        // handle picture sequences
                        int i = 0;
@@ -327,29 +358,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                        free( de );
                        free( dir_name );
                }
-               else if ( strstr( filename, "<svg" ) )
-               {
-                       // Generate a temporary file for the svg
-                       char fullname[ 1024 ] = "/tmp/mlt.XXXXXX";
-                       int fd = mkstemp( fullname );
-
-                       if ( fd > -1 )
-                       {
-                               // Write the svg into the temp file
-                               ssize_t remaining_bytes = strlen( filename );
-                               while ( remaining_bytes > 0 )
-                                       remaining_bytes -= write( fd, filename + strlen( filename ) - remaining_bytes, remaining_bytes );
-                               close( fd );
-
-                               this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) );
-                               this->filenames[ this->count ++ ] = strdup( fullname );
-
-                               mlt_properties_set_position( properties, "out", 250 );
-
-                               // Teehe - when the producer closes, delete the temp file and the space allo
-                               mlt_properties_set_data( properties, "__temporary_file__", this->filenames[ this->count - 1 ], 0, ( mlt_destructor )unlink, NULL );
-                       }
-               }
                else
                {
                        this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) );
@@ -380,7 +388,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
 
                // Set producer-specific frame properties
                mlt_properties_set_int( properties, "progressive", 1 );
-               mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( properties, "real_width" )/mlt_properties_get_double( properties, "real_height" ) );
+               mlt_properties_set_double( properties, "aspect_ratio", 1 );
 
                // Set alpha call back
                ( *frame )->get_alpha_mask = producer_get_alpha_mask;
@@ -406,4 +414,3 @@ static void producer_close( mlt_producer parent )
        free( this->filenames );
        free( this );
 }
-
index 0de719e7f4235e97f95c0a05b279a2c11d024e4d..74cfd28cb67ad5ac0b2fc052e5a047cbac239493 100644 (file)
@@ -118,9 +118,9 @@ mlt_consumer consumer_sdl_init( char *arg )
                        this->width = mlt_properties_get_int( this->properties, "width" );
                        this->height = mlt_properties_get_int( this->properties, "height" );
                }
-
+               
                // Default window size
-               this->window_width = (int)( (float)this->height * this->aspect_ratio ) + 1;
+               this->window_width = (int)( (float)this->height * 4.0/3.0 + 0.5);
                this->window_height = this->height;
                
                // Set the sdl flags
@@ -334,7 +334,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap
 
        // Set skip
        mlt_properties_set_position( mlt_frame_properties( frame ), "playtime", playtime );
-       mlt_properties_set_double( mlt_frame_properties( frame ), "consumer_scale", ( double )height / mlt_properties_get_double( properties, "height" ) );
 
        // Push this frame to the back of the queue
        mlt_deque_push_back( this->queue, frame );
@@ -397,12 +396,12 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap
 
                if ( this->sdl_screen == NULL || changed )
                {
-                       double aspect_ratio = mlt_frame_get_aspect_ratio( frame );
-                       float display_aspect_ratio = (float)width / (float)height;
+                       double aspect_ratio = ( float )this->aspect_ratio * this->width / this->height;
+                       float display_aspect_ratio = ( float )width / height;
                        SDL_Rect rect;
-
-                       if ( mlt_properties_get_double( properties, "aspect_ratio" ) )
-                               aspect_ratio = mlt_properties_get_double( properties, "aspect_ratio" );
+                       if ( mlt_properties_get( properties, "rescale" ) != NULL &&
+                                       !strcmp( mlt_properties_get( properties, "rescale" ), "none" ) )
+                               aspect_ratio = mlt_frame_get_aspect_ratio( frame ) * mlt_properties_get_int(mlt_frame_properties(frame),"width") / mlt_properties_get_int(mlt_frame_properties(frame),"height");
 
                        if ( aspect_ratio == 1 )
                        {
@@ -412,11 +411,11 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap
                        else if ( this->window_width < this->window_height * aspect_ratio )
                        {
                                rect.w = this->window_width;
-                               rect.h = this->window_width / aspect_ratio;
+                               rect.h = this->window_width / aspect_ratio + 1;
                        }
                        else
                        {
-                               rect.w = this->window_height * aspect_ratio;
+                               rect.w = this->window_height * aspect_ratio + 1;
                                rect.h = this->window_height;
                        }
 
@@ -604,4 +603,3 @@ static void consumer_close( mlt_consumer parent )
        // Finally clean up this
        free( this );
 }
-
index f7dd08049b98850087155bf98cb44106c6b4140d..49e808b4af6f6d58fe5c88bbafd0ad7a7ae96d18 100644 (file)
@@ -18,7 +18,9 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-// TODO: destroy unreferenced producers
+// TODO: destroy unreferenced producers (they are currently destroyed
+//       when the returned producer is closed).
+// TODO: try using XmlReader interface to avoid global context issues in sax.
  
 #include "producer_westley.h"
 #include <framework/mlt.h>
@@ -371,8 +373,12 @@ static void on_end_producer( deserialise_context context, const xmlChar *name )
        if ( properties == NULL )
                return;
                
-       // Instatiate the producer
-       if ( mlt_properties_get( properties, "resource" ) != NULL )
+       // Instantiate the producer
+       if ( mlt_properties_get( properties, "mlt_service" ) != NULL )
+       {
+               service = MLT_SERVICE( mlt_factory_producer( "fezzik", mlt_properties_get( properties, "mlt_service" ) ) );
+       }
+       if ( service == NULL && mlt_properties_get( properties, "resource" ) != NULL )
        {
                char *root = mlt_properties_get( context->producer_map, "_root" );
                char *resource = mlt_properties_get( properties, "resource" );
@@ -389,10 +395,6 @@ static void on_end_producer( deserialise_context context, const xmlChar *name )
                service = MLT_SERVICE( mlt_factory_producer( "fezzik", full_resource ) );
                free( full_resource );
        }
-       if ( service == NULL && mlt_properties_get( properties, "mlt_service" ) != NULL )
-       {
-               service = MLT_SERVICE( mlt_factory_producer( "fezzik", mlt_properties_get( properties, "mlt_service" ) ) );
-       }
 
        track_service( context->destructors, service, (mlt_destructor) mlt_producer_close );
 
@@ -620,6 +622,7 @@ mlt_producer producer_westley_init( char *filename )
        sax->startElement = on_start_element;
        sax->endElement = on_end_element;
        sax->characters = on_characters;
+       sax->cdataBlock = on_characters;
 
        // I REALLY DON'T GET THIS - HOW THE HELL CAN YOU REFERENCE A WESTLEY IN A WESTLEY???
        xmlInitParser();
@@ -669,10 +672,9 @@ mlt_producer producer_westley_init( char *filename )
        mlt_properties_close( context->producer_map );
        //free( context );
        free( sax );
-       xmlCleanupParser();
+       //xmlCleanupParser();
        xmlMemoryDump( );
 
 
        return MLT_PRODUCER( service );
 }
-