[vlc-devel] [PATCH 06/15] vlc_common: add helper fonctions to convert from mtime_t to floating point seconds
Steve Lhomme
robux4 at ycbcr.xyz
Sat Jun 16 09:37:13 CEST 2018
In many case where it's used it's not obvious the output is requested in
float rather than int. Like sout << secf_from_vtick()
Also the rounding may not be the same. For floating point llround() is
used in a few places. For integer it may be different although
everything I saw implied rounding down.
On 2018-06-16 9:09 AM, Rémi Denis-Courmont wrote:
> Le perjantaina 15. kesäkuuta 2018, 18.09.17 EEST Steve Lhomme a écrit :
>> ---
>> include/vlc_common.h | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/include/vlc_common.h b/include/vlc_common.h
>> index 8b4baffcf27..fe1b125625f 100644
>> --- a/include/vlc_common.h
>> +++ b/include/vlc_common.h
>> @@ -333,6 +333,16 @@ static inline int64_t nano_from_vtick(mtime_t tck)
>> return tck * INT64_C(1000000000) / CLOCK_FREQ;
>> }
>>
>> +static inline double secf_from_vtick(mtime_t m)
>> +{
>> + return (double)m / (double)CLOCK_FREQ;
>> +}
>> +static inline mtime_t vtick_from_secf(double secf)
>> +{
>> + return secf * CLOCK_FREQ; /* TODO use llround */
>> +}
> Bleh. Why new macro identifiers? You can use _Generic and C++ overloading to
> separate float and integer.
>
More information about the vlc-devel
mailing list