[Matroska-devel] Re: Timestamp precision in matroska files

Steve Lhomme steve.lhomme at free.fr
Fri Jan 9 15:09:25 CET 2004


Steve Lhomme wrote:

Poor me... This program can't be accurate. _RealTimecode and 
_ReconstitutedTimecode should be uint64 as they are very large values 
(hours expressed in ns).
I'll have a deeper look ...

> ------------------------------------------------------------------------
> 
> #include <stdio.h>
> #include <stdlib.h>
> 
> #define SamplingFreq 44100.0
> 
> int main(int argc, char *argv[])
> {
>     unsigned long Sample = 0;
>     unsigned int TimecodeScale = 1000000;
>     double TrackTimecodeScale = 0.022675736961451247165532879818594;
>     
>     // timecodes expressed in ns
>     double RealTimecode, ReconstitutedTimecode;
>     unsigned long _RealTimecode, _ReconstitutedTimecode;
> 
>     while (1)
>     {
>         RealTimecode = Sample * 1000000000.0 / SamplingFreq;
>         ReconstitutedTimecode = TrackTimecodeScale * TimecodeScale * Sample;
>         Sample+=10000;
>         _RealTimecode = (unsigned long) RealTimecode;
>         _ReconstitutedTimecode = (unsigned long) ReconstitutedTimecode;
>         if (_ReconstitutedTimecode != _RealTimecode)
>             break;
> /*
>         if (_ReconstitutedTimecode > _RealTimecode && _ReconstitutedTimecode - _RealTimecode >= 11337)
>             break;
>         if (_ReconstitutedTimecode < _RealTimecode && _RealTimecode - _ReconstitutedTimecode >= 11337)
>             break;
> */
>         if (Sample % 1000000 == 0)
>             printf("%lu ", Sample);
>     }
> 
>     printf("\nFirst problem at sample %lu (%lu != %lu)\n", Sample, _ReconstitutedTimecode, _RealTimecode);
>   
>     system("PAUSE");	
>     return 0;
> }
> 
> 
> ------------------------------------------------------------------------





More information about the Matroska-devel mailing list