VirtualBox

source: vbox/trunk/src/libs/libvorbis-1.3.7/doc/Vorbis_I_spec.html@ 106129

Last change on this file since 106129 was 96468, checked in by vboxsync, 2 years ago

libs/libvorbis-1.3.7: Re-exporting, hopefully this time everything is there. bugref:10275

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 535.2 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3<html >
4<head><title>Vorbis I specification</title>
5<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)">
7<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)">
8<!-- html -->
9<meta name="src" content="Vorbis_I_spec.tex">
10<link rel="stylesheet" type="text/css" href="Vorbis_I_spec.css">
11</head><body
12>
13<div class="maketitle">
14
15
16
17
18<h2 class="titleHead">Vorbis I specification</h2>
19<div class="author" ><span
20class="cmr-17">Xiph.Org Foundation</span></div><br />
21<div class="date" ><span
22class="cmr-17">July 4, 2020</span></div>
23</div>
24<h3 class="likesectionHead"><a
25 id="x1-1000"></a>Contents</h3>
26<div class="tableofcontents">
27&#x00A0;<span class="sectionToc" >1 <a
28href="#x1-20001" id="QQ2-1-2">Introduction and Description</a></span>
29<br />&#x00A0;&#x00A0;<span class="subsectionToc" >1.1 <a
30href="#x1-30001.1" id="QQ2-1-3">Overview</a></span>
31<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.1.1 <a
32href="#x1-40001.1.1" id="QQ2-1-4">Application</a></span>
33<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.1.2 <a
34href="#x1-50001.1.2" id="QQ2-1-5">Classification</a></span>
35<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.1.3 <a
36href="#x1-60001.1.3" id="QQ2-1-6">Assumptions</a></span>
37<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.1.4 <a
38href="#x1-70001.1.4" id="QQ2-1-7">Codec Setup and Probability Model</a></span>
39<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.1.5 <a
40href="#x1-90001.1.5" id="QQ2-1-9">Format Specification</a></span>
41<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.1.6 <a
42href="#x1-100001.1.6" id="QQ2-1-10">Hardware Profile</a></span>
43<br />&#x00A0;&#x00A0;<span class="subsectionToc" >1.2 <a
44href="#x1-110001.2" id="QQ2-1-11">Decoder Configuration</a></span>
45<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.2.1 <a
46href="#x1-120001.2.1" id="QQ2-1-13">Global Config</a></span>
47<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.2.2 <a
48href="#x1-130001.2.2" id="QQ2-1-14">Mode</a></span>
49<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.2.3 <a
50href="#x1-140001.2.3" id="QQ2-1-15">Mapping</a></span>
51
52
53
54<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.2.4 <a
55href="#x1-150001.2.4" id="QQ2-1-16">Floor</a></span>
56<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.2.5 <a
57href="#x1-160001.2.5" id="QQ2-1-17">Residue</a></span>
58<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.2.6 <a
59href="#x1-170001.2.6" id="QQ2-1-18">Codebooks</a></span>
60<br />&#x00A0;&#x00A0;<span class="subsectionToc" >1.3 <a
61href="#x1-180001.3" id="QQ2-1-19">High-level Decode Process</a></span>
62<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.3.1 <a
63href="#x1-190001.3.1" id="QQ2-1-20">Decode Setup</a></span>
64<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >1.3.2 <a
65href="#x1-230001.3.2" id="QQ2-1-24">Decode Procedure</a></span>
66<br />&#x00A0;<span class="sectionToc" >2 <a
67href="#x1-360002" id="QQ2-1-39">Bitpacking Convention</a></span>
68<br />&#x00A0;&#x00A0;<span class="subsectionToc" >2.1 <a
69href="#x1-370002.1" id="QQ2-1-40">Overview</a></span>
70<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.1 <a
71href="#x1-380002.1.1" id="QQ2-1-41">octets, bytes and words</a></span>
72<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.2 <a
73href="#x1-390002.1.2" id="QQ2-1-42">bit order</a></span>
74<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.3 <a
75href="#x1-400002.1.3" id="QQ2-1-43">byte order</a></span>
76<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.4 <a
77href="#x1-410002.1.4" id="QQ2-1-44">coding bits into byte sequences</a></span>
78<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.5 <a
79href="#x1-420002.1.5" id="QQ2-1-45">signedness</a></span>
80<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.6 <a
81href="#x1-430002.1.6" id="QQ2-1-46">coding example</a></span>
82<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.7 <a
83href="#x1-440002.1.7" id="QQ2-1-47">decoding example</a></span>
84<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.8 <a
85href="#x1-450002.1.8" id="QQ2-1-48">end-of-packet alignment</a></span>
86<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >2.1.9 <a
87href="#x1-460002.1.9" id="QQ2-1-49">reading zero bits</a></span>
88<br />&#x00A0;<span class="sectionToc" >3 <a
89href="#x1-470003" id="QQ2-1-50">Probability Model and Codebooks</a></span>
90<br />&#x00A0;&#x00A0;<span class="subsectionToc" >3.1 <a
91href="#x1-480003.1" id="QQ2-1-51">Overview</a></span>
92<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >3.1.1 <a
93href="#x1-490003.1.1" id="QQ2-1-52">Bitwise operation</a></span>
94<br />&#x00A0;&#x00A0;<span class="subsectionToc" >3.2 <a
95href="#x1-500003.2" id="QQ2-1-53">Packed codebook format</a></span>
96<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >3.2.1 <a
97href="#x1-510003.2.1" id="QQ2-1-54">codebook decode</a></span>
98<br />&#x00A0;&#x00A0;<span class="subsectionToc" >3.3 <a
99href="#x1-580003.3" id="QQ2-1-63">Use of the codebook abstraction</a></span>
100<br />&#x00A0;<span class="sectionToc" >4 <a
101href="#x1-590004" id="QQ2-1-64">Codec Setup and Packet Decode</a></span>
102<br />&#x00A0;&#x00A0;<span class="subsectionToc" >4.1 <a
103href="#x1-600004.1" id="QQ2-1-65">Overview</a></span>
104<br />&#x00A0;&#x00A0;<span class="subsectionToc" >4.2 <a
105href="#x1-610004.2" id="QQ2-1-66">Header decode and decode setup</a></span>
106<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.2.1 <a
107href="#x1-620004.2.1" id="QQ2-1-67">Common header decode</a></span>
108<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.2.2 <a
109href="#x1-630004.2.2" id="QQ2-1-68">Identification header</a></span>
110<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.2.3 <a
111href="#x1-640004.2.3" id="QQ2-1-69">Comment header</a></span>
112
113
114
115<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.2.4 <a
116href="#x1-650004.2.4" id="QQ2-1-70">Setup header</a></span>
117<br />&#x00A0;&#x00A0;<span class="subsectionToc" >4.3 <a
118href="#x1-720004.3" id="QQ2-1-78">Audio packet decode and synthesis</a></span>
119<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.1 <a
120href="#x1-730004.3.1" id="QQ2-1-79">packet type, mode and window decode</a></span>
121<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.2 <a
122href="#x1-740004.3.2" id="QQ2-1-80">floor curve decode</a></span>
123<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.3 <a
124href="#x1-750004.3.3" id="QQ2-1-81">nonzero vector propagate</a></span>
125<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.4 <a
126href="#x1-760004.3.4" id="QQ2-1-82">residue decode</a></span>
127<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.5 <a
128href="#x1-770004.3.5" id="QQ2-1-83">inverse coupling</a></span>
129<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.6 <a
130href="#x1-780004.3.6" id="QQ2-1-84">dot product</a></span>
131<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.7 <a
132href="#x1-790004.3.7" id="QQ2-1-85">inverse MDCT</a></span>
133<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.8 <a
134href="#x1-800004.3.8" id="QQ2-1-86">overlap_add</a></span>
135<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >4.3.9 <a
136href="#x1-810004.3.9" id="QQ2-1-87">output channel order</a></span>
137<br />&#x00A0;<span class="sectionToc" >5 <a
138href="#x1-820005" id="QQ2-1-88">comment field and header specification</a></span>
139<br />&#x00A0;&#x00A0;<span class="subsectionToc" >5.1 <a
140href="#x1-830005.1" id="QQ2-1-89">Overview</a></span>
141<br />&#x00A0;&#x00A0;<span class="subsectionToc" >5.2 <a
142href="#x1-840005.2" id="QQ2-1-90">Comment encoding</a></span>
143<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >5.2.1 <a
144href="#x1-850005.2.1" id="QQ2-1-91">Structure</a></span>
145<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >5.2.2 <a
146href="#x1-860005.2.2" id="QQ2-1-92">Content vector format</a></span>
147<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >5.2.3 <a
148href="#x1-890005.2.3" id="QQ2-1-95">Encoding</a></span>
149<br />&#x00A0;<span class="sectionToc" >6 <a
150href="#x1-900006" id="QQ2-1-96">Floor type 0 setup and decode</a></span>
151<br />&#x00A0;&#x00A0;<span class="subsectionToc" >6.1 <a
152href="#x1-910006.1" id="QQ2-1-97">Overview</a></span>
153<br />&#x00A0;&#x00A0;<span class="subsectionToc" >6.2 <a
154href="#x1-920006.2" id="QQ2-1-98">Floor 0 format</a></span>
155<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >6.2.1 <a
156href="#x1-930006.2.1" id="QQ2-1-99">header decode</a></span>
157<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >6.2.2 <a
158href="#x1-940006.2.2" id="QQ2-1-100">packet decode</a></span>
159<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >6.2.3 <a
160href="#x1-950006.2.3" id="QQ2-1-101">curve computation</a></span>
161<br />&#x00A0;<span class="sectionToc" >7 <a
162href="#x1-970007" id="QQ2-1-103">Floor type 1 setup and decode</a></span>
163<br />&#x00A0;&#x00A0;<span class="subsectionToc" >7.1 <a
164href="#x1-980007.1" id="QQ2-1-104">Overview</a></span>
165<br />&#x00A0;&#x00A0;<span class="subsectionToc" >7.2 <a
166href="#x1-990007.2" id="QQ2-1-105">Floor 1 format</a></span>
167<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >7.2.1 <a
168href="#x1-1000007.2.1" id="QQ2-1-106">model</a></span>
169<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >7.2.2 <a
170href="#x1-1010007.2.2" id="QQ2-1-111">header decode</a></span>
171<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >7.2.3 <a
172href="#x1-1020007.2.3" id="QQ2-1-112">packet decode</a></span>
173
174
175
176<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >7.2.4 <a
177href="#x1-1030007.2.4" id="QQ2-1-113">curve computation</a></span>
178<br />&#x00A0;<span class="sectionToc" >8 <a
179href="#x1-1040008" id="QQ2-1-114">Residue setup and decode</a></span>
180<br />&#x00A0;&#x00A0;<span class="subsectionToc" >8.1 <a
181href="#x1-1050008.1" id="QQ2-1-115">Overview</a></span>
182<br />&#x00A0;&#x00A0;<span class="subsectionToc" >8.2 <a
183href="#x1-1060008.2" id="QQ2-1-116">Residue format</a></span>
184<br />&#x00A0;&#x00A0;<span class="subsectionToc" >8.3 <a
185href="#x1-1070008.3" id="QQ2-1-118">residue 0</a></span>
186<br />&#x00A0;&#x00A0;<span class="subsectionToc" >8.4 <a
187href="#x1-1080008.4" id="QQ2-1-119">residue 1</a></span>
188<br />&#x00A0;&#x00A0;<span class="subsectionToc" >8.5 <a
189href="#x1-1090008.5" id="QQ2-1-120">residue 2</a></span>
190<br />&#x00A0;&#x00A0;<span class="subsectionToc" >8.6 <a
191href="#x1-1100008.6" id="QQ2-1-122">Residue decode</a></span>
192<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >8.6.1 <a
193href="#x1-1110008.6.1" id="QQ2-1-123">header decode</a></span>
194<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >8.6.2 <a
195href="#x1-1120008.6.2" id="QQ2-1-124">packet decode</a></span>
196<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >8.6.3 <a
197href="#x1-1130008.6.3" id="QQ2-1-125">format 0 specifics</a></span>
198<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >8.6.4 <a
199href="#x1-1140008.6.4" id="QQ2-1-126">format 1 specifics</a></span>
200<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >8.6.5 <a
201href="#x1-1150008.6.5" id="QQ2-1-127">format 2 specifics</a></span>
202<br />&#x00A0;<span class="sectionToc" >9 <a
203href="#x1-1160009" id="QQ2-1-128">Helper equations</a></span>
204<br />&#x00A0;&#x00A0;<span class="subsectionToc" >9.1 <a
205href="#x1-1170009.1" id="QQ2-1-129">Overview</a></span>
206<br />&#x00A0;&#x00A0;<span class="subsectionToc" >9.2 <a
207href="#x1-1180009.2" id="QQ2-1-130">Functions</a></span>
208<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >9.2.1 <a
209href="#x1-1190009.2.1" id="QQ2-1-131">ilog</a></span>
210<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >9.2.2 <a
211href="#x1-1200009.2.2" id="QQ2-1-132">float32_unpack</a></span>
212<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >9.2.3 <a
213href="#x1-1210009.2.3" id="QQ2-1-133">lookup1_values</a></span>
214<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >9.2.4 <a
215href="#x1-1220009.2.4" id="QQ2-1-134">low_neighbor</a></span>
216<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >9.2.5 <a
217href="#x1-1230009.2.5" id="QQ2-1-135">high_neighbor</a></span>
218<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >9.2.6 <a
219href="#x1-1240009.2.6" id="QQ2-1-136">render_point</a></span>
220<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >9.2.7 <a
221href="#x1-1250009.2.7" id="QQ2-1-137">render_line</a></span>
222<br />&#x00A0;<span class="sectionToc" >10 <a
223href="#x1-12600010" id="QQ2-1-138">Tables</a></span>
224<br />&#x00A0;&#x00A0;<span class="subsectionToc" >10.1 <a
225href="#x1-12700010.1" id="QQ2-1-139">floor1_inverse_dB_table</a></span>
226<br />&#x00A0;<span class="sectionToc" >A <a
227href="#x1-128000A" id="QQ2-1-140">Embedding Vorbis into an Ogg stream</a></span>
228<br />&#x00A0;&#x00A0;<span class="subsectionToc" >A.1 <a
229href="#x1-129000A.1" id="QQ2-1-141">Overview</a></span>
230<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >A.1.1 <a
231href="#x1-130000A.1.1" id="QQ2-1-142">Restrictions</a></span>
232<br />&#x00A0;&#x00A0;&#x00A0;<span class="subsubsectionToc" >A.1.2 <a
233href="#x1-131000A.1.2" id="QQ2-1-143">MIME type</a></span>
234
235
236
237<br />&#x00A0;&#x00A0;<span class="subsectionToc" >A.2 <a
238href="#x1-132000A.2" id="QQ2-1-144">Encapsulation</a></span>
239<br />&#x00A0;<span class="sectionToc" >B <a
240href="#x1-134000B" id="QQ2-1-146">Vorbis encapsulation in RTP</a></span>
241</div>
242
243
244
245<h3 class="sectionHead"><span class="titlemark">1. </span> <a
246 id="x1-20001"></a>Introduction and Description</h3>
247<!--l. 5--><p class="noindent" >
248<h4 class="subsectionHead"><span class="titlemark">1.1. </span> <a
249 id="x1-30001.1"></a>Overview</h4>
250<!--l. 7--><p class="noindent" >This document provides a high level description of the Vorbis codec&#8217;s construction. A bit-by-bit
251specification appears beginning in <a
252href="#x1-590004">section&#x00A0;4</a>, &#8220;<a
253href="#x1-590004">Codec Setup and Packet Decode<!--tex4ht:ref: vorbis:spec:codec --></a>&#8221;. The later
254sections assume a high-level understanding of the Vorbis decode process, which is provided
255here.
256<!--l. 14--><p class="noindent" >
257<h5 class="subsubsectionHead"><span class="titlemark">1.1.1. </span> <a
258 id="x1-40001.1.1"></a>Application</h5>
259<!--l. 15--><p class="noindent" >Vorbis is a general purpose perceptual audio CODEC intended to allow maximum encoder
260flexibility, thus allowing it to scale competitively over an exceptionally wide range of bitrates. At
261the high quality/bitrate end of the scale (CD or DAT rate stereo, 16/24 bits) it is in the same
262league as MPEG-2 and MPC. Similarly, the 1.0 encoder can encode high-quality CD and DAT
263rate stereo at below 48kbps without resampling to a lower rate. Vorbis is also intended for lower
264and higher sample rates (from 8kHz telephony to 192kHz digital masters) and a range of channel
265representations (monaural, polyphonic, stereo, quadraphonic, 5.1, ambisonic, or up to 255
266discrete channels).
267<!--l. 28--><p class="noindent" >
268<h5 class="subsubsectionHead"><span class="titlemark">1.1.2. </span> <a
269 id="x1-50001.1.2"></a>Classification</h5>
270<!--l. 29--><p class="noindent" >Vorbis I is a forward-adaptive monolithic transform CODEC based on the Modified Discrete
271Cosine Transform. The codec is structured to allow addition of a hybrid wavelet filterbank in
272Vorbis II to offer better transient response and reproduction using a transform better suited to
273localized time events.
274
275
276
277<!--l. 36--><p class="noindent" >
278<h5 class="subsubsectionHead"><span class="titlemark">1.1.3. </span> <a
279 id="x1-60001.1.3"></a>Assumptions</h5>
280<!--l. 38--><p class="noindent" >The Vorbis CODEC design assumes a complex, psychoacoustically-aware encoder and simple,
281low-complexity decoder. Vorbis decode is computationally simpler than mp3, although it does
282require more working memory as Vorbis has no static probability model; the vector codebooks
283used in the first stage of decoding from the bitstream are packed in their entirety into the Vorbis
284bitstream headers. In packed form, these codebooks occupy only a few kilobytes; the extent to
285which they are pre-decoded into a cache is the dominant factor in decoder memory
286usage.
287<!--l. 49--><p class="noindent" >Vorbis provides none of its own framing, synchronization or protection against errors; it
288is solely a method of accepting input audio, dividing it into individual frames and
289compressing these frames into raw, unformatted &#8217;packets&#8217;. The decoder then accepts
290these raw packets in sequence, decodes them, synthesizes audio frames from them, and
291reassembles the frames into a facsimile of the original audio stream. Vorbis is a free-form
292variable bit rate (VBR) codec and packets have no minimum size, maximum size, or
293fixed/expected size. Packets are designed that they may be truncated (or padded)
294and remain decodable; this is not to be considered an error condition and is used
295extensively in bitrate management in peeling. Both the transport mechanism and
296decoder must allow that a packet may be any size, or end before or after packet decode
297expects.
298<!--l. 63--><p class="noindent" >Vorbis packets are thus intended to be used with a transport mechanism that provides free-form
299framing, sync, positioning and error correction in accordance with these design assumptions, such
300as Ogg (for file transport) or RTP (for network multicast). For purposes of a few examples in this
301document, we will assume that Vorbis is to be embedded in an Ogg stream specifically,
302although this is by no means a requirement or fundamental assumption in the Vorbis
303design.
304<!--l. 71--><p class="noindent" >The specification for embedding Vorbis into an Ogg transport stream is in <a
305href="#x1-128000A">section&#x00A0;A</a>,
306&#8220;<a
307href="#x1-128000A">Embedding Vorbis into an Ogg stream<!--tex4ht:ref: vorbis:over:ogg --></a>&#8221;.
308<!--l. 76--><p class="noindent" >
309<h5 class="subsubsectionHead"><span class="titlemark">1.1.4. </span> <a
310 id="x1-70001.1.4"></a>Codec Setup and Probability Model</h5>
311<!--l. 78--><p class="noindent" >Vorbis&#8217; heritage is as a research CODEC and its current design reflects a desire to allow multiple
312decades of continuous encoder improvement before running out of room within the codec
313specification. For these reasons, configurable aspects of codec setup intentionally lean toward the
314extreme of forward adaptive.
315
316
317
318<!--l. 84--><p class="noindent" >The single most controversial design decision in Vorbis (and the most unusual for a Vorbis
319developer to keep in mind) is that the entire probability model of the codec, the Huffman and
320VQ codebooks, is packed into the bitstream header along with extensive CODEC setup
321parameters (often several hundred fields). This makes it impossible, as it would be with
322MPEG audio layers, to embed a simple frame type flag in each audio packet, or begin
323decode at any frame in the stream without having previously fetched the codec setup
324header.
325<!--l. 94--><p class="noindent" ><span class="likesubparagraphHead"><a
326 id="x1-80001.1.4"></a><span
327class="cmbx-12">Note:</span></span> Vorbis <span
328class="cmti-12">can </span>initiate decode at any arbitrary packet within a bitstream so long as the codec
329has been initialized/setup with the setup headers.
330<!--l. 100--><p class="noindent" >Thus, Vorbis headers are both required for decode to begin and relatively large as bitstream
331headers go. The header size is unbounded, although for streaming a rule-of-thumb of 4kB or less
332is recommended (and Xiph.Org&#8217;s Vorbis encoder follows this suggestion).
333<!--l. 105--><p class="noindent" >Our own design work indicates the primary liability of the required header is in mindshare; it is
334an unusual design and thus causes some amount of complaint among engineers as this runs
335against current design trends (and also points out limitations in some existing software/interface
336designs, such as Windows&#8217; ACM codec framework). However, we find that it does not
337fundamentally limit Vorbis&#8217; suitable application space.
338<!--l. 114--><p class="noindent" >
339<h5 class="subsubsectionHead"><span class="titlemark">1.1.5. </span> <a
340 id="x1-90001.1.5"></a>Format Specification</h5>
341<!--l. 115--><p class="noindent" >The Vorbis format is well-defined by its decode specification; any encoder that produces packets
342that are correctly decoded by the reference Vorbis decoder described below may be considered
343a proper Vorbis encoder. A decoder must faithfully and completely implement the
344specification defined below (except where noted) to be considered a proper Vorbis
345decoder.
346<!--l. 122--><p class="noindent" >
347<h5 class="subsubsectionHead"><span class="titlemark">1.1.6. </span> <a
348 id="x1-100001.1.6"></a>Hardware Profile</h5>
349
350
351
352<!--l. 123--><p class="noindent" >Although Vorbis decode is computationally simple, it may still run into specific limitations of an
353embedded design. For this reason, embedded designs are allowed to deviate in limited ways from
354the &#8216;full&#8217; decode specification yet still be certified compliant. These optional omissions are
355labelled in the spec where relevant.
356<!--l. 130--><p class="noindent" >
357<h4 class="subsectionHead"><span class="titlemark">1.2. </span> <a
358 id="x1-110001.2"></a>Decoder Configuration</h4>
359<!--l. 132--><p class="noindent" >Decoder setup consists of configuration of multiple, self-contained component abstractions that
360perform specific functions in the decode pipeline. Each different component instance of a specific
361type is semantically interchangeable; decoder configuration consists both of internal component
362configuration, as well as arrangement of specific instances into a decode pipeline. Componentry
363arrangement is roughly as follows:
364<div class="center"
365>
366<!--l. 140--><p class="noindent" >
367
368<!--l. 141--><p class="noindent" ><img
369src="components.png" alt="PIC"
370>
371<br /> <div class="caption"
372><span class="id">Figure&#x00A0;1: </span><span
373class="content">decoder pipeline configuration</span></div><!--tex4ht:label?: x1-110011 -->
374</div>
375<!--l. 145--><p class="noindent" >
376<h5 class="subsubsectionHead"><span class="titlemark">1.2.1. </span> <a
377 id="x1-120001.2.1"></a>Global Config</h5>
378<!--l. 146--><p class="noindent" >Global codec configuration consists of a few audio related fields (sample rate, channels), Vorbis
379version (always &#8217;0&#8217; in Vorbis I), bitrate hints, and the lists of component instances. All other
380configuration is in the context of specific components.
381<!--l. 151--><p class="noindent" >
382<h5 class="subsubsectionHead"><span class="titlemark">1.2.2. </span> <a
383 id="x1-130001.2.2"></a>Mode</h5>
384
385
386
387<!--l. 153--><p class="noindent" >Each Vorbis frame is coded according to a master &#8217;mode&#8217;. A bitstream may use one or many
388modes.
389<!--l. 156--><p class="noindent" >The mode mechanism is used to encode a frame according to one of multiple possible
390methods with the intention of choosing a method best suited to that frame. Different
391modes are, e.g. how frame size is changed from frame to frame. The mode number of a
392frame serves as a top level configuration switch for all other specific aspects of frame
393decode.
394<!--l. 163--><p class="noindent" >A &#8217;mode&#8217; configuration consists of a frame size setting, window type (always 0, the Vorbis
395window, in Vorbis I), transform type (always type 0, the MDCT, in Vorbis I) and a mapping
396number. The mapping number specifies which mapping configuration instance to use for low-level
397packet decode and synthesis.
398<!--l. 170--><p class="noindent" >
399<h5 class="subsubsectionHead"><span class="titlemark">1.2.3. </span> <a
400 id="x1-140001.2.3"></a>Mapping</h5>
401<!--l. 172--><p class="noindent" >A mapping contains a channel coupling description and a list of &#8217;submaps&#8217; that bundle sets
402of channel vectors together for grouped encoding and decoding. These submaps are
403not references to external components; the submap list is internal and specific to a
404mapping.
405<!--l. 177--><p class="noindent" >A &#8217;submap&#8217; is a configuration/grouping that applies to a subset of floor and residue vectors
406within a mapping. The submap functions as a last layer of indirection such that specific special
407floor or residue settings can be applied not only to all the vectors in a given mode, but also
408specific vectors in a specific mode. Each submap specifies the proper floor and residue
409instance number to use for decoding that submap&#8217;s spectral floor and spectral residue
410vectors.
411<!--l. 185--><p class="noindent" >As an example:
412<!--l. 187--><p class="noindent" >Assume a Vorbis stream that contains six channels in the standard 5.1 format. The sixth
413channel, as is normal in 5.1, is bass only. Therefore it would be wasteful to encode a
414full-spectrum version of it as with the other channels. The submapping mechanism can be used
415to apply a full range floor and residue encoding to channels 0 through 4, and a bass-only
416representation to the bass channel, thus saving space. In this example, channels 0-4 belong to
417submap 0 (which indicates use of a full-range floor) and channel 5 belongs to submap 1, which
418uses a bass-only representation.
419
420
421
422<!--l. 198--><p class="noindent" >
423<h5 class="subsubsectionHead"><span class="titlemark">1.2.4. </span> <a
424 id="x1-150001.2.4"></a>Floor</h5>
425<!--l. 200--><p class="noindent" >Vorbis encodes a spectral &#8217;floor&#8217; vector for each PCM channel. This vector is a low-resolution
426representation of the audio spectrum for the given channel in the current frame, generally used
427akin to a whitening filter. It is named a &#8217;floor&#8217; because the Xiph.Org reference encoder has
428historically used it as a unit-baseline for spectral resolution.
429<!--l. 207--><p class="noindent" >A floor encoding may be of two types. Floor 0 uses a packed LSP representation on a dB
430amplitude scale and Bark frequency scale. Floor 1 represents the curve as a piecewise linear
431interpolated representation on a dB amplitude scale and linear frequency scale. The two floors
432are semantically interchangeable in encoding/decoding. However, floor type 1 provides more
433stable inter-frame behavior, and so is the preferred choice in all coupled-stereo and
434high bitrate modes. Floor 1 is also considerably less expensive to decode than floor
4350.
436<!--l. 217--><p class="noindent" >Floor 0 is not to be considered deprecated, but it is of limited modern use. No known Vorbis
437encoder past Xiph.Org&#8217;s own beta 4 makes use of floor 0.
438<!--l. 221--><p class="noindent" >The values coded/decoded by a floor are both compactly formatted and make use of entropy
439coding to save space. For this reason, a floor configuration generally refers to multiple
440codebooks in the codebook component list. Entropy coding is thus provided as an
441abstraction, and each floor instance may choose from any and all available codebooks when
442coding/decoding.
443<!--l. 229--><p class="noindent" >
444<h5 class="subsubsectionHead"><span class="titlemark">1.2.5. </span> <a
445 id="x1-160001.2.5"></a>Residue</h5>
446<!--l. 230--><p class="noindent" >The spectral residue is the fine structure of the audio spectrum once the floor curve has been
447subtracted out. In simplest terms, it is coded in the bitstream using cascaded (multi-pass) vector
448quantization according to one of three specific packing/coding algorithms numbered
4490 through 2. The packing algorithm details are configured by residue instance. As
450with the floor components, the final VQ/entropy encoding is provided by external
451codebook instances and each residue instance may choose from any and all available
452codebooks.
453<!--l. 240--><p class="noindent" >
454
455
456
457<h5 class="subsubsectionHead"><span class="titlemark">1.2.6. </span> <a
458 id="x1-170001.2.6"></a>Codebooks</h5>
459<!--l. 242--><p class="noindent" >Codebooks are a self-contained abstraction that perform entropy decoding and, optionally, use
460the entropy-decoded integer value as an offset into an index of output value vectors, returning
461the indicated vector of values.
462<!--l. 247--><p class="noindent" >The entropy coding in a Vorbis I codebook is provided by a standard Huffman binary tree
463representation. This tree is tightly packed using one of several methods, depending on whether
464codeword lengths are ordered or unordered, or the tree is sparse.
465<!--l. 252--><p class="noindent" >The codebook vector index is similarly packed according to index characteristic. Most commonly,
466the vector index is encoded as a single list of values of possible values that are then permuted
467into a list of n-dimensional rows (lattice VQ).
468<!--l. 259--><p class="noindent" >
469<h4 class="subsectionHead"><span class="titlemark">1.3. </span> <a
470 id="x1-180001.3"></a>High-level Decode Process</h4>
471<!--l. 261--><p class="noindent" >
472<h5 class="subsubsectionHead"><span class="titlemark">1.3.1. </span> <a
473 id="x1-190001.3.1"></a>Decode Setup</h5>
474<!--l. 263--><p class="noindent" >Before decoding can begin, a decoder must initialize using the bitstream headers matching the
475stream to be decoded. Vorbis uses three header packets; all are required, in-order, by
476this specification. Once set up, decode may begin at any audio packet belonging to
477the Vorbis stream. In Vorbis I, all packets after the three initial headers are audio
478packets.
479<!--l. 270--><p class="noindent" >The header packets are, in order, the identification header, the comments header, and the setup
480header.
481<!--l. 273--><p class="noindent" ><span class="paragraphHead"><a
482 id="x1-200001.3.1"></a><span
483class="cmbx-12">Identification Header</span></span>
484The identification header identifies the bitstream as Vorbis, Vorbis version, and the simple audio
485characteristics of the stream such as sample rate and number of channels.
486
487
488
489<!--l. 278--><p class="noindent" ><span class="paragraphHead"><a
490 id="x1-210001.3.1"></a><span
491class="cmbx-12">Comment Header</span></span>
492The comment header includes user text comments (&#8220;tags&#8221;) and a vendor string for the
493application/library that produced the bitstream. The encoding and proper use of the comment
494header is described in <a
495href="#x1-820005">section&#x00A0;5</a>, &#8220;<a
496href="#x1-820005">comment field and header specification<!--tex4ht:ref: vorbis:spec:comment --></a>&#8221;.
497<!--l. 283--><p class="noindent" ><span class="paragraphHead"><a
498 id="x1-220001.3.1"></a><span
499class="cmbx-12">Setup Header</span></span>
500The setup header includes extensive CODEC setup information as well as the complete VQ and
501Huffman codebooks needed for decode.
502<!--l. 288--><p class="noindent" >
503<h5 class="subsubsectionHead"><span class="titlemark">1.3.2. </span> <a
504 id="x1-230001.3.2"></a>Decode Procedure</h5>
505<!--l. 290--><p class="noindent" >The decoding and synthesis procedure for all audio packets is fundamentally the same.
506 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
507 1. </dt><dd
508class="enumerate-enumitem">decode packet type flag
509 </dd><dt class="enumerate-enumitem">
510 2. </dt><dd
511class="enumerate-enumitem">decode mode number
512 </dd><dt class="enumerate-enumitem">
513 3. </dt><dd
514class="enumerate-enumitem">decode window shape (long windows only)
515 </dd><dt class="enumerate-enumitem">
516 4. </dt><dd
517class="enumerate-enumitem">decode floor
518 </dd><dt class="enumerate-enumitem">
519 5. </dt><dd
520class="enumerate-enumitem">decode residue into residue vectors
521 </dd><dt class="enumerate-enumitem">
522 6. </dt><dd
523class="enumerate-enumitem">inverse channel coupling of residue vectors
524 </dd><dt class="enumerate-enumitem">
525 7. </dt><dd
526class="enumerate-enumitem">generate floor curve from decoded floor data
527 </dd><dt class="enumerate-enumitem">
528 8. </dt><dd
529class="enumerate-enumitem">compute dot product of floor and residue, producing audio spectrum vector
530 </dd><dt class="enumerate-enumitem">
531 9. </dt><dd
532class="enumerate-enumitem">inverse monolithic transform of audio spectrum vector, always an MDCT in Vorbis
533 I
534
535
536
537 </dd><dt class="enumerate-enumitem">
538 10. </dt><dd
539class="enumerate-enumitem">overlap/add left-hand output of transform with right-hand output of previous frame
540 </dd><dt class="enumerate-enumitem">
541 11. </dt><dd
542class="enumerate-enumitem">store right hand-data from transform of current frame for future lapping
543 </dd><dt class="enumerate-enumitem">
544 12. </dt><dd
545class="enumerate-enumitem">if not first frame, return results of overlap/add as audio result of current frame</dd></dl>
546<!--l. 307--><p class="noindent" >Note that clever rearrangement of the synthesis arithmetic is possible; as an example, one can
547take advantage of symmetries in the MDCT to store the right-hand transform data of a partial
548MDCT for a 50% inter-frame buffer space savings, and then complete the transform later before
549overlap/add with the next frame. This optimization produces entirely equivalent output and is
550naturally perfectly legal. The decoder must be <span
551class="cmti-12">entirely mathematically equivalent </span>to the
552specification, it need not be a literal semantic implementation.
553<!--l. 316--><p class="noindent" ><span class="paragraphHead"><a
554 id="x1-240001.3.2"></a><span
555class="cmbx-12">Packet type decode</span></span>
556Vorbis I uses four packet types. The first three packet types mark each of the three Vorbis
557headers described above. The fourth packet type marks an audio packet. All other packet types
558are reserved; packets marked with a reserved type should be ignored.
559<!--l. 323--><p class="noindent" >Following the three header packets, all packets in a Vorbis I stream are audio. The first step of
560audio packet decode is to read and verify the packet type; <span
561class="cmti-12">a non-audio packet when audio is</span>
562<span
563class="cmti-12">expected indicates stream corruption or a non-compliant stream. The decoder must ignore the</span>
564<span
565class="cmti-12">packet and not attempt decoding it to audio</span>.
566<!--l. 333--><p class="noindent" ><span class="paragraphHead"><a
567 id="x1-250001.3.2"></a><span
568class="cmbx-12">Mode decode</span></span>
569Vorbis allows an encoder to set up multiple, numbered packet &#8217;modes&#8217;, as described earlier, all of
570which may be used in a given Vorbis stream. The mode is encoded as an integer used as a direct
571offset into the mode instance index.
572<!--l. 340--><p class="noindent" ><span class="paragraphHead"><a
573 id="x1-260001.3.2"></a><span
574class="cmbx-12">Window shape decode (long windows only)</span></span>
575Vorbis frames may be one of two PCM sample sizes specified during codec setup. In Vorbis I,
576legal frame sizes are powers of two from 64 to 8192 samples. Aside from coupling, Vorbis
577handles channels as independent vectors and these frame sizes are in samples per
578channel.
579
580
581
582<!--l. 347--><p class="noindent" >Vorbis uses an overlapping transform, namely the MDCT, to blend one frame into the next,
583avoiding most inter-frame block boundary artifacts. The MDCT output of one frame is windowed
584according to MDCT requirements, overlapped 50% with the output of the previous frame and
585added. The window shape assures seamless reconstruction.
586<!--l. 353--><p class="noindent" >This is easy to visualize in the case of equal sized-windows:
587<div class="center"
588>
589<!--l. 355--><p class="noindent" >
590
591<!--l. 356--><p class="noindent" ><img
592src="window1.png" alt="PIC"
593>
594<br /> <div class="caption"
595><span class="id">Figure&#x00A0;2: </span><span
596class="content">overlap of two equal-sized windows</span></div><!--tex4ht:label?: x1-260012 -->
597</div>
598<!--l. 360--><p class="noindent" >And slightly more complex in the case of overlapping unequal sized windows:
599<div class="center"
600>
601<!--l. 363--><p class="noindent" >
602
603<!--l. 364--><p class="noindent" ><img
604src="window2.png" alt="PIC"
605>
606<br /> <div class="caption"
607><span class="id">Figure&#x00A0;3: </span><span
608class="content">overlap of a long and a short window</span></div><!--tex4ht:label?: x1-260023 -->
609</div>
610<!--l. 368--><p class="noindent" >In the unequal-sized window case, the window shape of the long window must be modified for
611seamless lapping as above. It is possible to correctly infer window shape to be applied to the
612current window from knowing the sizes of the current, previous and next window. It is legal for a
613decoder to use this method. However, in the case of a long window (short windows require no
614modification), Vorbis also codes two flag bits to specify pre- and post- window shape. Although
615not strictly necessary for function, this minor redundancy allows a packet to be fully decoded to
616the point of lapping entirely independently of any other packet, allowing easier abstraction of
617decode layers as well as allowing a greater level of easy parallelism in encode and
618decode.
619<!--l. 381--><p class="noindent" >A description of valid window functions for use with an inverse MDCT can be found in <span class="cite">[<a
620href="#XSporer/Brandenburg/Edler">1</a>]</span>.
621Vorbis windows all use the slope function
622<center class="math-display" >
623<img
624src="Vorbis_I_spec0x.png" alt="y = sin (.5 * &#x03C0; sin2((x + .5)&#x2215;n * &#x03C0;)).
625
626
627
628" class="math-display" ></center>
629<!--l. 384--><p class="nopar" >
630<!--l. 388--><p class="noindent" ><span class="paragraphHead"><a
631 id="x1-270001.3.2"></a><span
632class="cmbx-12">floor decode</span></span>
633Each floor is encoded/decoded in channel order, however each floor belongs to a &#8217;submap&#8217; that
634specifies which floor configuration to use. All floors are decoded before residue decode
635begins.
636<!--l. 394--><p class="noindent" ><span class="paragraphHead"><a
637 id="x1-280001.3.2"></a><span
638class="cmbx-12">residue decode</span></span>
639Although the number of residue vectors equals the number of channels, channel coupling may
640mean that the raw residue vectors extracted during decode do not map directly to specific
641channels. When channel coupling is in use, some vectors will correspond to coupled magnitude or
642angle. The coupling relationships are described in the codec setup and may differ from frame to
643frame, due to different mode numbers.
644<!--l. 403--><p class="noindent" >Vorbis codes residue vectors in groups by submap; the coding is done in submap order from
645submap 0 through n-1. This differs from floors which are coded using a configuration provided by
646submap number, but are coded individually in channel order.
647<!--l. 410--><p class="noindent" ><span class="paragraphHead"><a
648 id="x1-290001.3.2"></a><span
649class="cmbx-12">inverse channel coupling</span></span>
650A detailed discussion of stereo in the Vorbis codec can be found in the document
651<a
652href="stereo.html" >Stereo Channel Coupling in the Vorbis CODEC</a>. Vorbis is not limited to only stereo
653coupling, but the stereo document also gives a good overview of the generic coupling
654mechanism.
655<!--l. 418--><p class="noindent" >Vorbis coupling applies to pairs of residue vectors at a time; decoupling is done in-place a
656pair at a time in the order and using the vectors specified in the current mapping
657configuration. The decoupling operation is the same for all pairs, converting square polar
658representation (where one vector is magnitude and the second angle) back to Cartesian
659representation.
660<!--l. 425--><p class="noindent" >After decoupling, in order, each pair of vectors on the coupling list, the resulting residue vectors
661represent the fine spectral detail of each output channel.
662
663
664
665<!--l. 431--><p class="noindent" ><span class="paragraphHead"><a
666 id="x1-300001.3.2"></a><span
667class="cmbx-12">generate floor curve</span></span>
668The decoder may choose to generate the floor curve at any appropriate time. It is reasonable to
669generate the output curve when the floor data is decoded from the raw packet, or it
670can be generated after inverse coupling and applied to the spectral residue directly,
671combining generation and the dot product into one step and eliminating some working
672space.
673<!--l. 440--><p class="noindent" >Both floor 0 and floor 1 generate a linear-range, linear-domain output vector to be multiplied
674(dot product) by the linear-range, linear-domain spectral residue.
675<!--l. 446--><p class="noindent" ><span class="paragraphHead"><a
676 id="x1-310001.3.2"></a><span
677class="cmbx-12">compute floor/residue dot product</span></span>
678This step is straightforward; for each output channel, the decoder multiplies the floor curve and
679residue vectors element by element, producing the finished audio spectrum of each
680channel.
681<!--l. 454--><p class="noindent" >One point is worth mentioning about this dot product; a common mistake in a fixed point
682implementation might be to assume that a 32 bit fixed-point representation for floor and
683residue and direct multiplication of the vectors is sufficient for acceptable spectral depth
684in all cases because it happens to mostly work with the current Xiph.Org reference
685encoder.
686<!--l. 461--><p class="noindent" >However, floor vector values can span <span
687class="cmsy-10x-x-120">~</span>140dB (<span
688class="cmsy-10x-x-120">~</span>24 bits unsigned), and the audio spectrum
689vector should represent a minimum of 120dB (<span
690class="cmsy-10x-x-120">~</span>21 bits with sign), even when output is to a 16
691bit PCM device. For the residue vector to represent full scale if the floor is nailed
692to <span
693class="cmsy-10x-x-120">-</span>140dB, it must be able to span 0 to +140dB. For the residue vector to reach
694full scale if the floor is nailed at 0dB, it must be able to represent <span
695class="cmsy-10x-x-120">-</span>140dB to +0dB.
696Thus, in order to handle full range dynamics, a residue vector may span <span
697class="cmsy-10x-x-120">-</span>140dB to
698+140dB entirely within spec. A 280dB range is approximately 48 bits with sign; thus the
699residue vector must be able to represent a 48 bit range and the dot product must
700be able to handle an effective 48 bit times 24 bit multiplication. This range may be
701achieved using large (64 bit or larger) integers, or implementing a movable binary point
702representation.
703<!--l. 478--><p class="noindent" ><span class="paragraphHead"><a
704 id="x1-320001.3.2"></a><span
705class="cmbx-12">inverse monolithic transform (MDCT)</span></span>
706The audio spectrum is converted back into time domain PCM audio via an inverse Modified
707Discrete Cosine Transform (MDCT). A detailed description of the MDCT is available in
708<span class="cite">[<a
709href="#XSporer/Brandenburg/Edler">1</a>]</span>.
710<!--l. 484--><p class="noindent" >Note that the PCM produced directly from the MDCT is not yet finished audio; it must be
711
712
713
714lapped with surrounding frames using an appropriate window (such as the Vorbis window) before
715the MDCT can be considered orthogonal.
716<!--l. 491--><p class="noindent" ><span class="paragraphHead"><a
717 id="x1-330001.3.2"></a><span
718class="cmbx-12">overlap/add data</span></span>
719Windowed MDCT output is overlapped and added with the right hand data of the previous
720window such that the 3/4 point of the previous window is aligned with the 1/4 point of the
721current window (as illustrated in the window overlap diagram). At this point, the audio data
722between the center of the previous frame and the center of the current frame is now finished and
723ready to be returned.
724<!--l. 500--><p class="noindent" ><span class="paragraphHead"><a
725 id="x1-340001.3.2"></a><span
726class="cmbx-12">cache right hand data</span></span>
727The decoder must cache the right hand portion of the current frame to be lapped with the left
728hand portion of the next frame.
729<!--l. 506--><p class="noindent" ><span class="paragraphHead"><a
730 id="x1-350001.3.2"></a><span
731class="cmbx-12">return finished audio data</span></span>
732The overlapped portion produced from overlapping the previous and current frame data
733is finished data to be returned by the decoder. This data spans from the center of
734the previous window to the center of the current window. In the case of same-sized
735windows, the amount of data to return is one-half block consisting of and only of the
736overlapped portions. When overlapping a short and long window, much of the returned
737range is not actually overlap. This does not damage transform orthogonality. Pay
738attention however to returning the correct data range; the amount of data to be returned
739is:
740<!--l. 518--><p class="noindent" >
741<div class="fancyvrb" id="fancyvrb1"><a
742 id="x1-35002r1"></a><span
743class="cmr-6">1</span><span
744class="cmtt-8">window</span><span
745class="cmtt-8">_blocksize(previous</span><span
746class="cmtt-8">_window)/4+window</span><span
747class="cmtt-8">_blocksize(current</span><span
748class="cmtt-8">_window)/4</span></div>
749<!--l. 522--><p class="noindent" >from the center of the previous window to the center of the current window.
750<!--l. 525--><p class="noindent" >Data is not returned from the first frame; it must be used to &#8217;prime&#8217; the decode engine. The
751encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper
752PCM output offset is &#8217;0&#8217; (as no data has been returned yet).
753
754
755
756
757
758
759<h3 class="sectionHead"><span class="titlemark">2. </span> <a
760 id="x1-360002"></a>Bitpacking Convention</h3>
761<!--l. 5--><p class="noindent" >
762<h4 class="subsectionHead"><span class="titlemark">2.1. </span> <a
763 id="x1-370002.1"></a>Overview</h4>
764<!--l. 7--><p class="noindent" >The Vorbis codec uses relatively unstructured raw packets containing arbitrary-width binary
765integer fields. Logically, these packets are a bitstream in which bits are coded one-by-one by the
766encoder and then read one-by-one in the same monotonically increasing order by the decoder.
767Most current binary storage arrangements group bits into a native word size of eight bits
768(octets), sixteen bits, thirty-two bits or, less commonly other fixed word sizes. The Vorbis
769bitpacking convention specifies the correct mapping of the logical packet bitstream into an actual
770representation in fixed-width words.
771<!--l. 18--><p class="noindent" >
772<h5 class="subsubsectionHead"><span class="titlemark">2.1.1. </span> <a
773 id="x1-380002.1.1"></a>octets, bytes and words</h5>
774<!--l. 20--><p class="noindent" >In most contemporary architectures, a &#8217;byte&#8217; is synonymous with an &#8217;octet&#8217;, that is, eight bits.
775This has not always been the case; seven, ten, eleven and sixteen bit &#8217;bytes&#8217; have been used.
776For purposes of the bitpacking convention, a byte implies the native, smallest integer
777storage representation offered by a platform. On modern platforms, this is generally
778assumed to be eight bits (not necessarily because of the processor but because of the
779filesystem/memory architecture. Modern filesystems invariably offer bytes as the fundamental
780atom of storage). A &#8217;word&#8217; is an integer size that is a grouped multiple of this smallest
781size.
782<!--l. 31--><p class="noindent" >The most ubiquitous architectures today consider a &#8217;byte&#8217; to be an octet (eight bits) and a word
783to be a group of two, four or eight bytes (16, 32 or 64 bits). Note however that the Vorbis
784bitpacking convention is still well defined for any native byte size; Vorbis uses the native
785bit-width of a given storage system. This document assumes that a byte is one octet for purposes
786of example.
787<!--l. 38--><p class="noindent" >
788
789
790
791<h5 class="subsubsectionHead"><span class="titlemark">2.1.2. </span> <a
792 id="x1-390002.1.2"></a>bit order</h5>
793<!--l. 40--><p class="noindent" >A byte has a well-defined &#8217;least significant&#8217; bit (LSb), which is the only bit set when the byte is
794storing the two&#8217;s complement integer value +1. A byte&#8217;s &#8217;most significant&#8217; bit (MSb) is at the
795opposite end of the byte. Bits in a byte are numbered from zero at the LSb to <span
796class="cmmi-12">n </span>(<span
797class="cmmi-12">n </span>= 7 in an
798octet) for the MSb.
799<!--l. 49--><p class="noindent" >
800<h5 class="subsubsectionHead"><span class="titlemark">2.1.3. </span> <a
801 id="x1-400002.1.3"></a>byte order</h5>
802<!--l. 51--><p class="noindent" >Words are native groupings of multiple bytes. Several byte orderings are possible in a word; the
803common ones are 3-2-1-0 (&#8217;big endian&#8217; or &#8217;most significant byte first&#8217; in which the
804highest-valued byte comes first), 0-1-2-3 (&#8217;little endian&#8217; or &#8217;least significant byte first&#8217; in
805which the lowest value byte comes first) and less commonly 3-1-2-0 and 0-2-1-3 (&#8217;mixed
806endian&#8217;).
807<!--l. 58--><p class="noindent" >The Vorbis bitpacking convention specifies storage and bitstream manipulation at the byte, not
808word, level, thus host word ordering is of a concern only during optimization when writing high
809performance code that operates on a word of storage at a time rather than by byte.
810Logically, bytes are always coded and decoded in order from byte zero through byte
811<span
812class="cmmi-12">n</span>.
813<!--l. 67--><p class="noindent" >
814<h5 class="subsubsectionHead"><span class="titlemark">2.1.4. </span> <a
815 id="x1-410002.1.4"></a>coding bits into byte sequences</h5>
816<!--l. 69--><p class="noindent" >The Vorbis codec has need to code arbitrary bit-width integers, from zero to 32 bits
817wide, into packets. These integer fields are not aligned to the boundaries of the byte
818representation; the next field is written at the bit position at which the previous field
819ends.
820<!--l. 74--><p class="noindent" >The encoder logically packs integers by writing the LSb of a binary integer to the logical
821bitstream first, followed by next least significant bit, etc, until the requested number of bits
822have been coded. When packing the bits into bytes, the encoder begins by placing
823the LSb of the integer to be written into the least significant unused bit position of
824the destination byte, followed by the next-least significant bit of the source integer
825and so on up to the requested number of bits. When all bits of the destination byte
826have been filled, encoding continues by zeroing all bits of the next byte and writing
827the next bit into the bit position 0 of that byte. Decoding follows the same process
828
829
830
831as encoding, but by reading bits from the byte stream and reassembling them into
832integers.
833<!--l. 89--><p class="noindent" >
834<h5 class="subsubsectionHead"><span class="titlemark">2.1.5. </span> <a
835 id="x1-420002.1.5"></a>signedness</h5>
836<!--l. 91--><p class="noindent" >The signedness of a specific number resulting from decode is to be interpreted by the decoder
837given decode context. That is, the three bit binary pattern &#8217;b111&#8217; can be taken to represent
838either &#8217;seven&#8217; as an unsigned integer, or &#8217;-1&#8217; as a signed, two&#8217;s complement integer. The
839encoder and decoder are responsible for knowing if fields are to be treated as signed or
840unsigned.
841<!--l. 100--><p class="noindent" >
842<h5 class="subsubsectionHead"><span class="titlemark">2.1.6. </span> <a
843 id="x1-430002.1.6"></a>coding example</h5>
844<!--l. 102--><p class="noindent" >Code the 4 bit integer value &#8217;12&#8217; [b1100] into an empty bytestream. Bytestream result:
845<!--l. 105--><p class="noindent" >
846<div class="fancyvrb" id="fancyvrb2"><a
847 id="x1-43002r1"></a><span
848class="cmr-6">1</span><span
849class="cmtt-8">&#x00A0;</span><span
850class="cmtt-8">&#x00A0;</span><span
851class="cmtt-8">&#x00A0;</span><span
852class="cmtt-8">&#x00A0;</span><span
853class="cmtt-8">&#x00A0;</span><span
854class="cmtt-8">&#x00A0;</span><span
855class="cmtt-8">&#x00A0;</span><span
856class="cmtt-8">&#x00A0;</span><span
857class="cmtt-8">&#x00A0;</span><span
858class="cmtt-8">&#x00A0;</span><span
859class="cmtt-8">&#x00A0;</span><span
860class="cmtt-8">&#x00A0;</span><span
861class="cmtt-8">&#x00A0;</span><span
862class="cmtt-8">&#x00A0;|</span><br class="fancyvrb" /><a
863 id="x1-43004r2"></a><span
864class="cmr-6">2</span><span
865class="cmtt-8">&#x00A0;</span><span
866class="cmtt-8">&#x00A0;</span><span
867class="cmtt-8">&#x00A0;</span><span
868class="cmtt-8">&#x00A0;</span><span
869class="cmtt-8">&#x00A0;</span><span
870class="cmtt-8">&#x00A0;</span><span
871class="cmtt-8">&#x00A0;</span><span
872class="cmtt-8">&#x00A0;</span><span
873class="cmtt-8">&#x00A0;</span><span
874class="cmtt-8">&#x00A0;</span><span
875class="cmtt-8">&#x00A0;</span><span
876class="cmtt-8">&#x00A0;</span><span
877class="cmtt-8">&#x00A0;</span><span
878class="cmtt-8">&#x00A0;V</span><br class="fancyvrb" /><a
879 id="x1-43006r3"></a><span
880class="cmr-6">3</span><br class="fancyvrb" /><a
881 id="x1-43008r4"></a><span
882class="cmr-6">4</span><span
883class="cmtt-8">&#x00A0;</span><span
884class="cmtt-8">&#x00A0;</span><span
885class="cmtt-8">&#x00A0;</span><span
886class="cmtt-8">&#x00A0;</span><span
887class="cmtt-8">&#x00A0;</span><span
888class="cmtt-8">&#x00A0;</span><span
889class="cmtt-8">&#x00A0;</span><span
890class="cmtt-8">&#x00A0;7</span><span
891class="cmtt-8">&#x00A0;6</span><span
892class="cmtt-8">&#x00A0;5</span><span
893class="cmtt-8">&#x00A0;4</span><span
894class="cmtt-8">&#x00A0;3</span><span
895class="cmtt-8">&#x00A0;2</span><span
896class="cmtt-8">&#x00A0;1</span><span
897class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
898 id="x1-43010r5"></a><span
899class="cmr-6">5</span><span
900class="cmtt-8">byte</span><span
901class="cmtt-8">&#x00A0;0</span><span
902class="cmtt-8">&#x00A0;[0</span><span
903class="cmtt-8">&#x00A0;0</span><span
904class="cmtt-8">&#x00A0;0</span><span
905class="cmtt-8">&#x00A0;0</span><span
906class="cmtt-8">&#x00A0;1</span><span
907class="cmtt-8">&#x00A0;1</span><span
908class="cmtt-8">&#x00A0;0</span><span
909class="cmtt-8">&#x00A0;0]</span><span
910class="cmtt-8">&#x00A0;</span><span
911class="cmtt-8">&#x00A0;&#x003C;-</span><br class="fancyvrb" /><a
912 id="x1-43012r6"></a><span
913class="cmr-6">6</span><span
914class="cmtt-8">byte</span><span
915class="cmtt-8">&#x00A0;1</span><span
916class="cmtt-8">&#x00A0;[</span><span
917class="cmtt-8">&#x00A0;</span><span
918class="cmtt-8">&#x00A0;</span><span
919class="cmtt-8">&#x00A0;</span><span
920class="cmtt-8">&#x00A0;</span><span
921class="cmtt-8">&#x00A0;</span><span
922class="cmtt-8">&#x00A0;</span><span
923class="cmtt-8">&#x00A0;</span><span
924class="cmtt-8">&#x00A0;</span><span
925class="cmtt-8">&#x00A0;</span><span
926class="cmtt-8">&#x00A0;</span><span
927class="cmtt-8">&#x00A0;</span><span
928class="cmtt-8">&#x00A0;</span><span
929class="cmtt-8">&#x00A0;</span><span
930class="cmtt-8">&#x00A0;</span><span
931class="cmtt-8">&#x00A0;]</span>
932<br class="fancyvrb" /><a
933 id="x1-43014r7"></a><span
934class="cmr-6">7</span><span
935class="cmtt-8">byte</span><span
936class="cmtt-8">&#x00A0;2</span><span
937class="cmtt-8">&#x00A0;[</span><span
938class="cmtt-8">&#x00A0;</span><span
939class="cmtt-8">&#x00A0;</span><span
940class="cmtt-8">&#x00A0;</span><span
941class="cmtt-8">&#x00A0;</span><span
942class="cmtt-8">&#x00A0;</span><span
943class="cmtt-8">&#x00A0;</span><span
944class="cmtt-8">&#x00A0;</span><span
945class="cmtt-8">&#x00A0;</span><span
946class="cmtt-8">&#x00A0;</span><span
947class="cmtt-8">&#x00A0;</span><span
948class="cmtt-8">&#x00A0;</span><span
949class="cmtt-8">&#x00A0;</span><span
950class="cmtt-8">&#x00A0;</span><span
951class="cmtt-8">&#x00A0;</span><span
952class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
953 id="x1-43016r8"></a><span
954class="cmr-6">8</span><span
955class="cmtt-8">byte</span><span
956class="cmtt-8">&#x00A0;3</span><span
957class="cmtt-8">&#x00A0;[</span><span
958class="cmtt-8">&#x00A0;</span><span
959class="cmtt-8">&#x00A0;</span><span
960class="cmtt-8">&#x00A0;</span><span
961class="cmtt-8">&#x00A0;</span><span
962class="cmtt-8">&#x00A0;</span><span
963class="cmtt-8">&#x00A0;</span><span
964class="cmtt-8">&#x00A0;</span><span
965class="cmtt-8">&#x00A0;</span><span
966class="cmtt-8">&#x00A0;</span><span
967class="cmtt-8">&#x00A0;</span><span
968class="cmtt-8">&#x00A0;</span><span
969class="cmtt-8">&#x00A0;</span><span
970class="cmtt-8">&#x00A0;</span><span
971class="cmtt-8">&#x00A0;</span><span
972class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
973 id="x1-43018r9"></a><span
974class="cmr-6">9</span><span
975class="cmtt-8">&#x00A0;</span><span
976class="cmtt-8">&#x00A0;</span><span
977class="cmtt-8">&#x00A0;</span><span
978class="cmtt-8">&#x00A0;</span><span
979class="cmtt-8">&#x00A0;</span><span
980class="cmtt-8">&#x00A0;</span><span
981class="cmtt-8">&#x00A0;</span><span
982class="cmtt-8">&#x00A0;</span><span
983class="cmtt-8">&#x00A0;</span><span
984class="cmtt-8">&#x00A0;</span><span
985class="cmtt-8">&#x00A0;</span><span
986class="cmtt-8">&#x00A0;</span><span
987class="cmtt-8">&#x00A0;...</span><br class="fancyvrb" /><a
988 id="x1-43020r10"></a><span
989class="cmr-6">10</span><span
990class="cmtt-8">byte</span><span
991class="cmtt-8">&#x00A0;n</span><span
992class="cmtt-8">&#x00A0;[</span><span
993class="cmtt-8">&#x00A0;</span><span
994class="cmtt-8">&#x00A0;</span><span
995class="cmtt-8">&#x00A0;</span><span
996class="cmtt-8">&#x00A0;</span><span
997class="cmtt-8">&#x00A0;</span><span
998class="cmtt-8">&#x00A0;</span><span
999class="cmtt-8">&#x00A0;</span><span
1000class="cmtt-8">&#x00A0;</span><span
1001class="cmtt-8">&#x00A0;</span><span
1002class="cmtt-8">&#x00A0;</span><span
1003class="cmtt-8">&#x00A0;</span><span
1004class="cmtt-8">&#x00A0;</span><span
1005class="cmtt-8">&#x00A0;</span><span
1006class="cmtt-8">&#x00A0;</span><span
1007class="cmtt-8">&#x00A0;]</span><span
1008class="cmtt-8">&#x00A0;</span><span
1009class="cmtt-8">&#x00A0;bytestream</span><span
1010class="cmtt-8">&#x00A0;length</span><span
1011class="cmtt-8">&#x00A0;==</span><span
1012class="cmtt-8">&#x00A0;1</span><span
1013class="cmtt-8">&#x00A0;byte</span><br class="fancyvrb" /><a
1014 id="x1-43022r11"></a><span
1015class="cmr-6">11</span></div>
1016<!--l. 120--><p class="noindent" >Continue by coding the 3 bit integer value &#8217;-1&#8217; [b111]:
1017<!--l. 122--><p class="noindent" >
1018<div class="fancyvrb" id="fancyvrb3"><a
1019 id="x1-43024r1"></a><span
1020class="cmr-6">1</span><span
1021class="cmtt-8">&#x00A0;</span><span
1022class="cmtt-8">&#x00A0;</span><span
1023class="cmtt-8">&#x00A0;</span><span
1024class="cmtt-8">&#x00A0;</span><span
1025class="cmtt-8">&#x00A0;</span><span
1026class="cmtt-8">&#x00A0;</span><span
1027class="cmtt-8">&#x00A0;</span><span
1028class="cmtt-8">&#x00A0;|</span><br class="fancyvrb" /><a
1029 id="x1-43026r2"></a><span
1030class="cmr-6">2</span><span
1031class="cmtt-8">&#x00A0;</span><span
1032class="cmtt-8">&#x00A0;</span><span
1033class="cmtt-8">&#x00A0;</span><span
1034class="cmtt-8">&#x00A0;</span><span
1035class="cmtt-8">&#x00A0;</span><span
1036class="cmtt-8">&#x00A0;</span><span
1037class="cmtt-8">&#x00A0;</span><span
1038class="cmtt-8">&#x00A0;V</span><br class="fancyvrb" /><a
1039 id="x1-43028r3"></a><span
1040class="cmr-6">3</span><br class="fancyvrb" /><a
1041 id="x1-43030r4"></a><span
1042class="cmr-6">4</span><span
1043class="cmtt-8">&#x00A0;</span><span
1044class="cmtt-8">&#x00A0;</span><span
1045class="cmtt-8">&#x00A0;</span><span
1046class="cmtt-8">&#x00A0;</span><span
1047class="cmtt-8">&#x00A0;</span><span
1048class="cmtt-8">&#x00A0;</span><span
1049class="cmtt-8">&#x00A0;</span><span
1050class="cmtt-8">&#x00A0;7</span><span
1051class="cmtt-8">&#x00A0;6</span><span
1052class="cmtt-8">&#x00A0;5</span><span
1053class="cmtt-8">&#x00A0;4</span><span
1054class="cmtt-8">&#x00A0;3</span><span
1055class="cmtt-8">&#x00A0;2</span><span
1056class="cmtt-8">&#x00A0;1</span><span
1057class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
1058 id="x1-43032r5"></a><span
1059class="cmr-6">5</span><span
1060class="cmtt-8">byte</span><span
1061class="cmtt-8">&#x00A0;0</span><span
1062class="cmtt-8">&#x00A0;[0</span><span
1063class="cmtt-8">&#x00A0;1</span><span
1064class="cmtt-8">&#x00A0;1</span><span
1065class="cmtt-8">&#x00A0;1</span><span
1066class="cmtt-8">&#x00A0;1</span><span
1067class="cmtt-8">&#x00A0;1</span><span
1068class="cmtt-8">&#x00A0;0</span><span
1069class="cmtt-8">&#x00A0;0]</span><span
1070class="cmtt-8">&#x00A0;</span><span
1071class="cmtt-8">&#x00A0;&#x003C;-</span><br class="fancyvrb" /><a
1072 id="x1-43034r6"></a><span
1073class="cmr-6">6</span><span
1074class="cmtt-8">byte</span><span
1075class="cmtt-8">&#x00A0;1</span><span
1076class="cmtt-8">&#x00A0;[</span><span
1077class="cmtt-8">&#x00A0;</span><span
1078class="cmtt-8">&#x00A0;</span><span
1079class="cmtt-8">&#x00A0;</span><span
1080class="cmtt-8">&#x00A0;</span><span
1081class="cmtt-8">&#x00A0;</span><span
1082class="cmtt-8">&#x00A0;</span><span
1083class="cmtt-8">&#x00A0;</span><span
1084class="cmtt-8">&#x00A0;</span><span
1085class="cmtt-8">&#x00A0;</span><span
1086class="cmtt-8">&#x00A0;</span><span
1087class="cmtt-8">&#x00A0;</span><span
1088class="cmtt-8">&#x00A0;</span><span
1089class="cmtt-8">&#x00A0;</span><span
1090class="cmtt-8">&#x00A0;</span><span
1091class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
1092 id="x1-43036r7"></a><span
1093class="cmr-6">7</span><span
1094class="cmtt-8">byte</span><span
1095class="cmtt-8">&#x00A0;2</span><span
1096class="cmtt-8">&#x00A0;[</span><span
1097class="cmtt-8">&#x00A0;</span><span
1098class="cmtt-8">&#x00A0;</span><span
1099class="cmtt-8">&#x00A0;</span><span
1100class="cmtt-8">&#x00A0;</span><span
1101class="cmtt-8">&#x00A0;</span><span
1102class="cmtt-8">&#x00A0;</span><span
1103class="cmtt-8">&#x00A0;</span><span
1104class="cmtt-8">&#x00A0;</span><span
1105class="cmtt-8">&#x00A0;</span><span
1106class="cmtt-8">&#x00A0;</span><span
1107class="cmtt-8">&#x00A0;</span><span
1108class="cmtt-8">&#x00A0;</span><span
1109class="cmtt-8">&#x00A0;</span><span
1110class="cmtt-8">&#x00A0;</span><span
1111class="cmtt-8">&#x00A0;]</span>
1112<br class="fancyvrb" /><a
1113 id="x1-43038r8"></a><span
1114class="cmr-6">8</span><span
1115class="cmtt-8">byte</span><span
1116class="cmtt-8">&#x00A0;3</span><span
1117class="cmtt-8">&#x00A0;[</span><span
1118class="cmtt-8">&#x00A0;</span><span
1119class="cmtt-8">&#x00A0;</span><span
1120class="cmtt-8">&#x00A0;</span><span
1121class="cmtt-8">&#x00A0;</span><span
1122class="cmtt-8">&#x00A0;</span><span
1123class="cmtt-8">&#x00A0;</span><span
1124class="cmtt-8">&#x00A0;</span><span
1125class="cmtt-8">&#x00A0;</span><span
1126class="cmtt-8">&#x00A0;</span><span
1127class="cmtt-8">&#x00A0;</span><span
1128class="cmtt-8">&#x00A0;</span><span
1129class="cmtt-8">&#x00A0;</span><span
1130class="cmtt-8">&#x00A0;</span><span
1131class="cmtt-8">&#x00A0;</span><span
1132class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
1133 id="x1-43040r9"></a><span
1134class="cmr-6">9</span><span
1135class="cmtt-8">&#x00A0;</span><span
1136class="cmtt-8">&#x00A0;</span><span
1137class="cmtt-8">&#x00A0;</span><span
1138class="cmtt-8">&#x00A0;</span><span
1139class="cmtt-8">&#x00A0;</span><span
1140class="cmtt-8">&#x00A0;</span><span
1141class="cmtt-8">&#x00A0;</span><span
1142class="cmtt-8">&#x00A0;</span><span
1143class="cmtt-8">&#x00A0;</span><span
1144class="cmtt-8">&#x00A0;</span><span
1145class="cmtt-8">&#x00A0;</span><span
1146class="cmtt-8">&#x00A0;</span><span
1147class="cmtt-8">&#x00A0;...</span><br class="fancyvrb" /><a
1148 id="x1-43042r10"></a><span
1149class="cmr-6">10</span><span
1150class="cmtt-8">byte</span><span
1151class="cmtt-8">&#x00A0;n</span><span
1152class="cmtt-8">&#x00A0;[</span><span
1153class="cmtt-8">&#x00A0;</span><span
1154class="cmtt-8">&#x00A0;</span><span
1155class="cmtt-8">&#x00A0;</span><span
1156class="cmtt-8">&#x00A0;</span><span
1157class="cmtt-8">&#x00A0;</span><span
1158class="cmtt-8">&#x00A0;</span><span
1159class="cmtt-8">&#x00A0;</span><span
1160class="cmtt-8">&#x00A0;</span><span
1161class="cmtt-8">&#x00A0;</span><span
1162class="cmtt-8">&#x00A0;</span><span
1163class="cmtt-8">&#x00A0;</span><span
1164class="cmtt-8">&#x00A0;</span><span
1165class="cmtt-8">&#x00A0;</span><span
1166class="cmtt-8">&#x00A0;</span><span
1167class="cmtt-8">&#x00A0;]</span><span
1168class="cmtt-8">&#x00A0;</span><span
1169class="cmtt-8">&#x00A0;bytestream</span><span
1170class="cmtt-8">&#x00A0;length</span><span
1171class="cmtt-8">&#x00A0;==</span><span
1172class="cmtt-8">&#x00A0;1</span><span
1173class="cmtt-8">&#x00A0;byte</span></div>
1174<!--l. 136--><p class="noindent" >Continue by coding the 7 bit integer value &#8217;17&#8217; [b0010001]:
1175<!--l. 138--><p class="noindent" >
1176<div class="fancyvrb" id="fancyvrb4"><a
1177 id="x1-43044r1"></a><span
1178class="cmr-6">1</span><span
1179class="cmtt-8">&#x00A0;</span><span
1180class="cmtt-8">&#x00A0;</span><span
1181class="cmtt-8">&#x00A0;</span><span
1182class="cmtt-8">&#x00A0;</span><span
1183class="cmtt-8">&#x00A0;</span><span
1184class="cmtt-8">&#x00A0;</span><span
1185class="cmtt-8">&#x00A0;</span><span
1186class="cmtt-8">&#x00A0;</span><span
1187class="cmtt-8">&#x00A0;</span><span
1188class="cmtt-8">&#x00A0;|</span><br class="fancyvrb" /><a
1189 id="x1-43046r2"></a><span
1190class="cmr-6">2</span><span
1191class="cmtt-8">&#x00A0;</span><span
1192class="cmtt-8">&#x00A0;</span><span
1193class="cmtt-8">&#x00A0;</span><span
1194class="cmtt-8">&#x00A0;</span><span
1195class="cmtt-8">&#x00A0;</span><span
1196class="cmtt-8">&#x00A0;</span><span
1197class="cmtt-8">&#x00A0;</span><span
1198class="cmtt-8">&#x00A0;</span><span
1199class="cmtt-8">&#x00A0;</span><span
1200class="cmtt-8">&#x00A0;V</span><br class="fancyvrb" /><a
1201 id="x1-43048r3"></a><span
1202class="cmr-6">3</span><br class="fancyvrb" /><a
1203 id="x1-43050r4"></a><span
1204class="cmr-6">4</span><span
1205class="cmtt-8">&#x00A0;</span><span
1206class="cmtt-8">&#x00A0;</span><span
1207class="cmtt-8">&#x00A0;</span><span
1208class="cmtt-8">&#x00A0;</span><span
1209class="cmtt-8">&#x00A0;</span><span
1210class="cmtt-8">&#x00A0;</span><span
1211class="cmtt-8">&#x00A0;</span><span
1212class="cmtt-8">&#x00A0;7</span><span
1213class="cmtt-8">&#x00A0;6</span><span
1214class="cmtt-8">&#x00A0;5</span><span
1215class="cmtt-8">&#x00A0;4</span><span
1216class="cmtt-8">&#x00A0;3</span><span
1217class="cmtt-8">&#x00A0;2</span><span
1218class="cmtt-8">&#x00A0;1</span><span
1219class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
1220 id="x1-43052r5"></a><span
1221class="cmr-6">5</span><span
1222class="cmtt-8">byte</span><span
1223class="cmtt-8">&#x00A0;0</span><span
1224class="cmtt-8">&#x00A0;[1</span><span
1225class="cmtt-8">&#x00A0;1</span><span
1226class="cmtt-8">&#x00A0;1</span><span
1227class="cmtt-8">&#x00A0;1</span><span
1228class="cmtt-8">&#x00A0;1</span><span
1229class="cmtt-8">&#x00A0;1</span><span
1230class="cmtt-8">&#x00A0;0</span><span
1231class="cmtt-8">&#x00A0;0]</span><br class="fancyvrb" /><a
1232 id="x1-43054r6"></a><span
1233class="cmr-6">6</span><span
1234class="cmtt-8">byte</span><span
1235class="cmtt-8">&#x00A0;1</span><span
1236class="cmtt-8">&#x00A0;[0</span><span
1237class="cmtt-8">&#x00A0;0</span><span
1238class="cmtt-8">&#x00A0;0</span><span
1239class="cmtt-8">&#x00A0;0</span><span
1240class="cmtt-8">&#x00A0;1</span><span
1241class="cmtt-8">&#x00A0;0</span><span
1242class="cmtt-8">&#x00A0;0</span><span
1243class="cmtt-8">&#x00A0;0]</span><span
1244class="cmtt-8">&#x00A0;</span><span
1245class="cmtt-8">&#x00A0;&#x003C;-</span><br class="fancyvrb" /><a
1246 id="x1-43056r7"></a><span
1247class="cmr-6">7</span><span
1248class="cmtt-8">byte</span><span
1249class="cmtt-8">&#x00A0;2</span><span
1250class="cmtt-8">&#x00A0;[</span><span
1251class="cmtt-8">&#x00A0;</span><span
1252class="cmtt-8">&#x00A0;</span><span
1253class="cmtt-8">&#x00A0;</span><span
1254class="cmtt-8">&#x00A0;</span><span
1255class="cmtt-8">&#x00A0;</span><span
1256class="cmtt-8">&#x00A0;</span><span
1257class="cmtt-8">&#x00A0;</span><span
1258class="cmtt-8">&#x00A0;</span><span
1259class="cmtt-8">&#x00A0;</span><span
1260class="cmtt-8">&#x00A0;</span><span
1261class="cmtt-8">&#x00A0;</span><span
1262class="cmtt-8">&#x00A0;</span><span
1263class="cmtt-8">&#x00A0;</span><span
1264class="cmtt-8">&#x00A0;</span><span
1265class="cmtt-8">&#x00A0;]</span>
1266<br class="fancyvrb" /><a
1267 id="x1-43058r8"></a><span
1268class="cmr-6">8</span><span
1269class="cmtt-8">byte</span><span
1270class="cmtt-8">&#x00A0;3</span><span
1271class="cmtt-8">&#x00A0;[</span><span
1272class="cmtt-8">&#x00A0;</span><span
1273class="cmtt-8">&#x00A0;</span><span
1274class="cmtt-8">&#x00A0;</span><span
1275class="cmtt-8">&#x00A0;</span><span
1276class="cmtt-8">&#x00A0;</span><span
1277class="cmtt-8">&#x00A0;</span><span
1278class="cmtt-8">&#x00A0;</span><span
1279class="cmtt-8">&#x00A0;</span><span
1280class="cmtt-8">&#x00A0;</span><span
1281class="cmtt-8">&#x00A0;</span><span
1282class="cmtt-8">&#x00A0;</span><span
1283class="cmtt-8">&#x00A0;</span><span
1284class="cmtt-8">&#x00A0;</span><span
1285class="cmtt-8">&#x00A0;</span><span
1286class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
1287 id="x1-43060r9"></a><span
1288class="cmr-6">9</span><span
1289class="cmtt-8">&#x00A0;</span><span
1290class="cmtt-8">&#x00A0;</span><span
1291class="cmtt-8">&#x00A0;</span><span
1292class="cmtt-8">&#x00A0;</span><span
1293class="cmtt-8">&#x00A0;</span><span
1294class="cmtt-8">&#x00A0;</span><span
1295class="cmtt-8">&#x00A0;</span><span
1296class="cmtt-8">&#x00A0;</span><span
1297class="cmtt-8">&#x00A0;</span><span
1298class="cmtt-8">&#x00A0;</span><span
1299class="cmtt-8">&#x00A0;</span><span
1300class="cmtt-8">&#x00A0;</span><span
1301class="cmtt-8">&#x00A0;...</span><br class="fancyvrb" /><a
1302 id="x1-43062r10"></a><span
1303class="cmr-6">10</span><span
1304class="cmtt-8">byte</span><span
1305class="cmtt-8">&#x00A0;n</span><span
1306class="cmtt-8">&#x00A0;[</span><span
1307class="cmtt-8">&#x00A0;</span><span
1308class="cmtt-8">&#x00A0;</span><span
1309class="cmtt-8">&#x00A0;</span><span
1310class="cmtt-8">&#x00A0;</span><span
1311class="cmtt-8">&#x00A0;</span><span
1312class="cmtt-8">&#x00A0;</span><span
1313class="cmtt-8">&#x00A0;</span><span
1314class="cmtt-8">&#x00A0;</span><span
1315class="cmtt-8">&#x00A0;</span><span
1316class="cmtt-8">&#x00A0;</span><span
1317class="cmtt-8">&#x00A0;</span><span
1318class="cmtt-8">&#x00A0;</span><span
1319class="cmtt-8">&#x00A0;</span><span
1320class="cmtt-8">&#x00A0;</span><span
1321class="cmtt-8">&#x00A0;]</span><span
1322class="cmtt-8">&#x00A0;</span><span
1323class="cmtt-8">&#x00A0;bytestream</span><span
1324class="cmtt-8">&#x00A0;length</span><span
1325class="cmtt-8">&#x00A0;==</span><span
1326class="cmtt-8">&#x00A0;2</span><span
1327class="cmtt-8">&#x00A0;bytes</span><br class="fancyvrb" /><a
1328 id="x1-43064r11"></a><span
1329class="cmr-6">11</span><span
1330class="cmtt-8">&#x00A0;</span><span
1331class="cmtt-8">&#x00A0;</span><span
1332class="cmtt-8">&#x00A0;</span><span
1333class="cmtt-8">&#x00A0;</span><span
1334class="cmtt-8">&#x00A0;</span><span
1335class="cmtt-8">&#x00A0;</span><span
1336class="cmtt-8">&#x00A0;</span><span
1337class="cmtt-8">&#x00A0;</span><span
1338class="cmtt-8">&#x00A0;</span><span
1339class="cmtt-8">&#x00A0;</span><span
1340class="cmtt-8">&#x00A0;</span><span
1341class="cmtt-8">&#x00A0;</span><span
1342class="cmtt-8">&#x00A0;</span><span
1343class="cmtt-8">&#x00A0;</span><span
1344class="cmtt-8">&#x00A0;</span><span
1345class="cmtt-8">&#x00A0;</span><span
1346class="cmtt-8">&#x00A0;</span><span
1347class="cmtt-8">&#x00A0;</span><span
1348class="cmtt-8">&#x00A0;</span><span
1349class="cmtt-8">&#x00A0;</span><span
1350class="cmtt-8">&#x00A0;</span><span
1351class="cmtt-8">&#x00A0;</span><span
1352class="cmtt-8">&#x00A0;</span><span
1353class="cmtt-8">&#x00A0;</span><span
1354class="cmtt-8">&#x00A0;</span><span
1355class="cmtt-8">&#x00A0;bit</span><span
1356class="cmtt-8">&#x00A0;cursor</span><span
1357class="cmtt-8">&#x00A0;==</span><span
1358class="cmtt-8">&#x00A0;6</span></div>
1359<!--l. 153--><p class="noindent" >Continue by coding the 13 bit integer value &#8217;6969&#8217; [b110 11001110 01]:
1360<!--l. 155--><p class="noindent" >
1361<div class="fancyvrb" id="fancyvrb5"><a
1362 id="x1-43066r1"></a><span
1363class="cmr-6">1</span><span
1364class="cmtt-8">&#x00A0;</span><span
1365class="cmtt-8">&#x00A0;</span><span
1366class="cmtt-8">&#x00A0;</span><span
1367class="cmtt-8">&#x00A0;</span><span
1368class="cmtt-8">&#x00A0;</span><span
1369class="cmtt-8">&#x00A0;</span><span
1370class="cmtt-8">&#x00A0;</span><span
1371class="cmtt-8">&#x00A0;</span><span
1372class="cmtt-8">&#x00A0;</span><span
1373class="cmtt-8">&#x00A0;</span><span
1374class="cmtt-8">&#x00A0;</span><span
1375class="cmtt-8">&#x00A0;</span><span
1376class="cmtt-8">&#x00A0;</span><span
1377class="cmtt-8">&#x00A0;</span><span
1378class="cmtt-8">&#x00A0;</span><span
1379class="cmtt-8">&#x00A0;|</span><br class="fancyvrb" /><a
1380 id="x1-43068r2"></a><span
1381class="cmr-6">2</span><span
1382class="cmtt-8">&#x00A0;</span><span
1383class="cmtt-8">&#x00A0;</span><span
1384class="cmtt-8">&#x00A0;</span><span
1385class="cmtt-8">&#x00A0;</span><span
1386class="cmtt-8">&#x00A0;</span><span
1387class="cmtt-8">&#x00A0;</span><span
1388class="cmtt-8">&#x00A0;</span><span
1389class="cmtt-8">&#x00A0;</span><span
1390class="cmtt-8">&#x00A0;</span><span
1391class="cmtt-8">&#x00A0;</span><span
1392class="cmtt-8">&#x00A0;</span><span
1393class="cmtt-8">&#x00A0;</span><span
1394class="cmtt-8">&#x00A0;</span><span
1395class="cmtt-8">&#x00A0;</span><span
1396class="cmtt-8">&#x00A0;</span><span
1397class="cmtt-8">&#x00A0;V</span><br class="fancyvrb" /><a
1398 id="x1-43070r3"></a><span
1399class="cmr-6">3</span><br class="fancyvrb" /><a
1400 id="x1-43072r4"></a><span
1401class="cmr-6">4</span><span
1402class="cmtt-8">&#x00A0;</span><span
1403class="cmtt-8">&#x00A0;</span><span
1404class="cmtt-8">&#x00A0;</span><span
1405class="cmtt-8">&#x00A0;</span><span
1406class="cmtt-8">&#x00A0;</span><span
1407class="cmtt-8">&#x00A0;</span><span
1408class="cmtt-8">&#x00A0;</span><span
1409class="cmtt-8">&#x00A0;7</span><span
1410class="cmtt-8">&#x00A0;6</span><span
1411class="cmtt-8">&#x00A0;5</span><span
1412class="cmtt-8">&#x00A0;4</span><span
1413class="cmtt-8">&#x00A0;3</span><span
1414class="cmtt-8">&#x00A0;2</span><span
1415class="cmtt-8">&#x00A0;1</span><span
1416class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
1417 id="x1-43074r5"></a><span
1418class="cmr-6">5</span><span
1419class="cmtt-8">byte</span><span
1420class="cmtt-8">&#x00A0;0</span><span
1421class="cmtt-8">&#x00A0;[1</span><span
1422class="cmtt-8">&#x00A0;1</span><span
1423class="cmtt-8">&#x00A0;1</span><span
1424class="cmtt-8">&#x00A0;1</span><span
1425class="cmtt-8">&#x00A0;1</span><span
1426class="cmtt-8">&#x00A0;1</span><span
1427class="cmtt-8">&#x00A0;0</span><span
1428class="cmtt-8">&#x00A0;0]</span><br class="fancyvrb" /><a
1429 id="x1-43076r6"></a><span
1430class="cmr-6">6</span><span
1431class="cmtt-8">byte</span><span
1432class="cmtt-8">&#x00A0;1</span><span
1433class="cmtt-8">&#x00A0;[0</span><span
1434class="cmtt-8">&#x00A0;1</span><span
1435class="cmtt-8">&#x00A0;0</span><span
1436class="cmtt-8">&#x00A0;0</span><span
1437class="cmtt-8">&#x00A0;1</span><span
1438class="cmtt-8">&#x00A0;0</span><span
1439class="cmtt-8">&#x00A0;0</span><span
1440class="cmtt-8">&#x00A0;0]</span>
1441<br class="fancyvrb" /><a
1442 id="x1-43078r7"></a><span
1443class="cmr-6">7</span><span
1444class="cmtt-8">byte</span><span
1445class="cmtt-8">&#x00A0;2</span><span
1446class="cmtt-8">&#x00A0;[1</span><span
1447class="cmtt-8">&#x00A0;1</span><span
1448class="cmtt-8">&#x00A0;0</span><span
1449class="cmtt-8">&#x00A0;0</span><span
1450class="cmtt-8">&#x00A0;1</span><span
1451class="cmtt-8">&#x00A0;1</span><span
1452class="cmtt-8">&#x00A0;1</span><span
1453class="cmtt-8">&#x00A0;0]</span><br class="fancyvrb" /><a
1454 id="x1-43080r8"></a><span
1455class="cmr-6">8</span><span
1456class="cmtt-8">byte</span><span
1457class="cmtt-8">&#x00A0;3</span><span
1458class="cmtt-8">&#x00A0;[0</span><span
1459class="cmtt-8">&#x00A0;0</span><span
1460class="cmtt-8">&#x00A0;0</span><span
1461class="cmtt-8">&#x00A0;0</span><span
1462class="cmtt-8">&#x00A0;0</span><span
1463class="cmtt-8">&#x00A0;1</span><span
1464class="cmtt-8">&#x00A0;1</span><span
1465class="cmtt-8">&#x00A0;0]</span><span
1466class="cmtt-8">&#x00A0;</span><span
1467class="cmtt-8">&#x00A0;&#x003C;-</span><br class="fancyvrb" /><a
1468 id="x1-43082r9"></a><span
1469class="cmr-6">9</span><span
1470class="cmtt-8">&#x00A0;</span><span
1471class="cmtt-8">&#x00A0;</span><span
1472class="cmtt-8">&#x00A0;</span><span
1473class="cmtt-8">&#x00A0;</span><span
1474class="cmtt-8">&#x00A0;</span><span
1475class="cmtt-8">&#x00A0;</span><span
1476class="cmtt-8">&#x00A0;</span><span
1477class="cmtt-8">&#x00A0;</span><span
1478class="cmtt-8">&#x00A0;</span><span
1479class="cmtt-8">&#x00A0;</span><span
1480class="cmtt-8">&#x00A0;</span><span
1481class="cmtt-8">&#x00A0;</span><span
1482class="cmtt-8">&#x00A0;...</span><br class="fancyvrb" /><a
1483 id="x1-43084r10"></a><span
1484class="cmr-6">10</span><span
1485class="cmtt-8">byte</span><span
1486class="cmtt-8">&#x00A0;n</span><span
1487class="cmtt-8">&#x00A0;[</span><span
1488class="cmtt-8">&#x00A0;</span><span
1489class="cmtt-8">&#x00A0;</span><span
1490class="cmtt-8">&#x00A0;</span><span
1491class="cmtt-8">&#x00A0;</span><span
1492class="cmtt-8">&#x00A0;</span><span
1493class="cmtt-8">&#x00A0;</span><span
1494class="cmtt-8">&#x00A0;</span><span
1495class="cmtt-8">&#x00A0;</span><span
1496class="cmtt-8">&#x00A0;</span><span
1497class="cmtt-8">&#x00A0;</span><span
1498class="cmtt-8">&#x00A0;</span><span
1499class="cmtt-8">&#x00A0;</span><span
1500class="cmtt-8">&#x00A0;</span><span
1501class="cmtt-8">&#x00A0;</span><span
1502class="cmtt-8">&#x00A0;]</span><span
1503class="cmtt-8">&#x00A0;</span><span
1504class="cmtt-8">&#x00A0;bytestream</span><span
1505class="cmtt-8">&#x00A0;length</span><span
1506class="cmtt-8">&#x00A0;==</span><span
1507class="cmtt-8">&#x00A0;4</span><span
1508class="cmtt-8">&#x00A0;bytes</span><br class="fancyvrb" /><a
1509 id="x1-43086r11"></a><span
1510class="cmr-6">11</span></div>
1511
1512
1513
1514<!--l. 172--><p class="noindent" >
1515<h5 class="subsubsectionHead"><span class="titlemark">2.1.7. </span> <a
1516 id="x1-440002.1.7"></a>decoding example</h5>
1517<!--l. 174--><p class="noindent" >Reading from the beginning of the bytestream encoded in the above example:
1518<!--l. 176--><p class="noindent" >
1519<div class="fancyvrb" id="fancyvrb6"><a
1520 id="x1-44002r1"></a><span
1521class="cmr-6">1</span><span
1522class="cmtt-8">&#x00A0;</span><span
1523class="cmtt-8">&#x00A0;</span><span
1524class="cmtt-8">&#x00A0;</span><span
1525class="cmtt-8">&#x00A0;</span><span
1526class="cmtt-8">&#x00A0;</span><span
1527class="cmtt-8">&#x00A0;</span><span
1528class="cmtt-8">&#x00A0;</span><span
1529class="cmtt-8">&#x00A0;</span><span
1530class="cmtt-8">&#x00A0;</span><span
1531class="cmtt-8">&#x00A0;</span><span
1532class="cmtt-8">&#x00A0;</span><span
1533class="cmtt-8">&#x00A0;</span><span
1534class="cmtt-8">&#x00A0;</span><span
1535class="cmtt-8">&#x00A0;</span><span
1536class="cmtt-8">&#x00A0;</span><span
1537class="cmtt-8">&#x00A0;</span><span
1538class="cmtt-8">&#x00A0;</span><span
1539class="cmtt-8">&#x00A0;</span><span
1540class="cmtt-8">&#x00A0;</span><span
1541class="cmtt-8">&#x00A0;</span><span
1542class="cmtt-8">&#x00A0;</span><span
1543class="cmtt-8">&#x00A0;|</span><br class="fancyvrb" /><a
1544 id="x1-44004r2"></a><span
1545class="cmr-6">2</span><span
1546class="cmtt-8">&#x00A0;</span><span
1547class="cmtt-8">&#x00A0;</span><span
1548class="cmtt-8">&#x00A0;</span><span
1549class="cmtt-8">&#x00A0;</span><span
1550class="cmtt-8">&#x00A0;</span><span
1551class="cmtt-8">&#x00A0;</span><span
1552class="cmtt-8">&#x00A0;</span><span
1553class="cmtt-8">&#x00A0;</span><span
1554class="cmtt-8">&#x00A0;</span><span
1555class="cmtt-8">&#x00A0;</span><span
1556class="cmtt-8">&#x00A0;</span><span
1557class="cmtt-8">&#x00A0;</span><span
1558class="cmtt-8">&#x00A0;</span><span
1559class="cmtt-8">&#x00A0;</span><span
1560class="cmtt-8">&#x00A0;</span><span
1561class="cmtt-8">&#x00A0;</span><span
1562class="cmtt-8">&#x00A0;</span><span
1563class="cmtt-8">&#x00A0;</span><span
1564class="cmtt-8">&#x00A0;</span><span
1565class="cmtt-8">&#x00A0;</span><span
1566class="cmtt-8">&#x00A0;</span><span
1567class="cmtt-8">&#x00A0;V</span><br class="fancyvrb" /><a
1568 id="x1-44006r3"></a><span
1569class="cmr-6">3</span><br class="fancyvrb" /><a
1570 id="x1-44008r4"></a><span
1571class="cmr-6">4</span><span
1572class="cmtt-8">&#x00A0;</span><span
1573class="cmtt-8">&#x00A0;</span><span
1574class="cmtt-8">&#x00A0;</span><span
1575class="cmtt-8">&#x00A0;</span><span
1576class="cmtt-8">&#x00A0;</span><span
1577class="cmtt-8">&#x00A0;</span><span
1578class="cmtt-8">&#x00A0;</span><span
1579class="cmtt-8">&#x00A0;7</span><span
1580class="cmtt-8">&#x00A0;6</span><span
1581class="cmtt-8">&#x00A0;5</span><span
1582class="cmtt-8">&#x00A0;4</span><span
1583class="cmtt-8">&#x00A0;3</span><span
1584class="cmtt-8">&#x00A0;2</span><span
1585class="cmtt-8">&#x00A0;1</span><span
1586class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
1587 id="x1-44010r5"></a><span
1588class="cmr-6">5</span><span
1589class="cmtt-8">byte</span><span
1590class="cmtt-8">&#x00A0;0</span><span
1591class="cmtt-8">&#x00A0;[1</span><span
1592class="cmtt-8">&#x00A0;1</span><span
1593class="cmtt-8">&#x00A0;1</span><span
1594class="cmtt-8">&#x00A0;1</span><span
1595class="cmtt-8">&#x00A0;1</span><span
1596class="cmtt-8">&#x00A0;1</span><span
1597class="cmtt-8">&#x00A0;0</span><span
1598class="cmtt-8">&#x00A0;0]</span><span
1599class="cmtt-8">&#x00A0;</span><span
1600class="cmtt-8">&#x00A0;&#x003C;-</span><br class="fancyvrb" /><a
1601 id="x1-44012r6"></a><span
1602class="cmr-6">6</span><span
1603class="cmtt-8">byte</span><span
1604class="cmtt-8">&#x00A0;1</span><span
1605class="cmtt-8">&#x00A0;[0</span><span
1606class="cmtt-8">&#x00A0;1</span><span
1607class="cmtt-8">&#x00A0;0</span><span
1608class="cmtt-8">&#x00A0;0</span><span
1609class="cmtt-8">&#x00A0;1</span><span
1610class="cmtt-8">&#x00A0;0</span><span
1611class="cmtt-8">&#x00A0;0</span><span
1612class="cmtt-8">&#x00A0;0]</span>
1613<br class="fancyvrb" /><a
1614 id="x1-44014r7"></a><span
1615class="cmr-6">7</span><span
1616class="cmtt-8">byte</span><span
1617class="cmtt-8">&#x00A0;2</span><span
1618class="cmtt-8">&#x00A0;[1</span><span
1619class="cmtt-8">&#x00A0;1</span><span
1620class="cmtt-8">&#x00A0;0</span><span
1621class="cmtt-8">&#x00A0;0</span><span
1622class="cmtt-8">&#x00A0;1</span><span
1623class="cmtt-8">&#x00A0;1</span><span
1624class="cmtt-8">&#x00A0;1</span><span
1625class="cmtt-8">&#x00A0;0]</span><br class="fancyvrb" /><a
1626 id="x1-44016r8"></a><span
1627class="cmr-6">8</span><span
1628class="cmtt-8">byte</span><span
1629class="cmtt-8">&#x00A0;3</span><span
1630class="cmtt-8">&#x00A0;[0</span><span
1631class="cmtt-8">&#x00A0;0</span><span
1632class="cmtt-8">&#x00A0;0</span><span
1633class="cmtt-8">&#x00A0;0</span><span
1634class="cmtt-8">&#x00A0;0</span><span
1635class="cmtt-8">&#x00A0;1</span><span
1636class="cmtt-8">&#x00A0;1</span><span
1637class="cmtt-8">&#x00A0;0]</span><span
1638class="cmtt-8">&#x00A0;</span><span
1639class="cmtt-8">&#x00A0;bytestream</span><span
1640class="cmtt-8">&#x00A0;length</span><span
1641class="cmtt-8">&#x00A0;==</span><span
1642class="cmtt-8">&#x00A0;4</span><span
1643class="cmtt-8">&#x00A0;bytes</span><br class="fancyvrb" /><a
1644 id="x1-44018r9"></a><span
1645class="cmr-6">9</span></div>
1646<!--l. 189--><p class="noindent" >We read two, two-bit integer fields, resulting in the returned numbers &#8217;b00&#8217; and &#8217;b11&#8217;. Two things
1647are worth noting here:
1648 <ul class="itemize1">
1649 <li class="itemize">Although these four bits were originally written as a single four-bit integer, reading
1650 some other combination of bit-widths from the bitstream is well defined. There are
1651 no artificial alignment boundaries maintained in the bitstream.
1652 </li>
1653 <li class="itemize">The second value is the two-bit-wide integer &#8217;b11&#8217;. This value may be interpreted
1654 either as the unsigned value &#8217;3&#8217;, or the signed value &#8217;-1&#8217;. Signedness is dependent on
1655 decode context.</li></ul>
1656<!--l. 207--><p class="noindent" >
1657<h5 class="subsubsectionHead"><span class="titlemark">2.1.8. </span> <a
1658 id="x1-450002.1.8"></a>end-of-packet alignment</h5>
1659<!--l. 209--><p class="noindent" >The typical use of bitpacking is to produce many independent byte-aligned packets which are
1660embedded into a larger byte-aligned container structure, such as an Ogg transport bitstream.
1661Externally, each bytestream (encoded bitstream) must begin and end on a byte boundary. Often,
1662the encoded bitstream is not an integer number of bytes, and so there is unused (uncoded) space
1663in the last byte of a packet.
1664<!--l. 217--><p class="noindent" >Unused space in the last byte of a bytestream is always zeroed during the coding process. Thus,
1665should this unused space be read, it will return binary zeroes.
1666<!--l. 221--><p class="noindent" >Attempting to read past the end of an encoded packet results in an &#8217;end-of-packet&#8217; condition.
1667End-of-packet is not to be considered an error; it is merely a state indicating that there is
1668insufficient remaining data to fulfill the desired read size. Vorbis uses truncated packets as a
1669
1670
1671
1672normal mode of operation, and as such, decoders must handle reading past the end of a packet as
1673a typical mode of operation. Any further read operations after an &#8217;end-of-packet&#8217; condition shall
1674also return &#8217;end-of-packet&#8217;.
1675<!--l. 232--><p class="noindent" >
1676<h5 class="subsubsectionHead"><span class="titlemark">2.1.9. </span> <a
1677 id="x1-460002.1.9"></a>reading zero bits</h5>
1678<!--l. 234--><p class="noindent" >Reading a zero-bit-wide integer returns the value &#8217;0&#8217; and does not increment the stream cursor.
1679Reading to the end of the packet (but not past, such that an &#8217;end-of-packet&#8217; condition has not
1680triggered) and then reading a zero bit integer shall succeed, returning 0, and not trigger an
1681end-of-packet condition. Reading a zero-bit-wide integer after a previous read sets &#8217;end-of-packet&#8217;
1682shall also fail with &#8217;end-of-packet&#8217;.
1683
1684
1685
1686
1687
1688
1689<h3 class="sectionHead"><span class="titlemark">3. </span> <a
1690 id="x1-470003"></a>Probability Model and Codebooks</h3>
1691<!--l. 5--><p class="noindent" >
1692<h4 class="subsectionHead"><span class="titlemark">3.1. </span> <a
1693 id="x1-480003.1"></a>Overview</h4>
1694<!--l. 7--><p class="noindent" >Unlike practically every other mainstream audio codec, Vorbis has no statically configured
1695probability model, instead packing all entropy decoding configuration, VQ and Huffman, into the
1696bitstream itself in the third header, the codec setup header. This packed configuration consists of
1697multiple &#8217;codebooks&#8217;, each containing a specific Huffman-equivalent representation for decoding
1698compressed codewords as well as an optional lookup table of output vector values to which a
1699decoded Huffman value is applied as an offset, generating the final decoded output corresponding
1700to a given compressed codeword.
1701<!--l. 17--><p class="noindent" >
1702<h5 class="subsubsectionHead"><span class="titlemark">3.1.1. </span> <a
1703 id="x1-490003.1.1"></a>Bitwise operation</h5>
1704<!--l. 18--><p class="noindent" >The codebook mechanism is built on top of the vorbis bitpacker. Both the codebooks themselves
1705and the codewords they decode are unrolled from a packet as a series of arbitrary-width values
1706read from the stream according to <a
1707href="#x1-360002">section&#x00A0;2</a>, &#8220;<a
1708href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>&#8221;.
1709<!--l. 26--><p class="noindent" >
1710<h4 class="subsectionHead"><span class="titlemark">3.2. </span> <a
1711 id="x1-500003.2"></a>Packed codebook format</h4>
1712<!--l. 28--><p class="noindent" >For purposes of the examples below, we assume that the storage system&#8217;s native byte width is
1713eight bits. This is not universally true; see <a
1714href="#x1-360002">section&#x00A0;2</a>, &#8220;<a
1715href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>&#8221; for discussion
1716relating to non-eight-bit bytes.
1717
1718
1719
1720<!--l. 33--><p class="noindent" >
1721<h5 class="subsubsectionHead"><span class="titlemark">3.2.1. </span> <a
1722 id="x1-510003.2.1"></a>codebook decode</h5>
1723<!--l. 35--><p class="noindent" >A codebook begins with a 24 bit sync pattern, 0x564342:
1724<!--l. 37--><p class="noindent" >
1725<div class="fancyvrb" id="fancyvrb7"><a
1726 id="x1-51002r1"></a><span
1727class="cmr-6">1</span><span
1728class="cmtt-8">byte</span><span
1729class="cmtt-8">&#x00A0;0:</span><span
1730class="cmtt-8">&#x00A0;[</span><span
1731class="cmtt-8">&#x00A0;0</span><span
1732class="cmtt-8">&#x00A0;1</span><span
1733class="cmtt-8">&#x00A0;0</span><span
1734class="cmtt-8">&#x00A0;0</span><span
1735class="cmtt-8">&#x00A0;0</span><span
1736class="cmtt-8">&#x00A0;0</span><span
1737class="cmtt-8">&#x00A0;1</span><span
1738class="cmtt-8">&#x00A0;0</span><span
1739class="cmtt-8">&#x00A0;]</span><span
1740class="cmtt-8">&#x00A0;(0x42)</span><br class="fancyvrb" /><a
1741 id="x1-51004r2"></a><span
1742class="cmr-6">2</span><span
1743class="cmtt-8">byte</span><span
1744class="cmtt-8">&#x00A0;1:</span><span
1745class="cmtt-8">&#x00A0;[</span><span
1746class="cmtt-8">&#x00A0;0</span><span
1747class="cmtt-8">&#x00A0;1</span><span
1748class="cmtt-8">&#x00A0;0</span><span
1749class="cmtt-8">&#x00A0;0</span><span
1750class="cmtt-8">&#x00A0;0</span><span
1751class="cmtt-8">&#x00A0;0</span><span
1752class="cmtt-8">&#x00A0;1</span><span
1753class="cmtt-8">&#x00A0;1</span><span
1754class="cmtt-8">&#x00A0;]</span><span
1755class="cmtt-8">&#x00A0;(0x43)</span><br class="fancyvrb" /><a
1756 id="x1-51006r3"></a><span
1757class="cmr-6">3</span><span
1758class="cmtt-8">byte</span><span
1759class="cmtt-8">&#x00A0;2:</span><span
1760class="cmtt-8">&#x00A0;[</span><span
1761class="cmtt-8">&#x00A0;0</span><span
1762class="cmtt-8">&#x00A0;1</span><span
1763class="cmtt-8">&#x00A0;0</span><span
1764class="cmtt-8">&#x00A0;1</span><span
1765class="cmtt-8">&#x00A0;0</span><span
1766class="cmtt-8">&#x00A0;1</span><span
1767class="cmtt-8">&#x00A0;1</span><span
1768class="cmtt-8">&#x00A0;0</span><span
1769class="cmtt-8">&#x00A0;]</span><span
1770class="cmtt-8">&#x00A0;(0x56)</span></div>
1771<!--l. 43--><p class="noindent" >16 bit <span
1772class="cmtt-12">[codebook</span><span
1773class="cmtt-12">_dimensions] </span>and 24 bit <span
1774class="cmtt-12">[codebook</span><span
1775class="cmtt-12">_entries] </span>fields:
1776<!--l. 45--><p class="noindent" >
1777<div class="fancyvrb" id="fancyvrb8"><a
1778 id="x1-51008r1"></a><span
1779class="cmr-6">1</span><br class="fancyvrb" /><a
1780 id="x1-51010r2"></a><span
1781class="cmr-6">2</span><span
1782class="cmtt-8">byte</span><span
1783class="cmtt-8">&#x00A0;3:</span><span
1784class="cmtt-8">&#x00A0;[</span><span
1785class="cmtt-8">&#x00A0;X</span><span
1786class="cmtt-8">&#x00A0;X</span><span
1787class="cmtt-8">&#x00A0;X</span><span
1788class="cmtt-8">&#x00A0;X</span><span
1789class="cmtt-8">&#x00A0;X</span><span
1790class="cmtt-8">&#x00A0;X</span><span
1791class="cmtt-8">&#x00A0;X</span><span
1792class="cmtt-8">&#x00A0;X</span><span
1793class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
1794 id="x1-51012r3"></a><span
1795class="cmr-6">3</span><span
1796class="cmtt-8">byte</span><span
1797class="cmtt-8">&#x00A0;4:</span><span
1798class="cmtt-8">&#x00A0;[</span><span
1799class="cmtt-8">&#x00A0;X</span><span
1800class="cmtt-8">&#x00A0;X</span><span
1801class="cmtt-8">&#x00A0;X</span><span
1802class="cmtt-8">&#x00A0;X</span><span
1803class="cmtt-8">&#x00A0;X</span><span
1804class="cmtt-8">&#x00A0;X</span><span
1805class="cmtt-8">&#x00A0;X</span><span
1806class="cmtt-8">&#x00A0;X</span><span
1807class="cmtt-8">&#x00A0;]</span><span
1808class="cmtt-8">&#x00A0;[codebook</span><span
1809class="cmtt-8">_dimensions]</span><span
1810class="cmtt-8">&#x00A0;(16</span><span
1811class="cmtt-8">&#x00A0;bit</span><span
1812class="cmtt-8">&#x00A0;unsigned)</span><br class="fancyvrb" /><a
1813 id="x1-51014r4"></a><span
1814class="cmr-6">4</span><br class="fancyvrb" /><a
1815 id="x1-51016r5"></a><span
1816class="cmr-6">5</span><span
1817class="cmtt-8">byte</span><span
1818class="cmtt-8">&#x00A0;5:</span><span
1819class="cmtt-8">&#x00A0;[</span><span
1820class="cmtt-8">&#x00A0;X</span><span
1821class="cmtt-8">&#x00A0;X</span><span
1822class="cmtt-8">&#x00A0;X</span><span
1823class="cmtt-8">&#x00A0;X</span><span
1824class="cmtt-8">&#x00A0;X</span><span
1825class="cmtt-8">&#x00A0;X</span><span
1826class="cmtt-8">&#x00A0;X</span><span
1827class="cmtt-8">&#x00A0;X</span><span
1828class="cmtt-8">&#x00A0;]</span>
1829<br class="fancyvrb" /><a
1830 id="x1-51018r6"></a><span
1831class="cmr-6">6</span><span
1832class="cmtt-8">byte</span><span
1833class="cmtt-8">&#x00A0;6:</span><span
1834class="cmtt-8">&#x00A0;[</span><span
1835class="cmtt-8">&#x00A0;X</span><span
1836class="cmtt-8">&#x00A0;X</span><span
1837class="cmtt-8">&#x00A0;X</span><span
1838class="cmtt-8">&#x00A0;X</span><span
1839class="cmtt-8">&#x00A0;X</span><span
1840class="cmtt-8">&#x00A0;X</span><span
1841class="cmtt-8">&#x00A0;X</span><span
1842class="cmtt-8">&#x00A0;X</span><span
1843class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
1844 id="x1-51020r7"></a><span
1845class="cmr-6">7</span><span
1846class="cmtt-8">byte</span><span
1847class="cmtt-8">&#x00A0;7:</span><span
1848class="cmtt-8">&#x00A0;[</span><span
1849class="cmtt-8">&#x00A0;X</span><span
1850class="cmtt-8">&#x00A0;X</span><span
1851class="cmtt-8">&#x00A0;X</span><span
1852class="cmtt-8">&#x00A0;X</span><span
1853class="cmtt-8">&#x00A0;X</span><span
1854class="cmtt-8">&#x00A0;X</span><span
1855class="cmtt-8">&#x00A0;X</span><span
1856class="cmtt-8">&#x00A0;X</span><span
1857class="cmtt-8">&#x00A0;]</span><span
1858class="cmtt-8">&#x00A0;[codebook</span><span
1859class="cmtt-8">_entries]</span><span
1860class="cmtt-8">&#x00A0;(24</span><span
1861class="cmtt-8">&#x00A0;bit</span><span
1862class="cmtt-8">&#x00A0;unsigned)</span><br class="fancyvrb" /><a
1863 id="x1-51022r8"></a><span
1864class="cmr-6">8</span></div>
1865<!--l. 56--><p class="noindent" >Next is the <span
1866class="cmtt-12">[ordered] </span>bit flag:
1867<!--l. 58--><p class="noindent" >
1868<div class="fancyvrb" id="fancyvrb9"><a
1869 id="x1-51024r1"></a><span
1870class="cmr-6">1</span><br class="fancyvrb" /><a
1871 id="x1-51026r2"></a><span
1872class="cmr-6">2</span><span
1873class="cmtt-8">byte</span><span
1874class="cmtt-8">&#x00A0;8:</span><span
1875class="cmtt-8">&#x00A0;[</span><span
1876class="cmtt-8">&#x00A0;</span><span
1877class="cmtt-8">&#x00A0;</span><span
1878class="cmtt-8">&#x00A0;</span><span
1879class="cmtt-8">&#x00A0;</span><span
1880class="cmtt-8">&#x00A0;</span><span
1881class="cmtt-8">&#x00A0;</span><span
1882class="cmtt-8">&#x00A0;</span><span
1883class="cmtt-8">&#x00A0;</span><span
1884class="cmtt-8">&#x00A0;</span><span
1885class="cmtt-8">&#x00A0;</span><span
1886class="cmtt-8">&#x00A0;</span><span
1887class="cmtt-8">&#x00A0;</span><span
1888class="cmtt-8">&#x00A0;</span><span
1889class="cmtt-8">&#x00A0;</span><span
1890class="cmtt-8">&#x00A0;X</span><span
1891class="cmtt-8">&#x00A0;]</span><span
1892class="cmtt-8">&#x00A0;[ordered]</span><span
1893class="cmtt-8">&#x00A0;(1</span><span
1894class="cmtt-8">&#x00A0;bit)</span><br class="fancyvrb" /><a
1895 id="x1-51028r3"></a><span
1896class="cmr-6">3</span></div>
1897<!--l. 64--><p class="noindent" >Each entry, numbering a total of <span
1898class="cmtt-12">[codebook</span><span
1899class="cmtt-12">_entries]</span>, is assigned a codeword length.
1900We now read the list of codeword lengths and store these lengths in the array
1901<span
1902class="cmtt-12">[codebook</span><span
1903class="cmtt-12">_codeword</span><span
1904class="cmtt-12">_lengths]</span>. Decode of lengths is according to whether the <span
1905class="cmtt-12">[ordered] </span>flag
1906is set or unset.
1907 <ul class="itemize1">
1908 <li class="itemize">If the <span
1909class="cmtt-12">[ordered] </span>flag is unset, the codeword list is not length ordered and the decoder
1910 needs to read each codeword length one-by-one.
1911 <!--l. 76--><p class="noindent" >The decoder first reads one additional bit flag, the <span
1912class="cmtt-12">[sparse] </span>flag. This flag determines
1913 whether or not the codebook contains unused entries that are not to be included in
1914 the codeword decode tree:
1915 <!--l. 81--><p class="noindent" >
1916 <div class="fancyvrb" id="fancyvrb10"><a
1917 id="x1-51030r1"></a><span
1918class="cmr-6">1</span><span
1919class="cmtt-8">byte</span><span
1920class="cmtt-8">&#x00A0;8:</span><span
1921class="cmtt-8">&#x00A0;[</span><span
1922class="cmtt-8">&#x00A0;</span><span
1923class="cmtt-8">&#x00A0;</span><span
1924class="cmtt-8">&#x00A0;</span><span
1925class="cmtt-8">&#x00A0;</span><span
1926class="cmtt-8">&#x00A0;</span><span
1927class="cmtt-8">&#x00A0;</span><span
1928class="cmtt-8">&#x00A0;</span><span
1929class="cmtt-8">&#x00A0;</span><span
1930class="cmtt-8">&#x00A0;</span><span
1931class="cmtt-8">&#x00A0;</span><span
1932class="cmtt-8">&#x00A0;</span><span
1933class="cmtt-8">&#x00A0;</span><span
1934class="cmtt-8">&#x00A0;X</span><span
1935class="cmtt-8">&#x00A0;1</span><span
1936class="cmtt-8">&#x00A0;]</span><span
1937class="cmtt-8">&#x00A0;[sparse]</span><span
1938class="cmtt-8">&#x00A0;flag</span><span
1939class="cmtt-8">&#x00A0;(1</span><span
1940class="cmtt-8">&#x00A0;bit)</span></div>
1941 <!--l. 85--><p class="noindent" >The decoder now performs for each of the <span
1942class="cmtt-12">[codebook</span><span
1943class="cmtt-12">_entries] </span>codebook entries:
1944 <!--l. 88--><p class="noindent" >
1945 <div class="fancyvrb" id="fancyvrb11"><a
1946 id="x1-51032r1"></a><span
1947class="cmr-6">1</span><br class="fancyvrb" /><a
1948 id="x1-51034r2"></a><span
1949class="cmr-6">2</span><span
1950class="cmtt-8">&#x00A0;</span><span
1951class="cmtt-8">&#x00A0;1)</span><span
1952class="cmtt-8">&#x00A0;if([sparse]</span><span
1953class="cmtt-8">&#x00A0;is</span><span
1954class="cmtt-8">&#x00A0;set)</span><span
1955class="cmtt-8">&#x00A0;</span><span
1956class="cmsy-8">{</span><br class="fancyvrb" /><a
1957 id="x1-51036r3"></a><span
1958class="cmr-6">3</span><br class="fancyvrb" /><a
1959 id="x1-51038r4"></a><span
1960class="cmr-6">4</span><span
1961class="cmtt-8">&#x00A0;</span><span
1962class="cmtt-8">&#x00A0;</span><span
1963class="cmtt-8">&#x00A0;</span><span
1964class="cmtt-8">&#x00A0;</span><span
1965class="cmtt-8">&#x00A0;</span><span
1966class="cmtt-8">&#x00A0;</span><span
1967class="cmtt-8">&#x00A0;</span><span
1968class="cmtt-8">&#x00A0;</span><span
1969class="cmtt-8">&#x00A0;2)</span><span
1970class="cmtt-8">&#x00A0;[flag]</span><span
1971class="cmtt-8">&#x00A0;=</span><span
1972class="cmtt-8">&#x00A0;read</span><span
1973class="cmtt-8">&#x00A0;one</span><span
1974class="cmtt-8">&#x00A0;bit;</span><br class="fancyvrb" /><a
1975 id="x1-51040r5"></a><span
1976class="cmr-6">5</span><span
1977class="cmtt-8">&#x00A0;</span><span
1978class="cmtt-8">&#x00A0;</span><span
1979class="cmtt-8">&#x00A0;</span><span
1980class="cmtt-8">&#x00A0;</span><span
1981class="cmtt-8">&#x00A0;</span><span
1982class="cmtt-8">&#x00A0;</span><span
1983class="cmtt-8">&#x00A0;</span><span
1984class="cmtt-8">&#x00A0;</span><span
1985class="cmtt-8">&#x00A0;3)</span><span
1986class="cmtt-8">&#x00A0;if([flag]</span><span
1987class="cmtt-8">&#x00A0;is</span><span
1988class="cmtt-8">&#x00A0;set)</span><span
1989class="cmtt-8">&#x00A0;</span><span
1990class="cmsy-8">{</span><br class="fancyvrb" /><a
1991 id="x1-51042r6"></a><span
1992class="cmr-6">6</span>
1993 <br class="fancyvrb" /><a
1994 id="x1-51044r7"></a><span
1995class="cmr-6">7</span><span
1996class="cmtt-8">&#x00A0;</span><span
1997class="cmtt-8">&#x00A0;</span><span
1998class="cmtt-8">&#x00A0;</span><span
1999class="cmtt-8">&#x00A0;</span><span
2000class="cmtt-8">&#x00A0;</span><span
2001class="cmtt-8">&#x00A0;</span><span
2002class="cmtt-8">&#x00A0;</span><span
2003class="cmtt-8">&#x00A0;</span><span
2004class="cmtt-8">&#x00A0;</span><span
2005class="cmtt-8">&#x00A0;</span><span
2006class="cmtt-8">&#x00A0;</span><span
2007class="cmtt-8">&#x00A0;</span><span
2008class="cmtt-8">&#x00A0;</span><span
2009class="cmtt-8">&#x00A0;4)</span><span
2010class="cmtt-8">&#x00A0;[length]</span><span
2011class="cmtt-8">&#x00A0;=</span><span
2012class="cmtt-8">&#x00A0;read</span><span
2013class="cmtt-8">&#x00A0;a</span><span
2014class="cmtt-8">&#x00A0;five</span><span
2015class="cmtt-8">&#x00A0;bit</span><span
2016class="cmtt-8">&#x00A0;unsigned</span><span
2017class="cmtt-8">&#x00A0;integer;</span><br class="fancyvrb" /><a
2018 id="x1-51046r8"></a><span
2019class="cmr-6">8</span><span
2020class="cmtt-8">&#x00A0;</span><span
2021class="cmtt-8">&#x00A0;</span><span
2022class="cmtt-8">&#x00A0;</span><span
2023class="cmtt-8">&#x00A0;</span><span
2024class="cmtt-8">&#x00A0;</span><span
2025class="cmtt-8">&#x00A0;</span><span
2026class="cmtt-8">&#x00A0;</span><span
2027class="cmtt-8">&#x00A0;</span><span
2028class="cmtt-8">&#x00A0;</span><span
2029class="cmtt-8">&#x00A0;</span><span
2030class="cmtt-8">&#x00A0;</span><span
2031class="cmtt-8">&#x00A0;</span><span
2032class="cmtt-8">&#x00A0;</span><span
2033class="cmtt-8">&#x00A0;5)</span><span
2034class="cmtt-8">&#x00A0;codeword</span><span
2035class="cmtt-8">&#x00A0;length</span><span
2036class="cmtt-8">&#x00A0;for</span><span
2037class="cmtt-8">&#x00A0;this</span><span
2038class="cmtt-8">&#x00A0;entry</span><span
2039class="cmtt-8">&#x00A0;is</span><span
2040class="cmtt-8">&#x00A0;[length]+1;</span><br class="fancyvrb" /><a
2041 id="x1-51048r9"></a><span
2042class="cmr-6">9</span>
2043 <br class="fancyvrb" /><a
2044 id="x1-51050r10"></a><span
2045class="cmr-6">10</span><span
2046class="cmtt-8">&#x00A0;</span><span
2047class="cmtt-8">&#x00A0;</span><span
2048class="cmtt-8">&#x00A0;</span><span
2049class="cmtt-8">&#x00A0;</span><span
2050class="cmtt-8">&#x00A0;</span><span
2051class="cmtt-8">&#x00A0;</span><span
2052class="cmtt-8">&#x00A0;</span><span
2053class="cmtt-8">&#x00A0;</span><span
2054class="cmtt-8">&#x00A0;</span><span
2055class="cmtt-8">&#x00A0;</span><span
2056class="cmtt-8">&#x00A0;</span><span
2057class="cmtt-8">&#x00A0;</span><span
2058class="cmsy-8">}</span><span
2059class="cmtt-8">&#x00A0;else</span><span
2060class="cmtt-8">&#x00A0;</span><span
2061class="cmsy-8">{</span><br class="fancyvrb" /><a
2062 id="x1-51052r11"></a><span
2063class="cmr-6">11</span><br class="fancyvrb" /><a
2064 id="x1-51054r12"></a><span
2065class="cmr-6">12</span><span
2066class="cmtt-8">&#x00A0;</span><span
2067class="cmtt-8">&#x00A0;</span><span
2068class="cmtt-8">&#x00A0;</span><span
2069class="cmtt-8">&#x00A0;</span><span
2070class="cmtt-8">&#x00A0;</span><span
2071class="cmtt-8">&#x00A0;</span><span
2072class="cmtt-8">&#x00A0;</span><span
2073class="cmtt-8">&#x00A0;</span><span
2074class="cmtt-8">&#x00A0;</span><span
2075class="cmtt-8">&#x00A0;</span><span
2076class="cmtt-8">&#x00A0;</span><span
2077class="cmtt-8">&#x00A0;</span><span
2078class="cmtt-8">&#x00A0;</span><span
2079class="cmtt-8">&#x00A0;6)</span><span
2080class="cmtt-8">&#x00A0;this</span><span
2081class="cmtt-8">&#x00A0;entry</span><span
2082class="cmtt-8">&#x00A0;is</span><span
2083class="cmtt-8">&#x00A0;unused.</span><span
2084class="cmtt-8">&#x00A0;</span><span
2085class="cmtt-8">&#x00A0;mark</span><span
2086class="cmtt-8">&#x00A0;it</span><span
2087class="cmtt-8">&#x00A0;as</span><span
2088class="cmtt-8">&#x00A0;such.</span><br class="fancyvrb" /><a
2089 id="x1-51056r13"></a><span
2090class="cmr-6">13</span><br class="fancyvrb" /><a
2091 id="x1-51058r14"></a><span
2092class="cmr-6">14</span><span
2093class="cmtt-8">&#x00A0;</span><span
2094class="cmtt-8">&#x00A0;</span><span
2095class="cmtt-8">&#x00A0;</span><span
2096class="cmtt-8">&#x00A0;</span><span
2097class="cmtt-8">&#x00A0;</span><span
2098class="cmtt-8">&#x00A0;</span><span
2099class="cmtt-8">&#x00A0;</span><span
2100class="cmtt-8">&#x00A0;</span><span
2101class="cmtt-8">&#x00A0;</span><span
2102class="cmtt-8">&#x00A0;</span><span
2103class="cmtt-8">&#x00A0;</span><span
2104class="cmtt-8">&#x00A0;</span><span
2105class="cmsy-8">}</span><br class="fancyvrb" /><a
2106 id="x1-51060r15"></a><span
2107class="cmr-6">15</span><br class="fancyvrb" /><a
2108 id="x1-51062r16"></a><span
2109class="cmr-6">16</span><span
2110class="cmtt-8">&#x00A0;</span><span
2111class="cmtt-8">&#x00A0;</span><span
2112class="cmtt-8">&#x00A0;</span><span
2113class="cmtt-8">&#x00A0;</span><span
2114class="cmtt-8">&#x00A0;</span><span
2115class="cmsy-8">}</span><span
2116class="cmtt-8">&#x00A0;else</span><span
2117class="cmtt-8">&#x00A0;the</span><span
2118class="cmtt-8">&#x00A0;sparse</span><span
2119class="cmtt-8">&#x00A0;flag</span><span
2120class="cmtt-8">&#x00A0;is</span><span
2121class="cmtt-8">&#x00A0;not</span><span
2122class="cmtt-8">&#x00A0;set</span><span
2123class="cmtt-8">&#x00A0;</span><span
2124class="cmsy-8">{</span><br class="fancyvrb" /><a
2125 id="x1-51064r17"></a><span
2126class="cmr-6">17</span>
2127 <br class="fancyvrb" /><a
2128 id="x1-51066r18"></a><span
2129class="cmr-6">18</span><span
2130class="cmtt-8">&#x00A0;</span><span
2131class="cmtt-8">&#x00A0;</span><span
2132class="cmtt-8">&#x00A0;</span><span
2133class="cmtt-8">&#x00A0;</span><span
2134class="cmtt-8">&#x00A0;</span><span
2135class="cmtt-8">&#x00A0;</span><span
2136class="cmtt-8">&#x00A0;</span><span
2137class="cmtt-8">&#x00A0;7)</span><span
2138class="cmtt-8">&#x00A0;[length]</span><span
2139class="cmtt-8">&#x00A0;=</span><span
2140class="cmtt-8">&#x00A0;read</span><span
2141class="cmtt-8">&#x00A0;a</span><span
2142class="cmtt-8">&#x00A0;five</span><span
2143class="cmtt-8">&#x00A0;bit</span><span
2144class="cmtt-8">&#x00A0;unsigned</span><span
2145class="cmtt-8">&#x00A0;integer;</span><br class="fancyvrb" /><a
2146 id="x1-51068r19"></a><span
2147class="cmr-6">19</span><span
2148class="cmtt-8">&#x00A0;</span><span
2149class="cmtt-8">&#x00A0;</span><span
2150class="cmtt-8">&#x00A0;</span><span
2151class="cmtt-8">&#x00A0;</span><span
2152class="cmtt-8">&#x00A0;</span><span
2153class="cmtt-8">&#x00A0;</span><span
2154class="cmtt-8">&#x00A0;</span><span
2155class="cmtt-8">&#x00A0;8)</span><span
2156class="cmtt-8">&#x00A0;the</span><span
2157class="cmtt-8">&#x00A0;codeword</span><span
2158class="cmtt-8">&#x00A0;length</span><span
2159class="cmtt-8">&#x00A0;for</span><span
2160class="cmtt-8">&#x00A0;this</span><span
2161class="cmtt-8">&#x00A0;entry</span><span
2162class="cmtt-8">&#x00A0;is</span><span
2163class="cmtt-8">&#x00A0;[length]+1;</span><br class="fancyvrb" /><a
2164 id="x1-51070r20"></a><span
2165class="cmr-6">20</span><br class="fancyvrb" /><a
2166 id="x1-51072r21"></a><span
2167class="cmr-6">21</span><span
2168class="cmtt-8">&#x00A0;</span><span
2169class="cmtt-8">&#x00A0;</span><span
2170class="cmtt-8">&#x00A0;</span><span
2171class="cmtt-8">&#x00A0;</span><span
2172class="cmtt-8">&#x00A0;</span><span
2173class="cmsy-8">}</span><br class="fancyvrb" /><a
2174 id="x1-51074r22"></a><span
2175class="cmr-6">22</span></div>
2176
2177
2178
2179 </li>
2180 <li class="itemize">If the <span
2181class="cmtt-12">[ordered] </span>flag is set, the codeword list for this codebook is encoded in
2182 ascending length order. Rather than reading a length for every codeword, the
2183 encoder reads the number of codewords per length. That is, beginning at entry
2184 zero:
2185 <!--l. 119--><p class="noindent" >
2186 <div class="fancyvrb" id="fancyvrb12"><a
2187 id="x1-51076r1"></a><span
2188class="cmr-6">1</span><span
2189class="cmtt-8">&#x00A0;</span><span
2190class="cmtt-8">&#x00A0;1)</span><span
2191class="cmtt-8">&#x00A0;[current</span><span
2192class="cmtt-8">_entry]</span><span
2193class="cmtt-8">&#x00A0;=</span><span
2194class="cmtt-8">&#x00A0;0;</span><br class="fancyvrb" /><a
2195 id="x1-51078r2"></a><span
2196class="cmr-6">2</span><span
2197class="cmtt-8">&#x00A0;</span><span
2198class="cmtt-8">&#x00A0;2)</span><span
2199class="cmtt-8">&#x00A0;[current</span><span
2200class="cmtt-8">_length]</span><span
2201class="cmtt-8">&#x00A0;=</span><span
2202class="cmtt-8">&#x00A0;read</span><span
2203class="cmtt-8">&#x00A0;a</span><span
2204class="cmtt-8">&#x00A0;five</span><span
2205class="cmtt-8">&#x00A0;bit</span><span
2206class="cmtt-8">&#x00A0;unsigned</span><span
2207class="cmtt-8">&#x00A0;integer</span><span
2208class="cmtt-8">&#x00A0;and</span><span
2209class="cmtt-8">&#x00A0;add</span><span
2210class="cmtt-8">&#x00A0;1;</span>
2211 <br class="fancyvrb" /><a
2212 id="x1-51080r3"></a><span
2213class="cmr-6">3</span><span
2214class="cmtt-8">&#x00A0;</span><span
2215class="cmtt-8">&#x00A0;3)</span><span
2216class="cmtt-8">&#x00A0;[number]</span><span
2217class="cmtt-8">&#x00A0;=</span><span
2218class="cmtt-8">&#x00A0;read</span><span
2219class="cmtt-8">&#x00A0;</span><a
2220href="#x1-1190009.2.1"><span
2221class="cmtt-8">ilog</span></a><span
2222class="cmtt-8">([codebook</span><span
2223class="cmtt-8">_entries]</span><span
2224class="cmtt-8">&#x00A0;-</span><span
2225class="cmtt-8">&#x00A0;[current</span><span
2226class="cmtt-8">_entry])</span><span
2227class="cmtt-8">&#x00A0;bits</span><span
2228class="cmtt-8">&#x00A0;as</span><span
2229class="cmtt-8">&#x00A0;an</span><span
2230class="cmtt-8">&#x00A0;unsigned</span><span
2231class="cmtt-8">&#x00A0;integer</span>
2232 <br class="fancyvrb" /><a
2233 id="x1-51082r4"></a><span
2234class="cmr-6">4</span><span
2235class="cmtt-8">&#x00A0;</span><span
2236class="cmtt-8">&#x00A0;4)</span><span
2237class="cmtt-8">&#x00A0;set</span><span
2238class="cmtt-8">&#x00A0;the</span><span
2239class="cmtt-8">&#x00A0;entries</span><span
2240class="cmtt-8">&#x00A0;[current</span><span
2241class="cmtt-8">_entry]</span><span
2242class="cmtt-8">&#x00A0;through</span><span
2243class="cmtt-8">&#x00A0;[current</span><span
2244class="cmtt-8">_entry]+[number]-1,</span><span
2245class="cmtt-8">&#x00A0;inclusive,</span>
2246 <br class="fancyvrb" /><a
2247 id="x1-51084r5"></a><span
2248class="cmr-6">5</span><span
2249class="cmtt-8">&#x00A0;</span><span
2250class="cmtt-8">&#x00A0;</span><span
2251class="cmtt-8">&#x00A0;</span><span
2252class="cmtt-8">&#x00A0;of</span><span
2253class="cmtt-8">&#x00A0;the</span><span
2254class="cmtt-8">&#x00A0;[codebook</span><span
2255class="cmtt-8">_codeword</span><span
2256class="cmtt-8">_lengths]</span><span
2257class="cmtt-8">&#x00A0;array</span><span
2258class="cmtt-8">&#x00A0;to</span><span
2259class="cmtt-8">&#x00A0;[current</span><span
2260class="cmtt-8">_length]</span><br class="fancyvrb" /><a
2261 id="x1-51086r6"></a><span
2262class="cmr-6">6</span><span
2263class="cmtt-8">&#x00A0;</span><span
2264class="cmtt-8">&#x00A0;5)</span><span
2265class="cmtt-8">&#x00A0;set</span><span
2266class="cmtt-8">&#x00A0;[current</span><span
2267class="cmtt-8">_entry]</span><span
2268class="cmtt-8">&#x00A0;to</span><span
2269class="cmtt-8">&#x00A0;[number]</span><span
2270class="cmtt-8">&#x00A0;+</span><span
2271class="cmtt-8">&#x00A0;[current</span><span
2272class="cmtt-8">_entry]</span>
2273 <br class="fancyvrb" /><a
2274 id="x1-51088r7"></a><span
2275class="cmr-6">7</span><span
2276class="cmtt-8">&#x00A0;</span><span
2277class="cmtt-8">&#x00A0;6)</span><span
2278class="cmtt-8">&#x00A0;increment</span><span
2279class="cmtt-8">&#x00A0;[current</span><span
2280class="cmtt-8">_length]</span><span
2281class="cmtt-8">&#x00A0;by</span><span
2282class="cmtt-8">&#x00A0;1</span><br class="fancyvrb" /><a
2283 id="x1-51090r8"></a><span
2284class="cmr-6">8</span><span
2285class="cmtt-8">&#x00A0;</span><span
2286class="cmtt-8">&#x00A0;7)</span><span
2287class="cmtt-8">&#x00A0;if</span><span
2288class="cmtt-8">&#x00A0;[current</span><span
2289class="cmtt-8">_entry]</span><span
2290class="cmtt-8">&#x00A0;is</span><span
2291class="cmtt-8">&#x00A0;greater</span><span
2292class="cmtt-8">&#x00A0;than</span><span
2293class="cmtt-8">&#x00A0;[codebook</span><span
2294class="cmtt-8">_entries]</span><span
2295class="cmtt-8">&#x00A0;ERROR</span><span
2296class="cmtt-8">&#x00A0;CONDITION;</span>
2297 <br class="fancyvrb" /><a
2298 id="x1-51092r9"></a><span
2299class="cmr-6">9</span><span
2300class="cmtt-8">&#x00A0;</span><span
2301class="cmtt-8">&#x00A0;</span><span
2302class="cmtt-8">&#x00A0;</span><span
2303class="cmtt-8">&#x00A0;the</span><span
2304class="cmtt-8">&#x00A0;decoder</span><span
2305class="cmtt-8">&#x00A0;will</span><span
2306class="cmtt-8">&#x00A0;not</span><span
2307class="cmtt-8">&#x00A0;be</span><span
2308class="cmtt-8">&#x00A0;able</span><span
2309class="cmtt-8">&#x00A0;to</span><span
2310class="cmtt-8">&#x00A0;read</span><span
2311class="cmtt-8">&#x00A0;this</span><span
2312class="cmtt-8">&#x00A0;stream.</span><br class="fancyvrb" /><a
2313 id="x1-51094r10"></a><span
2314class="cmr-6">10</span><span
2315class="cmtt-8">&#x00A0;</span><span
2316class="cmtt-8">&#x00A0;8)</span><span
2317class="cmtt-8">&#x00A0;if</span><span
2318class="cmtt-8">&#x00A0;[current</span><span
2319class="cmtt-8">_entry]</span><span
2320class="cmtt-8">&#x00A0;is</span><span
2321class="cmtt-8">&#x00A0;less</span><span
2322class="cmtt-8">&#x00A0;than</span><span
2323class="cmtt-8">&#x00A0;[codebook</span><span
2324class="cmtt-8">_entries],</span><span
2325class="cmtt-8">&#x00A0;repeat</span><span
2326class="cmtt-8">&#x00A0;process</span><span
2327class="cmtt-8">&#x00A0;starting</span><span
2328class="cmtt-8">&#x00A0;at</span><span
2329class="cmtt-8">&#x00A0;3)</span>
2330 <br class="fancyvrb" /><a
2331 id="x1-51096r11"></a><span
2332class="cmr-6">11</span><span
2333class="cmtt-8">&#x00A0;</span><span
2334class="cmtt-8">&#x00A0;9)</span><span
2335class="cmtt-8">&#x00A0;done.</span></div>
2336 </li></ul>
2337<!--l. 135--><p class="noindent" >After all codeword lengths have been decoded, the decoder reads the vector lookup table. Vorbis
2338I supports three lookup types:
2339 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
2340 1. </dt><dd
2341class="enumerate-enumitem">No lookup
2342 </dd><dt class="enumerate-enumitem">
2343 2. </dt><dd
2344class="enumerate-enumitem">Implicitly populated value mapping (lattice VQ)
2345 </dd><dt class="enumerate-enumitem">
2346 3. </dt><dd
2347class="enumerate-enumitem">Explicitly populated value mapping (tessellated or &#8217;foam&#8217; VQ)</dd></dl>
2348<!--l. 148--><p class="noindent" >The lookup table type is read as a four bit unsigned integer:
2349<div class="fancyvrb" id="fancyvrb13"><a
2350 id="x1-51101r1"></a><span
2351class="cmr-6">1</span><span
2352class="cmtt-8">&#x00A0;</span><span
2353class="cmtt-8">&#x00A0;1)</span><span
2354class="cmtt-8">&#x00A0;[codebook</span><span
2355class="cmtt-8">_lookup</span><span
2356class="cmtt-8">_type]</span><span
2357class="cmtt-8">&#x00A0;=</span><span
2358class="cmtt-8">&#x00A0;read</span><span
2359class="cmtt-8">&#x00A0;four</span><span
2360class="cmtt-8">&#x00A0;bits</span><span
2361class="cmtt-8">&#x00A0;as</span><span
2362class="cmtt-8">&#x00A0;an</span><span
2363class="cmtt-8">&#x00A0;unsigned</span><span
2364class="cmtt-8">&#x00A0;integer</span></div>
2365<!--l. 153--><p class="noindent" >Codebook decode precedes according to <span
2366class="cmtt-12">[codebook</span><span
2367class="cmtt-12">_lookup</span><span
2368class="cmtt-12">_type]</span>:
2369 <ul class="itemize1">
2370 <li class="itemize">Lookup type zero indicates no lookup to be read. Proceed past lookup decode.
2371 </li>
2372 <li class="itemize">Lookup types one and two are similar, differing only in the number of lookup values to
2373 be read. Lookup type one reads a list of values that are permuted in a set pattern to
2374 build a list of vectors, each vector of order <span
2375class="cmtt-12">[codebook</span><span
2376class="cmtt-12">_dimensions] </span>scalars. Lookup
2377 type two builds the same vector list, but reads each scalar for each vector explicitly,
2378 rather than building vectors from a smaller list of possible scalar values. Lookup
2379 decode proceeds as follows:
2380 <!--l. 167--><p class="noindent" >
2381 <div class="fancyvrb" id="fancyvrb14"><a
2382 id="x1-51103r1"></a><span
2383class="cmr-6">1</span><span
2384class="cmtt-8">&#x00A0;</span><span
2385class="cmtt-8">&#x00A0;1)</span><span
2386class="cmtt-8">&#x00A0;[codebook</span><span
2387class="cmtt-8">_minimum</span><span
2388class="cmtt-8">_value]</span><span
2389class="cmtt-8">&#x00A0;=</span><span
2390class="cmtt-8">&#x00A0;</span><a
2391href="#x1-1200009.2.2"><span
2392class="cmtt-8">float32</span><span
2393class="cmtt-8">_unpack</span></a><span
2394class="cmtt-8">(</span><span
2395class="cmtt-8">&#x00A0;read</span><span
2396class="cmtt-8">&#x00A0;32</span><span
2397class="cmtt-8">&#x00A0;bits</span><span
2398class="cmtt-8">&#x00A0;as</span><span
2399class="cmtt-8">&#x00A0;an</span><span
2400class="cmtt-8">&#x00A0;unsigned</span><span
2401class="cmtt-8">&#x00A0;integer)</span>
2402 <br class="fancyvrb" /><a
2403 id="x1-51105r2"></a><span
2404class="cmr-6">2</span><span
2405class="cmtt-8">&#x00A0;</span><span
2406class="cmtt-8">&#x00A0;2)</span><span
2407class="cmtt-8">&#x00A0;[codebook</span><span
2408class="cmtt-8">_delta</span><span
2409class="cmtt-8">_value]</span><span
2410class="cmtt-8">&#x00A0;=</span><span
2411class="cmtt-8">&#x00A0;</span><a
2412href="#x1-1200009.2.2"><span
2413class="cmtt-8">float32</span><span
2414class="cmtt-8">_unpack</span></a><span
2415class="cmtt-8">(</span><span
2416class="cmtt-8">&#x00A0;read</span><span
2417class="cmtt-8">&#x00A0;32</span><span
2418class="cmtt-8">&#x00A0;bits</span><span
2419class="cmtt-8">&#x00A0;as</span><span
2420class="cmtt-8">&#x00A0;an</span><span
2421class="cmtt-8">&#x00A0;unsigned</span><span
2422class="cmtt-8">&#x00A0;integer)</span>
2423 <br class="fancyvrb" /><a
2424 id="x1-51107r3"></a><span
2425class="cmr-6">3</span><span
2426class="cmtt-8">&#x00A0;</span><span
2427class="cmtt-8">&#x00A0;3)</span><span
2428class="cmtt-8">&#x00A0;[codebook</span><span
2429class="cmtt-8">_value</span><span
2430class="cmtt-8">_bits]</span><span
2431class="cmtt-8">&#x00A0;=</span><span
2432class="cmtt-8">&#x00A0;read</span><span
2433class="cmtt-8">&#x00A0;4</span><span
2434class="cmtt-8">&#x00A0;bits</span><span
2435class="cmtt-8">&#x00A0;as</span><span
2436class="cmtt-8">&#x00A0;an</span><span
2437class="cmtt-8">&#x00A0;unsigned</span><span
2438class="cmtt-8">&#x00A0;integer</span><span
2439class="cmtt-8">&#x00A0;and</span><span
2440class="cmtt-8">&#x00A0;add</span><span
2441class="cmtt-8">&#x00A0;1</span><br class="fancyvrb" /><a
2442 id="x1-51109r4"></a><span
2443class="cmr-6">4</span><span
2444class="cmtt-8">&#x00A0;</span><span
2445class="cmtt-8">&#x00A0;4)</span><span
2446class="cmtt-8">&#x00A0;[codebook</span><span
2447class="cmtt-8">_sequence</span><span
2448class="cmtt-8">_p]</span><span
2449class="cmtt-8">&#x00A0;=</span><span
2450class="cmtt-8">&#x00A0;read</span><span
2451class="cmtt-8">&#x00A0;1</span><span
2452class="cmtt-8">&#x00A0;bit</span><span
2453class="cmtt-8">&#x00A0;as</span><span
2454class="cmtt-8">&#x00A0;a</span><span
2455class="cmtt-8">&#x00A0;boolean</span><span
2456class="cmtt-8">&#x00A0;flag</span><br class="fancyvrb" /><a
2457 id="x1-51111r5"></a><span
2458class="cmr-6">5</span>
2459
2460
2461
2462 <br class="fancyvrb" /><a
2463 id="x1-51113r6"></a><span
2464class="cmr-6">6</span><span
2465class="cmtt-8">&#x00A0;</span><span
2466class="cmtt-8">&#x00A0;if</span><span
2467class="cmtt-8">&#x00A0;(</span><span
2468class="cmtt-8">&#x00A0;[codebook</span><span
2469class="cmtt-8">_lookup</span><span
2470class="cmtt-8">_type]</span><span
2471class="cmtt-8">&#x00A0;is</span><span
2472class="cmtt-8">&#x00A0;1</span><span
2473class="cmtt-8">&#x00A0;)</span><span
2474class="cmtt-8">&#x00A0;</span><span
2475class="cmsy-8">{</span><br class="fancyvrb" /><a
2476 id="x1-51115r7"></a><span
2477class="cmr-6">7</span><br class="fancyvrb" /><a
2478 id="x1-51117r8"></a><span
2479class="cmr-6">8</span><span
2480class="cmtt-8">&#x00A0;</span><span
2481class="cmtt-8">&#x00A0;</span><span
2482class="cmtt-8">&#x00A0;</span><span
2483class="cmtt-8">&#x00A0;</span><span
2484class="cmtt-8">&#x00A0;5)</span><span
2485class="cmtt-8">&#x00A0;[codebook</span><span
2486class="cmtt-8">_lookup</span><span
2487class="cmtt-8">_values]</span><span
2488class="cmtt-8">&#x00A0;=</span><span
2489class="cmtt-8">&#x00A0;</span><a
2490href="#x1-1210009.2.3"><span
2491class="cmtt-8">lookup1</span><span
2492class="cmtt-8">_values</span></a><span
2493class="cmtt-8">([codebook</span><span
2494class="cmtt-8">_entries],</span><span
2495class="cmtt-8">&#x00A0;[codebook</span><span
2496class="cmtt-8">_dimensions]</span><span
2497class="cmtt-8">&#x00A0;)</span><br class="fancyvrb" /><a
2498 id="x1-51119r9"></a><span
2499class="cmr-6">9</span>
2500 <br class="fancyvrb" /><a
2501 id="x1-51121r10"></a><span
2502class="cmr-6">10</span><span
2503class="cmtt-8">&#x00A0;</span><span
2504class="cmtt-8">&#x00A0;</span><span
2505class="cmsy-8">}</span><span
2506class="cmtt-8">&#x00A0;else</span><span
2507class="cmtt-8">&#x00A0;</span><span
2508class="cmsy-8">{</span><br class="fancyvrb" /><a
2509 id="x1-51123r11"></a><span
2510class="cmr-6">11</span><br class="fancyvrb" /><a
2511 id="x1-51125r12"></a><span
2512class="cmr-6">12</span><span
2513class="cmtt-8">&#x00A0;</span><span
2514class="cmtt-8">&#x00A0;</span><span
2515class="cmtt-8">&#x00A0;</span><span
2516class="cmtt-8">&#x00A0;</span><span
2517class="cmtt-8">&#x00A0;6)</span><span
2518class="cmtt-8">&#x00A0;[codebook</span><span
2519class="cmtt-8">_lookup</span><span
2520class="cmtt-8">_values]</span><span
2521class="cmtt-8">&#x00A0;=</span><span
2522class="cmtt-8">&#x00A0;[codebook</span><span
2523class="cmtt-8">_entries]</span><span
2524class="cmtt-8">&#x00A0;*</span><span
2525class="cmtt-8">&#x00A0;[codebook</span><span
2526class="cmtt-8">_dimensions]</span><br class="fancyvrb" /><a
2527 id="x1-51127r13"></a><span
2528class="cmr-6">13</span><br class="fancyvrb" /><a
2529 id="x1-51129r14"></a><span
2530class="cmr-6">14</span><span
2531class="cmtt-8">&#x00A0;</span><span
2532class="cmtt-8">&#x00A0;</span><span
2533class="cmsy-8">}</span><br class="fancyvrb" /><a
2534 id="x1-51131r15"></a><span
2535class="cmr-6">15</span>
2536 <br class="fancyvrb" /><a
2537 id="x1-51133r16"></a><span
2538class="cmr-6">16</span><span
2539class="cmtt-8">&#x00A0;</span><span
2540class="cmtt-8">&#x00A0;7)</span><span
2541class="cmtt-8">&#x00A0;read</span><span
2542class="cmtt-8">&#x00A0;a</span><span
2543class="cmtt-8">&#x00A0;total</span><span
2544class="cmtt-8">&#x00A0;of</span><span
2545class="cmtt-8">&#x00A0;[codebook</span><span
2546class="cmtt-8">_lookup</span><span
2547class="cmtt-8">_values]</span><span
2548class="cmtt-8">&#x00A0;unsigned</span><span
2549class="cmtt-8">&#x00A0;integers</span><span
2550class="cmtt-8">&#x00A0;of</span><span
2551class="cmtt-8">&#x00A0;[codebook</span><span
2552class="cmtt-8">_value</span><span
2553class="cmtt-8">_bits]</span><span
2554class="cmtt-8">&#x00A0;each;</span>
2555 <br class="fancyvrb" /><a
2556 id="x1-51135r17"></a><span
2557class="cmr-6">17</span><span
2558class="cmtt-8">&#x00A0;</span><span
2559class="cmtt-8">&#x00A0;</span><span
2560class="cmtt-8">&#x00A0;</span><span
2561class="cmtt-8">&#x00A0;</span><span
2562class="cmtt-8">&#x00A0;store</span><span
2563class="cmtt-8">&#x00A0;these</span><span
2564class="cmtt-8">&#x00A0;in</span><span
2565class="cmtt-8">&#x00A0;order</span><span
2566class="cmtt-8">&#x00A0;in</span><span
2567class="cmtt-8">&#x00A0;the</span><span
2568class="cmtt-8">&#x00A0;array</span><span
2569class="cmtt-8">&#x00A0;[codebook</span><span
2570class="cmtt-8">_multiplicands]</span></div>
2571 </li>
2572 <li class="itemize">A <span
2573class="cmtt-12">[codebook</span><span
2574class="cmtt-12">_lookup</span><span
2575class="cmtt-12">_type] </span>of greater than two is reserved and indicates a stream that is
2576 not decodable by the specification in this document.
2577 </li></ul>
2578<!--l. 194--><p class="noindent" >An &#8217;end of packet&#8217; during any read operation in the above steps is considered an error condition
2579rendering the stream undecodable.
2580<!--l. 197--><p class="noindent" ><span class="paragraphHead"><a
2581 id="x1-520003.2.1"></a><span
2582class="cmbx-12">Huffman decision tree representation</span></span>
2583The <span
2584class="cmtt-12">[codebook</span><span
2585class="cmtt-12">_codeword</span><span
2586class="cmtt-12">_lengths] </span>array and <span
2587class="cmtt-12">[codebook</span><span
2588class="cmtt-12">_entries] </span>value uniquely define the
2589Huffman decision tree used for entropy decoding.
2590<!--l. 203--><p class="noindent" >Briefly, each used codebook entry (recall that length-unordered codebooks support unused
2591codeword entries) is assigned, in order, the lowest valued unused binary Huffman codeword
2592possible. Assume the following codeword length list:
2593<!--l. 208--><p class="noindent" >
2594<div class="fancyvrb" id="fancyvrb15"><a
2595 id="x1-52002r1"></a><span
2596class="cmr-6">1</span><span
2597class="cmtt-8">entry</span><span
2598class="cmtt-8">&#x00A0;0:</span><span
2599class="cmtt-8">&#x00A0;length</span><span
2600class="cmtt-8">&#x00A0;2</span><br class="fancyvrb" /><a
2601 id="x1-52004r2"></a><span
2602class="cmr-6">2</span><span
2603class="cmtt-8">entry</span><span
2604class="cmtt-8">&#x00A0;1:</span><span
2605class="cmtt-8">&#x00A0;length</span><span
2606class="cmtt-8">&#x00A0;4</span><br class="fancyvrb" /><a
2607 id="x1-52006r3"></a><span
2608class="cmr-6">3</span><span
2609class="cmtt-8">entry</span><span
2610class="cmtt-8">&#x00A0;2:</span><span
2611class="cmtt-8">&#x00A0;length</span><span
2612class="cmtt-8">&#x00A0;4</span><br class="fancyvrb" /><a
2613 id="x1-52008r4"></a><span
2614class="cmr-6">4</span><span
2615class="cmtt-8">entry</span><span
2616class="cmtt-8">&#x00A0;3:</span><span
2617class="cmtt-8">&#x00A0;length</span><span
2618class="cmtt-8">&#x00A0;4</span><br class="fancyvrb" /><a
2619 id="x1-52010r5"></a><span
2620class="cmr-6">5</span><span
2621class="cmtt-8">entry</span><span
2622class="cmtt-8">&#x00A0;4:</span><span
2623class="cmtt-8">&#x00A0;length</span><span
2624class="cmtt-8">&#x00A0;4</span><br class="fancyvrb" /><a
2625 id="x1-52012r6"></a><span
2626class="cmr-6">6</span><span
2627class="cmtt-8">entry</span><span
2628class="cmtt-8">&#x00A0;5:</span><span
2629class="cmtt-8">&#x00A0;length</span><span
2630class="cmtt-8">&#x00A0;2</span><br class="fancyvrb" /><a
2631 id="x1-52014r7"></a><span
2632class="cmr-6">7</span><span
2633class="cmtt-8">entry</span><span
2634class="cmtt-8">&#x00A0;6:</span><span
2635class="cmtt-8">&#x00A0;length</span><span
2636class="cmtt-8">&#x00A0;3</span><br class="fancyvrb" /><a
2637 id="x1-52016r8"></a><span
2638class="cmr-6">8</span><span
2639class="cmtt-8">entry</span><span
2640class="cmtt-8">&#x00A0;7:</span><span
2641class="cmtt-8">&#x00A0;length</span><span
2642class="cmtt-8">&#x00A0;3</span></div>
2643<!--l. 219--><p class="noindent" >Assigning codewords in order (lowest possible value of the appropriate length to highest) results
2644in the following codeword list:
2645<!--l. 222--><p class="noindent" >
2646<div class="fancyvrb" id="fancyvrb16"><a
2647 id="x1-52018r1"></a><span
2648class="cmr-6">1</span><span
2649class="cmtt-8">entry</span><span
2650class="cmtt-8">&#x00A0;0:</span><span
2651class="cmtt-8">&#x00A0;length</span><span
2652class="cmtt-8">&#x00A0;2</span><span
2653class="cmtt-8">&#x00A0;codeword</span><span
2654class="cmtt-8">&#x00A0;00</span><br class="fancyvrb" /><a
2655 id="x1-52020r2"></a><span
2656class="cmr-6">2</span><span
2657class="cmtt-8">entry</span><span
2658class="cmtt-8">&#x00A0;1:</span><span
2659class="cmtt-8">&#x00A0;length</span><span
2660class="cmtt-8">&#x00A0;4</span><span
2661class="cmtt-8">&#x00A0;codeword</span><span
2662class="cmtt-8">&#x00A0;0100</span><br class="fancyvrb" /><a
2663 id="x1-52022r3"></a><span
2664class="cmr-6">3</span><span
2665class="cmtt-8">entry</span><span
2666class="cmtt-8">&#x00A0;2:</span><span
2667class="cmtt-8">&#x00A0;length</span><span
2668class="cmtt-8">&#x00A0;4</span><span
2669class="cmtt-8">&#x00A0;codeword</span><span
2670class="cmtt-8">&#x00A0;0101</span><br class="fancyvrb" /><a
2671 id="x1-52024r4"></a><span
2672class="cmr-6">4</span><span
2673class="cmtt-8">entry</span><span
2674class="cmtt-8">&#x00A0;3:</span><span
2675class="cmtt-8">&#x00A0;length</span><span
2676class="cmtt-8">&#x00A0;4</span><span
2677class="cmtt-8">&#x00A0;codeword</span><span
2678class="cmtt-8">&#x00A0;0110</span>
2679<br class="fancyvrb" /><a
2680 id="x1-52026r5"></a><span
2681class="cmr-6">5</span><span
2682class="cmtt-8">entry</span><span
2683class="cmtt-8">&#x00A0;4:</span><span
2684class="cmtt-8">&#x00A0;length</span><span
2685class="cmtt-8">&#x00A0;4</span><span
2686class="cmtt-8">&#x00A0;codeword</span><span
2687class="cmtt-8">&#x00A0;0111</span><br class="fancyvrb" /><a
2688 id="x1-52028r6"></a><span
2689class="cmr-6">6</span><span
2690class="cmtt-8">entry</span><span
2691class="cmtt-8">&#x00A0;5:</span><span
2692class="cmtt-8">&#x00A0;length</span><span
2693class="cmtt-8">&#x00A0;2</span><span
2694class="cmtt-8">&#x00A0;codeword</span><span
2695class="cmtt-8">&#x00A0;10</span><br class="fancyvrb" /><a
2696 id="x1-52030r7"></a><span
2697class="cmr-6">7</span><span
2698class="cmtt-8">entry</span><span
2699class="cmtt-8">&#x00A0;6:</span><span
2700class="cmtt-8">&#x00A0;length</span><span
2701class="cmtt-8">&#x00A0;3</span><span
2702class="cmtt-8">&#x00A0;codeword</span><span
2703class="cmtt-8">&#x00A0;110</span><br class="fancyvrb" /><a
2704 id="x1-52032r8"></a><span
2705class="cmr-6">8</span><span
2706class="cmtt-8">entry</span><span
2707class="cmtt-8">&#x00A0;7:</span><span
2708class="cmtt-8">&#x00A0;length</span><span
2709class="cmtt-8">&#x00A0;3</span><span
2710class="cmtt-8">&#x00A0;codeword</span><span
2711class="cmtt-8">&#x00A0;111</span></div>
2712<!--l. 234--><p class="noindent" ><span class="likesubparagraphHead"><a
2713 id="x1-530003.2.1"></a><span
2714class="cmbx-12">Note:</span></span> Unlike most binary numerical values in this document, we intend the above codewords to
2715be read and used bit by bit from left to right, thus the codeword &#8217;001&#8217; is the bit string &#8217;zero, zero,
2716one&#8217;. When determining &#8217;lowest possible value&#8217; in the assignment definition above, the leftmost
2717bit is the MSb.
2718<!--l. 242--><p class="noindent" >It is clear that the codeword length list represents a Huffman decision tree with the entry
2719numbers equivalent to the leaves numbered left-to-right:
2720
2721
2722
2723<div class="center"
2724>
2725<!--l. 246--><p class="noindent" >
2726
2727<!--l. 247--><p class="noindent" ><img
2728src="hufftree.png" alt="PIC"
2729>
2730<br /> <div class="caption"
2731><span class="id">Figure&#x00A0;4: </span><span
2732class="content">huffman tree illustration</span></div><!--tex4ht:label?: x1-530014 -->
2733</div>
2734<!--l. 252--><p class="noindent" >As we assign codewords in order, we see that each choice constructs a new leaf in the leftmost
2735possible position.
2736<!--l. 255--><p class="noindent" >Note that it&#8217;s possible to underspecify or overspecify a Huffman tree via the length list.
2737In the above example, if codeword seven were eliminated, it&#8217;s clear that the tree is
2738unfinished:
2739<div class="center"
2740>
2741<!--l. 259--><p class="noindent" >
2742
2743<!--l. 260--><p class="noindent" ><img
2744src="hufftree-under.png" alt="PIC"
2745>
2746<br /> <div class="caption"
2747><span class="id">Figure&#x00A0;5: </span><span
2748class="content">underspecified huffman tree illustration</span></div><!--tex4ht:label?: x1-530025 -->
2749</div>
2750<!--l. 265--><p class="noindent" >Similarly, in the original codebook, it&#8217;s clear that the tree is fully populated and a ninth
2751codeword is impossible. Both underspecified and overspecified trees are an error condition
2752rendering the stream undecodable.
2753<!--l. 270--><p class="noindent" >Codebook entries marked &#8217;unused&#8217; are simply skipped in the assigning process. They have no
2754codeword and do not appear in the decision tree, thus it&#8217;s impossible for any bit pattern read
2755from the stream to decode to that entry number.
2756<!--l. 275--><p class="noindent" ><span class="paragraphHead"><a
2757 id="x1-540003.2.1"></a><span
2758class="cmbx-12">Errata 20150226: Single entry codebooks</span></span>
2759A &#8217;single-entry codebook&#8217; is a codebook with one active codeword entry. A single-entry codebook
2760may be either a fully populated codebook with only one declared entry, or a sparse codebook
2761with only one entry marked used. The Vorbis I spec provides no means to specify a codeword
2762length of zero, and as a result, a single-entry codebook is inherently malformed because it is
2763underpopulated. The original specification did not address directly the matter of single-entry
2764codebooks; they were implicitly illegal as it was not possible to write such a codebook with a
2765valid tree structure.
2766
2767
2768
2769<!--l. 287--><p class="noindent" >In r14811 of the libvorbis reference implementation, Xiph added an additional check to the
2770codebook implementation to reject underpopulated Huffman trees. This change led to the
2771discovery of single-entry books used &#8217;in the wild&#8217; when the new, stricter checks rejected a number
2772of apparently working streams.
2773<!--l. 293--><p class="noindent" >In order to minimize breakage of deployed (if technically erroneous) streams, r16073 of the
2774reference implementation explicitly special-cased single-entry codebooks to tolerate the
2775single-entry case. Commit r16073 also added the following to the specification:
2776<!--l. 302--><p class="noindent" >&#8220;<span class="sout">Take special care that a codebook with a single used entry is handled properly; it consists of a
2777single codework of zero bits and reading a value out of such a codebook always returns the single
2778used value and sinks zero bits. </span>&#8221;
2779<!--l. 304--><p class="noindent" >The intent was to clarify the spec and codify current practice. However, this addition is
2780erroneously at odds with the intent of preserving usability of existing streams using single-entry
2781codebooks, disagrees with the code changes that reinstated decoding, and does not address how
2782single-entry codebooks should be encoded.
2783<!--l. 310--><p class="noindent" >As such, the above addition made in r16037 is struck from the specification and replaced by the
2784following:
2785<!--l. 329--><p class="noindent" >
2786 <div class="quote">
2787 <!--l. 329--><p class="noindent" >It is possible to declare a Vorbis codebook containing a single codework
2788 entry. A single-entry codebook may be either a fully populated codebook with
2789 <span
2790class="cmtt-12">[codebook</span><span
2791class="cmtt-12">_entries] </span>set to 1, or a sparse codebook marking only one entry
2792 used. Note that it is not possible to also encode a <span
2793class="cmtt-12">[codeword</span><span
2794class="cmtt-12">_length] </span>of zero
2795 for the single used codeword, as the unsigned value written to the stream
2796 is <span
2797class="cmtt-12">[codeword</span><span
2798class="cmtt-12">_length]-1</span>. Instead, encoder implementations should indicate a
2799 <span
2800class="cmtt-12">[codeword</span><span
2801class="cmtt-12">_length] </span>of 1 and &#8217;write&#8217; the codeword to a stream during audio
2802 encoding by writing a single zero bit.
2803 <!--l. 329--><p class="noindent" >Decoder implementations shall reject a codebook if it contains only one used
2804 entry and the encoded <span
2805class="cmtt-12">[codeword</span><span
2806class="cmtt-12">_length] </span>of that entry is not 1. &#8217;Reading&#8217; a
2807 value from single-entry codebook always returns the single used codeword value
2808 and sinks one bit. Decoders should tolerate that the bit read from the stream
2809 be &#8217;1&#8217; instead of &#8217;0&#8217;; both values shall return the single used codeword.</div>
2810<!--l. 331--><p class="noindent" ><span class="paragraphHead"><a
2811 id="x1-550003.2.1"></a><span
2812class="cmbx-12">VQ lookup table vector representation</span></span>
2813Unpacking the VQ lookup table vectors relies on the following values:
2814
2815
2816
2817<div class="fancyvrb" id="fancyvrb17"><a
2818 id="x1-55002r1"></a><span
2819class="cmr-6">1</span><span
2820class="cmtt-8">the</span><span
2821class="cmtt-8">&#x00A0;[codebook\_multiplicands]</span><span
2822class="cmtt-8">&#x00A0;array</span><br class="fancyvrb" /><a
2823 id="x1-55004r2"></a><span
2824class="cmr-6">2</span><span
2825class="cmtt-8">[codebook\_minimum\_value]</span><br class="fancyvrb" /><a
2826 id="x1-55006r3"></a><span
2827class="cmr-6">3</span><span
2828class="cmtt-8">[codebook\_delta\_value]</span><br class="fancyvrb" /><a
2829 id="x1-55008r4"></a><span
2830class="cmr-6">4</span><span
2831class="cmtt-8">[codebook\_sequence\_p]</span>
2832<br class="fancyvrb" /><a
2833 id="x1-55010r5"></a><span
2834class="cmr-6">5</span><span
2835class="cmtt-8">[codebook\_lookup\_type]</span><br class="fancyvrb" /><a
2836 id="x1-55012r6"></a><span
2837class="cmr-6">6</span><span
2838class="cmtt-8">[codebook\_entries]</span><br class="fancyvrb" /><a
2839 id="x1-55014r7"></a><span
2840class="cmr-6">7</span><span
2841class="cmtt-8">[codebook\_dimensions]</span><br class="fancyvrb" /><a
2842 id="x1-55016r8"></a><span
2843class="cmr-6">8</span><span
2844class="cmtt-8">[codebook\_lookup\_values]</span></div>
2845<!--l. 347--><p class="noindent" >Decoding (unpacking) a specific vector in the vector lookup table proceeds according to
2846<span
2847class="cmtt-12">[codebook</span><span
2848class="cmtt-12">_lookup</span><span
2849class="cmtt-12">_type]</span>. The unpacked vector values are what a codebook would return
2850during audio packet decode in a VQ context.
2851<!--l. 352--><p class="noindent" ><span class="paragraphHead"><a
2852 id="x1-560003.2.1"></a><span
2853class="cmbx-12">Vector value decode: Lookup type 1</span></span>
2854Lookup type one specifies a lattice VQ lookup table built algorithmically from a list of
2855scalar values. Calculate (unpack) the final values of a codebook entry vector from
2856the entries in <span
2857class="cmtt-12">[codebook</span><span
2858class="cmtt-12">_multiplicands] </span>as follows (<span
2859class="cmtt-12">[value</span><span
2860class="cmtt-12">_vector] </span>is the output
2861vector representing the vector of values for entry number <span
2862class="cmtt-12">[lookup</span><span
2863class="cmtt-12">_offset] </span>in this
2864codebook):
2865<!--l. 361--><p class="noindent" >
2866<div class="fancyvrb" id="fancyvrb18"><a
2867 id="x1-56002r1"></a><span
2868class="cmr-6">1</span><span
2869class="cmtt-8">&#x00A0;</span><span
2870class="cmtt-8">&#x00A0;1)</span><span
2871class="cmtt-8">&#x00A0;[last]</span><span
2872class="cmtt-8">&#x00A0;=</span><span
2873class="cmtt-8">&#x00A0;0;</span><br class="fancyvrb" /><a
2874 id="x1-56004r2"></a><span
2875class="cmr-6">2</span><span
2876class="cmtt-8">&#x00A0;</span><span
2877class="cmtt-8">&#x00A0;2)</span><span
2878class="cmtt-8">&#x00A0;[index</span><span
2879class="cmtt-8">_divisor]</span><span
2880class="cmtt-8">&#x00A0;=</span><span
2881class="cmtt-8">&#x00A0;1;</span><br class="fancyvrb" /><a
2882 id="x1-56006r3"></a><span
2883class="cmr-6">3</span><span
2884class="cmtt-8">&#x00A0;</span><span
2885class="cmtt-8">&#x00A0;3)</span><span
2886class="cmtt-8">&#x00A0;iterate</span><span
2887class="cmtt-8">&#x00A0;[i]</span><span
2888class="cmtt-8">&#x00A0;over</span><span
2889class="cmtt-8">&#x00A0;the</span><span
2890class="cmtt-8">&#x00A0;range</span><span
2891class="cmtt-8">&#x00A0;0</span><span
2892class="cmtt-8">&#x00A0;...</span><span
2893class="cmtt-8">&#x00A0;[codebook</span><span
2894class="cmtt-8">_dimensions]-1</span><span
2895class="cmtt-8">&#x00A0;(once</span><span
2896class="cmtt-8">&#x00A0;for</span><span
2897class="cmtt-8">&#x00A0;each</span><span
2898class="cmtt-8">&#x00A0;scalar</span><span
2899class="cmtt-8">&#x00A0;value</span><span
2900class="cmtt-8">&#x00A0;in</span><span
2901class="cmtt-8">&#x00A0;the</span><span
2902class="cmtt-8">&#x00A0;value</span><span
2903class="cmtt-8">&#x00A0;vector)</span><span
2904class="cmtt-8">&#x00A0;</span><span
2905class="cmsy-8">{</span><br class="fancyvrb" /><a
2906 id="x1-56008r4"></a><span
2907class="cmr-6">4</span>
2908<br class="fancyvrb" /><a
2909 id="x1-56010r5"></a><span
2910class="cmr-6">5</span><span
2911class="cmtt-8">&#x00A0;</span><span
2912class="cmtt-8">&#x00A0;</span><span
2913class="cmtt-8">&#x00A0;</span><span
2914class="cmtt-8">&#x00A0;</span><span
2915class="cmtt-8">&#x00A0;</span><span
2916class="cmtt-8">&#x00A0;</span><span
2917class="cmtt-8">&#x00A0;4)</span><span
2918class="cmtt-8">&#x00A0;[multiplicand</span><span
2919class="cmtt-8">_offset]</span><span
2920class="cmtt-8">&#x00A0;=</span><span
2921class="cmtt-8">&#x00A0;(</span><span
2922class="cmtt-8">&#x00A0;[lookup</span><span
2923class="cmtt-8">_offset]</span><span
2924class="cmtt-8">&#x00A0;divided</span><span
2925class="cmtt-8">&#x00A0;by</span><span
2926class="cmtt-8">&#x00A0;[index</span><span
2927class="cmtt-8">_divisor]</span><span
2928class="cmtt-8">&#x00A0;using</span><span
2929class="cmtt-8">&#x00A0;integer</span>
2930<br class="fancyvrb" /><a
2931 id="x1-56012r6"></a><span
2932class="cmr-6">6</span><span
2933class="cmtt-8">&#x00A0;</span><span
2934class="cmtt-8">&#x00A0;</span><span
2935class="cmtt-8">&#x00A0;</span><span
2936class="cmtt-8">&#x00A0;</span><span
2937class="cmtt-8">&#x00A0;</span><span
2938class="cmtt-8">&#x00A0;</span><span
2939class="cmtt-8">&#x00A0;</span><span
2940class="cmtt-8">&#x00A0;</span><span
2941class="cmtt-8">&#x00A0;</span><span
2942class="cmtt-8">&#x00A0;division</span><span
2943class="cmtt-8">&#x00A0;)</span><span
2944class="cmtt-8">&#x00A0;integer</span><span
2945class="cmtt-8">&#x00A0;modulo</span><span
2946class="cmtt-8">&#x00A0;[codebook</span><span
2947class="cmtt-8">_lookup</span><span
2948class="cmtt-8">_values]</span><br class="fancyvrb" /><a
2949 id="x1-56014r7"></a><span
2950class="cmr-6">7</span><br class="fancyvrb" /><a
2951 id="x1-56016r8"></a><span
2952class="cmr-6">8</span><span
2953class="cmtt-8">&#x00A0;</span><span
2954class="cmtt-8">&#x00A0;</span><span
2955class="cmtt-8">&#x00A0;</span><span
2956class="cmtt-8">&#x00A0;</span><span
2957class="cmtt-8">&#x00A0;</span><span
2958class="cmtt-8">&#x00A0;</span><span
2959class="cmtt-8">&#x00A0;5)</span><span
2960class="cmtt-8">&#x00A0;vector</span><span
2961class="cmtt-8">&#x00A0;[value</span><span
2962class="cmtt-8">_vector]</span><span
2963class="cmtt-8">&#x00A0;element</span><span
2964class="cmtt-8">&#x00A0;[i]</span><span
2965class="cmtt-8">&#x00A0;=</span>
2966<br class="fancyvrb" /><a
2967 id="x1-56018r9"></a><span
2968class="cmr-6">9</span><span
2969class="cmtt-8">&#x00A0;</span><span
2970class="cmtt-8">&#x00A0;</span><span
2971class="cmtt-8">&#x00A0;</span><span
2972class="cmtt-8">&#x00A0;</span><span
2973class="cmtt-8">&#x00A0;</span><span
2974class="cmtt-8">&#x00A0;</span><span
2975class="cmtt-8">&#x00A0;</span><span
2976class="cmtt-8">&#x00A0;</span><span
2977class="cmtt-8">&#x00A0;</span><span
2978class="cmtt-8">&#x00A0;</span><span
2979class="cmtt-8">&#x00A0;</span><span
2980class="cmtt-8">&#x00A0;(</span><span
2981class="cmtt-8">&#x00A0;[codebook</span><span
2982class="cmtt-8">_multiplicands]</span><span
2983class="cmtt-8">&#x00A0;array</span><span
2984class="cmtt-8">&#x00A0;element</span><span
2985class="cmtt-8">&#x00A0;number</span><span
2986class="cmtt-8">&#x00A0;[multiplicand</span><span
2987class="cmtt-8">_offset]</span><span
2988class="cmtt-8">&#x00A0;)</span><span
2989class="cmtt-8">&#x00A0;*</span>
2990<br class="fancyvrb" /><a
2991 id="x1-56020r10"></a><span
2992class="cmr-6">10</span><span
2993class="cmtt-8">&#x00A0;</span><span
2994class="cmtt-8">&#x00A0;</span><span
2995class="cmtt-8">&#x00A0;</span><span
2996class="cmtt-8">&#x00A0;</span><span
2997class="cmtt-8">&#x00A0;</span><span
2998class="cmtt-8">&#x00A0;</span><span
2999class="cmtt-8">&#x00A0;</span><span
3000class="cmtt-8">&#x00A0;</span><span
3001class="cmtt-8">&#x00A0;</span><span
3002class="cmtt-8">&#x00A0;</span><span
3003class="cmtt-8">&#x00A0;</span><span
3004class="cmtt-8">&#x00A0;[codebook</span><span
3005class="cmtt-8">_delta</span><span
3006class="cmtt-8">_value]</span><span
3007class="cmtt-8">&#x00A0;+</span><span
3008class="cmtt-8">&#x00A0;[codebook</span><span
3009class="cmtt-8">_minimum</span><span
3010class="cmtt-8">_value]</span><span
3011class="cmtt-8">&#x00A0;+</span><span
3012class="cmtt-8">&#x00A0;[last];</span><br class="fancyvrb" /><a
3013 id="x1-56022r11"></a><span
3014class="cmr-6">11</span>
3015<br class="fancyvrb" /><a
3016 id="x1-56024r12"></a><span
3017class="cmr-6">12</span><span
3018class="cmtt-8">&#x00A0;</span><span
3019class="cmtt-8">&#x00A0;</span><span
3020class="cmtt-8">&#x00A0;</span><span
3021class="cmtt-8">&#x00A0;</span><span
3022class="cmtt-8">&#x00A0;</span><span
3023class="cmtt-8">&#x00A0;</span><span
3024class="cmtt-8">&#x00A0;6)</span><span
3025class="cmtt-8">&#x00A0;if</span><span
3026class="cmtt-8">&#x00A0;(</span><span
3027class="cmtt-8">&#x00A0;[codebook</span><span
3028class="cmtt-8">_sequence</span><span
3029class="cmtt-8">_p]</span><span
3030class="cmtt-8">&#x00A0;is</span><span
3031class="cmtt-8">&#x00A0;set</span><span
3032class="cmtt-8">&#x00A0;)</span><span
3033class="cmtt-8">&#x00A0;then</span><span
3034class="cmtt-8">&#x00A0;set</span><span
3035class="cmtt-8">&#x00A0;[last]</span><span
3036class="cmtt-8">&#x00A0;=</span><span
3037class="cmtt-8">&#x00A0;vector</span><span
3038class="cmtt-8">&#x00A0;[value</span><span
3039class="cmtt-8">_vector]</span><span
3040class="cmtt-8">&#x00A0;element</span><span
3041class="cmtt-8">&#x00A0;[i]</span><br class="fancyvrb" /><a
3042 id="x1-56026r13"></a><span
3043class="cmr-6">13</span>
3044<br class="fancyvrb" /><a
3045 id="x1-56028r14"></a><span
3046class="cmr-6">14</span><span
3047class="cmtt-8">&#x00A0;</span><span
3048class="cmtt-8">&#x00A0;</span><span
3049class="cmtt-8">&#x00A0;</span><span
3050class="cmtt-8">&#x00A0;</span><span
3051class="cmtt-8">&#x00A0;</span><span
3052class="cmtt-8">&#x00A0;</span><span
3053class="cmtt-8">&#x00A0;7)</span><span
3054class="cmtt-8">&#x00A0;[index</span><span
3055class="cmtt-8">_divisor]</span><span
3056class="cmtt-8">&#x00A0;=</span><span
3057class="cmtt-8">&#x00A0;[index</span><span
3058class="cmtt-8">_divisor]</span><span
3059class="cmtt-8">&#x00A0;*</span><span
3060class="cmtt-8">&#x00A0;[codebook</span><span
3061class="cmtt-8">_lookup</span><span
3062class="cmtt-8">_values]</span><br class="fancyvrb" /><a
3063 id="x1-56030r15"></a><span
3064class="cmr-6">15</span><br class="fancyvrb" /><a
3065 id="x1-56032r16"></a><span
3066class="cmr-6">16</span><span
3067class="cmtt-8">&#x00A0;</span><span
3068class="cmtt-8">&#x00A0;</span><span
3069class="cmtt-8">&#x00A0;</span><span
3070class="cmtt-8">&#x00A0;</span><span
3071class="cmtt-8">&#x00A0;</span><span
3072class="cmsy-8">}</span><br class="fancyvrb" /><a
3073 id="x1-56034r17"></a><span
3074class="cmr-6">17</span><br class="fancyvrb" /><a
3075 id="x1-56036r18"></a><span
3076class="cmr-6">18</span><span
3077class="cmtt-8">&#x00A0;</span><span
3078class="cmtt-8">&#x00A0;8)</span><span
3079class="cmtt-8">&#x00A0;vector</span><span
3080class="cmtt-8">&#x00A0;calculation</span><span
3081class="cmtt-8">&#x00A0;completed.</span></div>
3082<!--l. 384--><p class="noindent" ><span class="paragraphHead"><a
3083 id="x1-570003.2.1"></a><span
3084class="cmbx-12">Vector value decode: Lookup type 2</span></span>
3085Lookup type two specifies a VQ lookup table in which each scalar in each vector is explicitly set
3086by the <span
3087class="cmtt-12">[codebook</span><span
3088class="cmtt-12">_multiplicands] </span>array in a one-to-one mapping. Calculate [unpack] the final
3089values of a codebook entry vector from the entries in <span
3090class="cmtt-12">[codebook</span><span
3091class="cmtt-12">_multiplicands] </span>as follows
3092(<span
3093class="cmtt-12">[value</span><span
3094class="cmtt-12">_vector] </span>is the output vector representing the vector of values for entry number
3095<span
3096class="cmtt-12">[lookup</span><span
3097class="cmtt-12">_offset] </span>in this codebook):
3098<!--l. 394--><p class="noindent" >
3099<div class="fancyvrb" id="fancyvrb19"><a
3100 id="x1-57002r1"></a><span
3101class="cmr-6">1</span><span
3102class="cmtt-8">&#x00A0;</span><span
3103class="cmtt-8">&#x00A0;1)</span><span
3104class="cmtt-8">&#x00A0;[last]</span><span
3105class="cmtt-8">&#x00A0;=</span><span
3106class="cmtt-8">&#x00A0;0;</span><br class="fancyvrb" /><a
3107 id="x1-57004r2"></a><span
3108class="cmr-6">2</span><span
3109class="cmtt-8">&#x00A0;</span><span
3110class="cmtt-8">&#x00A0;2)</span><span
3111class="cmtt-8">&#x00A0;[multiplicand</span><span
3112class="cmtt-8">_offset]</span><span
3113class="cmtt-8">&#x00A0;=</span><span
3114class="cmtt-8">&#x00A0;[lookup</span><span
3115class="cmtt-8">_offset]</span><span
3116class="cmtt-8">&#x00A0;*</span><span
3117class="cmtt-8">&#x00A0;[codebook</span><span
3118class="cmtt-8">_dimensions]</span>
3119<br class="fancyvrb" /><a
3120 id="x1-57006r3"></a><span
3121class="cmr-6">3</span><span
3122class="cmtt-8">&#x00A0;</span><span
3123class="cmtt-8">&#x00A0;3)</span><span
3124class="cmtt-8">&#x00A0;iterate</span><span
3125class="cmtt-8">&#x00A0;[i]</span><span
3126class="cmtt-8">&#x00A0;over</span><span
3127class="cmtt-8">&#x00A0;the</span><span
3128class="cmtt-8">&#x00A0;range</span><span
3129class="cmtt-8">&#x00A0;0</span><span
3130class="cmtt-8">&#x00A0;...</span><span
3131class="cmtt-8">&#x00A0;[codebook</span><span
3132class="cmtt-8">_dimensions]-1</span><span
3133class="cmtt-8">&#x00A0;(once</span><span
3134class="cmtt-8">&#x00A0;for</span><span
3135class="cmtt-8">&#x00A0;each</span><span
3136class="cmtt-8">&#x00A0;scalar</span><span
3137class="cmtt-8">&#x00A0;value</span><span
3138class="cmtt-8">&#x00A0;in</span><span
3139class="cmtt-8">&#x00A0;the</span><span
3140class="cmtt-8">&#x00A0;value</span><span
3141class="cmtt-8">&#x00A0;vector)</span><span
3142class="cmtt-8">&#x00A0;</span><span
3143class="cmsy-8">{</span><br class="fancyvrb" /><a
3144 id="x1-57008r4"></a><span
3145class="cmr-6">4</span>
3146<br class="fancyvrb" /><a
3147 id="x1-57010r5"></a><span
3148class="cmr-6">5</span><span
3149class="cmtt-8">&#x00A0;</span><span
3150class="cmtt-8">&#x00A0;</span><span
3151class="cmtt-8">&#x00A0;</span><span
3152class="cmtt-8">&#x00A0;</span><span
3153class="cmtt-8">&#x00A0;</span><span
3154class="cmtt-8">&#x00A0;</span><span
3155class="cmtt-8">&#x00A0;4)</span><span
3156class="cmtt-8">&#x00A0;vector</span><span
3157class="cmtt-8">&#x00A0;[value</span><span
3158class="cmtt-8">_vector]</span><span
3159class="cmtt-8">&#x00A0;element</span><span
3160class="cmtt-8">&#x00A0;[i]</span><span
3161class="cmtt-8">&#x00A0;=</span><br class="fancyvrb" /><a
3162 id="x1-57012r6"></a><span
3163class="cmr-6">6</span><span
3164class="cmtt-8">&#x00A0;</span><span
3165class="cmtt-8">&#x00A0;</span><span
3166class="cmtt-8">&#x00A0;</span><span
3167class="cmtt-8">&#x00A0;</span><span
3168class="cmtt-8">&#x00A0;</span><span
3169class="cmtt-8">&#x00A0;</span><span
3170class="cmtt-8">&#x00A0;</span><span
3171class="cmtt-8">&#x00A0;</span><span
3172class="cmtt-8">&#x00A0;</span><span
3173class="cmtt-8">&#x00A0;</span><span
3174class="cmtt-8">&#x00A0;</span><span
3175class="cmtt-8">&#x00A0;(</span><span
3176class="cmtt-8">&#x00A0;[codebook</span><span
3177class="cmtt-8">_multiplicands]</span><span
3178class="cmtt-8">&#x00A0;array</span><span
3179class="cmtt-8">&#x00A0;element</span><span
3180class="cmtt-8">&#x00A0;number</span><span
3181class="cmtt-8">&#x00A0;[multiplicand</span><span
3182class="cmtt-8">_offset]</span><span
3183class="cmtt-8">&#x00A0;)</span><span
3184class="cmtt-8">&#x00A0;*</span>
3185<br class="fancyvrb" /><a
3186 id="x1-57014r7"></a><span
3187class="cmr-6">7</span><span
3188class="cmtt-8">&#x00A0;</span><span
3189class="cmtt-8">&#x00A0;</span><span
3190class="cmtt-8">&#x00A0;</span><span
3191class="cmtt-8">&#x00A0;</span><span
3192class="cmtt-8">&#x00A0;</span><span
3193class="cmtt-8">&#x00A0;</span><span
3194class="cmtt-8">&#x00A0;</span><span
3195class="cmtt-8">&#x00A0;</span><span
3196class="cmtt-8">&#x00A0;</span><span
3197class="cmtt-8">&#x00A0;</span><span
3198class="cmtt-8">&#x00A0;</span><span
3199class="cmtt-8">&#x00A0;[codebook</span><span
3200class="cmtt-8">_delta</span><span
3201class="cmtt-8">_value]</span><span
3202class="cmtt-8">&#x00A0;+</span><span
3203class="cmtt-8">&#x00A0;[codebook</span><span
3204class="cmtt-8">_minimum</span><span
3205class="cmtt-8">_value]</span><span
3206class="cmtt-8">&#x00A0;+</span><span
3207class="cmtt-8">&#x00A0;[last];</span><br class="fancyvrb" /><a
3208 id="x1-57016r8"></a><span
3209class="cmr-6">8</span>
3210<br class="fancyvrb" /><a
3211 id="x1-57018r9"></a><span
3212class="cmr-6">9</span><span
3213class="cmtt-8">&#x00A0;</span><span
3214class="cmtt-8">&#x00A0;</span><span
3215class="cmtt-8">&#x00A0;</span><span
3216class="cmtt-8">&#x00A0;</span><span
3217class="cmtt-8">&#x00A0;</span><span
3218class="cmtt-8">&#x00A0;</span><span
3219class="cmtt-8">&#x00A0;5)</span><span
3220class="cmtt-8">&#x00A0;if</span><span
3221class="cmtt-8">&#x00A0;(</span><span
3222class="cmtt-8">&#x00A0;[codebook</span><span
3223class="cmtt-8">_sequence</span><span
3224class="cmtt-8">_p]</span><span
3225class="cmtt-8">&#x00A0;is</span><span
3226class="cmtt-8">&#x00A0;set</span><span
3227class="cmtt-8">&#x00A0;)</span><span
3228class="cmtt-8">&#x00A0;then</span><span
3229class="cmtt-8">&#x00A0;set</span><span
3230class="cmtt-8">&#x00A0;[last]</span><span
3231class="cmtt-8">&#x00A0;=</span><span
3232class="cmtt-8">&#x00A0;vector</span><span
3233class="cmtt-8">&#x00A0;[value</span><span
3234class="cmtt-8">_vector]</span><span
3235class="cmtt-8">&#x00A0;element</span><span
3236class="cmtt-8">&#x00A0;[i]</span><br class="fancyvrb" /><a
3237 id="x1-57020r10"></a><span
3238class="cmr-6">10</span>
3239<br class="fancyvrb" /><a
3240 id="x1-57022r11"></a><span
3241class="cmr-6">11</span><span
3242class="cmtt-8">&#x00A0;</span><span
3243class="cmtt-8">&#x00A0;</span><span
3244class="cmtt-8">&#x00A0;</span><span
3245class="cmtt-8">&#x00A0;</span><span
3246class="cmtt-8">&#x00A0;</span><span
3247class="cmtt-8">&#x00A0;</span><span
3248class="cmtt-8">&#x00A0;6)</span><span
3249class="cmtt-8">&#x00A0;increment</span><span
3250class="cmtt-8">&#x00A0;[multiplicand</span><span
3251class="cmtt-8">_offset]</span><br class="fancyvrb" /><a
3252 id="x1-57024r12"></a><span
3253class="cmr-6">12</span><br class="fancyvrb" /><a
3254 id="x1-57026r13"></a><span
3255class="cmr-6">13</span><span
3256class="cmtt-8">&#x00A0;</span><span
3257class="cmtt-8">&#x00A0;</span><span
3258class="cmtt-8">&#x00A0;</span><span
3259class="cmtt-8">&#x00A0;</span><span
3260class="cmtt-8">&#x00A0;</span><span
3261class="cmsy-8">}</span><br class="fancyvrb" /><a
3262 id="x1-57028r14"></a><span
3263class="cmr-6">14</span><br class="fancyvrb" /><a
3264 id="x1-57030r15"></a><span
3265class="cmr-6">15</span><span
3266class="cmtt-8">&#x00A0;</span><span
3267class="cmtt-8">&#x00A0;7)</span><span
3268class="cmtt-8">&#x00A0;vector</span><span
3269class="cmtt-8">&#x00A0;calculation</span><span
3270class="cmtt-8">&#x00A0;completed.</span></div>
3271
3272
3273
3274<!--l. 420--><p class="noindent" >
3275<h4 class="subsectionHead"><span class="titlemark">3.3. </span> <a
3276 id="x1-580003.3"></a>Use of the codebook abstraction</h4>
3277<!--l. 422--><p class="noindent" >The decoder uses the codebook abstraction much as it does the bit-unpacking convention; a
3278specific codebook reads a codeword from the bitstream, decoding it into an entry number, and
3279then returns that entry number to the decoder (when used in a scalar entropy coding context), or
3280uses that entry number as an offset into the VQ lookup table, returning a vector of values (when
3281used in a context desiring a VQ value). Scalar or VQ context is always explicit; any
3282call to the codebook mechanism requests either a scalar entry number or a lookup
3283vector.
3284<!--l. 432--><p class="noindent" >Note that VQ lookup type zero indicates that there is no lookup table; requesting
3285decode using a codebook of lookup type 0 in any context expecting a vector return
3286value (even in a case where a vector of dimension one) is forbidden. If decoder setup
3287or decode requests such an action, that is an error condition rendering the packet
3288undecodable.
3289<!--l. 439--><p class="noindent" >Using a codebook to read from the packet bitstream consists first of reading and decoding the
3290next codeword in the bitstream. The decoder reads bits until the accumulated bits match a
3291codeword in the codebook. This process can be though of as logically walking the
3292Huffman decode tree by reading one bit at a time from the bitstream, and using the
3293bit as a decision boolean to take the 0 branch (left in the above examples) or the 1
3294branch (right in the above examples). Walking the tree finishes when the decode process
3295hits a leaf in the decision tree; the result is the entry number corresponding to that
3296leaf. Reading past the end of a packet propagates the &#8217;end-of-stream&#8217; condition to the
3297decoder.
3298<!--l. 451--><p class="noindent" >When used in a scalar context, the resulting codeword entry is the desired return
3299value.
3300<!--l. 454--><p class="noindent" >When used in a VQ context, the codeword entry number is used as an offset into the VQ lookup
3301table. The value returned to the decoder is the vector of scalars corresponding to this
3302offset.
3303
3304
3305
3306
3307
3308
3309<h3 class="sectionHead"><span class="titlemark">4. </span> <a
3310 id="x1-590004"></a>Codec Setup and Packet Decode</h3>
3311<!--l. 6--><p class="noindent" >
3312<h4 class="subsectionHead"><span class="titlemark">4.1. </span> <a
3313 id="x1-600004.1"></a>Overview</h4>
3314<!--l. 8--><p class="noindent" >This document serves as the top-level reference document for the bit-by-bit decode specification
3315of Vorbis I. This document assumes a high-level understanding of the Vorbis decode
3316process, which is provided in <a
3317href="#x1-20001">section&#x00A0;1</a>, &#8220;<a
3318href="#x1-20001">Introduction and Description<!--tex4ht:ref: vorbis:spec:intro --></a>&#8221;. <a
3319href="#x1-360002">section&#x00A0;2</a>,
3320&#8220;<a
3321href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>&#8221; covers reading and writing bit fields from and to bitstream
3322packets.
3323<!--l. 16--><p class="noindent" >
3324<h4 class="subsectionHead"><span class="titlemark">4.2. </span> <a
3325 id="x1-610004.2"></a>Header decode and decode setup</h4>
3326<!--l. 18--><p class="noindent" >A Vorbis bitstream begins with three header packets. The header packets are, in order, the
3327identification header, the comments header, and the setup header. All are required for decode
3328compliance. An end-of-packet condition during decoding the first or third header packet renders
3329the stream undecodable. End-of-packet decoding the comment header is a non-fatal error
3330condition.
3331<!--l. 25--><p class="noindent" >
3332<h5 class="subsubsectionHead"><span class="titlemark">4.2.1. </span> <a
3333 id="x1-620004.2.1"></a>Common header decode</h5>
3334<!--l. 27--><p class="noindent" >Each header packet begins with the same header fields.
3335<!--l. 30--><p class="noindent" >
3336<div class="fancyvrb" id="fancyvrb20"><a
3337 id="x1-62002r1"></a><span
3338class="cmr-6">1</span><span
3339class="cmtt-8">&#x00A0;</span><span
3340class="cmtt-8">&#x00A0;1)</span><span
3341class="cmtt-8">&#x00A0;[packet</span><span
3342class="cmtt-8">_type]</span><span
3343class="cmtt-8">&#x00A0;:</span><span
3344class="cmtt-8">&#x00A0;8</span><span
3345class="cmtt-8">&#x00A0;bit</span><span
3346class="cmtt-8">&#x00A0;value</span><br class="fancyvrb" /><a
3347 id="x1-62004r2"></a><span
3348class="cmr-6">2</span><span
3349class="cmtt-8">&#x00A0;</span><span
3350class="cmtt-8">&#x00A0;2)</span><span
3351class="cmtt-8">&#x00A0;0x76,</span><span
3352class="cmtt-8">&#x00A0;0x6f,</span><span
3353class="cmtt-8">&#x00A0;0x72,</span><span
3354class="cmtt-8">&#x00A0;0x62,</span><span
3355class="cmtt-8">&#x00A0;0x69,</span><span
3356class="cmtt-8">&#x00A0;0x73:</span><span
3357class="cmtt-8">&#x00A0;the</span><span
3358class="cmtt-8">&#x00A0;characters</span><span
3359class="cmtt-8">&#x00A0;&#8217;v&#8217;,&#8217;o&#8217;,&#8217;r&#8217;,&#8217;b&#8217;,&#8217;i&#8217;,&#8217;s&#8217;</span><span
3360class="cmtt-8">&#x00A0;as</span><span
3361class="cmtt-8">&#x00A0;six</span><span
3362class="cmtt-8">&#x00A0;octets</span></div>
3363<!--l. 35--><p class="noindent" >Decode continues according to packet type; the identification header is type 1, the comment
3364header type 3 and the setup header type 5 (these types are all odd as a packet with a leading
3365single bit of &#8217;0&#8217; is an audio packet). The packets must occur in the order of identification,
3366
3367
3368
3369comment, setup.
3370<!--l. 43--><p class="noindent" >
3371<h5 class="subsubsectionHead"><span class="titlemark">4.2.2. </span> <a
3372 id="x1-630004.2.2"></a>Identification header</h5>
3373<!--l. 45--><p class="noindent" >The identification header is a short header of only a few fields used to declare the stream
3374definitively as Vorbis, and provide a few externally relevant pieces of information about the audio
3375stream. The identification header is coded as follows:
3376<!--l. 50--><p class="noindent" >
3377<div class="fancyvrb" id="fancyvrb21"><a
3378 id="x1-63002r1"></a><span
3379class="cmr-6">1</span><span
3380class="cmtt-8">&#x00A0;1)</span><span
3381class="cmtt-8">&#x00A0;[vorbis</span><span
3382class="cmtt-8">_version]</span><span
3383class="cmtt-8">&#x00A0;=</span><span
3384class="cmtt-8">&#x00A0;read</span><span
3385class="cmtt-8">&#x00A0;32</span><span
3386class="cmtt-8">&#x00A0;bits</span><span
3387class="cmtt-8">&#x00A0;as</span><span
3388class="cmtt-8">&#x00A0;unsigned</span><span
3389class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
3390 id="x1-63004r2"></a><span
3391class="cmr-6">2</span><span
3392class="cmtt-8">&#x00A0;2)</span><span
3393class="cmtt-8">&#x00A0;[audio</span><span
3394class="cmtt-8">_channels]</span><span
3395class="cmtt-8">&#x00A0;=</span><span
3396class="cmtt-8">&#x00A0;read</span><span
3397class="cmtt-8">&#x00A0;8</span><span
3398class="cmtt-8">&#x00A0;bit</span><span
3399class="cmtt-8">&#x00A0;integer</span><span
3400class="cmtt-8">&#x00A0;as</span><span
3401class="cmtt-8">&#x00A0;unsigned</span>
3402<br class="fancyvrb" /><a
3403 id="x1-63006r3"></a><span
3404class="cmr-6">3</span><span
3405class="cmtt-8">&#x00A0;3)</span><span
3406class="cmtt-8">&#x00A0;[audio</span><span
3407class="cmtt-8">_sample</span><span
3408class="cmtt-8">_rate]</span><span
3409class="cmtt-8">&#x00A0;=</span><span
3410class="cmtt-8">&#x00A0;read</span><span
3411class="cmtt-8">&#x00A0;32</span><span
3412class="cmtt-8">&#x00A0;bits</span><span
3413class="cmtt-8">&#x00A0;as</span><span
3414class="cmtt-8">&#x00A0;unsigned</span><span
3415class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
3416 id="x1-63008r4"></a><span
3417class="cmr-6">4</span><span
3418class="cmtt-8">&#x00A0;4)</span><span
3419class="cmtt-8">&#x00A0;[bitrate</span><span
3420class="cmtt-8">_maximum]</span><span
3421class="cmtt-8">&#x00A0;=</span><span
3422class="cmtt-8">&#x00A0;read</span><span
3423class="cmtt-8">&#x00A0;32</span><span
3424class="cmtt-8">&#x00A0;bits</span><span
3425class="cmtt-8">&#x00A0;as</span><span
3426class="cmtt-8">&#x00A0;signed</span><span
3427class="cmtt-8">&#x00A0;integer</span>
3428<br class="fancyvrb" /><a
3429 id="x1-63010r5"></a><span
3430class="cmr-6">5</span><span
3431class="cmtt-8">&#x00A0;5)</span><span
3432class="cmtt-8">&#x00A0;[bitrate</span><span
3433class="cmtt-8">_nominal]</span><span
3434class="cmtt-8">&#x00A0;=</span><span
3435class="cmtt-8">&#x00A0;read</span><span
3436class="cmtt-8">&#x00A0;32</span><span
3437class="cmtt-8">&#x00A0;bits</span><span
3438class="cmtt-8">&#x00A0;as</span><span
3439class="cmtt-8">&#x00A0;signed</span><span
3440class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
3441 id="x1-63012r6"></a><span
3442class="cmr-6">6</span><span
3443class="cmtt-8">&#x00A0;6)</span><span
3444class="cmtt-8">&#x00A0;[bitrate</span><span
3445class="cmtt-8">_minimum]</span><span
3446class="cmtt-8">&#x00A0;=</span><span
3447class="cmtt-8">&#x00A0;read</span><span
3448class="cmtt-8">&#x00A0;32</span><span
3449class="cmtt-8">&#x00A0;bits</span><span
3450class="cmtt-8">&#x00A0;as</span><span
3451class="cmtt-8">&#x00A0;signed</span><span
3452class="cmtt-8">&#x00A0;integer</span>
3453<br class="fancyvrb" /><a
3454 id="x1-63014r7"></a><span
3455class="cmr-6">7</span><span
3456class="cmtt-8">&#x00A0;7)</span><span
3457class="cmtt-8">&#x00A0;[blocksize</span><span
3458class="cmtt-8">_0]</span><span
3459class="cmtt-8">&#x00A0;=</span><span
3460class="cmtt-8">&#x00A0;2</span><span
3461class="cmtt-8">&#x00A0;exponent</span><span
3462class="cmtt-8">&#x00A0;(read</span><span
3463class="cmtt-8">&#x00A0;4</span><span
3464class="cmtt-8">&#x00A0;bits</span><span
3465class="cmtt-8">&#x00A0;as</span><span
3466class="cmtt-8">&#x00A0;unsigned</span><span
3467class="cmtt-8">&#x00A0;integer)</span><br class="fancyvrb" /><a
3468 id="x1-63016r8"></a><span
3469class="cmr-6">8</span><span
3470class="cmtt-8">&#x00A0;8)</span><span
3471class="cmtt-8">&#x00A0;[blocksize</span><span
3472class="cmtt-8">_1]</span><span
3473class="cmtt-8">&#x00A0;=</span><span
3474class="cmtt-8">&#x00A0;2</span><span
3475class="cmtt-8">&#x00A0;exponent</span><span
3476class="cmtt-8">&#x00A0;(read</span><span
3477class="cmtt-8">&#x00A0;4</span><span
3478class="cmtt-8">&#x00A0;bits</span><span
3479class="cmtt-8">&#x00A0;as</span><span
3480class="cmtt-8">&#x00A0;unsigned</span><span
3481class="cmtt-8">&#x00A0;integer)</span>
3482<br class="fancyvrb" /><a
3483 id="x1-63018r9"></a><span
3484class="cmr-6">9</span><span
3485class="cmtt-8">&#x00A0;9)</span><span
3486class="cmtt-8">&#x00A0;[framing</span><span
3487class="cmtt-8">_flag]</span><span
3488class="cmtt-8">&#x00A0;=</span><span
3489class="cmtt-8">&#x00A0;read</span><span
3490class="cmtt-8">&#x00A0;one</span><span
3491class="cmtt-8">&#x00A0;bit</span></div>
3492<!--l. 62--><p class="noindent" ><span
3493class="cmtt-12">[vorbis</span><span
3494class="cmtt-12">_version] </span>is to read &#8217;0&#8217; in order to be compatible with this document. Both
3495<span
3496class="cmtt-12">[audio</span><span
3497class="cmtt-12">_channels] </span>and <span
3498class="cmtt-12">[audio</span><span
3499class="cmtt-12">_sample</span><span
3500class="cmtt-12">_rate] </span>must read greater than zero. Allowed final
3501blocksize values are 64, 128, 256, 512, 1024, 2048, 4096 and 8192 in Vorbis I. <span
3502class="cmtt-12">[blocksize</span><span
3503class="cmtt-12">_0]</span>
3504must be less than or equal to <span
3505class="cmtt-12">[blocksize</span><span
3506class="cmtt-12">_1]</span>. The framing bit must be nonzero. Failure to meet
3507any of these conditions renders a stream undecodable.
3508<!--l. 70--><p class="noindent" >The bitrate fields above are used only as hints. The nominal bitrate field especially may be
3509considerably off in purely VBR streams. The fields are meaningful only when greater than
3510zero.
3511 <ul class="itemize1">
3512 <li class="itemize">All three fields set to the same value implies a fixed rate, or tightly bounded, nearly
3513 fixed-rate bitstream
3514 </li>
3515 <li class="itemize">Only nominal set implies a VBR or ABR stream that averages the nominal bitrate
3516 </li>
3517 <li class="itemize">Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits
3518 </li>
3519 <li class="itemize">None set indicates the encoder does not care to speculate.</li></ul>
3520
3521
3522
3523<!--l. 84--><p class="noindent" >
3524<h5 class="subsubsectionHead"><span class="titlemark">4.2.3. </span> <a
3525 id="x1-640004.2.3"></a>Comment header</h5>
3526<!--l. 85--><p class="noindent" >Comment header decode and data specification is covered in <a
3527href="#x1-820005">section&#x00A0;5</a>, &#8220;<a
3528href="#x1-820005">comment field and
3529header specification<!--tex4ht:ref: vorbis:spec:comment --></a>&#8221;.
3530<!--l. 89--><p class="noindent" >
3531<h5 class="subsubsectionHead"><span class="titlemark">4.2.4. </span> <a
3532 id="x1-650004.2.4"></a>Setup header</h5>
3533<!--l. 91--><p class="noindent" >Vorbis codec setup is configurable to an extreme degree:
3534<div class="center"
3535>
3536<!--l. 93--><p class="noindent" >
3537
3538<!--l. 94--><p class="noindent" ><img
3539src="components.png" alt="PIC"
3540>
3541<br /> <div class="caption"
3542><span class="id">Figure&#x00A0;6: </span><span
3543class="content">decoder pipeline configuration</span></div><!--tex4ht:label?: x1-650016 -->
3544</div>
3545<!--l. 99--><p class="noindent" >The setup header contains the bulk of the codec setup information needed for decode. The setup
3546header contains, in order, the lists of codebook configurations, time-domain transform
3547configurations (placeholders in Vorbis I), floor configurations, residue configurations, channel
3548mapping configurations and mode configurations. It finishes with a framing bit of &#8217;1&#8217;. Header
3549decode proceeds in the following order:
3550<!--l. 107--><p class="noindent" ><span class="paragraphHead"><a
3551 id="x1-660004.2.4"></a><span
3552class="cmbx-12">Codebooks</span></span>
3553 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3554 1. </dt><dd
3555class="enumerate-enumitem"><span
3556class="cmtt-12">[vorbis</span><span
3557class="cmtt-12">_codebook</span><span
3558class="cmtt-12">_count] </span>= read eight bits as unsigned integer and add one
3559 </dd><dt class="enumerate-enumitem">
3560 2. </dt><dd
3561class="enumerate-enumitem">Decode <span
3562class="cmtt-12">[vorbis</span><span
3563class="cmtt-12">_codebook</span><span
3564class="cmtt-12">_count] </span>codebooks in order as defined in <a
3565href="#x1-470003">section&#x00A0;3</a>,
3566 &#8220;<a
3567href="#x1-470003">Probability Model and Codebooks<!--tex4ht:ref: vorbis:spec:codebook --></a>&#8221;. Save each configuration, in order, in an array
3568 of codebook configurations <span
3569class="cmtt-12">[vorbis</span><span
3570class="cmtt-12">_codebook</span><span
3571class="cmtt-12">_configurations]</span>.</dd></dl>
3572
3573
3574
3575<!--l. 119--><p class="noindent" ><span class="paragraphHead"><a
3576 id="x1-670004.2.4"></a><span
3577class="cmbx-12">Time domain transforms</span></span>
3578These hooks are placeholders in Vorbis I. Nevertheless, the configuration placeholder values must
3579be read to maintain bitstream sync.
3580<!--l. 126--><p class="noindent" >
3581 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3582 1. </dt><dd
3583class="enumerate-enumitem"><span
3584class="cmtt-12">[vorbis</span><span
3585class="cmtt-12">_time</span><span
3586class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
3587 </dd><dt class="enumerate-enumitem">
3588 2. </dt><dd
3589class="enumerate-enumitem">read <span
3590class="cmtt-12">[vorbis</span><span
3591class="cmtt-12">_time</span><span
3592class="cmtt-12">_count] </span>16 bit values; each value should be zero. If any value is
3593 nonzero, this is an error condition and the stream is undecodable.</dd></dl>
3594<!--l. 132--><p class="noindent" ><span class="paragraphHead"><a
3595 id="x1-680004.2.4"></a><span
3596class="cmbx-12">Floors</span></span>
3597Vorbis uses two floor types; header decode is handed to the decode abstraction of the appropriate
3598type.
3599<!--l. 138--><p class="noindent" >
3600 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3601 1. </dt><dd
3602class="enumerate-enumitem"><span
3603class="cmtt-12">[vorbis</span><span
3604class="cmtt-12">_floor</span><span
3605class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
3606 </dd><dt class="enumerate-enumitem">
3607 2. </dt><dd
3608class="enumerate-enumitem">For each <span
3609class="cmtt-12">[i] </span>of <span
3610class="cmtt-12">[vorbis</span><span
3611class="cmtt-12">_floor</span><span
3612class="cmtt-12">_count] </span>floor numbers:
3613 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3614 a) </dt><dd
3615class="enumerate-enumitem">read the floor type: vector <span
3616class="cmtt-12">[vorbis</span><span
3617class="cmtt-12">_floor</span><span
3618class="cmtt-12">_types] </span>element <span
3619class="cmtt-12">[i] </span>= read 16 bits
3620 as unsigned integer
3621 </dd><dt class="enumerate-enumitem">
3622 b) </dt><dd
3623class="enumerate-enumitem">If the floor type is zero, decode the floor configuration as defined in <a
3624href="#x1-900006">section&#x00A0;6</a>,
3625 &#8220;<a
3626href="#x1-900006">Floor type 0 setup and decode<!--tex4ht:ref: vorbis:spec:floor0 --></a>&#8221;; save this configuration in slot <span
3627class="cmtt-12">[i] </span>of the floor
3628 configuration array <span
3629class="cmtt-12">[vorbis</span><span
3630class="cmtt-12">_floor</span><span
3631class="cmtt-12">_configurations]</span>.
3632 </dd><dt class="enumerate-enumitem">
3633 c) </dt><dd
3634class="enumerate-enumitem">If the floor type is one, decode the floor configuration as defined in <a
3635href="#x1-970007">section&#x00A0;7</a>,
3636 &#8220;<a
3637href="#x1-970007">Floor type 1 setup and decode<!--tex4ht:ref: vorbis:spec:floor1 --></a>&#8221;; save this configuration in slot <span
3638class="cmtt-12">[i] </span>of the floor
3639 configuration array <span
3640class="cmtt-12">[vorbis</span><span
3641class="cmtt-12">_floor</span><span
3642class="cmtt-12">_configurations]</span>.
3643 </dd><dt class="enumerate-enumitem">
3644 d) </dt><dd
3645class="enumerate-enumitem">If the the floor type is greater than one, this stream is undecodable; ERROR
3646 CONDITION</dd></dl>
3647
3648
3649
3650 </dd></dl>
3651<!--l. 156--><p class="noindent" ><span class="paragraphHead"><a
3652 id="x1-690004.2.4"></a><span
3653class="cmbx-12">Residues</span></span>
3654Vorbis uses three residue types; header decode of each type is identical.
3655<!--l. 162--><p class="noindent" >
3656 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3657 1. </dt><dd
3658class="enumerate-enumitem"><span
3659class="cmtt-12">[vorbis</span><span
3660class="cmtt-12">_residue</span><span
3661class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
3662 </dd><dt class="enumerate-enumitem">
3663 2. </dt><dd
3664class="enumerate-enumitem">For each of <span
3665class="cmtt-12">[vorbis</span><span
3666class="cmtt-12">_residue</span><span
3667class="cmtt-12">_count] </span>residue numbers:
3668 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3669 a) </dt><dd
3670class="enumerate-enumitem">read the residue type; vector <span
3671class="cmtt-12">[vorbis</span><span
3672class="cmtt-12">_residue</span><span
3673class="cmtt-12">_types] </span>element <span
3674class="cmtt-12">[i] </span>= read 16
3675 bits as unsigned integer
3676 </dd><dt class="enumerate-enumitem">
3677 b) </dt><dd
3678class="enumerate-enumitem">If the residue type is zero, one or two, decode the residue configuration as defined
3679 in <a
3680href="#x1-1040008">section&#x00A0;8</a>, &#8220;<a
3681href="#x1-1040008">Residue setup and decode<!--tex4ht:ref: vorbis:spec:residue --></a>&#8221;; save this configuration in slot <span
3682class="cmtt-12">[i] </span>of
3683 the residue configuration array <span
3684class="cmtt-12">[vorbis</span><span
3685class="cmtt-12">_residue</span><span
3686class="cmtt-12">_configurations]</span>.
3687 </dd><dt class="enumerate-enumitem">
3688 c) </dt><dd
3689class="enumerate-enumitem">If the the residue type is greater than two, this stream is undecodable; ERROR
3690 CONDITION</dd></dl>
3691 </dd></dl>
3692<!--l. 176--><p class="noindent" ><span class="paragraphHead"><a
3693 id="x1-700004.2.4"></a><span
3694class="cmbx-12">Mappings</span></span>
3695Mappings are used to set up specific pipelines for encoding multichannel audio with varying
3696channel mapping applications. Vorbis I uses a single mapping type (0), with implicit PCM
3697channel mappings.
3698<!--l. 187--><p class="noindent" >
3699 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3700 1. </dt><dd
3701class="enumerate-enumitem"><span
3702class="cmtt-12">[vorbis</span><span
3703class="cmtt-12">_mapping</span><span
3704class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
3705 </dd><dt class="enumerate-enumitem">
3706 2. </dt><dd
3707class="enumerate-enumitem">For each <span
3708class="cmtt-12">[i] </span>of <span
3709class="cmtt-12">[vorbis</span><span
3710class="cmtt-12">_mapping</span><span
3711class="cmtt-12">_count] </span>mapping numbers:
3712
3713
3714
3715 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3716 a) </dt><dd
3717class="enumerate-enumitem">read the mapping type: 16 bits as unsigned integer. There&#8217;s no reason to save
3718 the mapping type in Vorbis I.
3719 </dd><dt class="enumerate-enumitem">
3720 b) </dt><dd
3721class="enumerate-enumitem">If the mapping type is nonzero, the stream is undecodable
3722 </dd><dt class="enumerate-enumitem">
3723 c) </dt><dd
3724class="enumerate-enumitem">If the mapping type is zero:
3725 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3726 i. </dt><dd
3727class="enumerate-enumitem">read 1 bit as a boolean flag
3728 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3729 A. </dt><dd
3730class="enumerate-enumitem">if set, <span
3731class="cmtt-12">[vorbis</span><span
3732class="cmtt-12">_mapping</span><span
3733class="cmtt-12">_submaps] </span>= read 4 bits as unsigned integer
3734 and add one
3735 </dd><dt class="enumerate-enumitem">
3736 B. </dt><dd
3737class="enumerate-enumitem">if unset, <span
3738class="cmtt-12">[vorbis</span><span
3739class="cmtt-12">_mapping</span><span
3740class="cmtt-12">_submaps] </span>= 1</dd></dl>
3741 </dd><dt class="enumerate-enumitem">
3742 ii. </dt><dd
3743class="enumerate-enumitem">read 1 bit as a boolean flag
3744 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3745 A. </dt><dd
3746class="enumerate-enumitem">if set, square polar channel mapping is in use:
3747 <ul class="itemize1">
3748 <li class="itemize"><span
3749class="cmtt-12">[vorbis</span><span
3750class="cmtt-12">_mapping</span><span
3751class="cmtt-12">_coupling</span><span
3752class="cmtt-12">_steps] </span>= read 8 bits as unsigned
3753 integer and add one
3754 </li>
3755 <li class="itemize">for <span
3756class="cmtt-12">[j] </span>each of <span
3757class="cmtt-12">[vorbis</span><span
3758class="cmtt-12">_mapping</span><span
3759class="cmtt-12">_coupling</span><span
3760class="cmtt-12">_steps] </span>steps:
3761 <ul class="itemize2">
3762 <li class="itemize">vector <span
3763class="cmtt-12">[vorbis</span><span
3764class="cmtt-12">_mapping</span><span
3765class="cmtt-12">_magnitude] </span>element <span
3766class="cmtt-12">[j]</span>= read
3767 <a
3768href="#x1-1190009.2.1">ilog</a>(<span
3769class="cmtt-12">[audio</span><span
3770class="cmtt-12">_channels] </span>- 1) bits as unsigned integer
3771 </li>
3772 <li class="itemize">vector <span
3773class="cmtt-12">[vorbis</span><span
3774class="cmtt-12">_mapping</span><span
3775class="cmtt-12">_angle] </span>element <span
3776class="cmtt-12">[j]</span>= read
3777 <a
3778href="#x1-1190009.2.1">ilog</a>(<span
3779class="cmtt-12">[audio</span><span
3780class="cmtt-12">_channels] </span>- 1) bits as unsigned integer
3781 </li>
3782 <li class="itemize">the numbers read in the above two steps are channel numbers
3783 representing the channel to treat as magnitude and the channel
3784 to treat as angle, respectively. If for any coupling step the
3785 angle channel number equals the magnitude channel number, the
3786 magnitude channel number is greater than <span
3787class="cmtt-12">[audio</span><span
3788class="cmtt-12">_channels]</span>-1, or
3789 the angle channel is greater than <span
3790class="cmtt-12">[audio</span><span
3791class="cmtt-12">_channels]</span>-1, the stream
3792 is undecodable.</li></ul>
3793
3794
3795
3796 </li></ul>
3797 </dd><dt class="enumerate-enumitem">
3798 B. </dt><dd
3799class="enumerate-enumitem">if unset, <span
3800class="cmtt-12">[vorbis</span><span
3801class="cmtt-12">_mapping</span><span
3802class="cmtt-12">_coupling</span><span
3803class="cmtt-12">_steps] </span>= 0</dd></dl>
3804 </dd><dt class="enumerate-enumitem">
3805 iii. </dt><dd
3806class="enumerate-enumitem">read 2 bits (reserved field); if the value is nonzero, the stream is undecodable
3807 </dd><dt class="enumerate-enumitem">
3808 iv. </dt><dd
3809class="enumerate-enumitem">if <span
3810class="cmtt-12">[vorbis</span><span
3811class="cmtt-12">_mapping</span><span
3812class="cmtt-12">_submaps] </span>is greater than one, we read channel multiplex
3813 settings. For each <span
3814class="cmtt-12">[j] </span>of <span
3815class="cmtt-12">[audio</span><span
3816class="cmtt-12">_channels] </span>channels:
3817 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3818 A. </dt><dd
3819class="enumerate-enumitem">vector <span
3820class="cmtt-12">[vorbis</span><span
3821class="cmtt-12">_mapping</span><span
3822class="cmtt-12">_mux] </span>element <span
3823class="cmtt-12">[j] </span>= read 4 bits as unsigned
3824 integer
3825 </dd><dt class="enumerate-enumitem">
3826 B. </dt><dd
3827class="enumerate-enumitem">if the value is greater than the highest numbered submap
3828 (<span
3829class="cmtt-12">[vorbis</span><span
3830class="cmtt-12">_mapping</span><span
3831class="cmtt-12">_submaps] </span>- 1), this in an error condition rendering
3832 the stream undecodable</dd></dl>
3833 </dd><dt class="enumerate-enumitem">
3834 v. </dt><dd
3835class="enumerate-enumitem">for each submap <span
3836class="cmtt-12">[j] </span>of <span
3837class="cmtt-12">[vorbis</span><span
3838class="cmtt-12">_mapping</span><span
3839class="cmtt-12">_submaps] </span>submaps, read the floor and
3840 residue numbers for use in decoding that submap:
3841 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3842 A. </dt><dd
3843class="enumerate-enumitem">read and discard 8 bits (the unused time configuration placeholder)
3844 </dd><dt class="enumerate-enumitem">
3845 B. </dt><dd
3846class="enumerate-enumitem">read 8 bits as unsigned integer for the floor number; save in vector
3847 <span
3848class="cmtt-12">[vorbis</span><span
3849class="cmtt-12">_mapping</span><span
3850class="cmtt-12">_submap</span><span
3851class="cmtt-12">_floor] </span>element <span
3852class="cmtt-12">[j]</span>
3853 </dd><dt class="enumerate-enumitem">
3854 C. </dt><dd
3855class="enumerate-enumitem">verify the floor number is not greater than the highest number floor
3856 configured for the bitstream. If it is, the bitstream is undecodable
3857 </dd><dt class="enumerate-enumitem">
3858 D. </dt><dd
3859class="enumerate-enumitem">read 8 bits as unsigned integer for the residue number; save in vector
3860 <span
3861class="cmtt-12">[vorbis</span><span
3862class="cmtt-12">_mapping</span><span
3863class="cmtt-12">_submap</span><span
3864class="cmtt-12">_residue] </span>element <span
3865class="cmtt-12">[j]</span>
3866 </dd><dt class="enumerate-enumitem">
3867 E. </dt><dd
3868class="enumerate-enumitem">verify the residue number is not greater than the highest number residue
3869 configured for the bitstream. If it is, the bitstream is undecodable</dd></dl>
3870 </dd><dt class="enumerate-enumitem">
3871 vi. </dt><dd
3872class="enumerate-enumitem">save this mapping configuration in slot <span
3873class="cmtt-12">[i] </span>of the mapping configuration array
3874 <span
3875class="cmtt-12">[vorbis</span><span
3876class="cmtt-12">_mapping</span><span
3877class="cmtt-12">_configurations]</span>.</dd></dl>
3878 </dd></dl>
3879
3880
3881
3882 </dd></dl>
3883<!--l. 246--><p class="noindent" ><span class="paragraphHead"><a
3884 id="x1-710004.2.4"></a><span
3885class="cmbx-12">Modes</span></span>
3886 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3887 1. </dt><dd
3888class="enumerate-enumitem"><span
3889class="cmtt-12">[vorbis</span><span
3890class="cmtt-12">_mode</span><span
3891class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
3892 </dd><dt class="enumerate-enumitem">
3893 2. </dt><dd
3894class="enumerate-enumitem">For each of <span
3895class="cmtt-12">[vorbis</span><span
3896class="cmtt-12">_mode</span><span
3897class="cmtt-12">_count] </span>mode numbers:
3898 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3899 a) </dt><dd
3900class="enumerate-enumitem"><span
3901class="cmtt-12">[vorbis</span><span
3902class="cmtt-12">_mode</span><span
3903class="cmtt-12">_blockflag] </span>= read 1 bit
3904 </dd><dt class="enumerate-enumitem">
3905 b) </dt><dd
3906class="enumerate-enumitem"><span
3907class="cmtt-12">[vorbis</span><span
3908class="cmtt-12">_mode</span><span
3909class="cmtt-12">_windowtype] </span>= read 16 bits as unsigned integer
3910 </dd><dt class="enumerate-enumitem">
3911 c) </dt><dd
3912class="enumerate-enumitem"><span
3913class="cmtt-12">[vorbis</span><span
3914class="cmtt-12">_mode</span><span
3915class="cmtt-12">_transformtype] </span>= read 16 bits as unsigned integer
3916 </dd><dt class="enumerate-enumitem">
3917 d) </dt><dd
3918class="enumerate-enumitem"><span
3919class="cmtt-12">[vorbis</span><span
3920class="cmtt-12">_mode</span><span
3921class="cmtt-12">_mapping] </span>= read 8 bits as unsigned integer
3922 </dd><dt class="enumerate-enumitem">
3923 e) </dt><dd
3924class="enumerate-enumitem">verify ranges; zero is the only legal value in
3925 Vorbis I for <span
3926class="cmtt-12">[vorbis</span><span
3927class="cmtt-12">_mode</span><span
3928class="cmtt-12">_windowtype] </span>and <span
3929class="cmtt-12">[vorbis</span><span
3930class="cmtt-12">_mode</span><span
3931class="cmtt-12">_transformtype]</span>.
3932 <span
3933class="cmtt-12">[vorbis</span><span
3934class="cmtt-12">_mode</span><span
3935class="cmtt-12">_mapping] </span>must not be greater than the highest number mapping
3936 in use. Any illegal values render the stream undecodable.
3937 </dd><dt class="enumerate-enumitem">
3938 f) </dt><dd
3939class="enumerate-enumitem">save this mode configuration in slot <span
3940class="cmtt-12">[i] </span>of the mode configuration array
3941 <span
3942class="cmtt-12">[vorbis</span><span
3943class="cmtt-12">_mode</span><span
3944class="cmtt-12">_configurations]</span>.</dd></dl>
3945 </dd><dt class="enumerate-enumitem">
3946 3. </dt><dd
3947class="enumerate-enumitem">read 1 bit as a framing flag. If unset, a framing error occurred and the stream is not
3948 decodable.</dd></dl>
3949<!--l. 267--><p class="noindent" >After reading mode descriptions, setup header decode is complete.
3950<!--l. 276--><p class="noindent" >
3951<h4 class="subsectionHead"><span class="titlemark">4.3. </span> <a
3952 id="x1-720004.3"></a>Audio packet decode and synthesis</h4>
3953
3954
3955
3956<!--l. 278--><p class="noindent" >Following the three header packets, all packets in a Vorbis I stream are audio. The first step of
3957audio packet decode is to read and verify the packet type. <span
3958class="cmti-12">A non-audio packet when audio is</span>
3959<span
3960class="cmti-12">expected indicates stream corruption or a non-compliant stream. The decoder must ignore the</span>
3961<span
3962class="cmti-12">packet and not attempt decoding it to audio</span>.
3963<!--l. 285--><p class="noindent" >
3964<h5 class="subsubsectionHead"><span class="titlemark">4.3.1. </span> <a
3965 id="x1-730004.3.1"></a>packet type, mode and window decode</h5>
3966<!--l. 288--><p class="noindent" >
3967 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3968 1. </dt><dd
3969class="enumerate-enumitem">read 1 bit <span
3970class="cmtt-12">[packet</span><span
3971class="cmtt-12">_type]</span>; check that packet type is 0 (audio)
3972 </dd><dt class="enumerate-enumitem">
3973 2. </dt><dd
3974class="enumerate-enumitem">read <a
3975href="#x1-1190009.2.1">ilog</a>([vorbis_mode_count]-1) bits <span
3976class="cmtt-12">[mode</span><span
3977class="cmtt-12">_number]</span>
3978 </dd><dt class="enumerate-enumitem">
3979 3. </dt><dd
3980class="enumerate-enumitem">decode blocksize <span
3981class="cmtt-12">[n] </span>is equal to <span
3982class="cmtt-12">[blocksize</span><span
3983class="cmtt-12">_0] </span>if <span
3984class="cmtt-12">[vorbis</span><span
3985class="cmtt-12">_mode</span><span
3986class="cmtt-12">_blockflag] </span>is 0,
3987 else <span
3988class="cmtt-12">[n] </span>is equal to <span
3989class="cmtt-12">[blocksize</span><span
3990class="cmtt-12">_1]</span>.
3991 </dd><dt class="enumerate-enumitem">
3992 4. </dt><dd
3993class="enumerate-enumitem">perform window selection and setup; this window is used later by the inverse
3994 MDCT:
3995 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
3996 a) </dt><dd
3997class="enumerate-enumitem">if this is a long window (the <span
3998class="cmtt-12">[vorbis</span><span
3999class="cmtt-12">_mode</span><span
4000class="cmtt-12">_blockflag] </span>flag of this mode is
4001 set):
4002 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4003 i. </dt><dd
4004class="enumerate-enumitem">read 1 bit for <span
4005class="cmtt-12">[previous</span><span
4006class="cmtt-12">_window</span><span
4007class="cmtt-12">_flag]</span>
4008 </dd><dt class="enumerate-enumitem">
4009 ii. </dt><dd
4010class="enumerate-enumitem">read 1 bit for <span
4011class="cmtt-12">[next</span><span
4012class="cmtt-12">_window</span><span
4013class="cmtt-12">_flag]</span>
4014 </dd><dt class="enumerate-enumitem">
4015 iii. </dt><dd
4016class="enumerate-enumitem">if <span
4017class="cmtt-12">[previous</span><span
4018class="cmtt-12">_window</span><span
4019class="cmtt-12">_flag] </span>is not set, the left half of the window will
4020 be a hybrid window for lapping with a short block. See <a
4021href="#paragraph.1" >paragraph&#x00A0;<a
4022href="#x1-260001.3.2">1.3.2</a></a>,
4023 &#8220;<a
4024href="#x1-260001.3.2">Window shape decode (long windows only)<!--tex4ht:ref: vorbis:spec:window --></a>&#8221; for an illustration of
4025 overlapping dissimilar windows. Else, the left half window will have normal
4026 long shape.
4027 </dd><dt class="enumerate-enumitem">
4028 iv. </dt><dd
4029class="enumerate-enumitem">if <span
4030class="cmtt-12">[next</span><span
4031class="cmtt-12">_window</span><span
4032class="cmtt-12">_flag] </span>is not set, the right half of the window will be
4033 a hybrid window for lapping with a short block. See <a
4034href="#x1-260001.3.2">paragraph&#x00A0;1.3.2</a>,
4035
4036
4037
4038 &#8220;<a
4039href="#x1-260001.3.2">Window shape decode (long windows only)<!--tex4ht:ref: vorbis:spec:window --></a>&#8221; for an illustration of
4040 overlapping dissimilar windows. Else, the left right window will have normal
4041 long shape.</dd></dl>
4042 </dd><dt class="enumerate-enumitem">
4043 b) </dt><dd
4044class="enumerate-enumitem">if this is a short window, the window is always the same short-window
4045 shape.</dd></dl>
4046 </dd></dl>
4047<!--l. 320--><p class="noindent" >Vorbis windows all use the slope function <span
4048class="cmmi-12">y </span>= sin(<img
4049src="Vorbis_I_spec1x.png" alt="&#x03C0;
40502" class="frac" align="middle"> <span
4051class="cmsy-10x-x-120">*</span> sin <sup><span
4052class="cmr-8">2</span></sup>((<span
4053class="cmmi-12">x </span>+ 0<span
4054class="cmmi-12">.</span>5)<span
4055class="cmmi-12">&#x2215;n </span><span
4056class="cmsy-10x-x-120">* </span><span
4057class="cmmi-12">&#x03C0;</span>)), where <span
4058class="cmmi-12">n </span>is window
4059size and <span
4060class="cmmi-12">x </span>ranges 0<span
4061class="cmmi-12">&#x2026;</span><span
4062class="cmmi-12">n</span><span
4063class="cmsy-10x-x-120">- </span>1, but dissimilar lapping requirements can affect overall shape. Window
4064generation proceeds as follows:
4065<!--l. 326--><p class="noindent" >
4066 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4067 1. </dt><dd
4068class="enumerate-enumitem"><span
4069class="cmtt-12">[window</span><span
4070class="cmtt-12">_center] </span>= <span
4071class="cmtt-12">[n] </span>/ 2
4072 </dd><dt class="enumerate-enumitem">
4073 2. </dt><dd
4074class="enumerate-enumitem">if (<span
4075class="cmtt-12">[vorbis</span><span
4076class="cmtt-12">_mode</span><span
4077class="cmtt-12">_blockflag] </span>is set and <span
4078class="cmtt-12">[previous</span><span
4079class="cmtt-12">_window</span><span
4080class="cmtt-12">_flag] </span>is not set)
4081 then
4082 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4083 a) </dt><dd
4084class="enumerate-enumitem"><span
4085class="cmtt-12">[left</span><span
4086class="cmtt-12">_window</span><span
4087class="cmtt-12">_start] </span>= <span
4088class="cmtt-12">[n]</span>/4 - <span
4089class="cmtt-12">[blocksize</span><span
4090class="cmtt-12">_0]</span>/4
4091 </dd><dt class="enumerate-enumitem">
4092 b) </dt><dd
4093class="enumerate-enumitem"><span
4094class="cmtt-12">[left</span><span
4095class="cmtt-12">_window</span><span
4096class="cmtt-12">_end] </span>= <span
4097class="cmtt-12">[n]</span>/4 + <span
4098class="cmtt-12">[blocksize</span><span
4099class="cmtt-12">_0]</span>/4
4100 </dd><dt class="enumerate-enumitem">
4101 c) </dt><dd
4102class="enumerate-enumitem"><span
4103class="cmtt-12">[left</span><span
4104class="cmtt-12">_n] </span>= <span
4105class="cmtt-12">[blocksize</span><span
4106class="cmtt-12">_0]</span>/2</dd></dl>
4107 <!--l. 335--><p class="noindent" >else
4108 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4109 a) </dt><dd
4110class="enumerate-enumitem"><span
4111class="cmtt-12">[left</span><span
4112class="cmtt-12">_window</span><span
4113class="cmtt-12">_start] </span>= 0
4114 </dd><dt class="enumerate-enumitem">
4115 b) </dt><dd
4116class="enumerate-enumitem"><span
4117class="cmtt-12">[left</span><span
4118class="cmtt-12">_window</span><span
4119class="cmtt-12">_end] </span>= <span
4120class="cmtt-12">[window</span><span
4121class="cmtt-12">_center]</span>
4122 </dd><dt class="enumerate-enumitem">
4123 c) </dt><dd
4124class="enumerate-enumitem"><span
4125class="cmtt-12">[left</span><span
4126class="cmtt-12">_n] </span>= <span
4127class="cmtt-12">[n]</span>/2</dd></dl>
4128 </dd><dt class="enumerate-enumitem">
4129 3. </dt><dd
4130class="enumerate-enumitem">if (<span
4131class="cmtt-12">[vorbis</span><span
4132class="cmtt-12">_mode</span><span
4133class="cmtt-12">_blockflag] </span>is set and <span
4134class="cmtt-12">[next</span><span
4135class="cmtt-12">_window</span><span
4136class="cmtt-12">_flag] </span>is not set) then
4137 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4138 a) </dt><dd
4139class="enumerate-enumitem"><span
4140class="cmtt-12">[right</span><span
4141class="cmtt-12">_window</span><span
4142class="cmtt-12">_start] </span>= <span
4143class="cmtt-12">[n]*3</span>/4 - <span
4144class="cmtt-12">[blocksize</span><span
4145class="cmtt-12">_0]</span>/4
4146 </dd><dt class="enumerate-enumitem">
4147 b) </dt><dd
4148class="enumerate-enumitem"><span
4149class="cmtt-12">[right</span><span
4150class="cmtt-12">_window</span><span
4151class="cmtt-12">_end] </span>= <span
4152class="cmtt-12">[n]*3</span>/4 + <span
4153class="cmtt-12">[blocksize</span><span
4154class="cmtt-12">_0]</span>/4
4155
4156
4157
4158 </dd><dt class="enumerate-enumitem">
4159 c) </dt><dd
4160class="enumerate-enumitem"><span
4161class="cmtt-12">[right</span><span
4162class="cmtt-12">_n] </span>= <span
4163class="cmtt-12">[blocksize</span><span
4164class="cmtt-12">_0]</span>/2</dd></dl>
4165 <!--l. 351--><p class="noindent" >else
4166 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4167 a) </dt><dd
4168class="enumerate-enumitem"><span
4169class="cmtt-12">[right</span><span
4170class="cmtt-12">_window</span><span
4171class="cmtt-12">_start] </span>= <span
4172class="cmtt-12">[window</span><span
4173class="cmtt-12">_center]</span>
4174 </dd><dt class="enumerate-enumitem">
4175 b) </dt><dd
4176class="enumerate-enumitem"><span
4177class="cmtt-12">[right</span><span
4178class="cmtt-12">_window</span><span
4179class="cmtt-12">_end] </span>= <span
4180class="cmtt-12">[n]</span>
4181 </dd><dt class="enumerate-enumitem">
4182 c) </dt><dd
4183class="enumerate-enumitem"><span
4184class="cmtt-12">[right</span><span
4185class="cmtt-12">_n] </span>= <span
4186class="cmtt-12">[n]</span>/2</dd></dl>
4187 </dd><dt class="enumerate-enumitem">
4188 4. </dt><dd
4189class="enumerate-enumitem">window from range 0 ... <span
4190class="cmtt-12">[left</span><span
4191class="cmtt-12">_window</span><span
4192class="cmtt-12">_start]</span>-1 inclusive is zero
4193 </dd><dt class="enumerate-enumitem">
4194 5. </dt><dd
4195class="enumerate-enumitem">for <span
4196class="cmtt-12">[i] </span>in range <span
4197class="cmtt-12">[left</span><span
4198class="cmtt-12">_window</span><span
4199class="cmtt-12">_start] </span>... <span
4200class="cmtt-12">[left</span><span
4201class="cmtt-12">_window</span><span
4202class="cmtt-12">_end]</span>-1, window(<span
4203class="cmtt-12">[i]</span>) =
4204 sin(<img
4205src="Vorbis_I_spec2x.png" alt="&#x03C0;
42062" class="frac" align="middle"> <span
4207class="cmsy-10x-x-120">*</span> sin <sup><span
4208class="cmr-8">2</span></sup>( (<span
4209class="cmtt-12">[i]</span>-<span
4210class="cmtt-12">[left</span><span
4211class="cmtt-12">_window</span><span
4212class="cmtt-12">_start]</span>+0.5) / <span
4213class="cmtt-12">[left</span><span
4214class="cmtt-12">_n] </span><span
4215class="cmsy-10x-x-120">*</span><img
4216src="Vorbis_I_spec3x.png" alt="&#x03C0;
42172" class="frac" align="middle">) )
4218 </dd><dt class="enumerate-enumitem">
4219 6. </dt><dd
4220class="enumerate-enumitem">window from range <span
4221class="cmtt-12">[left</span><span
4222class="cmtt-12">_window</span><span
4223class="cmtt-12">_end] </span>... <span
4224class="cmtt-12">[right</span><span
4225class="cmtt-12">_window</span><span
4226class="cmtt-12">_start]</span>-1 inclusive is
4227 one
4228 </dd><dt class="enumerate-enumitem">
4229 7. </dt><dd
4230class="enumerate-enumitem">for <span
4231class="cmtt-12">[i] </span>in range <span
4232class="cmtt-12">[right</span><span
4233class="cmtt-12">_window</span><span
4234class="cmtt-12">_start] </span>... <span
4235class="cmtt-12">[right</span><span
4236class="cmtt-12">_window</span><span
4237class="cmtt-12">_end]</span>-1, window(<span
4238class="cmtt-12">[i]</span>) =
4239 sin(<img
4240src="Vorbis_I_spec4x.png" alt="&#x03C0;2" class="frac" align="middle"> <span
4241class="cmsy-10x-x-120">*</span> sin <sup><span
4242class="cmr-8">2</span></sup>( (<span
4243class="cmtt-12">[i]</span>-<span
4244class="cmtt-12">[right</span><span
4245class="cmtt-12">_window</span><span
4246class="cmtt-12">_start]</span>+0.5) / <span
4247class="cmtt-12">[right</span><span
4248class="cmtt-12">_n] </span><span
4249class="cmsy-10x-x-120">*</span><img
4250src="Vorbis_I_spec5x.png" alt="&#x03C0;2" class="frac" align="middle"> + <img
4251src="Vorbis_I_spec6x.png" alt="&#x03C0;2" class="frac" align="middle">) )
4252 </dd><dt class="enumerate-enumitem">
4253 8. </dt><dd
4254class="enumerate-enumitem">window from range <span
4255class="cmtt-12">[right</span><span
4256class="cmtt-12">_window</span><span
4257class="cmtt-12">_start] </span>... <span
4258class="cmtt-12">[n]</span>-1 is zero</dd></dl>
4259<!--l. 367--><p class="noindent" >An end-of-packet condition up to this point should be considered an error that discards this
4260packet from the stream. An end of packet condition past this point is to be considered a possible
4261nominal occurrence.
4262<!--l. 374--><p class="noindent" >
4263<h5 class="subsubsectionHead"><span class="titlemark">4.3.2. </span> <a
4264 id="x1-740004.3.2"></a>floor curve decode</h5>
4265<!--l. 376--><p class="noindent" >From this point on, we assume out decode context is using mode number <span
4266class="cmtt-12">[mode</span><span
4267class="cmtt-12">_number]</span>
4268from configuration array <span
4269class="cmtt-12">[vorbis</span><span
4270class="cmtt-12">_mode</span><span
4271class="cmtt-12">_configurations] </span>and the map number
4272<span
4273class="cmtt-12">[vorbis</span><span
4274class="cmtt-12">_mode</span><span
4275class="cmtt-12">_mapping] </span>(specified by the current mode) taken from the mapping configuration
4276array <span
4277class="cmtt-12">[vorbis</span><span
4278class="cmtt-12">_mapping</span><span
4279class="cmtt-12">_configurations]</span>.
4280<!--l. 383--><p class="noindent" >Floor curves are decoded one-by-one in channel order.
4281
4282
4283
4284<!--l. 385--><p class="noindent" >For each floor <span
4285class="cmtt-12">[i] </span>of <span
4286class="cmtt-12">[audio</span><span
4287class="cmtt-12">_channels]</span>
4288 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4289 1. </dt><dd
4290class="enumerate-enumitem"><span
4291class="cmtt-12">[submap</span><span
4292class="cmtt-12">_number] </span>= element <span
4293class="cmtt-12">[i] </span>of vector [vorbis_mapping_mux]
4294 </dd><dt class="enumerate-enumitem">
4295 2. </dt><dd
4296class="enumerate-enumitem"><span
4297class="cmtt-12">[floor</span><span
4298class="cmtt-12">_number] </span>= element <span
4299class="cmtt-12">[submap</span><span
4300class="cmtt-12">_number] </span>of vector [vorbis_submap_floor]
4301 </dd><dt class="enumerate-enumitem">
4302 3. </dt><dd
4303class="enumerate-enumitem">if the floor type of this floor (vector
4304 <span
4305class="cmtt-12">[vorbis</span><span
4306class="cmtt-12">_floor</span><span
4307class="cmtt-12">_types] </span>element <span
4308class="cmtt-12">[floor</span><span
4309class="cmtt-12">_number]</span>) is zero then decode the floor for
4310 channel <span
4311class="cmtt-12">[i] </span>according to the <a
4312href="#x1-940006.2.2">subsubsection&#x00A0;6.2.2</a>, &#8220;<a
4313href="#x1-940006.2.2">packet decode<!--tex4ht:ref: vorbis:spec:floor0-decode --></a>&#8221;
4314 </dd><dt class="enumerate-enumitem">
4315 4. </dt><dd
4316class="enumerate-enumitem">if the type of this floor is one then decode the floor for channel <span
4317class="cmtt-12">[i] </span>according to the
4318 <a
4319href="#x1-1020007.2.3">subsubsection&#x00A0;7.2.3</a>, &#8220;<a
4320href="#x1-1020007.2.3">packet decode<!--tex4ht:ref: vorbis:spec:floor1-decode --></a>&#8221;
4321 </dd><dt class="enumerate-enumitem">
4322 5. </dt><dd
4323class="enumerate-enumitem">save the needed decoded floor information for channel for later synthesis
4324 </dd><dt class="enumerate-enumitem">
4325 6. </dt><dd
4326class="enumerate-enumitem">if the decoded floor returned &#8217;unused&#8217;, set vector <span
4327class="cmtt-12">[no</span><span
4328class="cmtt-12">_residue] </span>element <span
4329class="cmtt-12">[i] </span>to true,
4330 else set vector <span
4331class="cmtt-12">[no</span><span
4332class="cmtt-12">_residue] </span>element <span
4333class="cmtt-12">[i] </span>to false</dd></dl>
4334<!--l. 405--><p class="noindent" >An end-of-packet condition during floor decode shall result in packet decode zeroing all channel
4335output vectors and skipping to the add/overlap output stage.
4336<!--l. 411--><p class="noindent" >
4337<h5 class="subsubsectionHead"><span class="titlemark">4.3.3. </span> <a
4338 id="x1-750004.3.3"></a>nonzero vector propagate</h5>
4339<!--l. 413--><p class="noindent" >A possible result of floor decode is that a specific vector is marked &#8217;unused&#8217; which indicates that
4340that final output vector is all-zero values (and the floor is zero). The residue for that vector is not
4341coded in the stream, save for one complication. If some vectors are used and some are not,
4342channel coupling could result in mixing a zeroed and nonzeroed vector to produce two nonzeroed
4343vectors.
4344<!--l. 420--><p class="noindent" >for each <span
4345class="cmtt-12">[i] </span>from 0 ... <span
4346class="cmtt-12">[vorbis</span><span
4347class="cmtt-12">_mapping</span><span
4348class="cmtt-12">_coupling</span><span
4349class="cmtt-12">_steps]</span>-1
4350<!--l. 423--><p class="noindent" >
4351 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4352 1. </dt><dd
4353class="enumerate-enumitem">if either <span
4354class="cmtt-12">[no</span><span
4355class="cmtt-12">_residue] </span>entry for channel (<span
4356class="cmtt-12">[vorbis</span><span
4357class="cmtt-12">_mapping</span><span
4358class="cmtt-12">_magnitude] </span>element
4359 <span
4360class="cmtt-12">[i]</span>) or channel (<span
4361class="cmtt-12">[vorbis</span><span
4362class="cmtt-12">_mapping</span><span
4363class="cmtt-12">_angle] </span>element <span
4364class="cmtt-12">[i]</span>) are set to false, then both
4365 must be set to false. Note that an &#8217;unused&#8217; floor has no decoded floor information; it
4366
4367
4368
4369 is important that this is remembered at floor curve synthesis time.</dd></dl>
4370<!--l. 435--><p class="noindent" >
4371<h5 class="subsubsectionHead"><span class="titlemark">4.3.4. </span> <a
4372 id="x1-760004.3.4"></a>residue decode</h5>
4373<!--l. 437--><p class="noindent" >Unlike floors, which are decoded in channel order, the residue vectors are decoded in submap
4374order.
4375<!--l. 440--><p class="noindent" >for each submap <span
4376class="cmtt-12">[i] </span>in order from 0 ... <span
4377class="cmtt-12">[vorbis</span><span
4378class="cmtt-12">_mapping</span><span
4379class="cmtt-12">_submaps]</span>-1
4380<!--l. 443--><p class="noindent" >
4381 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4382 1. </dt><dd
4383class="enumerate-enumitem"><span
4384class="cmtt-12">[ch] </span>= 0
4385 </dd><dt class="enumerate-enumitem">
4386 2. </dt><dd
4387class="enumerate-enumitem">for each channel <span
4388class="cmtt-12">[j] </span>in order from 0 ... <span
4389class="cmtt-12">[audio</span><span
4390class="cmtt-12">_channels] </span>- 1
4391 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4392 a) </dt><dd
4393class="enumerate-enumitem">if channel <span
4394class="cmtt-12">[j] </span>in submap <span
4395class="cmtt-12">[i] </span>(vector <span
4396class="cmtt-12">[vorbis</span><span
4397class="cmtt-12">_mapping</span><span
4398class="cmtt-12">_mux] </span>element <span
4399class="cmtt-12">[j] </span>is equal to
4400 <span
4401class="cmtt-12">[i]</span>)
4402 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4403 i. </dt><dd
4404class="enumerate-enumitem">if vector <span
4405class="cmtt-12">[no</span><span
4406class="cmtt-12">_residue] </span>element <span
4407class="cmtt-12">[j] </span>is true
4408 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4409 A. </dt><dd
4410class="enumerate-enumitem">vector <span
4411class="cmtt-12">[do</span><span
4412class="cmtt-12">_not</span><span
4413class="cmtt-12">_decode</span><span
4414class="cmtt-12">_flag] </span>element <span
4415class="cmtt-12">[ch] </span>is set</dd></dl>
4416 <!--l. 452--><p class="noindent" >else
4417 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4418 A. </dt><dd
4419class="enumerate-enumitem">vector <span
4420class="cmtt-12">[do</span><span
4421class="cmtt-12">_not</span><span
4422class="cmtt-12">_decode</span><span
4423class="cmtt-12">_flag] </span>element <span
4424class="cmtt-12">[ch] </span>is unset</dd></dl>
4425 </dd><dt class="enumerate-enumitem">
4426 ii. </dt><dd
4427class="enumerate-enumitem">increment <span
4428class="cmtt-12">[ch]</span></dd></dl>
4429 </dd></dl>
4430 </dd><dt class="enumerate-enumitem">
4431 3. </dt><dd
4432class="enumerate-enumitem"><span
4433class="cmtt-12">[residue</span><span
4434class="cmtt-12">_number] </span>= vector <span
4435class="cmtt-12">[vorbis</span><span
4436class="cmtt-12">_mapping</span><span
4437class="cmtt-12">_submap</span><span
4438class="cmtt-12">_residue] </span>element <span
4439class="cmtt-12">[i]</span>
4440 </dd><dt class="enumerate-enumitem">
4441 4. </dt><dd
4442class="enumerate-enumitem"><span
4443class="cmtt-12">[residue</span><span
4444class="cmtt-12">_type] </span>= vector <span
4445class="cmtt-12">[vorbis</span><span
4446class="cmtt-12">_residue</span><span
4447class="cmtt-12">_types] </span>element <span
4448class="cmtt-12">[residue</span><span
4449class="cmtt-12">_number]</span>
4450 </dd><dt class="enumerate-enumitem">
4451 5. </dt><dd
4452class="enumerate-enumitem">decode <span
4453class="cmtt-12">[ch] </span>vectors using residue <span
4454class="cmtt-12">[residue</span><span
4455class="cmtt-12">_number]</span>, according to type <span
4456class="cmtt-12">[residue</span><span
4457class="cmtt-12">_type]</span>,
4458
4459
4460
4461 also passing vector <span
4462class="cmtt-12">[do</span><span
4463class="cmtt-12">_not</span><span
4464class="cmtt-12">_decode</span><span
4465class="cmtt-12">_flag] </span>to indicate which vectors in the bundle should
4466 not be decoded. Correct per-vector decode length is <span
4467class="cmtt-12">[n]</span>/2.
4468 </dd><dt class="enumerate-enumitem">
4469 6. </dt><dd
4470class="enumerate-enumitem"><span
4471class="cmtt-12">[ch] </span>= 0
4472 </dd><dt class="enumerate-enumitem">
4473 7. </dt><dd
4474class="enumerate-enumitem">for each channel <span
4475class="cmtt-12">[j] </span>in order from 0 ... <span
4476class="cmtt-12">[audio</span><span
4477class="cmtt-12">_channels]</span>
4478 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4479 a) </dt><dd
4480class="enumerate-enumitem">if channel <span
4481class="cmtt-12">[j] </span>is in submap <span
4482class="cmtt-12">[i] </span>(vector <span
4483class="cmtt-12">[vorbis</span><span
4484class="cmtt-12">_mapping</span><span
4485class="cmtt-12">_mux] </span>element <span
4486class="cmtt-12">[j] </span>is equal
4487 to <span
4488class="cmtt-12">[i]</span>)
4489 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4490 i. </dt><dd
4491class="enumerate-enumitem">residue vector for channel <span
4492class="cmtt-12">[j] </span>is set to decoded residue vector <span
4493class="cmtt-12">[ch]</span>
4494 </dd><dt class="enumerate-enumitem">
4495 ii. </dt><dd
4496class="enumerate-enumitem">increment <span
4497class="cmtt-12">[ch]</span></dd></dl>
4498 </dd></dl>
4499 </dd></dl>
4500<!--l. 479--><p class="noindent" >
4501<h5 class="subsubsectionHead"><span class="titlemark">4.3.5. </span> <a
4502 id="x1-770004.3.5"></a>inverse coupling</h5>
4503<!--l. 481--><p class="noindent" >for each <span
4504class="cmtt-12">[i] </span>from <span
4505class="cmtt-12">[vorbis</span><span
4506class="cmtt-12">_mapping</span><span
4507class="cmtt-12">_coupling</span><span
4508class="cmtt-12">_steps]</span>-1 descending to 0
4509<!--l. 484--><p class="noindent" >
4510 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4511 1. </dt><dd
4512class="enumerate-enumitem"><span
4513class="cmtt-12">[magnitude</span><span
4514class="cmtt-12">_vector] </span>= the residue vector for channel (vector
4515 <span
4516class="cmtt-12">[vorbis</span><span
4517class="cmtt-12">_mapping</span><span
4518class="cmtt-12">_magnitude] </span>element <span
4519class="cmtt-12">[i]</span>)
4520 </dd><dt class="enumerate-enumitem">
4521 2. </dt><dd
4522class="enumerate-enumitem"><span
4523class="cmtt-12">[angle</span><span
4524class="cmtt-12">_vector] </span>= the residue vector for channel (vector <span
4525class="cmtt-12">[vorbis</span><span
4526class="cmtt-12">_mapping</span><span
4527class="cmtt-12">_angle]</span>
4528 element <span
4529class="cmtt-12">[i]</span>)
4530 </dd><dt class="enumerate-enumitem">
4531 3. </dt><dd
4532class="enumerate-enumitem">for each scalar value <span
4533class="cmtt-12">[M] </span>in vector <span
4534class="cmtt-12">[magnitude</span><span
4535class="cmtt-12">_vector] </span>and the corresponding scalar value
4536 <span
4537class="cmtt-12">[A] </span>in vector <span
4538class="cmtt-12">[angle</span><span
4539class="cmtt-12">_vector]</span>:
4540 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4541 a) </dt><dd
4542class="enumerate-enumitem">if (<span
4543class="cmtt-12">[M] </span>is greater than zero)
4544
4545
4546
4547 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4548 i. </dt><dd
4549class="enumerate-enumitem">if (<span
4550class="cmtt-12">[A] </span>is greater than zero)
4551 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4552 A. </dt><dd
4553class="enumerate-enumitem"><span
4554class="cmtt-12">[new</span><span
4555class="cmtt-12">_M] </span>= <span
4556class="cmtt-12">[M]</span>
4557 </dd><dt class="enumerate-enumitem">
4558 B. </dt><dd
4559class="enumerate-enumitem"><span
4560class="cmtt-12">[new</span><span
4561class="cmtt-12">_A] </span>= <span
4562class="cmtt-12">[M]</span>-<span
4563class="cmtt-12">[A]</span></dd></dl>
4564 <!--l. 497--><p class="noindent" >else
4565 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4566 A. </dt><dd
4567class="enumerate-enumitem"><span
4568class="cmtt-12">[new</span><span
4569class="cmtt-12">_A] </span>= <span
4570class="cmtt-12">[M]</span>
4571 </dd><dt class="enumerate-enumitem">
4572 B. </dt><dd
4573class="enumerate-enumitem"><span
4574class="cmtt-12">[new</span><span
4575class="cmtt-12">_M] </span>= <span
4576class="cmtt-12">[M]</span>+<span
4577class="cmtt-12">[A]</span></dd></dl>
4578 </dd></dl>
4579 <!--l. 504--><p class="noindent" >else
4580 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4581 i. </dt><dd
4582class="enumerate-enumitem">if (<span
4583class="cmtt-12">[A] </span>is greater than zero)
4584 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4585 A. </dt><dd
4586class="enumerate-enumitem"><span
4587class="cmtt-12">[new</span><span
4588class="cmtt-12">_M] </span>= <span
4589class="cmtt-12">[M]</span>
4590 </dd><dt class="enumerate-enumitem">
4591 B. </dt><dd
4592class="enumerate-enumitem"><span
4593class="cmtt-12">[new</span><span
4594class="cmtt-12">_A] </span>= <span
4595class="cmtt-12">[M]</span>+<span
4596class="cmtt-12">[A]</span></dd></dl>
4597 <!--l. 511--><p class="noindent" >else
4598 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
4599 A. </dt><dd
4600class="enumerate-enumitem"><span
4601class="cmtt-12">[new</span><span
4602class="cmtt-12">_A] </span>= <span
4603class="cmtt-12">[M]</span>
4604 </dd><dt class="enumerate-enumitem">
4605 B. </dt><dd
4606class="enumerate-enumitem"><span
4607class="cmtt-12">[new</span><span
4608class="cmtt-12">_M] </span>= <span
4609class="cmtt-12">[M]</span>-<span
4610class="cmtt-12">[A]</span></dd></dl>
4611 </dd></dl>
4612 </dd><dt class="enumerate-enumitem">
4613 b) </dt><dd
4614class="enumerate-enumitem">set scalar value <span
4615class="cmtt-12">[M] </span>in vector <span
4616class="cmtt-12">[magnitude</span><span
4617class="cmtt-12">_vector] </span>to <span
4618class="cmtt-12">[new</span><span
4619class="cmtt-12">_M]</span>
4620 </dd><dt class="enumerate-enumitem">
4621 c) </dt><dd
4622class="enumerate-enumitem">set scalar value <span
4623class="cmtt-12">[A] </span>in vector <span
4624class="cmtt-12">[angle</span><span
4625class="cmtt-12">_vector] </span>to <span
4626class="cmtt-12">[new</span><span
4627class="cmtt-12">_A]</span></dd></dl>
4628 </dd></dl>
4629
4630
4631
4632<!--l. 528--><p class="noindent" >
4633<h5 class="subsubsectionHead"><span class="titlemark">4.3.6. </span> <a
4634 id="x1-780004.3.6"></a>dot product</h5>
4635<!--l. 530--><p class="noindent" >For each channel, synthesize the floor curve from the decoded floor information, according to
4636packet type. Note that the vector synthesis length for floor computation is <span
4637class="cmtt-12">[n]</span>/2.
4638<!--l. 534--><p class="noindent" >For each channel, multiply each element of the floor curve by each element of that
4639channel&#8217;s residue vector. The result is the dot product of the floor and residue vectors for
4640each channel; the produced vectors are the length <span
4641class="cmtt-12">[n]</span>/2 audio spectrum for each
4642channel.
4643<!--l. 542--><p class="noindent" >One point is worth mentioning about this dot product; a common mistake in a fixed point
4644implementation might be to assume that a 32 bit fixed-point representation for floor and
4645residue and direct multiplication of the vectors is sufficient for acceptable spectral depth
4646in all cases because it happens to mostly work with the current Xiph.Org reference
4647encoder.
4648<!--l. 549--><p class="noindent" >However, floor vector values can span <span
4649class="cmsy-10x-x-120">~</span>140dB (<span
4650class="cmsy-10x-x-120">~</span>24 bits unsigned), and the audio spectrum
4651vector should represent a minimum of 120dB (<span
4652class="cmsy-10x-x-120">~</span>21 bits with sign), even when output is to a 16
4653bit PCM device. For the residue vector to represent full scale if the floor is nailed
4654to <span
4655class="cmsy-10x-x-120">-</span>140dB, it must be able to span 0 to +140dB. For the residue vector to reach
4656full scale if the floor is nailed at 0dB, it must be able to represent <span
4657class="cmsy-10x-x-120">-</span>140dB to +0dB.
4658Thus, in order to handle full range dynamics, a residue vector may span <span
4659class="cmsy-10x-x-120">-</span>140dB to
4660+140dB entirely within spec. A 280dB range is approximately 48 bits with sign; thus the
4661residue vector must be able to represent a 48 bit range and the dot product must
4662be able to handle an effective 48 bit times 24 bit multiplication. This range may be
4663achieved using large (64 bit or larger) integers, or implementing a movable binary point
4664representation.
4665<!--l. 566--><p class="noindent" >
4666<h5 class="subsubsectionHead"><span class="titlemark">4.3.7. </span> <a
4667 id="x1-790004.3.7"></a>inverse MDCT</h5>
4668<!--l. 568--><p class="noindent" >Convert the audio spectrum vector of each channel back into time domain PCM audio via an
4669inverse Modified Discrete Cosine Transform (MDCT). A detailed description of the MDCT is
4670available in <span class="cite">[<a
4671href="#XSporer/Brandenburg/Edler">1</a>]</span>. The window function used for the MDCT is the function described
4672earlier.
4673
4674
4675
4676<!--l. 575--><p class="noindent" >
4677<h5 class="subsubsectionHead"><span class="titlemark">4.3.8. </span> <a
4678 id="x1-800004.3.8"></a>overlap_add</h5>
4679<!--l. 577--><p class="noindent" >Windowed MDCT output is overlapped and added with the right hand data of the previous
4680window such that the 3/4 point of the previous window is aligned with the 1/4 point of the
4681current window (as illustrated in <a
4682href="#x1-260001.3.2">paragraph&#x00A0;1.3.2</a>, &#8220;<a
4683href="#x1-260001.3.2">Window shape decode (long windows
4684only)<!--tex4ht:ref: vorbis:spec:window --></a>&#8221;). The overlapped portion produced from overlapping the previous and current frame data
4685is finished data to be returned by the decoder. This data spans from the center of
4686the previous window to the center of the current window. In the case of same-sized
4687windows, the amount of data to return is one-half block consisting of and only of the
4688overlapped portions. When overlapping a short and long window, much of the returned
4689range does not actually overlap. This does not damage transform orthogonality. Pay
4690attention however to returning the correct data range; the amount of data to be returned
4691is:
4692<!--l. 591--><p class="noindent" >
4693<div class="fancyvrb" id="fancyvrb22"><a
4694 id="x1-80002r1"></a><span
4695class="cmr-6">1</span><span
4696class="cmtt-8">window_blocksize(previous_window)/4+window_blocksize(current_window)/4</span></div>
4697<!--l. 595--><p class="noindent" >from the center (element windowsize/2) of the previous window to the center (element
4698windowsize/2-1, inclusive) of the current window.
4699<!--l. 598--><p class="noindent" >Data is not returned from the first frame; it must be used to &#8217;prime&#8217; the decode engine. The
4700encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper
4701PCM output offset is &#8217;0&#8217; (as no data has been returned yet).
4702<!--l. 605--><p class="noindent" >
4703<h5 class="subsubsectionHead"><span class="titlemark">4.3.9. </span> <a
4704 id="x1-810004.3.9"></a>output channel order</h5>
4705<!--l. 607--><p class="noindent" >Vorbis I specifies only a channel mapping type 0. In mapping type 0, channel mapping is
4706implicitly defined as follows for standard audio applications. As of revision 16781 (20100113), the
4707specification adds defined channel locations for 6.1 and 7.1 surround. Ordering/location for
4708greater-than-eight channels remains &#8217;left to the implementation&#8217;.
4709<!--l. 613--><p class="noindent" >These channel orderings refer to order within the encoded stream. It is naturally possible for a
4710decoder to produce output with channels in any order. Any such decoder should explicitly
4711document channel reordering behavior.
4712<!--l. 619--><p class="noindent" >
4713 <dl class="description"><dt class="description">
4714<span
4715class="cmssbx-10x-x-120">one channel</span> </dt><dd
4716class="description">the stream is monophonic
4717
4718
4719
4720 </dd><dt class="description">
4721<span
4722class="cmssbx-10x-x-120">two channels</span> </dt><dd
4723class="description">the stream is stereo. channel order: left, right
4724 </dd><dt class="description">
4725<span
4726class="cmssbx-10x-x-120">three channels</span> </dt><dd
4727class="description">the stream is a 1d-surround encoding. channel order: left, center, right
4728 </dd><dt class="description">
4729<span
4730class="cmssbx-10x-x-120">four channels</span> </dt><dd
4731class="description">the stream is quadraphonic surround. channel order: front left, front right,
4732 rear left, rear right
4733 </dd><dt class="description">
4734<span
4735class="cmssbx-10x-x-120">five channels</span> </dt><dd
4736class="description">the stream is five-channel surround. channel order: front left, center, front
4737 right, rear left, rear right
4738 </dd><dt class="description">
4739<span
4740class="cmssbx-10x-x-120">six channels</span> </dt><dd
4741class="description">the stream is 5.1 surround. channel order: front left, center, front right, rear
4742 left, rear right, LFE
4743 </dd><dt class="description">
4744<span
4745class="cmssbx-10x-x-120">seven channels</span> </dt><dd
4746class="description">the stream is 6.1 surround. channel order: front left, center, front right,
4747 side left, side right, rear center, LFE
4748 </dd><dt class="description">
4749<span
4750class="cmssbx-10x-x-120">eight channels</span> </dt><dd
4751class="description">the stream is 7.1 surround. channel order: front left, center, front right,
4752 side left, side right, rear left, rear right, LFE
4753 </dd><dt class="description">
4754<span
4755class="cmssbx-10x-x-120">greater than eight channels</span> </dt><dd
4756class="description">channel use and order is defined by the application
4757 </dd></dl>
4758<!--l. 655--><p class="noindent" >Applications using Vorbis for dedicated purposes may define channel mapping as seen fit. Future
4759channel mappings (such as three and four channel <a
4760href="http://www.ambisonic.net/" >Ambisonics</a>) will make use of channel
4761mappings other than mapping 0.
4762
4763
4764
4765
4766
4767
4768<h3 class="sectionHead"><span class="titlemark">5. </span> <a
4769 id="x1-820005"></a>comment field and header specification</h3>
4770<!--l. 5--><p class="noindent" >
4771<h4 class="subsectionHead"><span class="titlemark">5.1. </span> <a
4772 id="x1-830005.1"></a>Overview</h4>
4773<!--l. 7--><p class="noindent" >The Vorbis text comment header is the second (of three) header packets that begin a Vorbis
4774bitstream. It is meant for short text comments, not arbitrary metadata; arbitrary metadata
4775belongs in a separate logical bitstream (usually an XML stream type) that provides greater
4776structure and machine parseability.
4777<!--l. 13--><p class="noindent" >The comment field is meant to be used much like someone jotting a quick note on the bottom of
4778a CDR. It should be a little information to remember the disc by and explain it to others; a
4779short, to-the-point text note that need not only be a couple words, but isn&#8217;t going to be more
4780than a short paragraph. The essentials, in other words, whatever they turn out to be,
4781eg:
4782<!--l. 20--><p class="noindent" >
4783 <div class="quote">
4784 <!--l. 21--><p class="noindent" >Honest Bob and the Factory-to-Dealer-Incentives, <span
4785class="cmti-12">&#8220;I&#8217;m Still Around&#8221;</span>, opening
4786 for Moxy Früvous, 1997.</div>
4787<!--l. 28--><p class="noindent" >
4788<h4 class="subsectionHead"><span class="titlemark">5.2. </span> <a
4789 id="x1-840005.2"></a>Comment encoding</h4>
4790<!--l. 30--><p class="noindent" >
4791<h5 class="subsubsectionHead"><span class="titlemark">5.2.1. </span> <a
4792 id="x1-850005.2.1"></a>Structure</h5>
4793<!--l. 32--><p class="noindent" >The comment header is logically a list of eight-bit-clean vectors; the number of vectors is
4794bounded to 2<sup><span
4795class="cmr-8">32</span></sup> <span
4796class="cmsy-10x-x-120">- </span>1 and the length of each vector is limited to 2<sup><span
4797class="cmr-8">32</span></sup> <span
4798class="cmsy-10x-x-120">- </span>1 bytes. The vector length is
4799
4800
4801
4802encoded; the vector contents themselves are not null terminated. In addition to the vector list,
4803there is a single vector for vendor name (also 8 bit clean, length encoded in 32 bits). For
4804example, the 1.0 release of libvorbis set the vendor string to &#8220;Xiph.Org libVorbis I
480520020717&#8221;.
4806<!--l. 40--><p class="noindent" >The vector lengths and number of vectors are stored lsb first, according to the bit
4807packing conventions of the vorbis codec. However, since data in the comment header
4808is octet-aligned, they can simply be read as unaligned 32 bit little endian unsigned
4809integers.
4810<!--l. 45--><p class="noindent" >The comment header is decoded as follows:
4811<!--l. 47--><p class="noindent" >
4812<div class="fancyvrb" id="fancyvrb23"><a
4813 id="x1-85002r1"></a><span
4814class="cmr-6">1</span><span
4815class="cmtt-8">&#x00A0;</span><span
4816class="cmtt-8">&#x00A0;1)</span><span
4817class="cmtt-8">&#x00A0;[vendor\_length]</span><span
4818class="cmtt-8">&#x00A0;=</span><span
4819class="cmtt-8">&#x00A0;read</span><span
4820class="cmtt-8">&#x00A0;an</span><span
4821class="cmtt-8">&#x00A0;unsigned</span><span
4822class="cmtt-8">&#x00A0;integer</span><span
4823class="cmtt-8">&#x00A0;of</span><span
4824class="cmtt-8">&#x00A0;32</span><span
4825class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
4826 id="x1-85004r2"></a><span
4827class="cmr-6">2</span><span
4828class="cmtt-8">&#x00A0;</span><span
4829class="cmtt-8">&#x00A0;2)</span><span
4830class="cmtt-8">&#x00A0;[vendor\_string]</span><span
4831class="cmtt-8">&#x00A0;=</span><span
4832class="cmtt-8">&#x00A0;read</span><span
4833class="cmtt-8">&#x00A0;a</span><span
4834class="cmtt-8">&#x00A0;UTF-8</span><span
4835class="cmtt-8">&#x00A0;vector</span><span
4836class="cmtt-8">&#x00A0;as</span><span
4837class="cmtt-8">&#x00A0;[vendor\_length]</span><span
4838class="cmtt-8">&#x00A0;octets</span>
4839<br class="fancyvrb" /><a
4840 id="x1-85006r3"></a><span
4841class="cmr-6">3</span><span
4842class="cmtt-8">&#x00A0;</span><span
4843class="cmtt-8">&#x00A0;3)</span><span
4844class="cmtt-8">&#x00A0;[user\_comment\_list\_length]</span><span
4845class="cmtt-8">&#x00A0;=</span><span
4846class="cmtt-8">&#x00A0;read</span><span
4847class="cmtt-8">&#x00A0;an</span><span
4848class="cmtt-8">&#x00A0;unsigned</span><span
4849class="cmtt-8">&#x00A0;integer</span><span
4850class="cmtt-8">&#x00A0;of</span><span
4851class="cmtt-8">&#x00A0;32</span><span
4852class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
4853 id="x1-85008r4"></a><span
4854class="cmr-6">4</span><span
4855class="cmtt-8">&#x00A0;</span><span
4856class="cmtt-8">&#x00A0;4)</span><span
4857class="cmtt-8">&#x00A0;iterate</span><span
4858class="cmtt-8">&#x00A0;[user\_comment\_list\_length]</span><span
4859class="cmtt-8">&#x00A0;times</span><span
4860class="cmtt-8">&#x00A0;{</span>
4861<br class="fancyvrb" /><a
4862 id="x1-85010r5"></a><span
4863class="cmr-6">5</span><span
4864class="cmtt-8">&#x00A0;</span><span
4865class="cmtt-8">&#x00A0;</span><span
4866class="cmtt-8">&#x00A0;</span><span
4867class="cmtt-8">&#x00A0;</span><span
4868class="cmtt-8">&#x00A0;</span><span
4869class="cmtt-8">&#x00A0;</span><span
4870class="cmtt-8">&#x00A0;5)</span><span
4871class="cmtt-8">&#x00A0;[length]</span><span
4872class="cmtt-8">&#x00A0;=</span><span
4873class="cmtt-8">&#x00A0;read</span><span
4874class="cmtt-8">&#x00A0;an</span><span
4875class="cmtt-8">&#x00A0;unsigned</span><span
4876class="cmtt-8">&#x00A0;integer</span><span
4877class="cmtt-8">&#x00A0;of</span><span
4878class="cmtt-8">&#x00A0;32</span><span
4879class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
4880 id="x1-85012r6"></a><span
4881class="cmr-6">6</span><span
4882class="cmtt-8">&#x00A0;</span><span
4883class="cmtt-8">&#x00A0;</span><span
4884class="cmtt-8">&#x00A0;</span><span
4885class="cmtt-8">&#x00A0;</span><span
4886class="cmtt-8">&#x00A0;</span><span
4887class="cmtt-8">&#x00A0;</span><span
4888class="cmtt-8">&#x00A0;6)</span><span
4889class="cmtt-8">&#x00A0;this</span><span
4890class="cmtt-8">&#x00A0;iteration&#8217;s</span><span
4891class="cmtt-8">&#x00A0;user</span><span
4892class="cmtt-8">&#x00A0;comment</span><span
4893class="cmtt-8">&#x00A0;=</span><span
4894class="cmtt-8">&#x00A0;read</span><span
4895class="cmtt-8">&#x00A0;a</span><span
4896class="cmtt-8">&#x00A0;UTF-8</span><span
4897class="cmtt-8">&#x00A0;vector</span><span
4898class="cmtt-8">&#x00A0;as</span><span
4899class="cmtt-8">&#x00A0;[length]</span><span
4900class="cmtt-8">&#x00A0;octets</span>
4901<br class="fancyvrb" /><a
4902 id="x1-85014r7"></a><span
4903class="cmr-6">7</span><span
4904class="cmtt-8">&#x00A0;</span><span
4905class="cmtt-8">&#x00A0;</span><span
4906class="cmtt-8">&#x00A0;</span><span
4907class="cmtt-8">&#x00A0;</span><span
4908class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
4909 id="x1-85016r8"></a><span
4910class="cmr-6">8</span><span
4911class="cmtt-8">&#x00A0;</span><span
4912class="cmtt-8">&#x00A0;7)</span><span
4913class="cmtt-8">&#x00A0;[framing\_bit]</span><span
4914class="cmtt-8">&#x00A0;=</span><span
4915class="cmtt-8">&#x00A0;read</span><span
4916class="cmtt-8">&#x00A0;a</span><span
4917class="cmtt-8">&#x00A0;single</span><span
4918class="cmtt-8">&#x00A0;bit</span><span
4919class="cmtt-8">&#x00A0;as</span><span
4920class="cmtt-8">&#x00A0;boolean</span><br class="fancyvrb" /><a
4921 id="x1-85018r9"></a><span
4922class="cmr-6">9</span><span
4923class="cmtt-8">&#x00A0;</span><span
4924class="cmtt-8">&#x00A0;8)</span><span
4925class="cmtt-8">&#x00A0;if</span><span
4926class="cmtt-8">&#x00A0;(</span><span
4927class="cmtt-8">&#x00A0;[framing\_bit]</span><span
4928class="cmtt-8">&#x00A0;unset</span><span
4929class="cmtt-8">&#x00A0;or</span><span
4930class="cmtt-8">&#x00A0;end-of-packet</span><span
4931class="cmtt-8">&#x00A0;)</span><span
4932class="cmtt-8">&#x00A0;then</span><span
4933class="cmtt-8">&#x00A0;ERROR</span><br class="fancyvrb" /><a
4934 id="x1-85020r10"></a><span
4935class="cmr-6">10</span><span
4936class="cmtt-8">&#x00A0;</span><span
4937class="cmtt-8">&#x00A0;9)</span><span
4938class="cmtt-8">&#x00A0;done.</span></div>
4939<!--l. 63--><p class="noindent" >
4940<h5 class="subsubsectionHead"><span class="titlemark">5.2.2. </span> <a
4941 id="x1-860005.2.2"></a>Content vector format</h5>
4942<!--l. 65--><p class="noindent" >The comment vectors are structured similarly to a UNIX environment variable. That is,
4943comment fields consist of a field name and a corresponding value and look like:
4944<!--l. 69--><p class="noindent" >
4945 <div class="quote">
4946 <!--l. 70--><p class="noindent" >
4947 <div class="fancyvrb" id="fancyvrb24"><a
4948 id="x1-86002r1"></a><span
4949class="cmr-6">1</span><span
4950class="cmtt-8">comment[0]="ARTIST=me";</span><br class="fancyvrb" /><a
4951 id="x1-86004r2"></a><span
4952class="cmr-6">2</span><span
4953class="cmtt-8">comment[1]="TITLE=the</span><span
4954class="cmtt-8">&#x00A0;sound</span><span
4955class="cmtt-8">&#x00A0;of</span><span
4956class="cmtt-8">&#x00A0;Vorbis";</span></div>
4957 </div>
4958<!--l. 76--><p class="noindent" >The field name is case-insensitive and may consist of ASCII 0x20 through 0x7D, 0x3D (&#8217;=&#8217;)
4959excluded. ASCII 0x41 through 0x5A inclusive (characters A-Z) is to be considered equivalent to
4960ASCII 0x61 through 0x7A inclusive (characters a-z).
4961<!--l. 82--><p class="noindent" >The field name is immediately followed by ASCII 0x3D (&#8217;=&#8217;); this equals sign is used to
4962terminate the field name.
4963<!--l. 86--><p class="noindent" >0x3D is followed by 8 bit clean UTF-8 encoded value of the field contents to the end of the
4964field.
4965
4966
4967
4968<!--l. 90--><p class="noindent" ><span class="paragraphHead"><a
4969 id="x1-870005.2.2"></a><span
4970class="cmbx-12">Field names</span></span>
4971Below is a proposed, minimal list of standard field names with a description of intended use. No
4972single or group of field names is mandatory; a comment header may contain one, all or none of
4973the names in this list.
4974<!--l. 98--><p class="noindent" >
4975 <dl class="description"><dt class="description">
4976<span
4977class="cmssbx-10x-x-120">TITLE</span> </dt><dd
4978class="description">Track/Work name
4979 </dd><dt class="description">
4980<span
4981class="cmssbx-10x-x-120">VERSION</span> </dt><dd
4982class="description">The version field may be used to differentiate multiple versions of the same
4983 track title in a single collection. (e.g. remix info)
4984 </dd><dt class="description">
4985<span
4986class="cmssbx-10x-x-120">ALBUM</span> </dt><dd
4987class="description">The collection name to which this track belongs
4988 </dd><dt class="description">
4989<span
4990class="cmssbx-10x-x-120">TRACKNUMBER</span> </dt><dd
4991class="description">The track number of this piece if part of a specific larger collection or
4992 album
4993 </dd><dt class="description">
4994<span
4995class="cmssbx-10x-x-120">ARTIST</span> </dt><dd
4996class="description">The artist generally considered responsible for the work. In popular music this is
4997 usually the performing band or singer. For classical music it would be the composer.
4998 For an audio book it would be the author of the original text.
4999 </dd><dt class="description">
5000<span
5001class="cmssbx-10x-x-120">PERFORMER</span> </dt><dd
5002class="description">The artist(s) who performed the work. In classical music this would be the
5003 conductor, orchestra, soloists. In an audio book it would be the actor who did the
5004 reading. In popular music this is typically the same as the ARTIST and is omitted.
5005 </dd><dt class="description">
5006<span
5007class="cmssbx-10x-x-120">COPYRIGHT</span> </dt><dd
5008class="description">Copyright attribution, e.g., &#8217;2001 Nobody&#8217;s Band&#8217; or &#8217;1999 Jack Moffitt&#8217;
5009 </dd><dt class="description">
5010<span
5011class="cmssbx-10x-x-120">LICENSE</span> </dt><dd
5012class="description">License information, for example, &#8217;All Rights Reserved&#8217;, &#8217;Any Use
5013 Permitted&#8217;, a URL to a license such as a Creative Commons license (e.g.
5014 &#8221;creativecommons.org/license/by/4.0/&#8221;) or similar.
5015 </dd><dt class="description">
5016<span
5017class="cmssbx-10x-x-120">ORGANIZATION</span> </dt><dd
5018class="description">Name of the organization producing the track (i.e. the &#8217;record label&#8217;)
5019 </dd><dt class="description">
5020<span
5021class="cmssbx-10x-x-120">DESCRIPTION</span> </dt><dd
5022class="description">A short text description of the contents
5023 </dd><dt class="description">
5024<span
5025class="cmssbx-10x-x-120">GENRE</span> </dt><dd
5026class="description">A short text indication of music genre
5027
5028
5029
5030 </dd><dt class="description">
5031<span
5032class="cmssbx-10x-x-120">DATE</span> </dt><dd
5033class="description">Date the track was recorded
5034 </dd><dt class="description">
5035<span
5036class="cmssbx-10x-x-120">LOCATION</span> </dt><dd
5037class="description">Location where track was recorded
5038 </dd><dt class="description">
5039<span
5040class="cmssbx-10x-x-120">CONTACT</span> </dt><dd
5041class="description">Contact information for the creators or distributors of the track. This could
5042 be a URL, an email address, the physical address of the producing label.
5043 </dd><dt class="description">
5044<span
5045class="cmssbx-10x-x-120">ISRC</span> </dt><dd
5046class="description">International Standard Recording Code for the track; see <a
5047href="https://isrc.ifpi.org/" >the ISRC intro page</a> for
5048 more information on ISRC numbers.
5049 </dd></dl>
5050<!--l. 154--><p class="noindent" ><span class="paragraphHead"><a
5051 id="x1-880005.2.2"></a><span
5052class="cmbx-12">Implications</span></span>
5053Field names should not be &#8217;internationalized&#8217;; this is a concession to simplicity not
5054an attempt to exclude the majority of the world that doesn&#8217;t speak English. Field
5055<span
5056class="cmti-12">contents</span>, however, use the UTF-8 character encoding to allow easy representation of any
5057language.
5058<!--l. 162--><p class="noindent" >We have the length of the entirety of the field and restrictions on the field name so that
5059the field name is bounded in a known way. Thus we also have the length of the field
5060contents.
5061<!--l. 166--><p class="noindent" >Individual &#8217;vendors&#8217; may use non-standard field names within reason. The proper
5062use of comment fields should be clear through context at this point. Abuse will be
5063discouraged.
5064<!--l. 170--><p class="noindent" >There is no vendor-specific prefix to &#8217;nonstandard&#8217; field names. Vendors should make some effort
5065to avoid arbitrarily polluting the common namespace. We will generally collect the more useful
5066tags here to help with standardization.
5067<!--l. 175--><p class="noindent" >Field names are not required to be unique (occur once) within a comment header. As an
5068example, assume a track was recorded by three well know artists; the following is permissible,
5069and encouraged:
5070<!--l. 179--><p class="noindent" >
5071 <div class="quote">
5072 <!--l. 180--><p class="noindent" >
5073 <div class="fancyvrb" id="fancyvrb25"><a
5074 id="x1-88002r1"></a><span
5075class="cmr-6">1</span><span
5076class="cmtt-8">ARTIST=Dizzy</span><span
5077class="cmtt-8">&#x00A0;Gillespie</span><br class="fancyvrb" /><a
5078 id="x1-88004r2"></a><span
5079class="cmr-6">2</span><span
5080class="cmtt-8">ARTIST=Sonny</span><span
5081class="cmtt-8">&#x00A0;Rollins</span><br class="fancyvrb" /><a
5082 id="x1-88006r3"></a><span
5083class="cmr-6">3</span><span
5084class="cmtt-8">ARTIST=Sonny</span><span
5085class="cmtt-8">&#x00A0;Stitt</span></div>
5086
5087
5088
5089 </div>
5090<!--l. 193--><p class="noindent" >
5091<h5 class="subsubsectionHead"><span class="titlemark">5.2.3. </span> <a
5092 id="x1-890005.2.3"></a>Encoding</h5>
5093<!--l. 195--><p class="noindent" >The comment header comprises the entirety of the second bitstream header packet. Unlike the
5094first bitstream header packet, it is not generally the only packet on the second page and may not
5095be restricted to within the second bitstream page. The length of the comment header packet is
5096(practically) unbounded. The comment header packet is not optional; it must be present in the
5097bitstream even if it is effectively empty.
5098<!--l. 203--><p class="noindent" >The comment header is encoded as follows (as per Ogg&#8217;s standard bitstream mapping which
5099renders least-significant-bit of the word to be coded into the least significant available bit of the
5100current bitstream octet first):
5101<!--l. 209--><p class="noindent" >
5102 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
5103 1. </dt><dd
5104class="enumerate-enumitem">Vendor string length (32 bit unsigned quantity specifying number of octets)
5105 </dd><dt class="enumerate-enumitem">
5106 2. </dt><dd
5107class="enumerate-enumitem">Vendor string ([vendor string length] octets coded from beginning of string to end of
5108 string, not null terminated)
5109 </dd><dt class="enumerate-enumitem">
5110 3. </dt><dd
5111class="enumerate-enumitem">Number of comment fields (32 bit unsigned quantity specifying number of fields)
5112 </dd><dt class="enumerate-enumitem">
5113 4. </dt><dd
5114class="enumerate-enumitem">Comment field 0 length (if [Number of comment fields] <span
5115class="cmmi-12">&#x003E; </span>0; 32 bit unsigned quantity
5116 specifying number of octets)
5117 </dd><dt class="enumerate-enumitem">
5118 5. </dt><dd
5119class="enumerate-enumitem">Comment field 0 ([Comment field 0 length] octets coded from beginning of string to
5120 end of string, not null terminated)
5121 </dd><dt class="enumerate-enumitem">
5122 6. </dt><dd
5123class="enumerate-enumitem">Comment field 1 length (if [Number of comment fields] <span
5124class="cmmi-12">&#x003E; </span>1...)...
5125 </dd></dl>
5126<!--l. 230--><p class="noindent" >This is actually somewhat easier to describe in code; implementation of the above can be found
5127in <span
5128class="cmtt-12">vorbis/lib/info.c</span>, <span
5129class="cmtt-12">_vorbis</span><span
5130class="cmtt-12">_pack</span><span
5131class="cmtt-12">_comment() </span>and <span
5132class="cmtt-12">_vorbis</span><span
5133class="cmtt-12">_unpack</span><span
5134class="cmtt-12">_comment()</span>.
5135
5136
5137
5138
5139
5140
5141<h3 class="sectionHead"><span class="titlemark">6. </span> <a
5142 id="x1-900006"></a>Floor type 0 setup and decode</h3>
5143<!--l. 5--><p class="noindent" >
5144<h4 class="subsectionHead"><span class="titlemark">6.1. </span> <a
5145 id="x1-910006.1"></a>Overview</h4>
5146<!--l. 7--><p class="noindent" >Vorbis floor type zero uses Line Spectral Pair (LSP, also alternately known as Line Spectral
5147Frequency or LSF) representation to encode a smooth spectral envelope curve as the frequency
5148response of the LSP filter. This representation is equivalent to a traditional all-pole infinite
5149impulse response filter as would be used in linear predictive coding; LSP representation may be
5150converted to LPC representation and vice-versa.
5151<!--l. 17--><p class="noindent" >
5152<h4 class="subsectionHead"><span class="titlemark">6.2. </span> <a
5153 id="x1-920006.2"></a>Floor 0 format</h4>
5154<!--l. 19--><p class="noindent" >Floor zero configuration consists of six integer fields and a list of VQ codebooks for use in
5155coding/decoding the LSP filter coefficient values used by each frame.
5156<!--l. 23--><p class="noindent" >
5157<h5 class="subsubsectionHead"><span class="titlemark">6.2.1. </span> <a
5158 id="x1-930006.2.1"></a>header decode</h5>
5159<!--l. 25--><p class="noindent" >Configuration information for instances of floor zero decodes from the codec setup header (third
5160packet). configuration decode proceeds as follows:
5161<!--l. 29--><p class="noindent" >
5162<div class="fancyvrb" id="fancyvrb26"><a
5163 id="x1-93002r1"></a><span
5164class="cmr-6">1</span><span
5165class="cmtt-8">&#x00A0;</span><span
5166class="cmtt-8">&#x00A0;1)</span><span
5167class="cmtt-8">&#x00A0;[floor0</span><span
5168class="cmtt-8">_order]</span><span
5169class="cmtt-8">&#x00A0;=</span><span
5170class="cmtt-8">&#x00A0;read</span><span
5171class="cmtt-8">&#x00A0;an</span><span
5172class="cmtt-8">&#x00A0;unsigned</span><span
5173class="cmtt-8">&#x00A0;integer</span><span
5174class="cmtt-8">&#x00A0;of</span><span
5175class="cmtt-8">&#x00A0;8</span><span
5176class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
5177 id="x1-93004r2"></a><span
5178class="cmr-6">2</span><span
5179class="cmtt-8">&#x00A0;</span><span
5180class="cmtt-8">&#x00A0;2)</span><span
5181class="cmtt-8">&#x00A0;[floor0</span><span
5182class="cmtt-8">_rate]</span><span
5183class="cmtt-8">&#x00A0;=</span><span
5184class="cmtt-8">&#x00A0;read</span><span
5185class="cmtt-8">&#x00A0;an</span><span
5186class="cmtt-8">&#x00A0;unsigned</span><span
5187class="cmtt-8">&#x00A0;integer</span><span
5188class="cmtt-8">&#x00A0;of</span><span
5189class="cmtt-8">&#x00A0;16</span><span
5190class="cmtt-8">&#x00A0;bits</span>
5191<br class="fancyvrb" /><a
5192 id="x1-93006r3"></a><span
5193class="cmr-6">3</span><span
5194class="cmtt-8">&#x00A0;</span><span
5195class="cmtt-8">&#x00A0;3)</span><span
5196class="cmtt-8">&#x00A0;[floor0</span><span
5197class="cmtt-8">_bark</span><span
5198class="cmtt-8">_map</span><span
5199class="cmtt-8">_size]</span><span
5200class="cmtt-8">&#x00A0;=</span><span
5201class="cmtt-8">&#x00A0;read</span><span
5202class="cmtt-8">&#x00A0;an</span><span
5203class="cmtt-8">&#x00A0;unsigned</span><span
5204class="cmtt-8">&#x00A0;integer</span><span
5205class="cmtt-8">&#x00A0;of</span><span
5206class="cmtt-8">&#x00A0;16</span><span
5207class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
5208 id="x1-93008r4"></a><span
5209class="cmr-6">4</span><span
5210class="cmtt-8">&#x00A0;</span><span
5211class="cmtt-8">&#x00A0;4)</span><span
5212class="cmtt-8">&#x00A0;[floor0</span><span
5213class="cmtt-8">_amplitude</span><span
5214class="cmtt-8">_bits]</span><span
5215class="cmtt-8">&#x00A0;=</span><span
5216class="cmtt-8">&#x00A0;read</span><span
5217class="cmtt-8">&#x00A0;an</span><span
5218class="cmtt-8">&#x00A0;unsigned</span><span
5219class="cmtt-8">&#x00A0;integer</span><span
5220class="cmtt-8">&#x00A0;of</span><span
5221class="cmtt-8">&#x00A0;six</span><span
5222class="cmtt-8">&#x00A0;bits</span>
5223<br class="fancyvrb" /><a
5224 id="x1-93010r5"></a><span
5225class="cmr-6">5</span><span
5226class="cmtt-8">&#x00A0;</span><span
5227class="cmtt-8">&#x00A0;5)</span><span
5228class="cmtt-8">&#x00A0;[floor0</span><span
5229class="cmtt-8">_amplitude</span><span
5230class="cmtt-8">_offset]</span><span
5231class="cmtt-8">&#x00A0;=</span><span
5232class="cmtt-8">&#x00A0;read</span><span
5233class="cmtt-8">&#x00A0;an</span><span
5234class="cmtt-8">&#x00A0;unsigned</span><span
5235class="cmtt-8">&#x00A0;integer</span><span
5236class="cmtt-8">&#x00A0;of</span><span
5237class="cmtt-8">&#x00A0;eight</span><span
5238class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
5239 id="x1-93012r6"></a><span
5240class="cmr-6">6</span><span
5241class="cmtt-8">&#x00A0;</span><span
5242class="cmtt-8">&#x00A0;6)</span><span
5243class="cmtt-8">&#x00A0;[floor0</span><span
5244class="cmtt-8">_number</span><span
5245class="cmtt-8">_of</span><span
5246class="cmtt-8">_books]</span><span
5247class="cmtt-8">&#x00A0;=</span><span
5248class="cmtt-8">&#x00A0;read</span><span
5249class="cmtt-8">&#x00A0;an</span><span
5250class="cmtt-8">&#x00A0;unsigned</span><span
5251class="cmtt-8">&#x00A0;integer</span><span
5252class="cmtt-8">&#x00A0;of</span><span
5253class="cmtt-8">&#x00A0;four</span><span
5254class="cmtt-8">&#x00A0;bits</span><span
5255class="cmtt-8">&#x00A0;and</span><span
5256class="cmtt-8">&#x00A0;add</span><span
5257class="cmtt-8">&#x00A0;1</span>
5258<br class="fancyvrb" /><a
5259 id="x1-93014r7"></a><span
5260class="cmr-6">7</span><span
5261class="cmtt-8">&#x00A0;</span><span
5262class="cmtt-8">&#x00A0;7)</span><span
5263class="cmtt-8">&#x00A0;array</span><span
5264class="cmtt-8">&#x00A0;[floor0</span><span
5265class="cmtt-8">_book</span><span
5266class="cmtt-8">_list]</span><span
5267class="cmtt-8">&#x00A0;=</span><span
5268class="cmtt-8">&#x00A0;read</span><span
5269class="cmtt-8">&#x00A0;a</span><span
5270class="cmtt-8">&#x00A0;list</span><span
5271class="cmtt-8">&#x00A0;of</span><span
5272class="cmtt-8">&#x00A0;[floor0</span><span
5273class="cmtt-8">_number</span><span
5274class="cmtt-8">_of</span><span
5275class="cmtt-8">_books]</span><span
5276class="cmtt-8">&#x00A0;unsigned</span><span
5277class="cmtt-8">&#x00A0;integers</span><span
5278class="cmtt-8">&#x00A0;of</span><span
5279class="cmtt-8">&#x00A0;eight</span><span
5280class="cmtt-8">&#x00A0;bits</span><span
5281class="cmtt-8">&#x00A0;each;</span></div>
5282<!--l. 39--><p class="noindent" >An end-of-packet condition during any of these bitstream reads renders this stream undecodable.
5283In addition, any element of the array <span
5284class="cmtt-12">[floor0</span><span
5285class="cmtt-12">_book</span><span
5286class="cmtt-12">_list] </span>that is greater than the maximum
5287codebook number for this bitstream is an error condition that also renders the stream
5288
5289
5290
5291undecodable.
5292<!--l. 47--><p class="noindent" >
5293<h5 class="subsubsectionHead"><span class="titlemark">6.2.2. </span> <a
5294 id="x1-940006.2.2"></a>packet decode</h5>
5295<!--l. 49--><p class="noindent" >Extracting a floor0 curve from an audio packet consists of first decoding the curve
5296amplitude and <span
5297class="cmtt-12">[floor0</span><span
5298class="cmtt-12">_order] </span>LSP coefficient values from the bitstream, and then
5299computing the floor curve, which is defined as the frequency response of the decoded LSP
5300filter.
5301<!--l. 55--><p class="noindent" >Packet decode proceeds as follows:
5302<div class="fancyvrb" id="fancyvrb27"><a
5303 id="x1-94002r1"></a><span
5304class="cmr-6">1</span><span
5305class="cmtt-8">&#x00A0;</span><span
5306class="cmtt-8">&#x00A0;1)</span><span
5307class="cmtt-8">&#x00A0;[amplitude]</span><span
5308class="cmtt-8">&#x00A0;=</span><span
5309class="cmtt-8">&#x00A0;read</span><span
5310class="cmtt-8">&#x00A0;an</span><span
5311class="cmtt-8">&#x00A0;unsigned</span><span
5312class="cmtt-8">&#x00A0;integer</span><span
5313class="cmtt-8">&#x00A0;of</span><span
5314class="cmtt-8">&#x00A0;[floor0</span><span
5315class="cmtt-8">_amplitude</span><span
5316class="cmtt-8">_bits]</span><span
5317class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
5318 id="x1-94004r2"></a><span
5319class="cmr-6">2</span><span
5320class="cmtt-8">&#x00A0;</span><span
5321class="cmtt-8">&#x00A0;2)</span><span
5322class="cmtt-8">&#x00A0;if</span><span
5323class="cmtt-8">&#x00A0;(</span><span
5324class="cmtt-8">&#x00A0;[amplitude]</span><span
5325class="cmtt-8">&#x00A0;is</span><span
5326class="cmtt-8">&#x00A0;greater</span><span
5327class="cmtt-8">&#x00A0;than</span><span
5328class="cmtt-8">&#x00A0;zero</span><span
5329class="cmtt-8">&#x00A0;)</span><span
5330class="cmtt-8">&#x00A0;</span><span
5331class="cmsy-8">{</span>
5332<br class="fancyvrb" /><a
5333 id="x1-94006r3"></a><span
5334class="cmr-6">3</span><span
5335class="cmtt-8">&#x00A0;</span><span
5336class="cmtt-8">&#x00A0;</span><span
5337class="cmtt-8">&#x00A0;</span><span
5338class="cmtt-8">&#x00A0;</span><span
5339class="cmtt-8">&#x00A0;</span><span
5340class="cmtt-8">&#x00A0;</span><span
5341class="cmtt-8">&#x00A0;3)</span><span
5342class="cmtt-8">&#x00A0;[coefficients]</span><span
5343class="cmtt-8">&#x00A0;is</span><span
5344class="cmtt-8">&#x00A0;an</span><span
5345class="cmtt-8">&#x00A0;empty,</span><span
5346class="cmtt-8">&#x00A0;zero</span><span
5347class="cmtt-8">&#x00A0;length</span><span
5348class="cmtt-8">&#x00A0;vector</span><br class="fancyvrb" /><a
5349 id="x1-94008r4"></a><span
5350class="cmr-6">4</span><span
5351class="cmtt-8">&#x00A0;</span><span
5352class="cmtt-8">&#x00A0;</span><span
5353class="cmtt-8">&#x00A0;</span><span
5354class="cmtt-8">&#x00A0;</span><span
5355class="cmtt-8">&#x00A0;</span><span
5356class="cmtt-8">&#x00A0;</span><span
5357class="cmtt-8">&#x00A0;4)</span><span
5358class="cmtt-8">&#x00A0;[booknumber]</span><span
5359class="cmtt-8">&#x00A0;=</span><span
5360class="cmtt-8">&#x00A0;read</span><span
5361class="cmtt-8">&#x00A0;an</span><span
5362class="cmtt-8">&#x00A0;unsigned</span><span
5363class="cmtt-8">&#x00A0;integer</span><span
5364class="cmtt-8">&#x00A0;of</span><span
5365class="cmtt-8">&#x00A0;</span><a
5366href="#x1-1190009.2.1"><span
5367class="cmtt-8">ilog</span></a><span
5368class="cmtt-8">(</span><span
5369class="cmtt-8">&#x00A0;[floor0</span><span
5370class="cmtt-8">_number</span><span
5371class="cmtt-8">_of</span><span
5372class="cmtt-8">_books]</span><span
5373class="cmtt-8">&#x00A0;)</span><span
5374class="cmtt-8">&#x00A0;bits</span>
5375<br class="fancyvrb" /><a
5376 id="x1-94010r5"></a><span
5377class="cmr-6">5</span><span
5378class="cmtt-8">&#x00A0;</span><span
5379class="cmtt-8">&#x00A0;</span><span
5380class="cmtt-8">&#x00A0;</span><span
5381class="cmtt-8">&#x00A0;</span><span
5382class="cmtt-8">&#x00A0;</span><span
5383class="cmtt-8">&#x00A0;</span><span
5384class="cmtt-8">&#x00A0;5)</span><span
5385class="cmtt-8">&#x00A0;if</span><span
5386class="cmtt-8">&#x00A0;(</span><span
5387class="cmtt-8">&#x00A0;[booknumber]</span><span
5388class="cmtt-8">&#x00A0;is</span><span
5389class="cmtt-8">&#x00A0;greater</span><span
5390class="cmtt-8">&#x00A0;than</span><span
5391class="cmtt-8">&#x00A0;the</span><span
5392class="cmtt-8">&#x00A0;highest</span><span
5393class="cmtt-8">&#x00A0;number</span><span
5394class="cmtt-8">&#x00A0;decode</span><span
5395class="cmtt-8">&#x00A0;codebook</span><span
5396class="cmtt-8">&#x00A0;)</span><span
5397class="cmtt-8">&#x00A0;then</span><span
5398class="cmtt-8">&#x00A0;packet</span><span
5399class="cmtt-8">&#x00A0;is</span><span
5400class="cmtt-8">&#x00A0;undecodable</span><br class="fancyvrb" /><a
5401 id="x1-94012r6"></a><span
5402class="cmr-6">6</span><span
5403class="cmtt-8">&#x00A0;</span><span
5404class="cmtt-8">&#x00A0;</span><span
5405class="cmtt-8">&#x00A0;</span><span
5406class="cmtt-8">&#x00A0;</span><span
5407class="cmtt-8">&#x00A0;</span><span
5408class="cmtt-8">&#x00A0;</span><span
5409class="cmtt-8">&#x00A0;6)</span><span
5410class="cmtt-8">&#x00A0;[last]</span><span
5411class="cmtt-8">&#x00A0;=</span><span
5412class="cmtt-8">&#x00A0;zero;</span>
5413<br class="fancyvrb" /><a
5414 id="x1-94014r7"></a><span
5415class="cmr-6">7</span><span
5416class="cmtt-8">&#x00A0;</span><span
5417class="cmtt-8">&#x00A0;</span><span
5418class="cmtt-8">&#x00A0;</span><span
5419class="cmtt-8">&#x00A0;</span><span
5420class="cmtt-8">&#x00A0;</span><span
5421class="cmtt-8">&#x00A0;</span><span
5422class="cmtt-8">&#x00A0;7)</span><span
5423class="cmtt-8">&#x00A0;vector</span><span
5424class="cmtt-8">&#x00A0;[temp</span><span
5425class="cmtt-8">_vector]</span><span
5426class="cmtt-8">&#x00A0;=</span><span
5427class="cmtt-8">&#x00A0;read</span><span
5428class="cmtt-8">&#x00A0;vector</span><span
5429class="cmtt-8">&#x00A0;from</span><span
5430class="cmtt-8">&#x00A0;bitstream</span><span
5431class="cmtt-8">&#x00A0;using</span><span
5432class="cmtt-8">&#x00A0;codebook</span><span
5433class="cmtt-8">&#x00A0;number</span><span
5434class="cmtt-8">&#x00A0;[floor0</span><span
5435class="cmtt-8">_book</span><span
5436class="cmtt-8">_list]</span><span
5437class="cmtt-8">&#x00A0;element</span><span
5438class="cmtt-8">&#x00A0;[booknumber]</span><span
5439class="cmtt-8">&#x00A0;in</span><span
5440class="cmtt-8">&#x00A0;VQ</span><span
5441class="cmtt-8">&#x00A0;context.</span>
5442<br class="fancyvrb" /><a
5443 id="x1-94016r8"></a><span
5444class="cmr-6">8</span><span
5445class="cmtt-8">&#x00A0;</span><span
5446class="cmtt-8">&#x00A0;</span><span
5447class="cmtt-8">&#x00A0;</span><span
5448class="cmtt-8">&#x00A0;</span><span
5449class="cmtt-8">&#x00A0;</span><span
5450class="cmtt-8">&#x00A0;</span><span
5451class="cmtt-8">&#x00A0;8)</span><span
5452class="cmtt-8">&#x00A0;add</span><span
5453class="cmtt-8">&#x00A0;the</span><span
5454class="cmtt-8">&#x00A0;scalar</span><span
5455class="cmtt-8">&#x00A0;value</span><span
5456class="cmtt-8">&#x00A0;[last]</span><span
5457class="cmtt-8">&#x00A0;to</span><span
5458class="cmtt-8">&#x00A0;each</span><span
5459class="cmtt-8">&#x00A0;scalar</span><span
5460class="cmtt-8">&#x00A0;in</span><span
5461class="cmtt-8">&#x00A0;vector</span><span
5462class="cmtt-8">&#x00A0;[temp</span><span
5463class="cmtt-8">_vector]</span><br class="fancyvrb" /><a
5464 id="x1-94018r9"></a><span
5465class="cmr-6">9</span><span
5466class="cmtt-8">&#x00A0;</span><span
5467class="cmtt-8">&#x00A0;</span><span
5468class="cmtt-8">&#x00A0;</span><span
5469class="cmtt-8">&#x00A0;</span><span
5470class="cmtt-8">&#x00A0;</span><span
5471class="cmtt-8">&#x00A0;</span><span
5472class="cmtt-8">&#x00A0;9)</span><span
5473class="cmtt-8">&#x00A0;[last]</span><span
5474class="cmtt-8">&#x00A0;=</span><span
5475class="cmtt-8">&#x00A0;the</span><span
5476class="cmtt-8">&#x00A0;value</span><span
5477class="cmtt-8">&#x00A0;of</span><span
5478class="cmtt-8">&#x00A0;the</span><span
5479class="cmtt-8">&#x00A0;last</span><span
5480class="cmtt-8">&#x00A0;scalar</span><span
5481class="cmtt-8">&#x00A0;in</span><span
5482class="cmtt-8">&#x00A0;vector</span><span
5483class="cmtt-8">&#x00A0;[temp</span><span
5484class="cmtt-8">_vector]</span>
5485<br class="fancyvrb" /><a
5486 id="x1-94020r10"></a><span
5487class="cmr-6">10</span><span
5488class="cmtt-8">&#x00A0;</span><span
5489class="cmtt-8">&#x00A0;</span><span
5490class="cmtt-8">&#x00A0;</span><span
5491class="cmtt-8">&#x00A0;</span><span
5492class="cmtt-8">&#x00A0;</span><span
5493class="cmtt-8">&#x00A0;10)</span><span
5494class="cmtt-8">&#x00A0;concatenate</span><span
5495class="cmtt-8">&#x00A0;[temp</span><span
5496class="cmtt-8">_vector]</span><span
5497class="cmtt-8">&#x00A0;onto</span><span
5498class="cmtt-8">&#x00A0;the</span><span
5499class="cmtt-8">&#x00A0;end</span><span
5500class="cmtt-8">&#x00A0;of</span><span
5501class="cmtt-8">&#x00A0;the</span><span
5502class="cmtt-8">&#x00A0;[coefficients]</span><span
5503class="cmtt-8">&#x00A0;vector</span>
5504<br class="fancyvrb" /><a
5505 id="x1-94022r11"></a><span
5506class="cmr-6">11</span><span
5507class="cmtt-8">&#x00A0;</span><span
5508class="cmtt-8">&#x00A0;</span><span
5509class="cmtt-8">&#x00A0;</span><span
5510class="cmtt-8">&#x00A0;</span><span
5511class="cmtt-8">&#x00A0;</span><span
5512class="cmtt-8">&#x00A0;11)</span><span
5513class="cmtt-8">&#x00A0;if</span><span
5514class="cmtt-8">&#x00A0;(length</span><span
5515class="cmtt-8">&#x00A0;of</span><span
5516class="cmtt-8">&#x00A0;vector</span><span
5517class="cmtt-8">&#x00A0;[coefficients]</span><span
5518class="cmtt-8">&#x00A0;is</span><span
5519class="cmtt-8">&#x00A0;less</span><span
5520class="cmtt-8">&#x00A0;than</span><span
5521class="cmtt-8">&#x00A0;[floor0</span><span
5522class="cmtt-8">_order],</span><span
5523class="cmtt-8">&#x00A0;continue</span><span
5524class="cmtt-8">&#x00A0;at</span><span
5525class="cmtt-8">&#x00A0;step</span><span
5526class="cmtt-8">&#x00A0;6</span><br class="fancyvrb" /><a
5527 id="x1-94024r12"></a><span
5528class="cmr-6">12</span><br class="fancyvrb" /><a
5529 id="x1-94026r13"></a><span
5530class="cmr-6">13</span><span
5531class="cmtt-8">&#x00A0;</span><span
5532class="cmtt-8">&#x00A0;</span><span
5533class="cmtt-8">&#x00A0;</span><span
5534class="cmtt-8">&#x00A0;</span><span
5535class="cmtt-8">&#x00A0;</span><span
5536class="cmsy-8">}</span><br class="fancyvrb" /><a
5537 id="x1-94028r14"></a><span
5538class="cmr-6">14</span><br class="fancyvrb" /><a
5539 id="x1-94030r15"></a><span
5540class="cmr-6">15</span><span
5541class="cmtt-8">&#x00A0;12)</span><span
5542class="cmtt-8">&#x00A0;done.</span><br class="fancyvrb" /><a
5543 id="x1-94032r16"></a><span
5544class="cmr-6">16</span></div>
5545<!--l. 75--><p class="noindent" >Take note of the following properties of decode:
5546 <ul class="itemize1">
5547 <li class="itemize">An <span
5548class="cmtt-12">[amplitude] </span>value of zero must result in a return code that indicates this channel
5549 is unused in this frame (the output of the channel will be all-zeroes in synthesis).
5550 Several later stages of decode don&#8217;t occur for an unused channel.
5551 </li>
5552 <li class="itemize">An end-of-packet condition during decode should be considered a nominal occruence;
5553 if end-of-packet is reached during any read operation above, floor decode is to return
5554 &#8217;unused&#8217; status as if the <span
5555class="cmtt-12">[amplitude] </span>value had read zero at the beginning of decode.
5556 </li>
5557 <li class="itemize">The book number used for decode can, in fact, be stored in the bitstream in <a
5558href="#x1-1190009.2.1">ilog</a>(
5559 <span
5560class="cmtt-12">[floor0</span><span
5561class="cmtt-12">_number</span><span
5562class="cmtt-12">_of</span><span
5563class="cmtt-12">_books] </span>- 1 ) bits. Nevertheless, the above specification is correct
5564 and values greater than the maximum possible book value are reserved.
5565 </li>
5566 <li class="itemize">The number of scalars read into the vector <span
5567class="cmtt-12">[coefficients] </span>may be greater
5568 than <span
5569class="cmtt-12">[floor0</span><span
5570class="cmtt-12">_order]</span>, the number actually required for curve computation. For
5571 example, if the VQ codebook used for the floor currently being decoded has a
5572 <span
5573class="cmtt-12">[codebook</span><span
5574class="cmtt-12">_dimensions] </span>value of three and <span
5575class="cmtt-12">[floor0</span><span
5576class="cmtt-12">_order] </span>is ten, the only way to
5577 fill all the needed scalars in <span
5578class="cmtt-12">[coefficients] </span>is to to read a total of twelve scalars
5579 as four vectors of three scalars each. This is not an error condition, and care must
5580 be taken not to allow a buffer overflow in decode. The extra values are not used and
5581
5582
5583
5584 may be ignored or discarded.</li></ul>
5585<!--l. 103--><p class="noindent" >
5586<h5 class="subsubsectionHead"><span class="titlemark">6.2.3. </span> <a
5587 id="x1-950006.2.3"></a>curve computation</h5>
5588<!--l. 105--><p class="noindent" >Given an <span
5589class="cmtt-12">[amplitude] </span>integer and <span
5590class="cmtt-12">[coefficients] </span>vector from packet decode as well as
5591the [floor0_order], [floor0_rate], [floor0_bark_map_size], [floor0_amplitude_bits] and
5592[floor0_amplitude_offset] values from floor setup, and an output vector size <span
5593class="cmtt-12">[n] </span>specified by the
5594decode process, we compute a floor output vector.
5595<!--l. 112--><p class="noindent" >If the value <span
5596class="cmtt-12">[amplitude] </span>is zero, the return value is a length <span
5597class="cmtt-12">[n] </span>vector with all-zero
5598scalars. Otherwise, begin by assuming the following definitions for the given vector to be
5599synthesized:
5600<center class="par-math-display" >
5601<img
5602src="Vorbis_I_spec7x.png" alt=" {
5603 min (floor0xbarkxmapxsize - 1,f oobar) for i &#x2208; [0, n - 1]
5604mapi = - 1 for i = n
5605" class="par-math-display" ></center>
5606<!--l. 127--><p class="nopar" >
5607<!--l. 129--><p class="noindent" >where
5608<center class="par-math-display" >
5609<img
5610src="Vorbis_I_spec8x.png" alt=" &#x230A; ( floor0xrate &#x22C5; i) floor0xbarkxmapxsize &#x230B;
5611f oobar = bark ---------------- &#x22C5;------------------------
5612 2n bark(.5 &#x22C5; floor0xrate )
5613" class="par-math-display" ></center>
5614<!--l. 136--><p class="nopar" >
5615<!--l. 138--><p class="noindent" >and
5616<center class="par-math-display" >
5617<img
5618src="Vorbis_I_spec9x.png" alt="bark(x) = 13.1arctan (.00074x ) + 2.24 arctan(.0000000185x2 ) + .0001x
5619" class="par-math-display" ></center>
5620<!--l. 142--><p class="nopar" >
5621
5622
5623
5624<!--l. 144--><p class="noindent" >The above is used to synthesize the LSP curve on a Bark-scale frequency axis, then map the
5625result to a linear-scale frequency axis. Similarly, the below calculation synthesizes the output
5626LSP curve <span
5627class="cmtt-12">[output] </span>on a log (dB) amplitude scale, mapping it to linear amplitude in the last
5628step:
5629<!--l. 150--><p class="noindent" >
5630 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
5631 1. </dt><dd
5632class="enumerate-enumitem"><span
5633class="cmtt-12">[i] </span>= 0
5634 </dd><dt class="enumerate-enumitem">
5635 2. </dt><dd
5636class="enumerate-enumitem"><span
5637class="cmtt-12">[</span><span
5638class="cmmi-12">&#x03C9;</span><span
5639class="cmtt-12">] </span>= <span
5640class="cmmi-12">&#x03C0; </span>* map element <span
5641class="cmtt-12">[i] </span>/ <span
5642class="cmtt-12">[floor0</span><span
5643class="cmtt-12">_bark</span><span
5644class="cmtt-12">_map</span><span
5645class="cmtt-12">_size]</span>
5646 </dd><dt class="enumerate-enumitem">
5647 3. </dt><dd
5648class="enumerate-enumitem">if ( <span
5649class="cmtt-12">[floor0</span><span
5650class="cmtt-12">_order] </span>is odd )
5651 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
5652 a) </dt><dd
5653class="enumerate-enumitem">calculate <span
5654class="cmtt-12">[p] </span>and <span
5655class="cmtt-12">[q] </span>according to: <div class="eqnarray">
5656 <center class="math-display" >
5657 <img
5658src="Vorbis_I_spec10x.png" alt=" floor0&#x220F;x2order-3
5659p = (1 - cos2&#x03C9;) 4(cos([coefficients ]2j+1) - cos&#x03C9; )2
5660 j=0
5661 floor0xorder-1
5662 1 &#x220F;2 2
5663q = -- 4(cos([coefficients ]2j) - cos&#x03C9; )
5664 4 j=0
5665 " class="math-display" ></center>
5666 </div>
5667 </dd></dl>
5668 <!--l. 161--><p class="noindent" >else <span
5669class="cmtt-12">[floor0</span><span
5670class="cmtt-12">_order] </span>is even
5671 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
5672 a) </dt><dd
5673class="enumerate-enumitem">calculate <span
5674class="cmtt-12">[p] </span>and <span
5675class="cmtt-12">[q] </span>according to: <div class="eqnarray">
5676
5677
5678
5679 <center class="math-display" >
5680 <img
5681src="Vorbis_I_spec11x.png" alt=" floor0x&#x220F;o2rder-2
5682p = (1---cos&#x03C9;-) 4(cos([coefficients ]2j+1) - cos&#x03C9;)2
5683 2 j=0
5684 floor0xorder--2
5685 (1 + cos&#x03C9; ) &#x220F;2 2
5686q = ----------- 4(cos([coefficients ]2j) - cos &#x03C9;)
5687 2 j=0
5688 " class="math-display" ></center>
5689 </div>
5690 </dd></dl>
5691 </dd><dt class="enumerate-enumitem">
5692 4. </dt><dd
5693class="enumerate-enumitem">calculate <span
5694class="cmtt-12">[linear</span><span
5695class="cmtt-12">_floor</span><span
5696class="cmtt-12">_value] </span>according to:
5697 <center class="math-display" >
5698 <img
5699src="Vorbis_I_spec12x.png" alt=" ( ( ))
5700 amplitude &#x22C5; floor0xamplitutexoffset
5701exp .11512925 ------floor0xamplitudexbits-----&#x221A;----------- floor0xamplitudexoffset
5702 (2 - 1) p + q
5703 " class="math-display" ></center>
5704 <!--l. 176--><p class="nopar" >
5705 </dd><dt class="enumerate-enumitem">
5706 5. </dt><dd
5707class="enumerate-enumitem"><span
5708class="cmtt-12">[iteration</span><span
5709class="cmtt-12">_condition] </span>= map element <span
5710class="cmtt-12">[i]</span>
5711 </dd><dt class="enumerate-enumitem">
5712 6. </dt><dd
5713class="enumerate-enumitem"><span
5714class="cmtt-12">[output] </span>element <span
5715class="cmtt-12">[i] </span>= <span
5716class="cmtt-12">[linear</span><span
5717class="cmtt-12">_floor</span><span
5718class="cmtt-12">_value]</span>
5719 </dd><dt class="enumerate-enumitem">
5720 7. </dt><dd
5721class="enumerate-enumitem">increment <span
5722class="cmtt-12">[i]</span>
5723 </dd><dt class="enumerate-enumitem">
5724 8. </dt><dd
5725class="enumerate-enumitem">if ( map element <span
5726class="cmtt-12">[i] </span>is equal to <span
5727class="cmtt-12">[iteration</span><span
5728class="cmtt-12">_condition] </span>) continue at step
5729 5
5730 </dd><dt class="enumerate-enumitem">
5731 9. </dt><dd
5732class="enumerate-enumitem">if ( <span
5733class="cmtt-12">[i] </span>is less than <span
5734class="cmtt-12">[n] </span>) continue at step 2
5735
5736
5737
5738 </dd><dt class="enumerate-enumitem">
5739 10. </dt><dd
5740class="enumerate-enumitem">done</dd></dl>
5741<!--l. 186--><p class="noindent" ><span class="paragraphHead"><a
5742 id="x1-960006.2.3"></a><span
5743class="cmbx-12">Errata 20150227: Bark scale computation</span></span>
5744Due to a typo when typesetting this version of the specification from the original HTML
5745document, the Bark scale computation previously erroneously read:
5746<center class="par-math-display" >
5747<img
5748src="Vorbis_I_spec13x.png" alt="bark(x) = 13.1arctan (.00074x ) + 2.24 arctan(.0000000185x2 + .0001x )
5749" class="par-math-display" ></center>
5750<!--l. 194--><p class="nopar" >
5751<!--l. 196--><p class="noindent" >Note that the last parenthesis is misplaced. This document now uses the correct equation as it
5752appeared in the original HTML spec document:
5753<center class="par-math-display" >
5754<img
5755src="Vorbis_I_spec14x.png" alt="bark(x) = 13.1arctan (.00074x ) + 2.24 arctan(.0000000185x2 ) + .0001x
5756" class="par-math-display" ></center>
5757<!--l. 200--><p class="nopar" >
5758
5759
5760
5761
5762
5763
5764<h3 class="sectionHead"><span class="titlemark">7. </span> <a
5765 id="x1-970007"></a>Floor type 1 setup and decode</h3>
5766<!--l. 5--><p class="noindent" >
5767<h4 class="subsectionHead"><span class="titlemark">7.1. </span> <a
5768 id="x1-980007.1"></a>Overview</h4>
5769<!--l. 7--><p class="noindent" >Vorbis floor type one uses a piecewise straight-line representation to encode a spectral envelope
5770curve. The representation plots this curve mechanically on a linear frequency axis and a
5771logarithmic (dB) amplitude axis. The integer plotting algorithm used is similar to Bresenham&#8217;s
5772algorithm.
5773<!--l. 15--><p class="noindent" >
5774<h4 class="subsectionHead"><span class="titlemark">7.2. </span> <a
5775 id="x1-990007.2"></a>Floor 1 format</h4>
5776<!--l. 17--><p class="noindent" >
5777<h5 class="subsubsectionHead"><span class="titlemark">7.2.1. </span> <a
5778 id="x1-1000007.2.1"></a>model</h5>
5779<!--l. 19--><p class="noindent" >Floor type one represents a spectral curve as a series of line segments. Synthesis constructs a
5780floor curve using iterative prediction in a process roughly equivalent to the following simplified
5781description:
5782 <ul class="itemize1">
5783 <li class="itemize">the first line segment (base case) is a logical line spanning from x&#x02D9;0,y&#x02D9;0 to x&#x02D9;1,y&#x02D9;1
5784 where in the base case x&#x02D9;0=0 and x&#x02D9;1=[n], the full range of the spectral floor to be
5785 computed.
5786 </li>
5787 <li class="itemize">the induction step chooses a point x&#x02D9;new within an existing logical line segment and
5788 produces a y&#x02D9;new value at that point computed from the existing line&#8217;s y value at
5789 x&#x02D9;new (as plotted by the line) and a difference value decoded from the bitstream
5790 packet.
5791
5792
5793
5794 </li>
5795 <li class="itemize">floor computation produces two new line segments, one running from x&#x02D9;0,y&#x02D9;0 to
5796 x&#x02D9;new,y&#x02D9;new and from x&#x02D9;new,y&#x02D9;new to x&#x02D9;1,y&#x02D9;1. This step is performed logically even if
5797 y&#x02D9;new represents no change to the amplitude value at x&#x02D9;new so that later refinement
5798 is additionally bounded at x&#x02D9;new.
5799 </li>
5800 <li class="itemize">the induction step repeats, using a list of x values specified in the codec setup header
5801 at floor 1 initialization time. Computation is completed at the end of the x value list.
5802 </li></ul>
5803<!--l. 47--><p class="noindent" >Consider the following example, with values chosen for ease of understanding rather than
5804representing typical configuration:
5805<!--l. 50--><p class="noindent" >For the below example, we assume a floor setup with an [n] of 128. The list of selected X values
5806in increasing order is 0,16,32,48,64,80,96,112 and 128. In list order, the values interleave as 0,
5807128, 64, 32, 96, 16, 48, 80 and 112. The corresponding list-order Y values as decoded from an
5808example packet are 110, 20, -5, -45, 0, -25, -10, 30 and -10. We compute the floor in the following
5809way, beginning with the first line:
5810<div class="center"
5811>
5812<!--l. 58--><p class="noindent" >
5813
5814<!--l. 59--><p class="noindent" ><img
5815src="floor1-1.png" alt="PIC"
5816>
5817<br /> <div class="caption"
5818><span class="id">Figure&#x00A0;7: </span><span
5819class="content">graph of example floor</span></div><!--tex4ht:label?: x1-1000017 -->
5820</div>
5821<!--l. 63--><p class="noindent" >We now draw new logical lines to reflect the correction to new&#x02D9;Y, and iterate for X positions 32
5822and 96:
5823<div class="center"
5824>
5825<!--l. 66--><p class="noindent" >
5826
5827<!--l. 67--><p class="noindent" ><img
5828src="floor1-2.png" alt="PIC"
5829>
5830<br /> <div class="caption"
5831><span class="id">Figure&#x00A0;8: </span><span
5832class="content">graph of example floor</span></div><!--tex4ht:label?: x1-1000028 -->
5833</div>
5834<!--l. 71--><p class="noindent" >Although the new Y value at X position 96 is unchanged, it is still used later as an endpoint for
5835further refinement. From here on, the pattern should be clear; we complete the floor computation
5836as follows:
5837
5838
5839
5840<div class="center"
5841>
5842<!--l. 75--><p class="noindent" >
5843
5844<!--l. 76--><p class="noindent" ><img
5845src="floor1-3.png" alt="PIC"
5846>
5847<br /> <div class="caption"
5848><span class="id">Figure&#x00A0;9: </span><span
5849class="content">graph of example floor</span></div><!--tex4ht:label?: x1-1000039 -->
5850</div>
5851<div class="center"
5852>
5853<!--l. 80--><p class="noindent" >
5854
5855<!--l. 81--><p class="noindent" ><img
5856src="floor1-4.png" alt="PIC"
5857>
5858<br /> <div class="caption"
5859><span class="id">Figure&#x00A0;10: </span><span
5860class="content">graph of example floor</span></div><!--tex4ht:label?: x1-10000410 -->
5861</div>
5862<!--l. 85--><p class="noindent" >A more efficient algorithm with carefully defined integer rounding behavior is used for actual
5863decode, as described later. The actual algorithm splits Y value computation and line plotting
5864into two steps with modifications to the above algorithm to eliminate noise accumulation
5865through integer roundoff/truncation.
5866<!--l. 93--><p class="noindent" >
5867<h5 class="subsubsectionHead"><span class="titlemark">7.2.2. </span> <a
5868 id="x1-1010007.2.2"></a>header decode</h5>
5869<!--l. 95--><p class="noindent" >A list of floor X values is stored in the packet header in interleaved format (used in list order
5870during packet decode and synthesis). This list is split into partitions, and each partition is
5871assigned to a partition class. X positions 0 and [n] are implicit and do not belong to an explicit
5872partition or partition class.
5873<!--l. 101--><p class="noindent" >A partition class consists of a representation vector width (the number of Y values which
5874the partition class encodes at once), a &#8217;subclass&#8217; value representing the number of
5875alternate entropy books the partition class may use in representing Y values, the list of
5876[subclass] books and a master book used to encode which alternate books were chosen
5877for representation in a given packet. The master/subclass mechanism is meant to be
5878used as a flexible representation cascade while still using codebooks only in a scalar
5879context.
5880
5881
5882
5883<!--l. 111--><p class="noindent" >
5884<div class="fancyvrb" id="fancyvrb28"><a
5885 id="x1-101002r1"></a><span
5886class="cmr-6">1</span><br class="fancyvrb" /><a
5887 id="x1-101004r2"></a><span
5888class="cmr-6">2</span><span
5889class="cmtt-8">&#x00A0;</span><span
5890class="cmtt-8">&#x00A0;1)</span><span
5891class="cmtt-8">&#x00A0;[floor1</span><span
5892class="cmtt-8">_partitions]</span><span
5893class="cmtt-8">&#x00A0;=</span><span
5894class="cmtt-8">&#x00A0;read</span><span
5895class="cmtt-8">&#x00A0;5</span><span
5896class="cmtt-8">&#x00A0;bits</span><span
5897class="cmtt-8">&#x00A0;as</span><span
5898class="cmtt-8">&#x00A0;unsigned</span><span
5899class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
5900 id="x1-101006r3"></a><span
5901class="cmr-6">3</span><span
5902class="cmtt-8">&#x00A0;</span><span
5903class="cmtt-8">&#x00A0;2)</span><span
5904class="cmtt-8">&#x00A0;[maximum</span><span
5905class="cmtt-8">_class]</span><span
5906class="cmtt-8">&#x00A0;=</span><span
5907class="cmtt-8">&#x00A0;-1</span><br class="fancyvrb" /><a
5908 id="x1-101008r4"></a><span
5909class="cmr-6">4</span><span
5910class="cmtt-8">&#x00A0;</span><span
5911class="cmtt-8">&#x00A0;3)</span><span
5912class="cmtt-8">&#x00A0;iterate</span><span
5913class="cmtt-8">&#x00A0;[i]</span><span
5914class="cmtt-8">&#x00A0;over</span><span
5915class="cmtt-8">&#x00A0;the</span><span
5916class="cmtt-8">&#x00A0;range</span><span
5917class="cmtt-8">&#x00A0;0</span><span
5918class="cmtt-8">&#x00A0;...</span><span
5919class="cmtt-8">&#x00A0;[floor1</span><span
5920class="cmtt-8">_partitions]-1</span><span
5921class="cmtt-8">&#x00A0;</span><span
5922class="cmsy-8">{</span><br class="fancyvrb" /><a
5923 id="x1-101010r5"></a><span
5924class="cmr-6">5</span>
5925<br class="fancyvrb" /><a
5926 id="x1-101012r6"></a><span
5927class="cmr-6">6</span><span
5928class="cmtt-8">&#x00A0;</span><span
5929class="cmtt-8">&#x00A0;</span><span
5930class="cmtt-8">&#x00A0;</span><span
5931class="cmtt-8">&#x00A0;</span><span
5932class="cmtt-8">&#x00A0;</span><span
5933class="cmtt-8">&#x00A0;</span><span
5934class="cmtt-8">&#x00A0;</span><span
5935class="cmtt-8">&#x00A0;4)</span><span
5936class="cmtt-8">&#x00A0;vector</span><span
5937class="cmtt-8">&#x00A0;[floor1</span><span
5938class="cmtt-8">_partition</span><span
5939class="cmtt-8">_class</span><span
5940class="cmtt-8">_list]</span><span
5941class="cmtt-8">&#x00A0;element</span><span
5942class="cmtt-8">&#x00A0;[i]</span><span
5943class="cmtt-8">&#x00A0;=</span><span
5944class="cmtt-8">&#x00A0;read</span><span
5945class="cmtt-8">&#x00A0;4</span><span
5946class="cmtt-8">&#x00A0;bits</span><span
5947class="cmtt-8">&#x00A0;as</span><span
5948class="cmtt-8">&#x00A0;unsigned</span><span
5949class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
5950 id="x1-101014r7"></a><span
5951class="cmr-6">7</span><br class="fancyvrb" /><a
5952 id="x1-101016r8"></a><span
5953class="cmr-6">8</span><span
5954class="cmtt-8">&#x00A0;</span><span
5955class="cmtt-8">&#x00A0;</span><span
5956class="cmtt-8">&#x00A0;</span><span
5957class="cmtt-8">&#x00A0;</span><span
5958class="cmtt-8">&#x00A0;</span><span
5959class="cmsy-8">}</span><br class="fancyvrb" /><a
5960 id="x1-101018r9"></a><span
5961class="cmr-6">9</span>
5962<br class="fancyvrb" /><a
5963 id="x1-101020r10"></a><span
5964class="cmr-6">10</span><span
5965class="cmtt-8">&#x00A0;</span><span
5966class="cmtt-8">&#x00A0;5)</span><span
5967class="cmtt-8">&#x00A0;[maximum</span><span
5968class="cmtt-8">_class]</span><span
5969class="cmtt-8">&#x00A0;=</span><span
5970class="cmtt-8">&#x00A0;largest</span><span
5971class="cmtt-8">&#x00A0;integer</span><span
5972class="cmtt-8">&#x00A0;scalar</span><span
5973class="cmtt-8">&#x00A0;value</span><span
5974class="cmtt-8">&#x00A0;in</span><span
5975class="cmtt-8">&#x00A0;vector</span><span
5976class="cmtt-8">&#x00A0;[floor1</span><span
5977class="cmtt-8">_partition</span><span
5978class="cmtt-8">_class</span><span
5979class="cmtt-8">_list]</span><br class="fancyvrb" /><a
5980 id="x1-101022r11"></a><span
5981class="cmr-6">11</span><span
5982class="cmtt-8">&#x00A0;</span><span
5983class="cmtt-8">&#x00A0;6)</span><span
5984class="cmtt-8">&#x00A0;iterate</span><span
5985class="cmtt-8">&#x00A0;[i]</span><span
5986class="cmtt-8">&#x00A0;over</span><span
5987class="cmtt-8">&#x00A0;the</span><span
5988class="cmtt-8">&#x00A0;range</span><span
5989class="cmtt-8">&#x00A0;0</span><span
5990class="cmtt-8">&#x00A0;...</span><span
5991class="cmtt-8">&#x00A0;[maximum</span><span
5992class="cmtt-8">_class]</span><span
5993class="cmtt-8">&#x00A0;</span><span
5994class="cmsy-8">{</span><br class="fancyvrb" /><a
5995 id="x1-101024r12"></a><span
5996class="cmr-6">12</span>
5997<br class="fancyvrb" /><a
5998 id="x1-101026r13"></a><span
5999class="cmr-6">13</span><span
6000class="cmtt-8">&#x00A0;</span><span
6001class="cmtt-8">&#x00A0;</span><span
6002class="cmtt-8">&#x00A0;</span><span
6003class="cmtt-8">&#x00A0;</span><span
6004class="cmtt-8">&#x00A0;</span><span
6005class="cmtt-8">&#x00A0;</span><span
6006class="cmtt-8">&#x00A0;</span><span
6007class="cmtt-8">&#x00A0;7)</span><span
6008class="cmtt-8">&#x00A0;vector</span><span
6009class="cmtt-8">&#x00A0;[floor1</span><span
6010class="cmtt-8">_class</span><span
6011class="cmtt-8">_dimensions]</span><span
6012class="cmtt-8">&#x00A0;element</span><span
6013class="cmtt-8">&#x00A0;[i]</span><span
6014class="cmtt-8">&#x00A0;=</span><span
6015class="cmtt-8">&#x00A0;read</span><span
6016class="cmtt-8">&#x00A0;3</span><span
6017class="cmtt-8">&#x00A0;bits</span><span
6018class="cmtt-8">&#x00A0;as</span><span
6019class="cmtt-8">&#x00A0;unsigned</span><span
6020class="cmtt-8">&#x00A0;integer</span><span
6021class="cmtt-8">&#x00A0;and</span><span
6022class="cmtt-8">&#x00A0;add</span><span
6023class="cmtt-8">&#x00A0;1</span>
6024<br class="fancyvrb" /><a
6025 id="x1-101028r14"></a><span
6026class="cmr-6">14</span> <span
6027class="cmtt-8">8)</span><span
6028class="cmtt-8">&#x00A0;vector</span><span
6029class="cmtt-8">&#x00A0;[floor1</span><span
6030class="cmtt-8">_class</span><span
6031class="cmtt-8">_subclasses]</span><span
6032class="cmtt-8">&#x00A0;element</span><span
6033class="cmtt-8">&#x00A0;[i]</span><span
6034class="cmtt-8">&#x00A0;=</span><span
6035class="cmtt-8">&#x00A0;read</span><span
6036class="cmtt-8">&#x00A0;2</span><span
6037class="cmtt-8">&#x00A0;bits</span><span
6038class="cmtt-8">&#x00A0;as</span><span
6039class="cmtt-8">&#x00A0;unsigned</span><span
6040class="cmtt-8">&#x00A0;integer</span>
6041<br class="fancyvrb" /><a
6042 id="x1-101030r15"></a><span
6043class="cmr-6">15</span><span
6044class="cmtt-8">&#x00A0;</span><span
6045class="cmtt-8">&#x00A0;</span><span
6046class="cmtt-8">&#x00A0;</span><span
6047class="cmtt-8">&#x00A0;</span><span
6048class="cmtt-8">&#x00A0;</span><span
6049class="cmtt-8">&#x00A0;</span><span
6050class="cmtt-8">&#x00A0;</span><span
6051class="cmtt-8">&#x00A0;9)</span><span
6052class="cmtt-8">&#x00A0;if</span><span
6053class="cmtt-8">&#x00A0;(</span><span
6054class="cmtt-8">&#x00A0;vector</span><span
6055class="cmtt-8">&#x00A0;[floor1</span><span
6056class="cmtt-8">_class</span><span
6057class="cmtt-8">_subclasses]</span><span
6058class="cmtt-8">&#x00A0;element</span><span
6059class="cmtt-8">&#x00A0;[i]</span><span
6060class="cmtt-8">&#x00A0;is</span><span
6061class="cmtt-8">&#x00A0;nonzero</span><span
6062class="cmtt-8">&#x00A0;)</span><span
6063class="cmtt-8">&#x00A0;</span><span
6064class="cmsy-8">{</span><br class="fancyvrb" /><a
6065 id="x1-101032r16"></a><span
6066class="cmr-6">16</span>
6067<br class="fancyvrb" /><a
6068 id="x1-101034r17"></a><span
6069class="cmr-6">17</span><span
6070class="cmtt-8">&#x00A0;</span><span
6071class="cmtt-8">&#x00A0;</span><span
6072class="cmtt-8">&#x00A0;</span><span
6073class="cmtt-8">&#x00A0;</span><span
6074class="cmtt-8">&#x00A0;</span><span
6075class="cmtt-8">&#x00A0;</span><span
6076class="cmtt-8">&#x00A0;</span><span
6077class="cmtt-8">&#x00A0;</span><span
6078class="cmtt-8">&#x00A0;</span><span
6079class="cmtt-8">&#x00A0;</span><span
6080class="cmtt-8">&#x00A0;</span><span
6081class="cmtt-8">&#x00A0;</span><span
6082class="cmtt-8">&#x00A0;10)</span><span
6083class="cmtt-8">&#x00A0;vector</span><span
6084class="cmtt-8">&#x00A0;[floor1</span><span
6085class="cmtt-8">_class</span><span
6086class="cmtt-8">_masterbooks]</span><span
6087class="cmtt-8">&#x00A0;element</span><span
6088class="cmtt-8">&#x00A0;[i]</span><span
6089class="cmtt-8">&#x00A0;=</span><span
6090class="cmtt-8">&#x00A0;read</span><span
6091class="cmtt-8">&#x00A0;8</span><span
6092class="cmtt-8">&#x00A0;bits</span><span
6093class="cmtt-8">&#x00A0;as</span><span
6094class="cmtt-8">&#x00A0;unsigned</span><span
6095class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
6096 id="x1-101036r18"></a><span
6097class="cmr-6">18</span><br class="fancyvrb" /><a
6098 id="x1-101038r19"></a><span
6099class="cmr-6">19</span><span
6100class="cmtt-8">&#x00A0;</span><span
6101class="cmtt-8">&#x00A0;</span><span
6102class="cmtt-8">&#x00A0;</span><span
6103class="cmtt-8">&#x00A0;</span><span
6104class="cmtt-8">&#x00A0;</span><span
6105class="cmtt-8">&#x00A0;</span><span
6106class="cmtt-8">&#x00A0;</span><span
6107class="cmtt-8">&#x00A0;</span><span
6108class="cmtt-8">&#x00A0;</span><span
6109class="cmtt-8">&#x00A0;</span><span
6110class="cmtt-8">&#x00A0;</span><span
6111class="cmsy-8">}</span><br class="fancyvrb" /><a
6112 id="x1-101040r20"></a><span
6113class="cmr-6">20</span>
6114<br class="fancyvrb" /><a
6115 id="x1-101042r21"></a><span
6116class="cmr-6">21</span><span
6117class="cmtt-8">&#x00A0;</span><span
6118class="cmtt-8">&#x00A0;</span><span
6119class="cmtt-8">&#x00A0;</span><span
6120class="cmtt-8">&#x00A0;</span><span
6121class="cmtt-8">&#x00A0;</span><span
6122class="cmtt-8">&#x00A0;</span><span
6123class="cmtt-8">&#x00A0;11)</span><span
6124class="cmtt-8">&#x00A0;iterate</span><span
6125class="cmtt-8">&#x00A0;[j]</span><span
6126class="cmtt-8">&#x00A0;over</span><span
6127class="cmtt-8">&#x00A0;the</span><span
6128class="cmtt-8">&#x00A0;range</span><span
6129class="cmtt-8">&#x00A0;0</span><span
6130class="cmtt-8">&#x00A0;...</span><span
6131class="cmtt-8">&#x00A0;(2</span><span
6132class="cmtt-8">&#x00A0;exponent</span><span
6133class="cmtt-8">&#x00A0;[floor1</span><span
6134class="cmtt-8">_class</span><span
6135class="cmtt-8">_subclasses]</span><span
6136class="cmtt-8">&#x00A0;element</span><span
6137class="cmtt-8">&#x00A0;[i])</span><span
6138class="cmtt-8">&#x00A0;-</span><span
6139class="cmtt-8">&#x00A0;1</span><span
6140class="cmtt-8">&#x00A0;</span><span
6141class="cmsy-8">{</span><br class="fancyvrb" /><a
6142 id="x1-101044r22"></a><span
6143class="cmr-6">22</span>
6144<br class="fancyvrb" /><a
6145 id="x1-101046r23"></a><span
6146class="cmr-6">23</span><span
6147class="cmtt-8">&#x00A0;</span><span
6148class="cmtt-8">&#x00A0;</span><span
6149class="cmtt-8">&#x00A0;</span><span
6150class="cmtt-8">&#x00A0;</span><span
6151class="cmtt-8">&#x00A0;</span><span
6152class="cmtt-8">&#x00A0;</span><span
6153class="cmtt-8">&#x00A0;</span><span
6154class="cmtt-8">&#x00A0;</span><span
6155class="cmtt-8">&#x00A0;</span><span
6156class="cmtt-8">&#x00A0;</span><span
6157class="cmtt-8">&#x00A0;</span><span
6158class="cmtt-8">&#x00A0;</span><span
6159class="cmtt-8">&#x00A0;12)</span><span
6160class="cmtt-8">&#x00A0;array</span><span
6161class="cmtt-8">&#x00A0;[floor1</span><span
6162class="cmtt-8">_subclass</span><span
6163class="cmtt-8">_books]</span><span
6164class="cmtt-8">&#x00A0;element</span><span
6165class="cmtt-8">&#x00A0;[i],[j]</span><span
6166class="cmtt-8">&#x00A0;=</span><br class="fancyvrb" /><a
6167 id="x1-101048r24"></a><span
6168class="cmr-6">24</span><span
6169class="cmtt-8">&#x00A0;</span><span
6170class="cmtt-8">&#x00A0;</span><span
6171class="cmtt-8">&#x00A0;</span><span
6172class="cmtt-8">&#x00A0;</span><span
6173class="cmtt-8">&#x00A0;</span><span
6174class="cmtt-8">&#x00A0;</span><span
6175class="cmtt-8">&#x00A0;</span><span
6176class="cmtt-8">&#x00A0;</span><span
6177class="cmtt-8">&#x00A0;</span><span
6178class="cmtt-8">&#x00A0;</span><span
6179class="cmtt-8">&#x00A0;</span><span
6180class="cmtt-8">&#x00A0;</span><span
6181class="cmtt-8">&#x00A0;</span><span
6182class="cmtt-8">&#x00A0;</span><span
6183class="cmtt-8">&#x00A0;</span><span
6184class="cmtt-8">&#x00A0;</span><span
6185class="cmtt-8">&#x00A0;read</span><span
6186class="cmtt-8">&#x00A0;8</span><span
6187class="cmtt-8">&#x00A0;bits</span><span
6188class="cmtt-8">&#x00A0;as</span><span
6189class="cmtt-8">&#x00A0;unsigned</span><span
6190class="cmtt-8">&#x00A0;integer</span><span
6191class="cmtt-8">&#x00A0;and</span><span
6192class="cmtt-8">&#x00A0;subtract</span><span
6193class="cmtt-8">&#x00A0;one</span>
6194<br class="fancyvrb" /><a
6195 id="x1-101050r25"></a><span
6196class="cmr-6">25</span><span
6197class="cmtt-8">&#x00A0;</span><span
6198class="cmtt-8">&#x00A0;</span><span
6199class="cmtt-8">&#x00A0;</span><span
6200class="cmtt-8">&#x00A0;</span><span
6201class="cmtt-8">&#x00A0;</span><span
6202class="cmtt-8">&#x00A0;</span><span
6203class="cmtt-8">&#x00A0;</span><span
6204class="cmtt-8">&#x00A0;</span><span
6205class="cmtt-8">&#x00A0;</span><span
6206class="cmtt-8">&#x00A0;</span><span
6207class="cmtt-8">&#x00A0;</span><span
6208class="cmsy-8">}</span><br class="fancyvrb" /><a
6209 id="x1-101052r26"></a><span
6210class="cmr-6">26</span><span
6211class="cmtt-8">&#x00A0;</span><span
6212class="cmtt-8">&#x00A0;</span><span
6213class="cmtt-8">&#x00A0;</span><span
6214class="cmtt-8">&#x00A0;</span><span
6215class="cmtt-8">&#x00A0;</span><span
6216class="cmtt-8">&#x00A0;</span><span
6217class="cmsy-8">}</span><br class="fancyvrb" /><a
6218 id="x1-101054r27"></a><span
6219class="cmr-6">27</span><br class="fancyvrb" /><a
6220 id="x1-101056r28"></a><span
6221class="cmr-6">28</span><span
6222class="cmtt-8">&#x00A0;13)</span><span
6223class="cmtt-8">&#x00A0;[floor1</span><span
6224class="cmtt-8">_multiplier]</span><span
6225class="cmtt-8">&#x00A0;=</span><span
6226class="cmtt-8">&#x00A0;read</span><span
6227class="cmtt-8">&#x00A0;2</span><span
6228class="cmtt-8">&#x00A0;bits</span><span
6229class="cmtt-8">&#x00A0;as</span><span
6230class="cmtt-8">&#x00A0;unsigned</span><span
6231class="cmtt-8">&#x00A0;integer</span><span
6232class="cmtt-8">&#x00A0;and</span><span
6233class="cmtt-8">&#x00A0;add</span><span
6234class="cmtt-8">&#x00A0;one</span><br class="fancyvrb" /><a
6235 id="x1-101058r29"></a><span
6236class="cmr-6">29</span><span
6237class="cmtt-8">&#x00A0;14)</span><span
6238class="cmtt-8">&#x00A0;[rangebits]</span><span
6239class="cmtt-8">&#x00A0;=</span><span
6240class="cmtt-8">&#x00A0;read</span><span
6241class="cmtt-8">&#x00A0;4</span><span
6242class="cmtt-8">&#x00A0;bits</span><span
6243class="cmtt-8">&#x00A0;as</span><span
6244class="cmtt-8">&#x00A0;unsigned</span><span
6245class="cmtt-8">&#x00A0;integer</span>
6246<br class="fancyvrb" /><a
6247 id="x1-101060r30"></a><span
6248class="cmr-6">30</span><span
6249class="cmtt-8">&#x00A0;15)</span><span
6250class="cmtt-8">&#x00A0;vector</span><span
6251class="cmtt-8">&#x00A0;[floor1</span><span
6252class="cmtt-8">_X</span><span
6253class="cmtt-8">_list]</span><span
6254class="cmtt-8">&#x00A0;element</span><span
6255class="cmtt-8">&#x00A0;[0]</span><span
6256class="cmtt-8">&#x00A0;=</span><span
6257class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
6258 id="x1-101062r31"></a><span
6259class="cmr-6">31</span><span
6260class="cmtt-8">&#x00A0;16)</span><span
6261class="cmtt-8">&#x00A0;vector</span><span
6262class="cmtt-8">&#x00A0;[floor1</span><span
6263class="cmtt-8">_X</span><span
6264class="cmtt-8">_list]</span><span
6265class="cmtt-8">&#x00A0;element</span><span
6266class="cmtt-8">&#x00A0;[1]</span><span
6267class="cmtt-8">&#x00A0;=</span><span
6268class="cmtt-8">&#x00A0;2</span><span
6269class="cmtt-8">&#x00A0;exponent</span><span
6270class="cmtt-8">&#x00A0;[rangebits];</span><br class="fancyvrb" /><a
6271 id="x1-101064r32"></a><span
6272class="cmr-6">32</span><span
6273class="cmtt-8">&#x00A0;17)</span><span
6274class="cmtt-8">&#x00A0;[floor1</span><span
6275class="cmtt-8">_values]</span><span
6276class="cmtt-8">&#x00A0;=</span><span
6277class="cmtt-8">&#x00A0;2</span>
6278<br class="fancyvrb" /><a
6279 id="x1-101066r33"></a><span
6280class="cmr-6">33</span><span
6281class="cmtt-8">&#x00A0;18)</span><span
6282class="cmtt-8">&#x00A0;iterate</span><span
6283class="cmtt-8">&#x00A0;[i]</span><span
6284class="cmtt-8">&#x00A0;over</span><span
6285class="cmtt-8">&#x00A0;the</span><span
6286class="cmtt-8">&#x00A0;range</span><span
6287class="cmtt-8">&#x00A0;0</span><span
6288class="cmtt-8">&#x00A0;...</span><span
6289class="cmtt-8">&#x00A0;[floor1</span><span
6290class="cmtt-8">_partitions]-1</span><span
6291class="cmtt-8">&#x00A0;</span><span
6292class="cmsy-8">{</span><br class="fancyvrb" /><a
6293 id="x1-101068r34"></a><span
6294class="cmr-6">34</span><br class="fancyvrb" /><a
6295 id="x1-101070r35"></a><span
6296class="cmr-6">35</span><span
6297class="cmtt-8">&#x00A0;</span><span
6298class="cmtt-8">&#x00A0;</span><span
6299class="cmtt-8">&#x00A0;</span><span
6300class="cmtt-8">&#x00A0;</span><span
6301class="cmtt-8">&#x00A0;</span><span
6302class="cmtt-8">&#x00A0;</span><span
6303class="cmtt-8">&#x00A0;19)</span><span
6304class="cmtt-8">&#x00A0;[current</span><span
6305class="cmtt-8">_class</span><span
6306class="cmtt-8">_number]</span><span
6307class="cmtt-8">&#x00A0;=</span><span
6308class="cmtt-8">&#x00A0;vector</span><span
6309class="cmtt-8">&#x00A0;[floor1</span><span
6310class="cmtt-8">_partition</span><span
6311class="cmtt-8">_class</span><span
6312class="cmtt-8">_list]</span><span
6313class="cmtt-8">&#x00A0;element</span><span
6314class="cmtt-8">&#x00A0;[i]</span>
6315<br class="fancyvrb" /><a
6316 id="x1-101072r36"></a><span
6317class="cmr-6">36</span><span
6318class="cmtt-8">&#x00A0;</span><span
6319class="cmtt-8">&#x00A0;</span><span
6320class="cmtt-8">&#x00A0;</span><span
6321class="cmtt-8">&#x00A0;</span><span
6322class="cmtt-8">&#x00A0;</span><span
6323class="cmtt-8">&#x00A0;</span><span
6324class="cmtt-8">&#x00A0;20)</span><span
6325class="cmtt-8">&#x00A0;iterate</span><span
6326class="cmtt-8">&#x00A0;[j]</span><span
6327class="cmtt-8">&#x00A0;over</span><span
6328class="cmtt-8">&#x00A0;the</span><span
6329class="cmtt-8">&#x00A0;range</span><span
6330class="cmtt-8">&#x00A0;0</span><span
6331class="cmtt-8">&#x00A0;...</span><span
6332class="cmtt-8">&#x00A0;([floor1</span><span
6333class="cmtt-8">_class</span><span
6334class="cmtt-8">_dimensions]</span><span
6335class="cmtt-8">&#x00A0;element</span><span
6336class="cmtt-8">&#x00A0;[current</span><span
6337class="cmtt-8">_class</span><span
6338class="cmtt-8">_number])-1</span><span
6339class="cmtt-8">&#x00A0;</span><span
6340class="cmsy-8">{</span>
6341<br class="fancyvrb" /><a
6342 id="x1-101074r37"></a><span
6343class="cmr-6">37</span><span
6344class="cmtt-8">&#x00A0;</span><span
6345class="cmtt-8">&#x00A0;</span><span
6346class="cmtt-8">&#x00A0;</span><span
6347class="cmtt-8">&#x00A0;</span><span
6348class="cmtt-8">&#x00A0;</span><span
6349class="cmtt-8">&#x00A0;</span><span
6350class="cmtt-8">&#x00A0;</span><span
6351class="cmtt-8">&#x00A0;</span><span
6352class="cmtt-8">&#x00A0;</span><span
6353class="cmtt-8">&#x00A0;</span><span
6354class="cmtt-8">&#x00A0;</span><span
6355class="cmtt-8">&#x00A0;</span><span
6356class="cmtt-8">&#x00A0;21)</span><span
6357class="cmtt-8">&#x00A0;vector</span><span
6358class="cmtt-8">&#x00A0;[floor1</span><span
6359class="cmtt-8">_X</span><span
6360class="cmtt-8">_list]</span><span
6361class="cmtt-8">&#x00A0;element</span><span
6362class="cmtt-8">&#x00A0;([floor1</span><span
6363class="cmtt-8">_values])</span><span
6364class="cmtt-8">&#x00A0;=</span><br class="fancyvrb" /><a
6365 id="x1-101076r38"></a><span
6366class="cmr-6">38</span><span
6367class="cmtt-8">&#x00A0;</span><span
6368class="cmtt-8">&#x00A0;</span><span
6369class="cmtt-8">&#x00A0;</span><span
6370class="cmtt-8">&#x00A0;</span><span
6371class="cmtt-8">&#x00A0;</span><span
6372class="cmtt-8">&#x00A0;</span><span
6373class="cmtt-8">&#x00A0;</span><span
6374class="cmtt-8">&#x00A0;</span><span
6375class="cmtt-8">&#x00A0;</span><span
6376class="cmtt-8">&#x00A0;</span><span
6377class="cmtt-8">&#x00A0;</span><span
6378class="cmtt-8">&#x00A0;</span><span
6379class="cmtt-8">&#x00A0;</span><span
6380class="cmtt-8">&#x00A0;</span><span
6381class="cmtt-8">&#x00A0;</span><span
6382class="cmtt-8">&#x00A0;</span><span
6383class="cmtt-8">&#x00A0;read</span><span
6384class="cmtt-8">&#x00A0;[rangebits]</span><span
6385class="cmtt-8">&#x00A0;bits</span><span
6386class="cmtt-8">&#x00A0;as</span><span
6387class="cmtt-8">&#x00A0;unsigned</span><span
6388class="cmtt-8">&#x00A0;integer</span>
6389<br class="fancyvrb" /><a
6390 id="x1-101078r39"></a><span
6391class="cmr-6">39</span><span
6392class="cmtt-8">&#x00A0;</span><span
6393class="cmtt-8">&#x00A0;</span><span
6394class="cmtt-8">&#x00A0;</span><span
6395class="cmtt-8">&#x00A0;</span><span
6396class="cmtt-8">&#x00A0;</span><span
6397class="cmtt-8">&#x00A0;</span><span
6398class="cmtt-8">&#x00A0;</span><span
6399class="cmtt-8">&#x00A0;</span><span
6400class="cmtt-8">&#x00A0;</span><span
6401class="cmtt-8">&#x00A0;</span><span
6402class="cmtt-8">&#x00A0;</span><span
6403class="cmtt-8">&#x00A0;</span><span
6404class="cmtt-8">&#x00A0;22)</span><span
6405class="cmtt-8">&#x00A0;increment</span><span
6406class="cmtt-8">&#x00A0;[floor1</span><span
6407class="cmtt-8">_values]</span><span
6408class="cmtt-8">&#x00A0;by</span><span
6409class="cmtt-8">&#x00A0;one</span><br class="fancyvrb" /><a
6410 id="x1-101080r40"></a><span
6411class="cmr-6">40</span><span
6412class="cmtt-8">&#x00A0;</span><span
6413class="cmtt-8">&#x00A0;</span><span
6414class="cmtt-8">&#x00A0;</span><span
6415class="cmtt-8">&#x00A0;</span><span
6416class="cmtt-8">&#x00A0;</span><span
6417class="cmtt-8">&#x00A0;</span><span
6418class="cmtt-8">&#x00A0;</span><span
6419class="cmtt-8">&#x00A0;</span><span
6420class="cmtt-8">&#x00A0;</span><span
6421class="cmtt-8">&#x00A0;</span><span
6422class="cmtt-8">&#x00A0;</span><span
6423class="cmsy-8">}</span><br class="fancyvrb" /><a
6424 id="x1-101082r41"></a><span
6425class="cmr-6">41</span><span
6426class="cmtt-8">&#x00A0;</span><span
6427class="cmtt-8">&#x00A0;</span><span
6428class="cmtt-8">&#x00A0;</span><span
6429class="cmtt-8">&#x00A0;</span><span
6430class="cmtt-8">&#x00A0;</span><span
6431class="cmsy-8">}</span><br class="fancyvrb" /><a
6432 id="x1-101084r42"></a><span
6433class="cmr-6">42</span><br class="fancyvrb" /><a
6434 id="x1-101086r43"></a><span
6435class="cmr-6">43</span><span
6436class="cmtt-8">&#x00A0;23)</span><span
6437class="cmtt-8">&#x00A0;done</span></div>
6438<!--l. 157--><p class="noindent" >An end-of-packet condition while reading any aspect of a floor 1 configuration during
6439setup renders a stream undecodable. In addition, a <span
6440class="cmtt-12">[floor1</span><span
6441class="cmtt-12">_class</span><span
6442class="cmtt-12">_masterbooks] </span>or
6443<span
6444class="cmtt-12">[floor1</span><span
6445class="cmtt-12">_subclass</span><span
6446class="cmtt-12">_books] </span>scalar element greater than the highest numbered codebook
6447configured in this stream is an error condition that renders the stream undecodable. Vector
6448[floor1_x_list] is limited to a maximum length of 65 elements; a setup indicating more than 65
6449total elements (including elements 0 and 1 set prior to the read loop) renders the stream
6450undecodable. All vector [floor1_x_list] element values must be unique within the vector; a
6451non-unique value renders the stream undecodable.
6452<!--l. 169--><p class="noindent" >
6453<h5 class="subsubsectionHead"><span class="titlemark">7.2.3. </span> <a
6454 id="x1-1020007.2.3"></a>packet decode</h5>
6455<!--l. 171--><p class="noindent" >Packet decode begins by checking the <span
6456class="cmtt-12">[nonzero] </span>flag:
6457<!--l. 173--><p class="noindent" >
6458<div class="fancyvrb" id="fancyvrb29"><a
6459 id="x1-102002r1"></a><span
6460class="cmr-6">1</span><span
6461class="cmtt-8">&#x00A0;</span><span
6462class="cmtt-8">&#x00A0;1)</span><span
6463class="cmtt-8">&#x00A0;[nonzero]</span><span
6464class="cmtt-8">&#x00A0;=</span><span
6465class="cmtt-8">&#x00A0;read</span><span
6466class="cmtt-8">&#x00A0;1</span><span
6467class="cmtt-8">&#x00A0;bit</span><span
6468class="cmtt-8">&#x00A0;as</span><span
6469class="cmtt-8">&#x00A0;boolean</span></div>
6470<!--l. 177--><p class="noindent" >If <span
6471class="cmtt-12">[nonzero] </span>is unset, that indicates this channel contained no audio energy in this frame.
6472Decode immediately returns a status indicating this floor curve (and thus this channel) is unused
6473this frame. (A return status of &#8217;unused&#8217; is different from decoding a floor that has all
6474points set to minimum representation amplitude, which happens to be approximately
6475-140dB).
6476<!--l. 185--><p class="noindent" >Assuming <span
6477class="cmtt-12">[nonzero] </span>is set, decode proceeds as follows:
6478<!--l. 187--><p class="noindent" >
6479<div class="fancyvrb" id="fancyvrb30"><a
6480 id="x1-102004r1"></a><span
6481class="cmr-6">1</span><span
6482class="cmtt-8">&#x00A0;</span><span
6483class="cmtt-8">&#x00A0;1)</span><span
6484class="cmtt-8">&#x00A0;[range]</span><span
6485class="cmtt-8">&#x00A0;=</span><span
6486class="cmtt-8">&#x00A0;vector</span><span
6487class="cmtt-8">&#x00A0;</span><span
6488class="cmsy-8">{</span><span
6489class="cmtt-8">&#x00A0;256,</span><span
6490class="cmtt-8">&#x00A0;128,</span><span
6491class="cmtt-8">&#x00A0;86,</span><span
6492class="cmtt-8">&#x00A0;64</span><span
6493class="cmtt-8">&#x00A0;</span><span
6494class="cmsy-8">}</span><span
6495class="cmtt-8">&#x00A0;element</span><span
6496class="cmtt-8">&#x00A0;([floor1</span><span
6497class="cmtt-8">_multiplier]-1)</span>
6498<br class="fancyvrb" /><a
6499 id="x1-102006r2"></a><span
6500class="cmr-6">2</span><span
6501class="cmtt-8">&#x00A0;</span><span
6502class="cmtt-8">&#x00A0;2)</span><span
6503class="cmtt-8">&#x00A0;vector</span><span
6504class="cmtt-8">&#x00A0;[floor1</span><span
6505class="cmtt-8">_Y]</span><span
6506class="cmtt-8">&#x00A0;element</span><span
6507class="cmtt-8">&#x00A0;[0]</span><span
6508class="cmtt-8">&#x00A0;=</span><span
6509class="cmtt-8">&#x00A0;read</span><span
6510class="cmtt-8">&#x00A0;</span><a
6511href="#x1-1190009.2.1"><span
6512class="cmtt-8">ilog</span></a><span
6513class="cmtt-8">([range]-1)</span><span
6514class="cmtt-8">&#x00A0;bits</span><span
6515class="cmtt-8">&#x00A0;as</span><span
6516class="cmtt-8">&#x00A0;unsigned</span><span
6517class="cmtt-8">&#x00A0;integer</span>
6518
6519
6520
6521<br class="fancyvrb" /><a
6522 id="x1-102008r3"></a><span
6523class="cmr-6">3</span><span
6524class="cmtt-8">&#x00A0;</span><span
6525class="cmtt-8">&#x00A0;3)</span><span
6526class="cmtt-8">&#x00A0;vector</span><span
6527class="cmtt-8">&#x00A0;[floor1</span><span
6528class="cmtt-8">_Y]</span><span
6529class="cmtt-8">&#x00A0;element</span><span
6530class="cmtt-8">&#x00A0;[1]</span><span
6531class="cmtt-8">&#x00A0;=</span><span
6532class="cmtt-8">&#x00A0;read</span><span
6533class="cmtt-8">&#x00A0;</span><a
6534href="#x1-1190009.2.1"><span
6535class="cmtt-8">ilog</span></a><span
6536class="cmtt-8">([range]-1)</span><span
6537class="cmtt-8">&#x00A0;bits</span><span
6538class="cmtt-8">&#x00A0;as</span><span
6539class="cmtt-8">&#x00A0;unsigned</span><span
6540class="cmtt-8">&#x00A0;integer</span>
6541<br class="fancyvrb" /><a
6542 id="x1-102010r4"></a><span
6543class="cmr-6">4</span><span
6544class="cmtt-8">&#x00A0;</span><span
6545class="cmtt-8">&#x00A0;4)</span><span
6546class="cmtt-8">&#x00A0;[offset]</span><span
6547class="cmtt-8">&#x00A0;=</span><span
6548class="cmtt-8">&#x00A0;2;</span><br class="fancyvrb" /><a
6549 id="x1-102012r5"></a><span
6550class="cmr-6">5</span><span
6551class="cmtt-8">&#x00A0;</span><span
6552class="cmtt-8">&#x00A0;5)</span><span
6553class="cmtt-8">&#x00A0;iterate</span><span
6554class="cmtt-8">&#x00A0;[i]</span><span
6555class="cmtt-8">&#x00A0;over</span><span
6556class="cmtt-8">&#x00A0;the</span><span
6557class="cmtt-8">&#x00A0;range</span><span
6558class="cmtt-8">&#x00A0;0</span><span
6559class="cmtt-8">&#x00A0;...</span><span
6560class="cmtt-8">&#x00A0;[floor1</span><span
6561class="cmtt-8">_partitions]-1</span><span
6562class="cmtt-8">&#x00A0;</span><span
6563class="cmsy-8">{</span><br class="fancyvrb" /><a
6564 id="x1-102014r6"></a><span
6565class="cmr-6">6</span>
6566<br class="fancyvrb" /><a
6567 id="x1-102016r7"></a><span
6568class="cmr-6">7</span><span
6569class="cmtt-8">&#x00A0;</span><span
6570class="cmtt-8">&#x00A0;</span><span
6571class="cmtt-8">&#x00A0;</span><span
6572class="cmtt-8">&#x00A0;</span><span
6573class="cmtt-8">&#x00A0;</span><span
6574class="cmtt-8">&#x00A0;</span><span
6575class="cmtt-8">&#x00A0;6)</span><span
6576class="cmtt-8">&#x00A0;[class]</span><span
6577class="cmtt-8">&#x00A0;=</span><span
6578class="cmtt-8">&#x00A0;vector</span><span
6579class="cmtt-8">&#x00A0;[floor1</span><span
6580class="cmtt-8">_partition</span><span
6581class="cmtt-8">_class]</span><span
6582class="cmtt-8">&#x00A0;</span><span
6583class="cmtt-8">&#x00A0;element</span><span
6584class="cmtt-8">&#x00A0;[i]</span><br class="fancyvrb" /><a
6585 id="x1-102018r8"></a><span
6586class="cmr-6">8</span><span
6587class="cmtt-8">&#x00A0;</span><span
6588class="cmtt-8">&#x00A0;</span><span
6589class="cmtt-8">&#x00A0;</span><span
6590class="cmtt-8">&#x00A0;</span><span
6591class="cmtt-8">&#x00A0;</span><span
6592class="cmtt-8">&#x00A0;</span><span
6593class="cmtt-8">&#x00A0;7)</span><span
6594class="cmtt-8">&#x00A0;[cdim]</span><span
6595class="cmtt-8">&#x00A0;</span><span
6596class="cmtt-8">&#x00A0;=</span><span
6597class="cmtt-8">&#x00A0;vector</span><span
6598class="cmtt-8">&#x00A0;[floor1</span><span
6599class="cmtt-8">_class</span><span
6600class="cmtt-8">_dimensions]</span><span
6601class="cmtt-8">&#x00A0;element</span><span
6602class="cmtt-8">&#x00A0;[class]</span>
6603<br class="fancyvrb" /><a
6604 id="x1-102020r9"></a><span
6605class="cmr-6">9</span><span
6606class="cmtt-8">&#x00A0;</span><span
6607class="cmtt-8">&#x00A0;</span><span
6608class="cmtt-8">&#x00A0;</span><span
6609class="cmtt-8">&#x00A0;</span><span
6610class="cmtt-8">&#x00A0;</span><span
6611class="cmtt-8">&#x00A0;</span><span
6612class="cmtt-8">&#x00A0;8)</span><span
6613class="cmtt-8">&#x00A0;[cbits]</span><span
6614class="cmtt-8">&#x00A0;=</span><span
6615class="cmtt-8">&#x00A0;vector</span><span
6616class="cmtt-8">&#x00A0;[floor1</span><span
6617class="cmtt-8">_class</span><span
6618class="cmtt-8">_subclasses]</span><span
6619class="cmtt-8">&#x00A0;element</span><span
6620class="cmtt-8">&#x00A0;[class]</span><br class="fancyvrb" /><a
6621 id="x1-102022r10"></a><span
6622class="cmr-6">10</span><span
6623class="cmtt-8">&#x00A0;</span><span
6624class="cmtt-8">&#x00A0;</span><span
6625class="cmtt-8">&#x00A0;</span><span
6626class="cmtt-8">&#x00A0;</span><span
6627class="cmtt-8">&#x00A0;</span><span
6628class="cmtt-8">&#x00A0;</span><span
6629class="cmtt-8">&#x00A0;9)</span><span
6630class="cmtt-8">&#x00A0;[csub]</span><span
6631class="cmtt-8">&#x00A0;</span><span
6632class="cmtt-8">&#x00A0;=</span><span
6633class="cmtt-8">&#x00A0;(2</span><span
6634class="cmtt-8">&#x00A0;exponent</span><span
6635class="cmtt-8">&#x00A0;[cbits])-1</span><br class="fancyvrb" /><a
6636 id="x1-102024r11"></a><span
6637class="cmr-6">11</span><span
6638class="cmtt-8">&#x00A0;</span><span
6639class="cmtt-8">&#x00A0;</span><span
6640class="cmtt-8">&#x00A0;</span><span
6641class="cmtt-8">&#x00A0;</span><span
6642class="cmtt-8">&#x00A0;</span><span
6643class="cmtt-8">&#x00A0;10)</span><span
6644class="cmtt-8">&#x00A0;[cval]</span><span
6645class="cmtt-8">&#x00A0;</span><span
6646class="cmtt-8">&#x00A0;=</span><span
6647class="cmtt-8">&#x00A0;0</span>
6648<br class="fancyvrb" /><a
6649 id="x1-102026r12"></a><span
6650class="cmr-6">12</span><span
6651class="cmtt-8">&#x00A0;</span><span
6652class="cmtt-8">&#x00A0;</span><span
6653class="cmtt-8">&#x00A0;</span><span
6654class="cmtt-8">&#x00A0;</span><span
6655class="cmtt-8">&#x00A0;</span><span
6656class="cmtt-8">&#x00A0;11)</span><span
6657class="cmtt-8">&#x00A0;if</span><span
6658class="cmtt-8">&#x00A0;(</span><span
6659class="cmtt-8">&#x00A0;[cbits]</span><span
6660class="cmtt-8">&#x00A0;is</span><span
6661class="cmtt-8">&#x00A0;greater</span><span
6662class="cmtt-8">&#x00A0;than</span><span
6663class="cmtt-8">&#x00A0;zero</span><span
6664class="cmtt-8">&#x00A0;)</span><span
6665class="cmtt-8">&#x00A0;</span><span
6666class="cmsy-8">{</span><br class="fancyvrb" /><a
6667 id="x1-102028r13"></a><span
6668class="cmr-6">13</span><br class="fancyvrb" /><a
6669 id="x1-102030r14"></a><span
6670class="cmr-6">14</span><span
6671class="cmtt-8">&#x00A0;</span><span
6672class="cmtt-8">&#x00A0;</span><span
6673class="cmtt-8">&#x00A0;</span><span
6674class="cmtt-8">&#x00A0;</span><span
6675class="cmtt-8">&#x00A0;</span><span
6676class="cmtt-8">&#x00A0;</span><span
6677class="cmtt-8">&#x00A0;</span><span
6678class="cmtt-8">&#x00A0;</span><span
6679class="cmtt-8">&#x00A0;</span><span
6680class="cmtt-8">&#x00A0;</span><span
6681class="cmtt-8">&#x00A0;</span><span
6682class="cmtt-8">&#x00A0;</span><span
6683class="cmtt-8">&#x00A0;12)</span><span
6684class="cmtt-8">&#x00A0;[cval]</span><span
6685class="cmtt-8">&#x00A0;=</span><span
6686class="cmtt-8">&#x00A0;read</span><span
6687class="cmtt-8">&#x00A0;from</span><span
6688class="cmtt-8">&#x00A0;packet</span><span
6689class="cmtt-8">&#x00A0;using</span><span
6690class="cmtt-8">&#x00A0;codebook</span><span
6691class="cmtt-8">&#x00A0;number</span>
6692<br class="fancyvrb" /><a
6693 id="x1-102032r15"></a><span
6694class="cmr-6">15</span><span
6695class="cmtt-8">&#x00A0;</span><span
6696class="cmtt-8">&#x00A0;</span><span
6697class="cmtt-8">&#x00A0;</span><span
6698class="cmtt-8">&#x00A0;</span><span
6699class="cmtt-8">&#x00A0;</span><span
6700class="cmtt-8">&#x00A0;</span><span
6701class="cmtt-8">&#x00A0;</span><span
6702class="cmtt-8">&#x00A0;</span><span
6703class="cmtt-8">&#x00A0;</span><span
6704class="cmtt-8">&#x00A0;</span><span
6705class="cmtt-8">&#x00A0;</span><span
6706class="cmtt-8">&#x00A0;</span><span
6707class="cmtt-8">&#x00A0;</span><span
6708class="cmtt-8">&#x00A0;</span><span
6709class="cmtt-8">&#x00A0;</span><span
6710class="cmtt-8">&#x00A0;</span><span
6711class="cmtt-8">&#x00A0;(vector</span><span
6712class="cmtt-8">&#x00A0;[floor1</span><span
6713class="cmtt-8">_class</span><span
6714class="cmtt-8">_masterbooks]</span><span
6715class="cmtt-8">&#x00A0;element</span><span
6716class="cmtt-8">&#x00A0;[class])</span><span
6717class="cmtt-8">&#x00A0;in</span><span
6718class="cmtt-8">&#x00A0;scalar</span><span
6719class="cmtt-8">&#x00A0;context</span><br class="fancyvrb" /><a
6720 id="x1-102034r16"></a><span
6721class="cmr-6">16</span><span
6722class="cmtt-8">&#x00A0;</span><span
6723class="cmtt-8">&#x00A0;</span><span
6724class="cmtt-8">&#x00A0;</span><span
6725class="cmtt-8">&#x00A0;</span><span
6726class="cmtt-8">&#x00A0;</span><span
6727class="cmtt-8">&#x00A0;</span><span
6728class="cmtt-8">&#x00A0;</span><span
6729class="cmtt-8">&#x00A0;</span><span
6730class="cmtt-8">&#x00A0;</span><span
6731class="cmtt-8">&#x00A0;</span><span
6732class="cmsy-8">}</span><br class="fancyvrb" /><a
6733 id="x1-102036r17"></a><span
6734class="cmr-6">17</span><br class="fancyvrb" /><a
6735 id="x1-102038r18"></a><span
6736class="cmr-6">18</span><span
6737class="cmtt-8">&#x00A0;</span><span
6738class="cmtt-8">&#x00A0;</span><span
6739class="cmtt-8">&#x00A0;</span><span
6740class="cmtt-8">&#x00A0;</span><span
6741class="cmtt-8">&#x00A0;</span><span
6742class="cmtt-8">&#x00A0;13)</span><span
6743class="cmtt-8">&#x00A0;iterate</span><span
6744class="cmtt-8">&#x00A0;[j]</span><span
6745class="cmtt-8">&#x00A0;over</span><span
6746class="cmtt-8">&#x00A0;the</span><span
6747class="cmtt-8">&#x00A0;range</span><span
6748class="cmtt-8">&#x00A0;0</span><span
6749class="cmtt-8">&#x00A0;...</span><span
6750class="cmtt-8">&#x00A0;[cdim]-1</span><span
6751class="cmtt-8">&#x00A0;</span><span
6752class="cmsy-8">{</span><br class="fancyvrb" /><a
6753 id="x1-102040r19"></a><span
6754class="cmr-6">19</span>
6755<br class="fancyvrb" /><a
6756 id="x1-102042r20"></a><span
6757class="cmr-6">20</span><span
6758class="cmtt-8">&#x00A0;</span><span
6759class="cmtt-8">&#x00A0;</span><span
6760class="cmtt-8">&#x00A0;</span><span
6761class="cmtt-8">&#x00A0;</span><span
6762class="cmtt-8">&#x00A0;</span><span
6763class="cmtt-8">&#x00A0;</span><span
6764class="cmtt-8">&#x00A0;</span><span
6765class="cmtt-8">&#x00A0;</span><span
6766class="cmtt-8">&#x00A0;</span><span
6767class="cmtt-8">&#x00A0;</span><span
6768class="cmtt-8">&#x00A0;</span><span
6769class="cmtt-8">&#x00A0;</span><span
6770class="cmtt-8">&#x00A0;14)</span><span
6771class="cmtt-8">&#x00A0;[book]</span><span
6772class="cmtt-8">&#x00A0;=</span><span
6773class="cmtt-8">&#x00A0;array</span><span
6774class="cmtt-8">&#x00A0;[floor1</span><span
6775class="cmtt-8">_subclass</span><span
6776class="cmtt-8">_books]</span><span
6777class="cmtt-8">&#x00A0;element</span><span
6778class="cmtt-8">&#x00A0;[class],([cval]</span><span
6779class="cmtt-8">&#x00A0;bitwise</span><span
6780class="cmtt-8">&#x00A0;AND</span><span
6781class="cmtt-8">&#x00A0;[csub])</span>
6782<br class="fancyvrb" /><a
6783 id="x1-102044r21"></a><span
6784class="cmr-6">21</span><span
6785class="cmtt-8">&#x00A0;</span><span
6786class="cmtt-8">&#x00A0;</span><span
6787class="cmtt-8">&#x00A0;</span><span
6788class="cmtt-8">&#x00A0;</span><span
6789class="cmtt-8">&#x00A0;</span><span
6790class="cmtt-8">&#x00A0;</span><span
6791class="cmtt-8">&#x00A0;</span><span
6792class="cmtt-8">&#x00A0;</span><span
6793class="cmtt-8">&#x00A0;</span><span
6794class="cmtt-8">&#x00A0;</span><span
6795class="cmtt-8">&#x00A0;</span><span
6796class="cmtt-8">&#x00A0;</span><span
6797class="cmtt-8">&#x00A0;15)</span><span
6798class="cmtt-8">&#x00A0;[cval]</span><span
6799class="cmtt-8">&#x00A0;=</span><span
6800class="cmtt-8">&#x00A0;[cval]</span><span
6801class="cmtt-8">&#x00A0;right</span><span
6802class="cmtt-8">&#x00A0;shifted</span><span
6803class="cmtt-8">&#x00A0;[cbits]</span><span
6804class="cmtt-8">&#x00A0;bits</span><br class="fancyvrb" /><a
6805 id="x1-102046r22"></a><span
6806class="cmr-6">22</span> <span
6807class="cmtt-8">&#x00A0;</span><span
6808class="cmtt-8">&#x00A0;</span><span
6809class="cmtt-8">&#x00A0;</span><span
6810class="cmtt-8">&#x00A0;</span><span
6811class="cmtt-8">&#x00A0;16)</span><span
6812class="cmtt-8">&#x00A0;if</span><span
6813class="cmtt-8">&#x00A0;(</span><span
6814class="cmtt-8">&#x00A0;[book]</span><span
6815class="cmtt-8">&#x00A0;is</span><span
6816class="cmtt-8">&#x00A0;not</span><span
6817class="cmtt-8">&#x00A0;less</span><span
6818class="cmtt-8">&#x00A0;than</span><span
6819class="cmtt-8">&#x00A0;zero</span><span
6820class="cmtt-8">&#x00A0;)</span><span
6821class="cmtt-8">&#x00A0;</span><span
6822class="cmsy-8">{</span><br class="fancyvrb" /><a
6823 id="x1-102048r23"></a><span
6824class="cmr-6">23</span>
6825<br class="fancyvrb" /><a
6826 id="x1-102050r24"></a><span
6827class="cmr-6">24</span> <span
6828class="cmtt-8">&#x00A0;</span><span
6829class="cmtt-8">&#x00A0;</span><span
6830class="cmtt-8">&#x00A0;</span><span
6831class="cmtt-8">&#x00A0;</span><span
6832class="cmtt-8">&#x00A0;</span><span
6833class="cmtt-8">&#x00A0;</span><span
6834class="cmtt-8">&#x00A0;</span><span
6835class="cmtt-8">&#x00A0;</span><span
6836class="cmtt-8">&#x00A0;</span><span
6837class="cmtt-8">&#x00A0;</span><span
6838class="cmtt-8">&#x00A0;17)</span><span
6839class="cmtt-8">&#x00A0;vector</span><span
6840class="cmtt-8">&#x00A0;[floor1</span><span
6841class="cmtt-8">_Y]</span><span
6842class="cmtt-8">&#x00A0;element</span><span
6843class="cmtt-8">&#x00A0;([j]+[offset])</span><span
6844class="cmtt-8">&#x00A0;=</span><span
6845class="cmtt-8">&#x00A0;read</span><span
6846class="cmtt-8">&#x00A0;from</span><span
6847class="cmtt-8">&#x00A0;packet</span><span
6848class="cmtt-8">&#x00A0;using</span><span
6849class="cmtt-8">&#x00A0;codebook</span><br class="fancyvrb" /><a
6850 id="x1-102052r25"></a><span
6851class="cmr-6">25</span><span
6852class="cmtt-8">&#x00A0;</span><span
6853class="cmtt-8">&#x00A0;</span><span
6854class="cmtt-8">&#x00A0;</span><span
6855class="cmtt-8">&#x00A0;</span><span
6856class="cmtt-8">&#x00A0;</span><span
6857class="cmtt-8">&#x00A0;</span><span
6858class="cmtt-8">&#x00A0;</span><span
6859class="cmtt-8">&#x00A0;</span><span
6860class="cmtt-8">&#x00A0;</span><span
6861class="cmtt-8">&#x00A0;</span><span
6862class="cmtt-8">&#x00A0;</span><span
6863class="cmtt-8">&#x00A0;</span><span
6864class="cmtt-8">&#x00A0;</span><span
6865class="cmtt-8">&#x00A0;</span><span
6866class="cmtt-8">&#x00A0;</span><span
6867class="cmtt-8">&#x00A0;</span><span
6868class="cmtt-8">&#x00A0;</span><span
6869class="cmtt-8">&#x00A0;</span><span
6870class="cmtt-8">&#x00A0;</span><span
6871class="cmtt-8">&#x00A0;</span><span
6872class="cmtt-8">&#x00A0;</span><span
6873class="cmtt-8">&#x00A0;</span><span
6874class="cmtt-8">&#x00A0;[book]</span><span
6875class="cmtt-8">&#x00A0;in</span><span
6876class="cmtt-8">&#x00A0;scalar</span><span
6877class="cmtt-8">&#x00A0;context</span><br class="fancyvrb" /><a
6878 id="x1-102054r26"></a><span
6879class="cmr-6">26</span>
6880<br class="fancyvrb" /><a
6881 id="x1-102056r27"></a><span
6882class="cmr-6">27</span><span
6883class="cmtt-8">&#x00A0;</span><span
6884class="cmtt-8">&#x00A0;</span><span
6885class="cmtt-8">&#x00A0;</span><span
6886class="cmtt-8">&#x00A0;</span><span
6887class="cmtt-8">&#x00A0;</span><span
6888class="cmtt-8">&#x00A0;</span><span
6889class="cmtt-8">&#x00A0;</span><span
6890class="cmtt-8">&#x00A0;</span><span
6891class="cmtt-8">&#x00A0;</span><span
6892class="cmtt-8">&#x00A0;</span><span
6893class="cmtt-8">&#x00A0;</span><span
6894class="cmtt-8">&#x00A0;</span><span
6895class="cmtt-8">&#x00A0;</span><span
6896class="cmtt-8">&#x00A0;</span><span
6897class="cmtt-8">&#x00A0;</span><span
6898class="cmtt-8">&#x00A0;</span><span
6899class="cmtt-8">&#x00A0;</span><span
6900class="cmsy-8">}</span><span
6901class="cmtt-8">&#x00A0;else</span><span
6902class="cmtt-8">&#x00A0;[book]</span><span
6903class="cmtt-8">&#x00A0;is</span><span
6904class="cmtt-8">&#x00A0;less</span><span
6905class="cmtt-8">&#x00A0;than</span><span
6906class="cmtt-8">&#x00A0;zero</span><span
6907class="cmtt-8">&#x00A0;</span><span
6908class="cmsy-8">{</span><br class="fancyvrb" /><a
6909 id="x1-102058r28"></a><span
6910class="cmr-6">28</span><br class="fancyvrb" /><a
6911 id="x1-102060r29"></a><span
6912class="cmr-6">29</span> <span
6913class="cmtt-8">&#x00A0;</span><span
6914class="cmtt-8">&#x00A0;</span><span
6915class="cmtt-8">&#x00A0;</span><span
6916class="cmtt-8">&#x00A0;</span><span
6917class="cmtt-8">&#x00A0;</span><span
6918class="cmtt-8">&#x00A0;</span><span
6919class="cmtt-8">&#x00A0;</span><span
6920class="cmtt-8">&#x00A0;</span><span
6921class="cmtt-8">&#x00A0;</span><span
6922class="cmtt-8">&#x00A0;</span><span
6923class="cmtt-8">&#x00A0;18)</span><span
6924class="cmtt-8">&#x00A0;vector</span><span
6925class="cmtt-8">&#x00A0;[floor1</span><span
6926class="cmtt-8">_Y]</span><span
6927class="cmtt-8">&#x00A0;element</span><span
6928class="cmtt-8">&#x00A0;([j]+[offset])</span><span
6929class="cmtt-8">&#x00A0;=</span><span
6930class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
6931 id="x1-102062r30"></a><span
6932class="cmr-6">30</span>
6933<br class="fancyvrb" /><a
6934 id="x1-102064r31"></a><span
6935class="cmr-6">31</span><span
6936class="cmtt-8">&#x00A0;</span><span
6937class="cmtt-8">&#x00A0;</span><span
6938class="cmtt-8">&#x00A0;</span><span
6939class="cmtt-8">&#x00A0;</span><span
6940class="cmtt-8">&#x00A0;</span><span
6941class="cmtt-8">&#x00A0;</span><span
6942class="cmtt-8">&#x00A0;</span><span
6943class="cmtt-8">&#x00A0;</span><span
6944class="cmtt-8">&#x00A0;</span><span
6945class="cmtt-8">&#x00A0;</span><span
6946class="cmtt-8">&#x00A0;</span><span
6947class="cmtt-8">&#x00A0;</span><span
6948class="cmtt-8">&#x00A0;</span><span
6949class="cmtt-8">&#x00A0;</span><span
6950class="cmtt-8">&#x00A0;</span><span
6951class="cmtt-8">&#x00A0;</span><span
6952class="cmtt-8">&#x00A0;</span><span
6953class="cmsy-8">}</span><br class="fancyvrb" /><a
6954 id="x1-102066r32"></a><span
6955class="cmr-6">32</span><span
6956class="cmtt-8">&#x00A0;</span><span
6957class="cmtt-8">&#x00A0;</span><span
6958class="cmtt-8">&#x00A0;</span><span
6959class="cmtt-8">&#x00A0;</span><span
6960class="cmtt-8">&#x00A0;</span><span
6961class="cmtt-8">&#x00A0;</span><span
6962class="cmtt-8">&#x00A0;</span><span
6963class="cmtt-8">&#x00A0;</span><span
6964class="cmtt-8">&#x00A0;</span><span
6965class="cmtt-8">&#x00A0;</span><span
6966class="cmsy-8">}</span><br class="fancyvrb" /><a
6967 id="x1-102068r33"></a><span
6968class="cmr-6">33</span><br class="fancyvrb" /><a
6969 id="x1-102070r34"></a><span
6970class="cmr-6">34</span><span
6971class="cmtt-8">&#x00A0;</span><span
6972class="cmtt-8">&#x00A0;</span><span
6973class="cmtt-8">&#x00A0;</span><span
6974class="cmtt-8">&#x00A0;</span><span
6975class="cmtt-8">&#x00A0;</span><span
6976class="cmtt-8">&#x00A0;19)</span><span
6977class="cmtt-8">&#x00A0;[offset]</span><span
6978class="cmtt-8">&#x00A0;=</span><span
6979class="cmtt-8">&#x00A0;[offset]</span><span
6980class="cmtt-8">&#x00A0;+</span><span
6981class="cmtt-8">&#x00A0;[cdim]</span><br class="fancyvrb" /><a
6982 id="x1-102072r35"></a><span
6983class="cmr-6">35</span><br class="fancyvrb" /><a
6984 id="x1-102074r36"></a><span
6985class="cmr-6">36</span><span
6986class="cmtt-8">&#x00A0;</span><span
6987class="cmtt-8">&#x00A0;</span><span
6988class="cmtt-8">&#x00A0;</span><span
6989class="cmtt-8">&#x00A0;</span><span
6990class="cmtt-8">&#x00A0;</span><span
6991class="cmsy-8">}</span><br class="fancyvrb" /><a
6992 id="x1-102076r37"></a><span
6993class="cmr-6">37</span><br class="fancyvrb" /><a
6994 id="x1-102078r38"></a><span
6995class="cmr-6">38</span><span
6996class="cmtt-8">&#x00A0;20)</span><span
6997class="cmtt-8">&#x00A0;done</span></div>
6998<!--l. 228--><p class="noindent" >An end-of-packet condition during curve decode should be considered a nominal occurrence; if
6999end-of-packet is reached during any read operation above, floor decode is to return &#8217;unused&#8217;
7000status as if the <span
7001class="cmtt-12">[nonzero] </span>flag had been unset at the beginning of decode.
7002<!--l. 234--><p class="noindent" >Vector <span
7003class="cmtt-12">[floor1</span><span
7004class="cmtt-12">_Y] </span>contains the values from packet decode needed for floor 1 synthesis.
7005<!--l. 239--><p class="noindent" >
7006<h5 class="subsubsectionHead"><span class="titlemark">7.2.4. </span> <a
7007 id="x1-1030007.2.4"></a>curve computation</h5>
7008<!--l. 241--><p class="noindent" >Curve computation is split into two logical steps; the first step derives final Y amplitude values
7009from the encoded, wrapped difference values taken from the bitstream. The second step
7010plots the curve lines. Also, although zero-difference values are used in the iterative
7011prediction to find final Y values, these points are conditionally skipped during final
7012line computation in step two. Skipping zero-difference values allows a smoother line
7013fit.
7014<!--l. 249--><p class="noindent" >Although some aspects of the below algorithm look like inconsequential optimizations,
7015implementors are warned to follow the details closely. Deviation from implementing a strictly
7016equivalent algorithm can result in serious decoding errors.
7017<!--l. 254--><p class="noindent" ><span
7018class="cmti-12">Additional note: </span>Although <span
7019class="cmtt-12">[floor1</span><span
7020class="cmtt-12">_final</span><span
7021class="cmtt-12">_Y] </span>values in the prediction loop and at the end of
7022step 1 are inherently limited by the prediction algorithm to [0, <span
7023class="cmtt-12">[range]</span>), it is possible to abuse
7024the setup and codebook machinery to produce negative or over-range results. We suggest that
7025decoder implementations guard the values in vector <span
7026class="cmtt-12">[floor1</span><span
7027class="cmtt-12">_final</span><span
7028class="cmtt-12">_Y] </span>by clamping each
7029element to [0, <span
7030class="cmtt-12">[range]</span>) after step 1. Variants of this suggestion are acceptable as valid floor1
7031setups cannot produce out of range values.
7032<!--l. 265--><p class="noindent" >
7033 <dl class="description"><dt class="description">
7034<span
7035class="cmssbx-10x-x-120">step 1: amplitude value synthesis</span> </dt><dd
7036class="description">
7037 <!--l. 267--><p class="noindent" >Unwrap the always-positive-or-zero values read from the packet into +/- difference
7038 values, then apply to line prediction.
7039
7040
7041
7042 <!--l. 270--><p class="noindent" >
7043 <div class="fancyvrb" id="fancyvrb31"><a
7044 id="x1-103002r1"></a><span
7045class="cmr-6">1</span><span
7046class="cmtt-8">&#x00A0;</span><span
7047class="cmtt-8">&#x00A0;1)</span><span
7048class="cmtt-8">&#x00A0;[range]</span><span
7049class="cmtt-8">&#x00A0;=</span><span
7050class="cmtt-8">&#x00A0;vector</span><span
7051class="cmtt-8">&#x00A0;</span><span
7052class="cmsy-8">{</span><span
7053class="cmtt-8">&#x00A0;256,</span><span
7054class="cmtt-8">&#x00A0;128,</span><span
7055class="cmtt-8">&#x00A0;86,</span><span
7056class="cmtt-8">&#x00A0;64</span><span
7057class="cmtt-8">&#x00A0;</span><span
7058class="cmsy-8">}</span><span
7059class="cmtt-8">&#x00A0;element</span><span
7060class="cmtt-8">&#x00A0;([floor1</span><span
7061class="cmtt-8">_multiplier]-1)</span><br class="fancyvrb" /><a
7062 id="x1-103004r2"></a><span
7063class="cmr-6">2</span><span
7064class="cmtt-8">&#x00A0;</span><span
7065class="cmtt-8">&#x00A0;2)</span><span
7066class="cmtt-8">&#x00A0;vector</span><span
7067class="cmtt-8">&#x00A0;[floor1</span><span
7068class="cmtt-8">_step2</span><span
7069class="cmtt-8">_flag]</span><span
7070class="cmtt-8">&#x00A0;element</span><span
7071class="cmtt-8">&#x00A0;[0]</span><span
7072class="cmtt-8">&#x00A0;=</span><span
7073class="cmtt-8">&#x00A0;set</span>
7074 <br class="fancyvrb" /><a
7075 id="x1-103006r3"></a><span
7076class="cmr-6">3</span><span
7077class="cmtt-8">&#x00A0;</span><span
7078class="cmtt-8">&#x00A0;3)</span><span
7079class="cmtt-8">&#x00A0;vector</span><span
7080class="cmtt-8">&#x00A0;[floor1</span><span
7081class="cmtt-8">_step2</span><span
7082class="cmtt-8">_flag]</span><span
7083class="cmtt-8">&#x00A0;element</span><span
7084class="cmtt-8">&#x00A0;[1]</span><span
7085class="cmtt-8">&#x00A0;=</span><span
7086class="cmtt-8">&#x00A0;set</span><br class="fancyvrb" /><a
7087 id="x1-103008r4"></a><span
7088class="cmr-6">4</span><span
7089class="cmtt-8">&#x00A0;</span><span
7090class="cmtt-8">&#x00A0;4)</span><span
7091class="cmtt-8">&#x00A0;vector</span><span
7092class="cmtt-8">&#x00A0;[floor1</span><span
7093class="cmtt-8">_final</span><span
7094class="cmtt-8">_Y]</span><span
7095class="cmtt-8">&#x00A0;element</span><span
7096class="cmtt-8">&#x00A0;[0]</span><span
7097class="cmtt-8">&#x00A0;=</span><span
7098class="cmtt-8">&#x00A0;vector</span><span
7099class="cmtt-8">&#x00A0;[floor1</span><span
7100class="cmtt-8">_Y]</span><span
7101class="cmtt-8">&#x00A0;element</span><span
7102class="cmtt-8">&#x00A0;[0]</span>
7103 <br class="fancyvrb" /><a
7104 id="x1-103010r5"></a><span
7105class="cmr-6">5</span><span
7106class="cmtt-8">&#x00A0;</span><span
7107class="cmtt-8">&#x00A0;5)</span><span
7108class="cmtt-8">&#x00A0;vector</span><span
7109class="cmtt-8">&#x00A0;[floor1</span><span
7110class="cmtt-8">_final</span><span
7111class="cmtt-8">_Y]</span><span
7112class="cmtt-8">&#x00A0;element</span><span
7113class="cmtt-8">&#x00A0;[1]</span><span
7114class="cmtt-8">&#x00A0;=</span><span
7115class="cmtt-8">&#x00A0;vector</span><span
7116class="cmtt-8">&#x00A0;[floor1</span><span
7117class="cmtt-8">_Y]</span><span
7118class="cmtt-8">&#x00A0;element</span><span
7119class="cmtt-8">&#x00A0;[1]</span><br class="fancyvrb" /><a
7120 id="x1-103012r6"></a><span
7121class="cmr-6">6</span><span
7122class="cmtt-8">&#x00A0;</span><span
7123class="cmtt-8">&#x00A0;6)</span><span
7124class="cmtt-8">&#x00A0;iterate</span><span
7125class="cmtt-8">&#x00A0;[i]</span><span
7126class="cmtt-8">&#x00A0;over</span><span
7127class="cmtt-8">&#x00A0;the</span><span
7128class="cmtt-8">&#x00A0;range</span><span
7129class="cmtt-8">&#x00A0;2</span><span
7130class="cmtt-8">&#x00A0;...</span><span
7131class="cmtt-8">&#x00A0;[floor1</span><span
7132class="cmtt-8">_values]-1</span><span
7133class="cmtt-8">&#x00A0;</span><span
7134class="cmsy-8">{</span><br class="fancyvrb" /><a
7135 id="x1-103014r7"></a><span
7136class="cmr-6">7</span>
7137 <br class="fancyvrb" /><a
7138 id="x1-103016r8"></a><span
7139class="cmr-6">8</span><span
7140class="cmtt-8">&#x00A0;</span><span
7141class="cmtt-8">&#x00A0;</span><span
7142class="cmtt-8">&#x00A0;</span><span
7143class="cmtt-8">&#x00A0;</span><span
7144class="cmtt-8">&#x00A0;</span><span
7145class="cmtt-8">&#x00A0;</span><span
7146class="cmtt-8">&#x00A0;7)</span><span
7147class="cmtt-8">&#x00A0;[low</span><span
7148class="cmtt-8">_neighbor</span><span
7149class="cmtt-8">_offset]</span><span
7150class="cmtt-8">&#x00A0;=</span><span
7151class="cmtt-8">&#x00A0;</span><a
7152href="#x1-1220009.2.4"><span
7153class="cmtt-8">low</span><span
7154class="cmtt-8">_neighbor</span></a><span
7155class="cmtt-8">([floor1</span><span
7156class="cmtt-8">_X</span><span
7157class="cmtt-8">_list],[i])</span><br class="fancyvrb" /><a
7158 id="x1-103018r9"></a><span
7159class="cmr-6">9</span><span
7160class="cmtt-8">&#x00A0;</span><span
7161class="cmtt-8">&#x00A0;</span><span
7162class="cmtt-8">&#x00A0;</span><span
7163class="cmtt-8">&#x00A0;</span><span
7164class="cmtt-8">&#x00A0;</span><span
7165class="cmtt-8">&#x00A0;</span><span
7166class="cmtt-8">&#x00A0;8)</span><span
7167class="cmtt-8">&#x00A0;[high</span><span
7168class="cmtt-8">_neighbor</span><span
7169class="cmtt-8">_offset]</span><span
7170class="cmtt-8">&#x00A0;=</span><span
7171class="cmtt-8">&#x00A0;</span><a
7172href="#x1-1230009.2.5"><span
7173class="cmtt-8">high</span><span
7174class="cmtt-8">_neighbor</span></a><span
7175class="cmtt-8">([floor1</span><span
7176class="cmtt-8">_X</span><span
7177class="cmtt-8">_list],[i])</span><br class="fancyvrb" /><a
7178 id="x1-103020r10"></a><span
7179class="cmr-6">10</span>
7180 <br class="fancyvrb" /><a
7181 id="x1-103022r11"></a><span
7182class="cmr-6">11</span><span
7183class="cmtt-8">&#x00A0;</span><span
7184class="cmtt-8">&#x00A0;</span><span
7185class="cmtt-8">&#x00A0;</span><span
7186class="cmtt-8">&#x00A0;</span><span
7187class="cmtt-8">&#x00A0;</span><span
7188class="cmtt-8">&#x00A0;</span><span
7189class="cmtt-8">&#x00A0;9)</span><span
7190class="cmtt-8">&#x00A0;[predicted]</span><span
7191class="cmtt-8">&#x00A0;=</span><span
7192class="cmtt-8">&#x00A0;</span><a
7193href="#x1-1240009.2.6"><span
7194class="cmtt-8">render</span><span
7195class="cmtt-8">_point</span></a><span
7196class="cmtt-8">(</span><span
7197class="cmtt-8">&#x00A0;vector</span><span
7198class="cmtt-8">&#x00A0;[floor1</span><span
7199class="cmtt-8">_X</span><span
7200class="cmtt-8">_list]</span><span
7201class="cmtt-8">&#x00A0;element</span><span
7202class="cmtt-8">&#x00A0;[low</span><span
7203class="cmtt-8">_neighbor</span><span
7204class="cmtt-8">_offset],</span>
7205 <br class="fancyvrb" /><a
7206 id="x1-103024r12"></a><span
7207class="cmr-6">12</span> <span
7208class="cmtt-8">&#x00A0;</span><span
7209class="cmtt-8">&#x00A0;</span><span
7210class="cmtt-8">&#x00A0;</span><span
7211class="cmtt-8">&#x00A0;</span><span
7212class="cmtt-8">&#x00A0;</span><span
7213class="cmtt-8">&#x00A0;vector</span><span
7214class="cmtt-8">&#x00A0;[floor1</span><span
7215class="cmtt-8">_final</span><span
7216class="cmtt-8">_Y]</span><span
7217class="cmtt-8">&#x00A0;element</span><span
7218class="cmtt-8">&#x00A0;[low</span><span
7219class="cmtt-8">_neighbor</span><span
7220class="cmtt-8">_offset],</span>
7221 <br class="fancyvrb" /><a
7222 id="x1-103026r13"></a><span
7223class="cmr-6">13</span><span
7224class="cmtt-8">&#x00A0;</span><span
7225class="cmtt-8">&#x00A0;</span><span
7226class="cmtt-8">&#x00A0;</span><span
7227class="cmtt-8">&#x00A0;</span><span
7228class="cmtt-8">&#x00A0;</span><span
7229class="cmtt-8">&#x00A0;</span><span
7230class="cmtt-8">&#x00A0;</span><span
7231class="cmtt-8">&#x00A0;</span><span
7232class="cmtt-8">&#x00A0;</span><span
7233class="cmtt-8">&#x00A0;</span><span
7234class="cmtt-8">&#x00A0;</span><span
7235class="cmtt-8">&#x00A0;</span><span
7236class="cmtt-8">&#x00A0;</span><span
7237class="cmtt-8">&#x00A0;</span><span
7238class="cmtt-8">&#x00A0;</span><span
7239class="cmtt-8">&#x00A0;</span><span
7240class="cmtt-8">&#x00A0;</span><span
7241class="cmtt-8">&#x00A0;</span><span
7242class="cmtt-8">&#x00A0;</span><span
7243class="cmtt-8">&#x00A0;</span><span
7244class="cmtt-8">&#x00A0;</span><span
7245class="cmtt-8">&#x00A0;</span><span
7246class="cmtt-8">&#x00A0;</span><span
7247class="cmtt-8">&#x00A0;</span><span
7248class="cmtt-8">&#x00A0;</span><span
7249class="cmtt-8">&#x00A0;</span><span
7250class="cmtt-8">&#x00A0;</span><span
7251class="cmtt-8">&#x00A0;</span><span
7252class="cmtt-8">&#x00A0;</span><span
7253class="cmtt-8">&#x00A0;</span><span
7254class="cmtt-8">&#x00A0;</span><span
7255class="cmtt-8">&#x00A0;</span><span
7256class="cmtt-8">&#x00A0;</span><span
7257class="cmtt-8">&#x00A0;</span><span
7258class="cmtt-8">&#x00A0;</span><span
7259class="cmtt-8">&#x00A0;</span><span
7260class="cmtt-8">&#x00A0;</span><span
7261class="cmtt-8">&#x00A0;vector</span><span
7262class="cmtt-8">&#x00A0;[floor1</span><span
7263class="cmtt-8">_X</span><span
7264class="cmtt-8">_list]</span><span
7265class="cmtt-8">&#x00A0;element</span><span
7266class="cmtt-8">&#x00A0;[high</span><span
7267class="cmtt-8">_neighbor</span><span
7268class="cmtt-8">_offset],</span>
7269 <br class="fancyvrb" /><a
7270 id="x1-103028r14"></a><span
7271class="cmr-6">14</span> <span
7272class="cmtt-8">&#x00A0;</span><span
7273class="cmtt-8">&#x00A0;</span><span
7274class="cmtt-8">&#x00A0;</span><span
7275class="cmtt-8">&#x00A0;</span><span
7276class="cmtt-8">&#x00A0;</span><span
7277class="cmtt-8">&#x00A0;vector</span><span
7278class="cmtt-8">&#x00A0;[floor1</span><span
7279class="cmtt-8">_final</span><span
7280class="cmtt-8">_Y]</span><span
7281class="cmtt-8">&#x00A0;element</span><span
7282class="cmtt-8">&#x00A0;[high</span><span
7283class="cmtt-8">_neighbor</span><span
7284class="cmtt-8">_offset],</span>
7285 <br class="fancyvrb" /><a
7286 id="x1-103030r15"></a><span
7287class="cmr-6">15</span><span
7288class="cmtt-8">&#x00A0;</span><span
7289class="cmtt-8">&#x00A0;</span><span
7290class="cmtt-8">&#x00A0;</span><span
7291class="cmtt-8">&#x00A0;</span><span
7292class="cmtt-8">&#x00A0;</span><span
7293class="cmtt-8">&#x00A0;</span><span
7294class="cmtt-8">&#x00A0;</span><span
7295class="cmtt-8">&#x00A0;</span><span
7296class="cmtt-8">&#x00A0;</span><span
7297class="cmtt-8">&#x00A0;</span><span
7298class="cmtt-8">&#x00A0;</span><span
7299class="cmtt-8">&#x00A0;</span><span
7300class="cmtt-8">&#x00A0;</span><span
7301class="cmtt-8">&#x00A0;</span><span
7302class="cmtt-8">&#x00A0;</span><span
7303class="cmtt-8">&#x00A0;</span><span
7304class="cmtt-8">&#x00A0;</span><span
7305class="cmtt-8">&#x00A0;</span><span
7306class="cmtt-8">&#x00A0;</span><span
7307class="cmtt-8">&#x00A0;</span><span
7308class="cmtt-8">&#x00A0;</span><span
7309class="cmtt-8">&#x00A0;</span><span
7310class="cmtt-8">&#x00A0;</span><span
7311class="cmtt-8">&#x00A0;</span><span
7312class="cmtt-8">&#x00A0;</span><span
7313class="cmtt-8">&#x00A0;</span><span
7314class="cmtt-8">&#x00A0;</span><span
7315class="cmtt-8">&#x00A0;</span><span
7316class="cmtt-8">&#x00A0;</span><span
7317class="cmtt-8">&#x00A0;</span><span
7318class="cmtt-8">&#x00A0;</span><span
7319class="cmtt-8">&#x00A0;</span><span
7320class="cmtt-8">&#x00A0;</span><span
7321class="cmtt-8">&#x00A0;</span><span
7322class="cmtt-8">&#x00A0;</span><span
7323class="cmtt-8">&#x00A0;</span><span
7324class="cmtt-8">&#x00A0;</span><span
7325class="cmtt-8">&#x00A0;vector</span><span
7326class="cmtt-8">&#x00A0;[floor1</span><span
7327class="cmtt-8">_X</span><span
7328class="cmtt-8">_list]</span><span
7329class="cmtt-8">&#x00A0;element</span><span
7330class="cmtt-8">&#x00A0;[i]</span><span
7331class="cmtt-8">&#x00A0;)</span><br class="fancyvrb" /><a
7332 id="x1-103032r16"></a><span
7333class="cmr-6">16</span><br class="fancyvrb" /><a
7334 id="x1-103034r17"></a><span
7335class="cmr-6">17</span><span
7336class="cmtt-8">&#x00A0;</span><span
7337class="cmtt-8">&#x00A0;</span><span
7338class="cmtt-8">&#x00A0;</span><span
7339class="cmtt-8">&#x00A0;</span><span
7340class="cmtt-8">&#x00A0;</span><span
7341class="cmtt-8">&#x00A0;10)</span><span
7342class="cmtt-8">&#x00A0;[val]</span><span
7343class="cmtt-8">&#x00A0;=</span><span
7344class="cmtt-8">&#x00A0;vector</span><span
7345class="cmtt-8">&#x00A0;[floor1</span><span
7346class="cmtt-8">_Y]</span><span
7347class="cmtt-8">&#x00A0;element</span><span
7348class="cmtt-8">&#x00A0;[i]</span>
7349 <br class="fancyvrb" /><a
7350 id="x1-103036r18"></a><span
7351class="cmr-6">18</span><span
7352class="cmtt-8">&#x00A0;</span><span
7353class="cmtt-8">&#x00A0;</span><span
7354class="cmtt-8">&#x00A0;</span><span
7355class="cmtt-8">&#x00A0;</span><span
7356class="cmtt-8">&#x00A0;</span><span
7357class="cmtt-8">&#x00A0;11)</span><span
7358class="cmtt-8">&#x00A0;[highroom]</span><span
7359class="cmtt-8">&#x00A0;=</span><span
7360class="cmtt-8">&#x00A0;[range]</span><span
7361class="cmtt-8">&#x00A0;-</span><span
7362class="cmtt-8">&#x00A0;[predicted]</span><br class="fancyvrb" /><a
7363 id="x1-103038r19"></a><span
7364class="cmr-6">19</span><span
7365class="cmtt-8">&#x00A0;</span><span
7366class="cmtt-8">&#x00A0;</span><span
7367class="cmtt-8">&#x00A0;</span><span
7368class="cmtt-8">&#x00A0;</span><span
7369class="cmtt-8">&#x00A0;</span><span
7370class="cmtt-8">&#x00A0;12)</span><span
7371class="cmtt-8">&#x00A0;[lowroom]</span><span
7372class="cmtt-8">&#x00A0;</span><span
7373class="cmtt-8">&#x00A0;=</span><span
7374class="cmtt-8">&#x00A0;[predicted]</span><br class="fancyvrb" /><a
7375 id="x1-103040r20"></a><span
7376class="cmr-6">20</span><span
7377class="cmtt-8">&#x00A0;</span><span
7378class="cmtt-8">&#x00A0;</span><span
7379class="cmtt-8">&#x00A0;</span><span
7380class="cmtt-8">&#x00A0;</span><span
7381class="cmtt-8">&#x00A0;</span><span
7382class="cmtt-8">&#x00A0;13)</span><span
7383class="cmtt-8">&#x00A0;if</span><span
7384class="cmtt-8">&#x00A0;(</span><span
7385class="cmtt-8">&#x00A0;[highroom]</span><span
7386class="cmtt-8">&#x00A0;is</span><span
7387class="cmtt-8">&#x00A0;less</span><span
7388class="cmtt-8">&#x00A0;than</span><span
7389class="cmtt-8">&#x00A0;[lowroom]</span><span
7390class="cmtt-8">&#x00A0;)</span><span
7391class="cmtt-8">&#x00A0;</span><span
7392class="cmsy-8">{</span><br class="fancyvrb" /><a
7393 id="x1-103042r21"></a><span
7394class="cmr-6">21</span>
7395 <br class="fancyvrb" /><a
7396 id="x1-103044r22"></a><span
7397class="cmr-6">22</span><span
7398class="cmtt-8">&#x00A0;</span><span
7399class="cmtt-8">&#x00A0;</span><span
7400class="cmtt-8">&#x00A0;</span><span
7401class="cmtt-8">&#x00A0;</span><span
7402class="cmtt-8">&#x00A0;</span><span
7403class="cmtt-8">&#x00A0;</span><span
7404class="cmtt-8">&#x00A0;</span><span
7405class="cmtt-8">&#x00A0;</span><span
7406class="cmtt-8">&#x00A0;</span><span
7407class="cmtt-8">&#x00A0;</span><span
7408class="cmtt-8">&#x00A0;</span><span
7409class="cmtt-8">&#x00A0;14)</span><span
7410class="cmtt-8">&#x00A0;[room]</span><span
7411class="cmtt-8">&#x00A0;=</span><span
7412class="cmtt-8">&#x00A0;[highroom]</span><span
7413class="cmtt-8">&#x00A0;*</span><span
7414class="cmtt-8">&#x00A0;2</span><br class="fancyvrb" /><a
7415 id="x1-103046r23"></a><span
7416class="cmr-6">23</span><br class="fancyvrb" /><a
7417 id="x1-103048r24"></a><span
7418class="cmr-6">24</span><span
7419class="cmtt-8">&#x00A0;</span><span
7420class="cmtt-8">&#x00A0;</span><span
7421class="cmtt-8">&#x00A0;</span><span
7422class="cmtt-8">&#x00A0;</span><span
7423class="cmtt-8">&#x00A0;</span><span
7424class="cmtt-8">&#x00A0;</span><span
7425class="cmtt-8">&#x00A0;</span><span
7426class="cmtt-8">&#x00A0;</span><span
7427class="cmtt-8">&#x00A0;</span><span
7428class="cmtt-8">&#x00A0;</span><span
7429class="cmsy-8">}</span><span
7430class="cmtt-8">&#x00A0;else</span><span
7431class="cmtt-8">&#x00A0;[highroom]</span><span
7432class="cmtt-8">&#x00A0;is</span><span
7433class="cmtt-8">&#x00A0;not</span><span
7434class="cmtt-8">&#x00A0;less</span><span
7435class="cmtt-8">&#x00A0;than</span><span
7436class="cmtt-8">&#x00A0;[lowroom]</span><span
7437class="cmtt-8">&#x00A0;</span><span
7438class="cmsy-8">{</span><br class="fancyvrb" /><a
7439 id="x1-103050r25"></a><span
7440class="cmr-6">25</span><br class="fancyvrb" /><a
7441 id="x1-103052r26"></a><span
7442class="cmr-6">26</span><span
7443class="cmtt-8">&#x00A0;</span><span
7444class="cmtt-8">&#x00A0;</span><span
7445class="cmtt-8">&#x00A0;</span><span
7446class="cmtt-8">&#x00A0;</span><span
7447class="cmtt-8">&#x00A0;</span><span
7448class="cmtt-8">&#x00A0;</span><span
7449class="cmtt-8">&#x00A0;</span><span
7450class="cmtt-8">&#x00A0;</span><span
7451class="cmtt-8">&#x00A0;</span><span
7452class="cmtt-8">&#x00A0;</span><span
7453class="cmtt-8">&#x00A0;</span><span
7454class="cmtt-8">&#x00A0;15)</span><span
7455class="cmtt-8">&#x00A0;[room]</span><span
7456class="cmtt-8">&#x00A0;=</span><span
7457class="cmtt-8">&#x00A0;[lowroom]</span><span
7458class="cmtt-8">&#x00A0;*</span><span
7459class="cmtt-8">&#x00A0;2</span><br class="fancyvrb" /><a
7460 id="x1-103054r27"></a><span
7461class="cmr-6">27</span>
7462 <br class="fancyvrb" /><a
7463 id="x1-103056r28"></a><span
7464class="cmr-6">28</span><span
7465class="cmtt-8">&#x00A0;</span><span
7466class="cmtt-8">&#x00A0;</span><span
7467class="cmtt-8">&#x00A0;</span><span
7468class="cmtt-8">&#x00A0;</span><span
7469class="cmtt-8">&#x00A0;</span><span
7470class="cmtt-8">&#x00A0;</span><span
7471class="cmtt-8">&#x00A0;</span><span
7472class="cmtt-8">&#x00A0;</span><span
7473class="cmtt-8">&#x00A0;</span><span
7474class="cmtt-8">&#x00A0;</span><span
7475class="cmsy-8">}</span><br class="fancyvrb" /><a
7476 id="x1-103058r29"></a><span
7477class="cmr-6">29</span><br class="fancyvrb" /><a
7478 id="x1-103060r30"></a><span
7479class="cmr-6">30</span><span
7480class="cmtt-8">&#x00A0;</span><span
7481class="cmtt-8">&#x00A0;</span><span
7482class="cmtt-8">&#x00A0;</span><span
7483class="cmtt-8">&#x00A0;</span><span
7484class="cmtt-8">&#x00A0;</span><span
7485class="cmtt-8">&#x00A0;16)</span><span
7486class="cmtt-8">&#x00A0;if</span><span
7487class="cmtt-8">&#x00A0;(</span><span
7488class="cmtt-8">&#x00A0;[val]</span><span
7489class="cmtt-8">&#x00A0;is</span><span
7490class="cmtt-8">&#x00A0;nonzero</span><span
7491class="cmtt-8">&#x00A0;)</span><span
7492class="cmtt-8">&#x00A0;</span><span
7493class="cmsy-8">{</span><br class="fancyvrb" /><a
7494 id="x1-103062r31"></a><span
7495class="cmr-6">31</span><br class="fancyvrb" /><a
7496 id="x1-103064r32"></a><span
7497class="cmr-6">32</span><span
7498class="cmtt-8">&#x00A0;</span><span
7499class="cmtt-8">&#x00A0;</span><span
7500class="cmtt-8">&#x00A0;</span><span
7501class="cmtt-8">&#x00A0;</span><span
7502class="cmtt-8">&#x00A0;</span><span
7503class="cmtt-8">&#x00A0;</span><span
7504class="cmtt-8">&#x00A0;</span><span
7505class="cmtt-8">&#x00A0;</span><span
7506class="cmtt-8">&#x00A0;</span><span
7507class="cmtt-8">&#x00A0;</span><span
7508class="cmtt-8">&#x00A0;</span><span
7509class="cmtt-8">&#x00A0;17)</span><span
7510class="cmtt-8">&#x00A0;vector</span><span
7511class="cmtt-8">&#x00A0;[floor1</span><span
7512class="cmtt-8">_step2</span><span
7513class="cmtt-8">_flag]</span><span
7514class="cmtt-8">&#x00A0;element</span><span
7515class="cmtt-8">&#x00A0;[low</span><span
7516class="cmtt-8">_neighbor</span><span
7517class="cmtt-8">_offset]</span><span
7518class="cmtt-8">&#x00A0;=</span><span
7519class="cmtt-8">&#x00A0;set</span>
7520 <br class="fancyvrb" /><a
7521 id="x1-103066r33"></a><span
7522class="cmr-6">33</span><span
7523class="cmtt-8">&#x00A0;</span><span
7524class="cmtt-8">&#x00A0;</span><span
7525class="cmtt-8">&#x00A0;</span><span
7526class="cmtt-8">&#x00A0;</span><span
7527class="cmtt-8">&#x00A0;</span><span
7528class="cmtt-8">&#x00A0;</span><span
7529class="cmtt-8">&#x00A0;</span><span
7530class="cmtt-8">&#x00A0;</span><span
7531class="cmtt-8">&#x00A0;</span><span
7532class="cmtt-8">&#x00A0;</span><span
7533class="cmtt-8">&#x00A0;</span><span
7534class="cmtt-8">&#x00A0;18)</span><span
7535class="cmtt-8">&#x00A0;vector</span><span
7536class="cmtt-8">&#x00A0;[floor1</span><span
7537class="cmtt-8">_step2</span><span
7538class="cmtt-8">_flag]</span><span
7539class="cmtt-8">&#x00A0;element</span><span
7540class="cmtt-8">&#x00A0;[high</span><span
7541class="cmtt-8">_neighbor</span><span
7542class="cmtt-8">_offset]</span><span
7543class="cmtt-8">&#x00A0;=</span><span
7544class="cmtt-8">&#x00A0;set</span><br class="fancyvrb" /><a
7545 id="x1-103068r34"></a><span
7546class="cmr-6">34</span><span
7547class="cmtt-8">&#x00A0;</span><span
7548class="cmtt-8">&#x00A0;</span><span
7549class="cmtt-8">&#x00A0;</span><span
7550class="cmtt-8">&#x00A0;</span><span
7551class="cmtt-8">&#x00A0;</span><span
7552class="cmtt-8">&#x00A0;</span><span
7553class="cmtt-8">&#x00A0;</span><span
7554class="cmtt-8">&#x00A0;</span><span
7555class="cmtt-8">&#x00A0;</span><span
7556class="cmtt-8">&#x00A0;</span><span
7557class="cmtt-8">&#x00A0;</span><span
7558class="cmtt-8">&#x00A0;19)</span><span
7559class="cmtt-8">&#x00A0;vector</span><span
7560class="cmtt-8">&#x00A0;[floor1</span><span
7561class="cmtt-8">_step2</span><span
7562class="cmtt-8">_flag]</span><span
7563class="cmtt-8">&#x00A0;element</span><span
7564class="cmtt-8">&#x00A0;[i]</span><span
7565class="cmtt-8">&#x00A0;=</span><span
7566class="cmtt-8">&#x00A0;set</span>
7567 <br class="fancyvrb" /><a
7568 id="x1-103070r35"></a><span
7569class="cmr-6">35</span><span
7570class="cmtt-8">&#x00A0;</span><span
7571class="cmtt-8">&#x00A0;</span><span
7572class="cmtt-8">&#x00A0;</span><span
7573class="cmtt-8">&#x00A0;</span><span
7574class="cmtt-8">&#x00A0;</span><span
7575class="cmtt-8">&#x00A0;</span><span
7576class="cmtt-8">&#x00A0;</span><span
7577class="cmtt-8">&#x00A0;</span><span
7578class="cmtt-8">&#x00A0;</span><span
7579class="cmtt-8">&#x00A0;</span><span
7580class="cmtt-8">&#x00A0;</span><span
7581class="cmtt-8">&#x00A0;20)</span><span
7582class="cmtt-8">&#x00A0;if</span><span
7583class="cmtt-8">&#x00A0;(</span><span
7584class="cmtt-8">&#x00A0;[val]</span><span
7585class="cmtt-8">&#x00A0;is</span><span
7586class="cmtt-8">&#x00A0;greater</span><span
7587class="cmtt-8">&#x00A0;than</span><span
7588class="cmtt-8">&#x00A0;or</span><span
7589class="cmtt-8">&#x00A0;equal</span><span
7590class="cmtt-8">&#x00A0;to</span><span
7591class="cmtt-8">&#x00A0;[room]</span><span
7592class="cmtt-8">&#x00A0;)</span><span
7593class="cmtt-8">&#x00A0;</span><span
7594class="cmsy-8">{</span><br class="fancyvrb" /><a
7595 id="x1-103072r36"></a><span
7596class="cmr-6">36</span><br class="fancyvrb" /><a
7597 id="x1-103074r37"></a><span
7598class="cmr-6">37</span><span
7599class="cmtt-8">&#x00A0;</span><span
7600class="cmtt-8">&#x00A0;</span><span
7601class="cmtt-8">&#x00A0;</span><span
7602class="cmtt-8">&#x00A0;</span><span
7603class="cmtt-8">&#x00A0;</span><span
7604class="cmtt-8">&#x00A0;</span><span
7605class="cmtt-8">&#x00A0;</span><span
7606class="cmtt-8">&#x00A0;</span><span
7607class="cmtt-8">&#x00A0;</span><span
7608class="cmtt-8">&#x00A0;</span><span
7609class="cmtt-8">&#x00A0;</span><span
7610class="cmtt-8">&#x00A0;</span><span
7611class="cmtt-8">&#x00A0;</span><span
7612class="cmtt-8">&#x00A0;</span><span
7613class="cmtt-8">&#x00A0;</span><span
7614class="cmtt-8">&#x00A0;</span><span
7615class="cmtt-8">&#x00A0;</span><span
7616class="cmtt-8">&#x00A0;21)</span><span
7617class="cmtt-8">&#x00A0;if</span><span
7618class="cmtt-8">&#x00A0;(</span><span
7619class="cmtt-8">&#x00A0;[highroom]</span><span
7620class="cmtt-8">&#x00A0;is</span><span
7621class="cmtt-8">&#x00A0;greater</span><span
7622class="cmtt-8">&#x00A0;than</span><span
7623class="cmtt-8">&#x00A0;[lowroom]</span><span
7624class="cmtt-8">&#x00A0;)</span><span
7625class="cmtt-8">&#x00A0;</span><span
7626class="cmsy-8">{</span><br class="fancyvrb" /><a
7627 id="x1-103076r38"></a><span
7628class="cmr-6">38</span>
7629 <br class="fancyvrb" /><a
7630 id="x1-103078r39"></a><span
7631class="cmr-6">39</span><span
7632class="cmtt-8">&#x00A0;</span><span
7633class="cmtt-8">&#x00A0;</span><span
7634class="cmtt-8">&#x00A0;</span><span
7635class="cmtt-8">&#x00A0;</span><span
7636class="cmtt-8">&#x00A0;</span><span
7637class="cmtt-8">&#x00A0;</span><span
7638class="cmtt-8">&#x00A0;</span><span
7639class="cmtt-8">&#x00A0;</span><span
7640class="cmtt-8">&#x00A0;</span><span
7641class="cmtt-8">&#x00A0;</span><span
7642class="cmtt-8">&#x00A0;</span><span
7643class="cmtt-8">&#x00A0;</span><span
7644class="cmtt-8">&#x00A0;</span><span
7645class="cmtt-8">&#x00A0;</span><span
7646class="cmtt-8">&#x00A0;</span><span
7647class="cmtt-8">&#x00A0;</span><span
7648class="cmtt-8">&#x00A0;</span><span
7649class="cmtt-8">&#x00A0;</span><span
7650class="cmtt-8">&#x00A0;</span><span
7651class="cmtt-8">&#x00A0;</span><span
7652class="cmtt-8">&#x00A0;</span><span
7653class="cmtt-8">&#x00A0;</span><span
7654class="cmtt-8">&#x00A0;</span><span
7655class="cmtt-8">&#x00A0;22)</span><span
7656class="cmtt-8">&#x00A0;vector</span><span
7657class="cmtt-8">&#x00A0;[floor1</span><span
7658class="cmtt-8">_final</span><span
7659class="cmtt-8">_Y]</span><span
7660class="cmtt-8">&#x00A0;element</span><span
7661class="cmtt-8">&#x00A0;[i]</span><span
7662class="cmtt-8">&#x00A0;=</span><span
7663class="cmtt-8">&#x00A0;[val]</span><span
7664class="cmtt-8">&#x00A0;-</span><span
7665class="cmtt-8">&#x00A0;[lowroom]</span><span
7666class="cmtt-8">&#x00A0;+</span><span
7667class="cmtt-8">&#x00A0;[predicted]</span><br class="fancyvrb" /><a
7668 id="x1-103080r40"></a><span
7669class="cmr-6">40</span>
7670 <br class="fancyvrb" /><a
7671 id="x1-103082r41"></a><span
7672class="cmr-6">41</span> <span
7673class="cmtt-8">&#x00A0;</span><span
7674class="cmtt-8">&#x00A0;</span><span
7675class="cmtt-8">&#x00A0;</span><span
7676class="cmtt-8">&#x00A0;</span><span
7677class="cmtt-8">&#x00A0;</span><span
7678class="cmtt-8">&#x00A0;</span><span
7679class="cmsy-8">}</span><span
7680class="cmtt-8">&#x00A0;else</span><span
7681class="cmtt-8">&#x00A0;[highroom]</span><span
7682class="cmtt-8">&#x00A0;is</span><span
7683class="cmtt-8">&#x00A0;not</span><span
7684class="cmtt-8">&#x00A0;greater</span><span
7685class="cmtt-8">&#x00A0;than</span><span
7686class="cmtt-8">&#x00A0;[lowroom]</span><span
7687class="cmtt-8">&#x00A0;</span><span
7688class="cmsy-8">{</span><br class="fancyvrb" /><a
7689 id="x1-103084r42"></a><span
7690class="cmr-6">42</span>
7691 <br class="fancyvrb" /><a
7692 id="x1-103086r43"></a><span
7693class="cmr-6">43</span><span
7694class="cmtt-8">&#x00A0;</span><span
7695class="cmtt-8">&#x00A0;</span><span
7696class="cmtt-8">&#x00A0;</span><span
7697class="cmtt-8">&#x00A0;</span><span
7698class="cmtt-8">&#x00A0;</span><span
7699class="cmtt-8">&#x00A0;</span><span
7700class="cmtt-8">&#x00A0;</span><span
7701class="cmtt-8">&#x00A0;</span><span
7702class="cmtt-8">&#x00A0;</span><span
7703class="cmtt-8">&#x00A0;</span><span
7704class="cmtt-8">&#x00A0;</span><span
7705class="cmtt-8">&#x00A0;</span><span
7706class="cmtt-8">&#x00A0;</span><span
7707class="cmtt-8">&#x00A0;</span><span
7708class="cmtt-8">&#x00A0;</span><span
7709class="cmtt-8">&#x00A0;</span><span
7710class="cmtt-8">&#x00A0;</span><span
7711class="cmtt-8">&#x00A0;</span><span
7712class="cmtt-8">&#x00A0;</span><span
7713class="cmtt-8">&#x00A0;</span><span
7714class="cmtt-8">&#x00A0;</span><span
7715class="cmtt-8">&#x00A0;</span><span
7716class="cmtt-8">&#x00A0;</span><span
7717class="cmtt-8">&#x00A0;23)</span><span
7718class="cmtt-8">&#x00A0;vector</span><span
7719class="cmtt-8">&#x00A0;[floor1</span><span
7720class="cmtt-8">_final</span><span
7721class="cmtt-8">_Y]</span><span
7722class="cmtt-8">&#x00A0;element</span><span
7723class="cmtt-8">&#x00A0;[i]</span><span
7724class="cmtt-8">&#x00A0;=</span><span
7725class="cmtt-8">&#x00A0;[predicted]</span><span
7726class="cmtt-8">&#x00A0;-</span><span
7727class="cmtt-8">&#x00A0;[val]</span><span
7728class="cmtt-8">&#x00A0;+</span><span
7729class="cmtt-8">&#x00A0;[highroom]</span><span
7730class="cmtt-8">&#x00A0;-</span><span
7731class="cmtt-8">&#x00A0;1</span><br class="fancyvrb" /><a
7732 id="x1-103088r44"></a><span
7733class="cmr-6">44</span>
7734 <br class="fancyvrb" /><a
7735 id="x1-103090r45"></a><span
7736class="cmr-6">45</span><span
7737class="cmtt-8">&#x00A0;</span><span
7738class="cmtt-8">&#x00A0;</span><span
7739class="cmtt-8">&#x00A0;</span><span
7740class="cmtt-8">&#x00A0;</span><span
7741class="cmtt-8">&#x00A0;</span><span
7742class="cmtt-8">&#x00A0;</span><span
7743class="cmtt-8">&#x00A0;</span><span
7744class="cmtt-8">&#x00A0;</span><span
7745class="cmtt-8">&#x00A0;</span><span
7746class="cmtt-8">&#x00A0;</span><span
7747class="cmtt-8">&#x00A0;</span><span
7748class="cmtt-8">&#x00A0;</span><span
7749class="cmtt-8">&#x00A0;</span><span
7750class="cmtt-8">&#x00A0;</span><span
7751class="cmtt-8">&#x00A0;</span><span
7752class="cmtt-8">&#x00A0;</span><span
7753class="cmtt-8">&#x00A0;</span><span
7754class="cmtt-8">&#x00A0;</span><span
7755class="cmtt-8">&#x00A0;</span><span
7756class="cmtt-8">&#x00A0;</span><span
7757class="cmtt-8">&#x00A0;</span><span
7758class="cmtt-8">&#x00A0;</span><span
7759class="cmsy-8">}</span><br class="fancyvrb" /><a
7760 id="x1-103092r46"></a><span
7761class="cmr-6">46</span><br class="fancyvrb" /><a
7762 id="x1-103094r47"></a><span
7763class="cmr-6">47</span><span
7764class="cmtt-8">&#x00A0;</span><span
7765class="cmtt-8">&#x00A0;</span><span
7766class="cmtt-8">&#x00A0;</span><span
7767class="cmtt-8">&#x00A0;</span><span
7768class="cmtt-8">&#x00A0;</span><span
7769class="cmtt-8">&#x00A0;</span><span
7770class="cmtt-8">&#x00A0;</span><span
7771class="cmtt-8">&#x00A0;</span><span
7772class="cmtt-8">&#x00A0;</span><span
7773class="cmtt-8">&#x00A0;</span><span
7774class="cmtt-8">&#x00A0;</span><span
7775class="cmtt-8">&#x00A0;</span><span
7776class="cmtt-8">&#x00A0;</span><span
7777class="cmtt-8">&#x00A0;</span><span
7778class="cmtt-8">&#x00A0;</span><span
7779class="cmtt-8">&#x00A0;</span><span
7780class="cmsy-8">}</span><span
7781class="cmtt-8">&#x00A0;else</span><span
7782class="cmtt-8">&#x00A0;[val]</span><span
7783class="cmtt-8">&#x00A0;is</span><span
7784class="cmtt-8">&#x00A0;less</span><span
7785class="cmtt-8">&#x00A0;than</span><span
7786class="cmtt-8">&#x00A0;[room]</span><span
7787class="cmtt-8">&#x00A0;</span><span
7788class="cmsy-8">{</span><br class="fancyvrb" /><a
7789 id="x1-103096r48"></a><span
7790class="cmr-6">48</span>
7791 <br class="fancyvrb" /><a
7792 id="x1-103098r49"></a><span
7793class="cmr-6">49</span><span
7794class="cmtt-8">&#x00A0;</span><span
7795class="cmtt-8">&#x00A0;</span><span
7796class="cmtt-8">&#x00A0;</span><span
7797class="cmtt-8">&#x00A0;</span><span
7798class="cmtt-8">&#x00A0;</span><span
7799class="cmtt-8">&#x00A0;</span><span
7800class="cmtt-8">&#x00A0;</span><span
7801class="cmtt-8">&#x00A0;</span><span
7802class="cmtt-8">&#x00A0;</span><span
7803class="cmtt-8">&#x00A0;</span><span
7804class="cmtt-8">&#x00A0;</span><span
7805class="cmtt-8">&#x00A0;</span><span
7806class="cmtt-8">&#x00A0;</span><span
7807class="cmtt-8">&#x00A0;</span><span
7808class="cmtt-8">&#x00A0;</span><span
7809class="cmtt-8">&#x00A0;</span><span
7810class="cmtt-8">&#x00A0;</span><span
7811class="cmtt-8">&#x00A0;</span><span
7812class="cmtt-8">&#x00A0;</span><span
7813class="cmtt-8">&#x00A0;24)</span><span
7814class="cmtt-8">&#x00A0;if</span><span
7815class="cmtt-8">&#x00A0;([val]</span><span
7816class="cmtt-8">&#x00A0;is</span><span
7817class="cmtt-8">&#x00A0;odd)</span><span
7818class="cmtt-8">&#x00A0;</span><span
7819class="cmsy-8">{</span><br class="fancyvrb" /><a
7820 id="x1-103100r50"></a><span
7821class="cmr-6">50</span><br class="fancyvrb" /><a
7822 id="x1-103102r51"></a><span
7823class="cmr-6">51</span><span
7824class="cmtt-8">&#x00A0;</span><span
7825class="cmtt-8">&#x00A0;</span><span
7826class="cmtt-8">&#x00A0;</span><span
7827class="cmtt-8">&#x00A0;</span><span
7828class="cmtt-8">&#x00A0;</span><span
7829class="cmtt-8">&#x00A0;</span><span
7830class="cmtt-8">&#x00A0;</span><span
7831class="cmtt-8">&#x00A0;</span><span
7832class="cmtt-8">&#x00A0;</span><span
7833class="cmtt-8">&#x00A0;</span><span
7834class="cmtt-8">&#x00A0;</span><span
7835class="cmtt-8">&#x00A0;</span><span
7836class="cmtt-8">&#x00A0;</span><span
7837class="cmtt-8">&#x00A0;</span><span
7838class="cmtt-8">&#x00A0;</span><span
7839class="cmtt-8">&#x00A0;</span><span
7840class="cmtt-8">&#x00A0;</span><span
7841class="cmtt-8">&#x00A0;</span><span
7842class="cmtt-8">&#x00A0;</span><span
7843class="cmtt-8">&#x00A0;</span><span
7844class="cmtt-8">&#x00A0;</span><span
7845class="cmtt-8">&#x00A0;</span><span
7846class="cmtt-8">&#x00A0;</span><span
7847class="cmtt-8">&#x00A0;25)</span><span
7848class="cmtt-8">&#x00A0;vector</span><span
7849class="cmtt-8">&#x00A0;[floor1</span><span
7850class="cmtt-8">_final</span><span
7851class="cmtt-8">_Y]</span><span
7852class="cmtt-8">&#x00A0;element</span><span
7853class="cmtt-8">&#x00A0;[i]</span><span
7854class="cmtt-8">&#x00A0;=</span>
7855 <br class="fancyvrb" /><a
7856 id="x1-103104r52"></a><span
7857class="cmr-6">52</span><span
7858class="cmtt-8">&#x00A0;</span><span
7859class="cmtt-8">&#x00A0;</span><span
7860class="cmtt-8">&#x00A0;</span><span
7861class="cmtt-8">&#x00A0;</span><span
7862class="cmtt-8">&#x00A0;</span><span
7863class="cmtt-8">&#x00A0;</span><span
7864class="cmtt-8">&#x00A0;</span><span
7865class="cmtt-8">&#x00A0;</span><span
7866class="cmtt-8">&#x00A0;</span><span
7867class="cmtt-8">&#x00A0;</span><span
7868class="cmtt-8">&#x00A0;</span><span
7869class="cmtt-8">&#x00A0;</span><span
7870class="cmtt-8">&#x00A0;</span><span
7871class="cmtt-8">&#x00A0;</span><span
7872class="cmtt-8">&#x00A0;</span><span
7873class="cmtt-8">&#x00A0;</span><span
7874class="cmtt-8">&#x00A0;</span><span
7875class="cmtt-8">&#x00A0;</span><span
7876class="cmtt-8">&#x00A0;</span><span
7877class="cmtt-8">&#x00A0;</span><span
7878class="cmtt-8">&#x00A0;</span><span
7879class="cmtt-8">&#x00A0;</span><span
7880class="cmtt-8">&#x00A0;</span><span
7881class="cmtt-8">&#x00A0;</span><span
7882class="cmtt-8">&#x00A0;</span><span
7883class="cmtt-8">&#x00A0;</span><span
7884class="cmtt-8">&#x00A0;</span><span
7885class="cmtt-8">&#x00A0;[predicted]</span><span
7886class="cmtt-8">&#x00A0;-</span><span
7887class="cmtt-8">&#x00A0;(([val]</span><span
7888class="cmtt-8">&#x00A0;+</span><span
7889class="cmtt-8">&#x00A0;1)</span><span
7890class="cmtt-8">&#x00A0;divided</span><span
7891class="cmtt-8">&#x00A0;by</span><span
7892class="cmtt-8">&#x00A0;</span><span
7893class="cmtt-8">&#x00A0;2</span><span
7894class="cmtt-8">&#x00A0;using</span><span
7895class="cmtt-8">&#x00A0;integer</span><span
7896class="cmtt-8">&#x00A0;division)</span><br class="fancyvrb" /><a
7897 id="x1-103106r53"></a><span
7898class="cmr-6">53</span>
7899 <br class="fancyvrb" /><a
7900 id="x1-103108r54"></a><span
7901class="cmr-6">54</span><span
7902class="cmtt-8">&#x00A0;</span><span
7903class="cmtt-8">&#x00A0;</span><span
7904class="cmtt-8">&#x00A0;</span><span
7905class="cmtt-8">&#x00A0;</span><span
7906class="cmtt-8">&#x00A0;</span><span
7907class="cmtt-8">&#x00A0;</span><span
7908class="cmtt-8">&#x00A0;</span><span
7909class="cmtt-8">&#x00A0;</span><span
7910class="cmtt-8">&#x00A0;</span><span
7911class="cmtt-8">&#x00A0;</span><span
7912class="cmtt-8">&#x00A0;</span><span
7913class="cmtt-8">&#x00A0;</span><span
7914class="cmtt-8">&#x00A0;</span><span
7915class="cmtt-8">&#x00A0;</span><span
7916class="cmtt-8">&#x00A0;</span><span
7917class="cmtt-8">&#x00A0;</span><span
7918class="cmtt-8">&#x00A0;</span><span
7919class="cmtt-8">&#x00A0;</span><span
7920class="cmtt-8">&#x00A0;</span><span
7921class="cmtt-8">&#x00A0;</span><span
7922class="cmtt-8">&#x00A0;</span><span
7923class="cmtt-8">&#x00A0;</span><span
7924class="cmsy-8">}</span><span
7925class="cmtt-8">&#x00A0;else</span><span
7926class="cmtt-8">&#x00A0;[val]</span><span
7927class="cmtt-8">&#x00A0;is</span><span
7928class="cmtt-8">&#x00A0;even</span><span
7929class="cmtt-8">&#x00A0;</span><span
7930class="cmsy-8">{</span><br class="fancyvrb" /><a
7931 id="x1-103110r55"></a><span
7932class="cmr-6">55</span><br class="fancyvrb" /><a
7933 id="x1-103112r56"></a><span
7934class="cmr-6">56</span><span
7935class="cmtt-8">&#x00A0;</span><span
7936class="cmtt-8">&#x00A0;</span><span
7937class="cmtt-8">&#x00A0;</span><span
7938class="cmtt-8">&#x00A0;</span><span
7939class="cmtt-8">&#x00A0;</span><span
7940class="cmtt-8">&#x00A0;</span><span
7941class="cmtt-8">&#x00A0;</span><span
7942class="cmtt-8">&#x00A0;</span><span
7943class="cmtt-8">&#x00A0;</span><span
7944class="cmtt-8">&#x00A0;</span><span
7945class="cmtt-8">&#x00A0;</span><span
7946class="cmtt-8">&#x00A0;</span><span
7947class="cmtt-8">&#x00A0;</span><span
7948class="cmtt-8">&#x00A0;</span><span
7949class="cmtt-8">&#x00A0;</span><span
7950class="cmtt-8">&#x00A0;</span><span
7951class="cmtt-8">&#x00A0;</span><span
7952class="cmtt-8">&#x00A0;</span><span
7953class="cmtt-8">&#x00A0;</span><span
7954class="cmtt-8">&#x00A0;</span><span
7955class="cmtt-8">&#x00A0;</span><span
7956class="cmtt-8">&#x00A0;</span><span
7957class="cmtt-8">&#x00A0;</span><span
7958class="cmtt-8">&#x00A0;26)</span><span
7959class="cmtt-8">&#x00A0;vector</span><span
7960class="cmtt-8">&#x00A0;[floor1</span><span
7961class="cmtt-8">_final</span><span
7962class="cmtt-8">_Y]</span><span
7963class="cmtt-8">&#x00A0;element</span><span
7964class="cmtt-8">&#x00A0;[i]</span><span
7965class="cmtt-8">&#x00A0;=</span>
7966 <br class="fancyvrb" /><a
7967 id="x1-103114r57"></a><span
7968class="cmr-6">57</span><span
7969class="cmtt-8">&#x00A0;</span><span
7970class="cmtt-8">&#x00A0;</span><span
7971class="cmtt-8">&#x00A0;</span><span
7972class="cmtt-8">&#x00A0;</span><span
7973class="cmtt-8">&#x00A0;</span><span
7974class="cmtt-8">&#x00A0;</span><span
7975class="cmtt-8">&#x00A0;</span><span
7976class="cmtt-8">&#x00A0;</span><span
7977class="cmtt-8">&#x00A0;</span><span
7978class="cmtt-8">&#x00A0;</span><span
7979class="cmtt-8">&#x00A0;</span><span
7980class="cmtt-8">&#x00A0;</span><span
7981class="cmtt-8">&#x00A0;</span><span
7982class="cmtt-8">&#x00A0;</span><span
7983class="cmtt-8">&#x00A0;</span><span
7984class="cmtt-8">&#x00A0;</span><span
7985class="cmtt-8">&#x00A0;</span><span
7986class="cmtt-8">&#x00A0;</span><span
7987class="cmtt-8">&#x00A0;</span><span
7988class="cmtt-8">&#x00A0;</span><span
7989class="cmtt-8">&#x00A0;</span><span
7990class="cmtt-8">&#x00A0;</span><span
7991class="cmtt-8">&#x00A0;</span><span
7992class="cmtt-8">&#x00A0;</span><span
7993class="cmtt-8">&#x00A0;</span><span
7994class="cmtt-8">&#x00A0;</span><span
7995class="cmtt-8">&#x00A0;</span><span
7996class="cmtt-8">&#x00A0;[predicted]</span><span
7997class="cmtt-8">&#x00A0;+</span><span
7998class="cmtt-8">&#x00A0;([val]</span><span
7999class="cmtt-8">&#x00A0;/</span><span
8000class="cmtt-8">&#x00A0;2</span><span
8001class="cmtt-8">&#x00A0;using</span><span
8002class="cmtt-8">&#x00A0;integer</span><span
8003class="cmtt-8">&#x00A0;division)</span><br class="fancyvrb" /><a
8004 id="x1-103116r58"></a><span
8005class="cmr-6">58</span><br class="fancyvrb" /><a
8006 id="x1-103118r59"></a><span
8007class="cmr-6">59</span><span
8008class="cmtt-8">&#x00A0;</span><span
8009class="cmtt-8">&#x00A0;</span><span
8010class="cmtt-8">&#x00A0;</span><span
8011class="cmtt-8">&#x00A0;</span><span
8012class="cmtt-8">&#x00A0;</span><span
8013class="cmtt-8">&#x00A0;</span><span
8014class="cmtt-8">&#x00A0;</span><span
8015class="cmtt-8">&#x00A0;</span><span
8016class="cmtt-8">&#x00A0;</span><span
8017class="cmtt-8">&#x00A0;</span><span
8018class="cmtt-8">&#x00A0;</span><span
8019class="cmtt-8">&#x00A0;</span><span
8020class="cmtt-8">&#x00A0;</span><span
8021class="cmtt-8">&#x00A0;</span><span
8022class="cmtt-8">&#x00A0;</span><span
8023class="cmtt-8">&#x00A0;</span><span
8024class="cmtt-8">&#x00A0;</span><span
8025class="cmtt-8">&#x00A0;</span><span
8026class="cmtt-8">&#x00A0;</span><span
8027class="cmtt-8">&#x00A0;</span><span
8028class="cmtt-8">&#x00A0;</span><span
8029class="cmtt-8">&#x00A0;</span><span
8030class="cmsy-8">}</span><br class="fancyvrb" /><a
8031 id="x1-103120r60"></a><span
8032class="cmr-6">60</span>
8033 <br class="fancyvrb" /><a
8034 id="x1-103122r61"></a><span
8035class="cmr-6">61</span><span
8036class="cmtt-8">&#x00A0;</span><span
8037class="cmtt-8">&#x00A0;</span><span
8038class="cmtt-8">&#x00A0;</span><span
8039class="cmtt-8">&#x00A0;</span><span
8040class="cmtt-8">&#x00A0;</span><span
8041class="cmtt-8">&#x00A0;</span><span
8042class="cmtt-8">&#x00A0;</span><span
8043class="cmtt-8">&#x00A0;</span><span
8044class="cmtt-8">&#x00A0;</span><span
8045class="cmtt-8">&#x00A0;</span><span
8046class="cmtt-8">&#x00A0;</span><span
8047class="cmtt-8">&#x00A0;</span><span
8048class="cmtt-8">&#x00A0;</span><span
8049class="cmtt-8">&#x00A0;</span><span
8050class="cmtt-8">&#x00A0;</span><span
8051class="cmtt-8">&#x00A0;</span><span
8052class="cmsy-8">}</span><br class="fancyvrb" /><a
8053 id="x1-103124r62"></a><span
8054class="cmr-6">62</span><br class="fancyvrb" /><a
8055 id="x1-103126r63"></a><span
8056class="cmr-6">63</span><span
8057class="cmtt-8">&#x00A0;</span><span
8058class="cmtt-8">&#x00A0;</span><span
8059class="cmtt-8">&#x00A0;</span><span
8060class="cmtt-8">&#x00A0;</span><span
8061class="cmtt-8">&#x00A0;</span><span
8062class="cmtt-8">&#x00A0;</span><span
8063class="cmtt-8">&#x00A0;</span><span
8064class="cmtt-8">&#x00A0;</span><span
8065class="cmtt-8">&#x00A0;</span><span
8066class="cmtt-8">&#x00A0;</span><span
8067class="cmsy-8">}</span><span
8068class="cmtt-8">&#x00A0;else</span><span
8069class="cmtt-8">&#x00A0;[val]</span><span
8070class="cmtt-8">&#x00A0;is</span><span
8071class="cmtt-8">&#x00A0;zero</span><span
8072class="cmtt-8">&#x00A0;</span><span
8073class="cmsy-8">{</span><br class="fancyvrb" /><a
8074 id="x1-103128r64"></a><span
8075class="cmr-6">64</span><br class="fancyvrb" /><a
8076 id="x1-103130r65"></a><span
8077class="cmr-6">65</span><span
8078class="cmtt-8">&#x00A0;</span><span
8079class="cmtt-8">&#x00A0;</span><span
8080class="cmtt-8">&#x00A0;</span><span
8081class="cmtt-8">&#x00A0;</span><span
8082class="cmtt-8">&#x00A0;</span><span
8083class="cmtt-8">&#x00A0;</span><span
8084class="cmtt-8">&#x00A0;</span><span
8085class="cmtt-8">&#x00A0;</span><span
8086class="cmtt-8">&#x00A0;</span><span
8087class="cmtt-8">&#x00A0;</span><span
8088class="cmtt-8">&#x00A0;</span><span
8089class="cmtt-8">&#x00A0;27)</span><span
8090class="cmtt-8">&#x00A0;vector</span><span
8091class="cmtt-8">&#x00A0;[floor1</span><span
8092class="cmtt-8">_step2</span><span
8093class="cmtt-8">_flag]</span><span
8094class="cmtt-8">&#x00A0;element</span><span
8095class="cmtt-8">&#x00A0;[i]</span><span
8096class="cmtt-8">&#x00A0;=</span><span
8097class="cmtt-8">&#x00A0;unset</span>
8098 <br class="fancyvrb" /><a
8099 id="x1-103132r66"></a><span
8100class="cmr-6">66</span><span
8101class="cmtt-8">&#x00A0;</span><span
8102class="cmtt-8">&#x00A0;</span><span
8103class="cmtt-8">&#x00A0;</span><span
8104class="cmtt-8">&#x00A0;</span><span
8105class="cmtt-8">&#x00A0;</span><span
8106class="cmtt-8">&#x00A0;</span><span
8107class="cmtt-8">&#x00A0;</span><span
8108class="cmtt-8">&#x00A0;</span><span
8109class="cmtt-8">&#x00A0;</span><span
8110class="cmtt-8">&#x00A0;</span><span
8111class="cmtt-8">&#x00A0;</span><span
8112class="cmtt-8">&#x00A0;28)</span><span
8113class="cmtt-8">&#x00A0;vector</span><span
8114class="cmtt-8">&#x00A0;[floor1</span><span
8115class="cmtt-8">_final</span><span
8116class="cmtt-8">_Y]</span><span
8117class="cmtt-8">&#x00A0;element</span><span
8118class="cmtt-8">&#x00A0;[i]</span><span
8119class="cmtt-8">&#x00A0;=</span><span
8120class="cmtt-8">&#x00A0;[predicted]</span><br class="fancyvrb" /><a
8121 id="x1-103134r67"></a><span
8122class="cmr-6">67</span><br class="fancyvrb" /><a
8123 id="x1-103136r68"></a><span
8124class="cmr-6">68</span><span
8125class="cmtt-8">&#x00A0;</span><span
8126class="cmtt-8">&#x00A0;</span><span
8127class="cmtt-8">&#x00A0;</span><span
8128class="cmtt-8">&#x00A0;</span><span
8129class="cmtt-8">&#x00A0;</span><span
8130class="cmtt-8">&#x00A0;</span><span
8131class="cmtt-8">&#x00A0;</span><span
8132class="cmtt-8">&#x00A0;</span><span
8133class="cmtt-8">&#x00A0;</span><span
8134class="cmtt-8">&#x00A0;</span><span
8135class="cmsy-8">}</span><br class="fancyvrb" /><a
8136 id="x1-103138r69"></a><span
8137class="cmr-6">69</span><br class="fancyvrb" /><a
8138 id="x1-103140r70"></a><span
8139class="cmr-6">70</span><span
8140class="cmtt-8">&#x00A0;</span><span
8141class="cmtt-8">&#x00A0;</span><span
8142class="cmtt-8">&#x00A0;</span><span
8143class="cmtt-8">&#x00A0;</span><span
8144class="cmtt-8">&#x00A0;</span><span
8145class="cmsy-8">}</span><br class="fancyvrb" /><a
8146 id="x1-103142r71"></a><span
8147class="cmr-6">71</span><br class="fancyvrb" /><a
8148 id="x1-103144r72"></a><span
8149class="cmr-6">72</span><span
8150class="cmtt-8">&#x00A0;29)</span><span
8151class="cmtt-8">&#x00A0;done</span><br class="fancyvrb" /><a
8152 id="x1-103146r73"></a><span
8153class="cmr-6">73</span></div>
8154 </dd><dt class="description">
8155<span
8156class="cmssbx-10x-x-120">step 2: curve synthesis</span> </dt><dd
8157class="description">
8158 <!--l. 350--><p class="noindent" >Curve synthesis generates a return vector <span
8159class="cmtt-12">[floor] </span>of length <span
8160class="cmtt-12">[n] </span>(where <span
8161class="cmtt-12">[n] </span>is provided by
8162 the decode process calling to floor decode). Floor 1 curve synthesis makes use of the
8163 <span
8164class="cmtt-12">[floor1</span><span
8165class="cmtt-12">_X</span><span
8166class="cmtt-12">_list]</span>, <span
8167class="cmtt-12">[floor1</span><span
8168class="cmtt-12">_final</span><span
8169class="cmtt-12">_Y] </span>and <span
8170class="cmtt-12">[floor1</span><span
8171class="cmtt-12">_step2</span><span
8172class="cmtt-12">_flag] </span>vectors, as well as
8173 [floor1_multiplier] and [floor1_values] values.
8174 <!--l. 357--><p class="noindent" >Decode begins by sorting the scalars from vectors <span
8175class="cmtt-12">[floor1</span><span
8176class="cmtt-12">_X</span><span
8177class="cmtt-12">_list]</span>, <span
8178class="cmtt-12">[floor1</span><span
8179class="cmtt-12">_final</span><span
8180class="cmtt-12">_Y] </span>and
8181 <span
8182class="cmtt-12">[floor1</span><span
8183class="cmtt-12">_step2</span><span
8184class="cmtt-12">_flag] </span>together into new vectors <span
8185class="cmtt-12">[floor1</span><span
8186class="cmtt-12">_X</span><span
8187class="cmtt-12">_list]&#8217;</span>, <span
8188class="cmtt-12">[floor1</span><span
8189class="cmtt-12">_final</span><span
8190class="cmtt-12">_Y]&#8217;</span>
8191 and <span
8192class="cmtt-12">[floor1</span><span
8193class="cmtt-12">_step2</span><span
8194class="cmtt-12">_flag]&#8217; </span>according to ascending sort order of the values in
8195 <span
8196class="cmtt-12">[floor1</span><span
8197class="cmtt-12">_X</span><span
8198class="cmtt-12">_list]</span>. That is, sort the values of <span
8199class="cmtt-12">[floor1</span><span
8200class="cmtt-12">_X</span><span
8201class="cmtt-12">_list] </span>and then apply the same
8202 permutation to elements of the other two vectors so that the X, Y and step2_flag values
8203 still match.
8204 <!--l. 367--><p class="noindent" >Then compute the final curve in one pass:
8205 <!--l. 369--><p class="noindent" >
8206 <div class="fancyvrb" id="fancyvrb32"><a
8207 id="x1-103148r1"></a><span
8208class="cmr-6">1</span><span
8209class="cmtt-8">&#x00A0;</span><span
8210class="cmtt-8">&#x00A0;1)</span><span
8211class="cmtt-8">&#x00A0;[hx]</span><span
8212class="cmtt-8">&#x00A0;=</span><span
8213class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
8214 id="x1-103150r2"></a><span
8215class="cmr-6">2</span><span
8216class="cmtt-8">&#x00A0;</span><span
8217class="cmtt-8">&#x00A0;2)</span><span
8218class="cmtt-8">&#x00A0;[lx]</span><span
8219class="cmtt-8">&#x00A0;=</span><span
8220class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
8221 id="x1-103152r3"></a><span
8222class="cmr-6">3</span><span
8223class="cmtt-8">&#x00A0;</span><span
8224class="cmtt-8">&#x00A0;3)</span><span
8225class="cmtt-8">&#x00A0;[ly]</span><span
8226class="cmtt-8">&#x00A0;=</span><span
8227class="cmtt-8">&#x00A0;vector</span><span
8228class="cmtt-8">&#x00A0;[floor1</span><span
8229class="cmtt-8">_final</span><span
8230class="cmtt-8">_Y]&#8217;</span><span
8231class="cmtt-8">&#x00A0;element</span><span
8232class="cmtt-8">&#x00A0;[0]</span><span
8233class="cmtt-8">&#x00A0;*</span><span
8234class="cmtt-8">&#x00A0;[floor1</span><span
8235class="cmtt-8">_multiplier]</span>
8236 <br class="fancyvrb" /><a
8237 id="x1-103154r4"></a><span
8238class="cmr-6">4</span><span
8239class="cmtt-8">&#x00A0;</span><span
8240class="cmtt-8">&#x00A0;4)</span><span
8241class="cmtt-8">&#x00A0;iterate</span><span
8242class="cmtt-8">&#x00A0;[i]</span><span
8243class="cmtt-8">&#x00A0;over</span><span
8244class="cmtt-8">&#x00A0;the</span><span
8245class="cmtt-8">&#x00A0;range</span><span
8246class="cmtt-8">&#x00A0;1</span><span
8247class="cmtt-8">&#x00A0;...</span><span
8248class="cmtt-8">&#x00A0;[floor1</span><span
8249class="cmtt-8">_values]-1</span><span
8250class="cmtt-8">&#x00A0;</span><span
8251class="cmsy-8">{</span><br class="fancyvrb" /><a
8252 id="x1-103156r5"></a><span
8253class="cmr-6">5</span><br class="fancyvrb" /><a
8254 id="x1-103158r6"></a><span
8255class="cmr-6">6</span><span
8256class="cmtt-8">&#x00A0;</span><span
8257class="cmtt-8">&#x00A0;</span><span
8258class="cmtt-8">&#x00A0;</span><span
8259class="cmtt-8">&#x00A0;</span><span
8260class="cmtt-8">&#x00A0;</span><span
8261class="cmtt-8">&#x00A0;</span><span
8262class="cmtt-8">&#x00A0;5)</span><span
8263class="cmtt-8">&#x00A0;if</span><span
8264class="cmtt-8">&#x00A0;(</span><span
8265class="cmtt-8">&#x00A0;[floor1</span><span
8266class="cmtt-8">_step2</span><span
8267class="cmtt-8">_flag]&#8217;</span><span
8268class="cmtt-8">&#x00A0;element</span><span
8269class="cmtt-8">&#x00A0;[i]</span><span
8270class="cmtt-8">&#x00A0;is</span><span
8271class="cmtt-8">&#x00A0;set</span><span
8272class="cmtt-8">&#x00A0;)</span><span
8273class="cmtt-8">&#x00A0;</span><span
8274class="cmsy-8">{</span><br class="fancyvrb" /><a
8275 id="x1-103160r7"></a><span
8276class="cmr-6">7</span>
8277 <br class="fancyvrb" /><a
8278 id="x1-103162r8"></a><span
8279class="cmr-6">8</span><span
8280class="cmtt-8">&#x00A0;</span><span
8281class="cmtt-8">&#x00A0;</span><span
8282class="cmtt-8">&#x00A0;</span><span
8283class="cmtt-8">&#x00A0;</span><span
8284class="cmtt-8">&#x00A0;</span><span
8285class="cmtt-8">&#x00A0;</span><span
8286class="cmtt-8">&#x00A0;</span><span
8287class="cmtt-8">&#x00A0;</span><span
8288class="cmtt-8">&#x00A0;</span><span
8289class="cmtt-8">&#x00A0;</span><span
8290class="cmtt-8">&#x00A0;</span><span
8291class="cmtt-8">&#x00A0;</span><span
8292class="cmtt-8">&#x00A0;6)</span><span
8293class="cmtt-8">&#x00A0;[hy]</span><span
8294class="cmtt-8">&#x00A0;=</span><span
8295class="cmtt-8">&#x00A0;[floor1</span><span
8296class="cmtt-8">_final</span><span
8297class="cmtt-8">_Y]&#8217;</span><span
8298class="cmtt-8">&#x00A0;element</span><span
8299class="cmtt-8">&#x00A0;[i]</span><span
8300class="cmtt-8">&#x00A0;*</span><span
8301class="cmtt-8">&#x00A0;[floor1</span><span
8302class="cmtt-8">_multiplier]</span><br class="fancyvrb" /><a
8303 id="x1-103164r9"></a><span
8304class="cmr-6">9</span><span
8305class="cmtt-8">&#x00A0; </span><span
8306class="cmtt-8">&#x00A0;</span><span
8307class="cmtt-8">&#x00A0;</span><span
8308class="cmtt-8">&#x00A0;</span><span
8309class="cmtt-8">&#x00A0;</span><span
8310class="cmtt-8">&#x00A0;7)</span><span
8311class="cmtt-8">&#x00A0;[hx]</span><span
8312class="cmtt-8">&#x00A0;=</span><span
8313class="cmtt-8">&#x00A0;[floor1</span><span
8314class="cmtt-8">_X</span><span
8315class="cmtt-8">_list]&#8217;</span><span
8316class="cmtt-8">&#x00A0;element</span><span
8317class="cmtt-8">&#x00A0;[i]</span>
8318 <br class="fancyvrb" /><a
8319 id="x1-103166r10"></a><span
8320class="cmr-6">10</span><span
8321class="cmtt-8">&#x00A0;</span><span
8322class="cmtt-8">&#x00A0;</span><span
8323class="cmtt-8">&#x00A0;</span><span
8324class="cmtt-8">&#x00A0;</span><span
8325class="cmtt-8">&#x00A0;</span><span
8326class="cmtt-8">&#x00A0;</span><span
8327class="cmtt-8">&#x00A0;</span><span
8328class="cmtt-8">&#x00A0;</span><span
8329class="cmtt-8">&#x00A0;</span><span
8330class="cmtt-8">&#x00A0;</span><span
8331class="cmtt-8">&#x00A0;</span><span
8332class="cmtt-8">&#x00A0;</span><span
8333class="cmtt-8">&#x00A0;8)</span><span
8334class="cmtt-8">&#x00A0;</span><a
8335href="#x1-1250009.2.7"><span
8336class="cmtt-8">render</span><span
8337class="cmtt-8">_line</span></a><span
8338class="cmtt-8">(</span><span
8339class="cmtt-8">&#x00A0;[lx],</span><span
8340class="cmtt-8">&#x00A0;[ly],</span><span
8341class="cmtt-8">&#x00A0;[hx],</span><span
8342class="cmtt-8">&#x00A0;[hy],</span><span
8343class="cmtt-8">&#x00A0;[floor]</span><span
8344class="cmtt-8">&#x00A0;)</span><br class="fancyvrb" /><a
8345 id="x1-103168r11"></a><span
8346class="cmr-6">11</span><span
8347class="cmtt-8">&#x00A0;</span><span
8348class="cmtt-8">&#x00A0;</span><span
8349class="cmtt-8">&#x00A0;</span><span
8350class="cmtt-8">&#x00A0;</span><span
8351class="cmtt-8">&#x00A0;</span><span
8352class="cmtt-8">&#x00A0;</span><span
8353class="cmtt-8">&#x00A0;</span><span
8354class="cmtt-8">&#x00A0;</span><span
8355class="cmtt-8">&#x00A0;</span><span
8356class="cmtt-8">&#x00A0;</span><span
8357class="cmtt-8">&#x00A0;</span><span
8358class="cmtt-8">&#x00A0;</span><span
8359class="cmtt-8">&#x00A0;9)</span><span
8360class="cmtt-8">&#x00A0;[lx]</span><span
8361class="cmtt-8">&#x00A0;=</span><span
8362class="cmtt-8">&#x00A0;[hx]</span><br class="fancyvrb" /><a
8363 id="x1-103170r12"></a><span
8364class="cmr-6">12</span> <span
8365class="cmtt-8">&#x00A0;</span><span
8366class="cmtt-8">&#x00A0;</span><span
8367class="cmtt-8">&#x00A0;</span><span
8368class="cmtt-8">&#x00A0;10)</span><span
8369class="cmtt-8">&#x00A0;[ly]</span><span
8370class="cmtt-8">&#x00A0;=</span><span
8371class="cmtt-8">&#x00A0;[hy]</span><br class="fancyvrb" /><a
8372 id="x1-103172r13"></a><span
8373class="cmr-6">13</span><span
8374class="cmtt-8">&#x00A0;</span><span
8375class="cmtt-8">&#x00A0;</span><span
8376class="cmtt-8">&#x00A0;</span><span
8377class="cmtt-8">&#x00A0;</span><span
8378class="cmtt-8">&#x00A0;</span><span
8379class="cmtt-8">&#x00A0;</span><span
8380class="cmtt-8">&#x00A0;</span><span
8381class="cmtt-8">&#x00A0;</span><span
8382class="cmtt-8">&#x00A0;</span><span
8383class="cmtt-8">&#x00A0;</span><span
8384class="cmsy-8">}</span><br class="fancyvrb" /><a
8385 id="x1-103174r14"></a><span
8386class="cmr-6">14</span><span
8387class="cmtt-8">&#x00A0;</span><span
8388class="cmtt-8">&#x00A0;</span><span
8389class="cmtt-8">&#x00A0;</span><span
8390class="cmtt-8">&#x00A0;</span><span
8391class="cmtt-8">&#x00A0;</span><span
8392class="cmsy-8">}</span><br class="fancyvrb" /><a
8393 id="x1-103176r15"></a><span
8394class="cmr-6">15</span>
8395 <br class="fancyvrb" /><a
8396 id="x1-103178r16"></a><span
8397class="cmr-6">16</span><span
8398class="cmtt-8">&#x00A0;11)</span><span
8399class="cmtt-8">&#x00A0;if</span><span
8400class="cmtt-8">&#x00A0;(</span><span
8401class="cmtt-8">&#x00A0;[hx]</span><span
8402class="cmtt-8">&#x00A0;is</span><span
8403class="cmtt-8">&#x00A0;less</span><span
8404class="cmtt-8">&#x00A0;than</span><span
8405class="cmtt-8">&#x00A0;[n]</span><span
8406class="cmtt-8">&#x00A0;)</span><span
8407class="cmtt-8">&#x00A0;</span><span
8408class="cmsy-8">{</span><br class="fancyvrb" /><a
8409 id="x1-103180r17"></a><span
8410class="cmr-6">17</span><br class="fancyvrb" /><a
8411 id="x1-103182r18"></a><span
8412class="cmr-6">18</span><span
8413class="cmtt-8">&#x00A0;</span><span
8414class="cmtt-8">&#x00A0;</span><span
8415class="cmtt-8">&#x00A0;</span><span
8416class="cmtt-8">&#x00A0;</span><span
8417class="cmtt-8">&#x00A0;</span><span
8418class="cmtt-8">&#x00A0;</span><span
8419class="cmtt-8">&#x00A0;</span><span
8420class="cmtt-8">&#x00A0;12)</span><span
8421class="cmtt-8">&#x00A0;</span><a
8422href="#x1-1250009.2.7"><span
8423class="cmtt-8">render</span><span
8424class="cmtt-8">_line</span></a><span
8425class="cmtt-8">(</span><span
8426class="cmtt-8">&#x00A0;[hx],</span><span
8427class="cmtt-8">&#x00A0;[hy],</span><span
8428class="cmtt-8">&#x00A0;[n],</span><span
8429class="cmtt-8">&#x00A0;[hy],</span><span
8430class="cmtt-8">&#x00A0;[floor]</span><span
8431class="cmtt-8">&#x00A0;)</span><br class="fancyvrb" /><a
8432 id="x1-103184r19"></a><span
8433class="cmr-6">19</span><br class="fancyvrb" /><a
8434 id="x1-103186r20"></a><span
8435class="cmr-6">20</span><span
8436class="cmtt-8">&#x00A0;</span><span
8437class="cmtt-8">&#x00A0;</span><span
8438class="cmtt-8">&#x00A0;</span><span
8439class="cmtt-8">&#x00A0;</span><span
8440class="cmtt-8">&#x00A0;</span><span
8441class="cmsy-8">}</span><br class="fancyvrb" /><a
8442 id="x1-103188r21"></a><span
8443class="cmr-6">21</span><br class="fancyvrb" /><a
8444 id="x1-103190r22"></a><span
8445class="cmr-6">22</span><span
8446class="cmtt-8">&#x00A0;13)</span><span
8447class="cmtt-8">&#x00A0;if</span><span
8448class="cmtt-8">&#x00A0;(</span><span
8449class="cmtt-8">&#x00A0;[hx]</span><span
8450class="cmtt-8">&#x00A0;is</span><span
8451class="cmtt-8">&#x00A0;greater</span><span
8452class="cmtt-8">&#x00A0;than</span><span
8453class="cmtt-8">&#x00A0;[n]</span><span
8454class="cmtt-8">&#x00A0;)</span><span
8455class="cmtt-8">&#x00A0;</span><span
8456class="cmsy-8">{</span><br class="fancyvrb" /><a
8457 id="x1-103192r23"></a><span
8458class="cmr-6">23</span>
8459 <br class="fancyvrb" /><a
8460 id="x1-103194r24"></a><span
8461class="cmr-6">24</span><span
8462class="cmtt-8">&#x00A0;</span><span
8463class="cmtt-8">&#x00A0;</span><span
8464class="cmtt-8">&#x00A0;</span><span
8465class="cmtt-8">&#x00A0;</span><span
8466class="cmtt-8">&#x00A0;</span><span
8467class="cmtt-8">&#x00A0;</span><span
8468class="cmtt-8">&#x00A0;</span><span
8469class="cmtt-8">&#x00A0;</span><span
8470class="cmtt-8">&#x00A0;</span><span
8471class="cmtt-8">&#x00A0;</span><span
8472class="cmtt-8">&#x00A0;</span><span
8473class="cmtt-8">&#x00A0;14)</span><span
8474class="cmtt-8">&#x00A0;truncate</span><span
8475class="cmtt-8">&#x00A0;vector</span><span
8476class="cmtt-8">&#x00A0;[floor]</span><span
8477class="cmtt-8">&#x00A0;to</span><span
8478class="cmtt-8">&#x00A0;[n]</span><span
8479class="cmtt-8">&#x00A0;elements</span><br class="fancyvrb" /><a
8480 id="x1-103196r25"></a><span
8481class="cmr-6">25</span><br class="fancyvrb" /><a
8482 id="x1-103198r26"></a><span
8483class="cmr-6">26</span><span
8484class="cmtt-8">&#x00A0;</span><span
8485class="cmtt-8">&#x00A0;</span><span
8486class="cmtt-8">&#x00A0;</span><span
8487class="cmtt-8">&#x00A0;</span><span
8488class="cmtt-8">&#x00A0;</span><span
8489class="cmsy-8">}</span><br class="fancyvrb" /><a
8490 id="x1-103200r27"></a><span
8491class="cmr-6">27</span><br class="fancyvrb" /><a
8492 id="x1-103202r28"></a><span
8493class="cmr-6">28</span><span
8494class="cmtt-8">&#x00A0;15)</span><span
8495class="cmtt-8">&#x00A0;for</span><span
8496class="cmtt-8">&#x00A0;each</span><span
8497class="cmtt-8">&#x00A0;scalar</span><span
8498class="cmtt-8">&#x00A0;in</span><span
8499class="cmtt-8">&#x00A0;vector</span><span
8500class="cmtt-8">&#x00A0;[floor],</span><span
8501class="cmtt-8">&#x00A0;perform</span><span
8502class="cmtt-8">&#x00A0;a</span><span
8503class="cmtt-8">&#x00A0;lookup</span><span
8504class="cmtt-8">&#x00A0;substitution</span><span
8505class="cmtt-8">&#x00A0;using</span>
8506 <br class="fancyvrb" /><a
8507 id="x1-103204r29"></a><span
8508class="cmr-6">29</span><span
8509class="cmtt-8">&#x00A0;</span><span
8510class="cmtt-8">&#x00A0;</span><span
8511class="cmtt-8">&#x00A0;</span><span
8512class="cmtt-8">&#x00A0;</span><span
8513class="cmtt-8">&#x00A0;the</span><span
8514class="cmtt-8">&#x00A0;scalar</span><span
8515class="cmtt-8">&#x00A0;value</span><span
8516class="cmtt-8">&#x00A0;from</span><span
8517class="cmtt-8">&#x00A0;[floor]</span><span
8518class="cmtt-8">&#x00A0;as</span><span
8519class="cmtt-8">&#x00A0;an</span><span
8520class="cmtt-8">&#x00A0;offset</span><span
8521class="cmtt-8">&#x00A0;into</span><span
8522class="cmtt-8">&#x00A0;the</span><span
8523class="cmtt-8">&#x00A0;vector</span><span
8524class="cmtt-8">&#x00A0;</span><a
8525href="#x1-12700010.1"><span
8526class="cmtt-8">[floor1</span><span
8527class="cmtt-8">_inverse</span><span
8528class="cmtt-8">_dB</span><span
8529class="cmtt-8">_static</span><span
8530class="cmtt-8">_table]</span></a><br class="fancyvrb" /><a
8531 id="x1-103206r30"></a><span
8532class="cmr-6">30</span><br class="fancyvrb" /><a
8533 id="x1-103208r31"></a><span
8534class="cmr-6">31</span><span
8535class="cmtt-8">&#x00A0;16)</span><span
8536class="cmtt-8">&#x00A0;done</span><br class="fancyvrb" /><a
8537 id="x1-103210r32"></a><span
8538class="cmr-6">32</span></div>
8539 </dd></dl>
8540
8541
8542
8543<h3 class="sectionHead"><span class="titlemark">8. </span> <a
8544 id="x1-1040008"></a>Residue setup and decode</h3>
8545<!--l. 5--><p class="noindent" >
8546<h4 class="subsectionHead"><span class="titlemark">8.1. </span> <a
8547 id="x1-1050008.1"></a>Overview</h4>
8548<!--l. 7--><p class="noindent" >A residue vector represents the fine detail of the audio spectrum of one channel in an audio frame
8549after the encoder subtracts the floor curve and performs any channel coupling. A residue vector
8550may represent spectral lines, spectral magnitude, spectral phase or hybrids as mixed by channel
8551coupling. The exact semantic content of the vector does not matter to the residue
8552abstraction.
8553<!--l. 14--><p class="noindent" >Whatever the exact qualities, the Vorbis residue abstraction codes the residue vectors into the
8554bitstream packet, and then reconstructs the vectors during decode. Vorbis makes use of three
8555different encoding variants (numbered 0, 1 and 2) of the same basic vector encoding
8556abstraction.
8557<!--l. 22--><p class="noindent" >
8558<h4 class="subsectionHead"><span class="titlemark">8.2. </span> <a
8559 id="x1-1060008.2"></a>Residue format</h4>
8560<!--l. 24--><p class="noindent" >Residue format partitions each vector in the vector bundle into chunks, classifies each
8561chunk, encodes the chunk classifications and finally encodes the chunks themselves
8562using the the specific VQ arrangement defined for each selected classification. The
8563exact interleaving and partitioning vary by residue encoding number, however the
8564high-level process used to classify and encode the residue vector is the same in all three
8565variants.
8566<!--l. 32--><p class="noindent" >A set of coded residue vectors are all of the same length. High level coding structure, ignoring for
8567the moment exactly how a partition is encoded and simply trusting that it is, is as
8568follows:
8569 <ul class="itemize1">
8570 <li class="itemize">Each vector is partitioned into multiple equal sized chunks according to configuration
8571 specified. If we have a vector size of <span
8572class="cmti-12">n</span>, a partition size <span
8573class="cmti-12">residue</span><span
8574class="cmti-12">_partition</span><span
8575class="cmti-12">_size</span>,
8576 and a total of <span
8577class="cmti-12">ch </span>residue vectors, the total number of partitioned chunks coded
8578
8579
8580
8581 is <span
8582class="cmti-12">n</span>/<span
8583class="cmti-12">residue</span><span
8584class="cmti-12">_partition</span><span
8585class="cmti-12">_size</span>*<span
8586class="cmti-12">ch</span>. It is important to note that the integer division
8587 truncates. In the below example, we assume an example <span
8588class="cmti-12">residue</span><span
8589class="cmti-12">_partition</span><span
8590class="cmti-12">_size </span>of 8.
8591 </li>
8592 <li class="itemize">Each partition in each vector has a classification number that specifies which of
8593 multiple configured VQ codebook setups are used to decode that partition. The
8594 classification numbers of each partition can be thought of as forming a vector in
8595 their own right, as in the illustration below. Just as the residue vectors are coded
8596 in grouped partitions to increase encoding efficiency, the classification vector is also
8597 partitioned into chunks. The integer elements of each scalar in a classification chunk
8598 are built into a single scalar that represents the classification numbers in that chunk.
8599 In the below example, the classification codeword encodes two classification numbers.
8600 </li>
8601 <li class="itemize">The values in a residue vector may be encoded monolithically in a single pass through
8602 the residue vector, but more often efficient codebook design dictates that each vector
8603 is encoded as the additive sum of several passes through the residue vector using
8604 more than one VQ codebook. Thus, each residue value potentially accumulates values
8605 from multiple decode passes. The classification value associated with a partition is
8606 the same in each pass, thus the classification codeword is coded only in the first pass.
8607 </li></ul>
8608<div class="center"
8609>
8610<!--l. 69--><p class="noindent" >
8611
8612<!--l. 70--><p class="noindent" ><img
8613src="residue-pack.png" alt="PIC"
8614>
8615<br /> <div class="caption"
8616><span class="id">Figure&#x00A0;11: </span><span
8617class="content">illustration of residue vector format</span></div><!--tex4ht:label?: x1-10600111 -->
8618</div>
8619<!--l. 76--><p class="noindent" >
8620<h4 class="subsectionHead"><span class="titlemark">8.3. </span> <a
8621 id="x1-1070008.3"></a>residue 0</h4>
8622<!--l. 78--><p class="noindent" >Residue 0 and 1 differ only in the way the values within a residue partition are interleaved during
8623partition encoding (visually treated as a black box&#8211;or cyan box or brown box&#8211;in the above
8624figure).
8625<!--l. 82--><p class="noindent" >Residue encoding 0 interleaves VQ encoding according to the dimension of the codebook used to
8626
8627
8628
8629encode a partition in a specific pass. The dimension of the codebook need not be the same in
8630multiple passes, however the partition size must be an even multiple of the codebook
8631dimension.
8632<!--l. 88--><p class="noindent" >As an example, assume a partition vector of size eight, to be encoded by residue 0 using
8633codebook sizes of 8, 4, 2 and 1:
8634<!--l. 91--><p class="noindent" >
8635<div class="fancyvrb" id="fancyvrb33"><a
8636 id="x1-107002r1"></a><span
8637class="cmr-6">1</span><br class="fancyvrb" /><a
8638 id="x1-107004r2"></a><span
8639class="cmr-6">2</span><span
8640class="cmtt-8">&#x00A0;</span><span
8641class="cmtt-8">&#x00A0;</span><span
8642class="cmtt-8">&#x00A0;</span><span
8643class="cmtt-8">&#x00A0;</span><span
8644class="cmtt-8">&#x00A0;</span><span
8645class="cmtt-8">&#x00A0;</span><span
8646class="cmtt-8">&#x00A0;</span><span
8647class="cmtt-8">&#x00A0;</span><span
8648class="cmtt-8">&#x00A0;</span><span
8649class="cmtt-8">&#x00A0;</span><span
8650class="cmtt-8">&#x00A0;</span><span
8651class="cmtt-8">&#x00A0;original</span><span
8652class="cmtt-8">&#x00A0;residue</span><span
8653class="cmtt-8">&#x00A0;vector:</span><span
8654class="cmtt-8">&#x00A0;[</span><span
8655class="cmtt-8">&#x00A0;0</span><span
8656class="cmtt-8">&#x00A0;1</span><span
8657class="cmtt-8">&#x00A0;2</span><span
8658class="cmtt-8">&#x00A0;3</span><span
8659class="cmtt-8">&#x00A0;4</span><span
8660class="cmtt-8">&#x00A0;5</span><span
8661class="cmtt-8">&#x00A0;6</span><span
8662class="cmtt-8">&#x00A0;7</span><span
8663class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8664 id="x1-107006r3"></a><span
8665class="cmr-6">3</span><br class="fancyvrb" /><a
8666 id="x1-107008r4"></a><span
8667class="cmr-6">4</span><span
8668class="cmtt-8">codebook</span><span
8669class="cmtt-8">&#x00A0;dimensions</span><span
8670class="cmtt-8">&#x00A0;=</span><span
8671class="cmtt-8">&#x00A0;8</span><span
8672class="cmtt-8">&#x00A0;</span><span
8673class="cmtt-8">&#x00A0;encoded</span><span
8674class="cmtt-8">&#x00A0;as:</span><span
8675class="cmtt-8">&#x00A0;[</span><span
8676class="cmtt-8">&#x00A0;0</span><span
8677class="cmtt-8">&#x00A0;1</span><span
8678class="cmtt-8">&#x00A0;2</span><span
8679class="cmtt-8">&#x00A0;3</span><span
8680class="cmtt-8">&#x00A0;4</span><span
8681class="cmtt-8">&#x00A0;5</span><span
8682class="cmtt-8">&#x00A0;6</span><span
8683class="cmtt-8">&#x00A0;7</span><span
8684class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8685 id="x1-107010r5"></a><span
8686class="cmr-6">5</span>
8687<br class="fancyvrb" /><a
8688 id="x1-107012r6"></a><span
8689class="cmr-6">6</span><span
8690class="cmtt-8">codebook</span><span
8691class="cmtt-8">&#x00A0;dimensions</span><span
8692class="cmtt-8">&#x00A0;=</span><span
8693class="cmtt-8">&#x00A0;4</span><span
8694class="cmtt-8">&#x00A0;</span><span
8695class="cmtt-8">&#x00A0;encoded</span><span
8696class="cmtt-8">&#x00A0;as:</span><span
8697class="cmtt-8">&#x00A0;[</span><span
8698class="cmtt-8">&#x00A0;0</span><span
8699class="cmtt-8">&#x00A0;2</span><span
8700class="cmtt-8">&#x00A0;4</span><span
8701class="cmtt-8">&#x00A0;6</span><span
8702class="cmtt-8">&#x00A0;],</span><span
8703class="cmtt-8">&#x00A0;[</span><span
8704class="cmtt-8">&#x00A0;1</span><span
8705class="cmtt-8">&#x00A0;3</span><span
8706class="cmtt-8">&#x00A0;5</span><span
8707class="cmtt-8">&#x00A0;7</span><span
8708class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8709 id="x1-107014r7"></a><span
8710class="cmr-6">7</span><br class="fancyvrb" /><a
8711 id="x1-107016r8"></a><span
8712class="cmr-6">8</span><span
8713class="cmtt-8">codebook</span><span
8714class="cmtt-8">&#x00A0;dimensions</span><span
8715class="cmtt-8">&#x00A0;=</span><span
8716class="cmtt-8">&#x00A0;2</span><span
8717class="cmtt-8">&#x00A0;</span><span
8718class="cmtt-8">&#x00A0;encoded</span><span
8719class="cmtt-8">&#x00A0;as:</span><span
8720class="cmtt-8">&#x00A0;[</span><span
8721class="cmtt-8">&#x00A0;0</span><span
8722class="cmtt-8">&#x00A0;4</span><span
8723class="cmtt-8">&#x00A0;],</span><span
8724class="cmtt-8">&#x00A0;[</span><span
8725class="cmtt-8">&#x00A0;1</span><span
8726class="cmtt-8">&#x00A0;5</span><span
8727class="cmtt-8">&#x00A0;],</span><span
8728class="cmtt-8">&#x00A0;[</span><span
8729class="cmtt-8">&#x00A0;2</span><span
8730class="cmtt-8">&#x00A0;6</span><span
8731class="cmtt-8">&#x00A0;],</span><span
8732class="cmtt-8">&#x00A0;[</span><span
8733class="cmtt-8">&#x00A0;3</span><span
8734class="cmtt-8">&#x00A0;7</span><span
8735class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8736 id="x1-107018r9"></a><span
8737class="cmr-6">9</span>
8738<br class="fancyvrb" /><a
8739 id="x1-107020r10"></a><span
8740class="cmr-6">10</span><span
8741class="cmtt-8">codebook</span><span
8742class="cmtt-8">&#x00A0;dimensions</span><span
8743class="cmtt-8">&#x00A0;=</span><span
8744class="cmtt-8">&#x00A0;1</span><span
8745class="cmtt-8">&#x00A0;</span><span
8746class="cmtt-8">&#x00A0;encoded</span><span
8747class="cmtt-8">&#x00A0;as:</span><span
8748class="cmtt-8">&#x00A0;[</span><span
8749class="cmtt-8">&#x00A0;0</span><span
8750class="cmtt-8">&#x00A0;],</span><span
8751class="cmtt-8">&#x00A0;[</span><span
8752class="cmtt-8">&#x00A0;1</span><span
8753class="cmtt-8">&#x00A0;],</span><span
8754class="cmtt-8">&#x00A0;[</span><span
8755class="cmtt-8">&#x00A0;2</span><span
8756class="cmtt-8">&#x00A0;],</span><span
8757class="cmtt-8">&#x00A0;[</span><span
8758class="cmtt-8">&#x00A0;3</span><span
8759class="cmtt-8">&#x00A0;],</span><span
8760class="cmtt-8">&#x00A0;[</span><span
8761class="cmtt-8">&#x00A0;4</span><span
8762class="cmtt-8">&#x00A0;],</span><span
8763class="cmtt-8">&#x00A0;[</span><span
8764class="cmtt-8">&#x00A0;5</span><span
8765class="cmtt-8">&#x00A0;],</span><span
8766class="cmtt-8">&#x00A0;[</span><span
8767class="cmtt-8">&#x00A0;6</span><span
8768class="cmtt-8">&#x00A0;],</span><span
8769class="cmtt-8">&#x00A0;[</span><span
8770class="cmtt-8">&#x00A0;7</span><span
8771class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8772 id="x1-107022r11"></a><span
8773class="cmr-6">11</span></div>
8774<!--l. 105--><p class="noindent" >It is worth mentioning at this point that no configurable value in the residue coding setup is
8775restricted to a power of two.
8776<!--l. 110--><p class="noindent" >
8777<h4 class="subsectionHead"><span class="titlemark">8.4. </span> <a
8778 id="x1-1080008.4"></a>residue 1</h4>
8779<!--l. 112--><p class="noindent" >Residue 1 does not interleave VQ encoding. It represents partition vector scalars in order. As
8780with residue 0, however, partition length must be an integer multiple of the codebook dimension,
8781although dimension may vary from pass to pass.
8782<!--l. 117--><p class="noindent" >As an example, assume a partition vector of size eight, to be encoded by residue 0 using
8783codebook sizes of 8, 4, 2 and 1:
8784<!--l. 120--><p class="noindent" >
8785<div class="fancyvrb" id="fancyvrb34"><a
8786 id="x1-108002r1"></a><span
8787class="cmr-6">1</span><br class="fancyvrb" /><a
8788 id="x1-108004r2"></a><span
8789class="cmr-6">2</span><span
8790class="cmtt-8">&#x00A0;</span><span
8791class="cmtt-8">&#x00A0;</span><span
8792class="cmtt-8">&#x00A0;</span><span
8793class="cmtt-8">&#x00A0;</span><span
8794class="cmtt-8">&#x00A0;</span><span
8795class="cmtt-8">&#x00A0;</span><span
8796class="cmtt-8">&#x00A0;</span><span
8797class="cmtt-8">&#x00A0;</span><span
8798class="cmtt-8">&#x00A0;</span><span
8799class="cmtt-8">&#x00A0;</span><span
8800class="cmtt-8">&#x00A0;</span><span
8801class="cmtt-8">&#x00A0;original</span><span
8802class="cmtt-8">&#x00A0;residue</span><span
8803class="cmtt-8">&#x00A0;vector:</span><span
8804class="cmtt-8">&#x00A0;[</span><span
8805class="cmtt-8">&#x00A0;0</span><span
8806class="cmtt-8">&#x00A0;1</span><span
8807class="cmtt-8">&#x00A0;2</span><span
8808class="cmtt-8">&#x00A0;3</span><span
8809class="cmtt-8">&#x00A0;4</span><span
8810class="cmtt-8">&#x00A0;5</span><span
8811class="cmtt-8">&#x00A0;6</span><span
8812class="cmtt-8">&#x00A0;7</span><span
8813class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8814 id="x1-108006r3"></a><span
8815class="cmr-6">3</span><br class="fancyvrb" /><a
8816 id="x1-108008r4"></a><span
8817class="cmr-6">4</span><span
8818class="cmtt-8">codebook</span><span
8819class="cmtt-8">&#x00A0;dimensions</span><span
8820class="cmtt-8">&#x00A0;=</span><span
8821class="cmtt-8">&#x00A0;8</span><span
8822class="cmtt-8">&#x00A0;</span><span
8823class="cmtt-8">&#x00A0;encoded</span><span
8824class="cmtt-8">&#x00A0;as:</span><span
8825class="cmtt-8">&#x00A0;[</span><span
8826class="cmtt-8">&#x00A0;0</span><span
8827class="cmtt-8">&#x00A0;1</span><span
8828class="cmtt-8">&#x00A0;2</span><span
8829class="cmtt-8">&#x00A0;3</span><span
8830class="cmtt-8">&#x00A0;4</span><span
8831class="cmtt-8">&#x00A0;5</span><span
8832class="cmtt-8">&#x00A0;6</span><span
8833class="cmtt-8">&#x00A0;7</span><span
8834class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8835 id="x1-108010r5"></a><span
8836class="cmr-6">5</span>
8837<br class="fancyvrb" /><a
8838 id="x1-108012r6"></a><span
8839class="cmr-6">6</span><span
8840class="cmtt-8">codebook</span><span
8841class="cmtt-8">&#x00A0;dimensions</span><span
8842class="cmtt-8">&#x00A0;=</span><span
8843class="cmtt-8">&#x00A0;4</span><span
8844class="cmtt-8">&#x00A0;</span><span
8845class="cmtt-8">&#x00A0;encoded</span><span
8846class="cmtt-8">&#x00A0;as:</span><span
8847class="cmtt-8">&#x00A0;[</span><span
8848class="cmtt-8">&#x00A0;0</span><span
8849class="cmtt-8">&#x00A0;1</span><span
8850class="cmtt-8">&#x00A0;2</span><span
8851class="cmtt-8">&#x00A0;3</span><span
8852class="cmtt-8">&#x00A0;],</span><span
8853class="cmtt-8">&#x00A0;[</span><span
8854class="cmtt-8">&#x00A0;4</span><span
8855class="cmtt-8">&#x00A0;5</span><span
8856class="cmtt-8">&#x00A0;6</span><span
8857class="cmtt-8">&#x00A0;7</span><span
8858class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8859 id="x1-108014r7"></a><span
8860class="cmr-6">7</span><br class="fancyvrb" /><a
8861 id="x1-108016r8"></a><span
8862class="cmr-6">8</span><span
8863class="cmtt-8">codebook</span><span
8864class="cmtt-8">&#x00A0;dimensions</span><span
8865class="cmtt-8">&#x00A0;=</span><span
8866class="cmtt-8">&#x00A0;2</span><span
8867class="cmtt-8">&#x00A0;</span><span
8868class="cmtt-8">&#x00A0;encoded</span><span
8869class="cmtt-8">&#x00A0;as:</span><span
8870class="cmtt-8">&#x00A0;[</span><span
8871class="cmtt-8">&#x00A0;0</span><span
8872class="cmtt-8">&#x00A0;1</span><span
8873class="cmtt-8">&#x00A0;],</span><span
8874class="cmtt-8">&#x00A0;[</span><span
8875class="cmtt-8">&#x00A0;2</span><span
8876class="cmtt-8">&#x00A0;3</span><span
8877class="cmtt-8">&#x00A0;],</span><span
8878class="cmtt-8">&#x00A0;[</span><span
8879class="cmtt-8">&#x00A0;4</span><span
8880class="cmtt-8">&#x00A0;5</span><span
8881class="cmtt-8">&#x00A0;],</span><span
8882class="cmtt-8">&#x00A0;[</span><span
8883class="cmtt-8">&#x00A0;6</span><span
8884class="cmtt-8">&#x00A0;7</span><span
8885class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8886 id="x1-108018r9"></a><span
8887class="cmr-6">9</span>
8888<br class="fancyvrb" /><a
8889 id="x1-108020r10"></a><span
8890class="cmr-6">10</span><span
8891class="cmtt-8">codebook</span><span
8892class="cmtt-8">&#x00A0;dimensions</span><span
8893class="cmtt-8">&#x00A0;=</span><span
8894class="cmtt-8">&#x00A0;1</span><span
8895class="cmtt-8">&#x00A0;</span><span
8896class="cmtt-8">&#x00A0;encoded</span><span
8897class="cmtt-8">&#x00A0;as:</span><span
8898class="cmtt-8">&#x00A0;[</span><span
8899class="cmtt-8">&#x00A0;0</span><span
8900class="cmtt-8">&#x00A0;],</span><span
8901class="cmtt-8">&#x00A0;[</span><span
8902class="cmtt-8">&#x00A0;1</span><span
8903class="cmtt-8">&#x00A0;],</span><span
8904class="cmtt-8">&#x00A0;[</span><span
8905class="cmtt-8">&#x00A0;2</span><span
8906class="cmtt-8">&#x00A0;],</span><span
8907class="cmtt-8">&#x00A0;[</span><span
8908class="cmtt-8">&#x00A0;3</span><span
8909class="cmtt-8">&#x00A0;],</span><span
8910class="cmtt-8">&#x00A0;[</span><span
8911class="cmtt-8">&#x00A0;4</span><span
8912class="cmtt-8">&#x00A0;],</span><span
8913class="cmtt-8">&#x00A0;[</span><span
8914class="cmtt-8">&#x00A0;5</span><span
8915class="cmtt-8">&#x00A0;],</span><span
8916class="cmtt-8">&#x00A0;[</span><span
8917class="cmtt-8">&#x00A0;6</span><span
8918class="cmtt-8">&#x00A0;],</span><span
8919class="cmtt-8">&#x00A0;[</span><span
8920class="cmtt-8">&#x00A0;7</span><span
8921class="cmtt-8">&#x00A0;]</span><br class="fancyvrb" /><a
8922 id="x1-108022r11"></a><span
8923class="cmr-6">11</span></div>
8924<!--l. 136--><p class="noindent" >
8925<h4 class="subsectionHead"><span class="titlemark">8.5. </span> <a
8926 id="x1-1090008.5"></a>residue 2</h4>
8927<!--l. 138--><p class="noindent" >Residue type two can be thought of as a variant of residue type 1. Rather than encoding multiple
8928passed-in vectors as in residue type 1, the <span
8929class="cmti-12">ch </span>passed in vectors of length <span
8930class="cmti-12">n </span>are first interleaved
8931and flattened into a single vector of length <span
8932class="cmti-12">ch</span>*<span
8933class="cmti-12">n</span>. Encoding then proceeds as in type 1. Decoding
8934is as in type 1 with decode interleave reversed. If operating on a single vector to begin with,
8935residue type 1 and type 2 are equivalent.
8936
8937
8938
8939<div class="center"
8940>
8941<!--l. 146--><p class="noindent" >
8942
8943<!--l. 147--><p class="noindent" ><img
8944src="residue2.png" alt="PIC"
8945>
8946<br /> <div class="caption"
8947><span class="id">Figure&#x00A0;12: </span><span
8948class="content">illustration of residue type 2</span></div><!--tex4ht:label?: x1-10900112 -->
8949</div>
8950<!--l. 152--><p class="noindent" >
8951<h4 class="subsectionHead"><span class="titlemark">8.6. </span> <a
8952 id="x1-1100008.6"></a>Residue decode</h4>
8953<!--l. 154--><p class="noindent" >
8954<h5 class="subsubsectionHead"><span class="titlemark">8.6.1. </span> <a
8955 id="x1-1110008.6.1"></a>header decode</h5>
8956<!--l. 156--><p class="noindent" >Header decode for all three residue types is identical.
8957<div class="fancyvrb" id="fancyvrb35"><a
8958 id="x1-111002r1"></a><span
8959class="cmr-6">1</span><span
8960class="cmtt-8">&#x00A0;</span><span
8961class="cmtt-8">&#x00A0;1)</span><span
8962class="cmtt-8">&#x00A0;[residue\_begin]</span><span
8963class="cmtt-8">&#x00A0;=</span><span
8964class="cmtt-8">&#x00A0;read</span><span
8965class="cmtt-8">&#x00A0;24</span><span
8966class="cmtt-8">&#x00A0;bits</span><span
8967class="cmtt-8">&#x00A0;as</span><span
8968class="cmtt-8">&#x00A0;unsigned</span><span
8969class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
8970 id="x1-111004r2"></a><span
8971class="cmr-6">2</span><span
8972class="cmtt-8">&#x00A0;</span><span
8973class="cmtt-8">&#x00A0;2)</span><span
8974class="cmtt-8">&#x00A0;[residue\_end]</span><span
8975class="cmtt-8">&#x00A0;=</span><span
8976class="cmtt-8">&#x00A0;read</span><span
8977class="cmtt-8">&#x00A0;24</span><span
8978class="cmtt-8">&#x00A0;bits</span><span
8979class="cmtt-8">&#x00A0;as</span><span
8980class="cmtt-8">&#x00A0;unsigned</span><span
8981class="cmtt-8">&#x00A0;integer</span>
8982<br class="fancyvrb" /><a
8983 id="x1-111006r3"></a><span
8984class="cmr-6">3</span><span
8985class="cmtt-8">&#x00A0;</span><span
8986class="cmtt-8">&#x00A0;3)</span><span
8987class="cmtt-8">&#x00A0;[residue\_partition\_size]</span><span
8988class="cmtt-8">&#x00A0;=</span><span
8989class="cmtt-8">&#x00A0;read</span><span
8990class="cmtt-8">&#x00A0;24</span><span
8991class="cmtt-8">&#x00A0;bits</span><span
8992class="cmtt-8">&#x00A0;as</span><span
8993class="cmtt-8">&#x00A0;unsigned</span><span
8994class="cmtt-8">&#x00A0;integer</span><span
8995class="cmtt-8">&#x00A0;and</span><span
8996class="cmtt-8">&#x00A0;add</span><span
8997class="cmtt-8">&#x00A0;one</span>
8998<br class="fancyvrb" /><a
8999 id="x1-111008r4"></a><span
9000class="cmr-6">4</span><span
9001class="cmtt-8">&#x00A0;</span><span
9002class="cmtt-8">&#x00A0;4)</span><span
9003class="cmtt-8">&#x00A0;[residue\_classifications]</span><span
9004class="cmtt-8">&#x00A0;=</span><span
9005class="cmtt-8">&#x00A0;read</span><span
9006class="cmtt-8">&#x00A0;6</span><span
9007class="cmtt-8">&#x00A0;bits</span><span
9008class="cmtt-8">&#x00A0;as</span><span
9009class="cmtt-8">&#x00A0;unsigned</span><span
9010class="cmtt-8">&#x00A0;integer</span><span
9011class="cmtt-8">&#x00A0;and</span><span
9012class="cmtt-8">&#x00A0;add</span><span
9013class="cmtt-8">&#x00A0;one</span><br class="fancyvrb" /><a
9014 id="x1-111010r5"></a><span
9015class="cmr-6">5</span><span
9016class="cmtt-8">&#x00A0;</span><span
9017class="cmtt-8">&#x00A0;5)</span><span
9018class="cmtt-8">&#x00A0;[residue\_classbook]</span><span
9019class="cmtt-8">&#x00A0;=</span><span
9020class="cmtt-8">&#x00A0;read</span><span
9021class="cmtt-8">&#x00A0;8</span><span
9022class="cmtt-8">&#x00A0;bits</span><span
9023class="cmtt-8">&#x00A0;as</span><span
9024class="cmtt-8">&#x00A0;unsigned</span><span
9025class="cmtt-8">&#x00A0;integer</span></div>
9026<!--l. 165--><p class="noindent" ><span
9027class="cmtt-12">[residue</span><span
9028class="cmtt-12">_begin] </span>and <span
9029class="cmtt-12">[residue</span><span
9030class="cmtt-12">_end] </span>select the specific sub-portion of each vector that is
9031actually coded; it implements akin to a bandpass where, for coding purposes, the vector
9032effectively begins at element <span
9033class="cmtt-12">[residue</span><span
9034class="cmtt-12">_begin] </span>and ends at <span
9035class="cmtt-12">[residue</span><span
9036class="cmtt-12">_end]</span>. Preceding and
9037following values in the unpacked vectors are zeroed. Note that for residue type 2, these
9038values as well as <span
9039class="cmtt-12">[residue</span><span
9040class="cmtt-12">_partition</span><span
9041class="cmtt-12">_size]</span>apply to the interleaved vector, not the
9042individual vectors before interleave. <span
9043class="cmtt-12">[residue</span><span
9044class="cmtt-12">_partition</span><span
9045class="cmtt-12">_size] </span>is as explained above,
9046<span
9047class="cmtt-12">[residue</span><span
9048class="cmtt-12">_classifications] </span>is the number of possible classification to which a partition can
9049belong and <span
9050class="cmtt-12">[residue</span><span
9051class="cmtt-12">_classbook] </span>is the codebook number used to code classification
9052codewords. The number of dimensions in book <span
9053class="cmtt-12">[residue</span><span
9054class="cmtt-12">_classbook] </span>determines how
9055many classification values are grouped into a single classification codeword. Note that
9056the number of entries and dimensions in book <span
9057class="cmtt-12">[residue</span><span
9058class="cmtt-12">_classbook]</span>, along with
9059<span
9060class="cmtt-12">[residue</span><span
9061class="cmtt-12">_classifications]</span>, overdetermines to possible number of classification
9062codewords. If <span
9063class="cmtt-12">[residue</span><span
9064class="cmtt-12">_classifications]</span>&#x02C6;<span
9065class="cmtt-12">[residue</span><span
9066class="cmtt-12">_classbook]</span>.dimensions exceeds
9067<span
9068class="cmtt-12">[residue</span><span
9069class="cmtt-12">_classbook]</span>.entries, the bitstream should be regarded to be undecodable.
9070
9071
9072
9073<!--l. 189--><p class="noindent" >Next we read a bitmap pattern that specifies which partition classes code values in which
9074passes.
9075<!--l. 192--><p class="noindent" >
9076<div class="fancyvrb" id="fancyvrb36"><a
9077 id="x1-111012r1"></a><span
9078class="cmr-6">1</span><span
9079class="cmtt-8">&#x00A0;</span><span
9080class="cmtt-8">&#x00A0;1)</span><span
9081class="cmtt-8">&#x00A0;iterate</span><span
9082class="cmtt-8">&#x00A0;[i]</span><span
9083class="cmtt-8">&#x00A0;over</span><span
9084class="cmtt-8">&#x00A0;the</span><span
9085class="cmtt-8">&#x00A0;range</span><span
9086class="cmtt-8">&#x00A0;0</span><span
9087class="cmtt-8">&#x00A0;...</span><span
9088class="cmtt-8">&#x00A0;[residue\_classifications]-1</span><span
9089class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9090 id="x1-111014r2"></a><span
9091class="cmr-6">2</span><br class="fancyvrb" /><a
9092 id="x1-111016r3"></a><span
9093class="cmr-6">3</span><span
9094class="cmtt-8">&#x00A0;</span><span
9095class="cmtt-8">&#x00A0;</span><span
9096class="cmtt-8">&#x00A0;</span><span
9097class="cmtt-8">&#x00A0;</span><span
9098class="cmtt-8">&#x00A0;</span><span
9099class="cmtt-8">&#x00A0;</span><span
9100class="cmtt-8">&#x00A0;2)</span><span
9101class="cmtt-8">&#x00A0;[high\_bits]</span><span
9102class="cmtt-8">&#x00A0;=</span><span
9103class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
9104 id="x1-111018r4"></a><span
9105class="cmr-6">4</span><span
9106class="cmtt-8">&#x00A0;</span><span
9107class="cmtt-8">&#x00A0;</span><span
9108class="cmtt-8">&#x00A0;</span><span
9109class="cmtt-8">&#x00A0;</span><span
9110class="cmtt-8">&#x00A0;</span><span
9111class="cmtt-8">&#x00A0;</span><span
9112class="cmtt-8">&#x00A0;3)</span><span
9113class="cmtt-8">&#x00A0;[low\_bits]</span><span
9114class="cmtt-8">&#x00A0;=</span><span
9115class="cmtt-8">&#x00A0;read</span><span
9116class="cmtt-8">&#x00A0;3</span><span
9117class="cmtt-8">&#x00A0;bits</span><span
9118class="cmtt-8">&#x00A0;as</span><span
9119class="cmtt-8">&#x00A0;unsigned</span><span
9120class="cmtt-8">&#x00A0;integer</span>
9121<br class="fancyvrb" /><a
9122 id="x1-111020r5"></a><span
9123class="cmr-6">5</span><span
9124class="cmtt-8">&#x00A0;</span><span
9125class="cmtt-8">&#x00A0;</span><span
9126class="cmtt-8">&#x00A0;</span><span
9127class="cmtt-8">&#x00A0;</span><span
9128class="cmtt-8">&#x00A0;</span><span
9129class="cmtt-8">&#x00A0;</span><span
9130class="cmtt-8">&#x00A0;4)</span><span
9131class="cmtt-8">&#x00A0;[bitflag]</span><span
9132class="cmtt-8">&#x00A0;=</span><span
9133class="cmtt-8">&#x00A0;read</span><span
9134class="cmtt-8">&#x00A0;one</span><span
9135class="cmtt-8">&#x00A0;bit</span><span
9136class="cmtt-8">&#x00A0;as</span><span
9137class="cmtt-8">&#x00A0;boolean</span><br class="fancyvrb" /><a
9138 id="x1-111022r6"></a><span
9139class="cmr-6">6</span><span
9140class="cmtt-8">&#x00A0;</span><span
9141class="cmtt-8">&#x00A0;</span><span
9142class="cmtt-8">&#x00A0;</span><span
9143class="cmtt-8">&#x00A0;</span><span
9144class="cmtt-8">&#x00A0;</span><span
9145class="cmtt-8">&#x00A0;</span><span
9146class="cmtt-8">&#x00A0;5)</span><span
9147class="cmtt-8">&#x00A0;if</span><span
9148class="cmtt-8">&#x00A0;(</span><span
9149class="cmtt-8">&#x00A0;[bitflag]</span><span
9150class="cmtt-8">&#x00A0;is</span><span
9151class="cmtt-8">&#x00A0;set</span><span
9152class="cmtt-8">&#x00A0;)</span><span
9153class="cmtt-8">&#x00A0;then</span><span
9154class="cmtt-8">&#x00A0;[high\_bits]</span><span
9155class="cmtt-8">&#x00A0;=</span><span
9156class="cmtt-8">&#x00A0;read</span><span
9157class="cmtt-8">&#x00A0;five</span><span
9158class="cmtt-8">&#x00A0;bits</span><span
9159class="cmtt-8">&#x00A0;as</span><span
9160class="cmtt-8">&#x00A0;unsigned</span><span
9161class="cmtt-8">&#x00A0;integer</span>
9162<br class="fancyvrb" /><a
9163 id="x1-111024r7"></a><span
9164class="cmr-6">7</span><span
9165class="cmtt-8">&#x00A0;</span><span
9166class="cmtt-8">&#x00A0;</span><span
9167class="cmtt-8">&#x00A0;</span><span
9168class="cmtt-8">&#x00A0;</span><span
9169class="cmtt-8">&#x00A0;</span><span
9170class="cmtt-8">&#x00A0;</span><span
9171class="cmtt-8">&#x00A0;6)</span><span
9172class="cmtt-8">&#x00A0;vector</span><span
9173class="cmtt-8">&#x00A0;[residue\_cascade]</span><span
9174class="cmtt-8">&#x00A0;element</span><span
9175class="cmtt-8">&#x00A0;[i]</span><span
9176class="cmtt-8">&#x00A0;=</span><span
9177class="cmtt-8">&#x00A0;[high\_bits]</span><span
9178class="cmtt-8">&#x00A0;*</span><span
9179class="cmtt-8">&#x00A0;8</span><span
9180class="cmtt-8">&#x00A0;+</span><span
9181class="cmtt-8">&#x00A0;[low\_bits]</span><br class="fancyvrb" /><a
9182 id="x1-111026r8"></a><span
9183class="cmr-6">8</span><span
9184class="cmtt-8">&#x00A0;</span><span
9185class="cmtt-8">&#x00A0;</span><span
9186class="cmtt-8">&#x00A0;</span><span
9187class="cmtt-8">&#x00A0;</span><span
9188class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9189 id="x1-111028r9"></a><span
9190class="cmr-6">9</span><span
9191class="cmtt-8">&#x00A0;</span><span
9192class="cmtt-8">&#x00A0;7)</span><span
9193class="cmtt-8">&#x00A0;done</span></div>
9194<!--l. 204--><p class="noindent" >Finally, we read in a list of book numbers, each corresponding to specific bit set in the cascade
9195bitmap. We loop over the possible codebook classifications and the maximum possible number of
9196encoding stages (8 in Vorbis I, as constrained by the elements of the cascade bitmap being eight
9197bits):
9198<!--l. 210--><p class="noindent" >
9199<div class="fancyvrb" id="fancyvrb37"><a
9200 id="x1-111030r1"></a><span
9201class="cmr-6">1</span><span
9202class="cmtt-8">&#x00A0;</span><span
9203class="cmtt-8">&#x00A0;1)</span><span
9204class="cmtt-8">&#x00A0;iterate</span><span
9205class="cmtt-8">&#x00A0;[i]</span><span
9206class="cmtt-8">&#x00A0;over</span><span
9207class="cmtt-8">&#x00A0;the</span><span
9208class="cmtt-8">&#x00A0;range</span><span
9209class="cmtt-8">&#x00A0;0</span><span
9210class="cmtt-8">&#x00A0;...</span><span
9211class="cmtt-8">&#x00A0;[residue\_classifications]-1</span><span
9212class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9213 id="x1-111032r2"></a><span
9214class="cmr-6">2</span><br class="fancyvrb" /><a
9215 id="x1-111034r3"></a><span
9216class="cmr-6">3</span><span
9217class="cmtt-8">&#x00A0;</span><span
9218class="cmtt-8">&#x00A0;</span><span
9219class="cmtt-8">&#x00A0;</span><span
9220class="cmtt-8">&#x00A0;</span><span
9221class="cmtt-8">&#x00A0;</span><span
9222class="cmtt-8">&#x00A0;</span><span
9223class="cmtt-8">&#x00A0;2)</span><span
9224class="cmtt-8">&#x00A0;iterate</span><span
9225class="cmtt-8">&#x00A0;[j]</span><span
9226class="cmtt-8">&#x00A0;over</span><span
9227class="cmtt-8">&#x00A0;the</span><span
9228class="cmtt-8">&#x00A0;range</span><span
9229class="cmtt-8">&#x00A0;0</span><span
9230class="cmtt-8">&#x00A0;...</span><span
9231class="cmtt-8">&#x00A0;7</span><span
9232class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9233 id="x1-111036r4"></a><span
9234class="cmr-6">4</span>
9235<br class="fancyvrb" /><a
9236 id="x1-111038r5"></a><span
9237class="cmr-6">5</span><span
9238class="cmtt-8">&#x00A0;</span><span
9239class="cmtt-8">&#x00A0;</span><span
9240class="cmtt-8">&#x00A0;</span><span
9241class="cmtt-8">&#x00A0;</span><span
9242class="cmtt-8">&#x00A0;</span><span
9243class="cmtt-8">&#x00A0;</span><span
9244class="cmtt-8">&#x00A0;</span><span
9245class="cmtt-8">&#x00A0;</span><span
9246class="cmtt-8">&#x00A0;</span><span
9247class="cmtt-8">&#x00A0;</span><span
9248class="cmtt-8">&#x00A0;</span><span
9249class="cmtt-8">&#x00A0;3)</span><span
9250class="cmtt-8">&#x00A0;if</span><span
9251class="cmtt-8">&#x00A0;(</span><span
9252class="cmtt-8">&#x00A0;vector</span><span
9253class="cmtt-8">&#x00A0;[residue\_cascade]</span><span
9254class="cmtt-8">&#x00A0;element</span><span
9255class="cmtt-8">&#x00A0;[i]</span><span
9256class="cmtt-8">&#x00A0;bit</span><span
9257class="cmtt-8">&#x00A0;[j]</span><span
9258class="cmtt-8">&#x00A0;is</span><span
9259class="cmtt-8">&#x00A0;set</span><span
9260class="cmtt-8">&#x00A0;)</span><span
9261class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9262 id="x1-111040r6"></a><span
9263class="cmr-6">6</span>
9264<br class="fancyvrb" /><a
9265 id="x1-111042r7"></a><span
9266class="cmr-6">7</span><span
9267class="cmtt-8">&#x00A0;</span><span
9268class="cmtt-8">&#x00A0;</span><span
9269class="cmtt-8">&#x00A0;</span><span
9270class="cmtt-8">&#x00A0;</span><span
9271class="cmtt-8">&#x00A0;</span><span
9272class="cmtt-8">&#x00A0;</span><span
9273class="cmtt-8">&#x00A0;</span><span
9274class="cmtt-8">&#x00A0;</span><span
9275class="cmtt-8">&#x00A0;</span><span
9276class="cmtt-8">&#x00A0;</span><span
9277class="cmtt-8">&#x00A0;</span><span
9278class="cmtt-8">&#x00A0;</span><span
9279class="cmtt-8">&#x00A0;</span><span
9280class="cmtt-8">&#x00A0;</span><span
9281class="cmtt-8">&#x00A0;</span><span
9282class="cmtt-8">&#x00A0;</span><span
9283class="cmtt-8">&#x00A0;4)</span><span
9284class="cmtt-8">&#x00A0;array</span><span
9285class="cmtt-8">&#x00A0;[residue\_books]</span><span
9286class="cmtt-8">&#x00A0;element</span><span
9287class="cmtt-8">&#x00A0;[i][j]</span><span
9288class="cmtt-8">&#x00A0;=</span><span
9289class="cmtt-8">&#x00A0;read</span><span
9290class="cmtt-8">&#x00A0;8</span><span
9291class="cmtt-8">&#x00A0;bits</span><span
9292class="cmtt-8">&#x00A0;as</span><span
9293class="cmtt-8">&#x00A0;unsigned</span><span
9294class="cmtt-8">&#x00A0;integer</span><br class="fancyvrb" /><a
9295 id="x1-111044r8"></a><span
9296class="cmr-6">8</span><br class="fancyvrb" /><a
9297 id="x1-111046r9"></a><span
9298class="cmr-6">9</span><span
9299class="cmtt-8">&#x00A0;</span><span
9300class="cmtt-8">&#x00A0;</span><span
9301class="cmtt-8">&#x00A0;</span><span
9302class="cmtt-8">&#x00A0;</span><span
9303class="cmtt-8">&#x00A0;</span><span
9304class="cmtt-8">&#x00A0;</span><span
9305class="cmtt-8">&#x00A0;</span><span
9306class="cmtt-8">&#x00A0;</span><span
9307class="cmtt-8">&#x00A0;</span><span
9308class="cmtt-8">&#x00A0;</span><span
9309class="cmtt-8">&#x00A0;</span><span
9310class="cmtt-8">&#x00A0;</span><span
9311class="cmtt-8">&#x00A0;</span><span
9312class="cmtt-8">&#x00A0;</span><span
9313class="cmtt-8">&#x00A0;}</span><span
9314class="cmtt-8">&#x00A0;else</span><span
9315class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9316 id="x1-111048r10"></a><span
9317class="cmr-6">10</span>
9318<br class="fancyvrb" /><a
9319 id="x1-111050r11"></a><span
9320class="cmr-6">11</span><span
9321class="cmtt-8">&#x00A0;</span><span
9322class="cmtt-8">&#x00A0;</span><span
9323class="cmtt-8">&#x00A0;</span><span
9324class="cmtt-8">&#x00A0;</span><span
9325class="cmtt-8">&#x00A0;</span><span
9326class="cmtt-8">&#x00A0;</span><span
9327class="cmtt-8">&#x00A0;</span><span
9328class="cmtt-8">&#x00A0;</span><span
9329class="cmtt-8">&#x00A0;</span><span
9330class="cmtt-8">&#x00A0;</span><span
9331class="cmtt-8">&#x00A0;</span><span
9332class="cmtt-8">&#x00A0;</span><span
9333class="cmtt-8">&#x00A0;</span><span
9334class="cmtt-8">&#x00A0;</span><span
9335class="cmtt-8">&#x00A0;</span><span
9336class="cmtt-8">&#x00A0;</span><span
9337class="cmtt-8">&#x00A0;5)</span><span
9338class="cmtt-8">&#x00A0;array</span><span
9339class="cmtt-8">&#x00A0;[residue\_books]</span><span
9340class="cmtt-8">&#x00A0;element</span><span
9341class="cmtt-8">&#x00A0;[i][j]</span><span
9342class="cmtt-8">&#x00A0;=</span><span
9343class="cmtt-8">&#x00A0;unused</span><br class="fancyvrb" /><a
9344 id="x1-111052r12"></a><span
9345class="cmr-6">12</span><br class="fancyvrb" /><a
9346 id="x1-111054r13"></a><span
9347class="cmr-6">13</span><span
9348class="cmtt-8">&#x00A0;</span><span
9349class="cmtt-8">&#x00A0;</span><span
9350class="cmtt-8">&#x00A0;</span><span
9351class="cmtt-8">&#x00A0;</span><span
9352class="cmtt-8">&#x00A0;</span><span
9353class="cmtt-8">&#x00A0;</span><span
9354class="cmtt-8">&#x00A0;</span><span
9355class="cmtt-8">&#x00A0;</span><span
9356class="cmtt-8">&#x00A0;</span><span
9357class="cmtt-8">&#x00A0;</span><span
9358class="cmtt-8">&#x00A0;</span><span
9359class="cmtt-8">&#x00A0;</span><span
9360class="cmtt-8">&#x00A0;</span><span
9361class="cmtt-8">&#x00A0;</span><span
9362class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9363 id="x1-111056r14"></a><span
9364class="cmr-6">14</span><span
9365class="cmtt-8">&#x00A0;</span><span
9366class="cmtt-8">&#x00A0;</span><span
9367class="cmtt-8">&#x00A0;</span><span
9368class="cmtt-8">&#x00A0;</span><span
9369class="cmtt-8">&#x00A0;</span><span
9370class="cmtt-8">&#x00A0;</span><span
9371class="cmtt-8">&#x00A0;</span><span
9372class="cmtt-8">&#x00A0;</span><span
9373class="cmtt-8">&#x00A0;</span><span
9374class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9375 id="x1-111058r15"></a><span
9376class="cmr-6">15</span><span
9377class="cmtt-8">&#x00A0;</span><span
9378class="cmtt-8">&#x00A0;</span><span
9379class="cmtt-8">&#x00A0;</span><span
9380class="cmtt-8">&#x00A0;</span><span
9381class="cmtt-8">&#x00A0;</span><span
9382class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9383 id="x1-111060r16"></a><span
9384class="cmr-6">16</span><br class="fancyvrb" /><a
9385 id="x1-111062r17"></a><span
9386class="cmr-6">17</span><span
9387class="cmtt-8">&#x00A0;</span><span
9388class="cmtt-8">&#x00A0;6)</span><span
9389class="cmtt-8">&#x00A0;done</span></div>
9390<!--l. 230--><p class="noindent" >An end-of-packet condition at any point in header decode renders the stream undecodable.
9391In addition, any codebook number greater than the maximum numbered codebook
9392set up in this stream also renders the stream undecodable. All codebooks in array
9393[residue_books] are required to have a value mapping. The presence of codebook in array
9394[residue_books] without a value mapping (maptype equals zero) renders the stream
9395undecodable.
9396<!--l. 240--><p class="noindent" >
9397<h5 class="subsubsectionHead"><span class="titlemark">8.6.2. </span> <a
9398 id="x1-1120008.6.2"></a>packet decode</h5>
9399<!--l. 242--><p class="noindent" >Format 0 and 1 packet decode is identical except for specific partition interleave. Format 2 packet
9400decode can be built out of the format 1 decode process. Thus we describe first the decode
9401infrastructure identical to all three formats.
9402<!--l. 247--><p class="noindent" >In addition to configuration information, the residue decode process is passed the number of
9403vectors in the submap bundle and a vector of flags indicating if any of the vectors are not to be
9404decoded. If the passed in number of vectors is 3 and vector number 1 is marked &#8217;do not decode&#8217;,
9405decode skips vector 1 during the decode loop. However, even &#8217;do not decode&#8217; vectors are
9406allocated and zeroed.
9407<!--l. 254--><p class="noindent" >Depending on the values of <span
9408class="cmtt-12">[residue</span><span
9409class="cmtt-12">_begin] </span>and <span
9410class="cmtt-12">[residue</span><span
9411class="cmtt-12">_end]</span>, it is obvious that the
9412encoded portion of a residue vector may be the entire possible residue vector or some other strict
9413subset of the actual residue vector size with zero padding at either uncoded end. However, it is
9414also possible to set <span
9415class="cmtt-12">[residue</span><span
9416class="cmtt-12">_begin] </span>and <span
9417class="cmtt-12">[residue</span><span
9418class="cmtt-12">_end] </span>to specify a range partially or wholly
9419
9420
9421
9422beyond the maximum vector size. Before beginning residue decode, limit <span
9423class="cmtt-12">[residue</span><span
9424class="cmtt-12">_begin]</span>
9425and <span
9426class="cmtt-12">[residue</span><span
9427class="cmtt-12">_end] </span>to the maximum possible vector size as follows. We assume that
9428the number of vectors being encoded, <span
9429class="cmtt-12">[ch] </span>is provided by the higher level decoding
9430process.
9431<!--l. 268--><p class="noindent" >
9432<div class="fancyvrb" id="fancyvrb38"><a
9433 id="x1-112002r1"></a><span
9434class="cmr-6">1</span><span
9435class="cmtt-8">&#x00A0;</span><span
9436class="cmtt-8">&#x00A0;1)</span><span
9437class="cmtt-8">&#x00A0;[actual\_size]</span><span
9438class="cmtt-8">&#x00A0;=</span><span
9439class="cmtt-8">&#x00A0;current</span><span
9440class="cmtt-8">&#x00A0;blocksize/2;</span><br class="fancyvrb" /><a
9441 id="x1-112004r2"></a><span
9442class="cmr-6">2</span><span
9443class="cmtt-8">&#x00A0;</span><span
9444class="cmtt-8">&#x00A0;2)</span><span
9445class="cmtt-8">&#x00A0;if</span><span
9446class="cmtt-8">&#x00A0;residue</span><span
9447class="cmtt-8">&#x00A0;encoding</span><span
9448class="cmtt-8">&#x00A0;is</span><span
9449class="cmtt-8">&#x00A0;format</span><span
9450class="cmtt-8">&#x00A0;2</span><br class="fancyvrb" /><a
9451 id="x1-112006r3"></a><span
9452class="cmr-6">3</span><span
9453class="cmtt-8">&#x00A0;</span><span
9454class="cmtt-8">&#x00A0;</span><span
9455class="cmtt-8">&#x00A0;</span><span
9456class="cmtt-8">&#x00A0;</span><span
9457class="cmtt-8">&#x00A0;</span><span
9458class="cmtt-8">&#x00A0;</span><span
9459class="cmtt-8">&#x00A0;3)</span><span
9460class="cmtt-8">&#x00A0;[actual\_size]</span><span
9461class="cmtt-8">&#x00A0;=</span><span
9462class="cmtt-8">&#x00A0;[actual\_size]</span><span
9463class="cmtt-8">&#x00A0;*</span><span
9464class="cmtt-8">&#x00A0;[ch];</span>
9465<br class="fancyvrb" /><a
9466 id="x1-112008r4"></a><span
9467class="cmr-6">4</span><span
9468class="cmtt-8">&#x00A0;</span><span
9469class="cmtt-8">&#x00A0;4)</span><span
9470class="cmtt-8">&#x00A0;[limit\_residue\_begin]</span><span
9471class="cmtt-8">&#x00A0;=</span><span
9472class="cmtt-8">&#x00A0;minimum</span><span
9473class="cmtt-8">&#x00A0;of</span><span
9474class="cmtt-8">&#x00A0;([residue\_begin],[actual\_size]);</span><br class="fancyvrb" /><a
9475 id="x1-112010r5"></a><span
9476class="cmr-6">5</span><span
9477class="cmtt-8">&#x00A0;</span><span
9478class="cmtt-8">&#x00A0;5)</span><span
9479class="cmtt-8">&#x00A0;[limit\_residue\_end]</span><span
9480class="cmtt-8">&#x00A0;=</span><span
9481class="cmtt-8">&#x00A0;minimum</span><span
9482class="cmtt-8">&#x00A0;of</span><span
9483class="cmtt-8">&#x00A0;([residue\_end],[actual\_size]);</span></div>
9484<!--l. 276--><p class="noindent" >The following convenience values are conceptually useful to clarifying the decode process:
9485<!--l. 279--><p class="noindent" >
9486<div class="fancyvrb" id="fancyvrb39"><a
9487 id="x1-112012r1"></a><span
9488class="cmr-6">1</span><span
9489class="cmtt-8">&#x00A0;</span><span
9490class="cmtt-8">&#x00A0;1)</span><span
9491class="cmtt-8">&#x00A0;[classwords\_per\_codeword]</span><span
9492class="cmtt-8">&#x00A0;=</span><span
9493class="cmtt-8">&#x00A0;[codebook\_dimensions]</span><span
9494class="cmtt-8">&#x00A0;value</span><span
9495class="cmtt-8">&#x00A0;of</span><span
9496class="cmtt-8">&#x00A0;codebook</span><span
9497class="cmtt-8">&#x00A0;[residue\_classbook]</span>
9498<br class="fancyvrb" /><a
9499 id="x1-112014r2"></a><span
9500class="cmr-6">2</span><span
9501class="cmtt-8">&#x00A0;</span><span
9502class="cmtt-8">&#x00A0;2)</span><span
9503class="cmtt-8">&#x00A0;[n\_to\_read]</span><span
9504class="cmtt-8">&#x00A0;=</span><span
9505class="cmtt-8">&#x00A0;[limit\_residue\_end]</span><span
9506class="cmtt-8">&#x00A0;-</span><span
9507class="cmtt-8">&#x00A0;[limit\_residue\_begin]</span><br class="fancyvrb" /><a
9508 id="x1-112016r3"></a><span
9509class="cmr-6">3</span><span
9510class="cmtt-8">&#x00A0;</span><span
9511class="cmtt-8">&#x00A0;3)</span><span
9512class="cmtt-8">&#x00A0;[partitions\_to\_read]</span><span
9513class="cmtt-8">&#x00A0;=</span><span
9514class="cmtt-8">&#x00A0;[n\_to\_read]</span><span
9515class="cmtt-8">&#x00A0;/</span><span
9516class="cmtt-8">&#x00A0;[residue\_partition\_size]</span></div>
9517<!--l. 285--><p class="noindent" >Packet decode proceeds as follows, matching the description offered earlier in the document.
9518<div class="fancyvrb" id="fancyvrb40"><a
9519 id="x1-112018r1"></a><span
9520class="cmr-6">1</span><span
9521class="cmtt-8">&#x00A0;</span><span
9522class="cmtt-8">&#x00A0;1)</span><span
9523class="cmtt-8">&#x00A0;allocate</span><span
9524class="cmtt-8">&#x00A0;and</span><span
9525class="cmtt-8">&#x00A0;zero</span><span
9526class="cmtt-8">&#x00A0;all</span><span
9527class="cmtt-8">&#x00A0;vectors</span><span
9528class="cmtt-8">&#x00A0;that</span><span
9529class="cmtt-8">&#x00A0;will</span><span
9530class="cmtt-8">&#x00A0;be</span><span
9531class="cmtt-8">&#x00A0;returned.</span><br class="fancyvrb" /><a
9532 id="x1-112020r2"></a><span
9533class="cmr-6">2</span><span
9534class="cmtt-8">&#x00A0;</span><span
9535class="cmtt-8">&#x00A0;2)</span><span
9536class="cmtt-8">&#x00A0;if</span><span
9537class="cmtt-8">&#x00A0;([n\_to\_read]</span><span
9538class="cmtt-8">&#x00A0;is</span><span
9539class="cmtt-8">&#x00A0;zero),</span><span
9540class="cmtt-8">&#x00A0;stop;</span><span
9541class="cmtt-8">&#x00A0;there</span><span
9542class="cmtt-8">&#x00A0;is</span><span
9543class="cmtt-8">&#x00A0;no</span><span
9544class="cmtt-8">&#x00A0;residue</span><span
9545class="cmtt-8">&#x00A0;to</span><span
9546class="cmtt-8">&#x00A0;decode.</span>
9547<br class="fancyvrb" /><a
9548 id="x1-112022r3"></a><span
9549class="cmr-6">3</span><span
9550class="cmtt-8">&#x00A0;</span><span
9551class="cmtt-8">&#x00A0;3)</span><span
9552class="cmtt-8">&#x00A0;iterate</span><span
9553class="cmtt-8">&#x00A0;[pass]</span><span
9554class="cmtt-8">&#x00A0;over</span><span
9555class="cmtt-8">&#x00A0;the</span><span
9556class="cmtt-8">&#x00A0;range</span><span
9557class="cmtt-8">&#x00A0;0</span><span
9558class="cmtt-8">&#x00A0;...</span><span
9559class="cmtt-8">&#x00A0;7</span><span
9560class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9561 id="x1-112024r4"></a><span
9562class="cmr-6">4</span><br class="fancyvrb" /><a
9563 id="x1-112026r5"></a><span
9564class="cmr-6">5</span><span
9565class="cmtt-8">&#x00A0;</span><span
9566class="cmtt-8">&#x00A0;</span><span
9567class="cmtt-8">&#x00A0;</span><span
9568class="cmtt-8">&#x00A0;</span><span
9569class="cmtt-8">&#x00A0;</span><span
9570class="cmtt-8">&#x00A0;</span><span
9571class="cmtt-8">&#x00A0;4)</span><span
9572class="cmtt-8">&#x00A0;[partition\_count]</span><span
9573class="cmtt-8">&#x00A0;=</span><span
9574class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
9575 id="x1-112028r6"></a><span
9576class="cmr-6">6</span>
9577<br class="fancyvrb" /><a
9578 id="x1-112030r7"></a><span
9579class="cmr-6">7</span><span
9580class="cmtt-8">&#x00A0;</span><span
9581class="cmtt-8">&#x00A0;</span><span
9582class="cmtt-8">&#x00A0;</span><span
9583class="cmtt-8">&#x00A0;</span><span
9584class="cmtt-8">&#x00A0;</span><span
9585class="cmtt-8">&#x00A0;</span><span
9586class="cmtt-8">&#x00A0;5)</span><span
9587class="cmtt-8">&#x00A0;while</span><span
9588class="cmtt-8">&#x00A0;[partition\_count]</span><span
9589class="cmtt-8">&#x00A0;is</span><span
9590class="cmtt-8">&#x00A0;less</span><span
9591class="cmtt-8">&#x00A0;than</span><span
9592class="cmtt-8">&#x00A0;[partitions\_to\_read]</span><br class="fancyvrb" /><a
9593 id="x1-112032r8"></a><span
9594class="cmr-6">8</span><br class="fancyvrb" /><a
9595 id="x1-112034r9"></a><span
9596class="cmr-6">9</span><span
9597class="cmtt-8">&#x00A0;</span><span
9598class="cmtt-8">&#x00A0;</span><span
9599class="cmtt-8">&#x00A0;</span><span
9600class="cmtt-8">&#x00A0;</span><span
9601class="cmtt-8">&#x00A0;</span><span
9602class="cmtt-8">&#x00A0;</span><span
9603class="cmtt-8">&#x00A0;</span><span
9604class="cmtt-8">&#x00A0;</span><span
9605class="cmtt-8">&#x00A0;</span><span
9606class="cmtt-8">&#x00A0;</span><span
9607class="cmtt-8">&#x00A0;</span><span
9608class="cmtt-8">&#x00A0;6)</span><span
9609class="cmtt-8">&#x00A0;if</span><span
9610class="cmtt-8">&#x00A0;([pass]</span><span
9611class="cmtt-8">&#x00A0;is</span><span
9612class="cmtt-8">&#x00A0;zero)</span><span
9613class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9614 id="x1-112036r10"></a><span
9615class="cmr-6">10</span>
9616<br class="fancyvrb" /><a
9617 id="x1-112038r11"></a><span
9618class="cmr-6">11</span><span
9619class="cmtt-8">&#x00A0;</span><span
9620class="cmtt-8">&#x00A0;</span><span
9621class="cmtt-8">&#x00A0;</span><span
9622class="cmtt-8">&#x00A0;</span><span
9623class="cmtt-8">&#x00A0;</span><span
9624class="cmtt-8">&#x00A0;</span><span
9625class="cmtt-8">&#x00A0;</span><span
9626class="cmtt-8">&#x00A0;</span><span
9627class="cmtt-8">&#x00A0;</span><span
9628class="cmtt-8">&#x00A0;</span><span
9629class="cmtt-8">&#x00A0;</span><span
9630class="cmtt-8">&#x00A0;</span><span
9631class="cmtt-8">&#x00A0;</span><span
9632class="cmtt-8">&#x00A0;</span><span
9633class="cmtt-8">&#x00A0;</span><span
9634class="cmtt-8">&#x00A0;</span><span
9635class="cmtt-8">&#x00A0;7)</span><span
9636class="cmtt-8">&#x00A0;iterate</span><span
9637class="cmtt-8">&#x00A0;[j]</span><span
9638class="cmtt-8">&#x00A0;over</span><span
9639class="cmtt-8">&#x00A0;the</span><span
9640class="cmtt-8">&#x00A0;range</span><span
9641class="cmtt-8">&#x00A0;0</span><span
9642class="cmtt-8">&#x00A0;..</span><span
9643class="cmtt-8">&#x00A0;[ch]-1</span><span
9644class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9645 id="x1-112040r12"></a><span
9646class="cmr-6">12</span><br class="fancyvrb" /><a
9647 id="x1-112042r13"></a><span
9648class="cmr-6">13</span><span
9649class="cmtt-8">&#x00A0;</span><span
9650class="cmtt-8">&#x00A0;</span><span
9651class="cmtt-8">&#x00A0;</span><span
9652class="cmtt-8">&#x00A0;</span><span
9653class="cmtt-8">&#x00A0;</span><span
9654class="cmtt-8">&#x00A0;</span><span
9655class="cmtt-8">&#x00A0;</span><span
9656class="cmtt-8">&#x00A0;</span><span
9657class="cmtt-8">&#x00A0;</span><span
9658class="cmtt-8">&#x00A0;</span><span
9659class="cmtt-8">&#x00A0;</span><span
9660class="cmtt-8">&#x00A0;</span><span
9661class="cmtt-8">&#x00A0;</span><span
9662class="cmtt-8">&#x00A0;</span><span
9663class="cmtt-8">&#x00A0;</span><span
9664class="cmtt-8">&#x00A0;</span><span
9665class="cmtt-8">&#x00A0;</span><span
9666class="cmtt-8">&#x00A0;</span><span
9667class="cmtt-8">&#x00A0;</span><span
9668class="cmtt-8">&#x00A0;</span><span
9669class="cmtt-8">&#x00A0;</span><span
9670class="cmtt-8">&#x00A0;8)</span><span
9671class="cmtt-8">&#x00A0;if</span><span
9672class="cmtt-8">&#x00A0;vector</span><span
9673class="cmtt-8">&#x00A0;[j]</span><span
9674class="cmtt-8">&#x00A0;is</span><span
9675class="cmtt-8">&#x00A0;not</span><span
9676class="cmtt-8">&#x00A0;marked</span><span
9677class="cmtt-8">&#x00A0;&#8217;do</span><span
9678class="cmtt-8">&#x00A0;not</span><span
9679class="cmtt-8">&#x00A0;decode&#8217;</span><span
9680class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9681 id="x1-112044r14"></a><span
9682class="cmr-6">14</span>
9683<br class="fancyvrb" /><a
9684 id="x1-112046r15"></a><span
9685class="cmr-6">15</span><span
9686class="cmtt-8">&#x00A0;</span><span
9687class="cmtt-8">&#x00A0;</span><span
9688class="cmtt-8">&#x00A0;</span><span
9689class="cmtt-8">&#x00A0;</span><span
9690class="cmtt-8">&#x00A0;</span><span
9691class="cmtt-8">&#x00A0;</span><span
9692class="cmtt-8">&#x00A0;</span><span
9693class="cmtt-8">&#x00A0;</span><span
9694class="cmtt-8">&#x00A0;</span><span
9695class="cmtt-8">&#x00A0;</span><span
9696class="cmtt-8">&#x00A0;</span><span
9697class="cmtt-8">&#x00A0;</span><span
9698class="cmtt-8">&#x00A0;</span><span
9699class="cmtt-8">&#x00A0;</span><span
9700class="cmtt-8">&#x00A0;</span><span
9701class="cmtt-8">&#x00A0;</span><span
9702class="cmtt-8">&#x00A0;</span><span
9703class="cmtt-8">&#x00A0;</span><span
9704class="cmtt-8">&#x00A0;</span><span
9705class="cmtt-8">&#x00A0;</span><span
9706class="cmtt-8">&#x00A0;</span><span
9707class="cmtt-8">&#x00A0;</span><span
9708class="cmtt-8">&#x00A0;</span><span
9709class="cmtt-8">&#x00A0;</span><span
9710class="cmtt-8">&#x00A0;</span><span
9711class="cmtt-8">&#x00A0;</span><span
9712class="cmtt-8">&#x00A0;9)</span><span
9713class="cmtt-8">&#x00A0;[temp]</span><span
9714class="cmtt-8">&#x00A0;=</span><span
9715class="cmtt-8">&#x00A0;read</span><span
9716class="cmtt-8">&#x00A0;from</span><span
9717class="cmtt-8">&#x00A0;packet</span><span
9718class="cmtt-8">&#x00A0;using</span><span
9719class="cmtt-8">&#x00A0;codebook</span><span
9720class="cmtt-8">&#x00A0;[residue\_classbook]</span><span
9721class="cmtt-8">&#x00A0;in</span><span
9722class="cmtt-8">&#x00A0;scalar</span><span
9723class="cmtt-8">&#x00A0;context</span>
9724<br class="fancyvrb" /><a
9725 id="x1-112048r16"></a><span
9726class="cmr-6">16</span><span
9727class="cmtt-8">&#x00A0;</span><span
9728class="cmtt-8">&#x00A0;</span><span
9729class="cmtt-8">&#x00A0;</span><span
9730class="cmtt-8">&#x00A0;</span><span
9731class="cmtt-8">&#x00A0;</span><span
9732class="cmtt-8">&#x00A0;</span><span
9733class="cmtt-8">&#x00A0;</span><span
9734class="cmtt-8">&#x00A0;</span><span
9735class="cmtt-8">&#x00A0;</span><span
9736class="cmtt-8">&#x00A0;</span><span
9737class="cmtt-8">&#x00A0;</span><span
9738class="cmtt-8">&#x00A0;</span><span
9739class="cmtt-8">&#x00A0;</span><span
9740class="cmtt-8">&#x00A0;</span><span
9741class="cmtt-8">&#x00A0;</span><span
9742class="cmtt-8">&#x00A0;</span><span
9743class="cmtt-8">&#x00A0;</span><span
9744class="cmtt-8">&#x00A0;</span><span
9745class="cmtt-8">&#x00A0;</span><span
9746class="cmtt-8">&#x00A0;</span><span
9747class="cmtt-8">&#x00A0;</span><span
9748class="cmtt-8">&#x00A0;</span><span
9749class="cmtt-8">&#x00A0;</span><span
9750class="cmtt-8">&#x00A0;</span><span
9751class="cmtt-8">&#x00A0;</span><span
9752class="cmtt-8">&#x00A0;10)</span><span
9753class="cmtt-8">&#x00A0;iterate</span><span
9754class="cmtt-8">&#x00A0;[i]</span><span
9755class="cmtt-8">&#x00A0;descending</span><span
9756class="cmtt-8">&#x00A0;over</span><span
9757class="cmtt-8">&#x00A0;the</span><span
9758class="cmtt-8">&#x00A0;range</span><span
9759class="cmtt-8">&#x00A0;[classwords\_per\_codeword]-1</span><span
9760class="cmtt-8">&#x00A0;...</span><span
9761class="cmtt-8">&#x00A0;0</span><span
9762class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
9763 id="x1-112050r17"></a><span
9764class="cmr-6">17</span>
9765<br class="fancyvrb" /><a
9766 id="x1-112052r18"></a><span
9767class="cmr-6">18</span><span
9768class="cmtt-8">&#x00A0;</span><span
9769class="cmtt-8">&#x00A0;</span><span
9770class="cmtt-8">&#x00A0;</span><span
9771class="cmtt-8">&#x00A0;</span><span
9772class="cmtt-8">&#x00A0;</span><span
9773class="cmtt-8">&#x00A0;</span><span
9774class="cmtt-8">&#x00A0;</span><span
9775class="cmtt-8">&#x00A0;</span><span
9776class="cmtt-8">&#x00A0;</span><span
9777class="cmtt-8">&#x00A0;</span><span
9778class="cmtt-8">&#x00A0;</span><span
9779class="cmtt-8">&#x00A0;</span><span
9780class="cmtt-8">&#x00A0;</span><span
9781class="cmtt-8">&#x00A0;</span><span
9782class="cmtt-8">&#x00A0;</span><span
9783class="cmtt-8">&#x00A0;</span><span
9784class="cmtt-8">&#x00A0;</span><span
9785class="cmtt-8">&#x00A0;</span><span
9786class="cmtt-8">&#x00A0;</span><span
9787class="cmtt-8">&#x00A0;</span><span
9788class="cmtt-8">&#x00A0;</span><span
9789class="cmtt-8">&#x00A0;</span><span
9790class="cmtt-8">&#x00A0;</span><span
9791class="cmtt-8">&#x00A0;</span><span
9792class="cmtt-8">&#x00A0;</span><span
9793class="cmtt-8">&#x00A0;</span><span
9794class="cmtt-8">&#x00A0;</span><span
9795class="cmtt-8">&#x00A0;</span><span
9796class="cmtt-8">&#x00A0;</span><span
9797class="cmtt-8">&#x00A0;</span><span
9798class="cmtt-8">&#x00A0;11)</span><span
9799class="cmtt-8">&#x00A0;array</span><span
9800class="cmtt-8">&#x00A0;[classifications]</span><span
9801class="cmtt-8">&#x00A0;element</span><span
9802class="cmtt-8">&#x00A0;[j],([i]+[partition\_count])</span><span
9803class="cmtt-8">&#x00A0;=</span>
9804<br class="fancyvrb" /><a
9805 id="x1-112054r19"></a><span
9806class="cmr-6">19</span><span
9807class="cmtt-8">&#x00A0;</span><span
9808class="cmtt-8">&#x00A0;</span><span
9809class="cmtt-8">&#x00A0;</span><span
9810class="cmtt-8">&#x00A0;</span><span
9811class="cmtt-8">&#x00A0;</span><span
9812class="cmtt-8">&#x00A0;</span><span
9813class="cmtt-8">&#x00A0;</span><span
9814class="cmtt-8">&#x00A0;</span><span
9815class="cmtt-8">&#x00A0;</span><span
9816class="cmtt-8">&#x00A0;</span><span
9817class="cmtt-8">&#x00A0;</span><span
9818class="cmtt-8">&#x00A0;</span><span
9819class="cmtt-8">&#x00A0;</span><span
9820class="cmtt-8">&#x00A0;</span><span
9821class="cmtt-8">&#x00A0;</span><span
9822class="cmtt-8">&#x00A0;</span><span
9823class="cmtt-8">&#x00A0;</span><span
9824class="cmtt-8">&#x00A0;</span><span
9825class="cmtt-8">&#x00A0;</span><span
9826class="cmtt-8">&#x00A0;</span><span
9827class="cmtt-8">&#x00A0;</span><span
9828class="cmtt-8">&#x00A0;</span><span
9829class="cmtt-8">&#x00A0;</span><span
9830class="cmtt-8">&#x00A0;</span><span
9831class="cmtt-8">&#x00A0;</span><span
9832class="cmtt-8">&#x00A0;</span><span
9833class="cmtt-8">&#x00A0;</span><span
9834class="cmtt-8">&#x00A0;</span><span
9835class="cmtt-8">&#x00A0;</span><span
9836class="cmtt-8">&#x00A0;</span><span
9837class="cmtt-8">&#x00A0;</span><span
9838class="cmtt-8">&#x00A0;</span><span
9839class="cmtt-8">&#x00A0;</span><span
9840class="cmtt-8">&#x00A0;</span><span
9841class="cmtt-8">&#x00A0;[temp]</span><span
9842class="cmtt-8">&#x00A0;integer</span><span
9843class="cmtt-8">&#x00A0;modulo</span><span
9844class="cmtt-8">&#x00A0;[residue\_classifications]</span>
9845<br class="fancyvrb" /><a
9846 id="x1-112056r20"></a><span
9847class="cmr-6">20</span><span
9848class="cmtt-8">&#x00A0;</span><span
9849class="cmtt-8">&#x00A0;</span><span
9850class="cmtt-8">&#x00A0;</span><span
9851class="cmtt-8">&#x00A0;</span><span
9852class="cmtt-8">&#x00A0;</span><span
9853class="cmtt-8">&#x00A0;</span><span
9854class="cmtt-8">&#x00A0;</span><span
9855class="cmtt-8">&#x00A0;</span><span
9856class="cmtt-8">&#x00A0;</span><span
9857class="cmtt-8">&#x00A0;</span><span
9858class="cmtt-8">&#x00A0;</span><span
9859class="cmtt-8">&#x00A0;</span><span
9860class="cmtt-8">&#x00A0;</span><span
9861class="cmtt-8">&#x00A0;</span><span
9862class="cmtt-8">&#x00A0;</span><span
9863class="cmtt-8">&#x00A0;</span><span
9864class="cmtt-8">&#x00A0;</span><span
9865class="cmtt-8">&#x00A0;</span><span
9866class="cmtt-8">&#x00A0;</span><span
9867class="cmtt-8">&#x00A0;</span><span
9868class="cmtt-8">&#x00A0;</span><span
9869class="cmtt-8">&#x00A0;</span><span
9870class="cmtt-8">&#x00A0;</span><span
9871class="cmtt-8">&#x00A0;</span><span
9872class="cmtt-8">&#x00A0;</span><span
9873class="cmtt-8">&#x00A0;</span><span
9874class="cmtt-8">&#x00A0;</span><span
9875class="cmtt-8">&#x00A0;</span><span
9876class="cmtt-8">&#x00A0;</span><span
9877class="cmtt-8">&#x00A0;</span><span
9878class="cmtt-8">&#x00A0;12)</span><span
9879class="cmtt-8">&#x00A0;[temp]</span><span
9880class="cmtt-8">&#x00A0;=</span><span
9881class="cmtt-8">&#x00A0;[temp]</span><span
9882class="cmtt-8">&#x00A0;/</span><span
9883class="cmtt-8">&#x00A0;[residue\_classifications]</span><span
9884class="cmtt-8">&#x00A0;using</span><span
9885class="cmtt-8">&#x00A0;integer</span><span
9886class="cmtt-8">&#x00A0;division</span><br class="fancyvrb" /><a
9887 id="x1-112058r21"></a><span
9888class="cmr-6">21</span>
9889<br class="fancyvrb" /><a
9890 id="x1-112060r22"></a><span
9891class="cmr-6">22</span><span
9892class="cmtt-8">&#x00A0;</span><span
9893class="cmtt-8">&#x00A0;</span><span
9894class="cmtt-8">&#x00A0;</span><span
9895class="cmtt-8">&#x00A0;</span><span
9896class="cmtt-8">&#x00A0;</span><span
9897class="cmtt-8">&#x00A0;</span><span
9898class="cmtt-8">&#x00A0;</span><span
9899class="cmtt-8">&#x00A0;</span><span
9900class="cmtt-8">&#x00A0;</span><span
9901class="cmtt-8">&#x00A0;</span><span
9902class="cmtt-8">&#x00A0;</span><span
9903class="cmtt-8">&#x00A0;</span><span
9904class="cmtt-8">&#x00A0;</span><span
9905class="cmtt-8">&#x00A0;</span><span
9906class="cmtt-8">&#x00A0;</span><span
9907class="cmtt-8">&#x00A0;</span><span
9908class="cmtt-8">&#x00A0;</span><span
9909class="cmtt-8">&#x00A0;</span><span
9910class="cmtt-8">&#x00A0;</span><span
9911class="cmtt-8">&#x00A0;</span><span
9912class="cmtt-8">&#x00A0;</span><span
9913class="cmtt-8">&#x00A0;</span><span
9914class="cmtt-8">&#x00A0;</span><span
9915class="cmtt-8">&#x00A0;</span><span
9916class="cmtt-8">&#x00A0;</span><span
9917class="cmtt-8">&#x00A0;</span><span
9918class="cmtt-8">&#x00A0;</span><span
9919class="cmtt-8">&#x00A0;</span><span
9920class="cmtt-8">&#x00A0;</span><span
9921class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9922 id="x1-112062r23"></a><span
9923class="cmr-6">23</span><br class="fancyvrb" /><a
9924 id="x1-112064r24"></a><span
9925class="cmr-6">24</span><span
9926class="cmtt-8">&#x00A0;</span><span
9927class="cmtt-8">&#x00A0;</span><span
9928class="cmtt-8">&#x00A0;</span><span
9929class="cmtt-8">&#x00A0;</span><span
9930class="cmtt-8">&#x00A0;</span><span
9931class="cmtt-8">&#x00A0;</span><span
9932class="cmtt-8">&#x00A0;</span><span
9933class="cmtt-8">&#x00A0;</span><span
9934class="cmtt-8">&#x00A0;</span><span
9935class="cmtt-8">&#x00A0;</span><span
9936class="cmtt-8">&#x00A0;</span><span
9937class="cmtt-8">&#x00A0;</span><span
9938class="cmtt-8">&#x00A0;</span><span
9939class="cmtt-8">&#x00A0;</span><span
9940class="cmtt-8">&#x00A0;</span><span
9941class="cmtt-8">&#x00A0;</span><span
9942class="cmtt-8">&#x00A0;</span><span
9943class="cmtt-8">&#x00A0;</span><span
9944class="cmtt-8">&#x00A0;</span><span
9945class="cmtt-8">&#x00A0;</span><span
9946class="cmtt-8">&#x00A0;</span><span
9947class="cmtt-8">&#x00A0;</span><span
9948class="cmtt-8">&#x00A0;</span><span
9949class="cmtt-8">&#x00A0;</span><span
9950class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9951 id="x1-112066r25"></a><span
9952class="cmr-6">25</span><br class="fancyvrb" /><a
9953 id="x1-112068r26"></a><span
9954class="cmr-6">26</span><span
9955class="cmtt-8">&#x00A0;</span><span
9956class="cmtt-8">&#x00A0;</span><span
9957class="cmtt-8">&#x00A0;</span><span
9958class="cmtt-8">&#x00A0;</span><span
9959class="cmtt-8">&#x00A0;</span><span
9960class="cmtt-8">&#x00A0;</span><span
9961class="cmtt-8">&#x00A0;</span><span
9962class="cmtt-8">&#x00A0;</span><span
9963class="cmtt-8">&#x00A0;</span><span
9964class="cmtt-8">&#x00A0;</span><span
9965class="cmtt-8">&#x00A0;</span><span
9966class="cmtt-8">&#x00A0;</span><span
9967class="cmtt-8">&#x00A0;</span><span
9968class="cmtt-8">&#x00A0;</span><span
9969class="cmtt-8">&#x00A0;</span><span
9970class="cmtt-8">&#x00A0;</span><span
9971class="cmtt-8">&#x00A0;</span><span
9972class="cmtt-8">&#x00A0;</span><span
9973class="cmtt-8">&#x00A0;</span><span
9974class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9975 id="x1-112070r27"></a><span
9976class="cmr-6">27</span><br class="fancyvrb" /><a
9977 id="x1-112072r28"></a><span
9978class="cmr-6">28</span><span
9979class="cmtt-8">&#x00A0;</span><span
9980class="cmtt-8">&#x00A0;</span><span
9981class="cmtt-8">&#x00A0;</span><span
9982class="cmtt-8">&#x00A0;</span><span
9983class="cmtt-8">&#x00A0;</span><span
9984class="cmtt-8">&#x00A0;</span><span
9985class="cmtt-8">&#x00A0;</span><span
9986class="cmtt-8">&#x00A0;</span><span
9987class="cmtt-8">&#x00A0;</span><span
9988class="cmtt-8">&#x00A0;</span><span
9989class="cmtt-8">&#x00A0;</span><span
9990class="cmtt-8">&#x00A0;</span><span
9991class="cmtt-8">&#x00A0;</span><span
9992class="cmtt-8">&#x00A0;</span><span
9993class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
9994 id="x1-112074r29"></a><span
9995class="cmr-6">29</span>
9996<br class="fancyvrb" /><a
9997 id="x1-112076r30"></a><span
9998class="cmr-6">30</span><span
9999class="cmtt-8">&#x00A0;</span><span
10000class="cmtt-8">&#x00A0;</span><span
10001class="cmtt-8">&#x00A0;</span><span
10002class="cmtt-8">&#x00A0;</span><span
10003class="cmtt-8">&#x00A0;</span><span
10004class="cmtt-8">&#x00A0;</span><span
10005class="cmtt-8">&#x00A0;</span><span
10006class="cmtt-8">&#x00A0;</span><span
10007class="cmtt-8">&#x00A0;</span><span
10008class="cmtt-8">&#x00A0;</span><span
10009class="cmtt-8">&#x00A0;13)</span><span
10010class="cmtt-8">&#x00A0;iterate</span><span
10011class="cmtt-8">&#x00A0;[i]</span><span
10012class="cmtt-8">&#x00A0;over</span><span
10013class="cmtt-8">&#x00A0;the</span><span
10014class="cmtt-8">&#x00A0;range</span><span
10015class="cmtt-8">&#x00A0;0</span><span
10016class="cmtt-8">&#x00A0;..</span><span
10017class="cmtt-8">&#x00A0;([classwords\_per\_codeword]</span><span
10018class="cmtt-8">&#x00A0;-</span><span
10019class="cmtt-8">&#x00A0;1)</span><span
10020class="cmtt-8">&#x00A0;while</span><span
10021class="cmtt-8">&#x00A0;[partition\_count]</span>
10022<br class="fancyvrb" /><a
10023 id="x1-112078r31"></a><span
10024class="cmr-6">31</span><span
10025class="cmtt-8">&#x00A0;</span><span
10026class="cmtt-8">&#x00A0;</span><span
10027class="cmtt-8">&#x00A0;</span><span
10028class="cmtt-8">&#x00A0;</span><span
10029class="cmtt-8">&#x00A0;</span><span
10030class="cmtt-8">&#x00A0;</span><span
10031class="cmtt-8">&#x00A0;</span><span
10032class="cmtt-8">&#x00A0;</span><span
10033class="cmtt-8">&#x00A0;</span><span
10034class="cmtt-8">&#x00A0;</span><span
10035class="cmtt-8">&#x00A0;</span><span
10036class="cmtt-8">&#x00A0;</span><span
10037class="cmtt-8">&#x00A0;</span><span
10038class="cmtt-8">&#x00A0;</span><span
10039class="cmtt-8">&#x00A0;is</span><span
10040class="cmtt-8">&#x00A0;also</span><span
10041class="cmtt-8">&#x00A0;less</span><span
10042class="cmtt-8">&#x00A0;than</span><span
10043class="cmtt-8">&#x00A0;[partitions\_to\_read]</span><span
10044class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10045 id="x1-112080r32"></a><span
10046class="cmr-6">32</span><br class="fancyvrb" /><a
10047 id="x1-112082r33"></a><span
10048class="cmr-6">33</span><span
10049class="cmtt-8">&#x00A0;</span><span
10050class="cmtt-8">&#x00A0;</span><span
10051class="cmtt-8">&#x00A0;</span><span
10052class="cmtt-8">&#x00A0;</span><span
10053class="cmtt-8">&#x00A0;</span><span
10054class="cmtt-8">&#x00A0;</span><span
10055class="cmtt-8">&#x00A0;</span><span
10056class="cmtt-8">&#x00A0;</span><span
10057class="cmtt-8">&#x00A0;</span><span
10058class="cmtt-8">&#x00A0;</span><span
10059class="cmtt-8">&#x00A0;</span><span
10060class="cmtt-8">&#x00A0;</span><span
10061class="cmtt-8">&#x00A0;</span><span
10062class="cmtt-8">&#x00A0;</span><span
10063class="cmtt-8">&#x00A0;</span><span
10064class="cmtt-8">&#x00A0;</span><span
10065class="cmtt-8">&#x00A0;14)</span><span
10066class="cmtt-8">&#x00A0;iterate</span><span
10067class="cmtt-8">&#x00A0;[j]</span><span
10068class="cmtt-8">&#x00A0;over</span><span
10069class="cmtt-8">&#x00A0;the</span><span
10070class="cmtt-8">&#x00A0;range</span><span
10071class="cmtt-8">&#x00A0;0</span><span
10072class="cmtt-8">&#x00A0;..</span><span
10073class="cmtt-8">&#x00A0;[ch]-1</span><span
10074class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10075 id="x1-112084r34"></a><span
10076class="cmr-6">34</span>
10077<br class="fancyvrb" /><a
10078 id="x1-112086r35"></a><span
10079class="cmr-6">35</span><span
10080class="cmtt-8">&#x00A0;</span><span
10081class="cmtt-8">&#x00A0;</span><span
10082class="cmtt-8">&#x00A0;</span><span
10083class="cmtt-8">&#x00A0;</span><span
10084class="cmtt-8">&#x00A0;</span><span
10085class="cmtt-8">&#x00A0;</span><span
10086class="cmtt-8">&#x00A0;</span><span
10087class="cmtt-8">&#x00A0;</span><span
10088class="cmtt-8">&#x00A0;</span><span
10089class="cmtt-8">&#x00A0;</span><span
10090class="cmtt-8">&#x00A0;</span><span
10091class="cmtt-8">&#x00A0;</span><span
10092class="cmtt-8">&#x00A0;</span><span
10093class="cmtt-8">&#x00A0;</span><span
10094class="cmtt-8">&#x00A0;</span><span
10095class="cmtt-8">&#x00A0;</span><span
10096class="cmtt-8">&#x00A0;</span><span
10097class="cmtt-8">&#x00A0;</span><span
10098class="cmtt-8">&#x00A0;</span><span
10099class="cmtt-8">&#x00A0;</span><span
10100class="cmtt-8">&#x00A0;</span><span
10101class="cmtt-8">&#x00A0;15)</span><span
10102class="cmtt-8">&#x00A0;if</span><span
10103class="cmtt-8">&#x00A0;vector</span><span
10104class="cmtt-8">&#x00A0;[j]</span><span
10105class="cmtt-8">&#x00A0;is</span><span
10106class="cmtt-8">&#x00A0;not</span><span
10107class="cmtt-8">&#x00A0;marked</span><span
10108class="cmtt-8">&#x00A0;&#8217;do</span><span
10109class="cmtt-8">&#x00A0;not</span><span
10110class="cmtt-8">&#x00A0;decode&#8217;</span><span
10111class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10112 id="x1-112088r36"></a><span
10113class="cmr-6">36</span>
10114<br class="fancyvrb" /><a
10115 id="x1-112090r37"></a><span
10116class="cmr-6">37</span><span
10117class="cmtt-8">&#x00A0;</span><span
10118class="cmtt-8">&#x00A0;</span><span
10119class="cmtt-8">&#x00A0;</span><span
10120class="cmtt-8">&#x00A0;</span><span
10121class="cmtt-8">&#x00A0;</span><span
10122class="cmtt-8">&#x00A0;</span><span
10123class="cmtt-8">&#x00A0;</span><span
10124class="cmtt-8">&#x00A0;</span><span
10125class="cmtt-8">&#x00A0;</span><span
10126class="cmtt-8">&#x00A0;</span><span
10127class="cmtt-8">&#x00A0;</span><span
10128class="cmtt-8">&#x00A0;</span><span
10129class="cmtt-8">&#x00A0;</span><span
10130class="cmtt-8">&#x00A0;</span><span
10131class="cmtt-8">&#x00A0;</span><span
10132class="cmtt-8">&#x00A0;</span><span
10133class="cmtt-8">&#x00A0;</span><span
10134class="cmtt-8">&#x00A0;</span><span
10135class="cmtt-8">&#x00A0;</span><span
10136class="cmtt-8">&#x00A0;</span><span
10137class="cmtt-8">&#x00A0;</span><span
10138class="cmtt-8">&#x00A0;</span><span
10139class="cmtt-8">&#x00A0;</span><span
10140class="cmtt-8">&#x00A0;</span><span
10141class="cmtt-8">&#x00A0;</span><span
10142class="cmtt-8">&#x00A0;</span><span
10143class="cmtt-8">&#x00A0;16)</span><span
10144class="cmtt-8">&#x00A0;[vqclass]</span><span
10145class="cmtt-8">&#x00A0;=</span><span
10146class="cmtt-8">&#x00A0;array</span><span
10147class="cmtt-8">&#x00A0;[classifications]</span><span
10148class="cmtt-8">&#x00A0;element</span><span
10149class="cmtt-8">&#x00A0;[j],[partition\_count]</span>
10150<br class="fancyvrb" /><a
10151 id="x1-112092r38"></a><span
10152class="cmr-6">38</span><span
10153class="cmtt-8">&#x00A0;</span><span
10154class="cmtt-8">&#x00A0;</span><span
10155class="cmtt-8">&#x00A0;</span><span
10156class="cmtt-8">&#x00A0;</span><span
10157class="cmtt-8">&#x00A0;</span><span
10158class="cmtt-8">&#x00A0;</span><span
10159class="cmtt-8">&#x00A0;</span><span
10160class="cmtt-8">&#x00A0;</span><span
10161class="cmtt-8">&#x00A0;</span><span
10162class="cmtt-8">&#x00A0;</span><span
10163class="cmtt-8">&#x00A0;</span><span
10164class="cmtt-8">&#x00A0;</span><span
10165class="cmtt-8">&#x00A0;</span><span
10166class="cmtt-8">&#x00A0;</span><span
10167class="cmtt-8">&#x00A0;</span><span
10168class="cmtt-8">&#x00A0;</span><span
10169class="cmtt-8">&#x00A0;</span><span
10170class="cmtt-8">&#x00A0;</span><span
10171class="cmtt-8">&#x00A0;</span><span
10172class="cmtt-8">&#x00A0;</span><span
10173class="cmtt-8">&#x00A0;</span><span
10174class="cmtt-8">&#x00A0;</span><span
10175class="cmtt-8">&#x00A0;</span><span
10176class="cmtt-8">&#x00A0;</span><span
10177class="cmtt-8">&#x00A0;</span><span
10178class="cmtt-8">&#x00A0;</span><span
10179class="cmtt-8">&#x00A0;17)</span><span
10180class="cmtt-8">&#x00A0;[vqbook]</span><span
10181class="cmtt-8">&#x00A0;=</span><span
10182class="cmtt-8">&#x00A0;array</span><span
10183class="cmtt-8">&#x00A0;[residue\_books]</span><span
10184class="cmtt-8">&#x00A0;element</span><span
10185class="cmtt-8">&#x00A0;[vqclass],[pass]</span><br class="fancyvrb" /><a
10186 id="x1-112094r39"></a><span
10187class="cmr-6">39</span><span
10188class="cmtt-8">&#x00A0;</span><span
10189class="cmtt-8">&#x00A0;</span><span
10190class="cmtt-8">&#x00A0;</span><span
10191class="cmtt-8">&#x00A0;</span><span
10192class="cmtt-8">&#x00A0;</span><span
10193class="cmtt-8">&#x00A0;</span><span
10194class="cmtt-8">&#x00A0;</span><span
10195class="cmtt-8">&#x00A0;</span><span
10196class="cmtt-8">&#x00A0;</span><span
10197class="cmtt-8">&#x00A0;</span><span
10198class="cmtt-8">&#x00A0;</span><span
10199class="cmtt-8">&#x00A0;</span><span
10200class="cmtt-8">&#x00A0;</span><span
10201class="cmtt-8">&#x00A0;</span><span
10202class="cmtt-8">&#x00A0;</span><span
10203class="cmtt-8">&#x00A0;</span><span
10204class="cmtt-8">&#x00A0;</span><span
10205class="cmtt-8">&#x00A0;</span><span
10206class="cmtt-8">&#x00A0;</span><span
10207class="cmtt-8">&#x00A0;</span><span
10208class="cmtt-8">&#x00A0;</span><span
10209class="cmtt-8">&#x00A0;</span><span
10210class="cmtt-8">&#x00A0;</span><span
10211class="cmtt-8">&#x00A0;</span><span
10212class="cmtt-8">&#x00A0;</span><span
10213class="cmtt-8">&#x00A0;</span><span
10214class="cmtt-8">&#x00A0;18)</span><span
10215class="cmtt-8">&#x00A0;if</span><span
10216class="cmtt-8">&#x00A0;([vqbook]</span><span
10217class="cmtt-8">&#x00A0;is</span><span
10218class="cmtt-8">&#x00A0;not</span><span
10219class="cmtt-8">&#x00A0;&#8217;unused&#8217;)</span><span
10220class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10221 id="x1-112096r40"></a><span
10222class="cmr-6">40</span>
10223<br class="fancyvrb" /><a
10224 id="x1-112098r41"></a><span
10225class="cmr-6">41</span><span
10226class="cmtt-8">&#x00A0;</span><span
10227class="cmtt-8">&#x00A0;</span><span
10228class="cmtt-8">&#x00A0;</span><span
10229class="cmtt-8">&#x00A0;</span><span
10230class="cmtt-8">&#x00A0;</span><span
10231class="cmtt-8">&#x00A0;</span><span
10232class="cmtt-8">&#x00A0;</span><span
10233class="cmtt-8">&#x00A0;</span><span
10234class="cmtt-8">&#x00A0;</span><span
10235class="cmtt-8">&#x00A0;</span><span
10236class="cmtt-8">&#x00A0;</span><span
10237class="cmtt-8">&#x00A0;</span><span
10238class="cmtt-8">&#x00A0;</span><span
10239class="cmtt-8">&#x00A0;</span><span
10240class="cmtt-8">&#x00A0;</span><span
10241class="cmtt-8">&#x00A0;</span><span
10242class="cmtt-8">&#x00A0;</span><span
10243class="cmtt-8">&#x00A0;</span><span
10244class="cmtt-8">&#x00A0;</span><span
10245class="cmtt-8">&#x00A0;</span><span
10246class="cmtt-8">&#x00A0;</span><span
10247class="cmtt-8">&#x00A0;</span><span
10248class="cmtt-8">&#x00A0;</span><span
10249class="cmtt-8">&#x00A0;</span><span
10250class="cmtt-8">&#x00A0;</span><span
10251class="cmtt-8">&#x00A0;</span><span
10252class="cmtt-8">&#x00A0;</span><span
10253class="cmtt-8">&#x00A0;</span><span
10254class="cmtt-8">&#x00A0;</span><span
10255class="cmtt-8">&#x00A0;</span><span
10256class="cmtt-8">&#x00A0;</span><span
10257class="cmtt-8">&#x00A0;19)</span><span
10258class="cmtt-8">&#x00A0;decode</span><span
10259class="cmtt-8">&#x00A0;partition</span><span
10260class="cmtt-8">&#x00A0;into</span><span
10261class="cmtt-8">&#x00A0;output</span><span
10262class="cmtt-8">&#x00A0;vector</span><span
10263class="cmtt-8">&#x00A0;number</span><span
10264class="cmtt-8">&#x00A0;[j],</span><span
10265class="cmtt-8">&#x00A0;starting</span><span
10266class="cmtt-8">&#x00A0;at</span><span
10267class="cmtt-8">&#x00A0;scalar</span>
10268<br class="fancyvrb" /><a
10269 id="x1-112100r42"></a><span
10270class="cmr-6">42</span><span
10271class="cmtt-8">&#x00A0;</span><span
10272class="cmtt-8">&#x00A0;</span><span
10273class="cmtt-8">&#x00A0;</span><span
10274class="cmtt-8">&#x00A0;</span><span
10275class="cmtt-8">&#x00A0;</span><span
10276class="cmtt-8">&#x00A0;</span><span
10277class="cmtt-8">&#x00A0;</span><span
10278class="cmtt-8">&#x00A0;</span><span
10279class="cmtt-8">&#x00A0;</span><span
10280class="cmtt-8">&#x00A0;</span><span
10281class="cmtt-8">&#x00A0;</span><span
10282class="cmtt-8">&#x00A0;</span><span
10283class="cmtt-8">&#x00A0;</span><span
10284class="cmtt-8">&#x00A0;</span><span
10285class="cmtt-8">&#x00A0;</span><span
10286class="cmtt-8">&#x00A0;</span><span
10287class="cmtt-8">&#x00A0;</span><span
10288class="cmtt-8">&#x00A0;</span><span
10289class="cmtt-8">&#x00A0;</span><span
10290class="cmtt-8">&#x00A0;</span><span
10291class="cmtt-8">&#x00A0;</span><span
10292class="cmtt-8">&#x00A0;</span><span
10293class="cmtt-8">&#x00A0;</span><span
10294class="cmtt-8">&#x00A0;</span><span
10295class="cmtt-8">&#x00A0;</span><span
10296class="cmtt-8">&#x00A0;</span><span
10297class="cmtt-8">&#x00A0;</span><span
10298class="cmtt-8">&#x00A0;</span><span
10299class="cmtt-8">&#x00A0;</span><span
10300class="cmtt-8">&#x00A0;</span><span
10301class="cmtt-8">&#x00A0;</span><span
10302class="cmtt-8">&#x00A0;</span><span
10303class="cmtt-8">&#x00A0;</span><span
10304class="cmtt-8">&#x00A0;</span><span
10305class="cmtt-8">&#x00A0;</span><span
10306class="cmtt-8">&#x00A0;offset</span><span
10307class="cmtt-8">&#x00A0;[limit\_residue\_begin]+[partition\_count]*[residue\_partition\_size]</span><span
10308class="cmtt-8">&#x00A0;using</span>
10309<br class="fancyvrb" /><a
10310 id="x1-112102r43"></a><span
10311class="cmr-6">43</span><span
10312class="cmtt-8">&#x00A0;</span><span
10313class="cmtt-8">&#x00A0;</span><span
10314class="cmtt-8">&#x00A0;</span><span
10315class="cmtt-8">&#x00A0;</span><span
10316class="cmtt-8">&#x00A0;</span><span
10317class="cmtt-8">&#x00A0;</span><span
10318class="cmtt-8">&#x00A0;</span><span
10319class="cmtt-8">&#x00A0;</span><span
10320class="cmtt-8">&#x00A0;</span><span
10321class="cmtt-8">&#x00A0;</span><span
10322class="cmtt-8">&#x00A0;</span><span
10323class="cmtt-8">&#x00A0;</span><span
10324class="cmtt-8">&#x00A0;</span><span
10325class="cmtt-8">&#x00A0;</span><span
10326class="cmtt-8">&#x00A0;</span><span
10327class="cmtt-8">&#x00A0;</span><span
10328class="cmtt-8">&#x00A0;</span><span
10329class="cmtt-8">&#x00A0;</span><span
10330class="cmtt-8">&#x00A0;</span><span
10331class="cmtt-8">&#x00A0;</span><span
10332class="cmtt-8">&#x00A0;</span><span
10333class="cmtt-8">&#x00A0;</span><span
10334class="cmtt-8">&#x00A0;</span><span
10335class="cmtt-8">&#x00A0;</span><span
10336class="cmtt-8">&#x00A0;</span><span
10337class="cmtt-8">&#x00A0;</span><span
10338class="cmtt-8">&#x00A0;</span><span
10339class="cmtt-8">&#x00A0;</span><span
10340class="cmtt-8">&#x00A0;</span><span
10341class="cmtt-8">&#x00A0;</span><span
10342class="cmtt-8">&#x00A0;</span><span
10343class="cmtt-8">&#x00A0;</span><span
10344class="cmtt-8">&#x00A0;</span><span
10345class="cmtt-8">&#x00A0;</span><span
10346class="cmtt-8">&#x00A0;</span><span
10347class="cmtt-8">&#x00A0;codebook</span><span
10348class="cmtt-8">&#x00A0;number</span><span
10349class="cmtt-8">&#x00A0;[vqbook]</span><span
10350class="cmtt-8">&#x00A0;in</span><span
10351class="cmtt-8">&#x00A0;VQ</span><span
10352class="cmtt-8">&#x00A0;context</span><br class="fancyvrb" /><a
10353 id="x1-112104r44"></a><span
10354class="cmr-6">44</span><span
10355class="cmtt-8">&#x00A0;</span><span
10356class="cmtt-8">&#x00A0;</span><span
10357class="cmtt-8">&#x00A0;</span><span
10358class="cmtt-8">&#x00A0;</span><span
10359class="cmtt-8">&#x00A0;</span><span
10360class="cmtt-8">&#x00A0;</span><span
10361class="cmtt-8">&#x00A0;</span><span
10362class="cmtt-8">&#x00A0;</span><span
10363class="cmtt-8">&#x00A0;</span><span
10364class="cmtt-8">&#x00A0;</span><span
10365class="cmtt-8">&#x00A0;</span><span
10366class="cmtt-8">&#x00A0;</span><span
10367class="cmtt-8">&#x00A0;</span><span
10368class="cmtt-8">&#x00A0;</span><span
10369class="cmtt-8">&#x00A0;</span><span
10370class="cmtt-8">&#x00A0;</span><span
10371class="cmtt-8">&#x00A0;</span><span
10372class="cmtt-8">&#x00A0;</span><span
10373class="cmtt-8">&#x00A0;</span><span
10374class="cmtt-8">&#x00A0;</span><span
10375class="cmtt-8">&#x00A0;</span><span
10376class="cmtt-8">&#x00A0;</span><span
10377class="cmtt-8">&#x00A0;</span><span
10378class="cmtt-8">&#x00A0;</span><span
10379class="cmtt-8">&#x00A0;</span><span
10380class="cmtt-8">&#x00A0;}</span>
10381<br class="fancyvrb" /><a
10382 id="x1-112106r45"></a><span
10383class="cmr-6">45</span><span
10384class="cmtt-8">&#x00A0;</span><span
10385class="cmtt-8">&#x00A0;</span><span
10386class="cmtt-8">&#x00A0;</span><span
10387class="cmtt-8">&#x00A0;</span><span
10388class="cmtt-8">&#x00A0;</span><span
10389class="cmtt-8">&#x00A0;</span><span
10390class="cmtt-8">&#x00A0;</span><span
10391class="cmtt-8">&#x00A0;</span><span
10392class="cmtt-8">&#x00A0;</span><span
10393class="cmtt-8">&#x00A0;</span><span
10394class="cmtt-8">&#x00A0;</span><span
10395class="cmtt-8">&#x00A0;</span><span
10396class="cmtt-8">&#x00A0;</span><span
10397class="cmtt-8">&#x00A0;</span><span
10398class="cmtt-8">&#x00A0;</span><span
10399class="cmtt-8">&#x00A0;</span><span
10400class="cmtt-8">&#x00A0;</span><span
10401class="cmtt-8">&#x00A0;</span><span
10402class="cmtt-8">&#x00A0;</span><span
10403class="cmtt-8">&#x00A0;</span><span
10404class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10405 id="x1-112108r46"></a><span
10406class="cmr-6">46</span><br class="fancyvrb" /><a
10407 id="x1-112110r47"></a><span
10408class="cmr-6">47</span><span
10409class="cmtt-8">&#x00A0;</span><span
10410class="cmtt-8">&#x00A0;</span><span
10411class="cmtt-8">&#x00A0;</span><span
10412class="cmtt-8">&#x00A0;</span><span
10413class="cmtt-8">&#x00A0;</span><span
10414class="cmtt-8">&#x00A0;</span><span
10415class="cmtt-8">&#x00A0;</span><span
10416class="cmtt-8">&#x00A0;</span><span
10417class="cmtt-8">&#x00A0;</span><span
10418class="cmtt-8">&#x00A0;</span><span
10419class="cmtt-8">&#x00A0;</span><span
10420class="cmtt-8">&#x00A0;</span><span
10421class="cmtt-8">&#x00A0;</span><span
10422class="cmtt-8">&#x00A0;</span><span
10423class="cmtt-8">&#x00A0;</span><span
10424class="cmtt-8">&#x00A0;</span><span
10425class="cmtt-8">&#x00A0;20)</span><span
10426class="cmtt-8">&#x00A0;increment</span><span
10427class="cmtt-8">&#x00A0;[partition\_count]</span><span
10428class="cmtt-8">&#x00A0;by</span><span
10429class="cmtt-8">&#x00A0;one</span><br class="fancyvrb" /><a
10430 id="x1-112112r48"></a><span
10431class="cmr-6">48</span><br class="fancyvrb" /><a
10432 id="x1-112114r49"></a><span
10433class="cmr-6">49</span><span
10434class="cmtt-8">&#x00A0;</span><span
10435class="cmtt-8">&#x00A0;</span><span
10436class="cmtt-8">&#x00A0;</span><span
10437class="cmtt-8">&#x00A0;</span><span
10438class="cmtt-8">&#x00A0;</span><span
10439class="cmtt-8">&#x00A0;</span><span
10440class="cmtt-8">&#x00A0;</span><span
10441class="cmtt-8">&#x00A0;</span><span
10442class="cmtt-8">&#x00A0;</span><span
10443class="cmtt-8">&#x00A0;</span><span
10444class="cmtt-8">&#x00A0;</span><span
10445class="cmtt-8">&#x00A0;</span><span
10446class="cmtt-8">&#x00A0;</span><span
10447class="cmtt-8">&#x00A0;</span><span
10448class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10449 id="x1-112116r50"></a><span
10450class="cmr-6">50</span><span
10451class="cmtt-8">&#x00A0;</span><span
10452class="cmtt-8">&#x00A0;</span><span
10453class="cmtt-8">&#x00A0;</span><span
10454class="cmtt-8">&#x00A0;</span><span
10455class="cmtt-8">&#x00A0;</span><span
10456class="cmtt-8">&#x00A0;</span><span
10457class="cmtt-8">&#x00A0;</span><span
10458class="cmtt-8">&#x00A0;</span><span
10459class="cmtt-8">&#x00A0;</span><span
10460class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10461 id="x1-112118r51"></a><span
10462class="cmr-6">51</span><span
10463class="cmtt-8">&#x00A0;</span><span
10464class="cmtt-8">&#x00A0;</span><span
10465class="cmtt-8">&#x00A0;</span><span
10466class="cmtt-8">&#x00A0;</span><span
10467class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10468 id="x1-112120r52"></a><span
10469class="cmr-6">52</span><br class="fancyvrb" /><a
10470 id="x1-112122r53"></a><span
10471class="cmr-6">53</span><span
10472class="cmtt-8">&#x00A0;21)</span><span
10473class="cmtt-8">&#x00A0;done</span><br class="fancyvrb" /><a
10474 id="x1-112124r54"></a><span
10475class="cmr-6">54</span></div>
10476<!--l. 343--><p class="noindent" >An end-of-packet condition during packet decode is to be considered a nominal occurrence.
10477Decode returns the result of vector decode up to that point.
10478<!--l. 349--><p class="noindent" >
10479<h5 class="subsubsectionHead"><span class="titlemark">8.6.3. </span> <a
10480 id="x1-1130008.6.3"></a>format 0 specifics</h5>
10481<!--l. 351--><p class="noindent" >Format zero decodes partitions exactly as described earlier in the &#8217;Residue Format: residue 0&#8217;
10482section. The following pseudocode presents the same algorithm. Assume:
10483
10484
10485
10486 <ul class="itemize1">
10487 <li class="itemize"><span
10488class="cmtt-12">[n] </span>is the value in <span
10489class="cmtt-12">[residue</span><span
10490class="cmtt-12">_partition</span><span
10491class="cmtt-12">_size]</span>
10492 </li>
10493 <li class="itemize"><span
10494class="cmtt-12">[v] </span>is the residue vector
10495 </li>
10496 <li class="itemize"><span
10497class="cmtt-12">[offset] </span>is the beginning read offset in [v]</li></ul>
10498<!--l. 362--><p class="noindent" >
10499<div class="fancyvrb" id="fancyvrb41"><a
10500 id="x1-113002r1"></a><span
10501class="cmr-6">1</span><span
10502class="cmtt-8">&#x00A0;1)</span><span
10503class="cmtt-8">&#x00A0;[step]</span><span
10504class="cmtt-8">&#x00A0;=</span><span
10505class="cmtt-8">&#x00A0;[n]</span><span
10506class="cmtt-8">&#x00A0;/</span><span
10507class="cmtt-8">&#x00A0;[codebook\_dimensions]</span><br class="fancyvrb" /><a
10508 id="x1-113004r2"></a><span
10509class="cmr-6">2</span><span
10510class="cmtt-8">&#x00A0;2)</span><span
10511class="cmtt-8">&#x00A0;iterate</span><span
10512class="cmtt-8">&#x00A0;[i]</span><span
10513class="cmtt-8">&#x00A0;over</span><span
10514class="cmtt-8">&#x00A0;the</span><span
10515class="cmtt-8">&#x00A0;range</span><span
10516class="cmtt-8">&#x00A0;0</span><span
10517class="cmtt-8">&#x00A0;...</span><span
10518class="cmtt-8">&#x00A0;[step]-1</span><span
10519class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10520 id="x1-113006r3"></a><span
10521class="cmr-6">3</span>
10522<br class="fancyvrb" /><a
10523 id="x1-113008r4"></a><span
10524class="cmr-6">4</span><span
10525class="cmtt-8">&#x00A0;</span><span
10526class="cmtt-8">&#x00A0;</span><span
10527class="cmtt-8">&#x00A0;</span><span
10528class="cmtt-8">&#x00A0;</span><span
10529class="cmtt-8">&#x00A0;</span><span
10530class="cmtt-8">&#x00A0;3)</span><span
10531class="cmtt-8">&#x00A0;vector</span><span
10532class="cmtt-8">&#x00A0;[entry\_temp]</span><span
10533class="cmtt-8">&#x00A0;=</span><span
10534class="cmtt-8">&#x00A0;read</span><span
10535class="cmtt-8">&#x00A0;vector</span><span
10536class="cmtt-8">&#x00A0;from</span><span
10537class="cmtt-8">&#x00A0;packet</span><span
10538class="cmtt-8">&#x00A0;using</span><span
10539class="cmtt-8">&#x00A0;current</span><span
10540class="cmtt-8">&#x00A0;codebook</span><span
10541class="cmtt-8">&#x00A0;in</span><span
10542class="cmtt-8">&#x00A0;VQ</span><span
10543class="cmtt-8">&#x00A0;context</span>
10544<br class="fancyvrb" /><a
10545 id="x1-113010r5"></a><span
10546class="cmr-6">5</span><span
10547class="cmtt-8">&#x00A0;</span><span
10548class="cmtt-8">&#x00A0;</span><span
10549class="cmtt-8">&#x00A0;</span><span
10550class="cmtt-8">&#x00A0;</span><span
10551class="cmtt-8">&#x00A0;</span><span
10552class="cmtt-8">&#x00A0;4)</span><span
10553class="cmtt-8">&#x00A0;iterate</span><span
10554class="cmtt-8">&#x00A0;[j]</span><span
10555class="cmtt-8">&#x00A0;over</span><span
10556class="cmtt-8">&#x00A0;the</span><span
10557class="cmtt-8">&#x00A0;range</span><span
10558class="cmtt-8">&#x00A0;0</span><span
10559class="cmtt-8">&#x00A0;...</span><span
10560class="cmtt-8">&#x00A0;[codebook\_dimensions]-1</span><span
10561class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10562 id="x1-113012r6"></a><span
10563class="cmr-6">6</span><br class="fancyvrb" /><a
10564 id="x1-113014r7"></a><span
10565class="cmr-6">7</span><span
10566class="cmtt-8">&#x00A0;</span><span
10567class="cmtt-8">&#x00A0;</span><span
10568class="cmtt-8">&#x00A0;</span><span
10569class="cmtt-8">&#x00A0;</span><span
10570class="cmtt-8">&#x00A0;</span><span
10571class="cmtt-8">&#x00A0;</span><span
10572class="cmtt-8">&#x00A0;</span><span
10573class="cmtt-8">&#x00A0;</span><span
10574class="cmtt-8">&#x00A0;</span><span
10575class="cmtt-8">&#x00A0;</span><span
10576class="cmtt-8">&#x00A0;5)</span><span
10577class="cmtt-8">&#x00A0;vector</span><span
10578class="cmtt-8">&#x00A0;[v]</span><span
10579class="cmtt-8">&#x00A0;element</span><span
10580class="cmtt-8">&#x00A0;([offset]+[i]+[j]*[step])</span><span
10581class="cmtt-8">&#x00A0;=</span>
10582<br class="fancyvrb" /><a
10583 id="x1-113016r8"></a><span
10584class="cmr-6">8</span> <span
10585class="cmtt-8">&#x00A0;</span><span
10586class="cmtt-8">&#x00A0;</span><span
10587class="cmtt-8">&#x00A0;</span><span
10588class="cmtt-8">&#x00A0;</span><span
10589class="cmtt-8">&#x00A0;</span><span
10590class="cmtt-8">&#x00A0;</span><span
10591class="cmtt-8">&#x00A0;</span><span
10592class="cmtt-8">&#x00A0;vector</span><span
10593class="cmtt-8">&#x00A0;[v]</span><span
10594class="cmtt-8">&#x00A0;element</span><span
10595class="cmtt-8">&#x00A0;([offset]+[i]+[j]*[step])</span><span
10596class="cmtt-8">&#x00A0;+</span><br class="fancyvrb" /><a
10597 id="x1-113018r9"></a><span
10598class="cmr-6">9</span><span
10599class="cmtt-8">&#x00A0;</span><span
10600class="cmtt-8">&#x00A0;</span><span
10601class="cmtt-8">&#x00A0;</span><span
10602class="cmtt-8">&#x00A0;</span><span
10603class="cmtt-8">&#x00A0;</span><span
10604class="cmtt-8">&#x00A0;</span><span
10605class="cmtt-8">&#x00A0;</span><span
10606class="cmtt-8">&#x00A0;</span><span
10607class="cmtt-8">&#x00A0;</span><span
10608class="cmtt-8">&#x00A0;</span><span
10609class="cmtt-8">&#x00A0;</span><span
10610class="cmtt-8">&#x00A0;</span><span
10611class="cmtt-8">&#x00A0;</span><span
10612class="cmtt-8">&#x00A0;</span><span
10613class="cmtt-8">&#x00A0;</span><span
10614class="cmtt-8">&#x00A0;vector</span><span
10615class="cmtt-8">&#x00A0;[entry\_temp]</span><span
10616class="cmtt-8">&#x00A0;element</span><span
10617class="cmtt-8">&#x00A0;[j]</span><br class="fancyvrb" /><a
10618 id="x1-113020r10"></a><span
10619class="cmr-6">10</span><br class="fancyvrb" /><a
10620 id="x1-113022r11"></a><span
10621class="cmr-6">11</span><span
10622class="cmtt-8">&#x00A0;</span><span
10623class="cmtt-8">&#x00A0;</span><span
10624class="cmtt-8">&#x00A0;</span><span
10625class="cmtt-8">&#x00A0;</span><span
10626class="cmtt-8">&#x00A0;</span><span
10627class="cmtt-8">&#x00A0;</span><span
10628class="cmtt-8">&#x00A0;</span><span
10629class="cmtt-8">&#x00A0;</span><span
10630class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10631 id="x1-113024r12"></a><span
10632class="cmr-6">12</span><br class="fancyvrb" /><a
10633 id="x1-113026r13"></a><span
10634class="cmr-6">13</span><span
10635class="cmtt-8">&#x00A0;</span><span
10636class="cmtt-8">&#x00A0;</span><span
10637class="cmtt-8">&#x00A0;</span><span
10638class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10639 id="x1-113028r14"></a><span
10640class="cmr-6">14</span><br class="fancyvrb" /><a
10641 id="x1-113030r15"></a><span
10642class="cmr-6">15</span><span
10643class="cmtt-8">&#x00A0;</span><span
10644class="cmtt-8">&#x00A0;6)</span><span
10645class="cmtt-8">&#x00A0;done</span><br class="fancyvrb" /><a
10646 id="x1-113032r16"></a><span
10647class="cmr-6">16</span></div>
10648<!--l. 383--><p class="noindent" >
10649<h5 class="subsubsectionHead"><span class="titlemark">8.6.4. </span> <a
10650 id="x1-1140008.6.4"></a>format 1 specifics</h5>
10651<!--l. 385--><p class="noindent" >Format 1 decodes partitions exactly as described earlier in the &#8217;Residue Format: residue 1&#8217;
10652section. The following pseudocode presents the same algorithm. Assume:
10653 <ul class="itemize1">
10654 <li class="itemize"><span
10655class="cmtt-12">[n] </span>is the value in <span
10656class="cmtt-12">[residue</span><span
10657class="cmtt-12">_partition</span><span
10658class="cmtt-12">_size]</span>
10659 </li>
10660 <li class="itemize"><span
10661class="cmtt-12">[v] </span>is the residue vector
10662 </li>
10663 <li class="itemize"><span
10664class="cmtt-12">[offset] </span>is the beginning read offset in [v]</li></ul>
10665<!--l. 397--><p class="noindent" >
10666<div class="fancyvrb" id="fancyvrb42"><a
10667 id="x1-114002r1"></a><span
10668class="cmr-6">1</span><span
10669class="cmtt-8">&#x00A0;1)</span><span
10670class="cmtt-8">&#x00A0;[i]</span><span
10671class="cmtt-8">&#x00A0;=</span><span
10672class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
10673 id="x1-114004r2"></a><span
10674class="cmr-6">2</span><span
10675class="cmtt-8">&#x00A0;2)</span><span
10676class="cmtt-8">&#x00A0;vector</span><span
10677class="cmtt-8">&#x00A0;[entry\_temp]</span><span
10678class="cmtt-8">&#x00A0;=</span><span
10679class="cmtt-8">&#x00A0;read</span><span
10680class="cmtt-8">&#x00A0;vector</span><span
10681class="cmtt-8">&#x00A0;from</span><span
10682class="cmtt-8">&#x00A0;packet</span><span
10683class="cmtt-8">&#x00A0;using</span><span
10684class="cmtt-8">&#x00A0;current</span><span
10685class="cmtt-8">&#x00A0;codebook</span><span
10686class="cmtt-8">&#x00A0;in</span><span
10687class="cmtt-8">&#x00A0;VQ</span><span
10688class="cmtt-8">&#x00A0;context</span>
10689<br class="fancyvrb" /><a
10690 id="x1-114006r3"></a><span
10691class="cmr-6">3</span><span
10692class="cmtt-8">&#x00A0;3)</span><span
10693class="cmtt-8">&#x00A0;iterate</span><span
10694class="cmtt-8">&#x00A0;[j]</span><span
10695class="cmtt-8">&#x00A0;over</span><span
10696class="cmtt-8">&#x00A0;the</span><span
10697class="cmtt-8">&#x00A0;range</span><span
10698class="cmtt-8">&#x00A0;0</span><span
10699class="cmtt-8">&#x00A0;...</span><span
10700class="cmtt-8">&#x00A0;[codebook\_dimensions]-1</span><span
10701class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10702 id="x1-114008r4"></a><span
10703class="cmr-6">4</span><br class="fancyvrb" /><a
10704 id="x1-114010r5"></a><span
10705class="cmr-6">5</span><span
10706class="cmtt-8">&#x00A0;</span><span
10707class="cmtt-8">&#x00A0;</span><span
10708class="cmtt-8">&#x00A0;</span><span
10709class="cmtt-8">&#x00A0;</span><span
10710class="cmtt-8">&#x00A0;</span><span
10711class="cmtt-8">&#x00A0;4)</span><span
10712class="cmtt-8">&#x00A0;vector</span><span
10713class="cmtt-8">&#x00A0;[v]</span><span
10714class="cmtt-8">&#x00A0;element</span><span
10715class="cmtt-8">&#x00A0;([offset]+[i])</span><span
10716class="cmtt-8">&#x00A0;=</span><br class="fancyvrb" /><a
10717 id="x1-114012r6"></a><span
10718class="cmr-6">6</span> <span
10719class="cmtt-8">&#x00A0;</span><span
10720class="cmtt-8">&#x00A0;vector</span><span
10721class="cmtt-8">&#x00A0;[v]</span><span
10722class="cmtt-8">&#x00A0;element</span><span
10723class="cmtt-8">&#x00A0;([offset]+[i])</span><span
10724class="cmtt-8">&#x00A0;+</span>
10725<br class="fancyvrb" /><a
10726 id="x1-114014r7"></a><span
10727class="cmr-6">7</span><span
10728class="cmtt-8">&#x00A0;</span><span
10729class="cmtt-8">&#x00A0;</span><span
10730class="cmtt-8">&#x00A0;</span><span
10731class="cmtt-8">&#x00A0;</span><span
10732class="cmtt-8">&#x00A0;</span><span
10733class="cmtt-8">&#x00A0;</span><span
10734class="cmtt-8">&#x00A0;</span><span
10735class="cmtt-8">&#x00A0;</span><span
10736class="cmtt-8">&#x00A0;</span><span
10737class="cmtt-8">&#x00A0;vector</span><span
10738class="cmtt-8">&#x00A0;[entry\_temp]</span><span
10739class="cmtt-8">&#x00A0;element</span><span
10740class="cmtt-8">&#x00A0;[j]</span><br class="fancyvrb" /><a
10741 id="x1-114016r8"></a><span
10742class="cmr-6">8</span><span
10743class="cmtt-8">&#x00A0;</span><span
10744class="cmtt-8">&#x00A0;</span><span
10745class="cmtt-8">&#x00A0;</span><span
10746class="cmtt-8">&#x00A0;</span><span
10747class="cmtt-8">&#x00A0;</span><span
10748class="cmtt-8">&#x00A0;5)</span><span
10749class="cmtt-8">&#x00A0;increment</span><span
10750class="cmtt-8">&#x00A0;[i]</span><br class="fancyvrb" /><a
10751 id="x1-114018r9"></a><span
10752class="cmr-6">9</span><br class="fancyvrb" /><a
10753 id="x1-114020r10"></a><span
10754class="cmr-6">10</span><span
10755class="cmtt-8">&#x00A0;</span><span
10756class="cmtt-8">&#x00A0;</span><span
10757class="cmtt-8">&#x00A0;</span><span
10758class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10759 id="x1-114022r11"></a><span
10760class="cmr-6">11</span><br class="fancyvrb" /><a
10761 id="x1-114024r12"></a><span
10762class="cmr-6">12</span><span
10763class="cmtt-8">&#x00A0;</span><span
10764class="cmtt-8">&#x00A0;6)</span><span
10765class="cmtt-8">&#x00A0;if</span><span
10766class="cmtt-8">&#x00A0;(</span><span
10767class="cmtt-8">&#x00A0;[i]</span><span
10768class="cmtt-8">&#x00A0;is</span><span
10769class="cmtt-8">&#x00A0;less</span><span
10770class="cmtt-8">&#x00A0;than</span><span
10771class="cmtt-8">&#x00A0;[n]</span><span
10772class="cmtt-8">&#x00A0;)</span><span
10773class="cmtt-8">&#x00A0;continue</span><span
10774class="cmtt-8">&#x00A0;at</span><span
10775class="cmtt-8">&#x00A0;step</span><span
10776class="cmtt-8">&#x00A0;2</span><br class="fancyvrb" /><a
10777 id="x1-114026r13"></a><span
10778class="cmr-6">13</span><span
10779class="cmtt-8">&#x00A0;</span><span
10780class="cmtt-8">&#x00A0;7)</span><span
10781class="cmtt-8">&#x00A0;done</span></div>
10782<!--l. 415--><p class="noindent" >
10783<h5 class="subsubsectionHead"><span class="titlemark">8.6.5. </span> <a
10784 id="x1-1150008.6.5"></a>format 2 specifics</h5>
10785
10786
10787
10788<!--l. 417--><p class="noindent" >Format 2 is reducible to format 1. It may be implemented as an additional step prior to and an
10789additional post-decode step after a normal format 1 decode.
10790<!--l. 420--><p class="noindent" >Format 2 handles &#8217;do not decode&#8217; vectors differently than residue 0 or 1; if all vectors are marked
10791&#8217;do not decode&#8217;, no decode occurrs. However, if at least one vector is to be decoded, all
10792the vectors are decoded. We then request normal format 1 to decode a single vector
10793representing all output channels, rather than a vector for each channel. After decode,
10794deinterleave the vector into independent vectors, one for each output channel. That
10795is:
10796<!--l. 428--><p class="noindent" >
10797 <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
10798 1. </dt><dd
10799class="enumerate-enumitem">If all vectors 0 through <span
10800class="cmti-12">ch</span>-1 are marked &#8217;do not decode&#8217;, allocate and clear a single
10801 vector <span
10802class="cmtt-12">[v]</span>of length <span
10803class="cmti-12">ch*n </span>and skip step 2 below; proceed directly to the post-decode
10804 step.
10805 </dd><dt class="enumerate-enumitem">
10806 2. </dt><dd
10807class="enumerate-enumitem">Rather than performing format 1 decode to produce <span
10808class="cmti-12">ch </span>vectors of length <span
10809class="cmti-12">n </span>each, call
10810 format 1 decode to produce a single vector <span
10811class="cmtt-12">[v] </span>of length <span
10812class="cmti-12">ch*n</span>.
10813 </dd><dt class="enumerate-enumitem">
10814 3. </dt><dd
10815class="enumerate-enumitem">Post decode: Deinterleave the single vector <span
10816class="cmtt-12">[v] </span>returned by format 1 decode as
10817 described above into <span
10818class="cmti-12">ch </span>independent vectors, one for each outputchannel, according
10819 to:
10820 <div class="fancyvrb" id="fancyvrb43"><a
10821 id="x1-115005r1"></a><span
10822class="cmr-6">1</span><span
10823class="cmtt-8">&#x00A0;</span><span
10824class="cmtt-8">&#x00A0;1)</span><span
10825class="cmtt-8">&#x00A0;iterate</span><span
10826class="cmtt-8">&#x00A0;[i]</span><span
10827class="cmtt-8">&#x00A0;over</span><span
10828class="cmtt-8">&#x00A0;the</span><span
10829class="cmtt-8">&#x00A0;range</span><span
10830class="cmtt-8">&#x00A0;0</span><span
10831class="cmtt-8">&#x00A0;...</span><span
10832class="cmtt-8">&#x00A0;[n]-1</span><span
10833class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10834 id="x1-115007r2"></a><span
10835class="cmr-6">2</span><br class="fancyvrb" /><a
10836 id="x1-115009r3"></a><span
10837class="cmr-6">3</span><span
10838class="cmtt-8">&#x00A0;</span><span
10839class="cmtt-8">&#x00A0;</span><span
10840class="cmtt-8">&#x00A0;</span><span
10841class="cmtt-8">&#x00A0;</span><span
10842class="cmtt-8">&#x00A0;</span><span
10843class="cmtt-8">&#x00A0;</span><span
10844class="cmtt-8">&#x00A0;2)</span><span
10845class="cmtt-8">&#x00A0;iterate</span><span
10846class="cmtt-8">&#x00A0;[j]</span><span
10847class="cmtt-8">&#x00A0;over</span><span
10848class="cmtt-8">&#x00A0;the</span><span
10849class="cmtt-8">&#x00A0;range</span><span
10850class="cmtt-8">&#x00A0;0</span><span
10851class="cmtt-8">&#x00A0;...</span><span
10852class="cmtt-8">&#x00A0;[ch]-1</span><span
10853class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10854 id="x1-115011r4"></a><span
10855class="cmr-6">4</span>
10856 <br class="fancyvrb" /><a
10857 id="x1-115013r5"></a><span
10858class="cmr-6">5</span><span
10859class="cmtt-8">&#x00A0;</span><span
10860class="cmtt-8">&#x00A0;</span><span
10861class="cmtt-8">&#x00A0;</span><span
10862class="cmtt-8">&#x00A0;</span><span
10863class="cmtt-8">&#x00A0;</span><span
10864class="cmtt-8">&#x00A0;</span><span
10865class="cmtt-8">&#x00A0;</span><span
10866class="cmtt-8">&#x00A0;</span><span
10867class="cmtt-8">&#x00A0;</span><span
10868class="cmtt-8">&#x00A0;</span><span
10869class="cmtt-8">&#x00A0;</span><span
10870class="cmtt-8">&#x00A0;3)</span><span
10871class="cmtt-8">&#x00A0;output</span><span
10872class="cmtt-8">&#x00A0;vector</span><span
10873class="cmtt-8">&#x00A0;number</span><span
10874class="cmtt-8">&#x00A0;[j]</span><span
10875class="cmtt-8">&#x00A0;element</span><span
10876class="cmtt-8">&#x00A0;[i]</span><span
10877class="cmtt-8">&#x00A0;=</span><span
10878class="cmtt-8">&#x00A0;vector</span><span
10879class="cmtt-8">&#x00A0;[v]</span><span
10880class="cmtt-8">&#x00A0;element</span><span
10881class="cmtt-8">&#x00A0;([i]</span><span
10882class="cmtt-8">&#x00A0;*</span><span
10883class="cmtt-8">&#x00A0;[ch]</span><span
10884class="cmtt-8">&#x00A0;+</span><span
10885class="cmtt-8">&#x00A0;[j])</span><br class="fancyvrb" /><a
10886 id="x1-115015r6"></a><span
10887class="cmr-6">6</span><br class="fancyvrb" /><a
10888 id="x1-115017r7"></a><span
10889class="cmr-6">7</span><span
10890class="cmtt-8">&#x00A0;</span><span
10891class="cmtt-8">&#x00A0;</span><span
10892class="cmtt-8">&#x00A0;</span><span
10893class="cmtt-8">&#x00A0;</span><span
10894class="cmtt-8">&#x00A0;</span><span
10895class="cmtt-8">&#x00A0;</span><span
10896class="cmtt-8">&#x00A0;</span><span
10897class="cmtt-8">&#x00A0;</span><span
10898class="cmtt-8">&#x00A0;</span><span
10899class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10900 id="x1-115019r8"></a><span
10901class="cmr-6">8</span><span
10902class="cmtt-8">&#x00A0;</span><span
10903class="cmtt-8">&#x00A0;</span><span
10904class="cmtt-8">&#x00A0;</span><span
10905class="cmtt-8">&#x00A0;</span><span
10906class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
10907 id="x1-115021r9"></a><span
10908class="cmr-6">9</span><br class="fancyvrb" /><a
10909 id="x1-115023r10"></a><span
10910class="cmr-6">10</span><span
10911class="cmtt-8">&#x00A0;</span><span
10912class="cmtt-8">&#x00A0;4)</span><span
10913class="cmtt-8">&#x00A0;done</span></div>
10914 </dd></dl>
10915
10916
10917
10918
10919
10920
10921<h3 class="sectionHead"><span class="titlemark">9. </span> <a
10922 id="x1-1160009"></a>Helper equations</h3>
10923<!--l. 5--><p class="noindent" >
10924<h4 class="subsectionHead"><span class="titlemark">9.1. </span> <a
10925 id="x1-1170009.1"></a>Overview</h4>
10926<!--l. 7--><p class="noindent" >The equations below are used in multiple places by the Vorbis codec specification. Rather than
10927cluttering up the main specification documents, they are defined here and referenced where
10928appropriate.
10929<!--l. 12--><p class="noindent" >
10930<h4 class="subsectionHead"><span class="titlemark">9.2. </span> <a
10931 id="x1-1180009.2"></a>Functions</h4>
10932<!--l. 14--><p class="noindent" >
10933<h5 class="subsubsectionHead"><span class="titlemark">9.2.1. </span> <a
10934 id="x1-1190009.2.1"></a>ilog</h5>
10935<!--l. 16--><p class="noindent" >The &#8221;ilog(x)&#8221; function returns the position number (1 through n) of the highest set bit in the
10936two&#8217;s complement integer value <span
10937class="cmtt-12">[x]</span>. Values of <span
10938class="cmtt-12">[x] </span>less than zero are defined to return
10939zero.
10940<!--l. 19--><p class="noindent" >
10941<div class="fancyvrb" id="fancyvrb44"><a
10942 id="x1-119002r1"></a><span
10943class="cmr-6">1</span><span
10944class="cmtt-8">&#x00A0;</span><span
10945class="cmtt-8">&#x00A0;1)</span><span
10946class="cmtt-8">&#x00A0;[return\_value]</span><span
10947class="cmtt-8">&#x00A0;=</span><span
10948class="cmtt-8">&#x00A0;0;</span><br class="fancyvrb" /><a
10949 id="x1-119004r2"></a><span
10950class="cmr-6">2</span><span
10951class="cmtt-8">&#x00A0;</span><span
10952class="cmtt-8">&#x00A0;2)</span><span
10953class="cmtt-8">&#x00A0;if</span><span
10954class="cmtt-8">&#x00A0;(</span><span
10955class="cmtt-8">&#x00A0;[x]</span><span
10956class="cmtt-8">&#x00A0;is</span><span
10957class="cmtt-8">&#x00A0;greater</span><span
10958class="cmtt-8">&#x00A0;than</span><span
10959class="cmtt-8">&#x00A0;zero</span><span
10960class="cmtt-8">&#x00A0;)</span><span
10961class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
10962 id="x1-119006r3"></a><span
10963class="cmr-6">3</span><br class="fancyvrb" /><a
10964 id="x1-119008r4"></a><span
10965class="cmr-6">4</span><span
10966class="cmtt-8">&#x00A0;</span><span
10967class="cmtt-8">&#x00A0;</span><span
10968class="cmtt-8">&#x00A0;</span><span
10969class="cmtt-8">&#x00A0;</span><span
10970class="cmtt-8">&#x00A0;</span><span
10971class="cmtt-8">&#x00A0;</span><span
10972class="cmtt-8">&#x00A0;3)</span><span
10973class="cmtt-8">&#x00A0;increment</span><span
10974class="cmtt-8">&#x00A0;[return\_value];</span>
10975<br class="fancyvrb" /><a
10976 id="x1-119010r5"></a><span
10977class="cmr-6">5</span><span
10978class="cmtt-8">&#x00A0;</span><span
10979class="cmtt-8">&#x00A0;</span><span
10980class="cmtt-8">&#x00A0;</span><span
10981class="cmtt-8">&#x00A0;</span><span
10982class="cmtt-8">&#x00A0;</span><span
10983class="cmtt-8">&#x00A0;</span><span
10984class="cmtt-8">&#x00A0;4)</span><span
10985class="cmtt-8">&#x00A0;logical</span><span
10986class="cmtt-8">&#x00A0;shift</span><span
10987class="cmtt-8">&#x00A0;[x]</span><span
10988class="cmtt-8">&#x00A0;one</span><span
10989class="cmtt-8">&#x00A0;bit</span><span
10990class="cmtt-8">&#x00A0;to</span><span
10991class="cmtt-8">&#x00A0;the</span><span
10992class="cmtt-8">&#x00A0;right,</span><span
10993class="cmtt-8">&#x00A0;padding</span><span
10994class="cmtt-8">&#x00A0;the</span><span
10995class="cmtt-8">&#x00A0;MSb</span><span
10996class="cmtt-8">&#x00A0;with</span><span
10997class="cmtt-8">&#x00A0;zero</span><br class="fancyvrb" /><a
10998 id="x1-119012r6"></a><span
10999class="cmr-6">6</span><span
11000class="cmtt-8">&#x00A0;</span><span
11001class="cmtt-8">&#x00A0;</span><span
11002class="cmtt-8">&#x00A0;</span><span
11003class="cmtt-8">&#x00A0;</span><span
11004class="cmtt-8">&#x00A0;</span><span
11005class="cmtt-8">&#x00A0;</span><span
11006class="cmtt-8">&#x00A0;5)</span><span
11007class="cmtt-8">&#x00A0;repeat</span><span
11008class="cmtt-8">&#x00A0;at</span><span
11009class="cmtt-8">&#x00A0;step</span><span
11010class="cmtt-8">&#x00A0;2)</span><br class="fancyvrb" /><a
11011 id="x1-119014r7"></a><span
11012class="cmr-6">7</span><br class="fancyvrb" /><a
11013 id="x1-119016r8"></a><span
11014class="cmr-6">8</span><span
11015class="cmtt-8">&#x00A0;</span><span
11016class="cmtt-8">&#x00A0;</span><span
11017class="cmtt-8">&#x00A0;</span><span
11018class="cmtt-8">&#x00A0;</span><span
11019class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
11020 id="x1-119018r9"></a><span
11021class="cmr-6">9</span><br class="fancyvrb" /><a
11022 id="x1-119020r10"></a><span
11023class="cmr-6">10</span><span
11024class="cmtt-8">&#x00A0;</span><span
11025class="cmtt-8">&#x00A0;</span><span
11026class="cmtt-8">&#x00A0;6)</span><span
11027class="cmtt-8">&#x00A0;done</span></div>
11028<!--l. 32--><p class="noindent" >Examples:
11029 <ul class="itemize1">
11030 <li class="itemize">ilog(0) = 0;
11031 </li>
11032 <li class="itemize">ilog(1) = 1;
11033
11034
11035
11036 </li>
11037 <li class="itemize">ilog(2) = 2;
11038 </li>
11039 <li class="itemize">ilog(3) = 2;
11040 </li>
11041 <li class="itemize">ilog(4) = 3;
11042 </li>
11043 <li class="itemize">ilog(7) = 3;
11044 </li>
11045 <li class="itemize">ilog(negative number) = 0;</li></ul>
11046<!--l. 47--><p class="noindent" >
11047<h5 class="subsubsectionHead"><span class="titlemark">9.2.2. </span> <a
11048 id="x1-1200009.2.2"></a>float32_unpack</h5>
11049<!--l. 49--><p class="noindent" >&#8221;float32_unpack(x)&#8221; is intended to translate the packed binary representation of a Vorbis
11050codebook float value into the representation used by the decoder for floating point numbers. For
11051purposes of this example, we will unpack a Vorbis float32 into a host-native floating point
11052number.
11053<!--l. 55--><p class="noindent" >
11054<div class="fancyvrb" id="fancyvrb45"><a
11055 id="x1-120002r1"></a><span
11056class="cmr-6">1</span><span
11057class="cmtt-8">&#x00A0;</span><span
11058class="cmtt-8">&#x00A0;1)</span><span
11059class="cmtt-8">&#x00A0;[mantissa]</span><span
11060class="cmtt-8">&#x00A0;=</span><span
11061class="cmtt-8">&#x00A0;[x]</span><span
11062class="cmtt-8">&#x00A0;bitwise</span><span
11063class="cmtt-8">&#x00A0;AND</span><span
11064class="cmtt-8">&#x00A0;0x1fffff</span><span
11065class="cmtt-8">&#x00A0;(unsigned</span><span
11066class="cmtt-8">&#x00A0;result)</span><br class="fancyvrb" /><a
11067 id="x1-120004r2"></a><span
11068class="cmr-6">2</span><span
11069class="cmtt-8">&#x00A0;</span><span
11070class="cmtt-8">&#x00A0;2)</span><span
11071class="cmtt-8">&#x00A0;[sign]</span><span
11072class="cmtt-8">&#x00A0;=</span><span
11073class="cmtt-8">&#x00A0;[x]</span><span
11074class="cmtt-8">&#x00A0;bitwise</span><span
11075class="cmtt-8">&#x00A0;AND</span><span
11076class="cmtt-8">&#x00A0;0x80000000</span><span
11077class="cmtt-8">&#x00A0;(unsigned</span><span
11078class="cmtt-8">&#x00A0;result)</span>
11079<br class="fancyvrb" /><a
11080 id="x1-120006r3"></a><span
11081class="cmr-6">3</span><span
11082class="cmtt-8">&#x00A0;</span><span
11083class="cmtt-8">&#x00A0;3)</span><span
11084class="cmtt-8">&#x00A0;[exponent]</span><span
11085class="cmtt-8">&#x00A0;=</span><span
11086class="cmtt-8">&#x00A0;(</span><span
11087class="cmtt-8">&#x00A0;[x]</span><span
11088class="cmtt-8">&#x00A0;bitwise</span><span
11089class="cmtt-8">&#x00A0;AND</span><span
11090class="cmtt-8">&#x00A0;0x7fe00000)</span><span
11091class="cmtt-8">&#x00A0;shifted</span><span
11092class="cmtt-8">&#x00A0;right</span><span
11093class="cmtt-8">&#x00A0;21</span><span
11094class="cmtt-8">&#x00A0;bits</span><span
11095class="cmtt-8">&#x00A0;(unsigned</span><span
11096class="cmtt-8">&#x00A0;result)</span>
11097<br class="fancyvrb" /><a
11098 id="x1-120008r4"></a><span
11099class="cmr-6">4</span><span
11100class="cmtt-8">&#x00A0;</span><span
11101class="cmtt-8">&#x00A0;4)</span><span
11102class="cmtt-8">&#x00A0;if</span><span
11103class="cmtt-8">&#x00A0;(</span><span
11104class="cmtt-8">&#x00A0;[sign]</span><span
11105class="cmtt-8">&#x00A0;is</span><span
11106class="cmtt-8">&#x00A0;nonzero</span><span
11107class="cmtt-8">&#x00A0;)</span><span
11108class="cmtt-8">&#x00A0;then</span><span
11109class="cmtt-8">&#x00A0;negate</span><span
11110class="cmtt-8">&#x00A0;[mantissa]</span><br class="fancyvrb" /><a
11111 id="x1-120010r5"></a><span
11112class="cmr-6">5</span><span
11113class="cmtt-8">&#x00A0;</span><span
11114class="cmtt-8">&#x00A0;5)</span><span
11115class="cmtt-8">&#x00A0;return</span><span
11116class="cmtt-8">&#x00A0;[mantissa]</span><span
11117class="cmtt-8">&#x00A0;*</span><span
11118class="cmtt-8">&#x00A0;(</span><span
11119class="cmtt-8">&#x00A0;2</span><span
11120class="cmtt-8">&#x00A0;^</span><span
11121class="cmtt-8">&#x00A0;(</span><span
11122class="cmtt-8">&#x00A0;[exponent]</span><span
11123class="cmtt-8">&#x00A0;-</span><span
11124class="cmtt-8">&#x00A0;788</span><span
11125class="cmtt-8">&#x00A0;)</span><span
11126class="cmtt-8">&#x00A0;)</span></div>
11127<!--l. 65--><p class="noindent" >
11128<h5 class="subsubsectionHead"><span class="titlemark">9.2.3. </span> <a
11129 id="x1-1210009.2.3"></a>lookup1_values</h5>
11130<!--l. 67--><p class="noindent" >&#8221;lookup1_values(codebook_entries,codebook_dimensions)&#8221; is used to compute the
11131correct length of the value index for a codebook VQ lookup table of lookup type 1.
11132The values on this list are permuted to construct the VQ vector lookup table of size
11133<span
11134class="cmtt-12">[codebook</span><span
11135class="cmtt-12">_entries]</span>.
11136<!--l. 73--><p class="noindent" >The return value for this function is defined to be &#8217;the greatest integer value for which
11137<span
11138class="cmtt-12">[return</span><span
11139class="cmtt-12">_value] </span>to the power of <span
11140class="cmtt-12">[codebook</span><span
11141class="cmtt-12">_dimensions] </span>is less than or equal to
11142<span
11143class="cmtt-12">[codebook</span><span
11144class="cmtt-12">_entries]</span>&#8217;.
11145
11146
11147
11148<!--l. 80--><p class="noindent" >
11149<h5 class="subsubsectionHead"><span class="titlemark">9.2.4. </span> <a
11150 id="x1-1220009.2.4"></a>low_neighbor</h5>
11151<!--l. 82--><p class="noindent" >&#8221;low_neighbor(v,x)&#8221; finds the position <span
11152class="cmtt-12">n </span>in vector <span
11153class="cmtt-12">[v] </span>of the greatest value scalar element for
11154which <span
11155class="cmtt-12">n </span>is less than <span
11156class="cmtt-12">[x] </span>and vector <span
11157class="cmtt-12">[v] </span>element <span
11158class="cmtt-12">n </span>is less than vector <span
11159class="cmtt-12">[v] </span>element
11160<span
11161class="cmtt-12">[x]</span>.
11162<!--l. 87--><p class="noindent" >
11163<h5 class="subsubsectionHead"><span class="titlemark">9.2.5. </span> <a
11164 id="x1-1230009.2.5"></a>high_neighbor</h5>
11165<!--l. 89--><p class="noindent" >&#8221;high_neighbor(v,x)&#8221; finds the position <span
11166class="cmtt-12">n </span>in vector [v] of the lowest value scalar element for
11167which <span
11168class="cmtt-12">n </span>is less than <span
11169class="cmtt-12">[x] </span>and vector <span
11170class="cmtt-12">[v] </span>element <span
11171class="cmtt-12">n </span>is greater than vector <span
11172class="cmtt-12">[v] </span>element
11173<span
11174class="cmtt-12">[x]</span>.
11175<!--l. 96--><p class="noindent" >
11176<h5 class="subsubsectionHead"><span class="titlemark">9.2.6. </span> <a
11177 id="x1-1240009.2.6"></a>render_point</h5>
11178<!--l. 98--><p class="noindent" >&#8221;render_point(x0,y0,x1,y1,X)&#8221; is used to find the Y value at point X along the line specified by
11179x0, x1, y0 and y1. This function uses an integer algorithm to solve for the point directly without
11180calculating intervening values along the line.
11181<!--l. 103--><p class="noindent" >
11182<div class="fancyvrb" id="fancyvrb46"><a
11183 id="x1-124002r1"></a><span
11184class="cmr-6">1</span><span
11185class="cmtt-8">&#x00A0;</span><span
11186class="cmtt-8">&#x00A0;1)</span><span
11187class="cmtt-8">&#x00A0;</span><span
11188class="cmtt-8">&#x00A0;[dy]</span><span
11189class="cmtt-8">&#x00A0;=</span><span
11190class="cmtt-8">&#x00A0;[y1]</span><span
11191class="cmtt-8">&#x00A0;-</span><span
11192class="cmtt-8">&#x00A0;[y0]</span><br class="fancyvrb" /><a
11193 id="x1-124004r2"></a><span
11194class="cmr-6">2</span><span
11195class="cmtt-8">&#x00A0;</span><span
11196class="cmtt-8">&#x00A0;2)</span><span
11197class="cmtt-8">&#x00A0;[adx]</span><span
11198class="cmtt-8">&#x00A0;=</span><span
11199class="cmtt-8">&#x00A0;[x1]</span><span
11200class="cmtt-8">&#x00A0;-</span><span
11201class="cmtt-8">&#x00A0;[x0]</span><br class="fancyvrb" /><a
11202 id="x1-124006r3"></a><span
11203class="cmr-6">3</span><span
11204class="cmtt-8">&#x00A0;</span><span
11205class="cmtt-8">&#x00A0;3)</span><span
11206class="cmtt-8">&#x00A0;[ady]</span><span
11207class="cmtt-8">&#x00A0;=</span><span
11208class="cmtt-8">&#x00A0;absolute</span><span
11209class="cmtt-8">&#x00A0;value</span><span
11210class="cmtt-8">&#x00A0;of</span><span
11211class="cmtt-8">&#x00A0;[dy]</span><br class="fancyvrb" /><a
11212 id="x1-124008r4"></a><span
11213class="cmr-6">4</span><span
11214class="cmtt-8">&#x00A0;</span><span
11215class="cmtt-8">&#x00A0;4)</span><span
11216class="cmtt-8">&#x00A0;[err]</span><span
11217class="cmtt-8">&#x00A0;=</span><span
11218class="cmtt-8">&#x00A0;[ady]</span><span
11219class="cmtt-8">&#x00A0;*</span><span
11220class="cmtt-8">&#x00A0;([X]</span><span
11221class="cmtt-8">&#x00A0;-</span><span
11222class="cmtt-8">&#x00A0;[x0])</span>
11223<br class="fancyvrb" /><a
11224 id="x1-124010r5"></a><span
11225class="cmr-6">5</span><span
11226class="cmtt-8">&#x00A0;</span><span
11227class="cmtt-8">&#x00A0;5)</span><span
11228class="cmtt-8">&#x00A0;[off]</span><span
11229class="cmtt-8">&#x00A0;=</span><span
11230class="cmtt-8">&#x00A0;[err]</span><span
11231class="cmtt-8">&#x00A0;/</span><span
11232class="cmtt-8">&#x00A0;[adx]</span><span
11233class="cmtt-8">&#x00A0;using</span><span
11234class="cmtt-8">&#x00A0;integer</span><span
11235class="cmtt-8">&#x00A0;division</span><br class="fancyvrb" /><a
11236 id="x1-124012r6"></a><span
11237class="cmr-6">6</span><span
11238class="cmtt-8">&#x00A0;</span><span
11239class="cmtt-8">&#x00A0;6)</span><span
11240class="cmtt-8">&#x00A0;if</span><span
11241class="cmtt-8">&#x00A0;(</span><span
11242class="cmtt-8">&#x00A0;[dy]</span><span
11243class="cmtt-8">&#x00A0;is</span><span
11244class="cmtt-8">&#x00A0;less</span><span
11245class="cmtt-8">&#x00A0;than</span><span
11246class="cmtt-8">&#x00A0;zero</span><span
11247class="cmtt-8">&#x00A0;)</span><span
11248class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
11249 id="x1-124014r7"></a><span
11250class="cmr-6">7</span><br class="fancyvrb" /><a
11251 id="x1-124016r8"></a><span
11252class="cmr-6">8</span><span
11253class="cmtt-8">&#x00A0;</span><span
11254class="cmtt-8">&#x00A0;</span><span
11255class="cmtt-8">&#x00A0;</span><span
11256class="cmtt-8">&#x00A0;</span><span
11257class="cmtt-8">&#x00A0;</span><span
11258class="cmtt-8">&#x00A0;</span><span
11259class="cmtt-8">&#x00A0;7)</span><span
11260class="cmtt-8">&#x00A0;[Y]</span><span
11261class="cmtt-8">&#x00A0;=</span><span
11262class="cmtt-8">&#x00A0;[y0]</span><span
11263class="cmtt-8">&#x00A0;-</span><span
11264class="cmtt-8">&#x00A0;[off]</span><br class="fancyvrb" /><a
11265 id="x1-124018r9"></a><span
11266class="cmr-6">9</span>
11267<br class="fancyvrb" /><a
11268 id="x1-124020r10"></a><span
11269class="cmr-6">10</span><span
11270class="cmtt-8">&#x00A0;</span><span
11271class="cmtt-8">&#x00A0;</span><span
11272class="cmtt-8">&#x00A0;</span><span
11273class="cmtt-8">&#x00A0;</span><span
11274class="cmtt-8">&#x00A0;}</span><span
11275class="cmtt-8">&#x00A0;else</span><span
11276class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
11277 id="x1-124022r11"></a><span
11278class="cmr-6">11</span><br class="fancyvrb" /><a
11279 id="x1-124024r12"></a><span
11280class="cmr-6">12</span><span
11281class="cmtt-8">&#x00A0;</span><span
11282class="cmtt-8">&#x00A0;</span><span
11283class="cmtt-8">&#x00A0;</span><span
11284class="cmtt-8">&#x00A0;</span><span
11285class="cmtt-8">&#x00A0;</span><span
11286class="cmtt-8">&#x00A0;</span><span
11287class="cmtt-8">&#x00A0;8)</span><span
11288class="cmtt-8">&#x00A0;[Y]</span><span
11289class="cmtt-8">&#x00A0;=</span><span
11290class="cmtt-8">&#x00A0;[y0]</span><span
11291class="cmtt-8">&#x00A0;+</span><span
11292class="cmtt-8">&#x00A0;[off]</span><br class="fancyvrb" /><a
11293 id="x1-124026r13"></a><span
11294class="cmr-6">13</span><br class="fancyvrb" /><a
11295 id="x1-124028r14"></a><span
11296class="cmr-6">14</span><span
11297class="cmtt-8">&#x00A0;</span><span
11298class="cmtt-8">&#x00A0;</span><span
11299class="cmtt-8">&#x00A0;</span><span
11300class="cmtt-8">&#x00A0;</span><span
11301class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
11302 id="x1-124030r15"></a><span
11303class="cmr-6">15</span><br class="fancyvrb" /><a
11304 id="x1-124032r16"></a><span
11305class="cmr-6">16</span><span
11306class="cmtt-8">&#x00A0;</span><span
11307class="cmtt-8">&#x00A0;9)</span><span
11308class="cmtt-8">&#x00A0;done</span></div>
11309<!--l. 124--><p class="noindent" >
11310<h5 class="subsubsectionHead"><span class="titlemark">9.2.7. </span> <a
11311 id="x1-1250009.2.7"></a>render_line</h5>
11312
11313
11314
11315<!--l. 126--><p class="noindent" >Floor decode type one uses the integer line drawing algorithm of &#8221;render_line(x0, y0, x1, y1, v)&#8221;
11316to construct an integer floor curve for contiguous piecewise line segments. Note that it has not
11317been relevant elsewhere, but here we must define integer division as rounding division of both
11318positive and negative numbers toward zero.
11319<!--l. 133--><p class="noindent" >
11320<div class="fancyvrb" id="fancyvrb47"><a
11321 id="x1-125002r1"></a><span
11322class="cmr-6">1</span><span
11323class="cmtt-8">&#x00A0;</span><span
11324class="cmtt-8">&#x00A0;1)</span><span
11325class="cmtt-8">&#x00A0;</span><span
11326class="cmtt-8">&#x00A0;</span><span
11327class="cmtt-8">&#x00A0;[dy]</span><span
11328class="cmtt-8">&#x00A0;=</span><span
11329class="cmtt-8">&#x00A0;[y1]</span><span
11330class="cmtt-8">&#x00A0;-</span><span
11331class="cmtt-8">&#x00A0;[y0]</span><br class="fancyvrb" /><a
11332 id="x1-125004r2"></a><span
11333class="cmr-6">2</span><span
11334class="cmtt-8">&#x00A0;</span><span
11335class="cmtt-8">&#x00A0;2)</span><span
11336class="cmtt-8">&#x00A0;</span><span
11337class="cmtt-8">&#x00A0;[adx]</span><span
11338class="cmtt-8">&#x00A0;=</span><span
11339class="cmtt-8">&#x00A0;[x1]</span><span
11340class="cmtt-8">&#x00A0;-</span><span
11341class="cmtt-8">&#x00A0;[x0]</span><br class="fancyvrb" /><a
11342 id="x1-125006r3"></a><span
11343class="cmr-6">3</span><span
11344class="cmtt-8">&#x00A0;</span><span
11345class="cmtt-8">&#x00A0;3)</span><span
11346class="cmtt-8">&#x00A0;</span><span
11347class="cmtt-8">&#x00A0;[ady]</span><span
11348class="cmtt-8">&#x00A0;=</span><span
11349class="cmtt-8">&#x00A0;absolute</span><span
11350class="cmtt-8">&#x00A0;value</span><span
11351class="cmtt-8">&#x00A0;of</span><span
11352class="cmtt-8">&#x00A0;[dy]</span><br class="fancyvrb" /><a
11353 id="x1-125008r4"></a><span
11354class="cmr-6">4</span><span
11355class="cmtt-8">&#x00A0;</span><span
11356class="cmtt-8">&#x00A0;4)</span><span
11357class="cmtt-8">&#x00A0;[base]</span><span
11358class="cmtt-8">&#x00A0;=</span><span
11359class="cmtt-8">&#x00A0;[dy]</span><span
11360class="cmtt-8">&#x00A0;/</span><span
11361class="cmtt-8">&#x00A0;[adx]</span><span
11362class="cmtt-8">&#x00A0;using</span><span
11363class="cmtt-8">&#x00A0;integer</span><span
11364class="cmtt-8">&#x00A0;division</span>
11365<br class="fancyvrb" /><a
11366 id="x1-125010r5"></a><span
11367class="cmr-6">5</span><span
11368class="cmtt-8">&#x00A0;</span><span
11369class="cmtt-8">&#x00A0;5)</span><span
11370class="cmtt-8">&#x00A0;</span><span
11371class="cmtt-8">&#x00A0;</span><span
11372class="cmtt-8">&#x00A0;</span><span
11373class="cmtt-8">&#x00A0;[x]</span><span
11374class="cmtt-8">&#x00A0;=</span><span
11375class="cmtt-8">&#x00A0;[x0]</span><br class="fancyvrb" /><a
11376 id="x1-125012r6"></a><span
11377class="cmr-6">6</span><span
11378class="cmtt-8">&#x00A0;</span><span
11379class="cmtt-8">&#x00A0;6)</span><span
11380class="cmtt-8">&#x00A0;</span><span
11381class="cmtt-8">&#x00A0;</span><span
11382class="cmtt-8">&#x00A0;</span><span
11383class="cmtt-8">&#x00A0;[y]</span><span
11384class="cmtt-8">&#x00A0;=</span><span
11385class="cmtt-8">&#x00A0;[y0]</span><br class="fancyvrb" /><a
11386 id="x1-125014r7"></a><span
11387class="cmr-6">7</span><span
11388class="cmtt-8">&#x00A0;</span><span
11389class="cmtt-8">&#x00A0;7)</span><span
11390class="cmtt-8">&#x00A0;</span><span
11391class="cmtt-8">&#x00A0;[err]</span><span
11392class="cmtt-8">&#x00A0;=</span><span
11393class="cmtt-8">&#x00A0;0</span><br class="fancyvrb" /><a
11394 id="x1-125016r8"></a><span
11395class="cmr-6">8</span><br class="fancyvrb" /><a
11396 id="x1-125018r9"></a><span
11397class="cmr-6">9</span><span
11398class="cmtt-8">&#x00A0;</span><span
11399class="cmtt-8">&#x00A0;8)</span><span
11400class="cmtt-8">&#x00A0;if</span><span
11401class="cmtt-8">&#x00A0;(</span><span
11402class="cmtt-8">&#x00A0;[dy]</span><span
11403class="cmtt-8">&#x00A0;is</span><span
11404class="cmtt-8">&#x00A0;less</span><span
11405class="cmtt-8">&#x00A0;than</span><span
11406class="cmtt-8">&#x00A0;0</span><span
11407class="cmtt-8">&#x00A0;)</span><span
11408class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
11409 id="x1-125020r10"></a><span
11410class="cmr-6">10</span><br class="fancyvrb" /><a
11411 id="x1-125022r11"></a><span
11412class="cmr-6">11</span><span
11413class="cmtt-8">&#x00A0;</span><span
11414class="cmtt-8">&#x00A0;</span><span
11415class="cmtt-8">&#x00A0;</span><span
11416class="cmtt-8">&#x00A0;</span><span
11417class="cmtt-8">&#x00A0;</span><span
11418class="cmtt-8">&#x00A0;</span><span
11419class="cmtt-8">&#x00A0;</span><span
11420class="cmtt-8">&#x00A0;9)</span><span
11421class="cmtt-8">&#x00A0;[sy]</span><span
11422class="cmtt-8">&#x00A0;=</span><span
11423class="cmtt-8">&#x00A0;[base]</span><span
11424class="cmtt-8">&#x00A0;-</span><span
11425class="cmtt-8">&#x00A0;1</span><br class="fancyvrb" /><a
11426 id="x1-125024r12"></a><span
11427class="cmr-6">12</span>
11428<br class="fancyvrb" /><a
11429 id="x1-125026r13"></a><span
11430class="cmr-6">13</span><span
11431class="cmtt-8">&#x00A0;</span><span
11432class="cmtt-8">&#x00A0;</span><span
11433class="cmtt-8">&#x00A0;</span><span
11434class="cmtt-8">&#x00A0;</span><span
11435class="cmtt-8">&#x00A0;}</span><span
11436class="cmtt-8">&#x00A0;else</span><span
11437class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
11438 id="x1-125028r14"></a><span
11439class="cmr-6">14</span><br class="fancyvrb" /><a
11440 id="x1-125030r15"></a><span
11441class="cmr-6">15</span><span
11442class="cmtt-8">&#x00A0;</span><span
11443class="cmtt-8">&#x00A0;</span><span
11444class="cmtt-8">&#x00A0;</span><span
11445class="cmtt-8">&#x00A0;</span><span
11446class="cmtt-8">&#x00A0;</span><span
11447class="cmtt-8">&#x00A0;</span><span
11448class="cmtt-8">&#x00A0;10)</span><span
11449class="cmtt-8">&#x00A0;[sy]</span><span
11450class="cmtt-8">&#x00A0;=</span><span
11451class="cmtt-8">&#x00A0;[base]</span><span
11452class="cmtt-8">&#x00A0;+</span><span
11453class="cmtt-8">&#x00A0;1</span><br class="fancyvrb" /><a
11454 id="x1-125032r16"></a><span
11455class="cmr-6">16</span><br class="fancyvrb" /><a
11456 id="x1-125034r17"></a><span
11457class="cmr-6">17</span><span
11458class="cmtt-8">&#x00A0;</span><span
11459class="cmtt-8">&#x00A0;</span><span
11460class="cmtt-8">&#x00A0;</span><span
11461class="cmtt-8">&#x00A0;</span><span
11462class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
11463 id="x1-125036r18"></a><span
11464class="cmr-6">18</span><br class="fancyvrb" /><a
11465 id="x1-125038r19"></a><span
11466class="cmr-6">19</span><span
11467class="cmtt-8">&#x00A0;11)</span><span
11468class="cmtt-8">&#x00A0;[ady]</span><span
11469class="cmtt-8">&#x00A0;=</span><span
11470class="cmtt-8">&#x00A0;[ady]</span><span
11471class="cmtt-8">&#x00A0;-</span><span
11472class="cmtt-8">&#x00A0;(absolute</span><span
11473class="cmtt-8">&#x00A0;value</span><span
11474class="cmtt-8">&#x00A0;of</span><span
11475class="cmtt-8">&#x00A0;[base])</span><span
11476class="cmtt-8">&#x00A0;*</span><span
11477class="cmtt-8">&#x00A0;[adx]</span>
11478<br class="fancyvrb" /><a
11479 id="x1-125040r20"></a><span
11480class="cmr-6">20</span><span
11481class="cmtt-8">&#x00A0;12)</span><span
11482class="cmtt-8">&#x00A0;vector</span><span
11483class="cmtt-8">&#x00A0;[v]</span><span
11484class="cmtt-8">&#x00A0;element</span><span
11485class="cmtt-8">&#x00A0;[x]</span><span
11486class="cmtt-8">&#x00A0;=</span><span
11487class="cmtt-8">&#x00A0;[y]</span><br class="fancyvrb" /><a
11488 id="x1-125042r21"></a><span
11489class="cmr-6">21</span><br class="fancyvrb" /><a
11490 id="x1-125044r22"></a><span
11491class="cmr-6">22</span><span
11492class="cmtt-8">&#x00A0;13)</span><span
11493class="cmtt-8">&#x00A0;iterate</span><span
11494class="cmtt-8">&#x00A0;[x]</span><span
11495class="cmtt-8">&#x00A0;over</span><span
11496class="cmtt-8">&#x00A0;the</span><span
11497class="cmtt-8">&#x00A0;range</span><span
11498class="cmtt-8">&#x00A0;[x0]+1</span><span
11499class="cmtt-8">&#x00A0;...</span><span
11500class="cmtt-8">&#x00A0;[x1]-1</span><span
11501class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
11502 id="x1-125046r23"></a><span
11503class="cmr-6">23</span><br class="fancyvrb" /><a
11504 id="x1-125048r24"></a><span
11505class="cmr-6">24</span><span
11506class="cmtt-8">&#x00A0;</span><span
11507class="cmtt-8">&#x00A0;</span><span
11508class="cmtt-8">&#x00A0;</span><span
11509class="cmtt-8">&#x00A0;</span><span
11510class="cmtt-8">&#x00A0;</span><span
11511class="cmtt-8">&#x00A0;</span><span
11512class="cmtt-8">&#x00A0;14)</span><span
11513class="cmtt-8">&#x00A0;[err]</span><span
11514class="cmtt-8">&#x00A0;=</span><span
11515class="cmtt-8">&#x00A0;[err]</span><span
11516class="cmtt-8">&#x00A0;+</span><span
11517class="cmtt-8">&#x00A0;[ady];</span>
11518<br class="fancyvrb" /><a
11519 id="x1-125050r25"></a><span
11520class="cmr-6">25</span><span
11521class="cmtt-8">&#x00A0;</span><span
11522class="cmtt-8">&#x00A0;</span><span
11523class="cmtt-8">&#x00A0;</span><span
11524class="cmtt-8">&#x00A0;</span><span
11525class="cmtt-8">&#x00A0;</span><span
11526class="cmtt-8">&#x00A0;</span><span
11527class="cmtt-8">&#x00A0;15)</span><span
11528class="cmtt-8">&#x00A0;if</span><span
11529class="cmtt-8">&#x00A0;(</span><span
11530class="cmtt-8">&#x00A0;[err]</span><span
11531class="cmtt-8">&#x00A0;&#x003E;=</span><span
11532class="cmtt-8">&#x00A0;[adx]</span><span
11533class="cmtt-8">&#x00A0;)</span><span
11534class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
11535 id="x1-125052r26"></a><span
11536class="cmr-6">26</span><br class="fancyvrb" /><a
11537 id="x1-125054r27"></a><span
11538class="cmr-6">27</span><span
11539class="cmtt-8">&#x00A0;</span><span
11540class="cmtt-8">&#x00A0;</span><span
11541class="cmtt-8">&#x00A0;</span><span
11542class="cmtt-8">&#x00A0;</span><span
11543class="cmtt-8">&#x00A0;</span><span
11544class="cmtt-8">&#x00A0;</span><span
11545class="cmtt-8">&#x00A0;</span><span
11546class="cmtt-8">&#x00A0;</span><span
11547class="cmtt-8">&#x00A0;</span><span
11548class="cmtt-8">&#x00A0;</span><span
11549class="cmtt-8">&#x00A0;</span><span
11550class="cmtt-8">&#x00A0;</span><span
11551class="cmtt-8">&#x00A0;16)</span><span
11552class="cmtt-8">&#x00A0;[err]</span><span
11553class="cmtt-8">&#x00A0;=</span><span
11554class="cmtt-8">&#x00A0;[err]</span><span
11555class="cmtt-8">&#x00A0;-</span><span
11556class="cmtt-8">&#x00A0;[adx]</span><br class="fancyvrb" /><a
11557 id="x1-125056r28"></a><span
11558class="cmr-6">28</span><span
11559class="cmtt-8">&#x00A0;</span><span
11560class="cmtt-8">&#x00A0;</span><span
11561class="cmtt-8">&#x00A0;</span><span
11562class="cmtt-8">&#x00A0;</span><span
11563class="cmtt-8">&#x00A0;</span><span
11564class="cmtt-8">&#x00A0;</span><span
11565class="cmtt-8">&#x00A0;</span><span
11566class="cmtt-8">&#x00A0;</span><span
11567class="cmtt-8">&#x00A0;</span><span
11568class="cmtt-8">&#x00A0;</span><span
11569class="cmtt-8">&#x00A0;</span><span
11570class="cmtt-8">&#x00A0;</span><span
11571class="cmtt-8">&#x00A0;17)</span><span
11572class="cmtt-8">&#x00A0;</span><span
11573class="cmtt-8">&#x00A0;</span><span
11574class="cmtt-8">&#x00A0;[y]</span><span
11575class="cmtt-8">&#x00A0;=</span><span
11576class="cmtt-8">&#x00A0;[y]</span><span
11577class="cmtt-8">&#x00A0;+</span><span
11578class="cmtt-8">&#x00A0;[sy]</span><br class="fancyvrb" /><a
11579 id="x1-125058r29"></a><span
11580class="cmr-6">29</span>
11581<br class="fancyvrb" /><a
11582 id="x1-125060r30"></a><span
11583class="cmr-6">30</span><span
11584class="cmtt-8">&#x00A0;</span><span
11585class="cmtt-8">&#x00A0;</span><span
11586class="cmtt-8">&#x00A0;</span><span
11587class="cmtt-8">&#x00A0;</span><span
11588class="cmtt-8">&#x00A0;</span><span
11589class="cmtt-8">&#x00A0;</span><span
11590class="cmtt-8">&#x00A0;</span><span
11591class="cmtt-8">&#x00A0;</span><span
11592class="cmtt-8">&#x00A0;</span><span
11593class="cmtt-8">&#x00A0;</span><span
11594class="cmtt-8">&#x00A0;}</span><span
11595class="cmtt-8">&#x00A0;else</span><span
11596class="cmtt-8">&#x00A0;{</span><br class="fancyvrb" /><a
11597 id="x1-125062r31"></a><span
11598class="cmr-6">31</span><br class="fancyvrb" /><a
11599 id="x1-125064r32"></a><span
11600class="cmr-6">32</span><span
11601class="cmtt-8">&#x00A0;</span><span
11602class="cmtt-8">&#x00A0;</span><span
11603class="cmtt-8">&#x00A0;</span><span
11604class="cmtt-8">&#x00A0;</span><span
11605class="cmtt-8">&#x00A0;</span><span
11606class="cmtt-8">&#x00A0;</span><span
11607class="cmtt-8">&#x00A0;</span><span
11608class="cmtt-8">&#x00A0;</span><span
11609class="cmtt-8">&#x00A0;</span><span
11610class="cmtt-8">&#x00A0;</span><span
11611class="cmtt-8">&#x00A0;</span><span
11612class="cmtt-8">&#x00A0;</span><span
11613class="cmtt-8">&#x00A0;18)</span><span
11614class="cmtt-8">&#x00A0;[y]</span><span
11615class="cmtt-8">&#x00A0;=</span><span
11616class="cmtt-8">&#x00A0;[y]</span><span
11617class="cmtt-8">&#x00A0;+</span><span
11618class="cmtt-8">&#x00A0;[base]</span><br class="fancyvrb" /><a
11619 id="x1-125066r33"></a><span
11620class="cmr-6">33</span><br class="fancyvrb" /><a
11621 id="x1-125068r34"></a><span
11622class="cmr-6">34</span><span
11623class="cmtt-8">&#x00A0;</span><span
11624class="cmtt-8">&#x00A0;</span><span
11625class="cmtt-8">&#x00A0;</span><span
11626class="cmtt-8">&#x00A0;</span><span
11627class="cmtt-8">&#x00A0;</span><span
11628class="cmtt-8">&#x00A0;</span><span
11629class="cmtt-8">&#x00A0;</span><span
11630class="cmtt-8">&#x00A0;</span><span
11631class="cmtt-8">&#x00A0;</span><span
11632class="cmtt-8">&#x00A0;</span><span
11633class="cmtt-8">&#x00A0;}</span><br class="fancyvrb" /><a
11634 id="x1-125070r35"></a><span
11635class="cmr-6">35</span><br class="fancyvrb" /><a
11636 id="x1-125072r36"></a><span
11637class="cmr-6">36</span><span
11638class="cmtt-8">&#x00A0;</span><span
11639class="cmtt-8">&#x00A0;</span><span
11640class="cmtt-8">&#x00A0;</span><span
11641class="cmtt-8">&#x00A0;</span><span
11642class="cmtt-8">&#x00A0;</span><span
11643class="cmtt-8">&#x00A0;</span><span
11644class="cmtt-8">&#x00A0;19)</span><span
11645class="cmtt-8">&#x00A0;vector</span><span
11646class="cmtt-8">&#x00A0;[v]</span><span
11647class="cmtt-8">&#x00A0;element</span><span
11648class="cmtt-8">&#x00A0;[x]</span><span
11649class="cmtt-8">&#x00A0;=</span><span
11650class="cmtt-8">&#x00A0;[y]</span><br class="fancyvrb" /><a
11651 id="x1-125074r37"></a><span
11652class="cmr-6">37</span><br class="fancyvrb" /><a
11653 id="x1-125076r38"></a><span
11654class="cmr-6">38</span><span
11655class="cmtt-8">&#x00A0;</span><span
11656class="cmtt-8">&#x00A0;</span><span
11657class="cmtt-8">&#x00A0;</span><span
11658class="cmtt-8">&#x00A0;</span><span
11659class="cmtt-8">&#x00A0;}</span></div>
11660
11661
11662
11663
11664
11665
11666<h3 class="sectionHead"><span class="titlemark">10. </span> <a
11667 id="x1-12600010"></a>Tables</h3>
11668<!--l. 5--><p class="noindent" >
11669<h4 class="subsectionHead"><span class="titlemark">10.1. </span> <a
11670 id="x1-12700010.1"></a>floor1_inverse_dB_table</h4>
11671<!--l. 7--><p class="noindent" >The vector <span
11672class="cmtt-12">[floor1</span><span
11673class="cmtt-12">_inverse</span><span
11674class="cmtt-12">_dB</span><span
11675class="cmtt-12">_table] </span>is a 256 element static lookup table consisting of the
11676following values (read left to right then top to bottom):
11677<!--l. 11--><p class="noindent" >
11678<div class="fancyvrb" id="fancyvrb48"><a
11679 id="x1-127002r1"></a><span
11680class="cmr-6">1</span><span
11681class="cmtt-8">&#x00A0;</span><span
11682class="cmtt-8">&#x00A0;1.0649863e-07,</span><span
11683class="cmtt-8">&#x00A0;1.1341951e-07,</span><span
11684class="cmtt-8">&#x00A0;1.2079015e-07,</span><span
11685class="cmtt-8">&#x00A0;1.2863978e-07,</span><br class="fancyvrb" /><a
11686 id="x1-127004r2"></a><span
11687class="cmr-6">2</span><span
11688class="cmtt-8">&#x00A0;</span><span
11689class="cmtt-8">&#x00A0;1.3699951e-07,</span><span
11690class="cmtt-8">&#x00A0;1.4590251e-07,</span><span
11691class="cmtt-8">&#x00A0;1.5538408e-07,</span><span
11692class="cmtt-8">&#x00A0;1.6548181e-07,</span>
11693<br class="fancyvrb" /><a
11694 id="x1-127006r3"></a><span
11695class="cmr-6">3</span><span
11696class="cmtt-8">&#x00A0;</span><span
11697class="cmtt-8">&#x00A0;1.7623575e-07,</span><span
11698class="cmtt-8">&#x00A0;1.8768855e-07,</span><span
11699class="cmtt-8">&#x00A0;1.9988561e-07,</span><span
11700class="cmtt-8">&#x00A0;2.1287530e-07,</span><br class="fancyvrb" /><a
11701 id="x1-127008r4"></a><span
11702class="cmr-6">4</span><span
11703class="cmtt-8">&#x00A0;</span><span
11704class="cmtt-8">&#x00A0;2.2670913e-07,</span><span
11705class="cmtt-8">&#x00A0;2.4144197e-07,</span><span
11706class="cmtt-8">&#x00A0;2.5713223e-07,</span><span
11707class="cmtt-8">&#x00A0;2.7384213e-07,</span>
11708<br class="fancyvrb" /><a
11709 id="x1-127010r5"></a><span
11710class="cmr-6">5</span><span
11711class="cmtt-8">&#x00A0;</span><span
11712class="cmtt-8">&#x00A0;2.9163793e-07,</span><span
11713class="cmtt-8">&#x00A0;3.1059021e-07,</span><span
11714class="cmtt-8">&#x00A0;3.3077411e-07,</span><span
11715class="cmtt-8">&#x00A0;3.5226968e-07,</span><br class="fancyvrb" /><a
11716 id="x1-127012r6"></a><span
11717class="cmr-6">6</span><span
11718class="cmtt-8">&#x00A0;</span><span
11719class="cmtt-8">&#x00A0;3.7516214e-07,</span><span
11720class="cmtt-8">&#x00A0;3.9954229e-07,</span><span
11721class="cmtt-8">&#x00A0;4.2550680e-07,</span><span
11722class="cmtt-8">&#x00A0;4.5315863e-07,</span>
11723<br class="fancyvrb" /><a
11724 id="x1-127014r7"></a><span
11725class="cmr-6">7</span><span
11726class="cmtt-8">&#x00A0;</span><span
11727class="cmtt-8">&#x00A0;4.8260743e-07,</span><span
11728class="cmtt-8">&#x00A0;5.1396998e-07,</span><span
11729class="cmtt-8">&#x00A0;5.4737065e-07,</span><span
11730class="cmtt-8">&#x00A0;5.8294187e-07,</span><br class="fancyvrb" /><a
11731 id="x1-127016r8"></a><span
11732class="cmr-6">8</span><span
11733class="cmtt-8">&#x00A0;</span><span
11734class="cmtt-8">&#x00A0;6.2082472e-07,</span><span
11735class="cmtt-8">&#x00A0;6.6116941e-07,</span><span
11736class="cmtt-8">&#x00A0;7.0413592e-07,</span><span
11737class="cmtt-8">&#x00A0;7.4989464e-07,</span>
11738<br class="fancyvrb" /><a
11739 id="x1-127018r9"></a><span
11740class="cmr-6">9</span><span
11741class="cmtt-8">&#x00A0;</span><span
11742class="cmtt-8">&#x00A0;7.9862701e-07,</span><span
11743class="cmtt-8">&#x00A0;8.5052630e-07,</span><span
11744class="cmtt-8">&#x00A0;9.0579828e-07,</span><span
11745class="cmtt-8">&#x00A0;9.6466216e-07,</span><br class="fancyvrb" /><a
11746 id="x1-127020r10"></a><span
11747class="cmr-6">10</span><span
11748class="cmtt-8">&#x00A0;</span><span
11749class="cmtt-8">&#x00A0;1.0273513e-06,</span><span
11750class="cmtt-8">&#x00A0;1.0941144e-06,</span><span
11751class="cmtt-8">&#x00A0;1.1652161e-06,</span><span
11752class="cmtt-8">&#x00A0;1.2409384e-06,</span>
11753<br class="fancyvrb" /><a
11754 id="x1-127022r11"></a><span
11755class="cmr-6">11</span><span
11756class="cmtt-8">&#x00A0;</span><span
11757class="cmtt-8">&#x00A0;1.3215816e-06,</span><span
11758class="cmtt-8">&#x00A0;1.4074654e-06,</span><span
11759class="cmtt-8">&#x00A0;1.4989305e-06,</span><span
11760class="cmtt-8">&#x00A0;1.5963394e-06,</span><br class="fancyvrb" /><a
11761 id="x1-127024r12"></a><span
11762class="cmr-6">12</span><span
11763class="cmtt-8">&#x00A0;</span><span
11764class="cmtt-8">&#x00A0;1.7000785e-06,</span><span
11765class="cmtt-8">&#x00A0;1.8105592e-06,</span><span
11766class="cmtt-8">&#x00A0;1.9282195e-06,</span><span
11767class="cmtt-8">&#x00A0;2.0535261e-06,</span>
11768<br class="fancyvrb" /><a
11769 id="x1-127026r13"></a><span
11770class="cmr-6">13</span><span
11771class="cmtt-8">&#x00A0;</span><span
11772class="cmtt-8">&#x00A0;2.1869758e-06,</span><span
11773class="cmtt-8">&#x00A0;2.3290978e-06,</span><span
11774class="cmtt-8">&#x00A0;2.4804557e-06,</span><span
11775class="cmtt-8">&#x00A0;2.6416497e-06,</span><br class="fancyvrb" /><a
11776 id="x1-127028r14"></a><span
11777class="cmr-6">14</span><span
11778class="cmtt-8">&#x00A0;</span><span
11779class="cmtt-8">&#x00A0;2.8133190e-06,</span><span
11780class="cmtt-8">&#x00A0;2.9961443e-06,</span><span
11781class="cmtt-8">&#x00A0;3.1908506e-06,</span><span
11782class="cmtt-8">&#x00A0;3.3982101e-06,</span>
11783<br class="fancyvrb" /><a
11784 id="x1-127030r15"></a><span
11785class="cmr-6">15</span><span
11786class="cmtt-8">&#x00A0;</span><span
11787class="cmtt-8">&#x00A0;3.6190449e-06,</span><span
11788class="cmtt-8">&#x00A0;3.8542308e-06,</span><span
11789class="cmtt-8">&#x00A0;4.1047004e-06,</span><span
11790class="cmtt-8">&#x00A0;4.3714470e-06,</span><br class="fancyvrb" /><a
11791 id="x1-127032r16"></a><span
11792class="cmr-6">16</span><span
11793class="cmtt-8">&#x00A0;</span><span
11794class="cmtt-8">&#x00A0;4.6555282e-06,</span><span
11795class="cmtt-8">&#x00A0;4.9580707e-06,</span><span
11796class="cmtt-8">&#x00A0;5.2802740e-06,</span><span
11797class="cmtt-8">&#x00A0;5.6234160e-06,</span>
11798<br class="fancyvrb" /><a
11799 id="x1-127034r17"></a><span
11800class="cmr-6">17</span><span
11801class="cmtt-8">&#x00A0;</span><span
11802class="cmtt-8">&#x00A0;5.9888572e-06,</span><span
11803class="cmtt-8">&#x00A0;6.3780469e-06,</span><span
11804class="cmtt-8">&#x00A0;6.7925283e-06,</span><span
11805class="cmtt-8">&#x00A0;7.2339451e-06,</span><br class="fancyvrb" /><a
11806 id="x1-127036r18"></a><span
11807class="cmr-6">18</span><span
11808class="cmtt-8">&#x00A0;</span><span
11809class="cmtt-8">&#x00A0;7.7040476e-06,</span><span
11810class="cmtt-8">&#x00A0;8.2047000e-06,</span><span
11811class="cmtt-8">&#x00A0;8.7378876e-06,</span><span
11812class="cmtt-8">&#x00A0;9.3057248e-06,</span>
11813<br class="fancyvrb" /><a
11814 id="x1-127038r19"></a><span
11815class="cmr-6">19</span><span
11816class="cmtt-8">&#x00A0;</span><span
11817class="cmtt-8">&#x00A0;9.9104632e-06,</span><span
11818class="cmtt-8">&#x00A0;1.0554501e-05,</span><span
11819class="cmtt-8">&#x00A0;1.1240392e-05,</span><span
11820class="cmtt-8">&#x00A0;1.1970856e-05,</span><br class="fancyvrb" /><a
11821 id="x1-127040r20"></a><span
11822class="cmr-6">20</span><span
11823class="cmtt-8">&#x00A0;</span><span
11824class="cmtt-8">&#x00A0;1.2748789e-05,</span><span
11825class="cmtt-8">&#x00A0;1.3577278e-05,</span><span
11826class="cmtt-8">&#x00A0;1.4459606e-05,</span><span
11827class="cmtt-8">&#x00A0;1.5399272e-05,</span>
11828<br class="fancyvrb" /><a
11829 id="x1-127042r21"></a><span
11830class="cmr-6">21</span><span
11831class="cmtt-8">&#x00A0;</span><span
11832class="cmtt-8">&#x00A0;1.6400004e-05,</span><span
11833class="cmtt-8">&#x00A0;1.7465768e-05,</span><span
11834class="cmtt-8">&#x00A0;1.8600792e-05,</span><span
11835class="cmtt-8">&#x00A0;1.9809576e-05,</span><br class="fancyvrb" /><a
11836 id="x1-127044r22"></a><span
11837class="cmr-6">22</span><span
11838class="cmtt-8">&#x00A0;</span><span
11839class="cmtt-8">&#x00A0;2.1096914e-05,</span><span
11840class="cmtt-8">&#x00A0;2.2467911e-05,</span><span
11841class="cmtt-8">&#x00A0;2.3928002e-05,</span><span
11842class="cmtt-8">&#x00A0;2.5482978e-05,</span>
11843<br class="fancyvrb" /><a
11844 id="x1-127046r23"></a><span
11845class="cmr-6">23</span><span
11846class="cmtt-8">&#x00A0;</span><span
11847class="cmtt-8">&#x00A0;2.7139006e-05,</span><span
11848class="cmtt-8">&#x00A0;2.8902651e-05,</span><span
11849class="cmtt-8">&#x00A0;3.0780908e-05,</span><span
11850class="cmtt-8">&#x00A0;3.2781225e-05,</span><br class="fancyvrb" /><a
11851 id="x1-127048r24"></a><span
11852class="cmr-6">24</span><span
11853class="cmtt-8">&#x00A0;</span><span
11854class="cmtt-8">&#x00A0;3.4911534e-05,</span><span
11855class="cmtt-8">&#x00A0;3.7180282e-05,</span><span
11856class="cmtt-8">&#x00A0;3.9596466e-05,</span><span
11857class="cmtt-8">&#x00A0;4.2169667e-05,</span>
11858<br class="fancyvrb" /><a
11859 id="x1-127050r25"></a><span
11860class="cmr-6">25</span><span
11861class="cmtt-8">&#x00A0;</span><span
11862class="cmtt-8">&#x00A0;4.4910090e-05,</span><span
11863class="cmtt-8">&#x00A0;4.7828601e-05,</span><span
11864class="cmtt-8">&#x00A0;5.0936773e-05,</span><span
11865class="cmtt-8">&#x00A0;5.4246931e-05,</span><br class="fancyvrb" /><a
11866 id="x1-127052r26"></a><span
11867class="cmr-6">26</span><span
11868class="cmtt-8">&#x00A0;</span><span
11869class="cmtt-8">&#x00A0;5.7772202e-05,</span><span
11870class="cmtt-8">&#x00A0;6.1526565e-05,</span><span
11871class="cmtt-8">&#x00A0;6.5524908e-05,</span><span
11872class="cmtt-8">&#x00A0;6.9783085e-05,</span>
11873<br class="fancyvrb" /><a
11874 id="x1-127054r27"></a><span
11875class="cmr-6">27</span><span
11876class="cmtt-8">&#x00A0;</span><span
11877class="cmtt-8">&#x00A0;7.4317983e-05,</span><span
11878class="cmtt-8">&#x00A0;7.9147585e-05,</span><span
11879class="cmtt-8">&#x00A0;8.4291040e-05,</span><span
11880class="cmtt-8">&#x00A0;8.9768747e-05,</span><br class="fancyvrb" /><a
11881 id="x1-127056r28"></a><span
11882class="cmr-6">28</span><span
11883class="cmtt-8">&#x00A0;</span><span
11884class="cmtt-8">&#x00A0;9.5602426e-05,</span><span
11885class="cmtt-8">&#x00A0;0.00010181521,</span><span
11886class="cmtt-8">&#x00A0;0.00010843174,</span><span
11887class="cmtt-8">&#x00A0;0.00011547824,</span>
11888<br class="fancyvrb" /><a
11889 id="x1-127058r29"></a><span
11890class="cmr-6">29</span><span
11891class="cmtt-8">&#x00A0;</span><span
11892class="cmtt-8">&#x00A0;0.00012298267,</span><span
11893class="cmtt-8">&#x00A0;0.00013097477,</span><span
11894class="cmtt-8">&#x00A0;0.00013948625,</span><span
11895class="cmtt-8">&#x00A0;0.00014855085,</span><br class="fancyvrb" /><a
11896 id="x1-127060r30"></a><span
11897class="cmr-6">30</span><span
11898class="cmtt-8">&#x00A0;</span><span
11899class="cmtt-8">&#x00A0;0.00015820453,</span><span
11900class="cmtt-8">&#x00A0;0.00016848555,</span><span
11901class="cmtt-8">&#x00A0;0.00017943469,</span><span
11902class="cmtt-8">&#x00A0;0.00019109536,</span>
11903<br class="fancyvrb" /><a
11904 id="x1-127062r31"></a><span
11905class="cmr-6">31</span><span
11906class="cmtt-8">&#x00A0;</span><span
11907class="cmtt-8">&#x00A0;0.00020351382,</span><span
11908class="cmtt-8">&#x00A0;0.00021673929,</span><span
11909class="cmtt-8">&#x00A0;0.00023082423,</span><span
11910class="cmtt-8">&#x00A0;0.00024582449,</span><br class="fancyvrb" /><a
11911 id="x1-127064r32"></a><span
11912class="cmr-6">32</span><span
11913class="cmtt-8">&#x00A0;</span><span
11914class="cmtt-8">&#x00A0;0.00026179955,</span><span
11915class="cmtt-8">&#x00A0;0.00027881276,</span><span
11916class="cmtt-8">&#x00A0;0.00029693158,</span><span
11917class="cmtt-8">&#x00A0;0.00031622787,</span>
11918<br class="fancyvrb" /><a
11919 id="x1-127066r33"></a><span
11920class="cmr-6">33</span><span
11921class="cmtt-8">&#x00A0;</span><span
11922class="cmtt-8">&#x00A0;0.00033677814,</span><span
11923class="cmtt-8">&#x00A0;0.00035866388,</span><span
11924class="cmtt-8">&#x00A0;0.00038197188,</span><span
11925class="cmtt-8">&#x00A0;0.00040679456,</span><br class="fancyvrb" /><a
11926 id="x1-127068r34"></a><span
11927class="cmr-6">34</span><span
11928class="cmtt-8">&#x00A0;</span><span
11929class="cmtt-8">&#x00A0;0.00043323036,</span><span
11930class="cmtt-8">&#x00A0;0.00046138411,</span><span
11931class="cmtt-8">&#x00A0;0.00049136745,</span><span
11932class="cmtt-8">&#x00A0;0.00052329927,</span>
11933<br class="fancyvrb" /><a
11934 id="x1-127070r35"></a><span
11935class="cmr-6">35</span><span
11936class="cmtt-8">&#x00A0;</span><span
11937class="cmtt-8">&#x00A0;0.00055730621,</span><span
11938class="cmtt-8">&#x00A0;0.00059352311,</span><span
11939class="cmtt-8">&#x00A0;0.00063209358,</span><span
11940class="cmtt-8">&#x00A0;0.00067317058,</span><br class="fancyvrb" /><a
11941 id="x1-127072r36"></a><span
11942class="cmr-6">36</span><span
11943class="cmtt-8">&#x00A0;</span><span
11944class="cmtt-8">&#x00A0;0.00071691700,</span><span
11945class="cmtt-8">&#x00A0;0.00076350630,</span><span
11946class="cmtt-8">&#x00A0;0.00081312324,</span><span
11947class="cmtt-8">&#x00A0;0.00086596457,</span>
11948<br class="fancyvrb" /><a
11949 id="x1-127074r37"></a><span
11950class="cmr-6">37</span><span
11951class="cmtt-8">&#x00A0;</span><span
11952class="cmtt-8">&#x00A0;0.00092223983,</span><span
11953class="cmtt-8">&#x00A0;0.00098217216,</span><span
11954class="cmtt-8">&#x00A0;0.0010459992,</span><span
11955class="cmtt-8">&#x00A0;</span><span
11956class="cmtt-8">&#x00A0;0.0011139742,</span><br class="fancyvrb" /><a
11957 id="x1-127076r38"></a><span
11958class="cmr-6">38</span><span
11959class="cmtt-8">&#x00A0;</span><span
11960class="cmtt-8">&#x00A0;0.0011863665,</span><span
11961class="cmtt-8">&#x00A0;</span><span
11962class="cmtt-8">&#x00A0;0.0012634633,</span><span
11963class="cmtt-8">&#x00A0;</span><span
11964class="cmtt-8">&#x00A0;0.0013455702,</span><span
11965class="cmtt-8">&#x00A0;</span><span
11966class="cmtt-8">&#x00A0;0.0014330129,</span>
11967<br class="fancyvrb" /><a
11968 id="x1-127078r39"></a><span
11969class="cmr-6">39</span><span
11970class="cmtt-8">&#x00A0;</span><span
11971class="cmtt-8">&#x00A0;0.0015261382,</span><span
11972class="cmtt-8">&#x00A0;</span><span
11973class="cmtt-8">&#x00A0;0.0016253153,</span><span
11974class="cmtt-8">&#x00A0;</span><span
11975class="cmtt-8">&#x00A0;0.0017309374,</span><span
11976class="cmtt-8">&#x00A0;</span><span
11977class="cmtt-8">&#x00A0;0.0018434235,</span><br class="fancyvrb" /><a
11978 id="x1-127080r40"></a><span
11979class="cmr-6">40</span><span
11980class="cmtt-8">&#x00A0;</span><span
11981class="cmtt-8">&#x00A0;0.0019632195,</span><span
11982class="cmtt-8">&#x00A0;</span><span
11983class="cmtt-8">&#x00A0;0.0020908006,</span><span
11984class="cmtt-8">&#x00A0;</span><span
11985class="cmtt-8">&#x00A0;0.0022266726,</span><span
11986class="cmtt-8">&#x00A0;</span><span
11987class="cmtt-8">&#x00A0;0.0023713743,</span>
11988<br class="fancyvrb" /><a
11989 id="x1-127082r41"></a><span
11990class="cmr-6">41</span><span
11991class="cmtt-8">&#x00A0;</span><span
11992class="cmtt-8">&#x00A0;0.0025254795,</span><span
11993class="cmtt-8">&#x00A0;</span><span
11994class="cmtt-8">&#x00A0;0.0026895994,</span><span
11995class="cmtt-8">&#x00A0;</span><span
11996class="cmtt-8">&#x00A0;0.0028643847,</span><span
11997class="cmtt-8">&#x00A0;</span><span
11998class="cmtt-8">&#x00A0;0.0030505286,</span><br class="fancyvrb" /><a
11999 id="x1-127084r42"></a><span
12000class="cmr-6">42</span><span
12001class="cmtt-8">&#x00A0;</span><span
12002class="cmtt-8">&#x00A0;0.0032487691,</span><span
12003class="cmtt-8">&#x00A0;</span><span
12004class="cmtt-8">&#x00A0;0.0034598925,</span><span
12005class="cmtt-8">&#x00A0;</span><span
12006class="cmtt-8">&#x00A0;0.0036847358,</span><span
12007class="cmtt-8">&#x00A0;</span><span
12008class="cmtt-8">&#x00A0;0.0039241906,</span>
12009<br class="fancyvrb" /><a
12010 id="x1-127086r43"></a><span
12011class="cmr-6">43</span><span
12012class="cmtt-8">&#x00A0;</span><span
12013class="cmtt-8">&#x00A0;0.0041792066,</span><span
12014class="cmtt-8">&#x00A0;</span><span
12015class="cmtt-8">&#x00A0;0.0044507950,</span><span
12016class="cmtt-8">&#x00A0;</span><span
12017class="cmtt-8">&#x00A0;0.0047400328,</span><span
12018class="cmtt-8">&#x00A0;</span><span
12019class="cmtt-8">&#x00A0;0.0050480668,</span><br class="fancyvrb" /><a
12020 id="x1-127088r44"></a><span
12021class="cmr-6">44</span><span
12022class="cmtt-8">&#x00A0;</span><span
12023class="cmtt-8">&#x00A0;0.0053761186,</span><span
12024class="cmtt-8">&#x00A0;</span><span
12025class="cmtt-8">&#x00A0;0.0057254891,</span><span
12026class="cmtt-8">&#x00A0;</span><span
12027class="cmtt-8">&#x00A0;0.0060975636,</span><span
12028class="cmtt-8">&#x00A0;</span><span
12029class="cmtt-8">&#x00A0;0.0064938176,</span>
12030<br class="fancyvrb" /><a
12031 id="x1-127090r45"></a><span
12032class="cmr-6">45</span><span
12033class="cmtt-8">&#x00A0;</span><span
12034class="cmtt-8">&#x00A0;0.0069158225,</span><span
12035class="cmtt-8">&#x00A0;</span><span
12036class="cmtt-8">&#x00A0;0.0073652516,</span><span
12037class="cmtt-8">&#x00A0;</span><span
12038class="cmtt-8">&#x00A0;0.0078438871,</span><span
12039class="cmtt-8">&#x00A0;</span><span
12040class="cmtt-8">&#x00A0;0.0083536271,</span><br class="fancyvrb" /><a
12041 id="x1-127092r46"></a><span
12042class="cmr-6">46</span><span
12043class="cmtt-8">&#x00A0;</span><span
12044class="cmtt-8">&#x00A0;0.0088964928,</span><span
12045class="cmtt-8">&#x00A0;</span><span
12046class="cmtt-8">&#x00A0;0.009474637,</span><span
12047class="cmtt-8">&#x00A0;</span><span
12048class="cmtt-8">&#x00A0;</span><span
12049class="cmtt-8">&#x00A0;0.010090352,</span><span
12050class="cmtt-8">&#x00A0;</span><span
12051class="cmtt-8">&#x00A0;</span><span
12052class="cmtt-8">&#x00A0;0.010746080,</span>
12053<br class="fancyvrb" /><a
12054 id="x1-127094r47"></a><span
12055class="cmr-6">47</span><span
12056class="cmtt-8">&#x00A0;</span><span
12057class="cmtt-8">&#x00A0;0.011444421,</span><span
12058class="cmtt-8">&#x00A0;</span><span
12059class="cmtt-8">&#x00A0;</span><span
12060class="cmtt-8">&#x00A0;0.012188144,</span><span
12061class="cmtt-8">&#x00A0;</span><span
12062class="cmtt-8">&#x00A0;</span><span
12063class="cmtt-8">&#x00A0;0.012980198,</span><span
12064class="cmtt-8">&#x00A0;</span><span
12065class="cmtt-8">&#x00A0;</span><span
12066class="cmtt-8">&#x00A0;0.013823725,</span><br class="fancyvrb" /><a
12067 id="x1-127096r48"></a><span
12068class="cmr-6">48</span><span
12069class="cmtt-8">&#x00A0;</span><span
12070class="cmtt-8">&#x00A0;0.014722068,</span><span
12071class="cmtt-8">&#x00A0;</span><span
12072class="cmtt-8">&#x00A0;</span><span
12073class="cmtt-8">&#x00A0;0.015678791,</span><span
12074class="cmtt-8">&#x00A0;</span><span
12075class="cmtt-8">&#x00A0;</span><span
12076class="cmtt-8">&#x00A0;0.016697687,</span><span
12077class="cmtt-8">&#x00A0;</span><span
12078class="cmtt-8">&#x00A0;</span><span
12079class="cmtt-8">&#x00A0;0.017782797,</span>
12080<br class="fancyvrb" /><a
12081 id="x1-127098r49"></a><span
12082class="cmr-6">49</span><span
12083class="cmtt-8">&#x00A0;</span><span
12084class="cmtt-8">&#x00A0;0.018938423,</span><span
12085class="cmtt-8">&#x00A0;</span><span
12086class="cmtt-8">&#x00A0;</span><span
12087class="cmtt-8">&#x00A0;0.020169149,</span><span
12088class="cmtt-8">&#x00A0;</span><span
12089class="cmtt-8">&#x00A0;</span><span
12090class="cmtt-8">&#x00A0;0.021479854,</span><span
12091class="cmtt-8">&#x00A0;</span><span
12092class="cmtt-8">&#x00A0;</span><span
12093class="cmtt-8">&#x00A0;0.022875735,</span><br class="fancyvrb" /><a
12094 id="x1-127100r50"></a><span
12095class="cmr-6">50</span><span
12096class="cmtt-8">&#x00A0;</span><span
12097class="cmtt-8">&#x00A0;0.024362330,</span><span
12098class="cmtt-8">&#x00A0;</span><span
12099class="cmtt-8">&#x00A0;</span><span
12100class="cmtt-8">&#x00A0;0.025945531,</span><span
12101class="cmtt-8">&#x00A0;</span><span
12102class="cmtt-8">&#x00A0;</span><span
12103class="cmtt-8">&#x00A0;0.027631618,</span><span
12104class="cmtt-8">&#x00A0;</span><span
12105class="cmtt-8">&#x00A0;</span><span
12106class="cmtt-8">&#x00A0;0.029427276,</span>
12107<br class="fancyvrb" /><a
12108 id="x1-127102r51"></a><span
12109class="cmr-6">51</span><span
12110class="cmtt-8">&#x00A0;</span><span
12111class="cmtt-8">&#x00A0;0.031339626,</span><span
12112class="cmtt-8">&#x00A0;</span><span
12113class="cmtt-8">&#x00A0;</span><span
12114class="cmtt-8">&#x00A0;0.033376252,</span><span
12115class="cmtt-8">&#x00A0;</span><span
12116class="cmtt-8">&#x00A0;</span><span
12117class="cmtt-8">&#x00A0;0.035545228,</span><span
12118class="cmtt-8">&#x00A0;</span><span
12119class="cmtt-8">&#x00A0;</span><span
12120class="cmtt-8">&#x00A0;0.037855157,</span><br class="fancyvrb" /><a
12121 id="x1-127104r52"></a><span
12122class="cmr-6">52</span><span
12123class="cmtt-8">&#x00A0;</span><span
12124class="cmtt-8">&#x00A0;0.040315199,</span><span
12125class="cmtt-8">&#x00A0;</span><span
12126class="cmtt-8">&#x00A0;</span><span
12127class="cmtt-8">&#x00A0;0.042935108,</span><span
12128class="cmtt-8">&#x00A0;</span><span
12129class="cmtt-8">&#x00A0;</span><span
12130class="cmtt-8">&#x00A0;0.045725273,</span><span
12131class="cmtt-8">&#x00A0;</span><span
12132class="cmtt-8">&#x00A0;</span><span
12133class="cmtt-8">&#x00A0;0.048696758,</span>
12134<br class="fancyvrb" /><a
12135 id="x1-127106r53"></a><span
12136class="cmr-6">53</span><span
12137class="cmtt-8">&#x00A0;</span><span
12138class="cmtt-8">&#x00A0;0.051861348,</span><span
12139class="cmtt-8">&#x00A0;</span><span
12140class="cmtt-8">&#x00A0;</span><span
12141class="cmtt-8">&#x00A0;0.055231591,</span><span
12142class="cmtt-8">&#x00A0;</span><span
12143class="cmtt-8">&#x00A0;</span><span
12144class="cmtt-8">&#x00A0;0.058820850,</span><span
12145class="cmtt-8">&#x00A0;</span><span
12146class="cmtt-8">&#x00A0;</span><span
12147class="cmtt-8">&#x00A0;0.062643361,</span><br class="fancyvrb" /><a
12148 id="x1-127108r54"></a><span
12149class="cmr-6">54</span><span
12150class="cmtt-8">&#x00A0;</span><span
12151class="cmtt-8">&#x00A0;0.066714279,</span><span
12152class="cmtt-8">&#x00A0;</span><span
12153class="cmtt-8">&#x00A0;</span><span
12154class="cmtt-8">&#x00A0;0.071049749,</span><span
12155class="cmtt-8">&#x00A0;</span><span
12156class="cmtt-8">&#x00A0;</span><span
12157class="cmtt-8">&#x00A0;0.075666962,</span><span
12158class="cmtt-8">&#x00A0;</span><span
12159class="cmtt-8">&#x00A0;</span><span
12160class="cmtt-8">&#x00A0;0.080584227,</span>
12161<br class="fancyvrb" /><a
12162 id="x1-127110r55"></a><span
12163class="cmr-6">55</span><span
12164class="cmtt-8">&#x00A0;</span><span
12165class="cmtt-8">&#x00A0;0.085821044,</span><span
12166class="cmtt-8">&#x00A0;</span><span
12167class="cmtt-8">&#x00A0;</span><span
12168class="cmtt-8">&#x00A0;0.091398179,</span><span
12169class="cmtt-8">&#x00A0;</span><span
12170class="cmtt-8">&#x00A0;</span><span
12171class="cmtt-8">&#x00A0;0.097337747,</span><span
12172class="cmtt-8">&#x00A0;</span><span
12173class="cmtt-8">&#x00A0;</span><span
12174class="cmtt-8">&#x00A0;0.10366330,</span><br class="fancyvrb" /><a
12175 id="x1-127112r56"></a><span
12176class="cmr-6">56</span><span
12177class="cmtt-8">&#x00A0;</span><span
12178class="cmtt-8">&#x00A0;0.11039993,</span><span
12179class="cmtt-8">&#x00A0;</span><span
12180class="cmtt-8">&#x00A0;</span><span
12181class="cmtt-8">&#x00A0;</span><span
12182class="cmtt-8">&#x00A0;0.11757434,</span><span
12183class="cmtt-8">&#x00A0;</span><span
12184class="cmtt-8">&#x00A0;</span><span
12185class="cmtt-8">&#x00A0;</span><span
12186class="cmtt-8">&#x00A0;0.12521498,</span><span
12187class="cmtt-8">&#x00A0;</span><span
12188class="cmtt-8">&#x00A0;</span><span
12189class="cmtt-8">&#x00A0;</span><span
12190class="cmtt-8">&#x00A0;0.13335215,</span>
12191<br class="fancyvrb" /><a
12192 id="x1-127114r57"></a><span
12193class="cmr-6">57</span><span
12194class="cmtt-8">&#x00A0;</span><span
12195class="cmtt-8">&#x00A0;0.14201813,</span><span
12196class="cmtt-8">&#x00A0;</span><span
12197class="cmtt-8">&#x00A0;</span><span
12198class="cmtt-8">&#x00A0;</span><span
12199class="cmtt-8">&#x00A0;0.15124727,</span><span
12200class="cmtt-8">&#x00A0;</span><span
12201class="cmtt-8">&#x00A0;</span><span
12202class="cmtt-8">&#x00A0;</span><span
12203class="cmtt-8">&#x00A0;0.16107617,</span><span
12204class="cmtt-8">&#x00A0;</span><span
12205class="cmtt-8">&#x00A0;</span><span
12206class="cmtt-8">&#x00A0;</span><span
12207class="cmtt-8">&#x00A0;0.17154380,</span><br class="fancyvrb" /><a
12208 id="x1-127116r58"></a><span
12209class="cmr-6">58</span><span
12210class="cmtt-8">&#x00A0;</span><span
12211class="cmtt-8">&#x00A0;0.18269168,</span><span
12212class="cmtt-8">&#x00A0;</span><span
12213class="cmtt-8">&#x00A0;</span><span
12214class="cmtt-8">&#x00A0;</span><span
12215class="cmtt-8">&#x00A0;0.19456402,</span><span
12216class="cmtt-8">&#x00A0;</span><span
12217class="cmtt-8">&#x00A0;</span><span
12218class="cmtt-8">&#x00A0;</span><span
12219class="cmtt-8">&#x00A0;0.20720788,</span><span
12220class="cmtt-8">&#x00A0;</span><span
12221class="cmtt-8">&#x00A0;</span><span
12222class="cmtt-8">&#x00A0;</span><span
12223class="cmtt-8">&#x00A0;0.22067342,</span>
12224<br class="fancyvrb" /><a
12225 id="x1-127118r59"></a><span
12226class="cmr-6">59</span><span
12227class="cmtt-8">&#x00A0;</span><span
12228class="cmtt-8">&#x00A0;0.23501402,</span><span
12229class="cmtt-8">&#x00A0;</span><span
12230class="cmtt-8">&#x00A0;</span><span
12231class="cmtt-8">&#x00A0;</span><span
12232class="cmtt-8">&#x00A0;0.25028656,</span><span
12233class="cmtt-8">&#x00A0;</span><span
12234class="cmtt-8">&#x00A0;</span><span
12235class="cmtt-8">&#x00A0;</span><span
12236class="cmtt-8">&#x00A0;0.26655159,</span><span
12237class="cmtt-8">&#x00A0;</span><span
12238class="cmtt-8">&#x00A0;</span><span
12239class="cmtt-8">&#x00A0;</span><span
12240class="cmtt-8">&#x00A0;0.28387361,</span><br class="fancyvrb" /><a
12241 id="x1-127120r60"></a><span
12242class="cmr-6">60</span><span
12243class="cmtt-8">&#x00A0;</span><span
12244class="cmtt-8">&#x00A0;0.30232132,</span><span
12245class="cmtt-8">&#x00A0;</span><span
12246class="cmtt-8">&#x00A0;</span><span
12247class="cmtt-8">&#x00A0;</span><span
12248class="cmtt-8">&#x00A0;0.32196786,</span><span
12249class="cmtt-8">&#x00A0;</span><span
12250class="cmtt-8">&#x00A0;</span><span
12251class="cmtt-8">&#x00A0;</span><span
12252class="cmtt-8">&#x00A0;0.34289114,</span><span
12253class="cmtt-8">&#x00A0;</span><span
12254class="cmtt-8">&#x00A0;</span><span
12255class="cmtt-8">&#x00A0;</span><span
12256class="cmtt-8">&#x00A0;0.36517414,</span>
12257<br class="fancyvrb" /><a
12258 id="x1-127122r61"></a><span
12259class="cmr-6">61</span><span
12260class="cmtt-8">&#x00A0;</span><span
12261class="cmtt-8">&#x00A0;0.38890521,</span><span
12262class="cmtt-8">&#x00A0;</span><span
12263class="cmtt-8">&#x00A0;</span><span
12264class="cmtt-8">&#x00A0;</span><span
12265class="cmtt-8">&#x00A0;0.41417847,</span><span
12266class="cmtt-8">&#x00A0;</span><span
12267class="cmtt-8">&#x00A0;</span><span
12268class="cmtt-8">&#x00A0;</span><span
12269class="cmtt-8">&#x00A0;0.44109412,</span><span
12270class="cmtt-8">&#x00A0;</span><span
12271class="cmtt-8">&#x00A0;</span><span
12272class="cmtt-8">&#x00A0;</span><span
12273class="cmtt-8">&#x00A0;0.46975890,</span><br class="fancyvrb" /><a
12274 id="x1-127124r62"></a><span
12275class="cmr-6">62</span><span
12276class="cmtt-8">&#x00A0;</span><span
12277class="cmtt-8">&#x00A0;0.50028648,</span><span
12278class="cmtt-8">&#x00A0;</span><span
12279class="cmtt-8">&#x00A0;</span><span
12280class="cmtt-8">&#x00A0;</span><span
12281class="cmtt-8">&#x00A0;0.53279791,</span><span
12282class="cmtt-8">&#x00A0;</span><span
12283class="cmtt-8">&#x00A0;</span><span
12284class="cmtt-8">&#x00A0;</span><span
12285class="cmtt-8">&#x00A0;0.56742212,</span><span
12286class="cmtt-8">&#x00A0;</span><span
12287class="cmtt-8">&#x00A0;</span><span
12288class="cmtt-8">&#x00A0;</span><span
12289class="cmtt-8">&#x00A0;0.60429640,</span>
12290<br class="fancyvrb" /><a
12291 id="x1-127126r63"></a><span
12292class="cmr-6">63</span><span
12293class="cmtt-8">&#x00A0;</span><span
12294class="cmtt-8">&#x00A0;0.64356699,</span><span
12295class="cmtt-8">&#x00A0;</span><span
12296class="cmtt-8">&#x00A0;</span><span
12297class="cmtt-8">&#x00A0;</span><span
12298class="cmtt-8">&#x00A0;0.68538959,</span><span
12299class="cmtt-8">&#x00A0;</span><span
12300class="cmtt-8">&#x00A0;</span><span
12301class="cmtt-8">&#x00A0;</span><span
12302class="cmtt-8">&#x00A0;0.72993007,</span><span
12303class="cmtt-8">&#x00A0;</span><span
12304class="cmtt-8">&#x00A0;</span><span
12305class="cmtt-8">&#x00A0;</span><span
12306class="cmtt-8">&#x00A0;0.77736504,</span><br class="fancyvrb" /><a
12307 id="x1-127128r64"></a><span
12308class="cmr-6">64</span><span
12309class="cmtt-8">&#x00A0;</span><span
12310class="cmtt-8">&#x00A0;0.82788260,</span><span
12311class="cmtt-8">&#x00A0;</span><span
12312class="cmtt-8">&#x00A0;</span><span
12313class="cmtt-8">&#x00A0;</span><span
12314class="cmtt-8">&#x00A0;0.88168307,</span><span
12315class="cmtt-8">&#x00A0;</span><span
12316class="cmtt-8">&#x00A0;</span><span
12317class="cmtt-8">&#x00A0;</span><span
12318class="cmtt-8">&#x00A0;0.9389798,</span><span
12319class="cmtt-8">&#x00A0;</span><span
12320class="cmtt-8">&#x00A0;</span><span
12321class="cmtt-8">&#x00A0;</span><span
12322class="cmtt-8">&#x00A0;</span><span
12323class="cmtt-8">&#x00A0;1.</span></div>
12324
12325
12326
12327
12328
12329
12330<h3 class="sectionHead"><span class="titlemark">A. </span> <a
12331 id="x1-128000A"></a>Embedding Vorbis into an Ogg stream</h3>
12332<!--l. 5--><p class="noindent" >
12333<h4 class="subsectionHead"><span class="titlemark">A.1. </span> <a
12334 id="x1-129000A.1"></a>Overview</h4>
12335<!--l. 7--><p class="noindent" >This document describes using Ogg logical and physical transport streams to encapsulate Vorbis
12336compressed audio packet data into file form.
12337<!--l. 11--><p class="noindent" >The <a
12338href="#x1-20001">section&#x00A0;1</a>, &#8220;<a
12339href="#x1-20001">Introduction and Description<!--tex4ht:ref: vorbis:spec:intro --></a>&#8221; provides an overview of the construction of Vorbis
12340audio packets.
12341<!--l. 14--><p class="noindent" >The <a
12342href="oggstream.html" >Ogg bitstream overview</a> and <a
12343href="framing.html" >Ogg logical bitstream and framing spec</a> provide detailed
12344descriptions of Ogg transport streams. This specification document assumes a working
12345knowledge of the concepts covered in these named backround documents. Please read them
12346first.
12347<!--l. 21--><p class="noindent" >
12348<h5 class="subsubsectionHead"><span class="titlemark">A.1.1. </span> <a
12349 id="x1-130000A.1.1"></a>Restrictions</h5>
12350<!--l. 23--><p class="noindent" >The Ogg/Vorbis I specification currently dictates that Ogg/Vorbis streams use Ogg transport
12351streams in degenerate, unmultiplexed form only. That is:
12352 <ul class="itemize1">
12353 <li class="itemize">A meta-headerless Ogg file encapsulates the Vorbis I packets
12354 </li>
12355 <li class="itemize">The Ogg stream may be chained, i.e., contain multiple, contigous logical streams
12356 (links).
12357 </li>
12358 <li class="itemize">The Ogg stream must be unmultiplexed (only one stream, a Vorbis audio stream,
12359 per link)
12360 </li></ul>
12361
12362
12363
12364<!--l. 40--><p class="noindent" >This is not to say that it is not currently possible to multiplex Vorbis with other media
12365types into a multi-stream Ogg file. At the time this document was written, Ogg was
12366becoming a popular container for low-bitrate movies consisting of DivX video and Vorbis
12367audio. However, a &#8217;Vorbis I audio file&#8217; is taken to imply Vorbis audio existing alone
12368within a degenerate Ogg stream. A compliant &#8217;Vorbis audio player&#8217; is not required to
12369implement Ogg support beyond the specific support of Vorbis within a degenrate Ogg
12370stream (naturally, application authors are encouraged to support full multiplexed Ogg
12371handling).
12372<!--l. 54--><p class="noindent" >
12373<h5 class="subsubsectionHead"><span class="titlemark">A.1.2. </span> <a
12374 id="x1-131000A.1.2"></a>MIME type</h5>
12375<!--l. 56--><p class="noindent" >The MIME type of Ogg files depend on the context. Specifically, complex multimedia and
12376applications should use <span
12377class="cmtt-12">application/ogg</span>, while visual media should use <span
12378class="cmtt-12">video/ogg</span>, and audio
12379<span
12380class="cmtt-12">audio/ogg</span>. Vorbis data encapsulated in Ogg may appear in any of those types. RTP
12381encapsulated Vorbis should use <span
12382class="cmtt-12">audio/vorbis </span>+ <span
12383class="cmtt-12">audio/vorbis-config</span>.
12384<!--l. 64--><p class="noindent" >
12385<h4 class="subsectionHead"><span class="titlemark">A.2. </span> <a
12386 id="x1-132000A.2"></a>Encapsulation</h4>
12387<!--l. 66--><p class="noindent" >Ogg encapsulation of a Vorbis packet stream is straightforward.
12388 <ul class="itemize1">
12389 <li class="itemize">The first Vorbis packet (the identification header), which uniquely identifies a stream
12390 as Vorbis audio, is placed alone in the first page of the logical Ogg stream. This
12391 results in a first Ogg page of exactly 58 bytes at the very beginning of the logical
12392 stream.
12393 </li>
12394 <li class="itemize">This first page is marked &#8217;beginning of stream&#8217; in the page flags.
12395 </li>
12396 <li class="itemize">The second and third vorbis packets (comment and setup headers) may span one or
12397 more pages beginning on the second page of the logical stream. However many pages
12398 they span, the third header packet finishes the page on which it ends. The next (first
12399 audio) packet must begin on a fresh page.
12400
12401
12402
12403 </li>
12404 <li class="itemize">The granule position of these first pages containing only headers is zero.
12405 </li>
12406 <li class="itemize">The first audio packet of the logical stream begins a fresh Ogg page.
12407 </li>
12408 <li class="itemize">Packets are placed into ogg pages in order until the end of stream.
12409 </li>
12410 <li class="itemize">The last page is marked &#8217;end of stream&#8217; in the page flags.
12411 </li>
12412 <li class="itemize">Vorbis packets may span page boundaries.
12413 </li>
12414 <li class="itemize">The granule position of pages containing Vorbis audio is in units of PCM audio
12415 samples (per channel; a stereo stream&#8217;s granule position does not increment at twice
12416 the speed of a mono stream).
12417 </li>
12418 <li class="itemize">The granule position of a page represents the end PCM sample position of the last
12419 packet <span
12420class="cmti-12">completed </span>on that page. The &#8217;last PCM sample&#8217; is the last complete sample
12421 returned by decode, not an internal sample awaiting lapping with a subsequent block.
12422 A page that is entirely spanned by a single packet (that completes on a subsequent
12423 page) has no granule position, and the granule position is set to &#8217;-1&#8217;.
12424 <!--l. 125--><p class="noindent" >Note that the last decoded (fully lapped) PCM sample from a packet is not
12425 necessarily the middle sample from that block. If, eg, the current Vorbis packet
12426 encodes a &#8221;long block&#8221; and the next Vorbis packet encodes a &#8221;short block&#8221;, the last
12427 decodable sample from the current packet be at position (3*long_block_length/4) -
12428 (short_block_length/4).
12429 </li>
12430 <li class="itemize">The granule (PCM) position of the first page need not indicate that the stream
12431 started at position zero. Although the granule position belongs to the last completed
12432 packet on the page and a valid granule position must be positive, by inference it may
12433 indicate that the PCM position of the beginning of audio is positive or negative.
12434 <ul class="itemize2">
12435 <li class="itemize">A positive starting value simply indicates that this stream begins at some
12436 positive time offset, potentially within a larger program. This is a common case
12437 when connecting to the middle of broadcast stream.
12438 </li>
12439 <li class="itemize">A negative value indicates that output samples preceeding time zero should be
12440
12441
12442
12443 discarded during decoding; this technique is used to allow sample-granularity
12444 editing of the stream start time of already-encoded Vorbis streams. The number
12445 of samples to be discarded must not exceed the overlap-add span of the first two
12446 audio packets.
12447 </li></ul>
12448 <!--l. 160--><p class="noindent" >In both of these cases in which the initial audio PCM starting offset is nonzero, the
12449 second finished audio packet must flush the page on which it appears and the
12450 third packet begin a fresh page. This allows the decoder to always be able to
12451 perform PCM position adjustments before needing to return any PCM data from
12452 synthesis, resulting in correct positioning information without any aditional seeking
12453 logic.
12454 <!--l. 169--><p class="noindent" ><span class="likesubparagraphHead"><a
12455 id="x1-133000A.2"></a><span
12456class="cmbx-12">Note:</span></span> Failure to do so should, at worst, cause a decoder implementation to return
12457 incorrect positioning information for seeking operations at the very beginning of the
12458 stream.
12459 </li>
12460 <li class="itemize">A granule position on the final page in a stream that indicates less audio data than the
12461 final packet would normally return is used to end the stream on other than even frame
12462 boundaries. The difference between the actual available data returned and the
12463 declared amount indicates how many trailing samples to discard from the decoding
12464 process.
12465 </li></ul>
12466
12467
12468
12469<h3 class="sectionHead"><span class="titlemark">B. </span> <a
12470 id="x1-134000B"></a>Vorbis encapsulation in RTP</h3>
12471<!--l. 7--><p class="noindent" >Please consult RFC 5215 <span
12472class="cmti-12">&#8220;RTP Payload Format for Vorbis Encoded Audio&#8221; </span>for description of
12473how to embed Vorbis audio in an RTP stream.
12474
12475
12476
12477
12478
12479
12480<h3 class="likesectionHead"><a
12481 id="x1-135000B"></a>Colophon</h3>
12482<!--l. 5--><p class="noindent" ><img
12483src="fish_xiph_org.png" alt="PIC"
12484>
12485<!--l. 8--><p class="noindent" >Ogg is a <a
12486href="https://xiph.org/" >Xiph.Org Foundation</a> effort to protect essential tenets of Internet multimedia from
12487corporate hostage-taking; Open Source is the net&#8217;s greatest tool to keep everyone honest. See
12488<a
12489href="https://xiph.org/about/" >About the Xiph.Org Foundation</a> for details.
12490<!--l. 15--><p class="noindent" >Ogg Vorbis is the first Ogg audio CODEC. Anyone may freely use and distribute the Ogg and
12491Vorbis specification, whether in a private, public or corporate capacity. However, the Xiph.Org
12492Foundation and the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis specification
12493and certify specification compliance.
12494<!--l. 21--><p class="noindent" >Xiph.Org&#8217;s Vorbis software CODEC implementation is distributed under a BSD-like license. This
12495does not restrict third parties from distributing independent implementations of Vorbis software
12496under other licenses.
12497<!--l. 26--><p class="noindent" >Ogg, Vorbis, Xiph.Org Foundation and their logos are trademarks (tm) of the <a
12498href="https://xiph.org/" >Xiph.Org
12499Foundation</a>. These pages are copyright (C) 1994-2015 Xiph.Org Foundation. All rights
12500reserved.
12501<!--l. 31--><p class="noindent" >This document is set using <span class="LATEX">L<span class="A">A</span><span class="TEX">T<span
12502class="E">E</span>X</span></span>.
12503
12504
12505
12506<h3 class="likesectionHead"><a
12507 id="x1-136000B"></a>References</h3>
12508<!--l. 132--><p class="noindent" >
12509 <div class="thebibliography">
12510 <p class="bibitem" ><span class="biblabel">
12511 [1]<span class="bibsp">&#x00A0;&#x00A0;&#x00A0;</span></span><a
12512 id="XSporer/Brandenburg/Edler"></a>T.&#x00A0;Sporer, K.&#x00A0;Brandenburg and
12513 B.&#x00A0;Edler, The use of multirate filter banks for coding of high quality digital audio,
12514 <a
12515href="https://media.taricorp.net/eusipco_corrected.pdf" class="url" ><span
12516class="cmtt-12">https://media.taricorp.net/eusipco_corrected.pdf</span></a>.
12517</p>
12518 </div>
12519
12520</body></html>
12521
12522
12523
12524
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette