[Matroska-devel] Timestamp precision in matroska files]
Christian HJ Wiesner
chris at matroska.org
Fri Jan 9 21:29:04 CET 2004
FYI, in German, but with code ( should be international ;-) ) ...
-------- Original Message --------
Subject: Antwort: Re: [Matroska-devel] Re: Timestamp precision in
matroska files
Date: Fri, 9 Jan 2004 18:40:21 +0100
From: Frank Klemm <f.klemm at zeiss.de>
To: chris at matroska.org
Die mindestens benötigte Auflösung zur samplegenauen Adressierung eines
Signals, das mit fs abgetastet wurde, ist 1/fs. Nicht mehr (schadet aber
nicht) und nicht weniger (sonst ist es nicht eindeutig).
Es müssen aber die Rundungsregeln EXAKT definiert sein. Mathematisch
EXAKT.
Für den Fall von nur ganzzahligen Abtastraten z.B.
UINT64
WhichSample ( UINT64 timeticks, // 0...2^64-1
UINT32 timetickspersecond, // 1, 300, 1000, 1200,
48000, 192000, 10^6, 10^9
UINT32 samplefreq ) // 8000, 32000, 44100,
48000, 96000, 192000
{
if ( timetickspersecond == 0 )
return ERROR ;
if ( samplefreq > timeticks )
fprintf ( stderr, "Inprecise\n" );
UINT32 seconds = timeticks / timetickspersecond ;
UINT32 remaining = timeticks % timetickspersecond ;
UINT64 ret ;
ret = (UINT64) remaining * samplefreq / timetickspersecond ;
ret += (UINT64) seconds * samplefreq ;
return ret ;
}
> So, the minimal required accuracy to determine a specific sample from a
> timestamp is 1/2 Ts = 11,3 µs
Den Faktor 2 benötigst Du nicht. Aber den Rundungsmodus mußt Du exakt
festlegen.
Möglichkeit 1:
- immer abrunden in Richtung -oo
Möglichkeit 2:
- immer aufrunden in Richtung +oo
Möglichkeit 3:
- immer zum nächstenliegenden Int runden,
0.500000000000000000000000000000000000 wird aufgerundet.
Möglichkeit 4:
- immer zum nächstenliegenden Int runden, Geradezahlregel
3 und 4 unterscheiden sich nur minimal, aber es gibt Fälle, in denen sie
sich unterscheiden.
Genauso solche Fehler führen zu kleinen Fehlern, die man kaum findet, die
selten auffallen und die
Jahrzehnte Ärger verursachen.
--
Frank Klemm
AIM Advanced Imaging Microscopy
phone: +49 (36 41) 64-27 21
fax: +49 (36 41) 64-31 44
mailto:f.klemm at zeiss.de
Christian HJ Wiesner <chris at matroska.org>
2004-01-09 13:35
Bitte antworten an chris
An: Discussion about the current and future development of Matroska
<matroska-devel at lists.matroska.org>
Kopie: Frank at matroska.org
Thema: Re: [Matroska-devel] Re: Timestamp precision in matroska files
Steve Lhomme wrote:
> Now it seems I find to put a simple example myself :
> Imagine sample 998 of an audio stream at 44100 kHz. The timecode for
> this sample is 998/44100 = 22.63038549 ms or 22,630,385.49 ns
> Now you'll have to explain me how any timecode precision, even of 1ns
> could be accurate for this sample !
There is one flaw in this example :
The only purpose of the timestamp accuracy is to allow to determine a
specific sample in a block by the timestamp attached to the start of the
block.
1 / 44100 = 22,6 µs , means every single sample is 22,6 µs long , or
Ts ( duration of each sample ) = 22,6 µs
So, the minimal required accuracy to determine a specific sample from a
timestamp is 1/2 Ts = 11,3 µs
So, if your timestamp is accurate to 10 µs or less, you can say with
100% certainty what sample you have to load, by using rounding.
Remember, we dont need the starting timestamp of this one sample with a
precision of 0,5 ns , all we need to know is, if we have a timestamp
xxxx , what sample corresponds to it.
Christian
More information about the Matroska-devel
mailing list