]> git.sesse.net Git - mlt/commitdiff
Filter optimisations and cleanup part 1
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 24 Feb 2004 08:41:24 +0000 (08:41 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 24 Feb 2004 08:41:24 +0000 (08:41 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@165 d19143bc-622f-0410-bfdd-b5b2a6649095

15 files changed:
src/framework/mlt_consumer.c
src/framework/mlt_filter.c
src/framework/mlt_filter.h
src/framework/mlt_frame.c
src/framework/mlt_frame.h
src/modules/core/filter_brightness.c
src/modules/core/filter_deinterlace.c
src/modules/core/filter_gamma.c
src/modules/core/filter_greyscale.c
src/modules/core/filter_obscure.c
src/modules/core/filter_resize.c
src/modules/core/transition_composite.c
src/modules/fezzik/producer_fezzik.c
src/modules/gtk2/producer_pixbuf.c
src/modules/sdl/consumer_sdl.c

index 7165ae9b36fd89da8661917608c5f22892c8238f..99a3856cf3582cf1115d91070b62743b72fd4a68 100644 (file)
@@ -164,7 +164,7 @@ mlt_frame mlt_consumer_get_frame( mlt_consumer this )
                if ( mlt_properties_get( properties, "rescale" ) != NULL )
                        mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale" ) );
 
-               // TODO: Aspect ratio and other jiggery pokery
+               // Aspect ratio and other jiggery pokery
                mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) );
                mlt_properties_set_int( frame_properties, "consumer_progressive", mlt_properties_get_int( properties, "progressive" ) );
                
index 90dea22c92e26db8686d8c1271fca06875507508..d83e42fbd4436848164b64e9cad6baabffa3d61b 100644 (file)
@@ -48,13 +48,23 @@ int mlt_filter_init( mlt_filter this, void *child )
                mlt_properties_set_position( properties, "in", 0 );
                mlt_properties_set_position( properties, "out", 0 );
                mlt_properties_set_int( properties, "track", 0 );
-               mlt_properties_set( properties, "resource", "<filter>" );
 
                return 0;
        }
        return 1;
 }
 
+/** Create a new filter.
+*/
+
+mlt_filter mlt_filter_new( )
+{
+       mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) );
+       if ( this != NULL )
+               mlt_filter_init( this, NULL );
+       return this;
+}
+
 /** Get the service associated to this filter
 */
 
index d107b3393e5628d18087cebe7e34ab86706dcf74..158f28a98865cc552de66433dc01b4c1cf7f0d21 100644 (file)
@@ -48,6 +48,7 @@ struct mlt_filter_s
 */
 
 extern int mlt_filter_init( mlt_filter this, void *child );
+extern mlt_filter mlt_filter_new( );
 extern mlt_service mlt_filter_service( mlt_filter this );
 extern mlt_properties mlt_filter_properties( mlt_filter this );
 extern mlt_frame mlt_filter_process( mlt_filter this, mlt_frame that );
index 409d3687a862555dc9a852299044c336dbeca705..6c367e9335e79778f38386855afc4524f90b3b22 100644 (file)
@@ -65,8 +65,11 @@ mlt_frame mlt_frame_init( )
                mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL );
                mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL );
 
-
+               // Construct stacks for frames and methods
+               this->stack_get_image = mlt_deque_init( );
+               this->stack_frame = mlt_deque_init( );
        }
+
        return this;
 }
 
