From d57832919959e117a68d856b172c090746fc3399 Mon Sep 17 00:00:00 2001 From: ddennedy Date: Fri, 20 Jul 2007 06:26:48 +0000 Subject: [PATCH] profiles/*: name->description mlt_factory.{h,cc}: added mlt_environment_set() mlt_profile.{h,cc}: fix setting legacy MLT_NORMALISATION, set MLT_PROFILE, and change "name" to "description" for clarity git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1011 d19143bc-622f-0410-bfdd-b5b2a6649095 --- profiles/atsc_wide_1080i | 2 +- profiles/atsc_wide_720p | 2 +- profiles/cif_ntsc | 2 +- profiles/cif_pal | 2 +- profiles/cvd_ntsc | 2 +- profiles/cvd_pal | 2 +- profiles/dv_ntsc | 2 +- profiles/dv_ntsc_wide | 2 +- profiles/dv_pal | 2 +- profiles/dv_pal_wide | 2 +- profiles/hdv_1080_ntsc | 2 +- profiles/hdv_1080_pal | 2 +- profiles/hdv_720_ntsc | 2 +- profiles/hdv_720_pal | 2 +- profiles/qcif_ntsc | 2 +- profiles/qcif_pal | 2 +- profiles/quarter_ntsc | 2 +- profiles/quarter_ntsc_wide | 2 +- profiles/quarter_pal | 2 +- profiles/quarter_pal_wide | 2 +- profiles/square_ntsc | 2 +- profiles/square_ntsc_wide | 2 +- profiles/square_pal | 2 +- profiles/square_pal_wide | 2 +- profiles/svcd_ntsc | 2 +- profiles/svcd_ntsc_wide | 2 +- profiles/svcd_pal | 2 +- profiles/svcd_pal_wide | 2 +- profiles/vcd_ntsc | 2 +- profiles/vcd_pal | 2 +- src/framework/mlt_factory.c | 22 +++++++------------ src/framework/mlt_factory.h | 1 + src/framework/mlt_profile.c | 50 ++++++++++++++++++++++++++++++------------- src/framework/mlt_profile.h | 2 +- 34 files changed, 75 insertions(+), 60 deletions(-) diff --git a/profiles/atsc_wide_1080i b/profiles/atsc_wide_1080i index 889379b..9a39901 100644 --- a/profiles/atsc_wide_1080i +++ b/profiles/atsc_wide_1080i @@ -1,4 +1,4 @@ -name=ATSC Widescreen 1080i +description=ATSC Widescreen 1080i frame_rate_num=30000 frame_rate_den=1001 width=1920 diff --git a/profiles/atsc_wide_720p b/profiles/atsc_wide_720p index 5558016..abb0df9 100644 --- a/profiles/atsc_wide_720p +++ b/profiles/atsc_wide_720p @@ -1,4 +1,4 @@ -name=ATSC Widescreen 720p +description=ATSC Widescreen 720p frame_rate_num=30000 frame_rate_den=1001 width=1280 diff --git a/profiles/cif_ntsc b/profiles/cif_ntsc index f4e8491..48279a5 100644 --- a/profiles/cif_ntsc +++ b/profiles/cif_ntsc @@ -1,4 +1,4 @@ -name=CIF NTSC +description=CIF NTSC frame_rate_num=30000 frame_rate_den=1001 width=352 diff --git a/profiles/cif_pal b/profiles/cif_pal index dafa242..a7f66d4 100644 --- a/profiles/cif_pal +++ b/profiles/cif_pal @@ -1,4 +1,4 @@ -name=CIF PAL +description=CIF PAL frame_rate_num=25 frame_rate_den=1 width=352 diff --git a/profiles/cvd_ntsc b/profiles/cvd_ntsc index af844c4..508b3cc 100644 --- a/profiles/cvd_ntsc +++ b/profiles/cvd_ntsc @@ -1,4 +1,4 @@ -name=CVD NTSC +description=CVD NTSC frame_rate_num=30000 frame_rate_den=1001 width=352 diff --git a/profiles/cvd_pal b/profiles/cvd_pal index 44cd5bc..2415c77 100644 --- a/profiles/cvd_pal +++ b/profiles/cvd_pal @@ -1,4 +1,4 @@ -name=CVD PAL +description=CVD PAL frame_rate_num=25 frame_rate_den=1 width=352 diff --git a/profiles/dv_ntsc b/profiles/dv_ntsc index 68cf870..c5462dd 100644 --- a/profiles/dv_ntsc +++ b/profiles/dv_ntsc @@ -1,4 +1,4 @@ -name=DV NTSC +description=DV NTSC frame_rate_num=30000 frame_rate_den=1001 width=720 diff --git a/profiles/dv_ntsc_wide b/profiles/dv_ntsc_wide index cc6879f..6c98e4f 100644 --- a/profiles/dv_ntsc_wide +++ b/profiles/dv_ntsc_wide @@ -1,4 +1,4 @@ -name=DV NTSC Widescreen +description=DV NTSC Widescreen frame_rate_num=30000 frame_rate_den=1001 width=720 diff --git a/profiles/dv_pal b/profiles/dv_pal index 32f72c3..33e82bc 100644 --- a/profiles/dv_pal +++ b/profiles/dv_pal @@ -1,4 +1,4 @@ -name=DV PAL +description=DV PAL frame_rate_num=25 frame_rate_den=1 width=720 diff --git a/profiles/dv_pal_wide b/profiles/dv_pal_wide index 313f12e..a4b669c 100644 --- a/profiles/dv_pal_wide +++ b/profiles/dv_pal_wide @@ -1,4 +1,4 @@ -name=DV PAL Widescreen +description=DV PAL Widescreen frame_rate_num=25 frame_rate_den=1 width=720 diff --git a/profiles/hdv_1080_ntsc b/profiles/hdv_1080_ntsc index 61e409b..334fb50 100644 --- a/profiles/hdv_1080_ntsc +++ b/profiles/hdv_1080_ntsc @@ -1,4 +1,4 @@ -name=HDV 1080i NTSC +description=HDV 1080i NTSC frame_rate_num=30000 frame_rate_den=1001 width=1440 diff --git a/profiles/hdv_1080_pal b/profiles/hdv_1080_pal index 8ecbacd..5ccb720 100644 --- a/profiles/hdv_1080_pal +++ b/profiles/hdv_1080_pal @@ -1,4 +1,4 @@ -name=HDV 1080i PAL +description=HDV 1080i PAL frame_rate_num=25 frame_rate_den=1 width=1440 diff --git a/profiles/hdv_720_ntsc b/profiles/hdv_720_ntsc index 08e17c0..928b557 100644 --- a/profiles/hdv_720_ntsc +++ b/profiles/hdv_720_ntsc @@ -1,4 +1,4 @@ -name=HDV 720p NTSC +description=HDV 720p NTSC frame_rate_num=30000 frame_rate_den=1001 width=1280 diff --git a/profiles/hdv_720_pal b/profiles/hdv_720_pal index c1908b5..3e59703 100644 --- a/profiles/hdv_720_pal +++ b/profiles/hdv_720_pal @@ -1,4 +1,4 @@ -name=HDV 720p PAL +description=HDV 720p PAL frame_rate_num=25 frame_rate_den=1 width=1280 diff --git a/profiles/qcif_ntsc b/profiles/qcif_ntsc index 59bd4ff..0e90157 100644 --- a/profiles/qcif_ntsc +++ b/profiles/qcif_ntsc @@ -1,4 +1,4 @@ -name=QCIF NTSC +description=QCIF NTSC frame_rate_num=30000 frame_rate_den=1001 width=176 diff --git a/profiles/qcif_pal b/profiles/qcif_pal index c96f62f..21667ee 100644 --- a/profiles/qcif_pal +++ b/profiles/qcif_pal @@ -1,4 +1,4 @@ -name=QCIF PAL +description=QCIF PAL frame_rate_num=25 frame_rate_den=1 width=176 diff --git a/profiles/quarter_ntsc b/profiles/quarter_ntsc index 240a814..fb37cd7 100644 --- a/profiles/quarter_ntsc +++ b/profiles/quarter_ntsc @@ -1,4 +1,4 @@ -name=Quarter Square NTSC +description=Quarter Square NTSC frame_rate_num=30000 frame_rate_den=1001 width=320 diff --git a/profiles/quarter_ntsc_wide b/profiles/quarter_ntsc_wide index bc1cf7d..8c7be94 100644 --- a/profiles/quarter_ntsc_wide +++ b/profiles/quarter_ntsc_wide @@ -1,4 +1,4 @@ -name=Quarter Square NTSC Widescreen +description=Quarter Square NTSC Widescreen frame_rate_num=30000 frame_rate_den=1001 width=426 diff --git a/profiles/quarter_pal b/profiles/quarter_pal index fd64d66..beec207 100644 --- a/profiles/quarter_pal +++ b/profiles/quarter_pal @@ -1,4 +1,4 @@ -name=Quarter Square PAL +description=Quarter Square PAL frame_rate_num=25 frame_rate_den=1 width=384 diff --git a/profiles/quarter_pal_wide b/profiles/quarter_pal_wide index 324a11d..195410a 100644 --- a/profiles/quarter_pal_wide +++ b/profiles/quarter_pal_wide @@ -1,4 +1,4 @@ -name=Quarter Square PAL Widescreen +description=Quarter Square PAL Widescreen frame_rate_num=25 frame_rate_den=1 width=512 diff --git a/profiles/square_ntsc b/profiles/square_ntsc index f668b82..e139c3e 100644 --- a/profiles/square_ntsc +++ b/profiles/square_ntsc @@ -1,4 +1,4 @@ -name=Square NTSC +description=Square NTSC frame_rate_num=30000 frame_rate_den=1001 width=640 diff --git a/profiles/square_ntsc_wide b/profiles/square_ntsc_wide index 86addae..da2de3e 100644 --- a/profiles/square_ntsc_wide +++ b/profiles/square_ntsc_wide @@ -1,4 +1,4 @@ -name=Square NTSC Widescreen +description=Square NTSC Widescreen frame_rate_num=30000 frame_rate_den=1001 width=854 diff --git a/profiles/square_pal b/profiles/square_pal index 4ece39b..a69c8d6 100644 --- a/profiles/square_pal +++ b/profiles/square_pal @@ -1,4 +1,4 @@ -name=Square PAL +description=Square PAL frame_rate_num=25 frame_rate_den=1 width=768 diff --git a/profiles/square_pal_wide b/profiles/square_pal_wide index 4fbbf05..316a80d 100644 --- a/profiles/square_pal_wide +++ b/profiles/square_pal_wide @@ -1,4 +1,4 @@ -name=Square PAL Widescreen +description=Square PAL Widescreen frame_rate_num=25 frame_rate_den=1 width=1024 diff --git a/profiles/svcd_ntsc b/profiles/svcd_ntsc index 828cccd..fd6f13a 100644 --- a/profiles/svcd_ntsc +++ b/profiles/svcd_ntsc @@ -1,4 +1,4 @@ -name=SVCD NTSC +description=SVCD NTSC frame_rate_num=30000 frame_rate_den=1001 width=480 diff --git a/profiles/svcd_ntsc_wide b/profiles/svcd_ntsc_wide index 42f04fc..174960a 100644 --- a/profiles/svcd_ntsc_wide +++ b/profiles/svcd_ntsc_wide @@ -1,4 +1,4 @@ -name=SVCD NTSC Widescreen +description=SVCD NTSC Widescreen frame_rate_num=30000 frame_rate_den=1001 width=480 diff --git a/profiles/svcd_pal b/profiles/svcd_pal index 3c41a68..2049270 100644 --- a/profiles/svcd_pal +++ b/profiles/svcd_pal @@ -1,4 +1,4 @@ -name=SVCD PAL +description=SVCD PAL frame_rate_num=25 frame_rate_den=1 width=480 diff --git a/profiles/svcd_pal_wide b/profiles/svcd_pal_wide index e634a4a..3aea87a 100644 --- a/profiles/svcd_pal_wide +++ b/profiles/svcd_pal_wide @@ -1,4 +1,4 @@ -name=SVCD PAL Widescreen +description=SVCD PAL Widescreen frame_rate_num=25 frame_rate_den=1 width=480 diff --git a/profiles/vcd_ntsc b/profiles/vcd_ntsc index ae70cad..e58f4f2 100644 --- a/profiles/vcd_ntsc +++ b/profiles/vcd_ntsc @@ -1,4 +1,4 @@ -name=VCD NTSC +description=VCD NTSC frame_rate_num=30000 frame_rate_den=1001 width=352 diff --git a/profiles/vcd_pal b/profiles/vcd_pal index e5db06c..5f4e03f 100644 --- a/profiles/vcd_pal +++ b/profiles/vcd_pal @@ -1,4 +1,4 @@ -name=VCD PAL +description=VCD PAL frame_rate_num=25 frame_rate_den=1 width=352 diff --git a/src/framework/mlt_factory.c b/src/framework/mlt_factory.c index 1245265..709dc5e 100644 --- a/src/framework/mlt_factory.c +++ b/src/framework/mlt_factory.c @@ -125,20 +125,6 @@ int mlt_factory_init( const char *prefix ) 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 ); - } } @@ -169,6 +155,14 @@ char *mlt_environment( const char *name ) return mlt_properties_get( global_properties, name ); } +/** Set a value in the environment. +*/ + +int mlt_environment_set( const char *name, const char *value ) +{ + return mlt_properties_set( global_properties, name, value ); +} + /** Fetch a producer from the repository. */ diff --git a/src/framework/mlt_factory.h b/src/framework/mlt_factory.h index 1765595..749a201 100644 --- a/src/framework/mlt_factory.h +++ b/src/framework/mlt_factory.h @@ -26,6 +26,7 @@ extern int mlt_factory_init( const char *prefix ); extern const char *mlt_factory_prefix( ); extern char *mlt_environment( const char *name ); +extern int mlt_environment_set( const char *name, const char *value ); extern mlt_properties mlt_factory_event_object( ); extern mlt_producer mlt_factory_producer( const char *name, void *input ); extern mlt_filter mlt_factory_filter( const char *name, void *input ); diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index d32146a..c9c67d2 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -41,7 +41,8 @@ mlt_profile mlt_profile_get( ) profile = calloc( 1, sizeof( struct mlt_profile_s ) ); if ( profile ) { - profile->name = strdup( "DV PAL" ); + mlt_environment_set( "MLT_PROFILE", "dv_pal" ); + profile->description = strdup( "PAL 4:3 DV or DVD" ); profile->frame_rate_num = 25; profile->frame_rate_den = 1; profile->width = 720; @@ -82,18 +83,38 @@ mlt_profile mlt_profile_load_file( const char *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 ); - } + mlt_properties_close( properties ); + + // Set MLT_PROFILE to basename + char *filename = strdup( file ); + mlt_environment_set( "MLT_PROFILE", basename( filename ) ); + free( filename ); } else { + // Cleanup mlt_properties_close( properties ); mlt_profile_close(); + // Failover + mlt_profile_get(); } + + // Set MLT_NORMALISATION to appease legacy modules + char *profile_name = mlt_environment( "MLT_PROFILE" ); + if ( strstr( profile_name, "_ntsc" ) || + strstr( profile_name, "_atsc" ) || + strstr( profile_name, "_60i" ) || + strstr( profile_name, "_30p" ) ) + { + mlt_environment_set( "MLT_NORMALISATION", "NTSC" ); + } + else if ( strstr( profile_name, "_pal" ) || + strstr( profile_name, "_50i" ) || + strstr( profile_name, "_25p" ) ) + { + mlt_environment_set( "MLT_NORMALISATION", "PAL" ); + } + return profile; } @@ -107,7 +128,9 @@ mlt_profile mlt_profile_load_properties( mlt_properties properties ) if ( profile ) { if ( mlt_properties_get( properties, "name" ) ) - profile->name = mlt_properties_get( properties, "name" ); + mlt_environment_set( "MLT_PROFILE", mlt_properties_get( properties, "name" ) ); + if ( mlt_properties_get( properties, "description" ) ) + profile->description = strdup( mlt_properties_get( properties, "description" ) ); 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" ); @@ -138,10 +161,7 @@ mlt_profile mlt_profile_load_string( const char *string ) if ( p ) p++; } } - mlt_profile_load_properties( properties ); - if ( profile && !profile->name ) - profile->name = strdup( "untitled" ); - return profile; + return mlt_profile_load_properties( properties ); } /** Get the framerate as float @@ -184,9 +204,9 @@ void mlt_profile_close( ) { if ( profile ) { - if ( profile->name ) - free( profile->name ); - profile->name = NULL; + if ( profile->description ) + free( profile->description ); + profile->description = NULL; free( profile ); profile = NULL; } diff --git a/src/framework/mlt_profile.h b/src/framework/mlt_profile.h index 29ee633..0c64e7c 100644 --- a/src/framework/mlt_profile.h +++ b/src/framework/mlt_profile.h @@ -25,7 +25,7 @@ struct mlt_profile_s { - char* name; + char* description; int frame_rate_num; int frame_rate_den; int width; -- 1.7.4.4