X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fframework%2Fmlt_profile.c;h=4385d7a789be5bf857c1d0b05f170256dce057f0;hb=9e781c515001a2428716557218200b2be634214e;hp=542a8f11b896984aabe4dbda80d6abed78ed7cec;hpb=41815085e59278fb8ff919cf3cb7551479cd7921;p=mlt diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index 542a8f11..4385d7a7 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -26,10 +26,11 @@ #include #include #include +#include -/** the default subdirectory of the prefix for holding profiles */ -#define PROFILES_DIR "/share/mlt/profiles/" +/** the default subdirectory of the datadir for holding profiles */ +#define PROFILES_DIR "/profiles/" /** Load a profile from the system folder. * @@ -53,14 +54,12 @@ static mlt_profile mlt_profile_select( const char *name ) { filename = calloc( 1, strlen( name ) + 1 ); } - // Load from $prefix/share/mlt/profiles + // Load from $datadir/mlt/profiles else if ( prefix == NULL ) { - prefix = PREFIX; - filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + strlen( name ) + 2 ); + prefix = mlt_environment( "MLT_DATA" ); + 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 ); } // Use environment variable instead @@ -233,6 +232,8 @@ mlt_profile mlt_profile_load_properties( mlt_properties properties ) mlt_profile mlt_profile_load_string( const char *string ) { mlt_properties properties = mlt_properties_new(); + mlt_profile profile = NULL; + if ( properties ) { const char *p = string; @@ -243,8 +244,10 @@ mlt_profile mlt_profile_load_string( const char *string ) p = strchr( p, '\n' ); if ( p ) p++; } + profile = mlt_profile_load_properties( properties ); + mlt_properties_close( properties ); } - return mlt_profile_load_properties( properties ); + return profile; } /** Get the video frame rate as a floating point value. @@ -353,14 +356,12 @@ mlt_properties mlt_profile_list( ) const char *wildcard = NULL; int i; - // Load from $prefix/share/mlt/profiles if no env var + // Load from $datadir/mlt/profiles if no env var if ( prefix == NULL ) { - prefix = PREFIX; - filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + 2 ); + prefix = mlt_environment( "MLT_DATA" ); + filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + 1 ); strcpy( filename, prefix ); - if ( filename[ strlen( filename ) - 1 ] != '/' ) - filename[ strlen( filename ) ] = '/'; strcat( filename, PROFILES_DIR ); prefix = filename; } @@ -402,15 +403,14 @@ mlt_properties mlt_profile_list( ) void mlt_profile_from_producer( mlt_profile profile, mlt_producer producer ) { mlt_frame fr = NULL; - uint8_t *buffer; - mlt_image_format fmt = mlt_image_yuv422; + uint8_t *buffer = NULL; + mlt_image_format fmt = mlt_image_none; mlt_properties p; int w = profile->width; int h = profile->height; if ( ! mlt_service_get_frame( MLT_PRODUCER_SERVICE(producer), &fr, 0 ) && fr ) { - mlt_properties_set_double( MLT_FRAME_PROPERTIES( fr ), "consumer_aspect_ratio", mlt_profile_sar( profile ) ); if ( ! mlt_frame_get_image( fr, &buffer, &fmt, &w, &h, 0 ) ) { // Some source properties are not exposed until after the first get_image call. @@ -418,13 +418,21 @@ void mlt_profile_from_producer( mlt_profile profile, mlt_producer producer ) mlt_service_get_frame( MLT_PRODUCER_SERVICE(producer), &fr, 0 ); p = MLT_FRAME_PROPERTIES( fr ); // mlt_properties_dump(p, stderr); - if ( mlt_properties_get_int( p, "meta.media.frame_rate_den" ) && mlt_properties_get_int( p, "meta.media.sample_aspect_den" ) ) + if ( mlt_properties_get_int( p, "meta.media.frame_rate_den" ) && + mlt_properties_get_int( p, "meta.media.sample_aspect_den" ) ) { profile->width = mlt_properties_get_int( p, "meta.media.width" ); profile->height = mlt_properties_get_int( p, "meta.media.height" ); profile->progressive = mlt_properties_get_int( p, "meta.media.progressive" ); - profile->frame_rate_num = mlt_properties_get_int( p, "meta.media.frame_rate_num" ); - profile->frame_rate_den = mlt_properties_get_int( p, "meta.media.frame_rate_den" ); + if ( 1000 > mlt_properties_get_double( p, "meta.media.frame_rate_num" ) + / mlt_properties_get_double( p, "meta.media.frame_rate_den" ) ) + { + profile->frame_rate_num = mlt_properties_get_int( p, "meta.media.frame_rate_num" ); + profile->frame_rate_den = mlt_properties_get_int( p, "meta.media.frame_rate_den" ); + } else { + profile->frame_rate_num = 60; + profile->frame_rate_den = 1; + } // AVCHD is mis-reported as double frame rate. if ( profile->progressive == 0 && ( profile->frame_rate_num / profile->frame_rate_den == 50 || @@ -433,7 +441,8 @@ void mlt_profile_from_producer( mlt_profile profile, mlt_producer producer ) profile->sample_aspect_num = mlt_properties_get_int( p, "meta.media.sample_aspect_num" ); profile->sample_aspect_den = mlt_properties_get_int( p, "meta.media.sample_aspect_den" ); profile->colorspace = mlt_properties_get_int( p, "meta.media.colorspace" ); - profile->display_aspect_num = (int) ( (double) profile->sample_aspect_num * profile->width / profile->sample_aspect_den + 0.5 ); + profile->display_aspect_num = lrint( (double) profile->sample_aspect_num * profile->width + / profile->sample_aspect_den ); profile->display_aspect_den = profile->height; free( profile->description ); profile->description = strdup( "automatic" );