[MPlayer-dev-eng] GetTimerMS overflow

Jarek Czekalski jarekczek at poczta.onet.pl
Mon Mar 3 19:45:11 CET 2014

W dniu 03/02/2014 06:32 PM, Reimar Döffinger pisze:
>> Ad. 2
>> long long values should hold number of milli- and microseconds, as it is done in stream/tvi_v4l2.c. The private library function GetTimerMS (osdep/timer-linux.c) uses unsigned int for this purpose. This easily overflows, because current time in seconds is 1 393 778 888, which hardly fits in 32-bit integer. After multiplying by 1K or 1M we are overflowed. If my calculations are correct, that means GetTimerMS starts from 0 every 4000 seconds.
> Which is completely irrelevant and not an issue as long as it is used correctly (as in: only used to track reasonably small time deltas), not to mention that it ensures compatibility with systems that only have 32 bit high-resolution timers.

GetTimer is not always used correctly. For example mencoder subtracts 2 
GetTimerMS values: one from the beginning of the capture and the current 
one. Maybe docs of these functions could make it clear, what is the 
allowed usage of them.

But as the idea of a wrapping timer, I now understand why it is correct. 
I also found a short and interesting reading about that: 

You are right that GetTimer is irrelevant, regarding both issues I have 
with timestamps. One is fixed now (patch sent), the second one on its way.


More information about the MPlayer-dev-eng mailing list