Another try at sorting out the thorny question of timing.
[dcpomatic.git] / doc / design / timing.tex
1 \documentclass{article}
2 \begin{document}
3
4 We are trying to implement full-ish playlist based content specification.  The timing is awkward.
5
6 \section{Reference timing}
7
8 Frame rates of things can vary a lot; content can be in pretty much
9 anything, and DCP video and audio frame rates may change on a whim
10 depending on what is best for a given set of content.  This suggests
11 (albeit without strong justification) the need for a frame-rate-independent unit of time.
12
13 So far we've been using a time type called \texttt{Time} expressed in
14 $\mathtt{TIME\_HZ}^{-1}$; e.g. \texttt{TIME\_HZ} units is 1 second.
15 \texttt{TIME\_HZ} is chosen to be divisible by lots of frame and
16 sample rates.
17
18 We express content start time as a \texttt{Time}.
19
20
21 \section{Timing at different stages of the chain}
22
23 Let's try this: decoders produce sequences of (perhaps) video frames
24 and (perhaps) audio frames.  There are no gaps.  They are at the
25 content's native frame rates and are synchronised (meaning that if
26 they are played together, at the content's frame rates, they will be
27 in sync).  The decoders give timestamps for each piece of their
28 output, which are \emph{simple indices} (\texttt{ContentVideoFrame}
29 and \texttt{ContentAudioFrame}).  Decoders know nothing of \texttt{Time}.
30
31
32 \section{Split of stuff between decoders and player}
33
34 In some ways it seems nice to have decoders which produce the rawest
35 possible data and make the player sort it out (e.g.\ cropping and
36 scaling video, resampling audio).  The resampling is awkward, though,
37 as you really need one resampler per source.  So it might make more sense
38 to put stuff in the decoder.  But then, what's one map of resamplers between friends?
39
40
41
42 \end{document}