Hello.

While investigating a kdenlive title issue, I found a strange behaviour with 
the corner effect, which I traced down to a locale issue.

Attached are two mlt playlists:

* test.mlt is a playlist with 2 color clips and a corner effect after 10 
frames, in french locale (with a comma as numeric separator)

* test_us.mlt is the same playlist but in english locale.


Now the fun part:

melt test_us.mlt  works fine

melt test.mlt     works fine half of the time, black output half of the time.


After some research, I discovered that MLT is using setlocale in a wrong way. 
The doc says that the string returned by setlocale(LC_NUMERIC, NULL) should 
not be modified because it can be changed by subsequent calls to setlocale.

In fact, in mlt_property, we store the previous locale by doing:

const char *orig_localename = setlocale( LC_NUMERIC, NULL );

then we change the locale, through setlocale, which corrupts the 
orig_localename string.

Finally we restore the locale using:

setlocale( LC_NUMERIC, orig_localename );

But since the orig_localename string was corrupted, we get a random behavior.

My patch below fixes the issue.

The problem now is that this fix breaks the locale conversion of geometry 
strings which previously seemed to work on a random basis. I am not exactly 
sure how the geometry parsing is supposed to work in relation with locales, so 
if you can have a look Dan, you can probably be more efficient than I will be.


thanks
jb


_____________________________________________________________________________

--- a/src/framework/mlt_property.c
+++ b/src/framework/mlt_property.c
@@ -512,7 +512,7 @@ char *mlt_property_get_string_l( mlt_property self, 
locale_t locale )
                pthread_mutex_lock( &self->mutex );
 
                // Get the current locale
-               const char *orig_localename = setlocale( LC_NUMERIC, NULL );
+               const char *orig_localename = strdup( setlocale( LC_NUMERIC, 
NULL ) );
 
                // Set the new locale
                setlocale( LC_NUMERIC, localename );
@@ -548,6 +548,7 @@ char *mlt_property_get_string_l( mlt_property self, 
locale_t locale )
                }
                // Restore the current locale
                setlocale( LC_NUMERIC, orig_localename );
+               free( orig_localename );
                pthread_mutex_unlock( &self->mutex );
        }

Attachment: test.mlt
Description: video/mlt-playlist

Attachment: test_us.mlt
Description: video/mlt-playlist

------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop 
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops?   How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
Mlt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to