From: lilo_booter Date: Wed, 27 Oct 2004 09:44:49 +0000 (+0000) Subject: Attempt at an aspect ratio clean up X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=59456c0f8d288d6bfa6df60d692b9209741ab02e;p=mlt Attempt at an aspect ratio clean up git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@492 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 268a5e60..ae79cf9d 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -55,7 +55,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 ); + mlt_properties_set_double( properties, "aspect_ratio", 59.0 / 54.0 ); } else { @@ -64,7 +64,7 @@ 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 ); + mlt_properties_set_double( properties, "aspect_ratio", 10.0 / 11.0 ); } // Default rescaler for all consumers diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index fe86d675..6e23964e 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -53,7 +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 ); + mlt_properties_set_double( properties, "aspect_ratio", 59.0/54.0 ); } else { @@ -61,7 +61,7 @@ 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", 10.0/11.0 ); } mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL ); diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index b1c42699..dab58445 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -78,12 +78,12 @@ int mlt_producer_init( mlt_producer this, void *child ) if ( normalisation == NULL || strcmp( normalisation, "NTSC" ) ) { mlt_properties_set_double( properties, "fps", 25.0 ); - mlt_properties_set_double( properties, "aspect_ratio", 72.0 / 79.0 ); + mlt_properties_set_double( properties, "aspect_ratio", 59.0 / 54.0 ); } else { mlt_properties_set_double( properties, "fps", 30000.0 / 1001.0 ); - mlt_properties_set_double( properties, "aspect_ratio", 128.0 / 117.0 ); + mlt_properties_set_double( properties, "aspect_ratio", 10.0 / 11.0 ); } mlt_properties_set_double( properties, "_speed", 1.0 ); mlt_properties_set_position( properties, "in", 0 ); diff --git a/src/framework/mlt_tractor.c b/src/framework/mlt_tractor.c index 2b7616c4..6ad86fcd 100644 --- a/src/framework/mlt_tractor.c +++ b/src/framework/mlt_tractor.c @@ -212,9 +212,10 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale.interp" ) ); if ( mlt_properties_get( properties, "distort" ) ) mlt_properties_set( frame_properties, "distort", mlt_properties_get( properties, "distort" ) ); - mlt_properties_set_double( frame_properties, "aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) ); mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "consumer_aspect_ratio" ) ); mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_double( properties, "consumer_deinterlace" ) ); + mlt_properties_set_int( frame_properties, "normalised_width", mlt_properties_get_double( properties, "normalised_width" ) ); + mlt_properties_set_int( frame_properties, "normalised_height", mlt_properties_get_double( properties, "normalised_height" ) ); mlt_frame_get_image( frame, buffer, format, width, height, writable ); mlt_properties_set_data( properties, "image", *buffer, *width * *height * 2, NULL, NULL ); mlt_properties_set_int( properties, "width", *width ); diff --git a/src/inigo/inigo.c b/src/inigo/inigo.c index bc4ad7c4..bc2f1560 100644 --- a/src/inigo/inigo.c +++ b/src/inigo/inigo.c @@ -145,7 +145,7 @@ static void transport( mlt_producer producer, mlt_consumer consumer ) { mlt_properties properties = mlt_producer_properties( producer ); int silent = mlt_properties_get_int( mlt_consumer_properties( consumer ), "silent" ); - + struct timespec tm = { 0, 40000 }; if ( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) ) { @@ -167,12 +167,16 @@ static void transport( mlt_producer producer, mlt_consumer consumer ) while( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) ) { - int value = term_read( ); + int value = silent ? -1 : term_read( ); + if ( value != -1 ) transport_action( producer, ( char * )&value ); if ( !silent && mlt_properties_get_int( properties, "stats_off" ) == 0 ) fprintf( stderr, "Current Position: %10d\r", mlt_producer_position( producer ) ); + + if ( silent ) + nanosleep( &tm, NULL ); } if ( !silent ) diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c index 318aec6b..9b431259 100644 --- a/src/modules/avformat/consumer_avformat.c +++ b/src/modules/avformat/consumer_avformat.c @@ -853,6 +853,14 @@ static void *consumer_thread( void *arg ) uint8_t *q; mlt_events_fire( properties, "consumer-frame-show", frame, NULL ); + + // This will cause some fx to go awry.... + if ( mlt_properties_get_int( properties, "transcode" ) ) + { + mlt_properties_set_int( mlt_frame_properties( frame ), "normalised_width", img_height * 4.0 / 3.0 ); + mlt_properties_set_int( mlt_frame_properties( frame ), "normalised_height", img_height ); + } + mlt_frame_get_image( frame, &image, &img_fmt, &img_width, &img_height, 0 ); q = image; diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index 85ee4a5a..1cebb3f3 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -691,7 +691,7 @@ static void producer_set_up_video( mlt_producer this, mlt_frame frame ) else { int is_pal = mlt_properties_get_double( properties, "fps" ) == 25.0; - mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 128.0/117.0 : 72.0/79.0 ); + mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); } //fprintf( stderr, "AVFORMAT: sample aspect %f %dx%d\n", av_q2d( codec_context->sample_aspect_ratio ), codec_context->width, codec_context->height ); diff --git a/src/modules/core/filter_resize.c b/src/modules/core/filter_resize.c index dcaa2d01..627d9e0b 100644 --- a/src/modules/core/filter_resize.c +++ b/src/modules/core/filter_resize.c @@ -62,6 +62,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * 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; + //fprintf( stderr, "normalised %dx%d output %dx%d %f %f\n", normalised_width, normalised_height, owidth, oheight, ( float )output_ar, ( float )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 = input_ar / output_ar * normalised_width + 0.5; int scaled_height = normalised_height; diff --git a/src/modules/core/filter_watermark.c b/src/modules/core/filter_watermark.c index 9f6b64d3..aee35ed3 100644 --- a/src/modules/core/filter_watermark.c +++ b/src/modules/core/filter_watermark.c @@ -144,6 +144,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); mlt_properties_set_int( b_props, "consumer_deinterlace", mlt_properties_get_double( a_props, "consumer_deinterlace" ) ); + mlt_properties_set_int( b_props, "normalised_width", mlt_properties_get_int( a_props, "normalised_width" ) ); + mlt_properties_set_int( b_props, "normalised_height", mlt_properties_get_int( a_props, "normalised_height" ) ); + if ( mlt_properties_get_int( properties, "distort" ) ) { mlt_properties_set( mlt_transition_properties( composite ), "distort", "true" ); @@ -168,6 +171,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format int count = 0; uint8_t *alpha = NULL; mlt_transition_process( composite, b_frame, frame ); + mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_int( a_props, "consumer_aspect_ratio" ) ); mlt_properties_set_int( a_props, "consumer_deinterlace", 1 ); mlt_properties_set_int( b_props, "consumer_deinterlace", 1 ); mlt_properties_set( a_props, "rescale.interp", "nearest" ); diff --git a/src/modules/core/producer_colour.c b/src/modules/core/producer_colour.c index 2cc67790..b4e8da83 100644 --- a/src/modules/core/producer_colour.c +++ b/src/modules/core/producer_colour.c @@ -199,7 +199,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", is_pal ? 128.0/117.0 : 72.0/79.0 ); + mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); // colour is an alias for resource if ( mlt_properties_get( producer_props, "colour" ) != NULL ) diff --git a/src/modules/core/producer_noise.c b/src/modules/core/producer_noise.c index 54d0474d..435e7e68 100644 --- a/src/modules/core/producer_noise.c +++ b/src/modules/core/producer_noise.c @@ -55,8 +55,10 @@ mlt_producer producer_noise_init( void *arg ) // Initialise the producer if ( this != NULL ) { + int is_pal = mlt_properties_get_int( mlt_producer_properties( this ), "normalised_height" ) == 576; + // Synthetic - aspect ratio of 1 - mlt_properties_set_double( mlt_producer_properties( this ), "aspect_ratio", 1 ); + mlt_properties_set_double( mlt_producer_properties( this ), "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); // Callback registration this->get_frame = producer_get_frame; @@ -156,7 +158,7 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index int is_pal = mlt_properties_get_double( producer_props, "fps" ) == 25.0; // Aspect ratio is 1? - mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 128.0/117.0 : 72.0/79.0 ); + mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); // Set producer-specific frame properties mlt_properties_set_int( properties, "progressive", 1 ); diff --git a/src/modules/core/transition_composite.c b/src/modules/core/transition_composite.c index 88d6b57c..e03e69b1 100644 --- a/src/modules/core/transition_composite.c +++ b/src/modules/core/transition_composite.c @@ -866,13 +866,13 @@ static struct geometry_s *composite_calculate( struct geometry_s *result, mlt_tr // Structures for geometry struct geometry_s *start = mlt_properties_get_data( properties, "geometries", NULL ); + // Obtain the normalised width and height from the a_frame + int normalised_width = mlt_properties_get_int( a_props, "normalised_width" ); + int normalised_height = mlt_properties_get_int( a_props, "normalised_height" ); + // Now parse the geometries - if ( start == NULL || mlt_properties_get_int( properties, "refresh" ) ) + if ( start == NULL || mlt_properties_get_int( properties, "refresh" ) || start->nw != normalised_width || start->nh != normalised_height ) { - // Obtain the normalised width and height from the a_frame - int normalised_width = mlt_properties_get_int( a_props, "normalised_width" ); - int normalised_height = mlt_properties_get_int( a_props, "normalised_height" ); - // Parse the transitions properties start = transition_parse_keys( this, normalised_width, normalised_height ); @@ -1051,6 +1051,8 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f // consumer properties from the a_frame mlt_properties_set_double( b_props, "consumer_deinterlace", mlt_properties_get_double( a_props, "consumer_deinterlace" ) ); mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); + mlt_properties_set_int( b_props, "normalised_width", mlt_properties_get_double( a_props, "normalised_width" ) ); + mlt_properties_set_int( b_props, "normalised_height", mlt_properties_get_double( a_props, "normalised_height" ) ); // Special case for titling... if ( mlt_properties_get_int( properties, "titles" ) ) diff --git a/src/modules/gtk2/producer_pixbuf.c b/src/modules/gtk2/producer_pixbuf.c index 10b5b8bb..4cd7a4cd 100644 --- a/src/modules/gtk2/producer_pixbuf.c +++ b/src/modules/gtk2/producer_pixbuf.c @@ -374,6 +374,9 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Obtain properties of frame and producer mlt_properties properties = mlt_frame_properties( *frame ); + // Determine if we're rendering for PAL or NTSC + int is_pal = mlt_properties_get_int( properties, "normalised_height" ) == 576; + // Set the producer on the frame properties mlt_properties_set_data( properties, "producer_pixbuf", this, 0, NULL, NULL ); @@ -388,7 +391,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", 1 ); + mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); // Set alpha call back ( *frame )->get_alpha_mask = producer_get_alpha_mask; diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 58741522..b707f786 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -386,7 +386,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) SDL_Event event; changed = consumer_get_dimensions( &this->window_width, &this->window_height ); - + while ( SDL_PollEvent( &event ) ) { mlt_events_fire( this->properties, "consumer-sdl-event", &event, NULL ); @@ -420,7 +420,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) if ( width != this->width || height != this->height || ( ( int )( this->last_frame_aspect * 1000 ) != ( int )( mlt_frame_get_aspect_ratio( frame ) * 1000 ) && ( mlt_frame_get_aspect_ratio( frame ) != 1.0 || this->last_frame_aspect == 0.0 ) ) ) - { this->width = width; this->height = height; @@ -430,12 +429,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) if ( this->running && ( this->sdl_screen == NULL || changed ) ) { - // Determine frame's display aspect ratio - float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * this->width / this->height; - - // Determine window's new display aspect ratio - float this_aspect = ( float )this->window_width / this->window_height; - // Force an overlay recreation if ( this->sdl_overlay != NULL ) SDL_FreeYUVOverlay( this->sdl_overlay ); @@ -446,9 +439,17 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) sdl_unlock_display(); if ( consumer_get_dimensions( &this->window_width, &this->window_height ) ) this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags ); - SDL_Flip( this->sdl_screen ); + //SDL_Flip( this->sdl_screen ); mlt_properties_set_int( properties, "changed", 0 ); - + + // Determine window's new display aspect ratio + float this_aspect = ( float )this->window_width / this->window_height; + + // Determine frame's display aspect ratio + float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * width / height; + this->width = width; + this->height = height; + // If using hardware scaler if ( mlt_properties_get( properties, "rescale" ) != NULL && !strcmp( mlt_properties_get( properties, "rescale" ), "none" ) ) @@ -508,13 +509,12 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) sdl_unlock_display(); } } - - if ( mlt_properties_get_int( properties, "changed" ) ) + else if ( mlt_properties_get_int( properties, "changed" ) ) { sdl_lock_display(); this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags ); SDL_SetClipRect( this->sdl_screen, &this->rect ); - SDL_Flip( this->sdl_screen ); + //SDL_Flip( this->sdl_screen ); sdl_unlock_display(); mlt_properties_set_int( properties, "changed", 0 ); } @@ -658,7 +658,8 @@ static void *consumer_thread( void *arg ) consumer_get_dimensions( &this->window_width, &this->window_height ); } - SDL_InitSubSystem( SDL_INIT_AUDIO ); + if ( !mlt_properties_get_int( mlt_consumer_properties( consumer ), "audio_off" ) ) + SDL_InitSubSystem( SDL_INIT_AUDIO ); // Loop until told not to while( this->running ) @@ -715,7 +716,8 @@ static void *consumer_thread( void *arg ) if ( this->sdl_overlay != NULL ) SDL_FreeYUVOverlay( this->sdl_overlay ); - SDL_QuitSubSystem( SDL_INIT_AUDIO ); + if ( !mlt_properties_get_int( mlt_consumer_properties( consumer ), "audio_off" ) ) + SDL_QuitSubSystem( SDL_INIT_AUDIO ); if ( mlt_properties_get_int( mlt_consumer_properties( consumer ), "sdl_started" ) == 0 ) SDL_Quit( ); diff --git a/src/modules/sdl/consumer_sdl_preview.c b/src/modules/sdl/consumer_sdl_preview.c index 8bf9e7c7..4b7e1169 100644 --- a/src/modules/sdl/consumer_sdl_preview.c +++ b/src/modules/sdl/consumer_sdl_preview.c @@ -204,6 +204,9 @@ static void *consumer_thread( void *arg ) mlt_properties_set_data( play, "app_unlock", mlt_properties_get_data( properties, "app_unlock", NULL ), 0, NULL, NULL ); mlt_properties_set_data( still, "app_unlock", mlt_properties_get_data( properties, "app_unlock", NULL ), 0, NULL, NULL ); + mlt_properties_set_int( play, "progressive", 1 ); + mlt_properties_set_int( still, "progressive", 1 ); + mlt_properties_set_int( play, "put_mode", 1 ); mlt_properties_set_int( still, "put_mode", 1 ); @@ -259,7 +262,6 @@ static void *consumer_thread( void *arg ) { this->last_speed = use_speed; this->active = this->still; - this->ignore_change = 5; mlt_consumer_start( this->still ); } mlt_properties_set_int( still, "changed", changed ); diff --git a/src/modules/sdl/consumer_sdl_still.c b/src/modules/sdl/consumer_sdl_still.c index dc0c79e6..3cf9d097 100644 --- a/src/modules/sdl/consumer_sdl_still.c +++ b/src/modules/sdl/consumer_sdl_still.c @@ -176,6 +176,8 @@ static int consumer_start( mlt_consumer parent ) mlt_properties_set_int( this->properties, "height", this->height ); } + //this->width = this->height * this->display_aspect; + // Inherit the scheduling priority pthread_attr_init( &thread_attributes ); pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); @@ -228,8 +230,9 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) mlt_properties properties = this->properties; mlt_image_format vfmt = mlt_image_rgb24; - int width = this->width, height = this->height; - uint8_t *image; + int height = this->height; + int width = this->width; + uint8_t *image = NULL; int changed = 0; void ( *lock )( void ) = mlt_properties_get_data( properties, "app_lock", NULL ); @@ -276,13 +279,9 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) } } - if ( width != this->width || height != this->height || - ( ( int )( this->last_frame_aspect * 1000 ) != ( int )( mlt_frame_get_aspect_ratio( frame ) * 1000 ) && + if ( ( ( int )( this->last_frame_aspect * 1000 ) != ( int )( mlt_frame_get_aspect_ratio( frame ) * 1000 ) && ( mlt_frame_get_aspect_ratio( frame ) != 1.0 || this->last_frame_aspect == 0.0 ) ) ) - { - this->width = width; - this->height = height; this->last_frame_aspect = mlt_frame_get_aspect_ratio( frame ); changed = 1; } @@ -293,58 +292,25 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 16, this->sdl_flags ); if ( consumer_get_dimensions( &this->window_width, &this->window_height ) ) this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 16, this->sdl_flags ); + changed = 1; mlt_properties_set_int( properties, "changed", 0 ); - // Determine frame's display aspect ratio - float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * this->width / this->height; - + // May as well use the mlt rescaler... + //if ( mlt_properties_get( properties, "rescale" ) != NULL && !strcmp( mlt_properties_get( properties, "rescale" ), "none" ) ) + //mlt_properties_set( properties, "rescale", "nearest" ); + // Determine window's new display aspect ratio - float this_aspect = ( float )this->window_width / this->window_height; + float this_aspect = this->display_aspect / ( ( float )this->window_width / ( float )this->window_height ); - // If using hardware scaler - if ( mlt_properties_get( properties, "rescale" ) != NULL && - !strcmp( mlt_properties_get( properties, "rescale" ), "none" ) ) - { - // Special case optimisation to negate odd effect of sample aspect ratio - // not corresponding exactly with image resolution. - if ( ( (int)( this_aspect * 1000 ) == (int)( this->display_aspect * 1000 ) ) && - ( (int)( mlt_frame_get_aspect_ratio( frame ) * 1000 ) == (int)( this->aspect_ratio * 1000 ) ) ) - { - this->rect.w = this->window_width; - this->rect.h = this->window_height; - } - else - { - // Use hardware scaler to normalise display aspect ratio - this->rect.w = frame_aspect / this_aspect * this->window_width; - this->rect.h = this->window_height; - if ( this->rect.w > this->window_width ) - { - this->rect.w = this->window_width; - this->rect.h = this_aspect / frame_aspect * this->window_height; - } - } - } - // Special case optimisation to negate odd effect of sample aspect ratio - // not corresponding exactly with image resolution. - else if ( (int)( this_aspect * 1000 ) == (int)( this->display_aspect * 1000 ) ) - { - this->rect.w = this->window_width; - this->rect.h = this->window_height; - } - // Use hardware scaler to normalise sample aspect ratio - else if ( this->window_height * this->display_aspect > this->window_width ) + this->rect.w = this_aspect * this->window_width; + this->rect.h = this->window_height; + if ( this->rect.w > this->window_width ) { this->rect.w = this->window_width; - this->rect.h = this->window_width / this->display_aspect; - } - else - { - this->rect.w = this->window_height * this->display_aspect; - this->rect.h = this->window_height; + this->rect.h = ( 1.0 / this_aspect ) * this->window_height; } - + this->rect.x = ( this->window_width - this->rect.w ) / 2; this->rect.y = ( this->window_height - this->rect.h ) / 2; @@ -374,9 +340,21 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) this->last_producer = mlt_properties_get_data( mlt_frame_properties( frame ), "_producer", NULL ); // Get the image, width and height - mlt_events_fire( properties, "consumer-frame-show", frame, NULL ); - mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 ); - + if ( image == NULL ) + { + mlt_events_fire( properties, "consumer-frame-show", frame, NULL ); + + // I would like to provide upstream scaling here, but this is incorrect + // Something? (or everything?) is too sensitive to aspect ratio + //width = this->rect.w; + //height = this->rect.h; + //mlt_properties_set( mlt_frame_properties( frame ), "distort", "true" ); + //mlt_properties_set_int( mlt_frame_properties( frame ), "normalised_width", width ); + //mlt_properties_set_int( mlt_frame_properties( frame ), "normalised_height", height ); + + mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 ); + } + if ( this->sdl_screen != NULL ) { // Calculate the scan length