[vlc-devel] [PATCH 05/15] vlc_common: add helper function to convert microseconds to/from mtime_t
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jun 18 08:48:23 CEST 2018
On 2018-06-16 10:56 AM, Rémi Denis-Courmont wrote:
> Le perjantaina 15. kesäkuuta 2018, 18.09.16 EEST Steve Lhomme a écrit :
>> ---
>> include/vlc_common.h | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/include/vlc_common.h b/include/vlc_common.h
>> index 3191d3ce4c8..8b4baffcf27 100644
>> --- a/include/vlc_common.h
>> +++ b/include/vlc_common.h
>> @@ -316,6 +316,14 @@ static inline int64_t milli_from_vtick(mtime_t mt)
>> return mt / (CLOCK_FREQ / 1000);
>> }
>>
>> +static inline int64_t micro_from_vtick(mtime_t mt)
>> +{
>> + return mt * INT64_C(1000000) / CLOCK_FREQ;
>> +}
>> +static inline mtime_t vtick_from_micro(int64_t micro)
>> +{
>> + return micro * CLOCK_FREQ / INT64_C(1000000);
>> +}
>> static inline mtime_t vtick_from_nano(int64_t nano)
>> {
>> return nano / (INT64_C(1000000000) / CLOCK_FREQ);
> Use macros to preserve constants.
There are no cases where the conversion happens on a constant. See other
thread about macros vs functions for these conversions.
More information about the vlc-devel
mailing list