* If the string contains a colon it is interpreted as a time value. If it also
* contains a period or comma character, the string is parsed as a clock value:
* HH:MM:SS. Otherwise, the time value is parsed as a SMPTE timecode: HH:MM:SS:FF.
+ * If the numeric string ends with '%' then the value is divided by 100 to convert
+ * it into a ratio.
* \private \memberof mlt_property_s
* \param value the string to convert
* \param fps frames per second, used when converting from time value
}
else
{
+ char *end = NULL;
+ double result;
#if defined(__GLIBC__) || defined(__DARWIN__)
if ( locale )
- return strtod_l( value, NULL, locale );
+ result = strtod_l( value, &end, locale );
#endif
- return strtod( value, NULL );
+ else
+ result = strtod( value, &end );
+ if ( *end && end[0] == '%' )
+ result /= 100.0;
+ return result;
}
}
QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 30, 100), 300);
mlt_property_close(p);
}
+
+ void PercentAsRatio()
+ {
+ Properties p;
+ p.set("foo", "12.3%");
+ QCOMPARE(p.get_double("foo"), 0.123);
+ p.set("foo", "456 %");
+ QCOMPARE(p.get_double("foo"), 456.0);
+ }
};
QTEST_APPLESS_MAIN(TestProperties)