Merge master.
[dcpomatic.git] / doc / design / resampling.tex
1 \documentclass{article}
2 \usepackage{amsmath}
3 \begin{document}
4
5 Here is what resampling we need to do.  Content video is at $C_V$ fps, audio at $C_A$.  
6
7 \section{Easy case 1}
8
9 $C_V$ and $C_A$ are both DCI rates, e.g.\ if $C_V = 24$, $C_A = 48\times{}10^3$.
10
11 \medskip
12 \textbf{Nothing to do.}
13
14 \section{Easy case 2}
15
16 $C_V$ is a DCI rate, $C_A$ is not.  e.g.\ if $C_V = 24$, $C_A = 44.1\times{}10^3$.
17
18 \medskip
19 \textbf{Resample $C_A$ to the DCI rate.}
20
21 \section{Hard case 1}
22 \label{sec:hard1}
23
24 $C_V$ is not a DCI rate, $C_A$ is, e.g.\ if $C_V = 25$, $C_A =
25 48\times{}10^3$.  We will run the video at a nearby DCI rate $F_V$,
26 meaning that it will run faster or slower than it should.  We resample
27 the audio to $C_V C_A / F_V$ and mark it as $C_A$ so that it, too,
28 runs faster or slower by the corresponding factor.
29
30 e.g.\ if $C_V = 25$, $F_V = 24$ and $C_A = 48\times{}10^3$, we
31 resample audio to $25 * 48\times{}10^3 / 24 = 50\times{}10^3$.
32
33 \medskip
34 \textbf{Resample $C_A$ to $C_V C_A / F_V$}
35
36 \section{Hard case 2}
37
38 Neither $C_V$ nor $C_A$ is not a DCI rate, e.g.\ if $C_V = 25$, $C_A =
39 44.1\times{}10^3$.  We will run the video at a nearby DCI rate $F_V$,
40 meaning that it will run faster or slower than it should.  We first
41 resample the audio to a DCI rate $F_A$, then perform as with
42 Section~\ref{sec:hard1} above.
43
44 \medskip
45 \textbf{Resample $C_A$ to $C_V F_A / F_V$}
46
47
48 \section{The general case}
49
50 Given a DCP running at $F_V$ and $F_A$ and a piece of content at $C_V$
51 and $C_A$, resample the audio to $R_A$ where
52 \begin{align*}
53 R_A &= \frac{C_V F_A}{F_V}
54 \end{align*}
55
56 \end{document}