$Id$
+USING svn log NOW
+
2007-04-09 Dan Dennedy <dan@dennedy.org>
Cleanup copyrights and attributions, and move Jean-Baptiste's services
to a new kdenlive module.
src/miracle \
src/humperdink \
src/albino \
- src/modules
+ src/modules \
+ profiles
all clean:
list='$(SUBDIRS)'; \
dist:
[ -d "mlt-$(version)" ] && rm -rf "mlt-$(version)" || echo
svn export . "mlt-$(version)"
+ svn log > "mlt-$(version)/ChangeLog"
tar -cvzf "mlt-$(version).tar.gz" "mlt-$(version)"
export prefix=/usr/local
export libdir=""
export help=0
-export version=0.2.3
+export version=0.2.4
export debug=true
export mmx=true
export gpl=false
--- /dev/null
+include ../config.mak
+
+all:
+
+depend:
+
+distclean:
+
+clean:
+
+install: all
+ install -d $(DESTDIR)$(prefix)/share/mlt/profiles
+ install -m 644 * $(DESTDIR)$(prefix)/share/mlt/profiles
+ rm -f $(DESTDIR)$(prefix)/share/mlt/profiles/{*~,Makefile}
--- /dev/null
+name=ATSC Widescreen 1080i
+frame_rate_num=30000
+frame_rate_den=1001
+width=1920
+height=1080
+progressive=0
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=ATSC Widescreen 720p
+frame_rate_num=30000
+frame_rate_den=1001
+width=1280
+height=720
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=CIF NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=352
+height=288
+progressive=1
+sample_aspect_num=10
+sample_aspect_den=11
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=CIF PAL
+frame_rate_num=25
+frame_rate_den=1
+width=352
+height=288
+progressive=1
+sample_aspect_num=59
+sample_aspect_den=54
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=CVD NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=352
+height=480
+progressive=0
+sample_aspect_num=20
+sample_aspect_den=11
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=CVD PAL
+frame_rate_num=25
+frame_rate_den=1
+width=352
+height=576
+progressive=0
+sample_aspect_num=59
+sample_aspect_den=27
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=DV NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=720
+height=480
+progressive=0
+sample_aspect_num=10
+sample_aspect_den=11
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=DV NTSC Widescreen
+frame_rate_num=30000
+frame_rate_den=1001
+width=720
+height=480
+progressive=0
+sample_aspect_num=40
+sample_aspect_den=33
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=DV PAL
+frame_rate_num=25
+frame_rate_den=1
+width=720
+height=576
+progressive=0
+sample_aspect_num=59
+sample_aspect_den=54
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=DV PAL Widescreen
+frame_rate_num=25
+frame_rate_den=1
+width=720
+height=576
+progressive=0
+sample_aspect_num=118
+sample_aspect_den=81
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=HDV 1080i NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=1440
+height=1080
+progressive=0
+sample_aspect_num=4
+sample_aspect_den=3
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=HDV 1080i PAL
+frame_rate_num=25
+frame_rate_den=1
+width=1440
+height=1080
+progressive=0
+sample_aspect_num=4
+sample_aspect_den=3
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=HDV 720p NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=1280
+height=720
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=HDV 720p PAL
+frame_rate_num=25
+frame_rate_den=1
+width=1280
+height=720
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=QCIF NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=176
+height=144
+progressive=1
+sample_aspect_num=10
+sample_aspect_den=11
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=QCIF PAL
+frame_rate_num=25
+frame_rate_den=1
+width=176
+height=144
+progressive=1
+sample_aspect_num=59
+sample_aspect_den=54
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=Quarter Square NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=320
+height=240
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=Quarter Square NTSC Widescreen
+frame_rate_num=30000
+frame_rate_den=1001
+width=426
+height=240
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=Quarter Square PAL
+frame_rate_num=25
+frame_rate_den=1
+width=384
+height=288
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=Quarter Square PAL Widescreen
+frame_rate_num=25
+frame_rate_den=1
+width=512
+height=288
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=Square NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=640
+height=480
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=Square NTSC Widescreen
+frame_rate_num=30000
+frame_rate_den=1001
+width=854
+height=480
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=Square PAL
+frame_rate_num=25
+frame_rate_den=1
+width=768
+height=576
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=Square PAL Widescreen
+frame_rate_num=25
+frame_rate_den=1
+width=1024
+height=576
+progressive=1
+sample_aspect_num=1
+sample_aspect_den=1
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=SVCD NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=480
+height=480
+progressive=0
+sample_aspect_num=15
+sample_aspect_den=11
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=SVCD NTSC Widescreen
+frame_rate_num=30000
+frame_rate_den=1001
+width=480
+height=480
+progressive=0
+sample_aspect_num=20
+sample_aspect_den=11
+display_aspect_num=16
+display_aspect_den=9
--- /dev/null
+name=SVCD PAL
+frame_rate_num=25
+frame_rate_den=1
+width=480
+height=576
+progressive=0
+sample_aspect_num=59
+sample_aspect_den=36
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=SVCD PAL Widescreen
+frame_rate_num=25
+frame_rate_den=1
+width=480
+height=576
+progressive=0
+sample_aspect_num=59
+sample_aspect_den=27
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=VCD NTSC
+frame_rate_num=30000
+frame_rate_den=1001
+width=352
+height=240
+progressive=1
+sample_aspect_num=10
+sample_aspect_den=11
+display_aspect_num=4
+display_aspect_den=3
--- /dev/null
+name=VCD PAL
+frame_rate_num=25
+frame_rate_den=1
+width=352
+height=288
+progressive=1
+sample_aspect_num=59
+sample_aspect_den=54
+display_aspect_num=4
+display_aspect_den=3
mlt_factory.o \
mlt_repository.o \
mlt_pool.o \
- mlt_tokeniser.o
+ mlt_tokeniser.o \
+ mlt_profile.o
INCS = mlt_consumer.h \
mlt_factory.h \
mlt_property.h \
mlt_service.h \
mlt_transition.h \
- mlt_tokeniser.h
+ mlt_tokeniser.h \
+ mlt_profile.h
SRCS := $(OBJS:.o=.c)
#include "mlt_tokeniser.h"
#include "mlt_parser.h"
#include "mlt_geometry.h"
+#include "mlt_profile.h"
#ifdef __cplusplus
}
#include "mlt_factory.h"
#include "mlt_producer.h"
#include "mlt_frame.h"
+#include "mlt_profile.h"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service this, void **args );
static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args );
+static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name );
+static void apply_profile_properties( mlt_profile profile, mlt_properties properties );
+
+static mlt_event g_event_listener = NULL;
/** Public final methods
*/
{
// Get the properties from the service
mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent );
-
- // Get the normalisation preference
- char *normalisation = mlt_environment( "MLT_NORMALISATION" );
-
- // Deal with normalisation
- if ( normalisation == NULL || strcmp( normalisation, "NTSC" ) )
- {
- mlt_properties_set( properties, "normalisation", "PAL" );
- mlt_properties_set_double( properties, "fps", 25.0 );
- mlt_properties_set_int( properties, "frame_rate_num", 25 );
- mlt_properties_set_int( properties, "frame_rate_den", 1 );
- 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", 59.0 / 54.0 );
- mlt_properties_set_int( properties, "aspect_ratio_num", 59 );
- mlt_properties_set_int( properties, "aspect_ratio_den", 54 );
- mlt_properties_set_double( properties, "display_ratio", 4.0 / 3.0 );
- mlt_properties_set_int( properties, "display_ratio_num", 4 );
- mlt_properties_set_int( properties, "display_ratio_den", 3 );
- }
- else
- {
- mlt_properties_set( properties, "normalisation", "NTSC" );
- mlt_properties_set_double( properties, "fps", 30000.0 / 1001.0 );
- mlt_properties_set_int( properties, "frame_rate_num", 30000 );
- mlt_properties_set_int( properties, "frame_rate_den", 1001 );
- 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", 10.0 / 11.0 );
- mlt_properties_set_int( properties, "aspect_ratio_num", 10 );
- mlt_properties_set_int( properties, "aspect_ratio_den", 11 );
- mlt_properties_set_double( properties, "display_ratio", 4.0 / 3.0 );
- mlt_properties_set_int( properties, "display_ratio_num", 4 );
- mlt_properties_set_int( properties, "display_ratio_den", 3 );
- }
+
+ // Apply the profile to properties for legacy integration
+ apply_profile_properties( mlt_profile_get(), properties );
// Default rescaler for all consumers
mlt_properties_set( properties, "rescale", "bilinear" );
mlt_events_register( properties, "consumer-frame-render", ( mlt_transmitter )mlt_consumer_frame_render );
mlt_events_register( properties, "consumer-stopped", NULL );
+ // Register a property-changed listener to handle the profile property -
+ // subsequent properties can override the profile
+ g_event_listener = mlt_events_listen( properties, this, "property-changed", ( mlt_listener )mlt_consumer_property_changed );
+
// Create the push mutex and condition
pthread_mutex_init( &this->put_mutex, NULL );
pthread_cond_init( &this->put_cond, NULL );
return error;
}
+static void apply_profile_properties( mlt_profile profile, mlt_properties properties )
+{
+ mlt_properties_set_double( properties, "fps", mlt_profile_fps( profile ) );
+ mlt_properties_set_int( properties, "frame_rate_num", profile->frame_rate_num );
+ mlt_properties_set_int( properties, "frame_rate_den", profile->frame_rate_den );
+ mlt_properties_set_int( properties, "width", profile->width );
+ mlt_properties_set_int( properties, "height", profile->height );
+ mlt_properties_set_int( properties, "progressive", profile->progressive );
+ mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( profile ) );
+ mlt_properties_set_int( properties, "sample_aspect_num", profile->sample_aspect_num );
+ mlt_properties_set_int( properties, "sample_aspect_den", profile->sample_aspect_den );
+ mlt_properties_set_double( properties, "display_ratio", mlt_profile_dar( profile ) );
+ mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num );
+ mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num );
+}
+
+static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name )
+{
+ if ( !strcmp( name, "profile" ) )
+ {
+ // Get the properies
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+
+ // Locate the profile
+ mlt_profile_select( mlt_properties_get( properties, "profile" ) );
+
+ // Stop listening to this
+ mlt_event_close( g_event_listener );
+ g_event_listener = NULL;
+
+ // Apply to properties
+ apply_profile_properties( mlt_profile_get(), properties );
+ }
+}
+
static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args )
{
if ( listener != NULL )
// Determine if there's a test card producer
char *test_card = mlt_properties_get( properties, "test_card" );
- // Handle profiles
- char *profile = mlt_properties_get( properties, "profile" );
- int profile_ok = mlt_consumer_profile( properties, profile );
-
- // Check that everything is OK
- if ( !profile_ok )
- fprintf( stderr, "Unrecognised profile %s - continuing with defaults.\n", mlt_properties_get( properties, "profile" ) );
- else if ( profile_ok < 0 )
- fprintf( stderr, "Recognised profile %s with warnings - trying to continue with some defaults.\n", mlt_properties_get( properties, "profile" ) );
-
// Just to make sure nothing is hanging around...
mlt_frame_close( this->put );
this->put = NULL;
int mlt_consumer_profile( mlt_properties properties, char *profile )
{
- double fps = mlt_properties_get_double( properties, "fps" );
- int recognised = 1;
- double display_num = 0;
- double display_den = 0;
- double pixel_num = 0;
- double pixel_den = 0;
- int width = 0;
- int height = 0;
-
- if ( fps == 25.0 && profile != NULL )
- {
- width = 720;
- height = 576;
- display_num = 4;
- display_den = 3;
- pixel_num = 59;
- pixel_den = 54;
-
- if ( !strcmp( profile, "dv_wide" ) )
- {
- display_num = 16;
- display_den = 9;
- pixel_num = 118;
- pixel_den = 81;
- }
- else if ( !strncmp( profile, "square_wide", 11 ) )
- {
- display_num = 16;
- display_den = 9;
- pixel_num = 1;
- pixel_den = 1;
- width = 1024;
- height = 576;
- }
- else if ( !strncmp( profile, "square", 6 ) )
- {
- pixel_num = 1;
- pixel_den = 1;
- width = 768;
- height = 576;
- }
- else if ( !strncmp( profile, "vcd", 3 ) )
- {
- width = 352;
- height = 288;
- }
- else if ( !strncmp( profile, "cvd", 3 ) )
- {
- width = 352;
- height = 576;
- pixel_num = 59;
- pixel_den = 27;
- }
- else if ( !strncmp( profile, "svcd_wide", 9 ) )
- {
- width = 480;
- height = 576;
- pixel_num = 59;
- pixel_den = 27;
- display_num = 16;
- display_den = 9;
- }
- else if ( !strncmp( profile, "svcd", 4 ) )
- {
- width = 480;
- height = 576;
- pixel_num = 59;
- pixel_den = 36;
- }
- else if ( strncmp( profile, "frame", 5 ) && strcmp( profile, "dv" ) )
- {
- recognised = 0;
- }
- }
- else if ( profile != NULL )
+ mlt_profile p = mlt_profile_select( profile );
+ if ( p )
{
- width = 720;
- height = 480;
- display_num = 4;
- display_den = 3;
- pixel_num = 10;
- pixel_den = 11;
-
- if ( !strcmp( profile, "dv_wide" ) )
- {
- display_num = 16;
- display_den = 9;
- pixel_num = 40;
- pixel_den = 33;
- }
- else if ( !strncmp( profile, "square_wide", 11 ) )
- {
- display_num = 16;
- display_den = 9;
- pixel_num = 1;
- pixel_den = 1;
- width = 854;
- height = 480;
- }
- else if ( !strncmp( profile, "square", 6 ) )
- {
- pixel_num = 1;
- pixel_den = 1;
- width = 640;
- height = 480;
- }
- else if ( !strncmp( profile, "vcd", 3 ) )
- {
- width = 352;
- height = 240;
- }
- else if ( !strncmp( profile, "cvd", 3 ) )
- {
- width = 352;
- height = 480;
- pixel_num = 20;
- pixel_den = 11;
- }
- else if ( !strncmp( profile, "svcd_wide", 9 ) )
- {
- width = 480;
- height = 480;
- pixel_num = 20;
- pixel_den = 11;
- display_num = 16;
- display_den = 9;
- }
- else if ( !strncmp( profile, "svcd", 4 ) )
- {
- width = 480;
- height = 480;
- pixel_num = 15;
- pixel_den = 11;
- }
- else if ( strncmp( profile, "frame", 5 ) && strcmp( profile, "dv" ) )
- {
- recognised = 0;
- }
+ apply_profile_properties( p, properties );
+ return 1;
}
-
- // If width (or any of the above are 0), we use defaults otherwise we switch to recognised
- if ( width != 0 && recognised )
+ else
{
- if ( recognised && strchr( profile, ':' ) )
- if ( sscanf( strchr( profile, ':' ) + 1, "%dx%d", &width, &height ) != 2 )
- recognised = -1;
-
- mlt_properties_set_int( properties, "width", width );
- mlt_properties_set_int( properties, "height", height );
- mlt_properties_set_double( properties, "aspect_ratio", pixel_num / pixel_den );
- mlt_properties_set_int( properties, "aspect_ratio_num", pixel_num );
- mlt_properties_set_int( properties, "aspect_ratio_den", pixel_den );
- mlt_properties_set_double( properties, "display_ratio", display_num / display_den );
- mlt_properties_set_int( properties, "display_ratio_num", display_num );
- mlt_properties_set_int( properties, "display_ratio_den", display_den );
+ return 0;
}
-
- return recognised;
}
static void *consumer_read_ahead_thread( void *arg )
mlt_properties_set_or_default( global_properties, "MLT_PRODUCER", getenv( "MLT_PRODUCER" ), "fezzik" );
mlt_properties_set_or_default( global_properties, "MLT_CONSUMER", getenv( "MLT_CONSUMER" ), "sdl" );
mlt_properties_set( global_properties, "MLT_TEST_CARD", getenv( "MLT_TEST_CARD" ) );
+ mlt_properties_set_or_default( global_properties, "MLT_PROFILE", getenv( "MLT_PROFILE" ), "dv_pal" );
+
+ // Load the most appropriate profile
+ // MLT_PROFILE preferred
+ if ( getenv( "MLT_PROFILE" ) )
+ {
+ if ( !mlt_profile_select( mlt_environment( "MLT_PROFILE" ) ) )
+ mlt_profile_load_file( mlt_environment( "MLT_PROFILE" ) );
+ }
+ // MLT_NORMALISATION backwards compatibility
+ else if ( strcmp( mlt_environment( "MLT_NORMALISATION" ), "PAL" ) )
+ mlt_profile_select( "dv_ntsc" );
+ else
+ mlt_profile_select( "dv_pal" );
+
+ // destroy an invalid profile so it can be constructed from hard defauls
+ if ( mlt_profile_get()->width == 0 )
+ mlt_profile_close();
+
+ // Set MLT_NORMALISATION to appease legacy modules
+ if ( !getenv( "MLT_NORMALISATION" ) )
+ {
+ const char *profile = mlt_profile_get()->name;
+ if ( strstr( profile, "_ntsc" ) || strstr( profile, "_atsc" ) )
+ setenv( "MLT_NORMALISATION", "NTSC", 1 );
+ else if ( strstr( profile, "_pal" ) )
+ setenv( "MLT_NORMALISATION", "PAL", 1 );
+ }
}
+
return 0;
}
free( mlt_prefix );
mlt_prefix = NULL;
mlt_pool_close( );
+ mlt_profile_close();
}
}
-
#include "mlt_frame.h"
#include "mlt_producer.h"
#include "mlt_factory.h"
+#include "mlt_profile.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
if ( this != NULL )
{
- // Get the normalisation
- char *normalisation = mlt_environment( "MLT_NORMALISATION" );
-
// Initialise the properties
mlt_properties properties = &this->parent;
mlt_properties_init( properties, this );
// Set default properties on the frame
mlt_properties_set_position( properties, "_position", 0.0 );
mlt_properties_set_data( properties, "image", NULL, 0, NULL, NULL );
-
- if ( normalisation == NULL || strcmp( normalisation, "NTSC" ) )
- {
- mlt_properties_set_int( properties, "width", 720 );
- 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", 59.0/54.0 );
- }
- else
- {
- mlt_properties_set_int( properties, "width", 720 );
- 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", 10.0/11.0 );
- }
-
+ mlt_properties_set_int( properties, "width", mlt_profile_get()->width );
+ mlt_properties_set_int( properties, "height", mlt_profile_get()->height );
+ mlt_properties_set_int( properties, "normalised_width", mlt_profile_get()->width );
+ mlt_properties_set_int( properties, "normalised_height", mlt_profile_get()->height );
+ mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( NULL ) );
mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL );
mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL );
#include "mlt_geometry.h"
#include "mlt_tokeniser.h"
#include "mlt_factory.h"
+#include "mlt_profile.h"
#include <stdio.h>
#include <stdlib.h>
if ( this->local != NULL )
{
geometry self = this->local;
- char *normalisation = mlt_environment( "MLT_NORMALISATION" );
- self->nw = 720;
- if ( normalisation == NULL || strcmp( normalisation, "NTSC" ) )
- self->nh = 576;
- else
- self->nh = 480;
+ self->nw = mlt_profile_get()->width;
+ self->nh = mlt_profile_get()->height;
}
else
{
#include "mlt_factory.h"
#include "mlt_frame.h"
#include "mlt_parser.h"
+#include "mlt_profile.h"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// Initialise the service
if ( mlt_service_init( &this->parent, this ) == 0 )
{
- // Get the normalisation preference
- char *normalisation = mlt_environment( "MLT_NORMALISATION" );
-
// The parent is the service
mlt_service parent = &this->parent;
mlt_properties_set( properties, "mlt_type", "mlt_producer" );
mlt_properties_set_position( properties, "_position", 0.0 );
mlt_properties_set_double( properties, "_frame", 0 );
- if ( normalisation == NULL || strcmp( normalisation, "NTSC" ) )
- {
- mlt_properties_set_double( properties, "fps", 25.0 );
- mlt_properties_set_int( properties, "frame_rate_num", 25 );
- mlt_properties_set_int( properties, "frame_rate_den", 1 );
- 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_int( properties, "frame_rate_num", 30000 );
- mlt_properties_set_int( properties, "frame_rate_den", 1001 );
- mlt_properties_set_double( properties, "aspect_ratio", 10.0 / 11.0 );
- }
+ mlt_properties_set_double( properties, "fps", mlt_profile_fps( NULL ) );
+ mlt_properties_set_int( properties, "frame_rate_num", mlt_profile_get()->frame_rate_num );
+ mlt_properties_set_int( properties, "frame_rate_den", mlt_profile_get()->frame_rate_den );
+ mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( NULL ) );
mlt_properties_set_double( properties, "_speed", 1.0 );
mlt_properties_set_position( properties, "in", 0 );
mlt_properties_set_position( properties, "out", 14999 );
--- /dev/null
+/*
+ * mlt_profile.c -- video output definition
+ * Copyright (C) 2007 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "mlt_profile.h"
+#include "mlt_factory.h"
+#include "mlt_properties.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <libgen.h>
+
+#define PROFILES_DIR "/share/mlt/profiles/"
+
+static mlt_profile profile = NULL;
+
+/** Get the current profile
+* Builds one for PAL DV if non-existing
+*/
+
+mlt_profile mlt_profile_get( )
+{
+ if ( !profile )
+ {
+ profile = calloc( 1, sizeof( struct mlt_profile_s ) );
+ if ( profile )
+ {
+ profile->name = strdup( "DV PAL" );
+ profile->frame_rate_num = 25;
+ profile->frame_rate_den = 1;
+ profile->width = 720;
+ profile->height = 576;
+ profile->progressive = 0;
+ profile->sample_aspect_num = 59;
+ profile->sample_aspect_den = 54;
+ profile->display_aspect_num = 4;
+ profile->display_aspect_den = 3;
+ }
+ }
+ return profile;
+}
+
+
+/** Load a profile from the system folder
+*/
+
+mlt_profile mlt_profile_select( const char *name )
+{
+ const char *prefix = PREFIX;
+ char *filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + strlen( name ) + 1 );
+ strcpy( filename, prefix );
+ if ( filename[ strlen( filename ) - 1 ] != '/' )
+ filename[ strlen( filename ) ] = '/';
+ strcat( filename, PROFILES_DIR );
+ strcat( filename, name );
+ return mlt_profile_load_file( filename );
+}
+
+/** Load a profile from specific file
+*/
+
+mlt_profile mlt_profile_load_file( const char *file )
+{
+ // Load the profile as properties
+ mlt_properties properties = mlt_properties_load( file );
+ if ( properties && mlt_properties_get_int( properties, "width" ) )
+ {
+ mlt_profile_load_properties( properties );
+ if ( !profile->name )
+ {
+ char *filename = strdup( file );
+ profile->name = strdup( basename( filename ) );
+ free( filename );
+ }
+ }
+ else
+ {
+ mlt_properties_close( properties );
+ mlt_profile_close();
+ }
+ return profile;
+}
+
+/** Load a profile from a properties object
+*/
+
+mlt_profile mlt_profile_load_properties( mlt_properties properties )
+{
+ mlt_profile_close();
+ profile = calloc( 1, sizeof( struct mlt_profile_s ) );
+ if ( profile )
+ {
+ if ( mlt_properties_get( properties, "name" ) )
+ profile->name = mlt_properties_get( properties, "name" );
+ profile->frame_rate_num = mlt_properties_get_int( properties, "frame_rate_num" );
+ profile->frame_rate_den = mlt_properties_get_int( properties, "frame_rate_den" );
+ profile->width = mlt_properties_get_int( properties, "width" );
+ profile->height = mlt_properties_get_int( properties, "height" );
+ profile->progressive = mlt_properties_get_int( properties, "progressive" );
+ profile->sample_aspect_num = mlt_properties_get_int( properties, "sample_aspect_num" );
+ profile->sample_aspect_den = mlt_properties_get_int( properties, "sample_aspect_den" );
+ profile->display_aspect_num = mlt_properties_get_int( properties, "display_aspect_num" );
+ profile->display_aspect_den = mlt_properties_get_int( properties, "display_aspect_den" );
+ }
+ return profile;
+}
+
+/** Load an anonymous profile from string
+*/
+
+mlt_profile mlt_profile_load_string( const char *string )
+{
+ mlt_properties properties = mlt_properties_new();
+ if ( properties )
+ {
+ const char *p = string;
+ while ( p )
+ {
+ if ( strcmp( p, "" ) && p[ 0 ] != '#' )
+ mlt_properties_parse( properties, p );
+ p = strchr( p, '\n' );
+ if ( p ) p++;
+ }
+ }
+ mlt_profile_load_properties( properties );
+ if ( profile && !profile->name )
+ profile->name = strdup( "untitled" );
+ return profile;
+}
+
+/** Get the framerate as float
+*/
+
+double mlt_profile_fps( mlt_profile aprofile )
+{
+ if ( aprofile )
+ return ( double ) aprofile->frame_rate_num / aprofile->frame_rate_den;
+ else
+ return ( double ) mlt_profile_get()->frame_rate_num / mlt_profile_get()->frame_rate_den;
+}
+
+/** Get the sample aspect ratio as float
+*/
+
+double mlt_profile_sar( mlt_profile aprofile )
+{
+ if ( aprofile )
+ return ( double ) aprofile->sample_aspect_num / aprofile->sample_aspect_den;
+ else
+ return ( double ) mlt_profile_get()->sample_aspect_num / mlt_profile_get()->sample_aspect_den;
+}
+
+/** Get the display aspect ratio as float
+*/
+
+double mlt_profile_dar( mlt_profile aprofile )
+{
+ if ( aprofile )
+ return ( double ) aprofile->display_aspect_num / aprofile->display_aspect_den;
+ else
+ return ( double ) mlt_profile_get()->display_aspect_num / mlt_profile_get()->display_aspect_den;
+}
+
+/** Free up the global profile resources
+*/
+
+void mlt_profile_close( )
+{
+ if ( profile )
+ {
+ if ( profile->name )
+ free( profile->name );
+ profile->name = NULL;
+ free( profile );
+ profile = NULL;
+ }
+}
--- /dev/null
+/*
+ * mlt_profile.h -- video output definition
+ * Copyright (C) 2007 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _MLT_PROFILE_H
+#define _MLT_PROFILE_H
+
+#include "mlt_types.h"
+
+struct mlt_profile_s
+{
+ char* name;
+ int frame_rate_num;
+ int frame_rate_den;
+ int width;
+ int height;
+ int progressive;
+ int sample_aspect_num;
+ int sample_aspect_den;
+ int display_aspect_num;
+ int display_aspect_den;
+};
+
+extern mlt_profile mlt_profile_get( );
+extern mlt_profile mlt_profile_select( const char *name );
+extern mlt_profile mlt_profile_load_file( const char *file );
+extern mlt_profile mlt_profile_load_properties( mlt_properties properties );
+extern mlt_profile mlt_profile_load_string( const char *string );
+extern double mlt_profile_fps( mlt_profile profile );
+extern double mlt_profile_sar( mlt_profile profile );
+extern double mlt_profile_dar( mlt_profile profile );
+extern void mlt_profile_close( );
+#endif
typedef struct mlt_deque_s *mlt_deque;
typedef struct mlt_geometry_s *mlt_geometry;
typedef struct mlt_geometry_item_s *mlt_geometry_item;
+typedef struct mlt_profile_s *mlt_profile;
typedef void ( *mlt_destructor )( void * );
typedef char *( *mlt_serialiser )( void *, int length );
time_t start = time( NULL );
int height = mlt_properties_get_int( this_properties, "height" );
int is_pal = height == 576;
- int is_wide = mlt_properties_get_int( this_properties, "display_ratio_num" ) == 16;
+ int is_wide = mlt_properties_get_int( this_properties, "display_aspect_num" ) == 16;
// Temporary - audio buffer allocation
int16_t *audio_buffers[ 4 ];
mlt_service service = MLT_CONSUMER_SERVICE( parent );
this->properties = MLT_SERVICE_PROPERTIES( service );
- // Default display aspect ratio
- double display_ratio = mlt_properties_get_double( this->properties, "display_ratio" );
-
// Set the default volume
mlt_properties_set_double( this->properties, "volume", 1.0 );
this->height = mlt_properties_get_int( this->properties, "height" );
}
- // Default window size
- this->window_width = ( double )this->height * display_ratio;
- this->window_height = this->height;
-
// Set the sdl flags
this->sdl_flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_RESIZABLE | SDL_DOUBLEBUF;
if ( audio_off == 0 )
SDL_InitSubSystem( SDL_INIT_AUDIO );
+ // Default window size
+ double display_ratio = mlt_properties_get_double( this->properties, "display_ratio" );
+ this->window_width = ( double )this->height * display_ratio;
+ this->window_height = this->height;
+
if ( this->sdl_screen == NULL && display_off == 0 )
this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );