Remove svn $Id$ header.
[platform/upstream/libvorbis.git] / doc / 07-floor1.tex
index c431a94..47ad798 100644 (file)
@@ -1,6 +1,5 @@
 % -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*-
 %!TEX root = Vorbis_I_spec.tex
-% $Id$
 \section{Floor type 1 setup and decode} \label{vorbis:spec:floor1}
 
 \subsection{Overview}
@@ -160,11 +159,14 @@ configuration during setup renders a stream undecodable.  In addition,
 a \varname{[floor1\_class\_masterbooks]} or
 \varname{[floor1\_subclass\_books]} scalar element greater than the
 highest numbered codebook configured in this stream is an error
-condition that renders the stream undecodable.  All vector
-[floor1\_x\_list] element values must be unique within the vector; a
-non-unique value renders the stream undecodable.
+condition that renders the stream undecodable.  Vector
+[floor1\_x\_list] is limited to a maximum length of 65 elements; a
+setup indicating more than 65 total elements (including elements 0 and
+1 set prior to the read loop) renders the stream undecodable.  All
+vector [floor1\_x\_list] element values must be unique within the
+vector; a non-unique value renders the stream undecodable.
 
-\paragraph{packet decode} \label{vorbis:spec:floor1-decode}
+\subsubsection{packet decode} \label{vorbis:spec:floor1-decode}
 
 Packet decode begins by checking the \varname{[nonzero]} flag:
 
@@ -234,7 +236,7 @@ needed for floor 1 synthesis.
 
 
 
-\paragraph{curve computation} \label{vorbis:spec:floor1-synth}
+\subsubsection{curve computation} \label{vorbis:spec:floor1-synth}
 
 Curve computation is split into two logical steps; the first step
 derives final Y amplitude values from the encoded, wrapped difference
@@ -249,6 +251,16 @@ optimizations, implementors are warned to follow the details closely.
 Deviation from implementing a strictly equivalent algorithm can result
 in serious decoding errors.
 
+{\em Additional note:} Although \varname{[floor1\_final\_Y]} values in
+the prediction loop and at the end of step 1 are inherently limited by
+the prediction algorithm to [0, \varname{[range]}), it is possible to
+  abuse the setup and codebook machinery to produce negative or
+  over-range results.  We suggest that decoder implementations guard
+  the values in vector \varname{[floor1\_final\_Y]} by clamping each
+  element to [0, \varname{[range]}) after step 1.  Variants of this
+    suggestion are acceptable as valid floor1 setups cannot produce
+    out of range values.
+
 \begin{description}
 \item[step 1: amplitude value synthesis]
 
@@ -304,7 +316,7 @@ Unwrap the always-positive-or-zero values read from the packet into
 
                 \} else [val] is less than [room] \{
 
-                 24) if ([val] is odd) \{
+                    24) if ([val] is odd) \{
 
                         25) vector [floor1\_final\_Y] element [i] =
                             [predicted] - (([val] + 1) divided by  2 using integer division)