aspect_ratio = ( double )codec_context->width / ( double )codec_context->height;
mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio );
+ fprintf( stderr, "avformat: %dx%d (%f)\n", codec_context->width, codec_context->height, av_q2d( codec_context->sample_aspect_ratio ) );
// Now store the codec with its destructor
mlt_properties_set_data( properties, "video_codec", codec_context, 0, producer_codec_close, NULL );
mlt_frame_get_image( this, &input, format, &iwidth, &iheight, 0 );
+#if 0
// Determine maximum size within the aspect ratio:
double aspect_ratio = mlt_frame_get_aspect_ratio( this );
- float display_aspect_ratio = 4.0 / 3.0; // (float)iwidth / (float)iheight;
- if ( *width < *height * aspect_ratio )
- oheight = *width / aspect_ratio;
+ // TODO: these need to be provided
+ double dsar = oheight < 576 ? (8.0 / 9.0) : (48.0 / 45.0);
+ double ssar = iheight < 576 ? (8.0 / 9.0) : (48.0 / 45.0);
+
+ if ( ( (double) owidth * dsar / iwidth * ssar ) < ( (double) oheight / iheight ) )
+ oheight = (double) owidth * dsar / aspect_ratio;
else
- owidth = *height * aspect_ratio;
- if ( ( float )owidth * display_aspect_ratio < *width )
- owidth = ( int )( ( float )owidth * display_aspect_ratio );
- else if ( ( float )oheight * display_aspect_ratio < *height )
- oheight = ( int )( ( float )oheight * display_aspect_ratio );
+ owidth = (int)( ( aspect_ratio * oheight / dsar ) + 0.5 ) >> 1 << 1;
+
+ fprintf( stderr, "rescale: from %dx%d (%f) to %dx%d\n", iwidth, iheight, aspect_ratio, owidth, oheight );
+#endif
// If width and height are correct, don't do anything
if ( input != NULL && ( iwidth != owidth || iheight != oheight ) )
{
GdkPixbuf *temp = pixbuf;
GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf,
- (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 54.0/59.0),
+ (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 45.0/48.0),
gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER );
pixbuf = scaled;
g_object_unref( temp );
{
GdkPixbuf *temp = pixbuf;
GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf,
- (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 11.0/10.0 ),
+ (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 9.0/8.0 ),
gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER );
pixbuf = scaled;
g_object_unref( temp );
{
GdkPixbuf *temp = pixbuf;
GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf,
- (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 54.0/59.0),
+ (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 45.0/48.0),
gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER );
pixbuf = scaled;
g_object_unref( temp );
{
GdkPixbuf *temp = pixbuf;
GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf,
- (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 11.0/10.0 ),
+ (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 9.0/8.0 ),
gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER );
pixbuf = scaled;
g_object_unref( temp );