Include a pre-rendered pdf version
[dirac-spec-errata.git] / sequence-dec.tex
blob79d1b9ddacc27ab3e8ae592f964a1591a3a5ab26
1 \label{sequencedecoding}
3 There is no one unique way of describing a Dirac decoder. However the pseudocode
4 below is illustrative code for a sample decoder. It emphasizes which parts of the decoding
5 process generate decoded output data. Note that the potential presence of padding or auxiliary data is ignored for clarity.
7 \begin{pseudo}{decode\_sequence}{}
8 \bsCODE{\StateName=\{\}}
9 \bsCODE{decoded\_pictures = \{\}}
10 \bsCODE{\RefBuffer=\{\}}
11 \bsCODE{parse\_info()}{\ref{parseinfoheader}}
12 \bsCODE{\VideoParams = sequence\_header()}{\ref{sequenceheader}}
13 \bsCODE{parse\_info()}{\ref{parseinfoheader}}
14 \bsWHILE{is\_end\_of\_sequence() == \false}{\ref{parsecodevalues}}
15 \bsIF{is\_seq\_header()==\true}{\ref{parsecodevalues}}
16 \bsCODE{\VideoParams = sequence\_header()}{\ref{sequenceheader}}
17 \bsELSEIF{is\_picture()==\true}{\ref{parsecodevalues}}
18 \bsCODE{picture\_parse()}{\ref{pictureparse}}
19 \bsCODE{decoded\_pictures[\PictureNumber] = picture\_decode()}{\ref{picturedec}}
20 \bsEND
21 \bsCODE{parse\_info()}{\ref{parseinfoheader}}
22 \bsEND
23 \bsRET{\{\VideoParams, decoded\_pictures\}}
24 \end{pseudo}
26 The process returns the video parameters, consisting of the essential metadata required for
27 display and interpretation of the video data, and the array of decoded pictures. Each decoded picture contains the three video component data arrays together with a picture number.
29 The pseudocode describes the decoding process. Decoding starts by clearing the
30 decoder state and the decoder output. Thus video sequences may be decoded as independent entities. The first data extracted from the Dirac stream is parse information. The parse info header indicates what type of data unit follows, and this information is stored in the decoder state. The decoder continues to read pairs of data unit and parse info
31 headers until the end of the sequence is reached. The end of sequence
32 is indicated by data in the final parse info header. If a data unit is a sequence header the
33 decoded video parameters are updated with the information contained in the header. If the
34 data unit is a picture then:
35 \begin{itemize}
36 \item the picture is parsed, then decoded
37 \item the picture is placed in the correct position in the output array
38 \end{itemize}
40 Note that since Dirac supports inter as well as intra picture coding, picture numbers
41 within the stream may not be sequential, and the decoded output pictures will not be
42 placed in the output buffer in order. Annex \ref{profilelevel} defines the constraints
43 which may be placed upon re-ordering depth.
45 Sequences need not be decoded from the start: decoding can start from any sequence header
46 according to the provisions of Section~\ref{randomaccess}, although some pictures might
47 not be (completely) decodeable due to a chain of references reaching back earlier in the stream
48 than the sequence header, introducing dependencies on unavailable pictures.
49 The behaviour of a decoder when confronted with such pictures is application-specific.
51 \subsection{Non-sequential picture decoding}
52 \label{nonsequential}
53 The ability to decode pictures in a non-sequential manner is important for many
54 applications, such as video editing. Non-sequential access means decoding a
55 stream in any manner other than decoding pictures sequentially from the beginning
56 of the stream to the end: this may include decoding only intra pictures, decoding backwards, or decoding pictures in random parts of the stream.
58 Stream navigation, including non-sequential access is supported by the information
59 in the parse info headers in the stream (Section~\ref{parseinfoheader}).
61 In order to start decoding, other than at the start of a sequence, the decoder
62 must first synchronize to the stream. The parse info prefix is present to support such synchronization. A decoder would first search for the parse info prefix to locate
63 the start of a parse info header. The parse info prefix is not guaranteed to occur
64 uniquely within parse info headers (the entropy coding used in
65 Dirac precludes this). However, the probability of a spurious
66 prefix occuring is low: 1 in $2^{32}$, since the prefix is 4 bytes long. The probability of finding
67 two spurious prefix sequences separated by the value of the next (or previous) parse
68 offset is 1 in $2^{64}$.
70 Having synchronized with the stream the decoder now needs to locate a sequence header
71 in order to find parameters needed to decode pictures. This may be done by moving back (or forward) through the stream, using the parse offsets.
73 The Dirac stream also supports seeking to a particular picture number, since this
74 is contained in each picture header.