Fill test disk partitions with random noise to expose more bugs.
[dcpomatic.git] / doc / design / gap_filling.tex
1 \documentclass{article}
2 \renewcommand{\c}[1]{\texttt{#1}}
3 \begin{document}
4
5 There are two sources of video gaps:
6
7 \begin{enumerate}
8 \item Discontiguous outputs from \c{FFmpegDecoder} --- it makes sense
9   to fix these when the frame after the gap is seen, as that's the
10   first time we know about the gap.  For example, it emits frame~1
11   then frame~3; when we see 3 we should emit 2 to fill the gap.
12 \item Periods where there is no video content --- these could be long,
13   so you can't just wait for the frame after the gap.
14 \end{enumerate}
15
16 Two solutions suggest themselves for the period of no video content:
17
18 \begin{enumerate}
19 \item Create `black' \c{Piece}s to act as dummy content and emit black
20   frames as required.
21 \item Fix it in \c{Player::pass()}.
22 \end{enumerate}
23
24 Dummy pieces feels like a nice solution but quite wordy as you need a
25 hierarchy of \c{Piece}s with virtual functions and so on.
26
27 If we can trust \c{Decoder::position()} we know the earliest time that
28 a decoder will emit data when it is next \c{pass()}ed.  If this is
29 more than one frame since the last video frame emitted we know we need
30 to emit a black frame.  This much seems straightforward.
31
32 Things appear to get harder with seeking.  There are two paths here:
33
34 \begin{enumerate}
35 \item Seeking into the middle of some video content.
36 \item Seeking into some empty space.
37 \end{enumerate}
38
39 and also differences between accurate and inaccurate seek.
40
41 Let's take them case-by-case:
42
43 \begin{enumerate}
44   \item \emph{Accurate seek into content} --- we should not fill
45     anything since the correct data will be generated, in time, by
46     \c{pass()}.
47   \item \emph{Accurate seek into space} --- we should fill up to the
48     earliest decoder position.
49   \item \emph{Inaccurate seek into content} --- we should not fill
50     anything since \c{pass()} will generate something at some
51     unknown time.
52   \item \emph{Inaccurate seek into space} --- we should fill up to
53     the earliest decoder position from the seek time.
54 \end{enumerate}
55
56 \end{document}