X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fframework%2Fmlt_profile.c;h=e2ccc56c5a02b06d51b96c86904f33c7c91bdb9f;hb=42eec4e241d043cbdb85009934fc1cea76ae8b05;hp=636eb097298db73c3fdb061cfbd92285d4b4bc75;hpb=7d4d1b562c760c86973180ae94ecc3f690107d2e;p=mlt diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index 636eb097..e2ccc56c 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -90,9 +90,9 @@ static mlt_profile mlt_profile_select( const char *name ) * This will never return NULL as it uses the dv_pal settings as hard-coded fallback default. * * \public \memberof mlt_profile_s - * @param name the name of a profile settings file located in the standard location or + * \param name the name of a profile settings file located in the standard location or * the full path name to a profile settings file - * @return a profile + * \return a profile */ mlt_profile mlt_profile_init( const char *name ) @@ -132,6 +132,7 @@ mlt_profile mlt_profile_init( const char *name ) profile->sample_aspect_den = 15; profile->display_aspect_num = 4; profile->display_aspect_den = 3; + profile->colorspace = 601; } } } @@ -162,8 +163,8 @@ static void set_mlt_normalisation( const char *profile_name ) /** Load a profile from specific file. * * \public \memberof mlt_profile_s - * @param file the full path name to a properties file - * @return a profile or NULL on error + * \param file the full path name to a properties file + * \return a profile or NULL on error */ mlt_profile mlt_profile_load_file( const char *file ) @@ -197,8 +198,8 @@ mlt_profile mlt_profile_load_file( const char *file ) /** Load a profile from a properties object. * * \public \memberof mlt_profile_s - * @param properties a properties list - * @return a profile or NULL if out of memory + * \param properties a properties list + * \return a profile or NULL if out of memory */ mlt_profile mlt_profile_load_properties( mlt_properties properties ) @@ -219,6 +220,7 @@ mlt_profile mlt_profile_load_properties( mlt_properties properties ) 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" ); + profile->colorspace = mlt_properties_get_int( properties, "colorspace" ); } return profile; } @@ -226,8 +228,8 @@ mlt_profile mlt_profile_load_properties( mlt_properties properties ) /** Load an anonymous profile from string. * * \public \memberof mlt_profile_s - * @param string a newline-delimited list of properties as name=value pairs - * @return a profile or NULL if out of memory + * \param string a newline-delimited list of properties as name=value pairs + * \return a profile or NULL if out of memory */ mlt_profile mlt_profile_load_string( const char *string ) @@ -250,14 +252,14 @@ mlt_profile mlt_profile_load_string( const char *string ) /** Get the video frame rate as a floating point value. * * \public \memberof mlt_profile_s - * @param aprofile a profile + * @param profile a profile * @return the frame rate */ -double mlt_profile_fps( mlt_profile aprofile ) +double mlt_profile_fps( mlt_profile profile ) { - if ( aprofile ) - return ( double ) aprofile->frame_rate_num / aprofile->frame_rate_den; + if ( profile ) + return ( double ) profile->frame_rate_num / profile->frame_rate_den; else return 0; } @@ -265,14 +267,14 @@ double mlt_profile_fps( mlt_profile aprofile ) /** Get the sample aspect ratio as a floating point value. * * \public \memberof mlt_profile_s - * @param aprofile a profile - * @return the pixel aspect ratio + * \param profile a profile + * \return the pixel aspect ratio */ -double mlt_profile_sar( mlt_profile aprofile ) +double mlt_profile_sar( mlt_profile profile ) { - if ( aprofile ) - return ( double ) aprofile->sample_aspect_num / aprofile->sample_aspect_den; + if ( profile ) + return ( double ) profile->sample_aspect_num / profile->sample_aspect_den; else return 0; } @@ -280,14 +282,14 @@ double mlt_profile_sar( mlt_profile aprofile ) /** Get the display aspect ratio as floating point value. * * \public \memberof mlt_profile_s - * @param aprofile a profile - * @return the image aspect ratio + * \param profile a profile + * \return the image aspect ratio */ -double mlt_profile_dar( mlt_profile aprofile ) +double mlt_profile_dar( mlt_profile profile ) { - if ( aprofile ) - return ( double ) aprofile->display_aspect_num / aprofile->display_aspect_den; + if ( profile ) + return ( double ) profile->display_aspect_num / profile->display_aspect_den; else return 0; } @@ -295,7 +297,7 @@ double mlt_profile_dar( mlt_profile aprofile ) /** Free up the global profile resources. * * \public \memberof mlt_profile_s - * @param profile a profile + * \param profile a profile */ void mlt_profile_close( mlt_profile profile ) @@ -309,3 +311,71 @@ void mlt_profile_close( mlt_profile profile ) profile = NULL; } } + +/** Make a copy of a profile. + * + * \public \memberof mlt_profile_s + * \param profile the profile to clone + * \return a copy of the profile + */ + +mlt_profile mlt_profile_clone( mlt_profile profile ) +{ + mlt_profile clone = NULL; + + if ( profile ) + { + clone = calloc( 1, sizeof( *profile ) ); + if ( clone ) + { + memcpy( clone, profile, sizeof( *profile ) ); + clone->description = strdup( profile->description ); + } + } + return clone; +} + + +/** Get the list of profiles. + * + * The caller MUST free the returned properties object! + * Each entry in the list is keyed on its name, and its value is another + * properties object that contains the attributes of the profile. + * \public \memberof mlt_profile_s + * \return a list of profiles + */ + +mlt_properties mlt_profile_list( ) +{ + const char *prefix = getenv( "MLT_PROFILES_PATH" ); + mlt_properties properties = mlt_properties_new(); + mlt_properties dir = mlt_properties_new(); + int sort = 1; + const char *wildcard = NULL; + int i; + + // Load from $prefix/share/mlt/profiles if no env var + if ( prefix == NULL ) + prefix = PREFIX; + + mlt_properties_dir_list( dir, prefix, wildcard, sort ); + + for ( i = 0; i < mlt_properties_count( dir ); i++ ) + { + char *filename = mlt_properties_get_value( dir, i ); + char *profile_name = basename( filename ); + if ( profile_name[0] != '.' && strcmp( profile_name, "Makefile" ) && + profile_name[ strlen( profile_name ) - 1 ] != '~' ) + { + mlt_properties profile = mlt_properties_load( filename ); + if ( profile ) + { + mlt_properties_set_data( properties, profile_name, profile, 0, + (mlt_destructor) mlt_properties_close, NULL ); + } + } + } + mlt_properties_close( dir ); + + return properties; +}