double source_fps = 0;
// Set aspect ratio
- if ( codec_context->sample_aspect_ratio.num == 0)
+ if ( codec_context->sample_aspect_ratio.num == 0 )
aspect_ratio = 0;
else
aspect_ratio = av_q2d( codec_context->sample_aspect_ratio ) * codec_context->width / codec_context->height;
+ // XXX: This assumes square pixels!
if (aspect_ratio <= 0.0)
aspect_ratio = ( double )codec_context->width / ( double )codec_context->height;
mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio );
- fprintf( stderr, "AVFORMAT: sample aspect %f\n", aspect_ratio );
+ fprintf( stderr, "AVFORMAT: sample aspect %f computed display aspect %f\n", av_q2d( codec_context->sample_aspect_ratio ), aspect_ratio );
// Determine the fps
source_fps = ( double )codec_context->frame_rate / codec_context->frame_rate_base;
if ( mlt_properties_get( properties, "distort" ) == NULL )
{
- // Now do additional calcs based on real_width/height etc
+ // Normalise the input and out display aspect
int normalised_width = mlt_properties_get_int( properties, "normalised_width" );
int normalised_height = mlt_properties_get_int( properties, "normalised_height" );
- int real_width = get_value( properties, "real_width", "width" );
- int real_height = get_value( properties, "real_height", "height" );
double input_ar = mlt_frame_get_aspect_ratio( this );
double output_ar = mlt_properties_get_double( properties, "consumer_aspect_ratio" );
- int scaled_width = ( input_ar > output_ar ? input_ar / output_ar : output_ar / input_ar ) * real_width;
- int scaled_height = ( input_ar > output_ar ? input_ar / output_ar : output_ar / input_ar ) * real_height;
+
+ // Optimised for the input_ar > output_ar case (e.g. widescreen on standard)
+ int scaled_width = normalised_width;
+ int scaled_height = output_ar / input_ar * normalised_height;
// Now ensure that our images fit in the normalised frame
- if ( scaled_width > normalised_width )
- {
- scaled_height = scaled_height * normalised_width / scaled_width;
- scaled_width = normalised_width;
- }
if ( scaled_height > normalised_height )
{
- scaled_width = scaled_width * normalised_height / scaled_height;
+ scaled_width = input_ar / output_ar * normalised_width;
scaled_height = normalised_height;
}
+ //fprintf( stderr, "resize: %dx%d from %dx%d input aspect %f output aspect %f\n",
+ // scaled_width, scaled_height, normalised_width, normalised_height, input_ar, output_ar );
- if ( input_ar == output_ar && scaled_height == normalised_height )
- {
- scaled_width = normalised_width;
- }
- else if ( ( real_height * 2 ) == normalised_height )
+#if 0
+ int real_width = get_value( properties, "real_height", "height" );
+ int real_height = get_value( properties, "real_height", "height" );
+ // DRD> Why?
+ if ( ( real_height * 2 ) == normalised_height )
{
scaled_width = normalised_width;
scaled_height = normalised_height;
}
+#endif
// Now calculate the actual image size that we want
owidth = scaled_width * owidth / normalised_width;
oheight = scaled_height * oheight / normalised_height;
+
+ // Tell frame we have conformed the aspect to the consumer
+ mlt_frame_set_aspect_ratio( this, output_ar );
}
// Now pass on the calculations down the line
if ( mlt_properties_get( properties, "distort" ) == NULL )
{
- // Now do additional calcs based on real_width/height etc
+ // Adjust b_frame pixel aspect
int normalised_width = geometry->w;
int normalised_height = geometry->h;
- //int real_width = get_value( b_props, "real_width", "width" );
+ int real_width = get_value( b_props, "real_width", "width" );
int real_height = get_value( b_props, "real_height", "height" );
double input_ar = mlt_frame_get_aspect_ratio( b_frame );
double output_ar = mlt_properties_get_double( b_props, "consumer_aspect_ratio" );
//int scaled_width = ( input_ar > output_ar ? input_ar / output_ar : output_ar / input_ar ) * real_width;
//int scaled_height = ( input_ar > output_ar ? input_ar / output_ar : output_ar / input_ar ) * real_height;
- int scaled_width = ( float )geometry->nw / geometry->nh / output_ar * real_height * input_ar;
+ int scaled_width = real_width;
int scaled_height = real_height;
- //fprintf( stderr, "composite: real %dx%d scaled %dx%d normalised %dx%d\n", real_width, real_height, scaled_width, scaled_height, normalised_width, normalised_height );
+ double output_sar = ( double ) geometry->nw / geometry->nh / output_ar;
+
+ // We always normalise pixel aspect by requesting a larger than normal
+ // image in order to maximise usage of the bounding rectangle
+
+ // These calcs are optimised by reducing factors in equations
+ if ( output_sar < 1.0 )
+ // If the output is skinny pixels (PAL) then stretch our input vertically
+ // derived from: input_sar / output_sar * real_height
+ scaled_height = ( double )real_width / input_ar / output_sar;
+
+ else
+ // If the output is fat pixels (NTSC) then stretch our input horizontally
+ // derived from: output_sar / input_sar * real_width
+ scaled_width = output_sar * real_height * input_ar;
+
+// fprintf( stderr, "composite: real %dx%d scaled %dx%d normalised %dx%d\n", real_width, real_height, scaled_width, scaled_height, normalised_width, normalised_height );
// Now ensure that our images fit in the normalised frame
if ( scaled_width > normalised_width )
scaled_height = normalised_height;
}
+#if 0
+ // DRD> Why?
// Special case
if ( scaled_height == normalised_height )
scaled_width = normalised_width;
+#endif
// Now we need to align to the geometry
if ( scaled_width <= geometry->w && scaled_height <= geometry->h )
// Save the new scaled dimensions
geometry->sw = scaled_width;
geometry->sh = scaled_height;
-
- mlt_properties_set( b_props, "distort", "true" );
}
- else
- {
- mlt_properties_set( b_props, "distort", "true" );
- }
- }
- else
- {
- // We want to ensure that we bypass resize now...
- mlt_properties_set( b_props, "distort", "true" );
}
+ // We want to ensure that we bypass resize now...
+ mlt_properties_set( b_props, "distort", "true" );
+
// Take into consideration alignment for optimisation
alignment_calculate( geometry );
uint8_t y;
uint8_t uv;
- float value;
+ float value;
float x_diff = ( float )luma_width / ( float )*width;
float y_diff = ( float )luma_height / ( float )*height;
CFLAGS = -O3 -I .. -Wall -rdynamic -pthread
-LDFLAGS = -L ../framework -lmlt
+LDFLAGS = -L ../framework -L ../modules -lmlt -lmltdv -lmltsdl
ifeq ($(MLT_GPROF),true)
CFLAGS+=-p
#include <framework/mlt.h>
+#include "../modules/dv/producer_libdv.h"
+#include "../modules/dv/consumer_libdv.h"
+//#include "../modules/sdl/consumer_sdl.h"
#include <stdio.h>
char *file1 = NULL;
char *file2 = NULL;
- mlt_factory_init( "../modules" );
+// mlt_factory_init( "../modules" );
+ mlt_pool_init( );
if ( argc >= 2 )
file1 = argv[ 1 ];
// Start the consumer...
int vstd = mlt_video_standard_ntsc;
//mlt_consumer consumer = mlt_factory_consumer( "bluefish", &vstd );
- mlt_consumer consumer = mlt_factory_consumer( "westley", NULL );
+ //mlt_consumer consumer = mlt_factory_consumer( "sdl", NULL );
+ mlt_consumer consumer = consumer_libdv_init( NULL );
// Create the producer(s)
- mlt_producer dv1 = mlt_factory_producer( "westley", file1 );
+ //mlt_producer dv1 = mlt_factory_producer( "libdv", file1 );
+ mlt_producer dv1 = producer_libdv_init( file1 );
//mlt_producer_set_in_and_out( dv1, 0, 5 );
- mlt_producer dv2 = mlt_factory_producer( "libdv", file2 );
+ mlt_producer dv2;// = mlt_factory_producer( "libdv", file2 );
//mlt_producer_set_in_and_out( dv2, 10.0, 30.0 );
#if 1
// Do stuff until we're told otherwise...
mlt_consumer_start( consumer );
-// fprintf( stderr, "Press return to continue\n" );
-// fgets( temp, 132, stdin );
+ fprintf( stderr, "Press return to continue\n" );
+ fgets( temp, 132, stdin );
mlt_consumer_stop( consumer );
mlt_consumer_close( consumer );
+ mlt_pool_close( );
return 0;
#endif