return consumer;
}
+static void recompute_aspect_ratio( mlt_properties properties )
+{
+ double ar = mlt_properties_get_double( properties, "aspect" );
+ AVRational rational = av_d2q( ar, 255 );
+ int width = mlt_properties_get_int( properties, "width" );
+ int height = mlt_properties_get_int( properties, "height" );
+
+ // Update the profile and properties as well since this is an alias
+ // for mlt properties that correspond to profile settings
+ mlt_properties_set_int( properties, "display_aspect_num", rational.num );
+ mlt_properties_set_int( properties, "display_aspect_den", rational.den );
+
+ // Now compute the sample aspect ratio
+ rational = av_d2q( ar * height / FFMAX(width, 1), 255 );
+
+ // Update the profile and properties as well since this is an alias
+ // for mlt properties that correspond to profile settings
+ mlt_properties_set_int( properties, "sample_aspect_num", rational.num );
+ mlt_properties_set_int( properties, "sample_aspect_den", rational.den );
+}
+
static void property_changed( mlt_properties owner, mlt_consumer self, char *name )
{
mlt_properties properties = MLT_CONSUMER_PROPERTIES( self );
height = ( height / 2 ) * 2;
mlt_properties_set_int( properties, "width", width );
mlt_properties_set_int( properties, "height", height );
+ recompute_aspect_ratio( properties );
}
// "-aspect" on ffmpeg command line is display aspect ratio
- else if ( !strcmp( name, "aspect" ) )
+ else if ( !strcmp( name, "aspect" ) || !strcmp( name, "width" ) || !strcmp( name, "height" ) )
{
- double ar = mlt_properties_get_double( properties, "aspect" );
- AVRational rational = av_d2q( ar, 255 );
- int width = mlt_properties_get_int( properties, "width" );
- int height = mlt_properties_get_int( properties, "height" );
-
- // Update the profile and properties as well since this is an alias
- // for mlt properties that correspond to profile settings
- mlt_properties_set_int( properties, "display_aspect_num", rational.num );
- mlt_properties_set_int( properties, "display_aspect_den", rational.den );
-
- // Now compute the sample aspect ratio
- rational = av_d2q( ar * height / FFMAX(width, 1), 255 );
-
- // Update the profile and properties as well since this is an alias
- // for mlt properties that correspond to profile settings
- mlt_properties_set_int( properties, "sample_aspect_num", rational.num );
- mlt_properties_set_int( properties, "sample_aspect_den", rational.den );
+ recompute_aspect_ratio( properties );
}
// Handle the ffmpeg command line "-r" property for frame rate
else if ( !strcmp( name, "r" ) )