@@ -131,10 +134,7 @@ int mlt_frame_set_position( mlt_frame this, mlt_position value )
 
 int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image )
 {
-       int ret = this->stack_get_image_size >= 10;
-       if ( ret == 0 )
-               this->stack_get_image[ this->stack_get_image_size ++ ] = get_image;
-       return ret;
+       return mlt_deque_push_back( this->stack_get_image, get_image );
 }
 
 /** Pop a get_image callback.
@@ -142,10 +142,7 @@ int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image )
 
 mlt_get_image mlt_frame_pop_get_image( mlt_frame this )
 {
-       mlt_get_image result = NULL;
-       if ( this->stack_get_image_size > 0 )
-               result = this->stack_get_image[ -- this->stack_get_image_size ];
-       return result;
+       return mlt_deque_pop_back( this->stack_get_image );
 }
 
 /** Push a frame.
@@ -153,10 +150,7 @@ mlt_get_image mlt_frame_pop_get_image( mlt_frame this )
 
 int mlt_frame_push_frame( mlt_frame this, mlt_frame that )
 {
-       int ret = this->stack_frame_size >= 10;
-       if ( ret == 0 )
-               this->stack_frame[ this->stack_frame_size ++ ] = that;
-       return ret;
+       return mlt_deque_push_back( this->stack_frame, that );
 }
 
 /** Pop a frame.
@@ -164,10 +158,7 @@ int mlt_frame_push_frame( mlt_frame this, mlt_frame that )
 
 mlt_frame mlt_frame_pop_frame( mlt_frame this )
 {
-       mlt_frame result = NULL;
-       if ( this->stack_frame_size > 0 )
-               result = this->stack_frame[ -- this->stack_frame_size ];
-       return result;
+       return mlt_deque_pop_back( this->stack_frame );
 }
 
 int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
@@ -302,6 +293,8 @@ int mlt_frame_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *for
 
 void mlt_frame_close( mlt_frame this )
 {
+       mlt_deque_close( this->stack_get_image );
+       mlt_deque_close( this->stack_frame );
        mlt_properties_close( &this->parent );
        free( this );
 }
index ee11626a3a1c7937c2444e6381b2cdad117258f9..1af606881cd932d1e06a50beef09931c2ae06580 100644 (file)
@@ -22,6 +22,7 @@
 #define _MLT_FRAME_H_
 
 #include "mlt_properties.h"
+#include "mlt_deque.h"
 
 typedef enum
 {
@@ -59,10 +60,8 @@ struct mlt_frame_s
        uint8_t * ( *get_alpha_mask )( mlt_frame this );
        
        // Private properties
-       mlt_get_image stack_get_image[ 10 ];
-       int stack_get_image_size;
-       mlt_frame stack_frame[ 10 ];
-       int stack_frame_size;
+       mlt_deque stack_get_image;
+       mlt_deque stack_frame;
 };
 
 extern mlt_frame mlt_frame_init( );
index d4b02af01aa8f3306debebd59ddb110114c57dee..6850d528a6978cf5cfcf076afb8822f7de9a8d34 100644 (file)
 
 static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
 {
-       mlt_frame_get_image( this, image, format, width, height, 1 );
-       uint8_t *p = *image;
-       uint8_t *q = *image + *width * *height * 2;
+       // Get the image
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
 
-       // Get the brightness level
-       double level = mlt_properties_get_double( mlt_frame_properties( this ), "brightness.level" );
-
-       while ( p != q )
+       // Only process if we have no error and a valid colour space
+       if ( error == 0 && *format == mlt_image_yuv422 )
        {
-               float x = (float) *p * level;
-               *p = x < 16 ? 16 : x > 235 ? 235 : x;
-               p += 2;
+               // Get the brightness level
+               double level = mlt_properties_get_double( mlt_frame_properties( this ), "brightness" );
+
+               // Only process if level is something other than 1
+               if ( level != 1.0 )
+               {
+                       uint8_t *p = *image;
+                       uint8_t *q = *image + *width * *height * 2;
+                       int32_t x = 0;
+                       int32_t m = level * ( 1 << 16 );
+
+                       while ( p != q )
+                       {
+                               x = ( *p * m ) >> 16;
+                               *p = x < 16 ? 16 : x > 235 ? 235 : x;
+                               p += 2;
+                       }
+               }
        }
 
-       return 0;
+       return error;
 }
 
 /** Filter processing.
@@ -53,6 +65,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
 
 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 {
+       // Get the starting brightness level
        double level = fabs( mlt_properties_get_double( mlt_filter_properties( this ), "start" ) );
        
        // If there is an end adjust gain to the range
@@ -66,8 +79,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
                double end = fabs( mlt_properties_get_double( mlt_filter_properties( this ), "end" ) );
                level += ( end - level ) * position;
        }
+
+       // Push the frame filter
+       mlt_properties_set_double( mlt_frame_properties( frame ), "brightness", level );
        mlt_frame_push_get_image( frame, filter_get_image );
-       mlt_properties_set_double( mlt_frame_properties( frame ), "brightness.level", level );
+
        return frame;
 }
 
@@ -76,13 +92,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 
 mlt_filter filter_brightness_init( char *arg )
 {
-       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+       mlt_filter this = mlt_filter_new( );
        if ( this != NULL )
        {
-               mlt_filter_init( this, NULL );
                this->process = filter_process;
-               if ( arg != NULL )
-                       mlt_properties_set_double( mlt_filter_properties( this ), "start", atof( arg ) );
+               mlt_properties_set( mlt_filter_properties( this ), "start", arg == NULL ? "1" : arg );
        }
        return this;
 }
index 3b4598a37408ff29b6021f980d4baa80406d58b7..59257f166cf8667da3f3c49c6123a08c8b5e7029 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 
-/** Deinterlace class.
-*/
-
-typedef struct 
-{
-       struct mlt_filter_s parent;
-}
-filter_deinterlace;
-
 /* Linear Blend filter - C version contributed by Rogerio Brito.
    This algorithm has the same interface as the other functions.
 
@@ -55,27 +46,27 @@ static void deinterlace_yuv( uint8_t *pdst, uint8_t *psrc, int width, int height
        register int x, y;
        register uint8_t *l0, *l1, *l2, *l3;
 
-       l0 = pdst;              /* target line */
-       l1 = psrc;              /* 1st source line */
-       l2 = l1 + width;        /* 2nd source line = line that follows l1 */
-       l3 = l2 + width;        /* 3rd source line = line that follows l2 */
+       l0 = pdst;                      // target line
+       l1 = psrc;                      // 1st source line
+       l2 = l1 + width;        // 2nd source line = line that follows l1
+       l3 = l2 + width;        // 3rd source line = line that follows l2
 
