]> git.sesse.net Git - mlt/commitdiff
Fix image format consistency and conversion.
authorDan Dennedy <dan@dennedy.org>
Tue, 15 Jun 2010 06:18:27 +0000 (23:18 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 24 Jan 2011 02:09:43 +0000 (18:09 -0800)
src/framework/mlt_consumer.c
src/framework/mlt_frame.c
src/framework/mlt_tractor.c
src/modules/core/filter_imageconvert.c
src/modules/sdl/consumer_sdl.c

index b6cc38630b6d4dabac84ef4d5b36ff3977c4c4d6..75ff93ab3ffa8e841199ec58dc3dc3080e08c427 100644 (file)
@@ -784,6 +784,7 @@ static void *consumer_worker_thread( void *arg )
        // Get the width and height
        int width = mlt_properties_get_int( properties, "width" );
        int height = mlt_properties_get_int( properties, "height" );
+       int format = this->format;
 
        // See if video is turned off
        int video_off = mlt_properties_get_int( properties, "video_off" );
@@ -807,7 +808,7 @@ static void *consumer_worker_thread( void *arg )
        uint8_t *image = NULL;
 
        if ( preview_off && preview_format != 0 )
-               this->format = preview_format;
+               format = preview_format;
 
        // Get the first frame from the work queue
        pthread_mutex_lock( &this->frame_queue_mutex );
@@ -821,7 +822,7 @@ static void *consumer_worker_thread( void *arg )
        if ( !video_off )
        {
                mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame, NULL );
-               mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 );
+               mlt_frame_get_image( frame, &image, &format, &width, &height, 0 );
        }
 
        if ( !audio_off )
@@ -873,7 +874,7 @@ static void *consumer_worker_thread( void *arg )
                if ( !video_off )
                {
                        mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame, NULL );
-                       mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 );
+                       mlt_frame_get_image( frame, &image, &format, &width, &height, 0 );
                }
                mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 );
 
index 76afc2208c806fab12a65cf05014a65c46d333ba..d048513ea47cd046d0a7b8d5c88590a8291d8c77 100644 (file)
@@ -391,9 +391,9 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
                {
                        mlt_properties_set_int( properties, "width", *width );
                        mlt_properties_set_int( properties, "height", *height );
-                       mlt_properties_set_int( properties, "format", *format );
-                       if ( this->convert_image )
+                       if ( this->convert_image && *buffer )
                                this->convert_image( this, buffer, format, requested_format );
+                       mlt_properties_set_int( properties, "format", *format );
                }
                else
                {
@@ -408,7 +408,10 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
                *width = mlt_properties_get_int( properties, "width" );
                *height = mlt_properties_get_int( properties, "height" );
                if ( this->convert_image && *buffer )
+               {
                        this->convert_image( this, buffer, format, requested_format );
+                       mlt_properties_set_int( properties, "format", *format );
+               }
        }
        else if ( producer )
        {
index 25bd0d320b69dafab0dc1aa5a5b4a09378aaf077..80f9430726a78d96146300620c4d57b76bb9f967 100644 (file)
@@ -285,6 +285,8 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma
        data = mlt_frame_get_alpha_mask( frame );
        mlt_properties_get_data( frame_properties, "alpha", &size );
        mlt_properties_set_data( properties, "alpha", data, size, NULL, NULL );
+       this->convert_image = frame->convert_image;
+       this->convert_audio = frame->convert_audio;
        return 0;
 }
 
index dd4a7ae7f145a48793a5b503d92379f14e9e3ca5..5c2ffdf6c46167dba3942c496001821a3e7bb9bd 100644 (file)
@@ -361,8 +361,6 @@ static int convert_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *f
                        error = 1;
                }
        }
-       if ( !error )
-               mlt_properties_set_int( properties, "format", *format );
 
        return error;
 }
index c11e7e18c8cf0ee2433f658c4e9d6ed85689d10d..9b24f86decdd6167b8d815ad4d4a205e3732cf83 100644 (file)
@@ -489,7 +489,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
        {
                // Get the image, width and height
                mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
-               mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "format", vfmt );
                
                void *pool = mlt_cocoa_autorelease_init();
 
@@ -648,7 +647,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                vfmt = preview_format == mlt_image_none ? mlt_image_rgb24a : preview_format;
                if ( !video_off )
                        mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
-               mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "format", vfmt );
                mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
        }