~ubuntu-branches/ubuntu/intrepid/libtheora/intrepid

« back to all changes in this revision

Viewing changes to doc/spec/spec.tex

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2008-04-23 14:08:37 UTC
  • mfrom: (1.1.6 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080423140837-t981xtgv43carzk8
Tags: 1.0~beta3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3112
3112
 
3113
3113
\begin{enumerate}
3114
3114
\item
3115
 
For each consecutive value of \locvar{\hti} from $0$ to $80$, inclusive:
 
3115
For each consecutive value of \locvar{\hti} from $0$ to $79$, inclusive:
3116
3116
\begin{enumerate}
3117
3117
\item
3118
3118
Set \locvar{HBITS} to the empty string.
3750
3750
 block. \\
3751
3751
\locvar{\bi}       & Integer & 36 & No & The index of the current block in
3752
3752
 coded order. \\
3753
 
\locvar{\mi}       & Integer & 32 & No & The index of a Huffman code from
 
3753
\locvar{\mi}       & Integer &  3 & No & The index of a Huffman code from
3754
3754
 Table~\ref{tab:mode-codes}, starting from $0$. \\
3755
3755
\bottomrule\end{tabularx}
3756
3756
\medskip
3775
3775
$7$   & INTER\_MV\_FOUR     \\
3776
3776
\bottomrule\end{tabular}
3777
3777
\end{center}
3778
 
\caption{Coding Modes}
 
3778
\caption{Macro Block Coding Modes}
3779
3779
\label{tab:coding-modes}
3780
3780
\end{table}
3781
3781
 
3795
3795
 
3796
3796
\begin{table}[htbp]
3797
3797
\begin{center}
3798
 
\begin{tabular}{lcccccc}\toprule
3799
 
Scheme        & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ \\\cmidrule{2-7}
3800
 
Huffman Code  & \multicolumn{6}{c}{Coding Mode}   \\\midrule
3801
 
\bin{0}       & $3$ & $3$ & $3$ & $3$ & $0$ & $0$ \\
3802
 
\bin{10}      & $4$ & $4$ & $2$ & $2$ & $3$ & $5$ \\
3803
 
\bin{110}     & $2$ & $0$ & $4$ & $0$ & $4$ & $3$ \\
3804
 
\bin{1110}    & $0$ & $2$ & $0$ & $4$ & $2$ & $4$ \\
3805
 
\bin{11110}   & $1$ & $1$ & $1$ & $1$ & $1$ & $2$ \\
3806
 
\bin{111110}  & $5$ & $5$ & $5$ & $5$ & $5$ & $1$ \\
3807
 
\bin{1111110} & $6$ & $6$ & $6$ & $6$ & $6$ & $6$ \\
3808
 
\bin{1111111} & $7$ & $7$ & $7$ & $7$ & $7$ & $7$ \\
 
3798
\begin{tabular}{lccccccc}\toprule
 
3799
Scheme        & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\\cmidrule{2-7}
 
3800
Huffman Code  & \multicolumn{6}{c}{Coding Mode}   & \locvar{\mi} \\\midrule
 
3801
\bin{0}       & $3$ & $3$ & $3$ & $3$ & $0$ & $0$ & $0$ \\
 
3802
\bin{10}      & $4$ & $4$ & $2$ & $2$ & $3$ & $5$ & $1$ \\
 
3803
\bin{110}     & $2$ & $0$ & $4$ & $0$ & $4$ & $3$ & $2$ \\
 
3804
\bin{1110}    & $0$ & $2$ & $0$ & $4$ & $2$ & $4$ & $3$ \\
 
3805
\bin{11110}   & $1$ & $1$ & $1$ & $1$ & $1$ & $2$ & $4$ \\
 
3806
\bin{111110}  & $5$ & $5$ & $5$ & $5$ & $5$ & $1$ & $5$ \\
 
3807
\bin{1111110} & $6$ & $6$ & $6$ & $6$ & $6$ & $6$ & $6$ \\
 
3808
\bin{1111111} & $7$ & $7$ & $7$ & $7$ & $7$ & $7$ & $7$ \\
3809
3809
\bottomrule\end{tabular}
3810
3810
\end{center}
3811
 
\caption{Coding Modes}
 
3811
\caption{Macro Block Mode Schemes}
3812
3812
\label{tab:mode-codes}
3813
3813
\end{table}
3814
3814
 
3818
3818
\begin{enumerate}
3819
3819
\item
3820
3820
For each consecutive value of \locvar{\mbi} from 0 to $(\bitvar{NMBS}-1)$,
3821
 
 inclusive, assign $\bitvar{MBMODES}[\mbi]$ the value 0 (INTRA).
 
3821
 inclusive, assign $\bitvar{MBMODES}[\mbi]$ the value 1 (INTRA).
3822
3822
\end{enumerate}
3823
3823
\item
3824
3824
Otherwise (inter frame):
3856
3856
 $\locvar{MALPHABET}[\locvar{\mi}]$, where \locvar{\mi} is the index of the
3857
3857
 Huffman code decoded.
3858
3858
\item
3859
 
Otherwise, if no luma-plane blocks in the macro block are coded, read a 3-bit
3860
 
 unsigned integer as $\bitvar{MBMODES}[\locvar{\mbi}]$.
 
3859
Otherwise, read a 3-bit unsigned integer as $\bitvar{MBMODES}[\locvar{\mbi}]$.
3861
3860
\end{enumerate}
3862
3861
\item
3863
 
Otherwise, assign $\bitvar{MBMODE}[\locvar{\mbi}]$ the value 0 (INTER\_NOMV).
 
3862
Otherwise, if no luma-plane blocks in the macro block are coded, assign
 
3863
 $\bitvar{MBMODES}[\locvar{\mbi}]$ the value 0 (INTER\_NOMV).
3864
3864
\end{enumerate}
3865
3865
\end{enumerate}
3866
3866
\end{enumerate}
4138
4138
Thus, \locvar{A} is the index in coded order of the block in the lower left,
4139
4139
 \locvar{B} the lower right, \locvar{C} the upper left, and \locvar{D} the
4140
4140
 upper right. % TODO: as shown in Figure~REF.
4141
 
\item
4142
 
If $\bitvar{BCODED}[\locvar{A}]$ is non-zero, decode a single motion vector
4143
 
 into \locvar{MVX} and \locvar{MVY} using the procedure described in
4144
 
 Section~\ref{sub:mv-decode}.
4145
 
\item
4146
 
Otherwise, assign \locvar{MVX} and \locvar{MVY} both the value zero.
4147
 
\item
4148
 
Assign $\bitvar{MVECTS}[\locvar{A}]$ the value $(\locvar{MVX},\locvar{MVY})$.
4149
 
\item
4150
 
If $\bitvar{BCODED}[\locvar{B}]$ is non-zero, decode a single motion vector
4151
 
 into \locvar{MVX} and \locvar{MVY} using the procedure described in
4152
 
 Section~\ref{sub:mv-decode}.
4153
 
\item
4154
 
Otherwise, assign \locvar{MVX} and \locvar{MVY} both the value zero.
4155
 
\item
4156
 
Assign $\bitvar{MVECTS}[\locvar{B}]$ the value $(\locvar{MVX},\locvar{MVY})$.
4157
 
\item
4158
 
If $\bitvar{BCODED}[\locvar{C}]$ is non-zero, decode a single motion vector
4159
 
 into \locvar{MVX} and \locvar{MVY} using the procedure described in
4160
 
 Section~\ref{sub:mv-decode}.
4161
 
\item
4162
 
Otherwise, assign \locvar{MVX} and \locvar{MVY} both the value zero.
4163
 
\item
4164
 
Assign $\bitvar{MVECTS}[\locvar{C}]$ the value $(\locvar{MVX},\locvar{MVY})$.
4165
 
\item
4166
 
If $\bitvar{BCODED}[\locvar{D}]$ is non-zero, decode a single motion vector
4167
 
 into \locvar{MVX} and \locvar{MVY} using the procedure described in
4168
 
 Section~\ref{sub:mv-decode}.
4169
 
\item
4170
 
Otherwise, assign \locvar{MVX} and \locvar{MVY} both the value zero.
4171
 
\item
4172
 
Assign $\bitvar{MVECTS}[\locvar{D}]$ the value $(\locvar{MVX},\locvar{MVY})$.
4173
 
Note that \locvar{MVX} and \locvar{MVY} retain this last value.
 
4141
\item If $\bitvar{BCODED}[\locvar{A}]$ is non-zero:
 
4142
\begin{enumerate}
 
4143
\item Decode a single motion vector into \locvar{MVX} and \locvar{MVY} using
 
4144
 the procedure described in Section~\ref{sub:mv-decode}.
 
4145
\item Assign $\bitvar{MVECTS}[\locvar{A}]$ the value
 
4146
 $(\locvar{MVX},\locvar{MVY})$.
 
4147
\end{enumerate}
 
4148
\item Otherwise, assign $\bitvar{MVECTS}[\locvar{A}]$ the value $(0,0)$.
 
4149
\item If $\bitvar{BCODED}[\locvar{B}]$ is non-zero:
 
4150
\begin{enumerate}
 
4151
\item Decode a single motion vector into \locvar{MVX} and \locvar{MVY} using
 
4152
 the procedure described in Section~\ref{sub:mv-decode}.
 
4153
\item Assign $\bitvar{MVECTS}[\locvar{B}]$ the value
 
4154
 $(\locvar{MVX},\locvar{MVY})$.
 
4155
\end{enumerate}
 
4156
\item
 
4157
Otherwise assign $\bitvar{MVECTS}[\locvar{B}]$ the value $(0,0)$.
 
4158
\item If $\bitvar{BCODED}[\locvar{C}]$ is non-zero:
 
4159
\begin{enumerate}
 
4160
\item Decode a single motion vector into \locvar{MVX} and \locvar{MVY} using
 
4161
 the procedure described in Section~\ref{sub:mv-decode}.
 
4162
\item Assign $\bitvar{MVECTS}[\locvar{C}]$ the value
 
4163
 $(\locvar{MVX},\locvar{MVY})$.
 
4164
\end{enumerate}
 
4165
\item Otherwise assign $\bitvar{MVECTS}[\locvar{C}]$ the value $(0,0)$.
 
4166
\item If $\bitvar{BCODED}[\locvar{D}]$ is non-zero:
 
4167
\begin{enumerate}
 
4168
\item Decode a single motion vector into \locvar{MVX} and \locvar{MVY} using
 
4169
 the procedure described in Section~\ref{sub:mv-decode}.
 
4170
\item Assign $\bitvar{MVECTS}[\locvar{D}]$ the value
 
4171
 $(\locvar{MVX},\locvar{MVY})$.
 
4172
\end{enumerate}
 
4173
\item
 
4174
Otherwise, assign $\bitvar{MVECTS}[\locvar{D}]$ the value $(0,0)$.
4174
4175
\item
4175
4176
If \bitvar{PF} is 0 (4:2:0):
4176
4177
\begin{enumerate}
4195
4196
If \bitvar{PF} is 2 (4:2:2):
4196
4197
\begin{enumerate}
4197
4198
\item
4198
 
Let \locvar{E} and \locvar{F} be the indices in coded order of the top and
4199
 
 bottom blocks in the macro block from the $C_b$ plane, respectively, and
4200
 
 \locvar{G} and \locvar{H} be the indices in coded order of the top and bottom
 
4199
Let \locvar{E} and \locvar{F} be the indices in coded order of the bottom and
 
4200
 top blocks in the macro block from the $C_b$ plane, respectively, and
 
4201
 \locvar{G} and \locvar{H} be the indices in coded order of the bottom and top
4201
4202
 blocks in the $C_r$ plane, respectively. %TODO: as shown in Figure~REF.
4202
4203
\item
4203
4204
Assign $\bitvar{MVECTS}[\locvar{E}]$ and $\bitvar{MVECTS}[\locvar{G}]$ the
4204
4205
 value
4205
4206
\begin{multline*}
4206
4207
(\round\left(\frac{
4207
 
 \bitvar{MVECTS}[\locvar{A}]_x+\bitvar{MVECTS}[\locvar{B}]_x}{4}\right), \\
 
4208
 \bitvar{MVECTS}[\locvar{A}]_x+\bitvar{MVECTS}[\locvar{B}]_x}{2}\right), \\
