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
{
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
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
{
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 );
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 );
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 );
{
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 ) )
{
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 )
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;
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 );
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;
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" );
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" );
// 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 )
// 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;
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 );
// 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 );
// 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" ) )
// 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 );
// 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;
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 );
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;
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 );
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" ) )
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 );
}
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 )
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( );
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 );
{
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 );
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 );
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 );
}
}
- 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;
}
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;
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