-       /* Copy the first line */
+       // Copy the first line
        memcpy(l0, l1, width);
        l0 += width;
 
        for (y = 1; y < height-1; ++y) 
        {
-               /* computes avg of: l1 + 2*l2 + l3 */
+               // computes avg of: l1 + 2*l2 + l3
                for (x = 0; x < width; ++x)
                        l0[x] = (l1[x] + (l2[x]<<1) + l3[x]) >> 2;
 
-               /* updates the line pointers */
+               // updates the line pointers
                l1 = l2; l2 = l3; l3 += width;
                l0 += width;
        }
 
-       /* Copy the last line */
+       // Copy the last line
        memcpy(l0, l1, width);
 }
 
@@ -84,10 +75,25 @@ static void deinterlace_yuv( uint8_t *pdst, uint8_t *psrc, int width, int height
 
 static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
 {
-       mlt_frame_get_image( this, image, format, width, height, 1 );
-       deinterlace_yuv( *image, *image, *width * 2, *height );
-       mlt_properties_set_int( mlt_frame_properties( this ), "progressive", 1 );
-       return 0;
+       // Get the input image
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+
+       // Only continue if we have no error and the right colour space
+       if ( error == 0 && *format == mlt_image_yuv422 )
+       {
+               // Check that we want progressive and we aren't already progressive
+               if ( !mlt_properties_get_int( mlt_frame_properties( this ), "progressive" ) &&
+                        mlt_properties_get_int( mlt_frame_properties( this ), "consumer_progressive" ) )
+               {
+                       // Deinterlace the image
+                       deinterlace_yuv( *image, *image, *width * 2, *height );
+
+                       // Make sure that others know the frame is deinterlaced
+                       mlt_properties_set_int( mlt_frame_properties( this ), "progressive", 1 );
+               }
+       }
+
+       return error;
 }
 
 /** Deinterlace filter processing - this should be lazy evaluation here...
@@ -104,14 +110,9 @@ static mlt_frame deinterlace_process( mlt_filter this, mlt_frame frame )
 
 mlt_filter filter_deinterlace_init( void *arg )
 {
-       filter_deinterlace *this = calloc( sizeof( filter_deinterlace ), 1 );
+       mlt_filter this = mlt_filter_new( );
        if ( this != NULL )
-       {
-               mlt_filter filter = &this->parent;
-               mlt_filter_init( filter, this );
-               filter->process = deinterlace_process;
-               return &this->parent;
-       }
-       return NULL;
+               this->process = deinterlace_process;
+       return this;
 }
 
index 338756161eb9b46c3522238f091bd7c893630558..213bc3adb72f1a9488ae08e32c114231f58a90a6 100644 (file)
 
 static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
 {
-       mlt_frame_get_image( this, image, format, width, height, 1 );
-       uint8_t *p = *image;
-       uint8_t *q = *image + *width * *height * 2;
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
 
-       // Get the gamma value
-       double gamma = mlt_properties_get_double( mlt_frame_properties( this ), "gamma" );
+       if ( error != 0 && *format == mlt_image_yuv422 )
+       {
+               // Get the gamma value
+               double gamma = mlt_properties_get_double( mlt_frame_properties( this ), "gamma" );
 
-       // Calculate the look up table
-       double exp = 1 / gamma;
-       uint8_t lookup[ 256 ];
-       int i;
+               if ( gamma != 1.0 )
+               {
+                       uint8_t *p = *image;
+                       uint8_t *q = *image + *width * *height * 2;
 
-       for( i = 0; i < 256; i ++ )
-               lookup[ i ] = ( uint8_t )( pow( ( double )i / 255.0, exp ) * 255 );
+                       // Calculate the look up table
+                       double exp = 1 / gamma;
+                       uint8_t lookup[ 256 ];
+                       int i;
 
-       while ( p != q )
-       {
-               *p = lookup[ *p ];
-               p += 2;
+                       for( i = 0; i < 256; i ++ )
+                               lookup[ i ] = ( uint8_t )( pow( ( double )i / 255.0, exp ) * 255 );
+
+                       while ( p != q )
+                       {
+                               *p = lookup[ *p ];
+                               p += 2;
+                       }
+               }
        }
 
        return 0;
@@ -61,9 +68,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 {
        double gamma = mlt_properties_get_double( mlt_filter_properties( this ), "gamma" );
-       gamma = gamma <= 0 ? 2 : gamma;
-       mlt_frame_push_get_image( frame, filter_get_image );
+       gamma = gamma <= 0 ? 1 : gamma;
        mlt_properties_set_double( mlt_frame_properties( frame ), "gamma", gamma );
+       mlt_frame_push_get_image( frame, filter_get_image );
        return frame;
 }
 
@@ -72,13 +79,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 
 mlt_filter filter_gamma_init( char *arg )
 {
-       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+       mlt_filter this = mlt_filter_new( );
        if ( this != NULL )
        {
-               mlt_filter_init( this, NULL );
                this->process = filter_process;
-               if ( arg != NULL )
-                       mlt_properties_set_double( mlt_filter_properties( this ), "gamma", atof( arg ) );
+               mlt_properties_set( mlt_filter_properties( this ), "gamma", arg == NULL ? "1" : arg );
        }
        return this;
 }
index 170ff4f543c82530d9fc85f0f6357839e1eb7ce0..8373161cecdfb4526af4d2dea0afec1bd6a667cc 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
-/** Greyscale class.
-*/
-
-typedef struct 
-{
-       struct mlt_filter_s parent;
-}
-filter_greyscale;
-
 /** Do it :-).
 */
 
 static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
 {
-       mlt_frame_get_image( this, image, format, width, height, 1 );
-       uint8_t *p = *image;
-       uint8_t *q = *image + *width * *height * 2;
-       while ( p ++ != q )
-               *p ++ = 128;
-       return 0;
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+       if ( error == 0 && *format == mlt_image_yuv422 )
+       {
+               uint8_t *p = *image;
+               uint8_t *q = *image + *width * *height * 2;
+               while ( p ++ != q )
+                       *p ++ = 128;
+       }
+       return error;
 }
 
 /** Filter processing.
@@ -61,13 +55,9 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 
 mlt_filter filter_greyscale_init( void *arg )
 {
-       filter_greyscale *this = calloc( sizeof( filter_greyscale ), 1 );
+       mlt_filter this = mlt_filter_new( );
        if ( this != NULL )
-       {
-               mlt_filter filter = &this->parent;
-               mlt_filter_init( filter, this );
-               filter->process = filter_process;
-       }
-       return ( mlt_filter )this;
+               this->process = filter_process;
+       return this;
 }
 
index 7324293fae67de7d09843ac0b47e48e4191ce2ef..b3c1622930306880bcd154e6fc2bff0790b9d3e8 100644 (file)
@@ -148,17 +148,18 @@ static float position_calculate( mlt_filter this, mlt_frame frame )
 /** The averaging function...
 */
 
-void obscure_average( uint8_t *start, int width, int height, int stride, uint8_t *alpha )
+void obscure_average( uint8_t *start, int width, int height, int stride )
 {
        int y;
        int x;
-       int Y = ( *start + *( start + 2 ) ) / 2;
-       int U = *( start + 1 );
-       int V = *( start + 3 );
+       register int Y = ( *start + *( start + 2 ) ) / 2;
+       register int U = *( start + 1 );
+       register int V = *( start + 3 );
+       register uint8_t *p;
 
        for ( y = 0; y < height; y ++ )
        {
-               uint8_t *p = start + y * stride;
+               p = start + y * stride;
                for ( x = 0; x < width / 2; x ++ )
                {
                        Y = ( Y + *p ++ ) / 2;
@@ -170,34 +171,14 @@ void obscure_average( uint8_t *start, int width, int height, int stride, uint8_t
 
        for ( y = 0; y < height; y ++ )
        {
-               uint8_t *p = start + y * stride;
-               uint8_t *z = alpha;
-               
-               if ( z != NULL )
-                       z += y * stride / 2;
+               p = start + y * stride;
                
                for ( x = 0; x < width / 2; x ++ )
                {
-                       if ( z == NULL || ( z != NULL && *z++ > 127 ) )
-                       {
-                               *p ++ = Y;
-                               *p ++ = U;
-                       }
-                       else
-                       {
-                               p += 2;
-                       }
-                               
-                       if ( z == NULL || ( z != NULL && *z++ > 127 ) )
-                       {
-                               
-                               *p ++ = Y;
-                               *p ++ = V;
-                       }
-                       else
-                       {
-                               p += 2;
-                       }
+                       *p ++ = Y;
+                       *p ++ = U;
+                       *p ++ = Y;
+                       *p ++ = V;
                }
        }
 }
@@ -206,7 +187,7 @@ void obscure_average( uint8_t *start, int width, int height, int stride, uint8_t
 /** The obscurer rendering function...
 */
 
-static void obscure_render( uint8_t *image, int width, int height, struct geometry_s result, uint8_t *alpha )
+static void obscure_render( uint8_t *image, int width, int height, struct geometry_s result )
 {
        int area_x = result.x;
        int area_y = result.y;
@@ -217,21 +198,19 @@ static void obscure_render( uint8_t *image, int width, int height, struct geomet
        int mh = result.mask_h;
        int w;
        int h;
+       int aw;
+       int ah;
 
        uint8_t *p = image + area_y * width * 2 + area_x * 2;
-       uint8_t *z = alpha;
-       if ( z != NULL )
-               z += area_y * width + area_x;
 
        for ( w = 0; w < area_w; w += mw )
        {
                for ( h = 0; h < area_h; h += mh )
                {
-                       int aw = w + mw > area_w ? mw - ( w + mw - area_w ) : mw;
-                       int ah = h + mh > area_h ? mh - ( h + mh - area_h ) : mh;
+                       aw = w + mw > area_w ? mw - ( w + mw - area_w ) : mw;
+                       ah = h + mh > area_h ? mh - ( h + mh - area_h ) : mh;
                        if ( aw > 1 && ah > 1 )
-                               obscure_average( p + h * width * 2 + w * 2, aw, ah, width * 2,
-                                       ( z == NULL ? z : z + h * width + w ) );
+                               obscure_average( p + h * width * 2 + w * 2, aw, ah, width * 2 );
                }
        }
 }
@@ -278,7 +257,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                        geometry_calculate( &result, &start, &end, position, *width, *height );
 
                        // Now actually render it
-                       obscure_render( *image, *width, *height, result, mlt_frame_get_alpha_mask( frame ) );
+                       obscure_render( *image, *width, *height, result );
                }
        }
 
@@ -320,12 +299,14 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 
 mlt_filter filter_obscure_init( void *arg )
 {
-       mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) );
-       mlt_properties properties = mlt_filter_properties( this );
-       mlt_filter_init( this, NULL );
-       this->process = filter_process;
-       mlt_properties_set( properties, "start", arg != NULL ? arg : "0%,0%:100%x100%" );
-       mlt_properties_set( properties, "end", "" );
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               mlt_properties properties = mlt_filter_properties( this );
+               this->process = filter_process;
+               mlt_properties_set( properties, "start", arg != NULL ? arg : "0%,0%:100%x100%" );
+               mlt_properties_set( properties, "end", "" );
+       }
        return this;
 }
 
index 7e7fac3a26c603441ac33abd443f30206afb059e..60a288722442761a7af180470eda655db3206ddb 100644 (file)
@@ -39,6 +39,8 @@ static int get_value( mlt_properties properties, char *preferred, char *fallback
 
 static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
 {
+       int error = 0;
+
        // Get the properties from the frame
        mlt_properties properties = mlt_frame_properties( this );
 
@@ -69,19 +71,6 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                        scaled_width = input_ar / output_ar * normalised_width;
                        scaled_height = normalised_height;
                }
-               //fprintf( stderr, "resize: %dx%d from %dx%d input aspect %f output aspect %f\n",
-               //      scaled_width, scaled_height, normalised_width, normalised_height, input_ar, output_ar );
-
-#if 0
-               int real_width = get_value( properties, "real_height", "height" );
-               int real_height = get_value( properties, "real_height", "height" );
-               // DRD> Why?
-               if ( ( real_height * 2 ) == normalised_height )
-               {
-                       scaled_width = normalised_width;
-                       scaled_height = normalised_height;
-               }
-#endif
        
                // Now calculate the actual image size that we want
                owidth = scaled_width * owidth / normalised_width;
@@ -96,38 +85,47 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        mlt_properties_set_int( properties, "resize_height", *height );
 
        // Now get the image
-       mlt_frame_get_image( this, image, format, &owidth, &oheight, writable );
-       
-       // Correct field order if needed
-       if ( mlt_properties_get_int( properties, "top_field_first" ) == 1 )
+       error = mlt_frame_get_image( this, image, format, &owidth, &oheight, writable );
+
+       // We only know how to process yuv422 at the moment
+       if ( error == 0 && *format == mlt_image_yuv422 )
        {
-               // Get the input image, width and height
-               int size;
-               uint8_t *image = mlt_properties_get_data( properties, "image", &size );
+               // Correct field order if needed
+               if ( mlt_properties_get_int( properties, "top_field_first" ) == 1 )
+               {
+                       // Get the input image, width and height
+                       int size;
+                       uint8_t *image = mlt_properties_get_data( properties, "image", &size );
 
-               // Keep the original image around to be destroyed on frame close
-               mlt_properties_rename( properties, "image", "original_image" );
+                       // Keep the original image around to be destroyed on frame close
+                       mlt_properties_rename( properties, "image", "original_image" );
 
-               // Offset the image pointer by one line
-               image += owidth * 2;
-               size -= owidth * 2;
+                       // Offset the image pointer by one line
+                       image += owidth * 2;
+                       size -= owidth * 2;
 
-               // Set the new image pointer with no destructor
-               mlt_properties_set_data( properties, "image", image, size, NULL, NULL );
+                       // Set the new image pointer with no destructor
+                       mlt_properties_set_data( properties, "image", image, size, NULL, NULL );
 
-               // Set the normalised field order
-               mlt_properties_set_int( properties, "top_field_first", 0 );
-       }
+                       // Set the normalised field order
+                       mlt_properties_set_int( properties, "top_field_first", 0 );
+               }
 
-       if ( !strcmp( mlt_properties_get( properties, "resize.scale" ), "affine" ) )
-               *image = mlt_frame_rescale_yuv422( this, *width, *height );
-       else if ( strcmp( mlt_properties_get( properties, "resize.scale" ), "none" ) != 0 )
-               *image = mlt_frame_resize_yuv422( this, *width, *height );
-       else
-       {
-               *width = owidth;
-               *height = oheight;
+               if ( !strcmp( mlt_properties_get( properties, "resize.scale" ), "affine" ) )
+               {
+                       *image = mlt_frame_rescale_yuv422( this, *width, *height );
+               }
+               else if ( strcmp( mlt_properties_get( properties, "resize.scale" ), "none" ) != 0 )
+               {
+                       *image = mlt_frame_resize_yuv422( this, *width, *height );
+               }
+               else
+               {
+                       *width = owidth;
+                       *height = oheight;
+               }
        }
+
        return 0;
 }
 
index 1499db1a1cc5381173df6e0ad4e765f7a978e0df..ad0c792f3cb8681b35d31228dbb8d015bd68d0fa 100644 (file)
@@ -360,13 +360,6 @@ static int get_b_frame_image( mlt_frame b_frame, uint8_t **image, int *width, in
                        scaled_height = normalised_height;
                }
 
-#if 0
-               // DRD> Why?
-               // Special case
-               if ( scaled_height == normalised_height )
-                       scaled_width = normalised_width;
-#endif
-
                // Now we need to align to the geometry
                if ( scaled_width <= geometry->w && scaled_height <= geometry->h )
                {
index 20ab7ea49d1bb2b626c7b75ec63cf85cd6694f53..31475127a8c8de688335b51551f22192de0a59b7 100644 (file)
@@ -132,6 +132,7 @@ mlt_producer producer_fezzik_init( char *arg )
                        mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL );
 
                        // Now attach normalising filters
+                       last = create_filter( tractor, last, "deinterlace" );
                        last = create_filter( tractor, last, "rescale" );
                        last = create_filter( tractor, last, "resize" );
                        last = create_filter( tractor, last, "resample" );
index b73d64b1e20c5b3093161110609642c0024b4703..7ee7b1cf5fe5c9b0871810cf089729b1541a6caa 100644 (file)
@@ -168,10 +168,7 @@ static void refresh_image( mlt_frame frame, int width, int height )
        double ttl = mlt_properties_get_int( producer_props, "ttl" );
 
        // Image index
-       int image_idx = ( int )floor( mlt_producer_position( producer ) / ttl ) % this->count;
-
-       // Update timecode on the frame we're creating
-       mlt_frame_set_position( frame, mlt_producer_position( producer ) );
+       int image_idx = ( int )floor( mlt_frame_get_position( frame ) / ttl ) % this->count;
 
     // optimization for subsequent iterations on single picture
        if ( width != 0 && this->image != NULL && image_idx == this->image_idx )
@@ -338,6 +335,9 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
        // Set the producer on the frame properties
        mlt_properties_set_data( properties, "producer_pixbuf", this, 0, NULL, NULL );
 
+       // Update timecode on the frame we're creating
+       mlt_frame_set_position( *frame, mlt_producer_position( producer ) );
+
        // Refresh the image
        refresh_image( *frame, 0, 0 );
 
index d35e4a7869f24346a6ed46883d13cbd5bb85aaa8..64cf9d9afb67e17b7e1e14fe48f29f426a345e1f 100644 (file)
@@ -103,7 +103,7 @@ mlt_consumer consumer_sdl_init( char *arg )
                mlt_properties_set( this->properties, "rescale", "nearest" );
 
                // Default progressive true
-               mlt_properties_set_int( this->properties, "progressive", 1 );
+               mlt_properties_set_int( this->properties, "progressive", 0 );
 
                // Get aspect ratio
                this->aspect_ratio = mlt_properties_get_double( this->properties, "aspect_ratio" );