4208
4209
 \round\left(\frac{
4209
 
 \bitvar{MVECTS}[\locvar{A}]_y+\bitvar{MVECTS}[\locvar{B}]_y}{4}\right))
 
4210
 \bitvar{MVECTS}[\locvar{A}]_y+\bitvar{MVECTS}[\locvar{B}]_y}{2}\right))
4210
4211
\end{multline*}
4211
4212
\item
4212
4213
Assign $\bitvar{MVECTS}[\locvar{F}]$ and $\bitvar{MVECTS}[\locvar{H}]$ the
4213
4214
 value
4214
4215
\begin{multline*}
4215
4216
(\round\left(\frac{
4216
 
 \bitvar{MVECTS}[\locvar{C}]_x+\bitvar{MVECTS}[\locvar{D}]_x}{4}\right), \\
 
4217
 \bitvar{MVECTS}[\locvar{C}]_x+\bitvar{MVECTS}[\locvar{D}]_x}{2}\right), \\
4217
4218
 \round\left(\frac{
4218
 
 \bitvar{MVECTS}[\locvar{C}]_y+\bitvar{MVECTS}[\locvar{D}]_y}{4}\right))
 
4219
 \bitvar{MVECTS}[\locvar{C}]_y+\bitvar{MVECTS}[\locvar{D}]_y}{2}\right))
4219
4220
\end{multline*}
4220
4221
\end{enumerate}
4221
4222
\item
4245
4246
Assign \locvar{LAST2} the value \locvar{LAST1}.
4246
4247
\item
4247
4248
Assign \locvar{LAST1} the value $(\locvar{MVX},\locvar{MVY})$.
 
4249
This is the value of the motion vector decoded from the last coded luma block
 
4250
 in raster order.
 
4251
There must always be at least one, since macro blocks with no coded luma blocks
 
4252
 must use mode 0:~INTER\_NOMV.
4248
4253
\end{enumerate}
4249
4254
\item
4250
4255
Otherwise, if $\bitvar{MBMODES}[\locvar{\mbi}]$ is 6 (INTER\_GOLDEN\_MV),
6206
6211
 
6207
6212
All intermediate values are truncated to a 32-bit signed representation by
6208
6213
 discarding any higher-order bits in their two's complement representation.
6209
 
The final output of each 1D transform is truncated to 16-bits in the same
6210
 
 manner.
 
6214
The final output of each 1D transform is truncated to a 16-bit signed value in
 
6215
 the same manner.
6211
6216
In practice, if the high word of a $16\times 16$ bit multiplication can be
6212
6217
 obtained directly, 16 bits is sufficient for every calculation except scaling
