]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_profile.c
Make animation length optional.
[mlt] / src / framework / mlt_profile.c
index 8766349f56cff877f3373ea2b04c6a2ad7ab1dc6..ad51e54dd9dd1f7f00a1fe1f3161c4cf192ada87 100644 (file)
@@ -231,6 +231,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;
@@ -241,8 +243,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.
@@ -398,8 +402,8 @@ 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;
@@ -413,7 +417,8 @@ 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" );
@@ -428,7 +433,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" );