6213
6218
 by $C4$.
6214
 
Here we specify truncating to 16 bits before the multiplication to simplify
6215
 
 implementations using hardware or common SIMD instruction sets.
 
6219
Thus we truncate to 16 bits before that multiplication to allow an
 
6220
 implementation entirely in 16-bit registers.
 
6221
Implementations using larger registers must sign-extend the 16-bit value to
 
6222
 maintain compatibility.
6216
6223
 
6217
6224
Note that if 16-bit register are used, overflow in the additions and
6218
6225
 subtractions should be handled using \textit{unsaturated} arithmetic.
6333
6340
\item
6334
6341
Assign $\locvar{T}[0]$ the value $\bitvar{Y}[0]+\bitvar{Y}[4]$.
6335
6342
\item
6336
 
Truncate $\locvar{T}[0]$ to a 16-bit representation by dropping any
 
6343
Truncate $\locvar{T}[0]$ to a 16-bit signed representation by dropping any
6337
6344
 higher-order bits.
6338
6345
\item
6339
6346
Assign $\locvar{T}[0]$ the value
6341
6348
\item
6342
6349
Assign $\locvar{T}[1]$ the value $\bitvar{Y}[0]-\bitvar{Y}[4]$.
6343
6350
\item
6344
 
Truncate $\locvar{T}[1]$ to a 16-bit representation by dropping any
 
6351
Truncate $\locvar{T}[1]$ to a 16-bit signed representation by dropping any
6345
6352
 higher-order bits.
6346
6353
\item
6347
6354
Assign $\locvar{T}[1]$ the value $\locvar{C4}*\locvar{T}[1]>>16$.
6368
6375
\item
6369
6376
Assign $\locvar{T}[5]$ the value $\locvar{T}[4]-\locvar{T}[5]$.
6370
6377
\item
6371
 
Truncate $\locvar{T}[5]$ to a 16-bit representation by dropping any
 
6378
Truncate $\locvar{T}[5]$ to a 16-bit signed representation by dropping any
6372
6379
 higher-order bits.
6373
6380
\item
6374
 
Assign $\locvar{T}[5]$ the value $\locvar{C4}*(-\locvar{T}[5])>>16$.
 
6381
Assign $\locvar{T}[5]$ the value $\locvar{C4}*\locvar{T}[5]>>16$.
6375
6382
\item
6376
6383
Assign $\locvar{T}[4]$ the value $\locvar{R}$.
6377
6384
\item
6379
6386
\item
6380
6387
Assign $\locvar{T}[6]$ the value $\locvar{T}[7]-\locvar{T}[6]$.
6381
6388
\item
6382
 
Truncate $\locvar{T}[6]$ to a 16-bit representation by dropping any
 
6389
Truncate $\locvar{T}[6]$ to a 16-bit signed representation by dropping any
6383
6390
 higher-order bits.
6384
6391
\item
6385
6392
Assign $\locvar{T}[6]$ the value $\locvar{C4}*\locvar{T}[6]>>16$.
6406
6413
\item
6407
6414
Assign \locvar{R} the value $\locvar{T}[0]+\locvar{T}[7]$.
6408
6415
\item
6409
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6410
 
 bits.
 
6416
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6417
 higher-order bits.
6411
6418
\item
6412
6419
Assign $\bitvar{X}[0]$ the value \locvar{R}.
6413
6420
\item
6414
6421
Assign \locvar{R} the value $\locvar{T}[1]+\locvar{T}[6]$.
6415
6422
\item
6416
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6417
 
 bits.
 
6423
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6424
 higher-order bits.
6418
6425
\item
6419
6426
Assign $\bitvar{X}[1]$ the value \locvar{R}.
6420
6427
\item
6421
6428
Assign \locvar{R} the value $\locvar{T}[2]+\locvar{T}[5]$.
6422
6429
\item
6423
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6424
 
 bits.
 
6430
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6431
 higher-order bits.
6425
6432
\item
6426
6433
Assign $\bitvar{X}[2]$ the value \locvar{R}.
6427
6434
\item
6428
6435
Assign \locvar{R} the value $\locvar{T}[3]+\locvar{T}[4]$.
6429
6436
\item
6430
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6431
 
 bits.
 
6437
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6438
 higher-order bits.
6432
6439
\item
6433
6440
Assign $\bitvar{X}[3]$ the value \locvar{R}.
6434
6441
\item
6435
6442
Assign \locvar{R} the value $\locvar{T}[3]-\locvar{T}[4]$.
6436
6443
\item
6437
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6438
 
 bits.
 
6444
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6445
 higher-order bits.
6439
6446
\item
6440
6447
Assign $\bitvar{X}[4]$ the value \locvar{R}.
6441
6448
\item
6442
6449
Assign \locvar{R} the value $\locvar{T}[2]-\locvar{T}[5]$.
6443
6450
\item
6444
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6445
 
 bits.
 
6451
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6452
 higher-order bits.
6446
6453
\item
6447
6454
Assign $\bitvar{X}[5]$ the value \locvar{R}.
6448
6455
\item
6449
 
Assign \locvar{X} the value $\locvar{T}[1]-\locvar{T}[6]$.
 
6456
Assign \locvar{R} the value $\locvar{T}[1]-\locvar{T}[6]$.
6450
6457
\item
6451
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6452
 
 bits.
 
6458
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6459
 higher-order bits.
6453
6460
\item
6454
6461
Assign $\bitvar{X}[6]$ the value \locvar{R}.
6455
6462
\item
6456
6463
Assign \locvar{R} the value $\locvar{T}[0]-\locvar{T}[7]$.
6457
6464
\item
6458
 
Truncate \locvar{R} to a 16-bit representation by dropping any higher-order
6459
 
 bits.
 
6465
Truncate \locvar{R} to a 16-bit signed representation by dropping any
 
6466
 higher-order bits.
6460
6467
\item
6461
6468
Assign $\bitvar{X}[7]$ the value \locvar{R}.
6462
6469
\end{enumerate}
7017
7024
 (\bitvar{COEFFS}[\bitvar{\bi}][0]*\locvar{QMAT}[0]+15)>>5.
7018
7025
\end{equation*}
7019
7026
\item
7020
 
Truncate \locvar{DC} to a 16-bit representation by dropping any higher-order
7021
 
 bits.
 
7027
Truncate \locvar{DC} to a 16-bit signed representation by dropping any
 
7028
 higher-order bits.
7022
7029
\item
7023
7030
For each value of \locvar{\idx{by}} from 0 to 7, and each value of
7024
7031
 \locvar{\idx{bx}} from 0 to 7, assign