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
|
---|
20 | class="cmr-17">Xiph.Org Foundation</span></div><br />
|
---|
21 | <div class="date" ><span
|
---|
22 | class="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 |  <span class="sectionToc" >1 <a
|
---|
28 | href="#x1-20001" id="QQ2-1-2">Introduction and Description</a></span>
|
---|
29 | <br />  <span class="subsectionToc" >1.1 <a
|
---|
30 | href="#x1-30001.1" id="QQ2-1-3">Overview</a></span>
|
---|
31 | <br />   <span class="subsubsectionToc" >1.1.1 <a
|
---|
32 | href="#x1-40001.1.1" id="QQ2-1-4">Application</a></span>
|
---|
33 | <br />   <span class="subsubsectionToc" >1.1.2 <a
|
---|
34 | href="#x1-50001.1.2" id="QQ2-1-5">Classification</a></span>
|
---|
35 | <br />   <span class="subsubsectionToc" >1.1.3 <a
|
---|
36 | href="#x1-60001.1.3" id="QQ2-1-6">Assumptions</a></span>
|
---|
37 | <br />   <span class="subsubsectionToc" >1.1.4 <a
|
---|
38 | href="#x1-70001.1.4" id="QQ2-1-7">Codec Setup and Probability Model</a></span>
|
---|
39 | <br />   <span class="subsubsectionToc" >1.1.5 <a
|
---|
40 | href="#x1-90001.1.5" id="QQ2-1-9">Format Specification</a></span>
|
---|
41 | <br />   <span class="subsubsectionToc" >1.1.6 <a
|
---|
42 | href="#x1-100001.1.6" id="QQ2-1-10">Hardware Profile</a></span>
|
---|
43 | <br />  <span class="subsectionToc" >1.2 <a
|
---|
44 | href="#x1-110001.2" id="QQ2-1-11">Decoder Configuration</a></span>
|
---|
45 | <br />   <span class="subsubsectionToc" >1.2.1 <a
|
---|
46 | href="#x1-120001.2.1" id="QQ2-1-13">Global Config</a></span>
|
---|
47 | <br />   <span class="subsubsectionToc" >1.2.2 <a
|
---|
48 | href="#x1-130001.2.2" id="QQ2-1-14">Mode</a></span>
|
---|
49 | <br />   <span class="subsubsectionToc" >1.2.3 <a
|
---|
50 | href="#x1-140001.2.3" id="QQ2-1-15">Mapping</a></span>
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 | <br />   <span class="subsubsectionToc" >1.2.4 <a
|
---|
55 | href="#x1-150001.2.4" id="QQ2-1-16">Floor</a></span>
|
---|
56 | <br />   <span class="subsubsectionToc" >1.2.5 <a
|
---|
57 | href="#x1-160001.2.5" id="QQ2-1-17">Residue</a></span>
|
---|
58 | <br />   <span class="subsubsectionToc" >1.2.6 <a
|
---|
59 | href="#x1-170001.2.6" id="QQ2-1-18">Codebooks</a></span>
|
---|
60 | <br />  <span class="subsectionToc" >1.3 <a
|
---|
61 | href="#x1-180001.3" id="QQ2-1-19">High-level Decode Process</a></span>
|
---|
62 | <br />   <span class="subsubsectionToc" >1.3.1 <a
|
---|
63 | href="#x1-190001.3.1" id="QQ2-1-20">Decode Setup</a></span>
|
---|
64 | <br />   <span class="subsubsectionToc" >1.3.2 <a
|
---|
65 | href="#x1-230001.3.2" id="QQ2-1-24">Decode Procedure</a></span>
|
---|
66 | <br /> <span class="sectionToc" >2 <a
|
---|
67 | href="#x1-360002" id="QQ2-1-39">Bitpacking Convention</a></span>
|
---|
68 | <br />  <span class="subsectionToc" >2.1 <a
|
---|
69 | href="#x1-370002.1" id="QQ2-1-40">Overview</a></span>
|
---|
70 | <br />   <span class="subsubsectionToc" >2.1.1 <a
|
---|
71 | href="#x1-380002.1.1" id="QQ2-1-41">octets, bytes and words</a></span>
|
---|
72 | <br />   <span class="subsubsectionToc" >2.1.2 <a
|
---|
73 | href="#x1-390002.1.2" id="QQ2-1-42">bit order</a></span>
|
---|
74 | <br />   <span class="subsubsectionToc" >2.1.3 <a
|
---|
75 | href="#x1-400002.1.3" id="QQ2-1-43">byte order</a></span>
|
---|
76 | <br />   <span class="subsubsectionToc" >2.1.4 <a
|
---|
77 | href="#x1-410002.1.4" id="QQ2-1-44">coding bits into byte sequences</a></span>
|
---|
78 | <br />   <span class="subsubsectionToc" >2.1.5 <a
|
---|
79 | href="#x1-420002.1.5" id="QQ2-1-45">signedness</a></span>
|
---|
80 | <br />   <span class="subsubsectionToc" >2.1.6 <a
|
---|
81 | href="#x1-430002.1.6" id="QQ2-1-46">coding example</a></span>
|
---|
82 | <br />   <span class="subsubsectionToc" >2.1.7 <a
|
---|
83 | href="#x1-440002.1.7" id="QQ2-1-47">decoding example</a></span>
|
---|
84 | <br />   <span class="subsubsectionToc" >2.1.8 <a
|
---|
85 | href="#x1-450002.1.8" id="QQ2-1-48">end-of-packet alignment</a></span>
|
---|
86 | <br />   <span class="subsubsectionToc" >2.1.9 <a
|
---|
87 | href="#x1-460002.1.9" id="QQ2-1-49">reading zero bits</a></span>
|
---|
88 | <br /> <span class="sectionToc" >3 <a
|
---|
89 | href="#x1-470003" id="QQ2-1-50">Probability Model and Codebooks</a></span>
|
---|
90 | <br />  <span class="subsectionToc" >3.1 <a
|
---|
91 | href="#x1-480003.1" id="QQ2-1-51">Overview</a></span>
|
---|
92 | <br />   <span class="subsubsectionToc" >3.1.1 <a
|
---|
93 | href="#x1-490003.1.1" id="QQ2-1-52">Bitwise operation</a></span>
|
---|
94 | <br />  <span class="subsectionToc" >3.2 <a
|
---|
95 | href="#x1-500003.2" id="QQ2-1-53">Packed codebook format</a></span>
|
---|
96 | <br />   <span class="subsubsectionToc" >3.2.1 <a
|
---|
97 | href="#x1-510003.2.1" id="QQ2-1-54">codebook decode</a></span>
|
---|
98 | <br />  <span class="subsectionToc" >3.3 <a
|
---|
99 | href="#x1-580003.3" id="QQ2-1-63">Use of the codebook abstraction</a></span>
|
---|
100 | <br /> <span class="sectionToc" >4 <a
|
---|
101 | href="#x1-590004" id="QQ2-1-64">Codec Setup and Packet Decode</a></span>
|
---|
102 | <br />  <span class="subsectionToc" >4.1 <a
|
---|
103 | href="#x1-600004.1" id="QQ2-1-65">Overview</a></span>
|
---|
104 | <br />  <span class="subsectionToc" >4.2 <a
|
---|
105 | href="#x1-610004.2" id="QQ2-1-66">Header decode and decode setup</a></span>
|
---|
106 | <br />   <span class="subsubsectionToc" >4.2.1 <a
|
---|
107 | href="#x1-620004.2.1" id="QQ2-1-67">Common header decode</a></span>
|
---|
108 | <br />   <span class="subsubsectionToc" >4.2.2 <a
|
---|
109 | href="#x1-630004.2.2" id="QQ2-1-68">Identification header</a></span>
|
---|
110 | <br />   <span class="subsubsectionToc" >4.2.3 <a
|
---|
111 | href="#x1-640004.2.3" id="QQ2-1-69">Comment header</a></span>
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 | <br />   <span class="subsubsectionToc" >4.2.4 <a
|
---|
116 | href="#x1-650004.2.4" id="QQ2-1-70">Setup header</a></span>
|
---|
117 | <br />  <span class="subsectionToc" >4.3 <a
|
---|
118 | href="#x1-720004.3" id="QQ2-1-78">Audio packet decode and synthesis</a></span>
|
---|
119 | <br />   <span class="subsubsectionToc" >4.3.1 <a
|
---|
120 | href="#x1-730004.3.1" id="QQ2-1-79">packet type, mode and window decode</a></span>
|
---|
121 | <br />   <span class="subsubsectionToc" >4.3.2 <a
|
---|
122 | href="#x1-740004.3.2" id="QQ2-1-80">floor curve decode</a></span>
|
---|
123 | <br />   <span class="subsubsectionToc" >4.3.3 <a
|
---|
124 | href="#x1-750004.3.3" id="QQ2-1-81">nonzero vector propagate</a></span>
|
---|
125 | <br />   <span class="subsubsectionToc" >4.3.4 <a
|
---|
126 | href="#x1-760004.3.4" id="QQ2-1-82">residue decode</a></span>
|
---|
127 | <br />   <span class="subsubsectionToc" >4.3.5 <a
|
---|
128 | href="#x1-770004.3.5" id="QQ2-1-83">inverse coupling</a></span>
|
---|
129 | <br />   <span class="subsubsectionToc" >4.3.6 <a
|
---|
130 | href="#x1-780004.3.6" id="QQ2-1-84">dot product</a></span>
|
---|
131 | <br />   <span class="subsubsectionToc" >4.3.7 <a
|
---|
132 | href="#x1-790004.3.7" id="QQ2-1-85">inverse MDCT</a></span>
|
---|
133 | <br />   <span class="subsubsectionToc" >4.3.8 <a
|
---|
134 | href="#x1-800004.3.8" id="QQ2-1-86">overlap_add</a></span>
|
---|
135 | <br />   <span class="subsubsectionToc" >4.3.9 <a
|
---|
136 | href="#x1-810004.3.9" id="QQ2-1-87">output channel order</a></span>
|
---|
137 | <br /> <span class="sectionToc" >5 <a
|
---|
138 | href="#x1-820005" id="QQ2-1-88">comment field and header specification</a></span>
|
---|
139 | <br />  <span class="subsectionToc" >5.1 <a
|
---|
140 | href="#x1-830005.1" id="QQ2-1-89">Overview</a></span>
|
---|
141 | <br />  <span class="subsectionToc" >5.2 <a
|
---|
142 | href="#x1-840005.2" id="QQ2-1-90">Comment encoding</a></span>
|
---|
143 | <br />   <span class="subsubsectionToc" >5.2.1 <a
|
---|
144 | href="#x1-850005.2.1" id="QQ2-1-91">Structure</a></span>
|
---|
145 | <br />   <span class="subsubsectionToc" >5.2.2 <a
|
---|
146 | href="#x1-860005.2.2" id="QQ2-1-92">Content vector format</a></span>
|
---|
147 | <br />   <span class="subsubsectionToc" >5.2.3 <a
|
---|
148 | href="#x1-890005.2.3" id="QQ2-1-95">Encoding</a></span>
|
---|
149 | <br /> <span class="sectionToc" >6 <a
|
---|
150 | href="#x1-900006" id="QQ2-1-96">Floor type 0 setup and decode</a></span>
|
---|
151 | <br />  <span class="subsectionToc" >6.1 <a
|
---|
152 | href="#x1-910006.1" id="QQ2-1-97">Overview</a></span>
|
---|
153 | <br />  <span class="subsectionToc" >6.2 <a
|
---|
154 | href="#x1-920006.2" id="QQ2-1-98">Floor 0 format</a></span>
|
---|
155 | <br />   <span class="subsubsectionToc" >6.2.1 <a
|
---|
156 | href="#x1-930006.2.1" id="QQ2-1-99">header decode</a></span>
|
---|
157 | <br />   <span class="subsubsectionToc" >6.2.2 <a
|
---|
158 | href="#x1-940006.2.2" id="QQ2-1-100">packet decode</a></span>
|
---|
159 | <br />   <span class="subsubsectionToc" >6.2.3 <a
|
---|
160 | href="#x1-950006.2.3" id="QQ2-1-101">curve computation</a></span>
|
---|
161 | <br /> <span class="sectionToc" >7 <a
|
---|
162 | href="#x1-970007" id="QQ2-1-103">Floor type 1 setup and decode</a></span>
|
---|
163 | <br />  <span class="subsectionToc" >7.1 <a
|
---|
164 | href="#x1-980007.1" id="QQ2-1-104">Overview</a></span>
|
---|
165 | <br />  <span class="subsectionToc" >7.2 <a
|
---|
166 | href="#x1-990007.2" id="QQ2-1-105">Floor 1 format</a></span>
|
---|
167 | <br />   <span class="subsubsectionToc" >7.2.1 <a
|
---|
168 | href="#x1-1000007.2.1" id="QQ2-1-106">model</a></span>
|
---|
169 | <br />   <span class="subsubsectionToc" >7.2.2 <a
|
---|
170 | href="#x1-1010007.2.2" id="QQ2-1-111">header decode</a></span>
|
---|
171 | <br />   <span class="subsubsectionToc" >7.2.3 <a
|
---|
172 | href="#x1-1020007.2.3" id="QQ2-1-112">packet decode</a></span>
|
---|
173 |
|
---|
174 |
|
---|
175 |
|
---|
176 | <br />   <span class="subsubsectionToc" >7.2.4 <a
|
---|
177 | href="#x1-1030007.2.4" id="QQ2-1-113">curve computation</a></span>
|
---|
178 | <br /> <span class="sectionToc" >8 <a
|
---|
179 | href="#x1-1040008" id="QQ2-1-114">Residue setup and decode</a></span>
|
---|
180 | <br />  <span class="subsectionToc" >8.1 <a
|
---|
181 | href="#x1-1050008.1" id="QQ2-1-115">Overview</a></span>
|
---|
182 | <br />  <span class="subsectionToc" >8.2 <a
|
---|
183 | href="#x1-1060008.2" id="QQ2-1-116">Residue format</a></span>
|
---|
184 | <br />  <span class="subsectionToc" >8.3 <a
|
---|
185 | href="#x1-1070008.3" id="QQ2-1-118">residue 0</a></span>
|
---|
186 | <br />  <span class="subsectionToc" >8.4 <a
|
---|
187 | href="#x1-1080008.4" id="QQ2-1-119">residue 1</a></span>
|
---|
188 | <br />  <span class="subsectionToc" >8.5 <a
|
---|
189 | href="#x1-1090008.5" id="QQ2-1-120">residue 2</a></span>
|
---|
190 | <br />  <span class="subsectionToc" >8.6 <a
|
---|
191 | href="#x1-1100008.6" id="QQ2-1-122">Residue decode</a></span>
|
---|
192 | <br />   <span class="subsubsectionToc" >8.6.1 <a
|
---|
193 | href="#x1-1110008.6.1" id="QQ2-1-123">header decode</a></span>
|
---|
194 | <br />   <span class="subsubsectionToc" >8.6.2 <a
|
---|
195 | href="#x1-1120008.6.2" id="QQ2-1-124">packet decode</a></span>
|
---|
196 | <br />   <span class="subsubsectionToc" >8.6.3 <a
|
---|
197 | href="#x1-1130008.6.3" id="QQ2-1-125">format 0 specifics</a></span>
|
---|
198 | <br />   <span class="subsubsectionToc" >8.6.4 <a
|
---|
199 | href="#x1-1140008.6.4" id="QQ2-1-126">format 1 specifics</a></span>
|
---|
200 | <br />   <span class="subsubsectionToc" >8.6.5 <a
|
---|
201 | href="#x1-1150008.6.5" id="QQ2-1-127">format 2 specifics</a></span>
|
---|
202 | <br /> <span class="sectionToc" >9 <a
|
---|
203 | href="#x1-1160009" id="QQ2-1-128">Helper equations</a></span>
|
---|
204 | <br />  <span class="subsectionToc" >9.1 <a
|
---|
205 | href="#x1-1170009.1" id="QQ2-1-129">Overview</a></span>
|
---|
206 | <br />  <span class="subsectionToc" >9.2 <a
|
---|
207 | href="#x1-1180009.2" id="QQ2-1-130">Functions</a></span>
|
---|
208 | <br />   <span class="subsubsectionToc" >9.2.1 <a
|
---|
209 | href="#x1-1190009.2.1" id="QQ2-1-131">ilog</a></span>
|
---|
210 | <br />   <span class="subsubsectionToc" >9.2.2 <a
|
---|
211 | href="#x1-1200009.2.2" id="QQ2-1-132">float32_unpack</a></span>
|
---|
212 | <br />   <span class="subsubsectionToc" >9.2.3 <a
|
---|
213 | href="#x1-1210009.2.3" id="QQ2-1-133">lookup1_values</a></span>
|
---|
214 | <br />   <span class="subsubsectionToc" >9.2.4 <a
|
---|
215 | href="#x1-1220009.2.4" id="QQ2-1-134">low_neighbor</a></span>
|
---|
216 | <br />   <span class="subsubsectionToc" >9.2.5 <a
|
---|
217 | href="#x1-1230009.2.5" id="QQ2-1-135">high_neighbor</a></span>
|
---|
218 | <br />   <span class="subsubsectionToc" >9.2.6 <a
|
---|
219 | href="#x1-1240009.2.6" id="QQ2-1-136">render_point</a></span>
|
---|
220 | <br />   <span class="subsubsectionToc" >9.2.7 <a
|
---|
221 | href="#x1-1250009.2.7" id="QQ2-1-137">render_line</a></span>
|
---|
222 | <br /> <span class="sectionToc" >10 <a
|
---|
223 | href="#x1-12600010" id="QQ2-1-138">Tables</a></span>
|
---|
224 | <br />  <span class="subsectionToc" >10.1 <a
|
---|
225 | href="#x1-12700010.1" id="QQ2-1-139">floor1_inverse_dB_table</a></span>
|
---|
226 | <br /> <span class="sectionToc" >A <a
|
---|
227 | href="#x1-128000A" id="QQ2-1-140">Embedding Vorbis into an Ogg stream</a></span>
|
---|
228 | <br />  <span class="subsectionToc" >A.1 <a
|
---|
229 | href="#x1-129000A.1" id="QQ2-1-141">Overview</a></span>
|
---|
230 | <br />   <span class="subsubsectionToc" >A.1.1 <a
|
---|
231 | href="#x1-130000A.1.1" id="QQ2-1-142">Restrictions</a></span>
|
---|
232 | <br />   <span class="subsubsectionToc" >A.1.2 <a
|
---|
233 | href="#x1-131000A.1.2" id="QQ2-1-143">MIME type</a></span>
|
---|
234 |
|
---|
235 |
|
---|
236 |
|
---|
237 | <br />  <span class="subsectionToc" >A.2 <a
|
---|
238 | href="#x1-132000A.2" id="QQ2-1-144">Encapsulation</a></span>
|
---|
239 | <br /> <span class="sectionToc" >B <a
|
---|
240 | href="#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’s construction. A bit-by-bit
|
---|
251 | specification appears beginning in <a
|
---|
252 | href="#x1-590004">section 4</a>, “<a
|
---|
253 | href="#x1-590004">Codec Setup and Packet Decode<!--tex4ht:ref: vorbis:spec:codec --></a>”. The later
|
---|
254 | sections assume a high-level understanding of the Vorbis decode process, which is provided
|
---|
255 | here.
|
---|
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
|
---|
260 | flexibility, thus allowing it to scale competitively over an exceptionally wide range of bitrates. At
|
---|
261 | the high quality/bitrate end of the scale (CD or DAT rate stereo, 16/24 bits) it is in the same
|
---|
262 | league as MPEG-2 and MPC. Similarly, the 1.0 encoder can encode high-quality CD and DAT
|
---|
263 | rate stereo at below 48kbps without resampling to a lower rate. Vorbis is also intended for lower
|
---|
264 | and higher sample rates (from 8kHz telephony to 192kHz digital masters) and a range of channel
|
---|
265 | representations (monaural, polyphonic, stereo, quadraphonic, 5.1, ambisonic, or up to 255
|
---|
266 | discrete 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
|
---|
271 | Cosine Transform. The codec is structured to allow addition of a hybrid wavelet filterbank in
|
---|
272 | Vorbis II to offer better transient response and reproduction using a transform better suited to
|
---|
273 | localized 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,
|
---|
281 | low-complexity decoder. Vorbis decode is computationally simpler than mp3, although it does
|
---|
282 | require more working memory as Vorbis has no static probability model; the vector codebooks
|
---|
283 | used in the first stage of decoding from the bitstream are packed in their entirety into the Vorbis
|
---|
284 | bitstream headers. In packed form, these codebooks occupy only a few kilobytes; the extent to
|
---|
285 | which they are pre-decoded into a cache is the dominant factor in decoder memory
|
---|
286 | usage.
|
---|
287 | <!--l. 49--><p class="noindent" >Vorbis provides none of its own framing, synchronization or protection against errors; it
|
---|
288 | is solely a method of accepting input audio, dividing it into individual frames and
|
---|
289 | compressing these frames into raw, unformatted ’packets’. The decoder then accepts
|
---|
290 | these raw packets in sequence, decodes them, synthesizes audio frames from them, and
|
---|
291 | reassembles the frames into a facsimile of the original audio stream. Vorbis is a free-form
|
---|
292 | variable bit rate (VBR) codec and packets have no minimum size, maximum size, or
|
---|
293 | fixed/expected size. Packets are designed that they may be truncated (or padded)
|
---|
294 | and remain decodable; this is not to be considered an error condition and is used
|
---|
295 | extensively in bitrate management in peeling. Both the transport mechanism and
|
---|
296 | decoder must allow that a packet may be any size, or end before or after packet decode
|
---|
297 | expects.
|
---|
298 | <!--l. 63--><p class="noindent" >Vorbis packets are thus intended to be used with a transport mechanism that provides free-form
|
---|
299 | framing, sync, positioning and error correction in accordance with these design assumptions, such
|
---|
300 | as Ogg (for file transport) or RTP (for network multicast). For purposes of a few examples in this
|
---|
301 | document, we will assume that Vorbis is to be embedded in an Ogg stream specifically,
|
---|
302 | although this is by no means a requirement or fundamental assumption in the Vorbis
|
---|
303 | design.
|
---|
304 | <!--l. 71--><p class="noindent" >The specification for embedding Vorbis into an Ogg transport stream is in <a
|
---|
305 | href="#x1-128000A">section A</a>,
|
---|
306 | “<a
|
---|
307 | href="#x1-128000A">Embedding Vorbis into an Ogg stream<!--tex4ht:ref: vorbis:over:ogg --></a>”.
|
---|
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’ heritage is as a research CODEC and its current design reflects a desire to allow multiple
|
---|
312 | decades of continuous encoder improvement before running out of room within the codec
|
---|
313 | specification. For these reasons, configurable aspects of codec setup intentionally lean toward the
|
---|
314 | extreme 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
|
---|
319 | developer to keep in mind) is that the entire probability model of the codec, the Huffman and
|
---|
320 | VQ codebooks, is packed into the bitstream header along with extensive CODEC setup
|
---|
321 | parameters (often several hundred fields). This makes it impossible, as it would be with
|
---|
322 | MPEG audio layers, to embed a simple frame type flag in each audio packet, or begin
|
---|
323 | decode at any frame in the stream without having previously fetched the codec setup
|
---|
324 | header.
|
---|
325 | <!--l. 94--><p class="noindent" ><span class="likesubparagraphHead"><a
|
---|
326 | id="x1-80001.1.4"></a><span
|
---|
327 | class="cmbx-12">Note:</span></span> Vorbis <span
|
---|
328 | class="cmti-12">can </span>initiate decode at any arbitrary packet within a bitstream so long as the codec
|
---|
329 | has 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
|
---|
331 | headers go. The header size is unbounded, although for streaming a rule-of-thumb of 4kB or less
|
---|
332 | is recommended (and Xiph.Org’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
|
---|
334 | an unusual design and thus causes some amount of complaint among engineers as this runs
|
---|
335 | against current design trends (and also points out limitations in some existing software/interface
|
---|
336 | designs, such as Windows’ ACM codec framework). However, we find that it does not
|
---|
337 | fundamentally limit Vorbis’ 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
|
---|
342 | that are correctly decoded by the reference Vorbis decoder described below may be considered
|
---|
343 | a proper Vorbis encoder. A decoder must faithfully and completely implement the
|
---|
344 | specification defined below (except where noted) to be considered a proper Vorbis
|
---|
345 | decoder.
|
---|
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
|
---|
353 | embedded design. For this reason, embedded designs are allowed to deviate in limited ways from
|
---|
354 | the ‘full’ decode specification yet still be certified compliant. These optional omissions are
|
---|
355 | labelled 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
|
---|
360 | perform specific functions in the decode pipeline. Each different component instance of a specific
|
---|
361 | type is semantically interchangeable; decoder configuration consists both of internal component
|
---|
362 | configuration, as well as arrangement of specific instances into a decode pipeline. Componentry
|
---|
363 | arrangement is roughly as follows:
|
---|
364 | <div class="center"
|
---|
365 | >
|
---|
366 | <!--l. 140--><p class="noindent" >
|
---|
367 |
|
---|
368 | <!--l. 141--><p class="noindent" ><img
|
---|
369 | src="components.png" alt="PIC"
|
---|
370 | >
|
---|
371 | <br /> <div class="caption"
|
---|
372 | ><span class="id">Figure 1: </span><span
|
---|
373 | class="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
|
---|
379 | version (always ’0’ in Vorbis I), bitrate hints, and the lists of component instances. All other
|
---|
380 | configuration 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 ’mode’. A bitstream may use one or many
|
---|
388 | modes.
|
---|
389 | <!--l. 156--><p class="noindent" >The mode mechanism is used to encode a frame according to one of multiple possible
|
---|
390 | methods with the intention of choosing a method best suited to that frame. Different
|
---|
391 | modes are, e.g. how frame size is changed from frame to frame. The mode number of a
|
---|
392 | frame serves as a top level configuration switch for all other specific aspects of frame
|
---|
393 | decode.
|
---|
394 | <!--l. 163--><p class="noindent" >A ’mode’ configuration consists of a frame size setting, window type (always 0, the Vorbis
|
---|
395 | window, in Vorbis I), transform type (always type 0, the MDCT, in Vorbis I) and a mapping
|
---|
396 | number. The mapping number specifies which mapping configuration instance to use for low-level
|
---|
397 | packet 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 ’submaps’ that bundle sets
|
---|
402 | of channel vectors together for grouped encoding and decoding. These submaps are
|
---|
403 | not references to external components; the submap list is internal and specific to a
|
---|
404 | mapping.
|
---|
405 | <!--l. 177--><p class="noindent" >A ’submap’ is a configuration/grouping that applies to a subset of floor and residue vectors
|
---|
406 | within a mapping. The submap functions as a last layer of indirection such that specific special
|
---|
407 | floor or residue settings can be applied not only to all the vectors in a given mode, but also
|
---|
408 | specific vectors in a specific mode. Each submap specifies the proper floor and residue
|
---|
409 | instance number to use for decoding that submap’s spectral floor and spectral residue
|
---|
410 | vectors.
|
---|
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
|
---|
413 | channel, as is normal in 5.1, is bass only. Therefore it would be wasteful to encode a
|
---|
414 | full-spectrum version of it as with the other channels. The submapping mechanism can be used
|
---|
415 | to apply a full range floor and residue encoding to channels 0 through 4, and a bass-only
|
---|
416 | representation to the bass channel, thus saving space. In this example, channels 0-4 belong to
|
---|
417 | submap 0 (which indicates use of a full-range floor) and channel 5 belongs to submap 1, which
|
---|
418 | uses 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 ’floor’ vector for each PCM channel. This vector is a low-resolution
|
---|
426 | representation of the audio spectrum for the given channel in the current frame, generally used
|
---|
427 | akin to a whitening filter. It is named a ’floor’ because the Xiph.Org reference encoder has
|
---|
428 | historically 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
|
---|
430 | amplitude scale and Bark frequency scale. Floor 1 represents the curve as a piecewise linear
|
---|
431 | interpolated representation on a dB amplitude scale and linear frequency scale. The two floors
|
---|
432 | are semantically interchangeable in encoding/decoding. However, floor type 1 provides more
|
---|
433 | stable inter-frame behavior, and so is the preferred choice in all coupled-stereo and
|
---|
434 | high bitrate modes. Floor 1 is also considerably less expensive to decode than floor
|
---|
435 | 0.
|
---|
436 | <!--l. 217--><p class="noindent" >Floor 0 is not to be considered deprecated, but it is of limited modern use. No known Vorbis
|
---|
437 | encoder past Xiph.Org’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
|
---|
439 | coding to save space. For this reason, a floor configuration generally refers to multiple
|
---|
440 | codebooks in the codebook component list. Entropy coding is thus provided as an
|
---|
441 | abstraction, and each floor instance may choose from any and all available codebooks when
|
---|
442 | coding/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
|
---|
447 | subtracted out. In simplest terms, it is coded in the bitstream using cascaded (multi-pass) vector
|
---|
448 | quantization according to one of three specific packing/coding algorithms numbered
|
---|
449 | 0 through 2. The packing algorithm details are configured by residue instance. As
|
---|
450 | with the floor components, the final VQ/entropy encoding is provided by external
|
---|
451 | codebook instances and each residue instance may choose from any and all available
|
---|
452 | codebooks.
|
---|
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
|
---|
460 | the entropy-decoded integer value as an offset into an index of output value vectors, returning
|
---|
461 | the 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
|
---|
463 | representation. This tree is tightly packed using one of several methods, depending on whether
|
---|
464 | codeword 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,
|
---|
466 | the vector index is encoded as a single list of values of possible values that are then permuted
|
---|
467 | into 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
|
---|
475 | stream to be decoded. Vorbis uses three header packets; all are required, in-order, by
|
---|
476 | this specification. Once set up, decode may begin at any audio packet belonging to
|
---|
477 | the Vorbis stream. In Vorbis I, all packets after the three initial headers are audio
|
---|
478 | packets.
|
---|
479 | <!--l. 270--><p class="noindent" >The header packets are, in order, the identification header, the comments header, and the setup
|
---|
480 | header.
|
---|
481 | <!--l. 273--><p class="noindent" ><span class="paragraphHead"><a
|
---|
482 | id="x1-200001.3.1"></a><span
|
---|
483 | class="cmbx-12">Identification Header</span></span>
|
---|
484 | The identification header identifies the bitstream as Vorbis, Vorbis version, and the simple audio
|
---|
485 | characteristics 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
|
---|
491 | class="cmbx-12">Comment Header</span></span>
|
---|
492 | The comment header includes user text comments (“tags”) and a vendor string for the
|
---|
493 | application/library that produced the bitstream. The encoding and proper use of the comment
|
---|
494 | header is described in <a
|
---|
495 | href="#x1-820005">section 5</a>, “<a
|
---|
496 | href="#x1-820005">comment field and header specification<!--tex4ht:ref: vorbis:spec:comment --></a>”.
|
---|
497 | <!--l. 283--><p class="noindent" ><span class="paragraphHead"><a
|
---|
498 | id="x1-220001.3.1"></a><span
|
---|
499 | class="cmbx-12">Setup Header</span></span>
|
---|
500 | The setup header includes extensive CODEC setup information as well as the complete VQ and
|
---|
501 | Huffman 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
|
---|
508 | class="enumerate-enumitem">decode packet type flag
|
---|
509 | </dd><dt class="enumerate-enumitem">
|
---|
510 | 2. </dt><dd
|
---|
511 | class="enumerate-enumitem">decode mode number
|
---|
512 | </dd><dt class="enumerate-enumitem">
|
---|
513 | 3. </dt><dd
|
---|
514 | class="enumerate-enumitem">decode window shape (long windows only)
|
---|
515 | </dd><dt class="enumerate-enumitem">
|
---|
516 | 4. </dt><dd
|
---|
517 | class="enumerate-enumitem">decode floor
|
---|
518 | </dd><dt class="enumerate-enumitem">
|
---|
519 | 5. </dt><dd
|
---|
520 | class="enumerate-enumitem">decode residue into residue vectors
|
---|
521 | </dd><dt class="enumerate-enumitem">
|
---|
522 | 6. </dt><dd
|
---|
523 | class="enumerate-enumitem">inverse channel coupling of residue vectors
|
---|
524 | </dd><dt class="enumerate-enumitem">
|
---|
525 | 7. </dt><dd
|
---|
526 | class="enumerate-enumitem">generate floor curve from decoded floor data
|
---|
527 | </dd><dt class="enumerate-enumitem">
|
---|
528 | 8. </dt><dd
|
---|
529 | class="enumerate-enumitem">compute dot product of floor and residue, producing audio spectrum vector
|
---|
530 | </dd><dt class="enumerate-enumitem">
|
---|
531 | 9. </dt><dd
|
---|
532 | class="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
|
---|
539 | class="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
|
---|
542 | class="enumerate-enumitem">store right hand-data from transform of current frame for future lapping
|
---|
543 | </dd><dt class="enumerate-enumitem">
|
---|
544 | 12. </dt><dd
|
---|
545 | class="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
|
---|
547 | take advantage of symmetries in the MDCT to store the right-hand transform data of a partial
|
---|
548 | MDCT for a 50% inter-frame buffer space savings, and then complete the transform later before
|
---|
549 | overlap/add with the next frame. This optimization produces entirely equivalent output and is
|
---|
550 | naturally perfectly legal. The decoder must be <span
|
---|
551 | class="cmti-12">entirely mathematically equivalent </span>to the
|
---|
552 | specification, 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
|
---|
555 | class="cmbx-12">Packet type decode</span></span>
|
---|
556 | Vorbis I uses four packet types. The first three packet types mark each of the three Vorbis
|
---|
557 | headers described above. The fourth packet type marks an audio packet. All other packet types
|
---|
558 | are 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
|
---|
560 | audio packet decode is to read and verify the packet type; <span
|
---|
561 | class="cmti-12">a non-audio packet when audio is</span>
|
---|
562 | <span
|
---|
563 | class="cmti-12">expected indicates stream corruption or a non-compliant stream. The decoder must ignore the</span>
|
---|
564 | <span
|
---|
565 | class="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
|
---|
568 | class="cmbx-12">Mode decode</span></span>
|
---|
569 | Vorbis allows an encoder to set up multiple, numbered packet ’modes’, as described earlier, all of
|
---|
570 | which may be used in a given Vorbis stream. The mode is encoded as an integer used as a direct
|
---|
571 | offset into the mode instance index.
|
---|
572 | <!--l. 340--><p class="noindent" ><span class="paragraphHead"><a
|
---|
573 | id="x1-260001.3.2"></a><span
|
---|
574 | class="cmbx-12">Window shape decode (long windows only)</span></span>
|
---|
575 | Vorbis frames may be one of two PCM sample sizes specified during codec setup. In Vorbis I,
|
---|
576 | legal frame sizes are powers of two from 64 to 8192 samples. Aside from coupling, Vorbis
|
---|
577 | handles channels as independent vectors and these frame sizes are in samples per
|
---|
578 | channel.
|
---|
579 |
|
---|
580 |
|
---|
581 |
|
---|
582 | <!--l. 347--><p class="noindent" >Vorbis uses an overlapping transform, namely the MDCT, to blend one frame into the next,
|
---|
583 | avoiding most inter-frame block boundary artifacts. The MDCT output of one frame is windowed
|
---|
584 | according to MDCT requirements, overlapped 50% with the output of the previous frame and
|
---|
585 | added. 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
|
---|
592 | src="window1.png" alt="PIC"
|
---|
593 | >
|
---|
594 | <br /> <div class="caption"
|
---|
595 | ><span class="id">Figure 2: </span><span
|
---|
596 | class="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
|
---|
604 | src="window2.png" alt="PIC"
|
---|
605 | >
|
---|
606 | <br /> <div class="caption"
|
---|
607 | ><span class="id">Figure 3: </span><span
|
---|
608 | class="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
|
---|
611 | seamless lapping as above. It is possible to correctly infer window shape to be applied to the
|
---|
612 | current window from knowing the sizes of the current, previous and next window. It is legal for a
|
---|
613 | decoder to use this method. However, in the case of a long window (short windows require no
|
---|
614 | modification), Vorbis also codes two flag bits to specify pre- and post- window shape. Although
|
---|
615 | not strictly necessary for function, this minor redundancy allows a packet to be fully decoded to
|
---|
616 | the point of lapping entirely independently of any other packet, allowing easier abstraction of
|
---|
617 | decode layers as well as allowing a greater level of easy parallelism in encode and
|
---|
618 | decode.
|
---|
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
|
---|
620 | href="#XSporer/Brandenburg/Edler">1</a>]</span>.
|
---|
621 | Vorbis windows all use the slope function
|
---|
622 | <center class="math-display" >
|
---|
623 | <img
|
---|
624 | src="Vorbis_I_spec0x.png" alt="y = sin (.5 * π sin2((x + .5)∕n * π)).
|
---|
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
|
---|
632 | class="cmbx-12">floor decode</span></span>
|
---|
633 | Each floor is encoded/decoded in channel order, however each floor belongs to a ’submap’ that
|
---|
634 | specifies which floor configuration to use. All floors are decoded before residue decode
|
---|
635 | begins.
|
---|
636 | <!--l. 394--><p class="noindent" ><span class="paragraphHead"><a
|
---|
637 | id="x1-280001.3.2"></a><span
|
---|
638 | class="cmbx-12">residue decode</span></span>
|
---|
639 | Although the number of residue vectors equals the number of channels, channel coupling may
|
---|
640 | mean that the raw residue vectors extracted during decode do not map directly to specific
|
---|
641 | channels. When channel coupling is in use, some vectors will correspond to coupled magnitude or
|
---|
642 | angle. The coupling relationships are described in the codec setup and may differ from frame to
|
---|
643 | frame, 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
|
---|
645 | submap 0 through n-1. This differs from floors which are coded using a configuration provided by
|
---|
646 | submap 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
|
---|
649 | class="cmbx-12">inverse channel coupling</span></span>
|
---|
650 | A detailed discussion of stereo in the Vorbis codec can be found in the document
|
---|
651 | <a
|
---|
652 | href="stereo.html" >Stereo Channel Coupling in the Vorbis CODEC</a>. Vorbis is not limited to only stereo
|
---|
653 | coupling, but the stereo document also gives a good overview of the generic coupling
|
---|
654 | mechanism.
|
---|
655 | <!--l. 418--><p class="noindent" >Vorbis coupling applies to pairs of residue vectors at a time; decoupling is done in-place a
|
---|
656 | pair at a time in the order and using the vectors specified in the current mapping
|
---|
657 | configuration. The decoupling operation is the same for all pairs, converting square polar
|
---|
658 | representation (where one vector is magnitude and the second angle) back to Cartesian
|
---|
659 | representation.
|
---|
660 | <!--l. 425--><p class="noindent" >After decoupling, in order, each pair of vectors on the coupling list, the resulting residue vectors
|
---|
661 | represent 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
|
---|
667 | class="cmbx-12">generate floor curve</span></span>
|
---|
668 | The decoder may choose to generate the floor curve at any appropriate time. It is reasonable to
|
---|
669 | generate the output curve when the floor data is decoded from the raw packet, or it
|
---|
670 | can be generated after inverse coupling and applied to the spectral residue directly,
|
---|
671 | combining generation and the dot product into one step and eliminating some working
|
---|
672 | space.
|
---|
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
|
---|
677 | class="cmbx-12">compute floor/residue dot product</span></span>
|
---|
678 | This step is straightforward; for each output channel, the decoder multiplies the floor curve and
|
---|
679 | residue vectors element by element, producing the finished audio spectrum of each
|
---|
680 | channel.
|
---|
681 | <!--l. 454--><p class="noindent" >One point is worth mentioning about this dot product; a common mistake in a fixed point
|
---|
682 | implementation might be to assume that a 32 bit fixed-point representation for floor and
|
---|
683 | residue and direct multiplication of the vectors is sufficient for acceptable spectral depth
|
---|
684 | in all cases because it happens to mostly work with the current Xiph.Org reference
|
---|
685 | encoder.
|
---|
686 | <!--l. 461--><p class="noindent" >However, floor vector values can span <span
|
---|
687 | class="cmsy-10x-x-120">~</span>140dB (<span
|
---|
688 | class="cmsy-10x-x-120">~</span>24 bits unsigned), and the audio spectrum
|
---|
689 | vector should represent a minimum of 120dB (<span
|
---|
690 | class="cmsy-10x-x-120">~</span>21 bits with sign), even when output is to a 16
|
---|
691 | bit PCM device. For the residue vector to represent full scale if the floor is nailed
|
---|
692 | to <span
|
---|
693 | class="cmsy-10x-x-120">-</span>140dB, it must be able to span 0 to +140dB. For the residue vector to reach
|
---|
694 | full scale if the floor is nailed at 0dB, it must be able to represent <span
|
---|
695 | class="cmsy-10x-x-120">-</span>140dB to +0dB.
|
---|
696 | Thus, in order to handle full range dynamics, a residue vector may span <span
|
---|
697 | class="cmsy-10x-x-120">-</span>140dB to
|
---|
698 | +140dB entirely within spec. A 280dB range is approximately 48 bits with sign; thus the
|
---|
699 | residue vector must be able to represent a 48 bit range and the dot product must
|
---|
700 | be able to handle an effective 48 bit times 24 bit multiplication. This range may be
|
---|
701 | achieved using large (64 bit or larger) integers, or implementing a movable binary point
|
---|
702 | representation.
|
---|
703 | <!--l. 478--><p class="noindent" ><span class="paragraphHead"><a
|
---|
704 | id="x1-320001.3.2"></a><span
|
---|
705 | class="cmbx-12">inverse monolithic transform (MDCT)</span></span>
|
---|
706 | The audio spectrum is converted back into time domain PCM audio via an inverse Modified
|
---|
707 | Discrete Cosine Transform (MDCT). A detailed description of the MDCT is available in
|
---|
708 | <span class="cite">[<a
|
---|
709 | href="#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 |
|
---|
714 | lapped with surrounding frames using an appropriate window (such as the Vorbis window) before
|
---|
715 | the MDCT can be considered orthogonal.
|
---|
716 | <!--l. 491--><p class="noindent" ><span class="paragraphHead"><a
|
---|
717 | id="x1-330001.3.2"></a><span
|
---|
718 | class="cmbx-12">overlap/add data</span></span>
|
---|
719 | Windowed MDCT output is overlapped and added with the right hand data of the previous
|
---|
720 | window such that the 3/4 point of the previous window is aligned with the 1/4 point of the
|
---|
721 | current window (as illustrated in the window overlap diagram). At this point, the audio data
|
---|
722 | between the center of the previous frame and the center of the current frame is now finished and
|
---|
723 | ready to be returned.
|
---|
724 | <!--l. 500--><p class="noindent" ><span class="paragraphHead"><a
|
---|
725 | id="x1-340001.3.2"></a><span
|
---|
726 | class="cmbx-12">cache right hand data</span></span>
|
---|
727 | The decoder must cache the right hand portion of the current frame to be lapped with the left
|
---|
728 | hand portion of the next frame.
|
---|
729 | <!--l. 506--><p class="noindent" ><span class="paragraphHead"><a
|
---|
730 | id="x1-350001.3.2"></a><span
|
---|
731 | class="cmbx-12">return finished audio data</span></span>
|
---|
732 | The overlapped portion produced from overlapping the previous and current frame data
|
---|
733 | is finished data to be returned by the decoder. This data spans from the center of
|
---|
734 | the previous window to the center of the current window. In the case of same-sized
|
---|
735 | windows, the amount of data to return is one-half block consisting of and only of the
|
---|
736 | overlapped portions. When overlapping a short and long window, much of the returned
|
---|
737 | range is not actually overlap. This does not damage transform orthogonality. Pay
|
---|
738 | attention however to returning the correct data range; the amount of data to be returned
|
---|
739 | is:
|
---|
740 | <!--l. 518--><p class="noindent" >
|
---|
741 | <div class="fancyvrb" id="fancyvrb1"><a
|
---|
742 | id="x1-35002r1"></a><span
|
---|
743 | class="cmr-6">1</span><span
|
---|
744 | class="cmtt-8">window</span><span
|
---|
745 | class="cmtt-8">_blocksize(previous</span><span
|
---|
746 | class="cmtt-8">_window)/4+window</span><span
|
---|
747 | class="cmtt-8">_blocksize(current</span><span
|
---|
748 | class="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 ’prime’ the decode engine. The
|
---|
751 | encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper
|
---|
752 | PCM output offset is ’0’ (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
|
---|
765 | integer fields. Logically, these packets are a bitstream in which bits are coded one-by-one by the
|
---|
766 | encoder and then read one-by-one in the same monotonically increasing order by the decoder.
|
---|
767 | Most 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
|
---|
769 | bitpacking convention specifies the correct mapping of the logical packet bitstream into an actual
|
---|
770 | representation 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 ’byte’ is synonymous with an ’octet’, that is, eight bits.
|
---|
775 | This has not always been the case; seven, ten, eleven and sixteen bit ’bytes’ have been used.
|
---|
776 | For purposes of the bitpacking convention, a byte implies the native, smallest integer
|
---|
777 | storage representation offered by a platform. On modern platforms, this is generally
|
---|
778 | assumed to be eight bits (not necessarily because of the processor but because of the
|
---|
779 | filesystem/memory architecture. Modern filesystems invariably offer bytes as the fundamental
|
---|
780 | atom of storage). A ’word’ is an integer size that is a grouped multiple of this smallest
|
---|
781 | size.
|
---|
782 | <!--l. 31--><p class="noindent" >The most ubiquitous architectures today consider a ’byte’ to be an octet (eight bits) and a word
|
---|
783 | to be a group of two, four or eight bytes (16, 32 or 64 bits). Note however that the Vorbis
|
---|
784 | bitpacking convention is still well defined for any native byte size; Vorbis uses the native
|
---|
785 | bit-width of a given storage system. This document assumes that a byte is one octet for purposes
|
---|
786 | of 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 ’least significant’ bit (LSb), which is the only bit set when the byte is
|
---|
794 | storing the two’s complement integer value +1. A byte’s ’most significant’ bit (MSb) is at the
|
---|
795 | opposite end of the byte. Bits in a byte are numbered from zero at the LSb to <span
|
---|
796 | class="cmmi-12">n </span>(<span
|
---|
797 | class="cmmi-12">n </span>= 7 in an
|
---|
798 | octet) 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
|
---|
803 | common ones are 3-2-1-0 (’big endian’ or ’most significant byte first’ in which the
|
---|
804 | highest-valued byte comes first), 0-1-2-3 (’little endian’ or ’least significant byte first’ in
|
---|
805 | which the lowest value byte comes first) and less commonly 3-1-2-0 and 0-2-1-3 (’mixed
|
---|
806 | endian’).
|
---|
807 | <!--l. 58--><p class="noindent" >The Vorbis bitpacking convention specifies storage and bitstream manipulation at the byte, not
|
---|
808 | word, level, thus host word ordering is of a concern only during optimization when writing high
|
---|
809 | performance code that operates on a word of storage at a time rather than by byte.
|
---|
810 | Logically, bytes are always coded and decoded in order from byte zero through byte
|
---|
811 | <span
|
---|
812 | class="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
|
---|
817 | wide, into packets. These integer fields are not aligned to the boundaries of the byte
|
---|
818 | representation; the next field is written at the bit position at which the previous field
|
---|
819 | ends.
|
---|
820 | <!--l. 74--><p class="noindent" >The encoder logically packs integers by writing the LSb of a binary integer to the logical
|
---|
821 | bitstream first, followed by next least significant bit, etc, until the requested number of bits
|
---|
822 | have been coded. When packing the bits into bytes, the encoder begins by placing
|
---|
823 | the LSb of the integer to be written into the least significant unused bit position of
|
---|
824 | the destination byte, followed by the next-least significant bit of the source integer
|
---|
825 | and so on up to the requested number of bits. When all bits of the destination byte
|
---|
826 | have been filled, encoding continues by zeroing all bits of the next byte and writing
|
---|
827 | the next bit into the bit position 0 of that byte. Decoding follows the same process
|
---|
828 |
|
---|
829 |
|
---|
830 |
|
---|
831 | as encoding, but by reading bits from the byte stream and reassembling them into
|
---|
832 | integers.
|
---|
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
|
---|
837 | given decode context. That is, the three bit binary pattern ’b111’ can be taken to represent
|
---|
838 | either ’seven’ as an unsigned integer, or ’-1’ as a signed, two’s complement integer. The
|
---|
839 | encoder and decoder are responsible for knowing if fields are to be treated as signed or
|
---|
840 | unsigned.
|
---|
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 ’12’ [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
|
---|
848 | class="cmr-6">1</span><span
|
---|
849 | class="cmtt-8"> </span><span
|
---|
850 | class="cmtt-8"> </span><span
|
---|
851 | class="cmtt-8"> </span><span
|
---|
852 | class="cmtt-8"> </span><span
|
---|
853 | class="cmtt-8"> </span><span
|
---|
854 | class="cmtt-8"> </span><span
|
---|
855 | class="cmtt-8"> </span><span
|
---|
856 | class="cmtt-8"> </span><span
|
---|
857 | class="cmtt-8"> </span><span
|
---|
858 | class="cmtt-8"> </span><span
|
---|
859 | class="cmtt-8"> </span><span
|
---|
860 | class="cmtt-8"> </span><span
|
---|
861 | class="cmtt-8"> </span><span
|
---|
862 | class="cmtt-8"> |</span><br class="fancyvrb" /><a
|
---|
863 | id="x1-43004r2"></a><span
|
---|
864 | class="cmr-6">2</span><span
|
---|
865 | class="cmtt-8"> </span><span
|
---|
866 | class="cmtt-8"> </span><span
|
---|
867 | class="cmtt-8"> </span><span
|
---|
868 | class="cmtt-8"> </span><span
|
---|
869 | class="cmtt-8"> </span><span
|
---|
870 | class="cmtt-8"> </span><span
|
---|
871 | class="cmtt-8"> </span><span
|
---|
872 | class="cmtt-8"> </span><span
|
---|
873 | class="cmtt-8"> </span><span
|
---|
874 | class="cmtt-8"> </span><span
|
---|
875 | class="cmtt-8"> </span><span
|
---|
876 | class="cmtt-8"> </span><span
|
---|
877 | class="cmtt-8"> </span><span
|
---|
878 | class="cmtt-8"> V</span><br class="fancyvrb" /><a
|
---|
879 | id="x1-43006r3"></a><span
|
---|
880 | class="cmr-6">3</span><br class="fancyvrb" /><a
|
---|
881 | id="x1-43008r4"></a><span
|
---|
882 | class="cmr-6">4</span><span
|
---|
883 | class="cmtt-8"> </span><span
|
---|
884 | class="cmtt-8"> </span><span
|
---|
885 | class="cmtt-8"> </span><span
|
---|
886 | class="cmtt-8"> </span><span
|
---|
887 | class="cmtt-8"> </span><span
|
---|
888 | class="cmtt-8"> </span><span
|
---|
889 | class="cmtt-8"> </span><span
|
---|
890 | class="cmtt-8"> 7</span><span
|
---|
891 | class="cmtt-8"> 6</span><span
|
---|
892 | class="cmtt-8"> 5</span><span
|
---|
893 | class="cmtt-8"> 4</span><span
|
---|
894 | class="cmtt-8"> 3</span><span
|
---|
895 | class="cmtt-8"> 2</span><span
|
---|
896 | class="cmtt-8"> 1</span><span
|
---|
897 | class="cmtt-8"> 0</span><br class="fancyvrb" /><a
|
---|
898 | id="x1-43010r5"></a><span
|
---|
899 | class="cmr-6">5</span><span
|
---|
900 | class="cmtt-8">byte</span><span
|
---|
901 | class="cmtt-8"> 0</span><span
|
---|
902 | class="cmtt-8"> [0</span><span
|
---|
903 | class="cmtt-8"> 0</span><span
|
---|
904 | class="cmtt-8"> 0</span><span
|
---|
905 | class="cmtt-8"> 0</span><span
|
---|
906 | class="cmtt-8"> 1</span><span
|
---|
907 | class="cmtt-8"> 1</span><span
|
---|
908 | class="cmtt-8"> 0</span><span
|
---|
909 | class="cmtt-8"> 0]</span><span
|
---|
910 | class="cmtt-8"> </span><span
|
---|
911 | class="cmtt-8"> <-</span><br class="fancyvrb" /><a
|
---|
912 | id="x1-43012r6"></a><span
|
---|
913 | class="cmr-6">6</span><span
|
---|
914 | class="cmtt-8">byte</span><span
|
---|
915 | class="cmtt-8"> 1</span><span
|
---|
916 | class="cmtt-8"> [</span><span
|
---|
917 | class="cmtt-8"> </span><span
|
---|
918 | class="cmtt-8"> </span><span
|
---|
919 | class="cmtt-8"> </span><span
|
---|
920 | class="cmtt-8"> </span><span
|
---|
921 | class="cmtt-8"> </span><span
|
---|
922 | class="cmtt-8"> </span><span
|
---|
923 | class="cmtt-8"> </span><span
|
---|
924 | class="cmtt-8"> </span><span
|
---|
925 | class="cmtt-8"> </span><span
|
---|
926 | class="cmtt-8"> </span><span
|
---|
927 | class="cmtt-8"> </span><span
|
---|
928 | class="cmtt-8"> </span><span
|
---|
929 | class="cmtt-8"> </span><span
|
---|
930 | class="cmtt-8"> </span><span
|
---|
931 | class="cmtt-8"> ]</span>
|
---|
932 | <br class="fancyvrb" /><a
|
---|
933 | id="x1-43014r7"></a><span
|
---|
934 | class="cmr-6">7</span><span
|
---|
935 | class="cmtt-8">byte</span><span
|
---|
936 | class="cmtt-8"> 2</span><span
|
---|
937 | class="cmtt-8"> [</span><span
|
---|
938 | class="cmtt-8"> </span><span
|
---|
939 | class="cmtt-8"> </span><span
|
---|
940 | class="cmtt-8"> </span><span
|
---|
941 | class="cmtt-8"> </span><span
|
---|
942 | class="cmtt-8"> </span><span
|
---|
943 | class="cmtt-8"> </span><span
|
---|
944 | class="cmtt-8"> </span><span
|
---|
945 | class="cmtt-8"> </span><span
|
---|
946 | class="cmtt-8"> </span><span
|
---|
947 | class="cmtt-8"> </span><span
|
---|
948 | class="cmtt-8"> </span><span
|
---|
949 | class="cmtt-8"> </span><span
|
---|
950 | class="cmtt-8"> </span><span
|
---|
951 | class="cmtt-8"> </span><span
|
---|
952 | class="cmtt-8"> ]</span><br class="fancyvrb" /><a
|
---|
953 | id="x1-43016r8"></a><span
|
---|
954 | class="cmr-6">8</span><span
|
---|
955 | class="cmtt-8">byte</span><span
|
---|
956 | class="cmtt-8"> 3</span><span
|
---|
957 | class="cmtt-8"> [</span><span
|
---|
958 | class="cmtt-8"> </span><span
|
---|
959 | class="cmtt-8"> </span><span
|
---|
960 | class="cmtt-8"> </span><span
|
---|
961 | class="cmtt-8"> </span><span
|
---|
962 | class="cmtt-8"> </span><span
|
---|
963 | class="cmtt-8"> </span><span
|
---|
964 | class="cmtt-8"> </span><span
|
---|
965 | class="cmtt-8"> </span><span
|
---|
966 | class="cmtt-8"> </span><span
|
---|
967 | class="cmtt-8"> </span><span
|
---|
968 | class="cmtt-8"> </span><span
|
---|
969 | class="cmtt-8"> </span><span
|
---|
970 | class="cmtt-8"> </span><span
|
---|
971 | class="cmtt-8"> </span><span
|
---|
972 | class="cmtt-8"> ]</span><br class="fancyvrb" /><a
|
---|
973 | id="x1-43018r9"></a><span
|
---|
974 | class="cmr-6">9</span><span
|
---|
975 | class="cmtt-8"> </span><span
|
---|
976 | class="cmtt-8"> </span><span
|
---|
977 | class="cmtt-8"> </span><span
|
---|
978 | class="cmtt-8"> </span><span
|
---|
979 | class="cmtt-8"> </span><span
|
---|
980 | class="cmtt-8"> </span><span
|
---|
981 | class="cmtt-8"> </span><span
|
---|
982 | class="cmtt-8"> </span><span
|
---|
983 | class="cmtt-8"> </span><span
|
---|
984 | class="cmtt-8"> </span><span
|
---|
985 | class="cmtt-8"> </span><span
|
---|
986 | class="cmtt-8"> </span><span
|
---|
987 | class="cmtt-8"> ...</span><br class="fancyvrb" /><a
|
---|
988 | id="x1-43020r10"></a><span
|
---|
989 | class="cmr-6">10</span><span
|
---|
990 | class="cmtt-8">byte</span><span
|
---|
991 | class="cmtt-8"> n</span><span
|
---|
992 | class="cmtt-8"> [</span><span
|
---|
993 | class="cmtt-8"> </span><span
|
---|
994 | class="cmtt-8"> </span><span
|
---|
995 | class="cmtt-8"> </span><span
|
---|
996 | class="cmtt-8"> </span><span
|
---|
997 | class="cmtt-8"> </span><span
|
---|
998 | class="cmtt-8"> </span><span
|
---|
999 | class="cmtt-8"> </span><span
|
---|
1000 | class="cmtt-8"> </span><span
|
---|
1001 | class="cmtt-8"> </span><span
|
---|
1002 | class="cmtt-8"> </span><span
|
---|
1003 | class="cmtt-8"> </span><span
|
---|
1004 | class="cmtt-8"> </span><span
|
---|
1005 | class="cmtt-8"> </span><span
|
---|
1006 | class="cmtt-8"> </span><span
|
---|
1007 | class="cmtt-8"> ]</span><span
|
---|
1008 | class="cmtt-8"> </span><span
|
---|
1009 | class="cmtt-8"> bytestream</span><span
|
---|
1010 | class="cmtt-8"> length</span><span
|
---|
1011 | class="cmtt-8"> ==</span><span
|
---|
1012 | class="cmtt-8"> 1</span><span
|
---|
1013 | class="cmtt-8"> byte</span><br class="fancyvrb" /><a
|
---|
1014 | id="x1-43022r11"></a><span
|
---|
1015 | class="cmr-6">11</span></div>
|
---|
1016 | <!--l. 120--><p class="noindent" >Continue by coding the 3 bit integer value ’-1’ [b111]:
|
---|
1017 | <!--l. 122--><p class="noindent" >
|
---|
1018 | <div class="fancyvrb" id="fancyvrb3"><a
|
---|
1019 | id="x1-43024r1"></a><span
|
---|
1020 | class="cmr-6">1</span><span
|
---|
1021 | class="cmtt-8"> </span><span
|
---|
1022 | class="cmtt-8"> </span><span
|
---|
1023 | class="cmtt-8"> </span><span
|
---|
1024 | class="cmtt-8"> </span><span
|
---|
1025 | class="cmtt-8"> </span><span
|
---|
1026 | class="cmtt-8"> </span><span
|
---|
1027 | class="cmtt-8"> </span><span
|
---|
1028 | class="cmtt-8"> |</span><br class="fancyvrb" /><a
|
---|
1029 | id="x1-43026r2"></a><span
|
---|
1030 | class="cmr-6">2</span><span
|
---|
1031 | class="cmtt-8"> </span><span
|
---|
1032 | class="cmtt-8"> </span><span
|
---|
1033 | class="cmtt-8"> </span><span
|
---|
1034 | class="cmtt-8"> </span><span
|
---|
1035 | class="cmtt-8"> </span><span
|
---|
1036 | class="cmtt-8"> </span><span
|
---|
1037 | class="cmtt-8"> </span><span
|
---|
1038 | class="cmtt-8"> V</span><br class="fancyvrb" /><a
|
---|
1039 | id="x1-43028r3"></a><span
|
---|
1040 | class="cmr-6">3</span><br class="fancyvrb" /><a
|
---|
1041 | id="x1-43030r4"></a><span
|
---|
1042 | class="cmr-6">4</span><span
|
---|
1043 | class="cmtt-8"> </span><span
|
---|
1044 | class="cmtt-8"> </span><span
|
---|
1045 | class="cmtt-8"> </span><span
|
---|
1046 | class="cmtt-8"> </span><span
|
---|
1047 | class="cmtt-8"> </span><span
|
---|
1048 | class="cmtt-8"> </span><span
|
---|
1049 | class="cmtt-8"> </span><span
|
---|
1050 | class="cmtt-8"> 7</span><span
|
---|
1051 | class="cmtt-8"> 6</span><span
|
---|
1052 | class="cmtt-8"> 5</span><span
|
---|
1053 | class="cmtt-8"> 4</span><span
|
---|
1054 | class="cmtt-8"> 3</span><span
|
---|
1055 | class="cmtt-8"> 2</span><span
|
---|
1056 | class="cmtt-8"> 1</span><span
|
---|
1057 | class="cmtt-8"> 0</span><br class="fancyvrb" /><a
|
---|
1058 | id="x1-43032r5"></a><span
|
---|
1059 | class="cmr-6">5</span><span
|
---|
1060 | class="cmtt-8">byte</span><span
|
---|
1061 | class="cmtt-8"> 0</span><span
|
---|
1062 | class="cmtt-8"> [0</span><span
|
---|
1063 | class="cmtt-8"> 1</span><span
|
---|
1064 | class="cmtt-8"> 1</span><span
|
---|
1065 | class="cmtt-8"> 1</span><span
|
---|
1066 | class="cmtt-8"> 1</span><span
|
---|
1067 | class="cmtt-8"> 1</span><span
|
---|
1068 | class="cmtt-8"> 0</span><span
|
---|
1069 | class="cmtt-8"> 0]</span><span
|
---|
1070 | class="cmtt-8"> </span><span
|
---|
1071 | class="cmtt-8"> <-</span><br class="fancyvrb" /><a
|
---|
1072 | id="x1-43034r6"></a><span
|
---|
1073 | class="cmr-6">6</span><span
|
---|
1074 | class="cmtt-8">byte</span><span
|
---|
1075 | class="cmtt-8"> 1</span><span
|
---|
1076 | class="cmtt-8"> [</span><span
|
---|
1077 | class="cmtt-8"> </span><span
|
---|
1078 | class="cmtt-8"> </span><span
|
---|
1079 | class="cmtt-8"> </span><span
|
---|
1080 | class="cmtt-8"> </span><span
|
---|
1081 | class="cmtt-8"> </span><span
|
---|
1082 | class="cmtt-8"> </span><span
|
---|
1083 | class="cmtt-8"> </span><span
|
---|
1084 | class="cmtt-8"> </span><span
|
---|
1085 | class="cmtt-8"> </span><span
|
---|
1086 | class="cmtt-8"> </span><span
|
---|
1087 | class="cmtt-8"> </span><span
|
---|
1088 | class="cmtt-8"> </span><span
|
---|
1089 | class="cmtt-8"> </span><span
|
---|
1090 | class="cmtt-8"> </span><span
|
---|
1091 | class="cmtt-8"> ]</span><br class="fancyvrb" /><a
|
---|
1092 | id="x1-43036r7"></a><span
|
---|
1093 | class="cmr-6">7</span><span
|
---|
1094 | class="cmtt-8">byte</span><span
|
---|
1095 | class="cmtt-8"> 2</span><span
|
---|
1096 | class="cmtt-8"> [</span><span
|
---|
1097 | class="cmtt-8"> </span><span
|
---|
1098 | class="cmtt-8"> </span><span
|
---|
1099 | class="cmtt-8"> </span><span
|
---|
1100 | class="cmtt-8"> </span><span
|
---|
1101 | class="cmtt-8"> </span><span
|
---|
1102 | class="cmtt-8"> </span><span
|
---|
1103 | class="cmtt-8"> </span><span
|
---|
1104 | class="cmtt-8"> </span><span
|
---|
1105 | class="cmtt-8"> </span><span
|
---|
1106 | class="cmtt-8"> </span><span
|
---|
1107 | class="cmtt-8"> </span><span
|
---|
1108 | class="cmtt-8"> </span><span
|
---|
1109 | class="cmtt-8"> </span><span
|
---|
1110 | class="cmtt-8"> </span><span
|
---|
1111 | class="cmtt-8"> ]</span>
|
---|
1112 | <br class="fancyvrb" /><a
|
---|
1113 | id="x1-43038r8"></a><span
|
---|
1114 | class="cmr-6">8</span><span
|
---|
1115 | class="cmtt-8">byte</span><span
|
---|
1116 | class="cmtt-8"> 3</span><span
|
---|
1117 | class="cmtt-8"> [</span><span
|
---|
1118 | class="cmtt-8"> </span><span
|
---|
1119 | class="cmtt-8"> </span><span
|
---|
1120 | class="cmtt-8"> </span><span
|
---|
1121 | class="cmtt-8"> </span><span
|
---|
1122 | class="cmtt-8"> </span><span
|
---|
1123 | class="cmtt-8"> </span><span
|
---|
1124 | class="cmtt-8"> </span><span
|
---|
1125 | class="cmtt-8"> </span><span
|
---|
1126 | class="cmtt-8"> </span><span
|
---|
1127 | class="cmtt-8"> </span><span
|
---|
1128 | class="cmtt-8"> </span><span
|
---|
1129 | class="cmtt-8"> </span><span
|
---|
1130 | class="cmtt-8"> </span><span
|
---|
1131 | class="cmtt-8"> </span><span
|
---|
1132 | class="cmtt-8"> ]</span><br class="fancyvrb" /><a
|
---|
1133 | id="x1-43040r9"></a><span
|
---|
1134 | class="cmr-6">9</span><span
|
---|
1135 | class="cmtt-8"> </span><span
|
---|
1136 | class="cmtt-8"> </span><span
|
---|
1137 | class="cmtt-8"> </span><span
|
---|
1138 | class="cmtt-8"> </span><span
|
---|
1139 | class="cmtt-8"> </span><span
|
---|
1140 | class="cmtt-8"> </span><span
|
---|
1141 | class="cmtt-8"> </span><span
|
---|
1142 | class="cmtt-8"> </span><span
|
---|
1143 | class="cmtt-8"> </span><span
|
---|
1144 | class="cmtt-8"> </span><span
|
---|
1145 | class="cmtt-8"> </span><span
|
---|
1146 | class="cmtt-8"> </span><span
|
---|
1147 | class="cmtt-8"> ...</span><br class="fancyvrb" /><a
|
---|
1148 | id="x1-43042r10"></a><span
|
---|
1149 | class="cmr-6">10</span><span
|
---|
1150 | class="cmtt-8">byte</span><span
|
---|
1151 | class="cmtt-8"> n</span><span
|
---|
1152 | class="cmtt-8"> [</span><span
|
---|
1153 | class="cmtt-8"> </span><span
|
---|
1154 | class="cmtt-8"> </span><span
|
---|
1155 | class="cmtt-8"> </span><span
|
---|
1156 | class="cmtt-8"> </span><span
|
---|
1157 | class="cmtt-8"> </span><span
|
---|
1158 | class="cmtt-8"> </span><span
|
---|
1159 | class="cmtt-8"> </span><span
|
---|
1160 | class="cmtt-8"> </span><span
|
---|
1161 | class="cmtt-8"> </span><span
|
---|
1162 | class="cmtt-8"> </span><span
|
---|
1163 | class="cmtt-8"> </span><span
|
---|
1164 | class="cmtt-8"> </span><span
|
---|
1165 | class="cmtt-8"> </span><span
|
---|
1166 | class="cmtt-8"> </span><span
|
---|
1167 | class="cmtt-8"> ]</span><span
|
---|
1168 | class="cmtt-8"> </span><span
|
---|
1169 | class="cmtt-8"> bytestream</span><span
|
---|
1170 | class="cmtt-8"> length</span><span
|
---|
1171 | class="cmtt-8"> ==</span><span
|
---|
1172 | class="cmtt-8"> 1</span><span
|
---|
1173 | class="cmtt-8"> byte</span></div>
|
---|
1174 | <!--l. 136--><p class="noindent" >Continue by coding the 7 bit integer value ’17’ [b0010001]:
|
---|
1175 | <!--l. 138--><p class="noindent" >
|
---|
1176 | <div class="fancyvrb" id="fancyvrb4"><a
|
---|
1177 | id="x1-43044r1"></a><span
|
---|
1178 | class="cmr-6">1</span><span
|
---|
1179 | class="cmtt-8"> </span><span
|
---|
1180 | class="cmtt-8"> </span><span
|
---|
1181 | class="cmtt-8"> </span><span
|
---|
1182 | class="cmtt-8"> </span><span
|
---|
1183 | class="cmtt-8"> </span><span
|
---|
1184 | class="cmtt-8"> </span><span
|
---|
1185 | class="cmtt-8"> </span><span
|
---|
1186 | class="cmtt-8"> </span><span
|
---|
1187 | class="cmtt-8"> </span><span
|
---|
1188 | class="cmtt-8"> |</span><br class="fancyvrb" /><a
|
---|
1189 | id="x1-43046r2"></a><span
|
---|
1190 | class="cmr-6">2</span><span
|
---|
1191 | class="cmtt-8"> </span><span
|
---|
1192 | class="cmtt-8"> </span><span
|
---|
1193 | class="cmtt-8"> </span><span
|
---|
1194 | class="cmtt-8"> </span><span
|
---|
1195 | class="cmtt-8"> </span><span
|
---|
1196 | class="cmtt-8"> </span><span
|
---|
1197 | class="cmtt-8"> </span><span
|
---|
1198 | class="cmtt-8"> </span><span
|
---|
1199 | class="cmtt-8"> </span><span
|
---|
1200 | class="cmtt-8"> V</span><br class="fancyvrb" /><a
|
---|
1201 | id="x1-43048r3"></a><span
|
---|
1202 | class="cmr-6">3</span><br class="fancyvrb" /><a
|
---|
1203 | id="x1-43050r4"></a><span
|
---|
1204 | class="cmr-6">4</span><span
|
---|
1205 | class="cmtt-8"> </span><span
|
---|
1206 | class="cmtt-8"> </span><span
|
---|
1207 | class="cmtt-8"> </span><span
|
---|
1208 | class="cmtt-8"> </span><span
|
---|
1209 | class="cmtt-8"> </span><span
|
---|
1210 | class="cmtt-8"> </span><span
|
---|
1211 | class="cmtt-8"> </span><span
|
---|
1212 | class="cmtt-8"> 7</span><span
|
---|
1213 | class="cmtt-8"> 6</span><span
|
---|
1214 | class="cmtt-8"> 5</span><span
|
---|
1215 | class="cmtt-8"> 4</span><span
|
---|
1216 | class="cmtt-8"> 3</span><span
|
---|
1217 | class="cmtt-8"> 2</span><span
|
---|
1218 | class="cmtt-8"> 1</span><span
|
---|
1219 | class="cmtt-8"> 0</span><br class="fancyvrb" /><a
|
---|
1220 | id="x1-43052r5"></a><span
|
---|
1221 | class="cmr-6">5</span><span
|
---|
1222 | class="cmtt-8">byte</span><span
|
---|
1223 | class="cmtt-8"> 0</span><span
|
---|
1224 | class="cmtt-8"> [1</span><span
|
---|
1225 | class="cmtt-8"> 1</span><span
|
---|
1226 | class="cmtt-8"> 1</span><span
|
---|
1227 | class="cmtt-8"> 1</span><span
|
---|
1228 | class="cmtt-8"> 1</span><span
|
---|
1229 | class="cmtt-8"> 1</span><span
|
---|
1230 | class="cmtt-8"> 0</span><span
|
---|
1231 | class="cmtt-8"> 0]</span><br class="fancyvrb" /><a
|
---|
1232 | id="x1-43054r6"></a><span
|
---|
1233 | class="cmr-6">6</span><span
|
---|
1234 | class="cmtt-8">byte</span><span
|
---|
1235 | class="cmtt-8"> 1</span><span
|
---|
1236 | class="cmtt-8"> [0</span><span
|
---|
1237 | class="cmtt-8"> 0</span><span
|
---|
1238 | class="cmtt-8"> 0</span><span
|
---|
1239 | class="cmtt-8"> 0</span><span
|
---|
1240 | class="cmtt-8"> 1</span><span
|
---|
1241 | class="cmtt-8"> 0</span><span
|
---|
1242 | class="cmtt-8"> 0</span><span
|
---|
1243 | class="cmtt-8"> 0]</span><span
|
---|
1244 | class="cmtt-8"> </span><span
|
---|
1245 | class="cmtt-8"> <-</span><br class="fancyvrb" /><a
|
---|
1246 | id="x1-43056r7"></a><span
|
---|
1247 | class="cmr-6">7</span><span
|
---|
1248 | class="cmtt-8">byte</span><span
|
---|
1249 | class="cmtt-8"> 2</span><span
|
---|
1250 | class="cmtt-8"> [</span><span
|
---|
1251 | class="cmtt-8"> </span><span
|
---|
1252 | class="cmtt-8"> </span><span
|
---|
1253 | class="cmtt-8"> </span><span
|
---|
1254 | class="cmtt-8"> </span><span
|
---|
1255 | class="cmtt-8"> </span><span
|
---|
1256 | class="cmtt-8"> </span><span
|
---|
1257 | class="cmtt-8"> </span><span
|
---|
1258 | class="cmtt-8"> </span><span
|
---|
1259 | class="cmtt-8"> </span><span
|
---|
1260 | class="cmtt-8"> </span><span
|
---|
1261 | class="cmtt-8"> </span><span
|
---|
1262 | class="cmtt-8"> </span><span
|
---|
1263 | class="cmtt-8"> </span><span
|
---|
1264 | class="cmtt-8"> </span><span
|
---|
1265 | class="cmtt-8"> ]</span>
|
---|
1266 | <br class="fancyvrb" /><a
|
---|
1267 | id="x1-43058r8"></a><span
|
---|
1268 | class="cmr-6">8</span><span
|
---|
1269 | class="cmtt-8">byte</span><span
|
---|
1270 | class="cmtt-8"> 3</span><span
|
---|
1271 | class="cmtt-8"> [</span><span
|
---|
1272 | class="cmtt-8"> </span><span
|
---|
1273 | class="cmtt-8"> </span><span
|
---|
1274 | class="cmtt-8"> </span><span
|
---|
1275 | class="cmtt-8"> </span><span
|
---|
1276 | class="cmtt-8"> </span><span
|
---|
1277 | class="cmtt-8"> </span><span
|
---|
1278 | class="cmtt-8"> </span><span
|
---|
1279 | class="cmtt-8"> </span><span
|
---|
1280 | class="cmtt-8"> </span><span
|
---|
1281 | class="cmtt-8"> </span><span
|
---|
1282 | class="cmtt-8"> </span><span
|
---|
1283 | class="cmtt-8"> </span><span
|
---|
1284 | class="cmtt-8"> </span><span
|
---|
1285 | class="cmtt-8"> </span><span
|
---|
1286 | class="cmtt-8"> ]</span><br class="fancyvrb" /><a
|
---|
1287 | id="x1-43060r9"></a><span
|
---|
1288 | class="cmr-6">9</span><span
|
---|
1289 | class="cmtt-8"> </span><span
|
---|
1290 | class="cmtt-8"> </span><span
|
---|
1291 | class="cmtt-8"> </span><span
|
---|
1292 | class="cmtt-8"> </span><span
|
---|
1293 | class="cmtt-8"> </span><span
|
---|
1294 | class="cmtt-8"> </span><span
|
---|
1295 | class="cmtt-8"> </span><span
|
---|
1296 | class="cmtt-8"> </span><span
|
---|
1297 | class="cmtt-8"> </span><span
|
---|
1298 | class="cmtt-8"> </span><span
|
---|
1299 | class="cmtt-8"> </span><span
|
---|
1300 | class="cmtt-8"> </span><span
|
---|
1301 | class="cmtt-8"> ...</span><br class="fancyvrb" /><a
|
---|
1302 | id="x1-43062r10"></a><span
|
---|
1303 | class="cmr-6">10</span><span
|
---|
1304 | class="cmtt-8">byte</span><span
|
---|
1305 | class="cmtt-8"> n</span><span
|
---|
1306 | class="cmtt-8"> [</span><span
|
---|
1307 | class="cmtt-8"> </span><span
|
---|
1308 | class="cmtt-8"> </span><span
|
---|
1309 | class="cmtt-8"> </span><span
|
---|
1310 | class="cmtt-8"> </span><span
|
---|
1311 | class="cmtt-8"> </span><span
|
---|
1312 | class="cmtt-8"> </span><span
|
---|
1313 | class="cmtt-8"> </span><span
|
---|
1314 | class="cmtt-8"> </span><span
|
---|
1315 | class="cmtt-8"> </span><span
|
---|
1316 | class="cmtt-8"> </span><span
|
---|
1317 | class="cmtt-8"> </span><span
|
---|
1318 | class="cmtt-8"> </span><span
|
---|
1319 | class="cmtt-8"> </span><span
|
---|
1320 | class="cmtt-8"> </span><span
|
---|
1321 | class="cmtt-8"> ]</span><span
|
---|
1322 | class="cmtt-8"> </span><span
|
---|
1323 | class="cmtt-8"> bytestream</span><span
|
---|
1324 | class="cmtt-8"> length</span><span
|
---|
1325 | class="cmtt-8"> ==</span><span
|
---|
1326 | class="cmtt-8"> 2</span><span
|
---|
1327 | class="cmtt-8"> bytes</span><br class="fancyvrb" /><a
|
---|
1328 | id="x1-43064r11"></a><span
|
---|
1329 | class="cmr-6">11</span><span
|
---|
1330 | class="cmtt-8"> </span><span
|
---|
1331 | class="cmtt-8"> </span><span
|
---|
1332 | class="cmtt-8"> </span><span
|
---|
1333 | class="cmtt-8"> </span><span
|
---|
1334 | class="cmtt-8"> </span><span
|
---|
1335 | class="cmtt-8"> </span><span
|
---|
1336 | class="cmtt-8"> </span><span
|
---|
1337 | class="cmtt-8"> </span><span
|
---|
1338 | class="cmtt-8"> </span><span
|
---|
1339 | class="cmtt-8"> </span><span
|
---|
1340 | class="cmtt-8"> </span><span
|
---|
1341 | class="cmtt-8"> </span><span
|
---|
1342 | class="cmtt-8"> </span><span
|
---|
1343 | class="cmtt-8"> </span><span
|
---|
1344 | class="cmtt-8"> </span><span
|
---|
1345 | class="cmtt-8"> </span><span
|
---|
1346 | class="cmtt-8"> </span><span
|
---|
1347 | class="cmtt-8"> </span><span
|
---|
1348 | class="cmtt-8"> </span><span
|
---|
1349 | class="cmtt-8"> </span><span
|
---|
1350 | class="cmtt-8"> </span><span
|
---|
1351 | class="cmtt-8"> </span><span
|
---|
1352 | class="cmtt-8"> </span><span
|
---|
1353 | class="cmtt-8"> </span><span
|
---|
1354 | class="cmtt-8"> </span><span
|
---|
1355 | class="cmtt-8"> bit</span><span
|
---|
1356 | class="cmtt-8"> cursor</span><span
|
---|
1357 | class="cmtt-8"> ==</span><span
|
---|
1358 | class="cmtt-8"> 6</span></div>
|
---|
1359 | <!--l. 153--><p class="noindent" >Continue by coding the 13 bit integer value ’6969’ [b110 11001110 01]:
|
---|
1360 | <!--l. 155--><p class="noindent" >
|
---|
1361 | <div class="fancyvrb" id="fancyvrb5"><a
|
---|
1362 | id="x1-43066r1"></a><span
|
---|
1363 | class="cmr-6">1</span><span
|
---|
1364 | class="cmtt-8"> </span><span
|
---|
1365 | class="cmtt-8"> </span><span
|
---|
1366 | class="cmtt-8"> </span><span
|
---|
1367 | class="cmtt-8"> </span><span
|
---|
1368 | class="cmtt-8"> </span><span
|
---|
1369 | class="cmtt-8"> </span><span
|
---|
1370 | class="cmtt-8"> </span><span
|
---|
1371 | class="cmtt-8"> </span><span
|
---|
1372 | class="cmtt-8"> </span><span
|
---|
1373 | class="cmtt-8"> </span><span
|
---|
1374 | class="cmtt-8"> </span><span
|
---|
1375 | class="cmtt-8"> </span><span
|
---|
1376 | class="cmtt-8"> </span><span
|
---|
1377 | class="cmtt-8"> </span><span
|
---|
1378 | class="cmtt-8"> </span><span
|
---|
1379 | class="cmtt-8"> |</span><br class="fancyvrb" /><a
|
---|
1380 | id="x1-43068r2"></a><span
|
---|
1381 | class="cmr-6">2</span><span
|
---|
1382 | class="cmtt-8"> </span><span
|
---|
1383 | class="cmtt-8"> </span><span
|
---|
1384 | class="cmtt-8"> </span><span
|
---|
1385 | class="cmtt-8"> </span><span
|
---|
1386 | class="cmtt-8"> </span><span
|
---|
1387 | class="cmtt-8"> </span><span
|
---|
1388 | class="cmtt-8"> </span><span
|
---|
1389 | class="cmtt-8"> </span><span
|
---|
1390 | class="cmtt-8"> </span><span
|
---|
1391 | class="cmtt-8"> </span><span
|
---|
1392 | class="cmtt-8"> </span><span
|
---|
1393 | class="cmtt-8"> </span><span
|
---|
1394 | class="cmtt-8"> </span><span
|
---|
1395 | class="cmtt-8"> </span><span
|
---|
1396 | class="cmtt-8"> </span><span
|
---|
1397 | class="cmtt-8"> V</span><br class="fancyvrb" /><a
|
---|
1398 | id="x1-43070r3"></a><span
|
---|
1399 | class="cmr-6">3</span><br class="fancyvrb" /><a
|
---|
1400 | id="x1-43072r4"></a><span
|
---|
1401 | class="cmr-6">4</span><span
|
---|
1402 | class="cmtt-8"> </span><span
|
---|
1403 | class="cmtt-8"> </span><span
|
---|
1404 | class="cmtt-8"> </span><span
|
---|
1405 | class="cmtt-8"> </span><span
|
---|
1406 | class="cmtt-8"> </span><span
|
---|
1407 | class="cmtt-8"> </span><span
|
---|
1408 | class="cmtt-8"> </span><span
|
---|
1409 | class="cmtt-8"> 7</span><span
|
---|
1410 | class="cmtt-8"> 6</span><span
|
---|
1411 | class="cmtt-8"> 5</span><span
|
---|
1412 | class="cmtt-8"> 4</span><span
|
---|
1413 | class="cmtt-8"> 3</span><span
|
---|
1414 | class="cmtt-8"> 2</span><span
|
---|
1415 | class="cmtt-8"> 1</span><span
|
---|
1416 | class="cmtt-8"> 0</span><br class="fancyvrb" /><a
|
---|
1417 | id="x1-43074r5"></a><span
|
---|
1418 | class="cmr-6">5</span><span
|
---|
1419 | class="cmtt-8">byte</span><span
|
---|
1420 | class="cmtt-8"> 0</span><span
|
---|
1421 | class="cmtt-8"> [1</span><span
|
---|
1422 | class="cmtt-8"> 1</span><span
|
---|
1423 | class="cmtt-8"> 1</span><span
|
---|
1424 | class="cmtt-8"> 1</span><span
|
---|
1425 | class="cmtt-8"> 1</span><span
|
---|
1426 | class="cmtt-8"> 1</span><span
|
---|
1427 | class="cmtt-8"> 0</span><span
|
---|
1428 | class="cmtt-8"> 0]</span><br class="fancyvrb" /><a
|
---|
1429 | id="x1-43076r6"></a><span
|
---|
1430 | class="cmr-6">6</span><span
|
---|
1431 | class="cmtt-8">byte</span><span
|
---|
1432 | class="cmtt-8"> 1</span><span
|
---|
1433 | class="cmtt-8"> [0</span><span
|
---|
1434 | class="cmtt-8"> 1</span><span
|
---|
1435 | class="cmtt-8"> 0</span><span
|
---|
1436 | class="cmtt-8"> 0</span><span
|
---|
1437 | class="cmtt-8"> 1</span><span
|
---|
1438 | class="cmtt-8"> 0</span><span
|
---|
1439 | class="cmtt-8"> 0</span><span
|
---|
1440 | class="cmtt-8"> 0]</span>
|
---|
1441 | <br class="fancyvrb" /><a
|
---|
1442 | id="x1-43078r7"></a><span
|
---|
1443 | class="cmr-6">7</span><span
|
---|
1444 | class="cmtt-8">byte</span><span
|
---|
1445 | class="cmtt-8"> 2</span><span
|
---|
1446 | class="cmtt-8"> [1</span><span
|
---|
1447 | class="cmtt-8"> 1</span><span
|
---|
1448 | class="cmtt-8"> 0</span><span
|
---|
1449 | class="cmtt-8"> 0</span><span
|
---|
1450 | class="cmtt-8"> 1</span><span
|
---|
1451 | class="cmtt-8"> 1</span><span
|
---|
1452 | class="cmtt-8"> 1</span><span
|
---|
1453 | class="cmtt-8"> 0]</span><br class="fancyvrb" /><a
|
---|
1454 | id="x1-43080r8"></a><span
|
---|
1455 | class="cmr-6">8</span><span
|
---|
1456 | class="cmtt-8">byte</span><span
|
---|
1457 | class="cmtt-8"> 3</span><span
|
---|
1458 | class="cmtt-8"> [0</span><span
|
---|
1459 | class="cmtt-8"> 0</span><span
|
---|
1460 | class="cmtt-8"> 0</span><span
|
---|
1461 | class="cmtt-8"> 0</span><span
|
---|
1462 | class="cmtt-8"> 0</span><span
|
---|
1463 | class="cmtt-8"> 1</span><span
|
---|
1464 | class="cmtt-8"> 1</span><span
|
---|
1465 | class="cmtt-8"> 0]</span><span
|
---|
1466 | class="cmtt-8"> </span><span
|
---|
1467 | class="cmtt-8"> <-</span><br class="fancyvrb" /><a
|
---|
1468 | id="x1-43082r9"></a><span
|
---|
1469 | class="cmr-6">9</span><span
|
---|
1470 | class="cmtt-8"> </span><span
|
---|
1471 | class="cmtt-8"> </span><span
|
---|
1472 | class="cmtt-8"> </span><span
|
---|
1473 | class="cmtt-8"> </span><span
|
---|
1474 | class="cmtt-8"> </span><span
|
---|
1475 | class="cmtt-8"> </span><span
|
---|
1476 | class="cmtt-8"> </span><span
|
---|
1477 | class="cmtt-8"> </span><span
|
---|
1478 | class="cmtt-8"> </span><span
|
---|
1479 | class="cmtt-8"> </span><span
|
---|
1480 | class="cmtt-8"> </span><span
|
---|
1481 | class="cmtt-8"> </span><span
|
---|
1482 | class="cmtt-8"> ...</span><br class="fancyvrb" /><a
|
---|
1483 | id="x1-43084r10"></a><span
|
---|
1484 | class="cmr-6">10</span><span
|
---|
1485 | class="cmtt-8">byte</span><span
|
---|
1486 | class="cmtt-8"> n</span><span
|
---|
1487 | class="cmtt-8"> [</span><span
|
---|
1488 | class="cmtt-8"> </span><span
|
---|
1489 | class="cmtt-8"> </span><span
|
---|
1490 | class="cmtt-8"> </span><span
|
---|
1491 | class="cmtt-8"> </span><span
|
---|
1492 | class="cmtt-8"> </span><span
|
---|
1493 | class="cmtt-8"> </span><span
|
---|
1494 | class="cmtt-8"> </span><span
|
---|
1495 | class="cmtt-8"> </span><span
|
---|
1496 | class="cmtt-8"> </span><span
|
---|
1497 | class="cmtt-8"> </span><span
|
---|
1498 | class="cmtt-8"> </span><span
|
---|
1499 | class="cmtt-8"> </span><span
|
---|
1500 | class="cmtt-8"> </span><span
|
---|
1501 | class="cmtt-8"> </span><span
|
---|
1502 | class="cmtt-8"> ]</span><span
|
---|
1503 | class="cmtt-8"> </span><span
|
---|
1504 | class="cmtt-8"> bytestream</span><span
|
---|
1505 | class="cmtt-8"> length</span><span
|
---|
1506 | class="cmtt-8"> ==</span><span
|
---|
1507 | class="cmtt-8"> 4</span><span
|
---|
1508 | class="cmtt-8"> bytes</span><br class="fancyvrb" /><a
|
---|
1509 | id="x1-43086r11"></a><span
|
---|
1510 | class="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
|
---|
1521 | class="cmr-6">1</span><span
|
---|
1522 | class="cmtt-8"> </span><span
|
---|
1523 | class="cmtt-8"> </span><span
|
---|
1524 | class="cmtt-8"> </span><span
|
---|
1525 | class="cmtt-8"> </span><span
|
---|
1526 | class="cmtt-8"> </span><span
|
---|
1527 | class="cmtt-8"> </span><span
|
---|
1528 | class="cmtt-8"> </span><span
|
---|
1529 | class="cmtt-8"> </span><span
|
---|
1530 | class="cmtt-8"> </span><span
|
---|
1531 | class="cmtt-8"> </span><span
|
---|
1532 | class="cmtt-8"> </span><span
|
---|
1533 | class="cmtt-8"> </span><span
|
---|
1534 | class="cmtt-8"> </span><span
|
---|
1535 | class="cmtt-8"> </span><span
|
---|
1536 | class="cmtt-8"> </span><span
|
---|
1537 | class="cmtt-8"> </span><span
|
---|
1538 | class="cmtt-8"> </span><span
|
---|
1539 | class="cmtt-8"> </span><span
|
---|
1540 | class="cmtt-8"> </span><span
|
---|
1541 | class="cmtt-8"> </span><span
|
---|
1542 | class="cmtt-8"> </span><span
|
---|
1543 | class="cmtt-8"> |</span><br class="fancyvrb" /><a
|
---|
1544 | id="x1-44004r2"></a><span
|
---|
1545 | class="cmr-6">2</span><span
|
---|
1546 | class="cmtt-8"> </span><span
|
---|
1547 | class="cmtt-8"> </span><span
|
---|
1548 | class="cmtt-8"> </span><span
|
---|
1549 | class="cmtt-8"> </span><span
|
---|
1550 | class="cmtt-8"> </span><span
|
---|
1551 | class="cmtt-8"> </span><span
|
---|
1552 | class="cmtt-8"> </span><span
|
---|
1553 | class="cmtt-8"> </span><span
|
---|
1554 | class="cmtt-8"> </span><span
|
---|
1555 | class="cmtt-8"> </span><span
|
---|
1556 | class="cmtt-8"> </span><span
|
---|
1557 | class="cmtt-8"> </span><span
|
---|
1558 | class="cmtt-8"> </span><span
|
---|
1559 | class="cmtt-8"> </span><span
|
---|
1560 | class="cmtt-8"> </span><span
|
---|
1561 | class="cmtt-8"> </span><span
|
---|
1562 | class="cmtt-8"> </span><span
|
---|
1563 | class="cmtt-8"> </span><span
|
---|
1564 | class="cmtt-8"> </span><span
|
---|
1565 | class="cmtt-8"> </span><span
|
---|
1566 | class="cmtt-8"> </span><span
|
---|
1567 | class="cmtt-8"> V</span><br class="fancyvrb" /><a
|
---|
1568 | id="x1-44006r3"></a><span
|
---|
1569 | class="cmr-6">3</span><br class="fancyvrb" /><a
|
---|
1570 | id="x1-44008r4"></a><span
|
---|
1571 | class="cmr-6">4</span><span
|
---|
1572 | class="cmtt-8"> </span><span
|
---|
1573 | class="cmtt-8"> </span><span
|
---|
1574 | class="cmtt-8"> </span><span
|
---|
1575 | class="cmtt-8"> </span><span
|
---|
1576 | class="cmtt-8"> </span><span
|
---|
1577 | class="cmtt-8"> </span><span
|
---|
1578 | class="cmtt-8"> </span><span
|
---|
1579 | class="cmtt-8"> 7</span><span
|
---|
1580 | class="cmtt-8"> 6</span><span
|
---|
1581 | class="cmtt-8"> 5</span><span
|
---|
1582 | class="cmtt-8"> 4</span><span
|
---|
1583 | class="cmtt-8"> 3</span><span
|
---|
1584 | class="cmtt-8"> 2</span><span
|
---|
1585 | class="cmtt-8"> 1</span><span
|
---|
1586 | class="cmtt-8"> 0</span><br class="fancyvrb" /><a
|
---|
1587 | id="x1-44010r5"></a><span
|
---|
1588 | class="cmr-6">5</span><span
|
---|
1589 | class="cmtt-8">byte</span><span
|
---|
1590 | class="cmtt-8"> 0</span><span
|
---|
1591 | class="cmtt-8"> [1</span><span
|
---|
1592 | class="cmtt-8"> 1</span><span
|
---|
1593 | class="cmtt-8"> 1</span><span
|
---|
1594 | class="cmtt-8"> 1</span><span
|
---|
1595 | class="cmtt-8"> 1</span><span
|
---|
1596 | class="cmtt-8"> 1</span><span
|
---|
1597 | class="cmtt-8"> 0</span><span
|
---|
1598 | class="cmtt-8"> 0]</span><span
|
---|
1599 | class="cmtt-8"> </span><span
|
---|
1600 | class="cmtt-8"> <-</span><br class="fancyvrb" /><a
|
---|
1601 | id="x1-44012r6"></a><span
|
---|
1602 | class="cmr-6">6</span><span
|
---|
1603 | class="cmtt-8">byte</span><span
|
---|
1604 | class="cmtt-8"> 1</span><span
|
---|
1605 | class="cmtt-8"> [0</span><span
|
---|
1606 | class="cmtt-8"> 1</span><span
|
---|
1607 | class="cmtt-8"> 0</span><span
|
---|
1608 | class="cmtt-8"> 0</span><span
|
---|
1609 | class="cmtt-8"> 1</span><span
|
---|
1610 | class="cmtt-8"> 0</span><span
|
---|
1611 | class="cmtt-8"> 0</span><span
|
---|
1612 | class="cmtt-8"> 0]</span>
|
---|
1613 | <br class="fancyvrb" /><a
|
---|
1614 | id="x1-44014r7"></a><span
|
---|
1615 | class="cmr-6">7</span><span
|
---|
1616 | class="cmtt-8">byte</span><span
|
---|
1617 | class="cmtt-8"> 2</span><span
|
---|
1618 | class="cmtt-8"> [1</span><span
|
---|
1619 | class="cmtt-8"> 1</span><span
|
---|
1620 | class="cmtt-8"> 0</span><span
|
---|
1621 | class="cmtt-8"> 0</span><span
|
---|
1622 | class="cmtt-8"> 1</span><span
|
---|
1623 | class="cmtt-8"> 1</span><span
|
---|
1624 | class="cmtt-8"> 1</span><span
|
---|
1625 | class="cmtt-8"> 0]</span><br class="fancyvrb" /><a
|
---|
1626 | id="x1-44016r8"></a><span
|
---|
1627 | class="cmr-6">8</span><span
|
---|
1628 | class="cmtt-8">byte</span><span
|
---|
1629 | class="cmtt-8"> 3</span><span
|
---|
1630 | class="cmtt-8"> [0</span><span
|
---|
1631 | class="cmtt-8"> 0</span><span
|
---|
1632 | class="cmtt-8"> 0</span><span
|
---|
1633 | class="cmtt-8"> 0</span><span
|
---|
1634 | class="cmtt-8"> 0</span><span
|
---|
1635 | class="cmtt-8"> 1</span><span
|
---|
1636 | class="cmtt-8"> 1</span><span
|
---|
1637 | class="cmtt-8"> 0]</span><span
|
---|
1638 | class="cmtt-8"> </span><span
|
---|
1639 | class="cmtt-8"> bytestream</span><span
|
---|
1640 | class="cmtt-8"> length</span><span
|
---|
1641 | class="cmtt-8"> ==</span><span
|
---|
1642 | class="cmtt-8"> 4</span><span
|
---|
1643 | class="cmtt-8"> bytes</span><br class="fancyvrb" /><a
|
---|
1644 | id="x1-44018r9"></a><span
|
---|
1645 | class="cmr-6">9</span></div>
|
---|
1646 | <!--l. 189--><p class="noindent" >We read two, two-bit integer fields, resulting in the returned numbers ’b00’ and ’b11’. Two things
|
---|
1647 | are 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 ’b11’. This value may be interpreted
|
---|
1654 | either as the unsigned value ’3’, or the signed value ’-1’. 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
|
---|
1660 | embedded into a larger byte-aligned container structure, such as an Ogg transport bitstream.
|
---|
1661 | Externally, each bytestream (encoded bitstream) must begin and end on a byte boundary. Often,
|
---|
1662 | the encoded bitstream is not an integer number of bytes, and so there is unused (uncoded) space
|
---|
1663 | in 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,
|
---|
1665 | should 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 ’end-of-packet’ condition.
|
---|
1667 | End-of-packet is not to be considered an error; it is merely a state indicating that there is
|
---|
1668 | insufficient remaining data to fulfill the desired read size. Vorbis uses truncated packets as a
|
---|
1669 |
|
---|
1670 |
|
---|
1671 |
|
---|
1672 | normal mode of operation, and as such, decoders must handle reading past the end of a packet as
|
---|
1673 | a typical mode of operation. Any further read operations after an ’end-of-packet’ condition shall
|
---|
1674 | also return ’end-of-packet’.
|
---|
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 ’0’ and does not increment the stream cursor.
|
---|
1679 | Reading to the end of the packet (but not past, such that an ’end-of-packet’ condition has not
|
---|
1680 | triggered) and then reading a zero bit integer shall succeed, returning 0, and not trigger an
|
---|
1681 | end-of-packet condition. Reading a zero-bit-wide integer after a previous read sets ’end-of-packet’
|
---|
1682 | shall also fail with ’end-of-packet’.
|
---|
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
|
---|
1695 | probability model, instead packing all entropy decoding configuration, VQ and Huffman, into the
|
---|
1696 | bitstream itself in the third header, the codec setup header. This packed configuration consists of
|
---|
1697 | multiple ’codebooks’, each containing a specific Huffman-equivalent representation for decoding
|
---|
1698 | compressed codewords as well as an optional lookup table of output vector values to which a
|
---|
1699 | decoded Huffman value is applied as an offset, generating the final decoded output corresponding
|
---|
1700 | to 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
|
---|
1705 | and the codewords they decode are unrolled from a packet as a series of arbitrary-width values
|
---|
1706 | read from the stream according to <a
|
---|
1707 | href="#x1-360002">section 2</a>, “<a
|
---|
1708 | href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>”.
|
---|
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’s native byte width is
|
---|
1713 | eight bits. This is not universally true; see <a
|
---|
1714 | href="#x1-360002">section 2</a>, “<a
|
---|
1715 | href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>” for discussion
|
---|
1716 | relating 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
|
---|
1727 | class="cmr-6">1</span><span
|
---|
1728 | class="cmtt-8">byte</span><span
|
---|
1729 | class="cmtt-8"> 0:</span><span
|
---|
1730 | class="cmtt-8"> [</span><span
|
---|
1731 | class="cmtt-8"> 0</span><span
|
---|
1732 | class="cmtt-8"> 1</span><span
|
---|
1733 | class="cmtt-8"> 0</span><span
|
---|
1734 | class="cmtt-8"> 0</span><span
|
---|
1735 | class="cmtt-8"> 0</span><span
|
---|
1736 | class="cmtt-8"> 0</span><span
|
---|
1737 | class="cmtt-8"> 1</span><span
|
---|
1738 | class="cmtt-8"> 0</span><span
|
---|
1739 | class="cmtt-8"> ]</span><span
|
---|
1740 | class="cmtt-8"> (0x42)</span><br class="fancyvrb" /><a
|
---|
1741 | id="x1-51004r2"></a><span
|
---|
1742 | class="cmr-6">2</span><span
|
---|
1743 | class="cmtt-8">byte</span><span
|
---|
1744 | class="cmtt-8"> 1:</span><span
|
---|
1745 | class="cmtt-8"> [</span><span
|
---|
1746 | class="cmtt-8"> 0</span><span
|
---|
1747 | class="cmtt-8"> 1</span><span
|
---|
1748 | class="cmtt-8"> 0</span><span
|
---|
1749 | class="cmtt-8"> 0</span><span
|
---|
1750 | class="cmtt-8"> 0</span><span
|
---|
1751 | class="cmtt-8"> 0</span><span
|
---|
1752 | class="cmtt-8"> 1</span><span
|
---|
1753 | class="cmtt-8"> 1</span><span
|
---|
1754 | class="cmtt-8"> ]</span><span
|
---|
1755 | class="cmtt-8"> (0x43)</span><br class="fancyvrb" /><a
|
---|
1756 | id="x1-51006r3"></a><span
|
---|
1757 | class="cmr-6">3</span><span
|
---|
1758 | class="cmtt-8">byte</span><span
|
---|
1759 | class="cmtt-8"> 2:</span><span
|
---|
1760 | class="cmtt-8"> [</span><span
|
---|
1761 | class="cmtt-8"> 0</span><span
|
---|
1762 | class="cmtt-8"> 1</span><span
|
---|
1763 | class="cmtt-8"> 0</span><span
|
---|
1764 | class="cmtt-8"> 1</span><span
|
---|
1765 | class="cmtt-8"> 0</span><span
|
---|
1766 | class="cmtt-8"> 1</span><span
|
---|
1767 | class="cmtt-8"> 1</span><span
|
---|
1768 | class="cmtt-8"> 0</span><span
|
---|
1769 | class="cmtt-8"> ]</span><span
|
---|
1770 | class="cmtt-8"> (0x56)</span></div>
|
---|
1771 | <!--l. 43--><p class="noindent" >16 bit <span
|
---|
1772 | class="cmtt-12">[codebook</span><span
|
---|
1773 | class="cmtt-12">_dimensions] </span>and 24 bit <span
|
---|
1774 | class="cmtt-12">[codebook</span><span
|
---|
1775 | class="cmtt-12">_entries] </span>fields:
|
---|
1776 | <!--l. 45--><p class="noindent" >
|
---|
1777 | <div class="fancyvrb" id="fancyvrb8"><a
|
---|
1778 | id="x1-51008r1"></a><span
|
---|
1779 | class="cmr-6">1</span><br class="fancyvrb" /><a
|
---|
1780 | id="x1-51010r2"></a><span
|
---|
1781 | class="cmr-6">2</span><span
|
---|
1782 | class="cmtt-8">byte</span><span
|
---|
1783 | class="cmtt-8"> 3:</span><span
|
---|
1784 | class="cmtt-8"> [</span><span
|
---|
1785 | class="cmtt-8"> X</span><span
|
---|
1786 | class="cmtt-8"> X</span><span
|
---|
1787 | class="cmtt-8"> X</span><span
|
---|
1788 | class="cmtt-8"> X</span><span
|
---|
1789 | class="cmtt-8"> X</span><span
|
---|
1790 | class="cmtt-8"> X</span><span
|
---|
1791 | class="cmtt-8"> X</span><span
|
---|
1792 | class="cmtt-8"> X</span><span
|
---|
1793 | class="cmtt-8"> ]</span><br class="fancyvrb" /><a
|
---|
1794 | id="x1-51012r3"></a><span
|
---|
1795 | class="cmr-6">3</span><span
|
---|
1796 | class="cmtt-8">byte</span><span
|
---|
1797 | class="cmtt-8"> 4:</span><span
|
---|
1798 | class="cmtt-8"> [</span><span
|
---|
1799 | class="cmtt-8"> X</span><span
|
---|
1800 | class="cmtt-8"> X</span><span
|
---|
1801 | class="cmtt-8"> X</span><span
|
---|
1802 | class="cmtt-8"> X</span><span
|
---|
1803 | class="cmtt-8"> X</span><span
|
---|
1804 | class="cmtt-8"> X</span><span
|
---|
1805 | class="cmtt-8"> X</span><span
|
---|
1806 | class="cmtt-8"> X</span><span
|
---|
1807 | class="cmtt-8"> ]</span><span
|
---|
1808 | class="cmtt-8"> [codebook</span><span
|
---|
1809 | class="cmtt-8">_dimensions]</span><span
|
---|
1810 | class="cmtt-8"> (16</span><span
|
---|
1811 | class="cmtt-8"> bit</span><span
|
---|
1812 | class="cmtt-8"> unsigned)</span><br class="fancyvrb" /><a
|
---|
1813 | id="x1-51014r4"></a><span
|
---|
1814 | class="cmr-6">4</span><br class="fancyvrb" /><a
|
---|
1815 | id="x1-51016r5"></a><span
|
---|
1816 | class="cmr-6">5</span><span
|
---|
1817 | class="cmtt-8">byte</span><span
|
---|
1818 | class="cmtt-8"> 5:</span><span
|
---|
1819 | class="cmtt-8"> [</span><span
|
---|
1820 | class="cmtt-8"> X</span><span
|
---|
1821 | class="cmtt-8"> X</span><span
|
---|
1822 | class="cmtt-8"> X</span><span
|
---|
1823 | class="cmtt-8"> X</span><span
|
---|
1824 | class="cmtt-8"> X</span><span
|
---|
1825 | class="cmtt-8"> X</span><span
|
---|
1826 | class="cmtt-8"> X</span><span
|
---|
1827 | class="cmtt-8"> X</span><span
|
---|
1828 | class="cmtt-8"> ]</span>
|
---|
1829 | <br class="fancyvrb" /><a
|
---|
1830 | id="x1-51018r6"></a><span
|
---|
1831 | class="cmr-6">6</span><span
|
---|
1832 | class="cmtt-8">byte</span><span
|
---|
1833 | class="cmtt-8"> 6:</span><span
|
---|
1834 | class="cmtt-8"> [</span><span
|
---|
1835 | class="cmtt-8"> X</span><span
|
---|
1836 | class="cmtt-8"> X</span><span
|
---|
1837 | class="cmtt-8"> X</span><span
|
---|
1838 | class="cmtt-8"> X</span><span
|
---|
1839 | class="cmtt-8"> X</span><span
|
---|
1840 | class="cmtt-8"> X</span><span
|
---|
1841 | class="cmtt-8"> X</span><span
|
---|
1842 | class="cmtt-8"> X</span><span
|
---|
1843 | class="cmtt-8"> ]</span><br class="fancyvrb" /><a
|
---|
1844 | id="x1-51020r7"></a><span
|
---|
1845 | class="cmr-6">7</span><span
|
---|
1846 | class="cmtt-8">byte</span><span
|
---|
1847 | class="cmtt-8"> 7:</span><span
|
---|
1848 | class="cmtt-8"> [</span><span
|
---|
1849 | class="cmtt-8"> X</span><span
|
---|
1850 | class="cmtt-8"> X</span><span
|
---|
1851 | class="cmtt-8"> X</span><span
|
---|
1852 | class="cmtt-8"> X</span><span
|
---|
1853 | class="cmtt-8"> X</span><span
|
---|
1854 | class="cmtt-8"> X</span><span
|
---|
1855 | class="cmtt-8"> X</span><span
|
---|
1856 | class="cmtt-8"> X</span><span
|
---|
1857 | class="cmtt-8"> ]</span><span
|
---|
1858 | class="cmtt-8"> [codebook</span><span
|
---|
1859 | class="cmtt-8">_entries]</span><span
|
---|
1860 | class="cmtt-8"> (24</span><span
|
---|
1861 | class="cmtt-8"> bit</span><span
|
---|
1862 | class="cmtt-8"> unsigned)</span><br class="fancyvrb" /><a
|
---|
1863 | id="x1-51022r8"></a><span
|
---|
1864 | class="cmr-6">8</span></div>
|
---|
1865 | <!--l. 56--><p class="noindent" >Next is the <span
|
---|
1866 | class="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
|
---|
1870 | class="cmr-6">1</span><br class="fancyvrb" /><a
|
---|
1871 | id="x1-51026r2"></a><span
|
---|
1872 | class="cmr-6">2</span><span
|
---|
1873 | class="cmtt-8">byte</span><span
|
---|
1874 | class="cmtt-8"> 8:</span><span
|
---|
1875 | class="cmtt-8"> [</span><span
|
---|
1876 | class="cmtt-8"> </span><span
|
---|
1877 | class="cmtt-8"> </span><span
|
---|
1878 | class="cmtt-8"> </span><span
|
---|
1879 | class="cmtt-8"> </span><span
|
---|
1880 | class="cmtt-8"> </span><span
|
---|
1881 | class="cmtt-8"> </span><span
|
---|
1882 | class="cmtt-8"> </span><span
|
---|
1883 | class="cmtt-8"> </span><span
|
---|
1884 | class="cmtt-8"> </span><span
|
---|
1885 | class="cmtt-8"> </span><span
|
---|
1886 | class="cmtt-8"> </span><span
|
---|
1887 | class="cmtt-8"> </span><span
|
---|
1888 | class="cmtt-8"> </span><span
|
---|
1889 | class="cmtt-8"> </span><span
|
---|
1890 | class="cmtt-8"> X</span><span
|
---|
1891 | class="cmtt-8"> ]</span><span
|
---|
1892 | class="cmtt-8"> [ordered]</span><span
|
---|
1893 | class="cmtt-8"> (1</span><span
|
---|
1894 | class="cmtt-8"> bit)</span><br class="fancyvrb" /><a
|
---|
1895 | id="x1-51028r3"></a><span
|
---|
1896 | class="cmr-6">3</span></div>
|
---|
1897 | <!--l. 64--><p class="noindent" >Each entry, numbering a total of <span
|
---|
1898 | class="cmtt-12">[codebook</span><span
|
---|
1899 | class="cmtt-12">_entries]</span>, is assigned a codeword length.
|
---|
1900 | We now read the list of codeword lengths and store these lengths in the array
|
---|
1901 | <span
|
---|
1902 | class="cmtt-12">[codebook</span><span
|
---|
1903 | class="cmtt-12">_codeword</span><span
|
---|
1904 | class="cmtt-12">_lengths]</span>. Decode of lengths is according to whether the <span
|
---|
1905 | class="cmtt-12">[ordered] </span>flag
|
---|
1906 | is set or unset.
|
---|
1907 | <ul class="itemize1">
|
---|
1908 | <li class="itemize">If the <span
|
---|
1909 | class="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
|
---|
1912 | class="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
|
---|
1918 | class="cmr-6">1</span><span
|
---|
1919 | class="cmtt-8">byte</span><span
|
---|
1920 | class="cmtt-8"> 8:</span><span
|
---|
1921 | class="cmtt-8"> [</span><span
|
---|
1922 | class="cmtt-8"> </span><span
|
---|
1923 | class="cmtt-8"> </span><span
|
---|
1924 | class="cmtt-8"> </span><span
|
---|
1925 | class="cmtt-8"> </span><span
|
---|
1926 | class="cmtt-8"> </span><span
|
---|
1927 | class="cmtt-8"> </span><span
|
---|
1928 | class="cmtt-8"> </span><span
|
---|
1929 | class="cmtt-8"> </span><span
|
---|
1930 | class="cmtt-8"> </span><span
|
---|
1931 | class="cmtt-8"> </span><span
|
---|
1932 | class="cmtt-8"> </span><span
|
---|
1933 | class="cmtt-8"> </span><span
|
---|
1934 | class="cmtt-8"> X</span><span
|
---|
1935 | class="cmtt-8"> 1</span><span
|
---|
1936 | class="cmtt-8"> ]</span><span
|
---|
1937 | class="cmtt-8"> [sparse]</span><span
|
---|
1938 | class="cmtt-8"> flag</span><span
|
---|
1939 | class="cmtt-8"> (1</span><span
|
---|
1940 | class="cmtt-8"> bit)</span></div>
|
---|
1941 | <!--l. 85--><p class="noindent" >The decoder now performs for each of the <span
|
---|
1942 | class="cmtt-12">[codebook</span><span
|
---|
1943 | class="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
|
---|
1947 | class="cmr-6">1</span><br class="fancyvrb" /><a
|
---|
1948 | id="x1-51034r2"></a><span
|
---|
1949 | class="cmr-6">2</span><span
|
---|
1950 | class="cmtt-8"> </span><span
|
---|
1951 | class="cmtt-8"> 1)</span><span
|
---|
1952 | class="cmtt-8"> if([sparse]</span><span
|
---|
1953 | class="cmtt-8"> is</span><span
|
---|
1954 | class="cmtt-8"> set)</span><span
|
---|
1955 | class="cmtt-8"> </span><span
|
---|
1956 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
1957 | id="x1-51036r3"></a><span
|
---|
1958 | class="cmr-6">3</span><br class="fancyvrb" /><a
|
---|
1959 | id="x1-51038r4"></a><span
|
---|
1960 | class="cmr-6">4</span><span
|
---|
1961 | class="cmtt-8"> </span><span
|
---|
1962 | class="cmtt-8"> </span><span
|
---|
1963 | class="cmtt-8"> </span><span
|
---|
1964 | class="cmtt-8"> </span><span
|
---|
1965 | class="cmtt-8"> </span><span
|
---|
1966 | class="cmtt-8"> </span><span
|
---|
1967 | class="cmtt-8"> </span><span
|
---|
1968 | class="cmtt-8"> </span><span
|
---|
1969 | class="cmtt-8"> 2)</span><span
|
---|
1970 | class="cmtt-8"> [flag]</span><span
|
---|
1971 | class="cmtt-8"> =</span><span
|
---|
1972 | class="cmtt-8"> read</span><span
|
---|
1973 | class="cmtt-8"> one</span><span
|
---|
1974 | class="cmtt-8"> bit;</span><br class="fancyvrb" /><a
|
---|
1975 | id="x1-51040r5"></a><span
|
---|
1976 | class="cmr-6">5</span><span
|
---|
1977 | class="cmtt-8"> </span><span
|
---|
1978 | class="cmtt-8"> </span><span
|
---|
1979 | class="cmtt-8"> </span><span
|
---|
1980 | class="cmtt-8"> </span><span
|
---|
1981 | class="cmtt-8"> </span><span
|
---|
1982 | class="cmtt-8"> </span><span
|
---|
1983 | class="cmtt-8"> </span><span
|
---|
1984 | class="cmtt-8"> </span><span
|
---|
1985 | class="cmtt-8"> 3)</span><span
|
---|
1986 | class="cmtt-8"> if([flag]</span><span
|
---|
1987 | class="cmtt-8"> is</span><span
|
---|
1988 | class="cmtt-8"> set)</span><span
|
---|
1989 | class="cmtt-8"> </span><span
|
---|
1990 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
1991 | id="x1-51042r6"></a><span
|
---|
1992 | class="cmr-6">6</span>
|
---|
1993 | <br class="fancyvrb" /><a
|
---|
1994 | id="x1-51044r7"></a><span
|
---|
1995 | class="cmr-6">7</span><span
|
---|
1996 | class="cmtt-8"> </span><span
|
---|
1997 | class="cmtt-8"> </span><span
|
---|
1998 | class="cmtt-8"> </span><span
|
---|
1999 | class="cmtt-8"> </span><span
|
---|
2000 | class="cmtt-8"> </span><span
|
---|
2001 | class="cmtt-8"> </span><span
|
---|
2002 | class="cmtt-8"> </span><span
|
---|
2003 | class="cmtt-8"> </span><span
|
---|
2004 | class="cmtt-8"> </span><span
|
---|
2005 | class="cmtt-8"> </span><span
|
---|
2006 | class="cmtt-8"> </span><span
|
---|
2007 | class="cmtt-8"> </span><span
|
---|
2008 | class="cmtt-8"> </span><span
|
---|
2009 | class="cmtt-8"> 4)</span><span
|
---|
2010 | class="cmtt-8"> [length]</span><span
|
---|
2011 | class="cmtt-8"> =</span><span
|
---|
2012 | class="cmtt-8"> read</span><span
|
---|
2013 | class="cmtt-8"> a</span><span
|
---|
2014 | class="cmtt-8"> five</span><span
|
---|
2015 | class="cmtt-8"> bit</span><span
|
---|
2016 | class="cmtt-8"> unsigned</span><span
|
---|
2017 | class="cmtt-8"> integer;</span><br class="fancyvrb" /><a
|
---|
2018 | id="x1-51046r8"></a><span
|
---|
2019 | class="cmr-6">8</span><span
|
---|
2020 | class="cmtt-8"> </span><span
|
---|
2021 | class="cmtt-8"> </span><span
|
---|
2022 | class="cmtt-8"> </span><span
|
---|
2023 | class="cmtt-8"> </span><span
|
---|
2024 | class="cmtt-8"> </span><span
|
---|
2025 | class="cmtt-8"> </span><span
|
---|
2026 | class="cmtt-8"> </span><span
|
---|
2027 | class="cmtt-8"> </span><span
|
---|
2028 | class="cmtt-8"> </span><span
|
---|
2029 | class="cmtt-8"> </span><span
|
---|
2030 | class="cmtt-8"> </span><span
|
---|
2031 | class="cmtt-8"> </span><span
|
---|
2032 | class="cmtt-8"> </span><span
|
---|
2033 | class="cmtt-8"> 5)</span><span
|
---|
2034 | class="cmtt-8"> codeword</span><span
|
---|
2035 | class="cmtt-8"> length</span><span
|
---|
2036 | class="cmtt-8"> for</span><span
|
---|
2037 | class="cmtt-8"> this</span><span
|
---|
2038 | class="cmtt-8"> entry</span><span
|
---|
2039 | class="cmtt-8"> is</span><span
|
---|
2040 | class="cmtt-8"> [length]+1;</span><br class="fancyvrb" /><a
|
---|
2041 | id="x1-51048r9"></a><span
|
---|
2042 | class="cmr-6">9</span>
|
---|
2043 | <br class="fancyvrb" /><a
|
---|
2044 | id="x1-51050r10"></a><span
|
---|
2045 | class="cmr-6">10</span><span
|
---|
2046 | class="cmtt-8"> </span><span
|
---|
2047 | class="cmtt-8"> </span><span
|
---|
2048 | class="cmtt-8"> </span><span
|
---|
2049 | class="cmtt-8"> </span><span
|
---|
2050 | class="cmtt-8"> </span><span
|
---|
2051 | class="cmtt-8"> </span><span
|
---|
2052 | class="cmtt-8"> </span><span
|
---|
2053 | class="cmtt-8"> </span><span
|
---|
2054 | class="cmtt-8"> </span><span
|
---|
2055 | class="cmtt-8"> </span><span
|
---|
2056 | class="cmtt-8"> </span><span
|
---|
2057 | class="cmtt-8"> </span><span
|
---|
2058 | class="cmsy-8">}</span><span
|
---|
2059 | class="cmtt-8"> else</span><span
|
---|
2060 | class="cmtt-8"> </span><span
|
---|
2061 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
2062 | id="x1-51052r11"></a><span
|
---|
2063 | class="cmr-6">11</span><br class="fancyvrb" /><a
|
---|
2064 | id="x1-51054r12"></a><span
|
---|
2065 | class="cmr-6">12</span><span
|
---|
2066 | class="cmtt-8"> </span><span
|
---|
2067 | class="cmtt-8"> </span><span
|
---|
2068 | class="cmtt-8"> </span><span
|
---|
2069 | class="cmtt-8"> </span><span
|
---|
2070 | class="cmtt-8"> </span><span
|
---|
2071 | class="cmtt-8"> </span><span
|
---|
2072 | class="cmtt-8"> </span><span
|
---|
2073 | class="cmtt-8"> </span><span
|
---|
2074 | class="cmtt-8"> </span><span
|
---|
2075 | class="cmtt-8"> </span><span
|
---|
2076 | class="cmtt-8"> </span><span
|
---|
2077 | class="cmtt-8"> </span><span
|
---|
2078 | class="cmtt-8"> </span><span
|
---|
2079 | class="cmtt-8"> 6)</span><span
|
---|
2080 | class="cmtt-8"> this</span><span
|
---|
2081 | class="cmtt-8"> entry</span><span
|
---|
2082 | class="cmtt-8"> is</span><span
|
---|
2083 | class="cmtt-8"> unused.</span><span
|
---|
2084 | class="cmtt-8"> </span><span
|
---|
2085 | class="cmtt-8"> mark</span><span
|
---|
2086 | class="cmtt-8"> it</span><span
|
---|
2087 | class="cmtt-8"> as</span><span
|
---|
2088 | class="cmtt-8"> such.</span><br class="fancyvrb" /><a
|
---|
2089 | id="x1-51056r13"></a><span
|
---|
2090 | class="cmr-6">13</span><br class="fancyvrb" /><a
|
---|
2091 | id="x1-51058r14"></a><span
|
---|
2092 | class="cmr-6">14</span><span
|
---|
2093 | class="cmtt-8"> </span><span
|
---|
2094 | class="cmtt-8"> </span><span
|
---|
2095 | class="cmtt-8"> </span><span
|
---|
2096 | class="cmtt-8"> </span><span
|
---|
2097 | class="cmtt-8"> </span><span
|
---|
2098 | class="cmtt-8"> </span><span
|
---|
2099 | class="cmtt-8"> </span><span
|
---|
2100 | class="cmtt-8"> </span><span
|
---|
2101 | class="cmtt-8"> </span><span
|
---|
2102 | class="cmtt-8"> </span><span
|
---|
2103 | class="cmtt-8"> </span><span
|
---|
2104 | class="cmtt-8"> </span><span
|
---|
2105 | class="cmsy-8">}</span><br class="fancyvrb" /><a
|
---|
2106 | id="x1-51060r15"></a><span
|
---|
2107 | class="cmr-6">15</span><br class="fancyvrb" /><a
|
---|
2108 | id="x1-51062r16"></a><span
|
---|
2109 | class="cmr-6">16</span><span
|
---|
2110 | class="cmtt-8"> </span><span
|
---|
2111 | class="cmtt-8"> </span><span
|
---|
2112 | class="cmtt-8"> </span><span
|
---|
2113 | class="cmtt-8"> </span><span
|
---|
2114 | class="cmtt-8"> </span><span
|
---|
2115 | class="cmsy-8">}</span><span
|
---|
2116 | class="cmtt-8"> else</span><span
|
---|
2117 | class="cmtt-8"> the</span><span
|
---|
2118 | class="cmtt-8"> sparse</span><span
|
---|
2119 | class="cmtt-8"> flag</span><span
|
---|
2120 | class="cmtt-8"> is</span><span
|
---|
2121 | class="cmtt-8"> not</span><span
|
---|
2122 | class="cmtt-8"> set</span><span
|
---|
2123 | class="cmtt-8"> </span><span
|
---|
2124 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
2125 | id="x1-51064r17"></a><span
|
---|
2126 | class="cmr-6">17</span>
|
---|
2127 | <br class="fancyvrb" /><a
|
---|
2128 | id="x1-51066r18"></a><span
|
---|
2129 | class="cmr-6">18</span><span
|
---|
2130 | class="cmtt-8"> </span><span
|
---|
2131 | class="cmtt-8"> </span><span
|
---|
2132 | class="cmtt-8"> </span><span
|
---|
2133 | class="cmtt-8"> </span><span
|
---|
2134 | class="cmtt-8"> </span><span
|
---|
2135 | class="cmtt-8"> </span><span
|
---|
2136 | class="cmtt-8"> </span><span
|
---|
2137 | class="cmtt-8"> 7)</span><span
|
---|
2138 | class="cmtt-8"> [length]</span><span
|
---|
2139 | class="cmtt-8"> =</span><span
|
---|
2140 | class="cmtt-8"> read</span><span
|
---|
2141 | class="cmtt-8"> a</span><span
|
---|
2142 | class="cmtt-8"> five</span><span
|
---|
2143 | class="cmtt-8"> bit</span><span
|
---|
2144 | class="cmtt-8"> unsigned</span><span
|
---|
2145 | class="cmtt-8"> integer;</span><br class="fancyvrb" /><a
|
---|
2146 | id="x1-51068r19"></a><span
|
---|
2147 | class="cmr-6">19</span><span
|
---|
2148 | class="cmtt-8"> </span><span
|
---|
2149 | class="cmtt-8"> </span><span
|
---|
2150 | class="cmtt-8"> </span><span
|
---|
2151 | class="cmtt-8"> </span><span
|
---|
2152 | class="cmtt-8"> </span><span
|
---|
2153 | class="cmtt-8"> </span><span
|
---|
2154 | class="cmtt-8"> </span><span
|
---|
2155 | class="cmtt-8"> 8)</span><span
|
---|
2156 | class="cmtt-8"> the</span><span
|
---|
2157 | class="cmtt-8"> codeword</span><span
|
---|
2158 | class="cmtt-8"> length</span><span
|
---|
2159 | class="cmtt-8"> for</span><span
|
---|
2160 | class="cmtt-8"> this</span><span
|
---|
2161 | class="cmtt-8"> entry</span><span
|
---|
2162 | class="cmtt-8"> is</span><span
|
---|
2163 | class="cmtt-8"> [length]+1;</span><br class="fancyvrb" /><a
|
---|
2164 | id="x1-51070r20"></a><span
|
---|
2165 | class="cmr-6">20</span><br class="fancyvrb" /><a
|
---|
2166 | id="x1-51072r21"></a><span
|
---|
2167 | class="cmr-6">21</span><span
|
---|
2168 | class="cmtt-8"> </span><span
|
---|
2169 | class="cmtt-8"> </span><span
|
---|
2170 | class="cmtt-8"> </span><span
|
---|
2171 | class="cmtt-8"> </span><span
|
---|
2172 | class="cmtt-8"> </span><span
|
---|
2173 | class="cmsy-8">}</span><br class="fancyvrb" /><a
|
---|
2174 | id="x1-51074r22"></a><span
|
---|
2175 | class="cmr-6">22</span></div>
|
---|
2176 |
|
---|
2177 |
|
---|
2178 |
|
---|
2179 | </li>
|
---|
2180 | <li class="itemize">If the <span
|
---|
2181 | class="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
|
---|
2188 | class="cmr-6">1</span><span
|
---|
2189 | class="cmtt-8"> </span><span
|
---|
2190 | class="cmtt-8"> 1)</span><span
|
---|
2191 | class="cmtt-8"> [current</span><span
|
---|
2192 | class="cmtt-8">_entry]</span><span
|
---|
2193 | class="cmtt-8"> =</span><span
|
---|
2194 | class="cmtt-8"> 0;</span><br class="fancyvrb" /><a
|
---|
2195 | id="x1-51078r2"></a><span
|
---|
2196 | class="cmr-6">2</span><span
|
---|
2197 | class="cmtt-8"> </span><span
|
---|
2198 | class="cmtt-8"> 2)</span><span
|
---|
2199 | class="cmtt-8"> [current</span><span
|
---|
2200 | class="cmtt-8">_length]</span><span
|
---|
2201 | class="cmtt-8"> =</span><span
|
---|
2202 | class="cmtt-8"> read</span><span
|
---|
2203 | class="cmtt-8"> a</span><span
|
---|
2204 | class="cmtt-8"> five</span><span
|
---|
2205 | class="cmtt-8"> bit</span><span
|
---|
2206 | class="cmtt-8"> unsigned</span><span
|
---|
2207 | class="cmtt-8"> integer</span><span
|
---|
2208 | class="cmtt-8"> and</span><span
|
---|
2209 | class="cmtt-8"> add</span><span
|
---|
2210 | class="cmtt-8"> 1;</span>
|
---|
2211 | <br class="fancyvrb" /><a
|
---|
2212 | id="x1-51080r3"></a><span
|
---|
2213 | class="cmr-6">3</span><span
|
---|
2214 | class="cmtt-8"> </span><span
|
---|
2215 | class="cmtt-8"> 3)</span><span
|
---|
2216 | class="cmtt-8"> [number]</span><span
|
---|
2217 | class="cmtt-8"> =</span><span
|
---|
2218 | class="cmtt-8"> read</span><span
|
---|
2219 | class="cmtt-8"> </span><a
|
---|
2220 | href="#x1-1190009.2.1"><span
|
---|
2221 | class="cmtt-8">ilog</span></a><span
|
---|
2222 | class="cmtt-8">([codebook</span><span
|
---|
2223 | class="cmtt-8">_entries]</span><span
|
---|
2224 | class="cmtt-8"> -</span><span
|
---|
2225 | class="cmtt-8"> [current</span><span
|
---|
2226 | class="cmtt-8">_entry])</span><span
|
---|
2227 | class="cmtt-8"> bits</span><span
|
---|
2228 | class="cmtt-8"> as</span><span
|
---|
2229 | class="cmtt-8"> an</span><span
|
---|
2230 | class="cmtt-8"> unsigned</span><span
|
---|
2231 | class="cmtt-8"> integer</span>
|
---|
2232 | <br class="fancyvrb" /><a
|
---|
2233 | id="x1-51082r4"></a><span
|
---|
2234 | class="cmr-6">4</span><span
|
---|
2235 | class="cmtt-8"> </span><span
|
---|
2236 | class="cmtt-8"> 4)</span><span
|
---|
2237 | class="cmtt-8"> set</span><span
|
---|
2238 | class="cmtt-8"> the</span><span
|
---|
2239 | class="cmtt-8"> entries</span><span
|
---|
2240 | class="cmtt-8"> [current</span><span
|
---|
2241 | class="cmtt-8">_entry]</span><span
|
---|
2242 | class="cmtt-8"> through</span><span
|
---|
2243 | class="cmtt-8"> [current</span><span
|
---|
2244 | class="cmtt-8">_entry]+[number]-1,</span><span
|
---|
2245 | class="cmtt-8"> inclusive,</span>
|
---|
2246 | <br class="fancyvrb" /><a
|
---|
2247 | id="x1-51084r5"></a><span
|
---|
2248 | class="cmr-6">5</span><span
|
---|
2249 | class="cmtt-8"> </span><span
|
---|
2250 | class="cmtt-8"> </span><span
|
---|
2251 | class="cmtt-8"> </span><span
|
---|
2252 | class="cmtt-8"> of</span><span
|
---|
2253 | class="cmtt-8"> the</span><span
|
---|
2254 | class="cmtt-8"> [codebook</span><span
|
---|
2255 | class="cmtt-8">_codeword</span><span
|
---|
2256 | class="cmtt-8">_lengths]</span><span
|
---|
2257 | class="cmtt-8"> array</span><span
|
---|
2258 | class="cmtt-8"> to</span><span
|
---|
2259 | class="cmtt-8"> [current</span><span
|
---|
2260 | class="cmtt-8">_length]</span><br class="fancyvrb" /><a
|
---|
2261 | id="x1-51086r6"></a><span
|
---|
2262 | class="cmr-6">6</span><span
|
---|
2263 | class="cmtt-8"> </span><span
|
---|
2264 | class="cmtt-8"> 5)</span><span
|
---|
2265 | class="cmtt-8"> set</span><span
|
---|
2266 | class="cmtt-8"> [current</span><span
|
---|
2267 | class="cmtt-8">_entry]</span><span
|
---|
2268 | class="cmtt-8"> to</span><span
|
---|
2269 | class="cmtt-8"> [number]</span><span
|
---|
2270 | class="cmtt-8"> +</span><span
|
---|
2271 | class="cmtt-8"> [current</span><span
|
---|
2272 | class="cmtt-8">_entry]</span>
|
---|
2273 | <br class="fancyvrb" /><a
|
---|
2274 | id="x1-51088r7"></a><span
|
---|
2275 | class="cmr-6">7</span><span
|
---|
2276 | class="cmtt-8"> </span><span
|
---|
2277 | class="cmtt-8"> 6)</span><span
|
---|
2278 | class="cmtt-8"> increment</span><span
|
---|
2279 | class="cmtt-8"> [current</span><span
|
---|
2280 | class="cmtt-8">_length]</span><span
|
---|
2281 | class="cmtt-8"> by</span><span
|
---|
2282 | class="cmtt-8"> 1</span><br class="fancyvrb" /><a
|
---|
2283 | id="x1-51090r8"></a><span
|
---|
2284 | class="cmr-6">8</span><span
|
---|
2285 | class="cmtt-8"> </span><span
|
---|
2286 | class="cmtt-8"> 7)</span><span
|
---|
2287 | class="cmtt-8"> if</span><span
|
---|
2288 | class="cmtt-8"> [current</span><span
|
---|
2289 | class="cmtt-8">_entry]</span><span
|
---|
2290 | class="cmtt-8"> is</span><span
|
---|
2291 | class="cmtt-8"> greater</span><span
|
---|
2292 | class="cmtt-8"> than</span><span
|
---|
2293 | class="cmtt-8"> [codebook</span><span
|
---|
2294 | class="cmtt-8">_entries]</span><span
|
---|
2295 | class="cmtt-8"> ERROR</span><span
|
---|
2296 | class="cmtt-8"> CONDITION;</span>
|
---|
2297 | <br class="fancyvrb" /><a
|
---|
2298 | id="x1-51092r9"></a><span
|
---|
2299 | class="cmr-6">9</span><span
|
---|
2300 | class="cmtt-8"> </span><span
|
---|
2301 | class="cmtt-8"> </span><span
|
---|
2302 | class="cmtt-8"> </span><span
|
---|
2303 | class="cmtt-8"> the</span><span
|
---|
2304 | class="cmtt-8"> decoder</span><span
|
---|
2305 | class="cmtt-8"> will</span><span
|
---|
2306 | class="cmtt-8"> not</span><span
|
---|
2307 | class="cmtt-8"> be</span><span
|
---|
2308 | class="cmtt-8"> able</span><span
|
---|
2309 | class="cmtt-8"> to</span><span
|
---|
2310 | class="cmtt-8"> read</span><span
|
---|
2311 | class="cmtt-8"> this</span><span
|
---|
2312 | class="cmtt-8"> stream.</span><br class="fancyvrb" /><a
|
---|
2313 | id="x1-51094r10"></a><span
|
---|
2314 | class="cmr-6">10</span><span
|
---|
2315 | class="cmtt-8"> </span><span
|
---|
2316 | class="cmtt-8"> 8)</span><span
|
---|
2317 | class="cmtt-8"> if</span><span
|
---|
2318 | class="cmtt-8"> [current</span><span
|
---|
2319 | class="cmtt-8">_entry]</span><span
|
---|
2320 | class="cmtt-8"> is</span><span
|
---|
2321 | class="cmtt-8"> less</span><span
|
---|
2322 | class="cmtt-8"> than</span><span
|
---|
2323 | class="cmtt-8"> [codebook</span><span
|
---|
2324 | class="cmtt-8">_entries],</span><span
|
---|
2325 | class="cmtt-8"> repeat</span><span
|
---|
2326 | class="cmtt-8"> process</span><span
|
---|
2327 | class="cmtt-8"> starting</span><span
|
---|
2328 | class="cmtt-8"> at</span><span
|
---|
2329 | class="cmtt-8"> 3)</span>
|
---|
2330 | <br class="fancyvrb" /><a
|
---|
2331 | id="x1-51096r11"></a><span
|
---|
2332 | class="cmr-6">11</span><span
|
---|
2333 | class="cmtt-8"> </span><span
|
---|
2334 | class="cmtt-8"> 9)</span><span
|
---|
2335 | class="cmtt-8"> 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
|
---|
2338 | I supports three lookup types:
|
---|
2339 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
2340 | 1. </dt><dd
|
---|
2341 | class="enumerate-enumitem">No lookup
|
---|
2342 | </dd><dt class="enumerate-enumitem">
|
---|
2343 | 2. </dt><dd
|
---|
2344 | class="enumerate-enumitem">Implicitly populated value mapping (lattice VQ)
|
---|
2345 | </dd><dt class="enumerate-enumitem">
|
---|
2346 | 3. </dt><dd
|
---|
2347 | class="enumerate-enumitem">Explicitly populated value mapping (tessellated or ’foam’ 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
|
---|
2351 | class="cmr-6">1</span><span
|
---|
2352 | class="cmtt-8"> </span><span
|
---|
2353 | class="cmtt-8"> 1)</span><span
|
---|
2354 | class="cmtt-8"> [codebook</span><span
|
---|
2355 | class="cmtt-8">_lookup</span><span
|
---|
2356 | class="cmtt-8">_type]</span><span
|
---|
2357 | class="cmtt-8"> =</span><span
|
---|
2358 | class="cmtt-8"> read</span><span
|
---|
2359 | class="cmtt-8"> four</span><span
|
---|
2360 | class="cmtt-8"> bits</span><span
|
---|
2361 | class="cmtt-8"> as</span><span
|
---|
2362 | class="cmtt-8"> an</span><span
|
---|
2363 | class="cmtt-8"> unsigned</span><span
|
---|
2364 | class="cmtt-8"> integer</span></div>
|
---|
2365 | <!--l. 153--><p class="noindent" >Codebook decode precedes according to <span
|
---|
2366 | class="cmtt-12">[codebook</span><span
|
---|
2367 | class="cmtt-12">_lookup</span><span
|
---|
2368 | class="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
|
---|
2375 | class="cmtt-12">[codebook</span><span
|
---|
2376 | class="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
|
---|
2383 | class="cmr-6">1</span><span
|
---|
2384 | class="cmtt-8"> </span><span
|
---|
2385 | class="cmtt-8"> 1)</span><span
|
---|
2386 | class="cmtt-8"> [codebook</span><span
|
---|
2387 | class="cmtt-8">_minimum</span><span
|
---|
2388 | class="cmtt-8">_value]</span><span
|
---|
2389 | class="cmtt-8"> =</span><span
|
---|
2390 | class="cmtt-8"> </span><a
|
---|
2391 | href="#x1-1200009.2.2"><span
|
---|
2392 | class="cmtt-8">float32</span><span
|
---|
2393 | class="cmtt-8">_unpack</span></a><span
|
---|
2394 | class="cmtt-8">(</span><span
|
---|
2395 | class="cmtt-8"> read</span><span
|
---|
2396 | class="cmtt-8"> 32</span><span
|
---|
2397 | class="cmtt-8"> bits</span><span
|
---|
2398 | class="cmtt-8"> as</span><span
|
---|
2399 | class="cmtt-8"> an</span><span
|
---|
2400 | class="cmtt-8"> unsigned</span><span
|
---|
2401 | class="cmtt-8"> integer)</span>
|
---|
2402 | <br class="fancyvrb" /><a
|
---|
2403 | id="x1-51105r2"></a><span
|
---|
2404 | class="cmr-6">2</span><span
|
---|
2405 | class="cmtt-8"> </span><span
|
---|
2406 | class="cmtt-8"> 2)</span><span
|
---|
2407 | class="cmtt-8"> [codebook</span><span
|
---|
2408 | class="cmtt-8">_delta</span><span
|
---|
2409 | class="cmtt-8">_value]</span><span
|
---|
2410 | class="cmtt-8"> =</span><span
|
---|
2411 | class="cmtt-8"> </span><a
|
---|
2412 | href="#x1-1200009.2.2"><span
|
---|
2413 | class="cmtt-8">float32</span><span
|
---|
2414 | class="cmtt-8">_unpack</span></a><span
|
---|
2415 | class="cmtt-8">(</span><span
|
---|
2416 | class="cmtt-8"> read</span><span
|
---|
2417 | class="cmtt-8"> 32</span><span
|
---|
2418 | class="cmtt-8"> bits</span><span
|
---|
2419 | class="cmtt-8"> as</span><span
|
---|
2420 | class="cmtt-8"> an</span><span
|
---|
2421 | class="cmtt-8"> unsigned</span><span
|
---|
2422 | class="cmtt-8"> integer)</span>
|
---|
2423 | <br class="fancyvrb" /><a
|
---|
2424 | id="x1-51107r3"></a><span
|
---|
2425 | class="cmr-6">3</span><span
|
---|
2426 | class="cmtt-8"> </span><span
|
---|
2427 | class="cmtt-8"> 3)</span><span
|
---|
2428 | class="cmtt-8"> [codebook</span><span
|
---|
2429 | class="cmtt-8">_value</span><span
|
---|
2430 | class="cmtt-8">_bits]</span><span
|
---|
2431 | class="cmtt-8"> =</span><span
|
---|
2432 | class="cmtt-8"> read</span><span
|
---|
2433 | class="cmtt-8"> 4</span><span
|
---|
2434 | class="cmtt-8"> bits</span><span
|
---|
2435 | class="cmtt-8"> as</span><span
|
---|
2436 | class="cmtt-8"> an</span><span
|
---|
2437 | class="cmtt-8"> unsigned</span><span
|
---|
2438 | class="cmtt-8"> integer</span><span
|
---|
2439 | class="cmtt-8"> and</span><span
|
---|
2440 | class="cmtt-8"> add</span><span
|
---|
2441 | class="cmtt-8"> 1</span><br class="fancyvrb" /><a
|
---|
2442 | id="x1-51109r4"></a><span
|
---|
2443 | class="cmr-6">4</span><span
|
---|
2444 | class="cmtt-8"> </span><span
|
---|
2445 | class="cmtt-8"> 4)</span><span
|
---|
2446 | class="cmtt-8"> [codebook</span><span
|
---|
2447 | class="cmtt-8">_sequence</span><span
|
---|
2448 | class="cmtt-8">_p]</span><span
|
---|
2449 | class="cmtt-8"> =</span><span
|
---|
2450 | class="cmtt-8"> read</span><span
|
---|
2451 | class="cmtt-8"> 1</span><span
|
---|
2452 | class="cmtt-8"> bit</span><span
|
---|
2453 | class="cmtt-8"> as</span><span
|
---|
2454 | class="cmtt-8"> a</span><span
|
---|
2455 | class="cmtt-8"> boolean</span><span
|
---|
2456 | class="cmtt-8"> flag</span><br class="fancyvrb" /><a
|
---|
2457 | id="x1-51111r5"></a><span
|
---|
2458 | class="cmr-6">5</span>
|
---|
2459 |
|
---|
2460 |
|
---|
2461 |
|
---|
2462 | <br class="fancyvrb" /><a
|
---|
2463 | id="x1-51113r6"></a><span
|
---|
2464 | class="cmr-6">6</span><span
|
---|
2465 | class="cmtt-8"> </span><span
|
---|
2466 | class="cmtt-8"> if</span><span
|
---|
2467 | class="cmtt-8"> (</span><span
|
---|
2468 | class="cmtt-8"> [codebook</span><span
|
---|
2469 | class="cmtt-8">_lookup</span><span
|
---|
2470 | class="cmtt-8">_type]</span><span
|
---|
2471 | class="cmtt-8"> is</span><span
|
---|
2472 | class="cmtt-8"> 1</span><span
|
---|
2473 | class="cmtt-8"> )</span><span
|
---|
2474 | class="cmtt-8"> </span><span
|
---|
2475 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
2476 | id="x1-51115r7"></a><span
|
---|
2477 | class="cmr-6">7</span><br class="fancyvrb" /><a
|
---|
2478 | id="x1-51117r8"></a><span
|
---|
2479 | class="cmr-6">8</span><span
|
---|
2480 | class="cmtt-8"> </span><span
|
---|
2481 | class="cmtt-8"> </span><span
|
---|
2482 | class="cmtt-8"> </span><span
|
---|
2483 | class="cmtt-8"> </span><span
|
---|
2484 | class="cmtt-8"> 5)</span><span
|
---|
2485 | class="cmtt-8"> [codebook</span><span
|
---|
2486 | class="cmtt-8">_lookup</span><span
|
---|
2487 | class="cmtt-8">_values]</span><span
|
---|
2488 | class="cmtt-8"> =</span><span
|
---|
2489 | class="cmtt-8"> </span><a
|
---|
2490 | href="#x1-1210009.2.3"><span
|
---|
2491 | class="cmtt-8">lookup1</span><span
|
---|
2492 | class="cmtt-8">_values</span></a><span
|
---|
2493 | class="cmtt-8">([codebook</span><span
|
---|
2494 | class="cmtt-8">_entries],</span><span
|
---|
2495 | class="cmtt-8"> [codebook</span><span
|
---|
2496 | class="cmtt-8">_dimensions]</span><span
|
---|
2497 | class="cmtt-8"> )</span><br class="fancyvrb" /><a
|
---|
2498 | id="x1-51119r9"></a><span
|
---|
2499 | class="cmr-6">9</span>
|
---|
2500 | <br class="fancyvrb" /><a
|
---|
2501 | id="x1-51121r10"></a><span
|
---|
2502 | class="cmr-6">10</span><span
|
---|
2503 | class="cmtt-8"> </span><span
|
---|
2504 | class="cmtt-8"> </span><span
|
---|
2505 | class="cmsy-8">}</span><span
|
---|
2506 | class="cmtt-8"> else</span><span
|
---|
2507 | class="cmtt-8"> </span><span
|
---|
2508 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
2509 | id="x1-51123r11"></a><span
|
---|
2510 | class="cmr-6">11</span><br class="fancyvrb" /><a
|
---|
2511 | id="x1-51125r12"></a><span
|
---|
2512 | class="cmr-6">12</span><span
|
---|
2513 | class="cmtt-8"> </span><span
|
---|
2514 | class="cmtt-8"> </span><span
|
---|
2515 | class="cmtt-8"> </span><span
|
---|
2516 | class="cmtt-8"> </span><span
|
---|
2517 | class="cmtt-8"> 6)</span><span
|
---|
2518 | class="cmtt-8"> [codebook</span><span
|
---|
2519 | class="cmtt-8">_lookup</span><span
|
---|
2520 | class="cmtt-8">_values]</span><span
|
---|
2521 | class="cmtt-8"> =</span><span
|
---|
2522 | class="cmtt-8"> [codebook</span><span
|
---|
2523 | class="cmtt-8">_entries]</span><span
|
---|
2524 | class="cmtt-8"> *</span><span
|
---|
2525 | class="cmtt-8"> [codebook</span><span
|
---|
2526 | class="cmtt-8">_dimensions]</span><br class="fancyvrb" /><a
|
---|
2527 | id="x1-51127r13"></a><span
|
---|
2528 | class="cmr-6">13</span><br class="fancyvrb" /><a
|
---|
2529 | id="x1-51129r14"></a><span
|
---|
2530 | class="cmr-6">14</span><span
|
---|
2531 | class="cmtt-8"> </span><span
|
---|
2532 | class="cmtt-8"> </span><span
|
---|
2533 | class="cmsy-8">}</span><br class="fancyvrb" /><a
|
---|
2534 | id="x1-51131r15"></a><span
|
---|
2535 | class="cmr-6">15</span>
|
---|
2536 | <br class="fancyvrb" /><a
|
---|
2537 | id="x1-51133r16"></a><span
|
---|
2538 | class="cmr-6">16</span><span
|
---|
2539 | class="cmtt-8"> </span><span
|
---|
2540 | class="cmtt-8"> 7)</span><span
|
---|
2541 | class="cmtt-8"> read</span><span
|
---|
2542 | class="cmtt-8"> a</span><span
|
---|
2543 | class="cmtt-8"> total</span><span
|
---|
2544 | class="cmtt-8"> of</span><span
|
---|
2545 | class="cmtt-8"> [codebook</span><span
|
---|
2546 | class="cmtt-8">_lookup</span><span
|
---|
2547 | class="cmtt-8">_values]</span><span
|
---|
2548 | class="cmtt-8"> unsigned</span><span
|
---|
2549 | class="cmtt-8"> integers</span><span
|
---|
2550 | class="cmtt-8"> of</span><span
|
---|
2551 | class="cmtt-8"> [codebook</span><span
|
---|
2552 | class="cmtt-8">_value</span><span
|
---|
2553 | class="cmtt-8">_bits]</span><span
|
---|
2554 | class="cmtt-8"> each;</span>
|
---|
2555 | <br class="fancyvrb" /><a
|
---|
2556 | id="x1-51135r17"></a><span
|
---|
2557 | class="cmr-6">17</span><span
|
---|
2558 | class="cmtt-8"> </span><span
|
---|
2559 | class="cmtt-8"> </span><span
|
---|
2560 | class="cmtt-8"> </span><span
|
---|
2561 | class="cmtt-8"> </span><span
|
---|
2562 | class="cmtt-8"> store</span><span
|
---|
2563 | class="cmtt-8"> these</span><span
|
---|
2564 | class="cmtt-8"> in</span><span
|
---|
2565 | class="cmtt-8"> order</span><span
|
---|
2566 | class="cmtt-8"> in</span><span
|
---|
2567 | class="cmtt-8"> the</span><span
|
---|
2568 | class="cmtt-8"> array</span><span
|
---|
2569 | class="cmtt-8"> [codebook</span><span
|
---|
2570 | class="cmtt-8">_multiplicands]</span></div>
|
---|
2571 | </li>
|
---|
2572 | <li class="itemize">A <span
|
---|
2573 | class="cmtt-12">[codebook</span><span
|
---|
2574 | class="cmtt-12">_lookup</span><span
|
---|
2575 | class="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 ’end of packet’ during any read operation in the above steps is considered an error condition
|
---|
2579 | rendering the stream undecodable.
|
---|
2580 | <!--l. 197--><p class="noindent" ><span class="paragraphHead"><a
|
---|
2581 | id="x1-520003.2.1"></a><span
|
---|
2582 | class="cmbx-12">Huffman decision tree representation</span></span>
|
---|
2583 | The <span
|
---|
2584 | class="cmtt-12">[codebook</span><span
|
---|
2585 | class="cmtt-12">_codeword</span><span
|
---|
2586 | class="cmtt-12">_lengths] </span>array and <span
|
---|
2587 | class="cmtt-12">[codebook</span><span
|
---|
2588 | class="cmtt-12">_entries] </span>value uniquely define the
|
---|
2589 | Huffman decision tree used for entropy decoding.
|
---|
2590 | <!--l. 203--><p class="noindent" >Briefly, each used codebook entry (recall that length-unordered codebooks support unused
|
---|
2591 | codeword entries) is assigned, in order, the lowest valued unused binary Huffman codeword
|
---|
2592 | possible. 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
|
---|
2596 | class="cmr-6">1</span><span
|
---|
2597 | class="cmtt-8">entry</span><span
|
---|
2598 | class="cmtt-8"> 0:</span><span
|
---|
2599 | class="cmtt-8"> length</span><span
|
---|
2600 | class="cmtt-8"> 2</span><br class="fancyvrb" /><a
|
---|
2601 | id="x1-52004r2"></a><span
|
---|
2602 | class="cmr-6">2</span><span
|
---|
2603 | class="cmtt-8">entry</span><span
|
---|
2604 | class="cmtt-8"> 1:</span><span
|
---|
2605 | class="cmtt-8"> length</span><span
|
---|
2606 | class="cmtt-8"> 4</span><br class="fancyvrb" /><a
|
---|
2607 | id="x1-52006r3"></a><span
|
---|
2608 | class="cmr-6">3</span><span
|
---|
2609 | class="cmtt-8">entry</span><span
|
---|
2610 | class="cmtt-8"> 2:</span><span
|
---|
2611 | class="cmtt-8"> length</span><span
|
---|
2612 | class="cmtt-8"> 4</span><br class="fancyvrb" /><a
|
---|
2613 | id="x1-52008r4"></a><span
|
---|
2614 | class="cmr-6">4</span><span
|
---|
2615 | class="cmtt-8">entry</span><span
|
---|
2616 | class="cmtt-8"> 3:</span><span
|
---|
2617 | class="cmtt-8"> length</span><span
|
---|
2618 | class="cmtt-8"> 4</span><br class="fancyvrb" /><a
|
---|
2619 | id="x1-52010r5"></a><span
|
---|
2620 | class="cmr-6">5</span><span
|
---|
2621 | class="cmtt-8">entry</span><span
|
---|
2622 | class="cmtt-8"> 4:</span><span
|
---|
2623 | class="cmtt-8"> length</span><span
|
---|
2624 | class="cmtt-8"> 4</span><br class="fancyvrb" /><a
|
---|
2625 | id="x1-52012r6"></a><span
|
---|
2626 | class="cmr-6">6</span><span
|
---|
2627 | class="cmtt-8">entry</span><span
|
---|
2628 | class="cmtt-8"> 5:</span><span
|
---|
2629 | class="cmtt-8"> length</span><span
|
---|
2630 | class="cmtt-8"> 2</span><br class="fancyvrb" /><a
|
---|
2631 | id="x1-52014r7"></a><span
|
---|
2632 | class="cmr-6">7</span><span
|
---|
2633 | class="cmtt-8">entry</span><span
|
---|
2634 | class="cmtt-8"> 6:</span><span
|
---|
2635 | class="cmtt-8"> length</span><span
|
---|
2636 | class="cmtt-8"> 3</span><br class="fancyvrb" /><a
|
---|
2637 | id="x1-52016r8"></a><span
|
---|
2638 | class="cmr-6">8</span><span
|
---|
2639 | class="cmtt-8">entry</span><span
|
---|
2640 | class="cmtt-8"> 7:</span><span
|
---|
2641 | class="cmtt-8"> length</span><span
|
---|
2642 | class="cmtt-8"> 3</span></div>
|
---|
2643 | <!--l. 219--><p class="noindent" >Assigning codewords in order (lowest possible value of the appropriate length to highest) results
|
---|
2644 | in the following codeword list:
|
---|
2645 | <!--l. 222--><p class="noindent" >
|
---|
2646 | <div class="fancyvrb" id="fancyvrb16"><a
|
---|
2647 | id="x1-52018r1"></a><span
|
---|
2648 | class="cmr-6">1</span><span
|
---|
2649 | class="cmtt-8">entry</span><span
|
---|
2650 | class="cmtt-8"> 0:</span><span
|
---|
2651 | class="cmtt-8"> length</span><span
|
---|
2652 | class="cmtt-8"> 2</span><span
|
---|
2653 | class="cmtt-8"> codeword</span><span
|
---|
2654 | class="cmtt-8"> 00</span><br class="fancyvrb" /><a
|
---|
2655 | id="x1-52020r2"></a><span
|
---|
2656 | class="cmr-6">2</span><span
|
---|
2657 | class="cmtt-8">entry</span><span
|
---|
2658 | class="cmtt-8"> 1:</span><span
|
---|
2659 | class="cmtt-8"> length</span><span
|
---|
2660 | class="cmtt-8"> 4</span><span
|
---|
2661 | class="cmtt-8"> codeword</span><span
|
---|
2662 | class="cmtt-8"> 0100</span><br class="fancyvrb" /><a
|
---|
2663 | id="x1-52022r3"></a><span
|
---|
2664 | class="cmr-6">3</span><span
|
---|
2665 | class="cmtt-8">entry</span><span
|
---|
2666 | class="cmtt-8"> 2:</span><span
|
---|
2667 | class="cmtt-8"> length</span><span
|
---|
2668 | class="cmtt-8"> 4</span><span
|
---|
2669 | class="cmtt-8"> codeword</span><span
|
---|
2670 | class="cmtt-8"> 0101</span><br class="fancyvrb" /><a
|
---|
2671 | id="x1-52024r4"></a><span
|
---|
2672 | class="cmr-6">4</span><span
|
---|
2673 | class="cmtt-8">entry</span><span
|
---|
2674 | class="cmtt-8"> 3:</span><span
|
---|
2675 | class="cmtt-8"> length</span><span
|
---|
2676 | class="cmtt-8"> 4</span><span
|
---|
2677 | class="cmtt-8"> codeword</span><span
|
---|
2678 | class="cmtt-8"> 0110</span>
|
---|
2679 | <br class="fancyvrb" /><a
|
---|
2680 | id="x1-52026r5"></a><span
|
---|
2681 | class="cmr-6">5</span><span
|
---|
2682 | class="cmtt-8">entry</span><span
|
---|
2683 | class="cmtt-8"> 4:</span><span
|
---|
2684 | class="cmtt-8"> length</span><span
|
---|
2685 | class="cmtt-8"> 4</span><span
|
---|
2686 | class="cmtt-8"> codeword</span><span
|
---|
2687 | class="cmtt-8"> 0111</span><br class="fancyvrb" /><a
|
---|
2688 | id="x1-52028r6"></a><span
|
---|
2689 | class="cmr-6">6</span><span
|
---|
2690 | class="cmtt-8">entry</span><span
|
---|
2691 | class="cmtt-8"> 5:</span><span
|
---|
2692 | class="cmtt-8"> length</span><span
|
---|
2693 | class="cmtt-8"> 2</span><span
|
---|
2694 | class="cmtt-8"> codeword</span><span
|
---|
2695 | class="cmtt-8"> 10</span><br class="fancyvrb" /><a
|
---|
2696 | id="x1-52030r7"></a><span
|
---|
2697 | class="cmr-6">7</span><span
|
---|
2698 | class="cmtt-8">entry</span><span
|
---|
2699 | class="cmtt-8"> 6:</span><span
|
---|
2700 | class="cmtt-8"> length</span><span
|
---|
2701 | class="cmtt-8"> 3</span><span
|
---|
2702 | class="cmtt-8"> codeword</span><span
|
---|
2703 | class="cmtt-8"> 110</span><br class="fancyvrb" /><a
|
---|
2704 | id="x1-52032r8"></a><span
|
---|
2705 | class="cmr-6">8</span><span
|
---|
2706 | class="cmtt-8">entry</span><span
|
---|
2707 | class="cmtt-8"> 7:</span><span
|
---|
2708 | class="cmtt-8"> length</span><span
|
---|
2709 | class="cmtt-8"> 3</span><span
|
---|
2710 | class="cmtt-8"> codeword</span><span
|
---|
2711 | class="cmtt-8"> 111</span></div>
|
---|
2712 | <!--l. 234--><p class="noindent" ><span class="likesubparagraphHead"><a
|
---|
2713 | id="x1-530003.2.1"></a><span
|
---|
2714 | class="cmbx-12">Note:</span></span> Unlike most binary numerical values in this document, we intend the above codewords to
|
---|
2715 | be read and used bit by bit from left to right, thus the codeword ’001’ is the bit string ’zero, zero,
|
---|
2716 | one’. When determining ’lowest possible value’ in the assignment definition above, the leftmost
|
---|
2717 | bit 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
|
---|
2719 | numbers 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
|
---|
2728 | src="hufftree.png" alt="PIC"
|
---|
2729 | >
|
---|
2730 | <br /> <div class="caption"
|
---|
2731 | ><span class="id">Figure 4: </span><span
|
---|
2732 | class="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
|
---|
2735 | possible position.
|
---|
2736 | <!--l. 255--><p class="noindent" >Note that it’s possible to underspecify or overspecify a Huffman tree via the length list.
|
---|
2737 | In the above example, if codeword seven were eliminated, it’s clear that the tree is
|
---|
2738 | unfinished:
|
---|
2739 | <div class="center"
|
---|
2740 | >
|
---|
2741 | <!--l. 259--><p class="noindent" >
|
---|
2742 |
|
---|
2743 | <!--l. 260--><p class="noindent" ><img
|
---|
2744 | src="hufftree-under.png" alt="PIC"
|
---|
2745 | >
|
---|
2746 | <br /> <div class="caption"
|
---|
2747 | ><span class="id">Figure 5: </span><span
|
---|
2748 | class="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’s clear that the tree is fully populated and a ninth
|
---|
2751 | codeword is impossible. Both underspecified and overspecified trees are an error condition
|
---|
2752 | rendering the stream undecodable.
|
---|
2753 | <!--l. 270--><p class="noindent" >Codebook entries marked ’unused’ are simply skipped in the assigning process. They have no
|
---|
2754 | codeword and do not appear in the decision tree, thus it’s impossible for any bit pattern read
|
---|
2755 | from 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
|
---|
2758 | class="cmbx-12">Errata 20150226: Single entry codebooks</span></span>
|
---|
2759 | A ’single-entry codebook’ is a codebook with one active codeword entry. A single-entry codebook
|
---|
2760 | may be either a fully populated codebook with only one declared entry, or a sparse codebook
|
---|
2761 | with only one entry marked used. The Vorbis I spec provides no means to specify a codeword
|
---|
2762 | length of zero, and as a result, a single-entry codebook is inherently malformed because it is
|
---|
2763 | underpopulated. The original specification did not address directly the matter of single-entry
|
---|
2764 | codebooks; they were implicitly illegal as it was not possible to write such a codebook with a
|
---|
2765 | valid 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
|
---|
2770 | codebook implementation to reject underpopulated Huffman trees. This change led to the
|
---|
2771 | discovery of single-entry books used ’in the wild’ when the new, stricter checks rejected a number
|
---|
2772 | of apparently working streams.
|
---|
2773 | <!--l. 293--><p class="noindent" >In order to minimize breakage of deployed (if technically erroneous) streams, r16073 of the
|
---|
2774 | reference implementation explicitly special-cased single-entry codebooks to tolerate the
|
---|
2775 | single-entry case. Commit r16073 also added the following to the specification:
|
---|
2776 | <!--l. 302--><p class="noindent" >“<span class="sout">Take special care that a codebook with a single used entry is handled properly; it consists of a
|
---|
2777 | single codework of zero bits and reading a value out of such a codebook always returns the single
|
---|
2778 | used value and sinks zero bits. </span>”
|
---|
2779 | <!--l. 304--><p class="noindent" >The intent was to clarify the spec and codify current practice. However, this addition is
|
---|
2780 | erroneously at odds with the intent of preserving usability of existing streams using single-entry
|
---|
2781 | codebooks, disagrees with the code changes that reinstated decoding, and does not address how
|
---|
2782 | single-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
|
---|
2784 | following:
|
---|
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
|
---|
2790 | class="cmtt-12">[codebook</span><span
|
---|
2791 | class="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
|
---|
2793 | class="cmtt-12">[codeword</span><span
|
---|
2794 | class="cmtt-12">_length] </span>of zero
|
---|
2795 | for the single used codeword, as the unsigned value written to the stream
|
---|
2796 | is <span
|
---|
2797 | class="cmtt-12">[codeword</span><span
|
---|
2798 | class="cmtt-12">_length]-1</span>. Instead, encoder implementations should indicate a
|
---|
2799 | <span
|
---|
2800 | class="cmtt-12">[codeword</span><span
|
---|
2801 | class="cmtt-12">_length] </span>of 1 and ’write’ 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
|
---|
2805 | class="cmtt-12">[codeword</span><span
|
---|
2806 | class="cmtt-12">_length] </span>of that entry is not 1. ’Reading’ 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 ’1’ instead of ’0’; 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
|
---|
2812 | class="cmbx-12">VQ lookup table vector representation</span></span>
|
---|
2813 | Unpacking 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
|
---|
2819 | class="cmr-6">1</span><span
|
---|
2820 | class="cmtt-8">the</span><span
|
---|
2821 | class="cmtt-8"> [codebook\_multiplicands]</span><span
|
---|
2822 | class="cmtt-8"> array</span><br class="fancyvrb" /><a
|
---|
2823 | id="x1-55004r2"></a><span
|
---|
2824 | class="cmr-6">2</span><span
|
---|
2825 | class="cmtt-8">[codebook\_minimum\_value]</span><br class="fancyvrb" /><a
|
---|
2826 | id="x1-55006r3"></a><span
|
---|
2827 | class="cmr-6">3</span><span
|
---|
2828 | class="cmtt-8">[codebook\_delta\_value]</span><br class="fancyvrb" /><a
|
---|
2829 | id="x1-55008r4"></a><span
|
---|
2830 | class="cmr-6">4</span><span
|
---|
2831 | class="cmtt-8">[codebook\_sequence\_p]</span>
|
---|
2832 | <br class="fancyvrb" /><a
|
---|
2833 | id="x1-55010r5"></a><span
|
---|
2834 | class="cmr-6">5</span><span
|
---|
2835 | class="cmtt-8">[codebook\_lookup\_type]</span><br class="fancyvrb" /><a
|
---|
2836 | id="x1-55012r6"></a><span
|
---|
2837 | class="cmr-6">6</span><span
|
---|
2838 | class="cmtt-8">[codebook\_entries]</span><br class="fancyvrb" /><a
|
---|
2839 | id="x1-55014r7"></a><span
|
---|
2840 | class="cmr-6">7</span><span
|
---|
2841 | class="cmtt-8">[codebook\_dimensions]</span><br class="fancyvrb" /><a
|
---|
2842 | id="x1-55016r8"></a><span
|
---|
2843 | class="cmr-6">8</span><span
|
---|
2844 | class="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
|
---|
2847 | class="cmtt-12">[codebook</span><span
|
---|
2848 | class="cmtt-12">_lookup</span><span
|
---|
2849 | class="cmtt-12">_type]</span>. The unpacked vector values are what a codebook would return
|
---|
2850 | during 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
|
---|
2853 | class="cmbx-12">Vector value decode: Lookup type 1</span></span>
|
---|
2854 | Lookup type one specifies a lattice VQ lookup table built algorithmically from a list of
|
---|
2855 | scalar values. Calculate (unpack) the final values of a codebook entry vector from
|
---|
2856 | the entries in <span
|
---|
2857 | class="cmtt-12">[codebook</span><span
|
---|
2858 | class="cmtt-12">_multiplicands] </span>as follows (<span
|
---|
2859 | class="cmtt-12">[value</span><span
|
---|
2860 | class="cmtt-12">_vector] </span>is the output
|
---|
2861 | vector representing the vector of values for entry number <span
|
---|
2862 | class="cmtt-12">[lookup</span><span
|
---|
2863 | class="cmtt-12">_offset] </span>in this
|
---|
2864 | codebook):
|
---|
2865 | <!--l. 361--><p class="noindent" >
|
---|
2866 | <div class="fancyvrb" id="fancyvrb18"><a
|
---|
2867 | id="x1-56002r1"></a><span
|
---|
2868 | class="cmr-6">1</span><span
|
---|
2869 | class="cmtt-8"> </span><span
|
---|
2870 | class="cmtt-8"> 1)</span><span
|
---|
2871 | class="cmtt-8"> [last]</span><span
|
---|
2872 | class="cmtt-8"> =</span><span
|
---|
2873 | class="cmtt-8"> 0;</span><br class="fancyvrb" /><a
|
---|
2874 | id="x1-56004r2"></a><span
|
---|
2875 | class="cmr-6">2</span><span
|
---|
2876 | class="cmtt-8"> </span><span
|
---|
2877 | class="cmtt-8"> 2)</span><span
|
---|
2878 | class="cmtt-8"> [index</span><span
|
---|
2879 | class="cmtt-8">_divisor]</span><span
|
---|
2880 | class="cmtt-8"> =</span><span
|
---|
2881 | class="cmtt-8"> 1;</span><br class="fancyvrb" /><a
|
---|
2882 | id="x1-56006r3"></a><span
|
---|
2883 | class="cmr-6">3</span><span
|
---|
2884 | class="cmtt-8"> </span><span
|
---|
2885 | class="cmtt-8"> 3)</span><span
|
---|
2886 | class="cmtt-8"> iterate</span><span
|
---|
2887 | class="cmtt-8"> [i]</span><span
|
---|
2888 | class="cmtt-8"> over</span><span
|
---|
2889 | class="cmtt-8"> the</span><span
|
---|
2890 | class="cmtt-8"> range</span><span
|
---|
2891 | class="cmtt-8"> 0</span><span
|
---|
2892 | class="cmtt-8"> ...</span><span
|
---|
2893 | class="cmtt-8"> [codebook</span><span
|
---|
2894 | class="cmtt-8">_dimensions]-1</span><span
|
---|
2895 | class="cmtt-8"> (once</span><span
|
---|
2896 | class="cmtt-8"> for</span><span
|
---|
2897 | class="cmtt-8"> each</span><span
|
---|
2898 | class="cmtt-8"> scalar</span><span
|
---|
2899 | class="cmtt-8"> value</span><span
|
---|
2900 | class="cmtt-8"> in</span><span
|
---|
2901 | class="cmtt-8"> the</span><span
|
---|
2902 | class="cmtt-8"> value</span><span
|
---|
2903 | class="cmtt-8"> vector)</span><span
|
---|
2904 | class="cmtt-8"> </span><span
|
---|
2905 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
2906 | id="x1-56008r4"></a><span
|
---|
2907 | class="cmr-6">4</span>
|
---|
2908 | <br class="fancyvrb" /><a
|
---|
2909 | id="x1-56010r5"></a><span
|
---|
2910 | class="cmr-6">5</span><span
|
---|
2911 | class="cmtt-8"> </span><span
|
---|
2912 | class="cmtt-8"> </span><span
|
---|
2913 | class="cmtt-8"> </span><span
|
---|
2914 | class="cmtt-8"> </span><span
|
---|
2915 | class="cmtt-8"> </span><span
|
---|
2916 | class="cmtt-8"> </span><span
|
---|
2917 | class="cmtt-8"> 4)</span><span
|
---|
2918 | class="cmtt-8"> [multiplicand</span><span
|
---|
2919 | class="cmtt-8">_offset]</span><span
|
---|
2920 | class="cmtt-8"> =</span><span
|
---|
2921 | class="cmtt-8"> (</span><span
|
---|
2922 | class="cmtt-8"> [lookup</span><span
|
---|
2923 | class="cmtt-8">_offset]</span><span
|
---|
2924 | class="cmtt-8"> divided</span><span
|
---|
2925 | class="cmtt-8"> by</span><span
|
---|
2926 | class="cmtt-8"> [index</span><span
|
---|
2927 | class="cmtt-8">_divisor]</span><span
|
---|
2928 | class="cmtt-8"> using</span><span
|
---|
2929 | class="cmtt-8"> integer</span>
|
---|
2930 | <br class="fancyvrb" /><a
|
---|
2931 | id="x1-56012r6"></a><span
|
---|
2932 | class="cmr-6">6</span><span
|
---|
2933 | class="cmtt-8"> </span><span
|
---|
2934 | class="cmtt-8"> </span><span
|
---|
2935 | class="cmtt-8"> </span><span
|
---|
2936 | class="cmtt-8"> </span><span
|
---|
2937 | class="cmtt-8"> </span><span
|
---|
2938 | class="cmtt-8"> </span><span
|
---|
2939 | class="cmtt-8"> </span><span
|
---|
2940 | class="cmtt-8"> </span><span
|
---|
2941 | class="cmtt-8"> </span><span
|
---|
2942 | class="cmtt-8"> division</span><span
|
---|
2943 | class="cmtt-8"> )</span><span
|
---|
2944 | class="cmtt-8"> integer</span><span
|
---|
2945 | class="cmtt-8"> modulo</span><span
|
---|
2946 | class="cmtt-8"> [codebook</span><span
|
---|
2947 | class="cmtt-8">_lookup</span><span
|
---|
2948 | class="cmtt-8">_values]</span><br class="fancyvrb" /><a
|
---|
2949 | id="x1-56014r7"></a><span
|
---|
2950 | class="cmr-6">7</span><br class="fancyvrb" /><a
|
---|
2951 | id="x1-56016r8"></a><span
|
---|
2952 | class="cmr-6">8</span><span
|
---|
2953 | class="cmtt-8"> </span><span
|
---|
2954 | class="cmtt-8"> </span><span
|
---|
2955 | class="cmtt-8"> </span><span
|
---|
2956 | class="cmtt-8"> </span><span
|
---|
2957 | class="cmtt-8"> </span><span
|
---|
2958 | class="cmtt-8"> </span><span
|
---|
2959 | class="cmtt-8"> 5)</span><span
|
---|
2960 | class="cmtt-8"> vector</span><span
|
---|
2961 | class="cmtt-8"> [value</span><span
|
---|
2962 | class="cmtt-8">_vector]</span><span
|
---|
2963 | class="cmtt-8"> element</span><span
|
---|
2964 | class="cmtt-8"> [i]</span><span
|
---|
2965 | class="cmtt-8"> =</span>
|
---|
2966 | <br class="fancyvrb" /><a
|
---|
2967 | id="x1-56018r9"></a><span
|
---|
2968 | class="cmr-6">9</span><span
|
---|
2969 | class="cmtt-8"> </span><span
|
---|
2970 | class="cmtt-8"> </span><span
|
---|
2971 | class="cmtt-8"> </span><span
|
---|
2972 | class="cmtt-8"> </span><span
|
---|
2973 | class="cmtt-8"> </span><span
|
---|
2974 | class="cmtt-8"> </span><span
|
---|
2975 | class="cmtt-8"> </span><span
|
---|
2976 | class="cmtt-8"> </span><span
|
---|
2977 | class="cmtt-8"> </span><span
|
---|
2978 | class="cmtt-8"> </span><span
|
---|
2979 | class="cmtt-8"> </span><span
|
---|
2980 | class="cmtt-8"> (</span><span
|
---|
2981 | class="cmtt-8"> [codebook</span><span
|
---|
2982 | class="cmtt-8">_multiplicands]</span><span
|
---|
2983 | class="cmtt-8"> array</span><span
|
---|
2984 | class="cmtt-8"> element</span><span
|
---|
2985 | class="cmtt-8"> number</span><span
|
---|
2986 | class="cmtt-8"> [multiplicand</span><span
|
---|
2987 | class="cmtt-8">_offset]</span><span
|
---|
2988 | class="cmtt-8"> )</span><span
|
---|
2989 | class="cmtt-8"> *</span>
|
---|
2990 | <br class="fancyvrb" /><a
|
---|
2991 | id="x1-56020r10"></a><span
|
---|
2992 | class="cmr-6">10</span><span
|
---|
2993 | class="cmtt-8"> </span><span
|
---|
2994 | class="cmtt-8"> </span><span
|
---|
2995 | class="cmtt-8"> </span><span
|
---|
2996 | class="cmtt-8"> </span><span
|
---|
2997 | class="cmtt-8"> </span><span
|
---|
2998 | class="cmtt-8"> </span><span
|
---|
2999 | class="cmtt-8"> </span><span
|
---|
3000 | class="cmtt-8"> </span><span
|
---|
3001 | class="cmtt-8"> </span><span
|
---|
3002 | class="cmtt-8"> </span><span
|
---|
3003 | class="cmtt-8"> </span><span
|
---|
3004 | class="cmtt-8"> [codebook</span><span
|
---|
3005 | class="cmtt-8">_delta</span><span
|
---|
3006 | class="cmtt-8">_value]</span><span
|
---|
3007 | class="cmtt-8"> +</span><span
|
---|
3008 | class="cmtt-8"> [codebook</span><span
|
---|
3009 | class="cmtt-8">_minimum</span><span
|
---|
3010 | class="cmtt-8">_value]</span><span
|
---|
3011 | class="cmtt-8"> +</span><span
|
---|
3012 | class="cmtt-8"> [last];</span><br class="fancyvrb" /><a
|
---|
3013 | id="x1-56022r11"></a><span
|
---|
3014 | class="cmr-6">11</span>
|
---|
3015 | <br class="fancyvrb" /><a
|
---|
3016 | id="x1-56024r12"></a><span
|
---|
3017 | class="cmr-6">12</span><span
|
---|
3018 | class="cmtt-8"> </span><span
|
---|
3019 | class="cmtt-8"> </span><span
|
---|
3020 | class="cmtt-8"> </span><span
|
---|
3021 | class="cmtt-8"> </span><span
|
---|
3022 | class="cmtt-8"> </span><span
|
---|
3023 | class="cmtt-8"> </span><span
|
---|
3024 | class="cmtt-8"> 6)</span><span
|
---|
3025 | class="cmtt-8"> if</span><span
|
---|
3026 | class="cmtt-8"> (</span><span
|
---|
3027 | class="cmtt-8"> [codebook</span><span
|
---|
3028 | class="cmtt-8">_sequence</span><span
|
---|
3029 | class="cmtt-8">_p]</span><span
|
---|
3030 | class="cmtt-8"> is</span><span
|
---|
3031 | class="cmtt-8"> set</span><span
|
---|
3032 | class="cmtt-8"> )</span><span
|
---|
3033 | class="cmtt-8"> then</span><span
|
---|
3034 | class="cmtt-8"> set</span><span
|
---|
3035 | class="cmtt-8"> [last]</span><span
|
---|
3036 | class="cmtt-8"> =</span><span
|
---|
3037 | class="cmtt-8"> vector</span><span
|
---|
3038 | class="cmtt-8"> [value</span><span
|
---|
3039 | class="cmtt-8">_vector]</span><span
|
---|
3040 | class="cmtt-8"> element</span><span
|
---|
3041 | class="cmtt-8"> [i]</span><br class="fancyvrb" /><a
|
---|
3042 | id="x1-56026r13"></a><span
|
---|
3043 | class="cmr-6">13</span>
|
---|
3044 | <br class="fancyvrb" /><a
|
---|
3045 | id="x1-56028r14"></a><span
|
---|
3046 | class="cmr-6">14</span><span
|
---|
3047 | class="cmtt-8"> </span><span
|
---|
3048 | class="cmtt-8"> </span><span
|
---|
3049 | class="cmtt-8"> </span><span
|
---|
3050 | class="cmtt-8"> </span><span
|
---|
3051 | class="cmtt-8"> </span><span
|
---|
3052 | class="cmtt-8"> </span><span
|
---|
3053 | class="cmtt-8"> 7)</span><span
|
---|
3054 | class="cmtt-8"> [index</span><span
|
---|
3055 | class="cmtt-8">_divisor]</span><span
|
---|
3056 | class="cmtt-8"> =</span><span
|
---|
3057 | class="cmtt-8"> [index</span><span
|
---|
3058 | class="cmtt-8">_divisor]</span><span
|
---|
3059 | class="cmtt-8"> *</span><span
|
---|
3060 | class="cmtt-8"> [codebook</span><span
|
---|
3061 | class="cmtt-8">_lookup</span><span
|
---|
3062 | class="cmtt-8">_values]</span><br class="fancyvrb" /><a
|
---|
3063 | id="x1-56030r15"></a><span
|
---|
3064 | class="cmr-6">15</span><br class="fancyvrb" /><a
|
---|
3065 | id="x1-56032r16"></a><span
|
---|
3066 | class="cmr-6">16</span><span
|
---|
3067 | class="cmtt-8"> </span><span
|
---|
3068 | class="cmtt-8"> </span><span
|
---|
3069 | class="cmtt-8"> </span><span
|
---|
3070 | class="cmtt-8"> </span><span
|
---|
3071 | class="cmtt-8"> </span><span
|
---|
3072 | class="cmsy-8">}</span><br class="fancyvrb" /><a
|
---|
3073 | id="x1-56034r17"></a><span
|
---|
3074 | class="cmr-6">17</span><br class="fancyvrb" /><a
|
---|
3075 | id="x1-56036r18"></a><span
|
---|
3076 | class="cmr-6">18</span><span
|
---|
3077 | class="cmtt-8"> </span><span
|
---|
3078 | class="cmtt-8"> 8)</span><span
|
---|
3079 | class="cmtt-8"> vector</span><span
|
---|
3080 | class="cmtt-8"> calculation</span><span
|
---|
3081 | class="cmtt-8"> completed.</span></div>
|
---|
3082 | <!--l. 384--><p class="noindent" ><span class="paragraphHead"><a
|
---|
3083 | id="x1-570003.2.1"></a><span
|
---|
3084 | class="cmbx-12">Vector value decode: Lookup type 2</span></span>
|
---|
3085 | Lookup type two specifies a VQ lookup table in which each scalar in each vector is explicitly set
|
---|
3086 | by the <span
|
---|
3087 | class="cmtt-12">[codebook</span><span
|
---|
3088 | class="cmtt-12">_multiplicands] </span>array in a one-to-one mapping. Calculate [unpack] the final
|
---|
3089 | values of a codebook entry vector from the entries in <span
|
---|
3090 | class="cmtt-12">[codebook</span><span
|
---|
3091 | class="cmtt-12">_multiplicands] </span>as follows
|
---|
3092 | (<span
|
---|
3093 | class="cmtt-12">[value</span><span
|
---|
3094 | class="cmtt-12">_vector] </span>is the output vector representing the vector of values for entry number
|
---|
3095 | <span
|
---|
3096 | class="cmtt-12">[lookup</span><span
|
---|
3097 | class="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
|
---|
3101 | class="cmr-6">1</span><span
|
---|
3102 | class="cmtt-8"> </span><span
|
---|
3103 | class="cmtt-8"> 1)</span><span
|
---|
3104 | class="cmtt-8"> [last]</span><span
|
---|
3105 | class="cmtt-8"> =</span><span
|
---|
3106 | class="cmtt-8"> 0;</span><br class="fancyvrb" /><a
|
---|
3107 | id="x1-57004r2"></a><span
|
---|
3108 | class="cmr-6">2</span><span
|
---|
3109 | class="cmtt-8"> </span><span
|
---|
3110 | class="cmtt-8"> 2)</span><span
|
---|
3111 | class="cmtt-8"> [multiplicand</span><span
|
---|
3112 | class="cmtt-8">_offset]</span><span
|
---|
3113 | class="cmtt-8"> =</span><span
|
---|
3114 | class="cmtt-8"> [lookup</span><span
|
---|
3115 | class="cmtt-8">_offset]</span><span
|
---|
3116 | class="cmtt-8"> *</span><span
|
---|
3117 | class="cmtt-8"> [codebook</span><span
|
---|
3118 | class="cmtt-8">_dimensions]</span>
|
---|
3119 | <br class="fancyvrb" /><a
|
---|
3120 | id="x1-57006r3"></a><span
|
---|
3121 | class="cmr-6">3</span><span
|
---|
3122 | class="cmtt-8"> </span><span
|
---|
3123 | class="cmtt-8"> 3)</span><span
|
---|
3124 | class="cmtt-8"> iterate</span><span
|
---|
3125 | class="cmtt-8"> [i]</span><span
|
---|
3126 | class="cmtt-8"> over</span><span
|
---|
3127 | class="cmtt-8"> the</span><span
|
---|
3128 | class="cmtt-8"> range</span><span
|
---|
3129 | class="cmtt-8"> 0</span><span
|
---|
3130 | class="cmtt-8"> ...</span><span
|
---|
3131 | class="cmtt-8"> [codebook</span><span
|
---|
3132 | class="cmtt-8">_dimensions]-1</span><span
|
---|
3133 | class="cmtt-8"> (once</span><span
|
---|
3134 | class="cmtt-8"> for</span><span
|
---|
3135 | class="cmtt-8"> each</span><span
|
---|
3136 | class="cmtt-8"> scalar</span><span
|
---|
3137 | class="cmtt-8"> value</span><span
|
---|
3138 | class="cmtt-8"> in</span><span
|
---|
3139 | class="cmtt-8"> the</span><span
|
---|
3140 | class="cmtt-8"> value</span><span
|
---|
3141 | class="cmtt-8"> vector)</span><span
|
---|
3142 | class="cmtt-8"> </span><span
|
---|
3143 | class="cmsy-8">{</span><br class="fancyvrb" /><a
|
---|
3144 | id="x1-57008r4"></a><span
|
---|
3145 | class="cmr-6">4</span>
|
---|
3146 | <br class="fancyvrb" /><a
|
---|
3147 | id="x1-57010r5"></a><span
|
---|
3148 | class="cmr-6">5</span><span
|
---|
3149 | class="cmtt-8"> </span><span
|
---|
3150 | class="cmtt-8"> </span><span
|
---|
3151 | class="cmtt-8"> </span><span
|
---|
3152 | class="cmtt-8"> </span><span
|
---|
3153 | class="cmtt-8"> </span><span
|
---|
3154 | class="cmtt-8"> </span><span
|
---|
3155 | class="cmtt-8"> 4)</span><span
|
---|
3156 | class="cmtt-8"> vector</span><span
|
---|
3157 | class="cmtt-8"> [value</span><span
|
---|
3158 | class="cmtt-8">_vector]</span><span
|
---|
3159 | class="cmtt-8"> element</span><span
|
---|
3160 | class="cmtt-8"> [i]</span><span
|
---|
3161 | class="cmtt-8"> =</span><br class="fancyvrb" /><a
|
---|
3162 | id="x1-57012r6"></a><span
|
---|
3163 | class="cmr-6">6</span><span
|
---|
3164 | class="cmtt-8"> </span><span
|
---|
3165 | class="cmtt-8"> </span><span
|
---|
3166 | class="cmtt-8"> </span><span
|
---|
3167 | class="cmtt-8"> </span><span
|
---|
3168 | class="cmtt-8"> </span><span
|
---|
3169 | class="cmtt-8"> </span><span
|
---|
3170 | class="cmtt-8"> </span><span
|
---|
3171 | class="cmtt-8"> </span><span
|
---|
3172 | class="cmtt-8"> </span><span
|
---|
3173 | class="cmtt-8"> </span><span
|
---|
3174 | class="cmtt-8"> </span><span
|
---|
3175 | class="cmtt-8"> (</span><span
|
---|
3176 | class="cmtt-8"> [codebook</span><span
|
---|
3177 | class="cmtt-8">_multiplicands]</span><span
|
---|
3178 | class="cmtt-8"> array</span><span
|
---|
3179 | class="cmtt-8"> element</span><span
|
---|
3180 | class="cmtt-8"> number</span><span
|
---|
3181 | class="cmtt-8"> [multiplicand</span><span
|
---|
3182 | class="cmtt-8">_offset]</span><span
|
---|
3183 | class="cmtt-8"> )</span><span
|
---|
3184 | class="cmtt-8"> *</span>
|
---|
3185 | <br class="fancyvrb" /><a
|
---|
3186 | id="x1-57014r7"></a><span
|
---|
3187 | class="cmr-6">7</span><span
|
---|
3188 | class="cmtt-8"> </span><span
|
---|
3189 | class="cmtt-8"> </span><span
|
---|
3190 | class="cmtt-8"> </span><span
|
---|
3191 | class="cmtt-8"> </span><span
|
---|
3192 | class="cmtt-8"> </span><span
|
---|
3193 | class="cmtt-8"> </span><span
|
---|
3194 | class="cmtt-8"> </span><span
|
---|
3195 | class="cmtt-8"> </span><span
|
---|
3196 | class="cmtt-8"> </span><span
|
---|
3197 | class="cmtt-8"> </span><span
|
---|
3198 | class="cmtt-8"> </span><span
|
---|
3199 | class="cmtt-8"> [codebook</span><span
|
---|
3200 | class="cmtt-8">_delta</span><span
|
---|
3201 | class="cmtt-8">_value]</span><span
|
---|
3202 | class="cmtt-8"> +</span><span
|
---|
3203 | class="cmtt-8"> [codebook</span><span
|
---|
3204 | class="cmtt-8">_minimum</span><span
|
---|
3205 | class="cmtt-8">_value]</span><span
|
---|
3206 | class="cmtt-8"> +</span><span
|
---|
3207 | class="cmtt-8"> [last];</span><br class="fancyvrb" /><a
|
---|
3208 | id="x1-57016r8"></a><span
|
---|
3209 | class="cmr-6">8</span>
|
---|
3210 | <br class="fancyvrb" /><a
|
---|
3211 | id="x1-57018r9"></a><span
|
---|
3212 | class="cmr-6">9</span><span
|
---|
3213 | class="cmtt-8"> </span><span
|
---|
3214 | class="cmtt-8"> </span><span
|
---|
3215 | class="cmtt-8"> </span><span
|
---|
3216 | class="cmtt-8"> </span><span
|
---|
3217 | class="cmtt-8"> </span><span
|
---|
3218 | class="cmtt-8"> </span><span
|
---|
3219 | class="cmtt-8"> 5)</span><span
|
---|
3220 | class="cmtt-8"> if</span><span
|
---|
3221 | class="cmtt-8"> (</span><span
|
---|
3222 | class="cmtt-8"> [codebook</span><span
|
---|
3223 | class="cmtt-8">_sequence</span><span
|
---|
3224 | class="cmtt-8">_p]</span><span
|
---|
3225 | class="cmtt-8"> is</span><span
|
---|
3226 | class="cmtt-8"> set</span><span
|
---|
3227 | class="cmtt-8"> )</span><span
|
---|
3228 | class="cmtt-8"> then</span><span
|
---|
3229 | class="cmtt-8"> set</span><span
|
---|
3230 | class="cmtt-8"> [last]</span><span
|
---|
3231 | class="cmtt-8"> =</span><span
|
---|
3232 | class="cmtt-8"> vector</span><span
|
---|
3233 | class="cmtt-8"> [value</span><span
|
---|
3234 | class="cmtt-8">_vector]</span><span
|
---|
3235 | class="cmtt-8"> element</span><span
|
---|
3236 | class="cmtt-8"> [i]</span><br class="fancyvrb" /><a
|
---|
3237 | id="x1-57020r10"></a><span
|
---|
3238 | class="cmr-6">10</span>
|
---|
3239 | <br class="fancyvrb" /><a
|
---|
3240 | id="x1-57022r11"></a><span
|
---|
3241 | class="cmr-6">11</span><span
|
---|
3242 | class="cmtt-8"> </span><span
|
---|
3243 | class="cmtt-8"> </span><span
|
---|
3244 | class="cmtt-8"> </span><span
|
---|
3245 | class="cmtt-8"> </span><span
|
---|
3246 | class="cmtt-8"> </span><span
|
---|
3247 | class="cmtt-8"> </span><span
|
---|
3248 | class="cmtt-8"> 6)</span><span
|
---|
3249 | class="cmtt-8"> increment</span><span
|
---|
3250 | class="cmtt-8"> [multiplicand</span><span
|
---|
3251 | class="cmtt-8">_offset]</span><br class="fancyvrb" /><a
|
---|
3252 | id="x1-57024r12"></a><span
|
---|
3253 | class="cmr-6">12</span><br class="fancyvrb" /><a
|
---|
3254 | id="x1-57026r13"></a><span
|
---|
3255 | class="cmr-6">13</span><span
|
---|
3256 | class="cmtt-8"> </span><span
|
---|
3257 | class="cmtt-8"> </span><span
|
---|
3258 | class="cmtt-8"> </span><span
|
---|
3259 | class="cmtt-8"> </span><span
|
---|
3260 | class="cmtt-8"> </span><span
|
---|
3261 | class="cmsy-8">}</span><br class="fancyvrb" /><a
|
---|
3262 | id="x1-57028r14"></a><span
|
---|
3263 | class="cmr-6">14</span><br class="fancyvrb" /><a
|
---|
3264 | id="x1-57030r15"></a><span
|
---|
3265 | class="cmr-6">15</span><span
|
---|
3266 | class="cmtt-8"> </span><span
|
---|
3267 | class="cmtt-8"> 7)</span><span
|
---|
3268 | class="cmtt-8"> vector</span><span
|
---|
3269 | class="cmtt-8"> calculation</span><span
|
---|
3270 | class="cmtt-8"> 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
|
---|
3278 | specific codebook reads a codeword from the bitstream, decoding it into an entry number, and
|
---|
3279 | then returns that entry number to the decoder (when used in a scalar entropy coding context), or
|
---|
3280 | uses that entry number as an offset into the VQ lookup table, returning a vector of values (when
|
---|
3281 | used in a context desiring a VQ value). Scalar or VQ context is always explicit; any
|
---|
3282 | call to the codebook mechanism requests either a scalar entry number or a lookup
|
---|
3283 | vector.
|
---|
3284 | <!--l. 432--><p class="noindent" >Note that VQ lookup type zero indicates that there is no lookup table; requesting
|
---|
3285 | decode using a codebook of lookup type 0 in any context expecting a vector return
|
---|
3286 | value (even in a case where a vector of dimension one) is forbidden. If decoder setup
|
---|
3287 | or decode requests such an action, that is an error condition rendering the packet
|
---|
3288 | undecodable.
|
---|
3289 | <!--l. 439--><p class="noindent" >Using a codebook to read from the packet bitstream consists first of reading and decoding the
|
---|
3290 | next codeword in the bitstream. The decoder reads bits until the accumulated bits match a
|
---|
3291 | codeword in the codebook. This process can be though of as logically walking the
|
---|
3292 | Huffman decode tree by reading one bit at a time from the bitstream, and using the
|
---|
3293 | bit as a decision boolean to take the 0 branch (left in the above examples) or the 1
|
---|
3294 | branch (right in the above examples). Walking the tree finishes when the decode process
|
---|
3295 | hits a leaf in the decision tree; the result is the entry number corresponding to that
|
---|
3296 | leaf. Reading past the end of a packet propagates the ’end-of-stream’ condition to the
|
---|
3297 | decoder.
|
---|
3298 | <!--l. 451--><p class="noindent" >When used in a scalar context, the resulting codeword entry is the desired return
|
---|
3299 | value.
|
---|
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
|
---|
3301 | table. The value returned to the decoder is the vector of scalars corresponding to this
|
---|
3302 | offset.
|
---|
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
|
---|
3315 | of Vorbis I. This document assumes a high-level understanding of the Vorbis decode
|
---|
3316 | process, which is provided in <a
|
---|
3317 | href="#x1-20001">section 1</a>, “<a
|
---|
3318 | href="#x1-20001">Introduction and Description<!--tex4ht:ref: vorbis:spec:intro --></a>”. <a
|
---|
3319 | href="#x1-360002">section 2</a>,
|
---|
3320 | “<a
|
---|
3321 | href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>” covers reading and writing bit fields from and to bitstream
|
---|
3322 | packets.
|
---|
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
|
---|
3327 | identification header, the comments header, and the setup header. All are required for decode
|
---|
3328 | compliance. An end-of-packet condition during decoding the first or third header packet renders
|
---|
3329 | the stream undecodable. End-of-packet decoding the comment header is a non-fatal error
|
---|
3330 | condition.
|
---|
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
|
---|
3338 | class="cmr-6">1</span><span
|
---|
3339 | class="cmtt-8"> </span><span
|
---|
3340 | class="cmtt-8"> 1)</span><span
|
---|
3341 | class="cmtt-8"> [packet</span><span
|
---|
3342 | class="cmtt-8">_type]</span><span
|
---|
3343 | class="cmtt-8"> :</span><span
|
---|
3344 | class="cmtt-8"> 8</span><span
|
---|
3345 | class="cmtt-8"> bit</span><span
|
---|
3346 | class="cmtt-8"> value</span><br class="fancyvrb" /><a
|
---|
3347 | id="x1-62004r2"></a><span
|
---|
3348 | class="cmr-6">2</span><span
|
---|
3349 | class="cmtt-8"> </span><span
|
---|
3350 | class="cmtt-8"> 2)</span><span
|
---|
3351 | class="cmtt-8"> 0x76,</span><span
|
---|
3352 | class="cmtt-8"> 0x6f,</span><span
|
---|
3353 | class="cmtt-8"> 0x72,</span><span
|
---|
3354 | class="cmtt-8"> 0x62,</span><span
|
---|
3355 | class="cmtt-8"> 0x69,</span><span
|
---|
3356 | class="cmtt-8"> 0x73:</span><span
|
---|
3357 | class="cmtt-8"> the</span><span
|
---|
3358 | class="cmtt-8"> characters</span><span
|
---|
3359 | class="cmtt-8"> ’v’,’o’,’r’,’b’,’i’,’s’</span><span
|
---|
3360 | class="cmtt-8"> as</span><span
|
---|
3361 | class="cmtt-8"> six</span><span
|
---|
3362 | class="cmtt-8"> octets</span></div>
|
---|
3363 | <!--l. 35--><p class="noindent" >Decode continues according to packet type; the identification header is type 1, the comment
|
---|
3364 | header type 3 and the setup header type 5 (these types are all odd as a packet with a leading
|
---|
3365 | single bit of ’0’ is an audio packet). The packets must occur in the order of identification,
|
---|
3366 |
|
---|
3367 |
|
---|
3368 |
|
---|
3369 | comment, 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
|
---|
3374 | definitively as Vorbis, and provide a few externally relevant pieces of information about the audio
|
---|
3375 | stream. 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
|
---|
3379 | class="cmr-6">1</span><span
|
---|
3380 | class="cmtt-8"> 1)</span><span
|
---|
3381 | class="cmtt-8"> [vorbis</span><span
|
---|
3382 | class="cmtt-8">_version]</span><span
|
---|
3383 | class="cmtt-8"> =</span><span
|
---|
3384 | class="cmtt-8"> read</span><span
|
---|
3385 | class="cmtt-8"> 32</span><span
|
---|
3386 | class="cmtt-8"> bits</span><span
|
---|
3387 | class="cmtt-8"> as</span><span
|
---|
3388 | class="cmtt-8"> unsigned</span><span
|
---|
3389 | class="cmtt-8"> integer</span><br class="fancyvrb" /><a
|
---|
3390 | id="x1-63004r2"></a><span
|
---|
3391 | class="cmr-6">2</span><span
|
---|
3392 | class="cmtt-8"> 2)</span><span
|
---|
3393 | class="cmtt-8"> [audio</span><span
|
---|
3394 | class="cmtt-8">_channels]</span><span
|
---|
3395 | class="cmtt-8"> =</span><span
|
---|
3396 | class="cmtt-8"> read</span><span
|
---|
3397 | class="cmtt-8"> 8</span><span
|
---|
3398 | class="cmtt-8"> bit</span><span
|
---|
3399 | class="cmtt-8"> integer</span><span
|
---|
3400 | class="cmtt-8"> as</span><span
|
---|
3401 | class="cmtt-8"> unsigned</span>
|
---|
3402 | <br class="fancyvrb" /><a
|
---|
3403 | id="x1-63006r3"></a><span
|
---|
3404 | class="cmr-6">3</span><span
|
---|
3405 | class="cmtt-8"> 3)</span><span
|
---|
3406 | class="cmtt-8"> [audio</span><span
|
---|
3407 | class="cmtt-8">_sample</span><span
|
---|
3408 | class="cmtt-8">_rate]</span><span
|
---|
3409 | class="cmtt-8"> =</span><span
|
---|
3410 | class="cmtt-8"> read</span><span
|
---|
3411 | class="cmtt-8"> 32</span><span
|
---|
3412 | class="cmtt-8"> bits</span><span
|
---|
3413 | class="cmtt-8"> as</span><span
|
---|
3414 | class="cmtt-8"> unsigned</span><span
|
---|
3415 | class="cmtt-8"> integer</span><br class="fancyvrb" /><a
|
---|
3416 | id="x1-63008r4"></a><span
|
---|
3417 | class="cmr-6">4</span><span
|
---|
3418 | class="cmtt-8"> 4)</span><span
|
---|
3419 | class="cmtt-8"> [bitrate</span><span
|
---|
3420 | class="cmtt-8">_maximum]</span><span
|
---|
3421 | class="cmtt-8"> =</span><span
|
---|
3422 | class="cmtt-8"> read</span><span
|
---|
3423 | class="cmtt-8"> 32</span><span
|
---|
3424 | class="cmtt-8"> bits</span><span
|
---|
3425 | class="cmtt-8"> as</span><span
|
---|
3426 | class="cmtt-8"> signed</span><span
|
---|
3427 | class="cmtt-8"> integer</span>
|
---|
3428 | <br class="fancyvrb" /><a
|
---|
3429 | id="x1-63010r5"></a><span
|
---|
3430 | class="cmr-6">5</span><span
|
---|
3431 | class="cmtt-8"> 5)</span><span
|
---|
3432 | class="cmtt-8"> [bitrate</span><span
|
---|
3433 | class="cmtt-8">_nominal]</span><span
|
---|
3434 | class="cmtt-8"> =</span><span
|
---|
3435 | class="cmtt-8"> read</span><span
|
---|
3436 | class="cmtt-8"> 32</span><span
|
---|
3437 | class="cmtt-8"> bits</span><span
|
---|
3438 | class="cmtt-8"> as</span><span
|
---|
3439 | class="cmtt-8"> signed</span><span
|
---|
3440 | class="cmtt-8"> integer</span><br class="fancyvrb" /><a
|
---|
3441 | id="x1-63012r6"></a><span
|
---|
3442 | class="cmr-6">6</span><span
|
---|
3443 | class="cmtt-8"> 6)</span><span
|
---|
3444 | class="cmtt-8"> [bitrate</span><span
|
---|
3445 | class="cmtt-8">_minimum]</span><span
|
---|
3446 | class="cmtt-8"> =</span><span
|
---|
3447 | class="cmtt-8"> read</span><span
|
---|
3448 | class="cmtt-8"> 32</span><span
|
---|
3449 | class="cmtt-8"> bits</span><span
|
---|
3450 | class="cmtt-8"> as</span><span
|
---|
3451 | class="cmtt-8"> signed</span><span
|
---|
3452 | class="cmtt-8"> integer</span>
|
---|
3453 | <br class="fancyvrb" /><a
|
---|
3454 | id="x1-63014r7"></a><span
|
---|
3455 | class="cmr-6">7</span><span
|
---|
3456 | class="cmtt-8"> 7)</span><span
|
---|
3457 | class="cmtt-8"> [blocksize</span><span
|
---|
3458 | class="cmtt-8">_0]</span><span
|
---|
3459 | class="cmtt-8"> =</span><span
|
---|
3460 | class="cmtt-8"> 2</span><span
|
---|
3461 | class="cmtt-8"> exponent</span><span
|
---|
3462 | class="cmtt-8"> (read</span><span
|
---|
3463 | class="cmtt-8"> 4</span><span
|
---|
3464 | class="cmtt-8"> bits</span><span
|
---|
3465 | class="cmtt-8"> as</span><span
|
---|
3466 | class="cmtt-8"> unsigned</span><span
|
---|
3467 | class="cmtt-8"> integer)</span><br class="fancyvrb" /><a
|
---|
3468 | id="x1-63016r8"></a><span
|
---|
3469 | class="cmr-6">8</span><span
|
---|
3470 | class="cmtt-8"> 8)</span><span
|
---|
3471 | class="cmtt-8"> [blocksize</span><span
|
---|
3472 | class="cmtt-8">_1]</span><span
|
---|
3473 | class="cmtt-8"> =</span><span
|
---|
3474 | class="cmtt-8"> 2</span><span
|
---|
3475 | class="cmtt-8"> exponent</span><span
|
---|
3476 | class="cmtt-8"> (read</span><span
|
---|
3477 | class="cmtt-8"> 4</span><span
|
---|
3478 | class="cmtt-8"> bits</span><span
|
---|
3479 | class="cmtt-8"> as</span><span
|
---|
3480 | class="cmtt-8"> unsigned</span><span
|
---|
3481 | class="cmtt-8"> integer)</span>
|
---|
3482 | <br class="fancyvrb" /><a
|
---|
3483 | id="x1-63018r9"></a><span
|
---|
3484 | class="cmr-6">9</span><span
|
---|
3485 | class="cmtt-8"> 9)</span><span
|
---|
3486 | class="cmtt-8"> [framing</span><span
|
---|
3487 | class="cmtt-8">_flag]</span><span
|
---|
3488 | class="cmtt-8"> =</span><span
|
---|
3489 | class="cmtt-8"> read</span><span
|
---|
3490 | class="cmtt-8"> one</span><span
|
---|
3491 | class="cmtt-8"> bit</span></div>
|
---|
3492 | <!--l. 62--><p class="noindent" ><span
|
---|
3493 | class="cmtt-12">[vorbis</span><span
|
---|
3494 | class="cmtt-12">_version] </span>is to read ’0’ in order to be compatible with this document. Both
|
---|
3495 | <span
|
---|
3496 | class="cmtt-12">[audio</span><span
|
---|
3497 | class="cmtt-12">_channels] </span>and <span
|
---|
3498 | class="cmtt-12">[audio</span><span
|
---|
3499 | class="cmtt-12">_sample</span><span
|
---|
3500 | class="cmtt-12">_rate] </span>must read greater than zero. Allowed final
|
---|
3501 | blocksize values are 64, 128, 256, 512, 1024, 2048, 4096 and 8192 in Vorbis I. <span
|
---|
3502 | class="cmtt-12">[blocksize</span><span
|
---|
3503 | class="cmtt-12">_0]</span>
|
---|
3504 | must be less than or equal to <span
|
---|
3505 | class="cmtt-12">[blocksize</span><span
|
---|
3506 | class="cmtt-12">_1]</span>. The framing bit must be nonzero. Failure to meet
|
---|
3507 | any 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
|
---|
3509 | considerably off in purely VBR streams. The fields are meaningful only when greater than
|
---|
3510 | zero.
|
---|
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
|
---|
3527 | href="#x1-820005">section 5</a>, “<a
|
---|
3528 | href="#x1-820005">comment field and
|
---|
3529 | header specification<!--tex4ht:ref: vorbis:spec:comment --></a>”.
|
---|
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
|
---|
3539 | src="components.png" alt="PIC"
|
---|
3540 | >
|
---|
3541 | <br /> <div class="caption"
|
---|
3542 | ><span class="id">Figure 6: </span><span
|
---|
3543 | class="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
|
---|
3546 | header contains, in order, the lists of codebook configurations, time-domain transform
|
---|
3547 | configurations (placeholders in Vorbis I), floor configurations, residue configurations, channel
|
---|
3548 | mapping configurations and mode configurations. It finishes with a framing bit of ’1’. Header
|
---|
3549 | decode proceeds in the following order:
|
---|
3550 | <!--l. 107--><p class="noindent" ><span class="paragraphHead"><a
|
---|
3551 | id="x1-660004.2.4"></a><span
|
---|
3552 | class="cmbx-12">Codebooks</span></span>
|
---|
3553 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3554 | 1. </dt><dd
|
---|
3555 | class="enumerate-enumitem"><span
|
---|
3556 | class="cmtt-12">[vorbis</span><span
|
---|
3557 | class="cmtt-12">_codebook</span><span
|
---|
3558 | class="cmtt-12">_count] </span>= read eight bits as unsigned integer and add one
|
---|
3559 | </dd><dt class="enumerate-enumitem">
|
---|
3560 | 2. </dt><dd
|
---|
3561 | class="enumerate-enumitem">Decode <span
|
---|
3562 | class="cmtt-12">[vorbis</span><span
|
---|
3563 | class="cmtt-12">_codebook</span><span
|
---|
3564 | class="cmtt-12">_count] </span>codebooks in order as defined in <a
|
---|
3565 | href="#x1-470003">section 3</a>,
|
---|
3566 | “<a
|
---|
3567 | href="#x1-470003">Probability Model and Codebooks<!--tex4ht:ref: vorbis:spec:codebook --></a>”. Save each configuration, in order, in an array
|
---|
3568 | of codebook configurations <span
|
---|
3569 | class="cmtt-12">[vorbis</span><span
|
---|
3570 | class="cmtt-12">_codebook</span><span
|
---|
3571 | class="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
|
---|
3577 | class="cmbx-12">Time domain transforms</span></span>
|
---|
3578 | These hooks are placeholders in Vorbis I. Nevertheless, the configuration placeholder values must
|
---|
3579 | be read to maintain bitstream sync.
|
---|
3580 | <!--l. 126--><p class="noindent" >
|
---|
3581 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3582 | 1. </dt><dd
|
---|
3583 | class="enumerate-enumitem"><span
|
---|
3584 | class="cmtt-12">[vorbis</span><span
|
---|
3585 | class="cmtt-12">_time</span><span
|
---|
3586 | class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
|
---|
3587 | </dd><dt class="enumerate-enumitem">
|
---|
3588 | 2. </dt><dd
|
---|
3589 | class="enumerate-enumitem">read <span
|
---|
3590 | class="cmtt-12">[vorbis</span><span
|
---|
3591 | class="cmtt-12">_time</span><span
|
---|
3592 | class="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
|
---|
3596 | class="cmbx-12">Floors</span></span>
|
---|
3597 | Vorbis uses two floor types; header decode is handed to the decode abstraction of the appropriate
|
---|
3598 | type.
|
---|
3599 | <!--l. 138--><p class="noindent" >
|
---|
3600 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3601 | 1. </dt><dd
|
---|
3602 | class="enumerate-enumitem"><span
|
---|
3603 | class="cmtt-12">[vorbis</span><span
|
---|
3604 | class="cmtt-12">_floor</span><span
|
---|
3605 | class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
|
---|
3606 | </dd><dt class="enumerate-enumitem">
|
---|
3607 | 2. </dt><dd
|
---|
3608 | class="enumerate-enumitem">For each <span
|
---|
3609 | class="cmtt-12">[i] </span>of <span
|
---|
3610 | class="cmtt-12">[vorbis</span><span
|
---|
3611 | class="cmtt-12">_floor</span><span
|
---|
3612 | class="cmtt-12">_count] </span>floor numbers:
|
---|
3613 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3614 | a) </dt><dd
|
---|
3615 | class="enumerate-enumitem">read the floor type: vector <span
|
---|
3616 | class="cmtt-12">[vorbis</span><span
|
---|
3617 | class="cmtt-12">_floor</span><span
|
---|
3618 | class="cmtt-12">_types] </span>element <span
|
---|
3619 | class="cmtt-12">[i] </span>= read 16 bits
|
---|
3620 | as unsigned integer
|
---|
3621 | </dd><dt class="enumerate-enumitem">
|
---|
3622 | b) </dt><dd
|
---|
3623 | class="enumerate-enumitem">If the floor type is zero, decode the floor configuration as defined in <a
|
---|
3624 | href="#x1-900006">section 6</a>,
|
---|
3625 | “<a
|
---|
3626 | href="#x1-900006">Floor type 0 setup and decode<!--tex4ht:ref: vorbis:spec:floor0 --></a>”; save this configuration in slot <span
|
---|
3627 | class="cmtt-12">[i] </span>of the floor
|
---|
3628 | configuration array <span
|
---|
3629 | class="cmtt-12">[vorbis</span><span
|
---|
3630 | class="cmtt-12">_floor</span><span
|
---|
3631 | class="cmtt-12">_configurations]</span>.
|
---|
3632 | </dd><dt class="enumerate-enumitem">
|
---|
3633 | c) </dt><dd
|
---|
3634 | class="enumerate-enumitem">If the floor type is one, decode the floor configuration as defined in <a
|
---|
3635 | href="#x1-970007">section 7</a>,
|
---|
3636 | “<a
|
---|
3637 | href="#x1-970007">Floor type 1 setup and decode<!--tex4ht:ref: vorbis:spec:floor1 --></a>”; save this configuration in slot <span
|
---|
3638 | class="cmtt-12">[i] </span>of the floor
|
---|
3639 | configuration array <span
|
---|
3640 | class="cmtt-12">[vorbis</span><span
|
---|
3641 | class="cmtt-12">_floor</span><span
|
---|
3642 | class="cmtt-12">_configurations]</span>.
|
---|
3643 | </dd><dt class="enumerate-enumitem">
|
---|
3644 | d) </dt><dd
|
---|
3645 | class="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
|
---|
3653 | class="cmbx-12">Residues</span></span>
|
---|
3654 | Vorbis 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
|
---|
3658 | class="enumerate-enumitem"><span
|
---|
3659 | class="cmtt-12">[vorbis</span><span
|
---|
3660 | class="cmtt-12">_residue</span><span
|
---|
3661 | class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
|
---|
3662 | </dd><dt class="enumerate-enumitem">
|
---|
3663 | 2. </dt><dd
|
---|
3664 | class="enumerate-enumitem">For each of <span
|
---|
3665 | class="cmtt-12">[vorbis</span><span
|
---|
3666 | class="cmtt-12">_residue</span><span
|
---|
3667 | class="cmtt-12">_count] </span>residue numbers:
|
---|
3668 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3669 | a) </dt><dd
|
---|
3670 | class="enumerate-enumitem">read the residue type; vector <span
|
---|
3671 | class="cmtt-12">[vorbis</span><span
|
---|
3672 | class="cmtt-12">_residue</span><span
|
---|
3673 | class="cmtt-12">_types] </span>element <span
|
---|
3674 | class="cmtt-12">[i] </span>= read 16
|
---|
3675 | bits as unsigned integer
|
---|
3676 | </dd><dt class="enumerate-enumitem">
|
---|
3677 | b) </dt><dd
|
---|
3678 | class="enumerate-enumitem">If the residue type is zero, one or two, decode the residue configuration as defined
|
---|
3679 | in <a
|
---|
3680 | href="#x1-1040008">section 8</a>, “<a
|
---|
3681 | href="#x1-1040008">Residue setup and decode<!--tex4ht:ref: vorbis:spec:residue --></a>”; save this configuration in slot <span
|
---|
3682 | class="cmtt-12">[i] </span>of
|
---|
3683 | the residue configuration array <span
|
---|
3684 | class="cmtt-12">[vorbis</span><span
|
---|
3685 | class="cmtt-12">_residue</span><span
|
---|
3686 | class="cmtt-12">_configurations]</span>.
|
---|
3687 | </dd><dt class="enumerate-enumitem">
|
---|
3688 | c) </dt><dd
|
---|
3689 | class="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
|
---|
3694 | class="cmbx-12">Mappings</span></span>
|
---|
3695 | Mappings are used to set up specific pipelines for encoding multichannel audio with varying
|
---|
3696 | channel mapping applications. Vorbis I uses a single mapping type (0), with implicit PCM
|
---|
3697 | channel mappings.
|
---|
3698 | <!--l. 187--><p class="noindent" >
|
---|
3699 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3700 | 1. </dt><dd
|
---|
3701 | class="enumerate-enumitem"><span
|
---|
3702 | class="cmtt-12">[vorbis</span><span
|
---|
3703 | class="cmtt-12">_mapping</span><span
|
---|
3704 | class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
|
---|
3705 | </dd><dt class="enumerate-enumitem">
|
---|
3706 | 2. </dt><dd
|
---|
3707 | class="enumerate-enumitem">For each <span
|
---|
3708 | class="cmtt-12">[i] </span>of <span
|
---|
3709 | class="cmtt-12">[vorbis</span><span
|
---|
3710 | class="cmtt-12">_mapping</span><span
|
---|
3711 | class="cmtt-12">_count] </span>mapping numbers:
|
---|
3712 |
|
---|
3713 |
|
---|
3714 |
|
---|
3715 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3716 | a) </dt><dd
|
---|
3717 | class="enumerate-enumitem">read the mapping type: 16 bits as unsigned integer. There’s no reason to save
|
---|
3718 | the mapping type in Vorbis I.
|
---|
3719 | </dd><dt class="enumerate-enumitem">
|
---|
3720 | b) </dt><dd
|
---|
3721 | class="enumerate-enumitem">If the mapping type is nonzero, the stream is undecodable
|
---|
3722 | </dd><dt class="enumerate-enumitem">
|
---|
3723 | c) </dt><dd
|
---|
3724 | class="enumerate-enumitem">If the mapping type is zero:
|
---|
3725 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3726 | i. </dt><dd
|
---|
3727 | class="enumerate-enumitem">read 1 bit as a boolean flag
|
---|
3728 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3729 | A. </dt><dd
|
---|
3730 | class="enumerate-enumitem">if set, <span
|
---|
3731 | class="cmtt-12">[vorbis</span><span
|
---|
3732 | class="cmtt-12">_mapping</span><span
|
---|
3733 | class="cmtt-12">_submaps] </span>= read 4 bits as unsigned integer
|
---|
3734 | and add one
|
---|
3735 | </dd><dt class="enumerate-enumitem">
|
---|
3736 | B. </dt><dd
|
---|
3737 | class="enumerate-enumitem">if unset, <span
|
---|
3738 | class="cmtt-12">[vorbis</span><span
|
---|
3739 | class="cmtt-12">_mapping</span><span
|
---|
3740 | class="cmtt-12">_submaps] </span>= 1</dd></dl>
|
---|
3741 | </dd><dt class="enumerate-enumitem">
|
---|
3742 | ii. </dt><dd
|
---|
3743 | class="enumerate-enumitem">read 1 bit as a boolean flag
|
---|
3744 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3745 | A. </dt><dd
|
---|
3746 | class="enumerate-enumitem">if set, square polar channel mapping is in use:
|
---|
3747 | <ul class="itemize1">
|
---|
3748 | <li class="itemize"><span
|
---|
3749 | class="cmtt-12">[vorbis</span><span
|
---|
3750 | class="cmtt-12">_mapping</span><span
|
---|
3751 | class="cmtt-12">_coupling</span><span
|
---|
3752 | class="cmtt-12">_steps] </span>= read 8 bits as unsigned
|
---|
3753 | integer and add one
|
---|
3754 | </li>
|
---|
3755 | <li class="itemize">for <span
|
---|
3756 | class="cmtt-12">[j] </span>each of <span
|
---|
3757 | class="cmtt-12">[vorbis</span><span
|
---|
3758 | class="cmtt-12">_mapping</span><span
|
---|
3759 | class="cmtt-12">_coupling</span><span
|
---|
3760 | class="cmtt-12">_steps] </span>steps:
|
---|
3761 | <ul class="itemize2">
|
---|
3762 | <li class="itemize">vector <span
|
---|
3763 | class="cmtt-12">[vorbis</span><span
|
---|
3764 | class="cmtt-12">_mapping</span><span
|
---|
3765 | class="cmtt-12">_magnitude] </span>element <span
|
---|
3766 | class="cmtt-12">[j]</span>= read
|
---|
3767 | <a
|
---|
3768 | href="#x1-1190009.2.1">ilog</a>(<span
|
---|
3769 | class="cmtt-12">[audio</span><span
|
---|
3770 | class="cmtt-12">_channels] </span>- 1) bits as unsigned integer
|
---|
3771 | </li>
|
---|
3772 | <li class="itemize">vector <span
|
---|
3773 | class="cmtt-12">[vorbis</span><span
|
---|
3774 | class="cmtt-12">_mapping</span><span
|
---|
3775 | class="cmtt-12">_angle] </span>element <span
|
---|
3776 | class="cmtt-12">[j]</span>= read
|
---|
3777 | <a
|
---|
3778 | href="#x1-1190009.2.1">ilog</a>(<span
|
---|
3779 | class="cmtt-12">[audio</span><span
|
---|
3780 | class="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
|
---|
3787 | class="cmtt-12">[audio</span><span
|
---|
3788 | class="cmtt-12">_channels]</span>-1, or
|
---|
3789 | the angle channel is greater than <span
|
---|
3790 | class="cmtt-12">[audio</span><span
|
---|
3791 | class="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
|
---|
3799 | class="enumerate-enumitem">if unset, <span
|
---|
3800 | class="cmtt-12">[vorbis</span><span
|
---|
3801 | class="cmtt-12">_mapping</span><span
|
---|
3802 | class="cmtt-12">_coupling</span><span
|
---|
3803 | class="cmtt-12">_steps] </span>= 0</dd></dl>
|
---|
3804 | </dd><dt class="enumerate-enumitem">
|
---|
3805 | iii. </dt><dd
|
---|
3806 | class="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
|
---|
3809 | class="enumerate-enumitem">if <span
|
---|
3810 | class="cmtt-12">[vorbis</span><span
|
---|
3811 | class="cmtt-12">_mapping</span><span
|
---|
3812 | class="cmtt-12">_submaps] </span>is greater than one, we read channel multiplex
|
---|
3813 | settings. For each <span
|
---|
3814 | class="cmtt-12">[j] </span>of <span
|
---|
3815 | class="cmtt-12">[audio</span><span
|
---|
3816 | class="cmtt-12">_channels] </span>channels:
|
---|
3817 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3818 | A. </dt><dd
|
---|
3819 | class="enumerate-enumitem">vector <span
|
---|
3820 | class="cmtt-12">[vorbis</span><span
|
---|
3821 | class="cmtt-12">_mapping</span><span
|
---|
3822 | class="cmtt-12">_mux] </span>element <span
|
---|
3823 | class="cmtt-12">[j] </span>= read 4 bits as unsigned
|
---|
3824 | integer
|
---|
3825 | </dd><dt class="enumerate-enumitem">
|
---|
3826 | B. </dt><dd
|
---|
3827 | class="enumerate-enumitem">if the value is greater than the highest numbered submap
|
---|
3828 | (<span
|
---|
3829 | class="cmtt-12">[vorbis</span><span
|
---|
3830 | class="cmtt-12">_mapping</span><span
|
---|
3831 | class="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
|
---|
3835 | class="enumerate-enumitem">for each submap <span
|
---|
3836 | class="cmtt-12">[j] </span>of <span
|
---|
3837 | class="cmtt-12">[vorbis</span><span
|
---|
3838 | class="cmtt-12">_mapping</span><span
|
---|
3839 | class="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
|
---|
3843 | class="enumerate-enumitem">read and discard 8 bits (the unused time configuration placeholder)
|
---|
3844 | </dd><dt class="enumerate-enumitem">
|
---|
3845 | B. </dt><dd
|
---|
3846 | class="enumerate-enumitem">read 8 bits as unsigned integer for the floor number; save in vector
|
---|
3847 | <span
|
---|
3848 | class="cmtt-12">[vorbis</span><span
|
---|
3849 | class="cmtt-12">_mapping</span><span
|
---|
3850 | class="cmtt-12">_submap</span><span
|
---|
3851 | class="cmtt-12">_floor] </span>element <span
|
---|
3852 | class="cmtt-12">[j]</span>
|
---|
3853 | </dd><dt class="enumerate-enumitem">
|
---|
3854 | C. </dt><dd
|
---|
3855 | class="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
|
---|
3859 | class="enumerate-enumitem">read 8 bits as unsigned integer for the residue number; save in vector
|
---|
3860 | <span
|
---|
3861 | class="cmtt-12">[vorbis</span><span
|
---|
3862 | class="cmtt-12">_mapping</span><span
|
---|
3863 | class="cmtt-12">_submap</span><span
|
---|
3864 | class="cmtt-12">_residue] </span>element <span
|
---|
3865 | class="cmtt-12">[j]</span>
|
---|
3866 | </dd><dt class="enumerate-enumitem">
|
---|
3867 | E. </dt><dd
|
---|
3868 | class="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
|
---|
3872 | class="enumerate-enumitem">save this mapping configuration in slot <span
|
---|
3873 | class="cmtt-12">[i] </span>of the mapping configuration array
|
---|
3874 | <span
|
---|
3875 | class="cmtt-12">[vorbis</span><span
|
---|
3876 | class="cmtt-12">_mapping</span><span
|
---|
3877 | class="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
|
---|
3885 | class="cmbx-12">Modes</span></span>
|
---|
3886 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3887 | 1. </dt><dd
|
---|
3888 | class="enumerate-enumitem"><span
|
---|
3889 | class="cmtt-12">[vorbis</span><span
|
---|
3890 | class="cmtt-12">_mode</span><span
|
---|
3891 | class="cmtt-12">_count] </span>= read 6 bits as unsigned integer and add one
|
---|
3892 | </dd><dt class="enumerate-enumitem">
|
---|
3893 | 2. </dt><dd
|
---|
3894 | class="enumerate-enumitem">For each of <span
|
---|
3895 | class="cmtt-12">[vorbis</span><span
|
---|
3896 | class="cmtt-12">_mode</span><span
|
---|
3897 | class="cmtt-12">_count] </span>mode numbers:
|
---|
3898 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
3899 | a) </dt><dd
|
---|
3900 | class="enumerate-enumitem"><span
|
---|
3901 | class="cmtt-12">[vorbis</span><span
|
---|
3902 | class="cmtt-12">_mode</span><span
|
---|
3903 | class="cmtt-12">_blockflag] </span>= read 1 bit
|
---|
3904 | </dd><dt class="enumerate-enumitem">
|
---|
3905 | b) </dt><dd
|
---|
3906 | class="enumerate-enumitem"><span
|
---|
3907 | class="cmtt-12">[vorbis</span><span
|
---|
3908 | class="cmtt-12">_mode</span><span
|
---|
3909 | class="cmtt-12">_windowtype] </span>= read 16 bits as unsigned integer
|
---|
3910 | </dd><dt class="enumerate-enumitem">
|
---|
3911 | c) </dt><dd
|
---|
3912 | class="enumerate-enumitem"><span
|
---|
3913 | class="cmtt-12">[vorbis</span><span
|
---|
3914 | class="cmtt-12">_mode</span><span
|
---|
3915 | class="cmtt-12">_transformtype] </span>= read 16 bits as unsigned integer
|
---|
3916 | </dd><dt class="enumerate-enumitem">
|
---|
3917 | d) </dt><dd
|
---|
3918 | class="enumerate-enumitem"><span
|
---|
3919 | class="cmtt-12">[vorbis</span><span
|
---|
3920 | class="cmtt-12">_mode</span><span
|
---|
3921 | class="cmtt-12">_mapping] </span>= read 8 bits as unsigned integer
|
---|
3922 | </dd><dt class="enumerate-enumitem">
|
---|
3923 | e) </dt><dd
|
---|
3924 | class="enumerate-enumitem">verify ranges; zero is the only legal value in
|
---|
3925 | Vorbis I for <span
|
---|
3926 | class="cmtt-12">[vorbis</span><span
|
---|
3927 | class="cmtt-12">_mode</span><span
|
---|
3928 | class="cmtt-12">_windowtype] </span>and <span
|
---|
3929 | class="cmtt-12">[vorbis</span><span
|
---|
3930 | class="cmtt-12">_mode</span><span
|
---|
3931 | class="cmtt-12">_transformtype]</span>.
|
---|
3932 | <span
|
---|
3933 | class="cmtt-12">[vorbis</span><span
|
---|
3934 | class="cmtt-12">_mode</span><span
|
---|
3935 | class="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
|
---|
3939 | class="enumerate-enumitem">save this mode configuration in slot <span
|
---|
3940 | class="cmtt-12">[i] </span>of the mode configuration array
|
---|
3941 | <span
|
---|
3942 | class="cmtt-12">[vorbis</span><span
|
---|
3943 | class="cmtt-12">_mode</span><span
|
---|
3944 | class="cmtt-12">_configurations]</span>.</dd></dl>
|
---|
3945 | </dd><dt class="enumerate-enumitem">
|
---|
3946 | 3. </dt><dd
|
---|
3947 | class="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
|
---|
3957 | audio packet decode is to read and verify the packet type. <span
|
---|
3958 | class="cmti-12">A non-audio packet when audio is</span>
|
---|
3959 | <span
|
---|
3960 | class="cmti-12">expected indicates stream corruption or a non-compliant stream. The decoder must ignore the</span>
|
---|
3961 | <span
|
---|
3962 | class="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
|
---|
3969 | class="enumerate-enumitem">read 1 bit <span
|
---|
3970 | class="cmtt-12">[packet</span><span
|
---|
3971 | class="cmtt-12">_type]</span>; check that packet type is 0 (audio)
|
---|
3972 | </dd><dt class="enumerate-enumitem">
|
---|
3973 | 2. </dt><dd
|
---|
3974 | class="enumerate-enumitem">read <a
|
---|
3975 | href="#x1-1190009.2.1">ilog</a>([vorbis_mode_count]-1) bits <span
|
---|
3976 | class="cmtt-12">[mode</span><span
|
---|
3977 | class="cmtt-12">_number]</span>
|
---|
3978 | </dd><dt class="enumerate-enumitem">
|
---|
3979 | 3. </dt><dd
|
---|
3980 | class="enumerate-enumitem">decode blocksize <span
|
---|
3981 | class="cmtt-12">[n] </span>is equal to <span
|
---|
3982 | class="cmtt-12">[blocksize</span><span
|
---|
3983 | class="cmtt-12">_0] </span>if <span
|
---|
3984 | class="cmtt-12">[vorbis</span><span
|
---|
3985 | class="cmtt-12">_mode</span><span
|
---|
3986 | class="cmtt-12">_blockflag] </span>is 0,
|
---|
3987 | else <span
|
---|
3988 | class="cmtt-12">[n] </span>is equal to <span
|
---|
3989 | class="cmtt-12">[blocksize</span><span
|
---|
3990 | class="cmtt-12">_1]</span>.
|
---|
3991 | </dd><dt class="enumerate-enumitem">
|
---|
3992 | 4. </dt><dd
|
---|
3993 | class="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
|
---|
3997 | class="enumerate-enumitem">if this is a long window (the <span
|
---|
3998 | class="cmtt-12">[vorbis</span><span
|
---|
3999 | class="cmtt-12">_mode</span><span
|
---|
4000 | class="cmtt-12">_blockflag] </span>flag of this mode is
|
---|
4001 | set):
|
---|
4002 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4003 | i. </dt><dd
|
---|
4004 | class="enumerate-enumitem">read 1 bit for <span
|
---|
4005 | class="cmtt-12">[previous</span><span
|
---|
4006 | class="cmtt-12">_window</span><span
|
---|
4007 | class="cmtt-12">_flag]</span>
|
---|
4008 | </dd><dt class="enumerate-enumitem">
|
---|
4009 | ii. </dt><dd
|
---|
4010 | class="enumerate-enumitem">read 1 bit for <span
|
---|
4011 | class="cmtt-12">[next</span><span
|
---|
4012 | class="cmtt-12">_window</span><span
|
---|
4013 | class="cmtt-12">_flag]</span>
|
---|
4014 | </dd><dt class="enumerate-enumitem">
|
---|
4015 | iii. </dt><dd
|
---|
4016 | class="enumerate-enumitem">if <span
|
---|
4017 | class="cmtt-12">[previous</span><span
|
---|
4018 | class="cmtt-12">_window</span><span
|
---|
4019 | class="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
|
---|
4021 | href="#paragraph.1" >paragraph <a
|
---|
4022 | href="#x1-260001.3.2">1.3.2</a></a>,
|
---|
4023 | “<a
|
---|
4024 | href="#x1-260001.3.2">Window shape decode (long windows only)<!--tex4ht:ref: vorbis:spec:window --></a>” 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
|
---|
4029 | class="enumerate-enumitem">if <span
|
---|
4030 | class="cmtt-12">[next</span><span
|
---|
4031 | class="cmtt-12">_window</span><span
|
---|
4032 | class="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
|
---|
4034 | href="#x1-260001.3.2">paragraph 1.3.2</a>,
|
---|
4035 |
|
---|
4036 |
|
---|
4037 |
|
---|
4038 | “<a
|
---|
4039 | href="#x1-260001.3.2">Window shape decode (long windows only)<!--tex4ht:ref: vorbis:spec:window --></a>” 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
|
---|
4044 | class="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
|
---|
4048 | class="cmmi-12">y </span>= sin(<img
|
---|
4049 | src="Vorbis_I_spec1x.png" alt="π
|
---|
4050 | 2" class="frac" align="middle"> <span
|
---|
4051 | class="cmsy-10x-x-120">*</span> sin <sup><span
|
---|
4052 | class="cmr-8">2</span></sup>((<span
|
---|
4053 | class="cmmi-12">x </span>+ 0<span
|
---|
4054 | class="cmmi-12">.</span>5)<span
|
---|
4055 | class="cmmi-12">∕n </span><span
|
---|
4056 | class="cmsy-10x-x-120">* </span><span
|
---|
4057 | class="cmmi-12">π</span>)), where <span
|
---|
4058 | class="cmmi-12">n </span>is window
|
---|
4059 | size and <span
|
---|
4060 | class="cmmi-12">x </span>ranges 0<span
|
---|
4061 | class="cmmi-12">…</span><span
|
---|
4062 | class="cmmi-12">n</span><span
|
---|
4063 | class="cmsy-10x-x-120">- </span>1, but dissimilar lapping requirements can affect overall shape. Window
|
---|
4064 | generation proceeds as follows:
|
---|
4065 | <!--l. 326--><p class="noindent" >
|
---|
4066 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4067 | 1. </dt><dd
|
---|
4068 | class="enumerate-enumitem"><span
|
---|
4069 | class="cmtt-12">[window</span><span
|
---|
4070 | class="cmtt-12">_center] </span>= <span
|
---|
4071 | class="cmtt-12">[n] </span>/ 2
|
---|
4072 | </dd><dt class="enumerate-enumitem">
|
---|
4073 | 2. </dt><dd
|
---|
4074 | class="enumerate-enumitem">if (<span
|
---|
4075 | class="cmtt-12">[vorbis</span><span
|
---|
4076 | class="cmtt-12">_mode</span><span
|
---|
4077 | class="cmtt-12">_blockflag] </span>is set and <span
|
---|
4078 | class="cmtt-12">[previous</span><span
|
---|
4079 | class="cmtt-12">_window</span><span
|
---|
4080 | class="cmtt-12">_flag] </span>is not set)
|
---|
4081 | then
|
---|
4082 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4083 | a) </dt><dd
|
---|
4084 | class="enumerate-enumitem"><span
|
---|
4085 | class="cmtt-12">[left</span><span
|
---|
4086 | class="cmtt-12">_window</span><span
|
---|
4087 | class="cmtt-12">_start] </span>= <span
|
---|
4088 | class="cmtt-12">[n]</span>/4 - <span
|
---|
4089 | class="cmtt-12">[blocksize</span><span
|
---|
4090 | class="cmtt-12">_0]</span>/4
|
---|
4091 | </dd><dt class="enumerate-enumitem">
|
---|
4092 | b) </dt><dd
|
---|
4093 | class="enumerate-enumitem"><span
|
---|
4094 | class="cmtt-12">[left</span><span
|
---|
4095 | class="cmtt-12">_window</span><span
|
---|
4096 | class="cmtt-12">_end] </span>= <span
|
---|
4097 | class="cmtt-12">[n]</span>/4 + <span
|
---|
4098 | class="cmtt-12">[blocksize</span><span
|
---|
4099 | class="cmtt-12">_0]</span>/4
|
---|
4100 | </dd><dt class="enumerate-enumitem">
|
---|
4101 | c) </dt><dd
|
---|
4102 | class="enumerate-enumitem"><span
|
---|
4103 | class="cmtt-12">[left</span><span
|
---|
4104 | class="cmtt-12">_n] </span>= <span
|
---|
4105 | class="cmtt-12">[blocksize</span><span
|
---|
4106 | class="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
|
---|
4110 | class="enumerate-enumitem"><span
|
---|
4111 | class="cmtt-12">[left</span><span
|
---|
4112 | class="cmtt-12">_window</span><span
|
---|
4113 | class="cmtt-12">_start] </span>= 0
|
---|
4114 | </dd><dt class="enumerate-enumitem">
|
---|
4115 | b) </dt><dd
|
---|
4116 | class="enumerate-enumitem"><span
|
---|
4117 | class="cmtt-12">[left</span><span
|
---|
4118 | class="cmtt-12">_window</span><span
|
---|
4119 | class="cmtt-12">_end] </span>= <span
|
---|
4120 | class="cmtt-12">[window</span><span
|
---|
4121 | class="cmtt-12">_center]</span>
|
---|
4122 | </dd><dt class="enumerate-enumitem">
|
---|
4123 | c) </dt><dd
|
---|
4124 | class="enumerate-enumitem"><span
|
---|
4125 | class="cmtt-12">[left</span><span
|
---|
4126 | class="cmtt-12">_n] </span>= <span
|
---|
4127 | class="cmtt-12">[n]</span>/2</dd></dl>
|
---|
4128 | </dd><dt class="enumerate-enumitem">
|
---|
4129 | 3. </dt><dd
|
---|
4130 | class="enumerate-enumitem">if (<span
|
---|
4131 | class="cmtt-12">[vorbis</span><span
|
---|
4132 | class="cmtt-12">_mode</span><span
|
---|
4133 | class="cmtt-12">_blockflag] </span>is set and <span
|
---|
4134 | class="cmtt-12">[next</span><span
|
---|
4135 | class="cmtt-12">_window</span><span
|
---|
4136 | class="cmtt-12">_flag] </span>is not set) then
|
---|
4137 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4138 | a) </dt><dd
|
---|
4139 | class="enumerate-enumitem"><span
|
---|
4140 | class="cmtt-12">[right</span><span
|
---|
4141 | class="cmtt-12">_window</span><span
|
---|
4142 | class="cmtt-12">_start] </span>= <span
|
---|
4143 | class="cmtt-12">[n]*3</span>/4 - <span
|
---|
4144 | class="cmtt-12">[blocksize</span><span
|
---|
4145 | class="cmtt-12">_0]</span>/4
|
---|
4146 | </dd><dt class="enumerate-enumitem">
|
---|
4147 | b) </dt><dd
|
---|
4148 | class="enumerate-enumitem"><span
|
---|
4149 | class="cmtt-12">[right</span><span
|
---|
4150 | class="cmtt-12">_window</span><span
|
---|
4151 | class="cmtt-12">_end] </span>= <span
|
---|
4152 | class="cmtt-12">[n]*3</span>/4 + <span
|
---|
4153 | class="cmtt-12">[blocksize</span><span
|
---|
4154 | class="cmtt-12">_0]</span>/4
|
---|
4155 |
|
---|
4156 |
|
---|
4157 |
|
---|
4158 | </dd><dt class="enumerate-enumitem">
|
---|
4159 | c) </dt><dd
|
---|
4160 | class="enumerate-enumitem"><span
|
---|
4161 | class="cmtt-12">[right</span><span
|
---|
4162 | class="cmtt-12">_n] </span>= <span
|
---|
4163 | class="cmtt-12">[blocksize</span><span
|
---|
4164 | class="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
|
---|
4168 | class="enumerate-enumitem"><span
|
---|
4169 | class="cmtt-12">[right</span><span
|
---|
4170 | class="cmtt-12">_window</span><span
|
---|
4171 | class="cmtt-12">_start] </span>= <span
|
---|
4172 | class="cmtt-12">[window</span><span
|
---|
4173 | class="cmtt-12">_center]</span>
|
---|
4174 | </dd><dt class="enumerate-enumitem">
|
---|
4175 | b) </dt><dd
|
---|
4176 | class="enumerate-enumitem"><span
|
---|
4177 | class="cmtt-12">[right</span><span
|
---|
4178 | class="cmtt-12">_window</span><span
|
---|
4179 | class="cmtt-12">_end] </span>= <span
|
---|
4180 | class="cmtt-12">[n]</span>
|
---|
4181 | </dd><dt class="enumerate-enumitem">
|
---|
4182 | c) </dt><dd
|
---|
4183 | class="enumerate-enumitem"><span
|
---|
4184 | class="cmtt-12">[right</span><span
|
---|
4185 | class="cmtt-12">_n] </span>= <span
|
---|
4186 | class="cmtt-12">[n]</span>/2</dd></dl>
|
---|
4187 | </dd><dt class="enumerate-enumitem">
|
---|
4188 | 4. </dt><dd
|
---|
4189 | class="enumerate-enumitem">window from range 0 ... <span
|
---|
4190 | class="cmtt-12">[left</span><span
|
---|
4191 | class="cmtt-12">_window</span><span
|
---|
4192 | class="cmtt-12">_start]</span>-1 inclusive is zero
|
---|
4193 | </dd><dt class="enumerate-enumitem">
|
---|
4194 | 5. </dt><dd
|
---|
4195 | class="enumerate-enumitem">for <span
|
---|
4196 | class="cmtt-12">[i] </span>in range <span
|
---|
4197 | class="cmtt-12">[left</span><span
|
---|
4198 | class="cmtt-12">_window</span><span
|
---|
4199 | class="cmtt-12">_start] </span>... <span
|
---|
4200 | class="cmtt-12">[left</span><span
|
---|
4201 | class="cmtt-12">_window</span><span
|
---|
4202 | class="cmtt-12">_end]</span>-1, window(<span
|
---|
4203 | class="cmtt-12">[i]</span>) =
|
---|
4204 | sin(<img
|
---|
4205 | src="Vorbis_I_spec2x.png" alt="π
|
---|
4206 | 2" class="frac" align="middle"> <span
|
---|
4207 | class="cmsy-10x-x-120">*</span> sin <sup><span
|
---|
4208 | class="cmr-8">2</span></sup>( (<span
|
---|
4209 | class="cmtt-12">[i]</span>-<span
|
---|
4210 | class="cmtt-12">[left</span><span
|
---|
4211 | class="cmtt-12">_window</span><span
|
---|
4212 | class="cmtt-12">_start]</span>+0.5) / <span
|
---|
4213 | class="cmtt-12">[left</span><span
|
---|
4214 | class="cmtt-12">_n] </span><span
|
---|
4215 | class="cmsy-10x-x-120">*</span><img
|
---|
4216 | src="Vorbis_I_spec3x.png" alt="π
|
---|
4217 | 2" class="frac" align="middle">) )
|
---|
4218 | </dd><dt class="enumerate-enumitem">
|
---|
4219 | 6. </dt><dd
|
---|
4220 | class="enumerate-enumitem">window from range <span
|
---|
4221 | class="cmtt-12">[left</span><span
|
---|
4222 | class="cmtt-12">_window</span><span
|
---|
4223 | class="cmtt-12">_end] </span>... <span
|
---|
4224 | class="cmtt-12">[right</span><span
|
---|
4225 | class="cmtt-12">_window</span><span
|
---|
4226 | class="cmtt-12">_start]</span>-1 inclusive is
|
---|
4227 | one
|
---|
4228 | </dd><dt class="enumerate-enumitem">
|
---|
4229 | 7. </dt><dd
|
---|
4230 | class="enumerate-enumitem">for <span
|
---|
4231 | class="cmtt-12">[i] </span>in range <span
|
---|
4232 | class="cmtt-12">[right</span><span
|
---|
4233 | class="cmtt-12">_window</span><span
|
---|
4234 | class="cmtt-12">_start] </span>... <span
|
---|
4235 | class="cmtt-12">[right</span><span
|
---|
4236 | class="cmtt-12">_window</span><span
|
---|
4237 | class="cmtt-12">_end]</span>-1, window(<span
|
---|
4238 | class="cmtt-12">[i]</span>) =
|
---|
4239 | sin(<img
|
---|
4240 | src="Vorbis_I_spec4x.png" alt="π2" class="frac" align="middle"> <span
|
---|
4241 | class="cmsy-10x-x-120">*</span> sin <sup><span
|
---|
4242 | class="cmr-8">2</span></sup>( (<span
|
---|
4243 | class="cmtt-12">[i]</span>-<span
|
---|
4244 | class="cmtt-12">[right</span><span
|
---|
4245 | class="cmtt-12">_window</span><span
|
---|
4246 | class="cmtt-12">_start]</span>+0.5) / <span
|
---|
4247 | class="cmtt-12">[right</span><span
|
---|
4248 | class="cmtt-12">_n] </span><span
|
---|
4249 | class="cmsy-10x-x-120">*</span><img
|
---|
4250 | src="Vorbis_I_spec5x.png" alt="π2" class="frac" align="middle"> + <img
|
---|
4251 | src="Vorbis_I_spec6x.png" alt="π2" class="frac" align="middle">) )
|
---|
4252 | </dd><dt class="enumerate-enumitem">
|
---|
4253 | 8. </dt><dd
|
---|
4254 | class="enumerate-enumitem">window from range <span
|
---|
4255 | class="cmtt-12">[right</span><span
|
---|
4256 | class="cmtt-12">_window</span><span
|
---|
4257 | class="cmtt-12">_start] </span>... <span
|
---|
4258 | class="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
|
---|
4260 | packet from the stream. An end of packet condition past this point is to be considered a possible
|
---|
4261 | nominal 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
|
---|
4266 | class="cmtt-12">[mode</span><span
|
---|
4267 | class="cmtt-12">_number]</span>
|
---|
4268 | from configuration array <span
|
---|
4269 | class="cmtt-12">[vorbis</span><span
|
---|
4270 | class="cmtt-12">_mode</span><span
|
---|
4271 | class="cmtt-12">_configurations] </span>and the map number
|
---|
4272 | <span
|
---|
4273 | class="cmtt-12">[vorbis</span><span
|
---|
4274 | class="cmtt-12">_mode</span><span
|
---|
4275 | class="cmtt-12">_mapping] </span>(specified by the current mode) taken from the mapping configuration
|
---|
4276 | array <span
|
---|
4277 | class="cmtt-12">[vorbis</span><span
|
---|
4278 | class="cmtt-12">_mapping</span><span
|
---|
4279 | class="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
|
---|
4285 | class="cmtt-12">[i] </span>of <span
|
---|
4286 | class="cmtt-12">[audio</span><span
|
---|
4287 | class="cmtt-12">_channels]</span>
|
---|
4288 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4289 | 1. </dt><dd
|
---|
4290 | class="enumerate-enumitem"><span
|
---|
4291 | class="cmtt-12">[submap</span><span
|
---|
4292 | class="cmtt-12">_number] </span>= element <span
|
---|
4293 | class="cmtt-12">[i] </span>of vector [vorbis_mapping_mux]
|
---|
4294 | </dd><dt class="enumerate-enumitem">
|
---|
4295 | 2. </dt><dd
|
---|
4296 | class="enumerate-enumitem"><span
|
---|
4297 | class="cmtt-12">[floor</span><span
|
---|
4298 | class="cmtt-12">_number] </span>= element <span
|
---|
4299 | class="cmtt-12">[submap</span><span
|
---|
4300 | class="cmtt-12">_number] </span>of vector [vorbis_submap_floor]
|
---|
4301 | </dd><dt class="enumerate-enumitem">
|
---|
4302 | 3. </dt><dd
|
---|
4303 | class="enumerate-enumitem">if the floor type of this floor (vector
|
---|
4304 | <span
|
---|
4305 | class="cmtt-12">[vorbis</span><span
|
---|
4306 | class="cmtt-12">_floor</span><span
|
---|
4307 | class="cmtt-12">_types] </span>element <span
|
---|
4308 | class="cmtt-12">[floor</span><span
|
---|
4309 | class="cmtt-12">_number]</span>) is zero then decode the floor for
|
---|
4310 | channel <span
|
---|
4311 | class="cmtt-12">[i] </span>according to the <a
|
---|
4312 | href="#x1-940006.2.2">subsubsection 6.2.2</a>, “<a
|
---|
4313 | href="#x1-940006.2.2">packet decode<!--tex4ht:ref: vorbis:spec:floor0-decode --></a>”
|
---|
4314 | </dd><dt class="enumerate-enumitem">
|
---|
4315 | 4. </dt><dd
|
---|
4316 | class="enumerate-enumitem">if the type of this floor is one then decode the floor for channel <span
|
---|
4317 | class="cmtt-12">[i] </span>according to the
|
---|
4318 | <a
|
---|
4319 | href="#x1-1020007.2.3">subsubsection 7.2.3</a>, “<a
|
---|
4320 | href="#x1-1020007.2.3">packet decode<!--tex4ht:ref: vorbis:spec:floor1-decode --></a>”
|
---|
4321 | </dd><dt class="enumerate-enumitem">
|
---|
4322 | 5. </dt><dd
|
---|
4323 | class="enumerate-enumitem">save the needed decoded floor information for channel for later synthesis
|
---|
4324 | </dd><dt class="enumerate-enumitem">
|
---|
4325 | 6. </dt><dd
|
---|
4326 | class="enumerate-enumitem">if the decoded floor returned ’unused’, set vector <span
|
---|
4327 | class="cmtt-12">[no</span><span
|
---|
4328 | class="cmtt-12">_residue] </span>element <span
|
---|
4329 | class="cmtt-12">[i] </span>to true,
|
---|
4330 | else set vector <span
|
---|
4331 | class="cmtt-12">[no</span><span
|
---|
4332 | class="cmtt-12">_residue] </span>element <span
|
---|
4333 | class="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
|
---|
4335 | output 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 ’unused’ which indicates that
|
---|
4340 | that final output vector is all-zero values (and the floor is zero). The residue for that vector is not
|
---|
4341 | coded in the stream, save for one complication. If some vectors are used and some are not,
|
---|
4342 | channel coupling could result in mixing a zeroed and nonzeroed vector to produce two nonzeroed
|
---|
4343 | vectors.
|
---|
4344 | <!--l. 420--><p class="noindent" >for each <span
|
---|
4345 | class="cmtt-12">[i] </span>from 0 ... <span
|
---|
4346 | class="cmtt-12">[vorbis</span><span
|
---|
4347 | class="cmtt-12">_mapping</span><span
|
---|
4348 | class="cmtt-12">_coupling</span><span
|
---|
4349 | class="cmtt-12">_steps]</span>-1
|
---|
4350 | <!--l. 423--><p class="noindent" >
|
---|
4351 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4352 | 1. </dt><dd
|
---|
4353 | class="enumerate-enumitem">if either <span
|
---|
4354 | class="cmtt-12">[no</span><span
|
---|
4355 | class="cmtt-12">_residue] </span>entry for channel (<span
|
---|
4356 | class="cmtt-12">[vorbis</span><span
|
---|
4357 | class="cmtt-12">_mapping</span><span
|
---|
4358 | class="cmtt-12">_magnitude] </span>element
|
---|
4359 | <span
|
---|
4360 | class="cmtt-12">[i]</span>) or channel (<span
|
---|
4361 | class="cmtt-12">[vorbis</span><span
|
---|
4362 | class="cmtt-12">_mapping</span><span
|
---|
4363 | class="cmtt-12">_angle] </span>element <span
|
---|
4364 | class="cmtt-12">[i]</span>) are set to false, then both
|
---|
4365 | must be set to false. Note that an ’unused’ 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
|
---|
4374 | order.
|
---|
4375 | <!--l. 440--><p class="noindent" >for each submap <span
|
---|
4376 | class="cmtt-12">[i] </span>in order from 0 ... <span
|
---|
4377 | class="cmtt-12">[vorbis</span><span
|
---|
4378 | class="cmtt-12">_mapping</span><span
|
---|
4379 | class="cmtt-12">_submaps]</span>-1
|
---|
4380 | <!--l. 443--><p class="noindent" >
|
---|
4381 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4382 | 1. </dt><dd
|
---|
4383 | class="enumerate-enumitem"><span
|
---|
4384 | class="cmtt-12">[ch] </span>= 0
|
---|
4385 | </dd><dt class="enumerate-enumitem">
|
---|
4386 | 2. </dt><dd
|
---|
4387 | class="enumerate-enumitem">for each channel <span
|
---|
4388 | class="cmtt-12">[j] </span>in order from 0 ... <span
|
---|
4389 | class="cmtt-12">[audio</span><span
|
---|
4390 | class="cmtt-12">_channels] </span>- 1
|
---|
4391 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4392 | a) </dt><dd
|
---|
4393 | class="enumerate-enumitem">if channel <span
|
---|
4394 | class="cmtt-12">[j] </span>in submap <span
|
---|
4395 | class="cmtt-12">[i] </span>(vector <span
|
---|
4396 | class="cmtt-12">[vorbis</span><span
|
---|
4397 | class="cmtt-12">_mapping</span><span
|
---|
4398 | class="cmtt-12">_mux] </span>element <span
|
---|
4399 | class="cmtt-12">[j] </span>is equal to
|
---|
4400 | <span
|
---|
4401 | class="cmtt-12">[i]</span>)
|
---|
4402 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4403 | i. </dt><dd
|
---|
4404 | class="enumerate-enumitem">if vector <span
|
---|
4405 | class="cmtt-12">[no</span><span
|
---|
4406 | class="cmtt-12">_residue] </span>element <span
|
---|
4407 | class="cmtt-12">[j] </span>is true
|
---|
4408 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4409 | A. </dt><dd
|
---|
4410 | class="enumerate-enumitem">vector <span
|
---|
4411 | class="cmtt-12">[do</span><span
|
---|
4412 | class="cmtt-12">_not</span><span
|
---|
4413 | class="cmtt-12">_decode</span><span
|
---|
4414 | class="cmtt-12">_flag] </span>element <span
|
---|
4415 | class="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
|
---|
4419 | class="enumerate-enumitem">vector <span
|
---|
4420 | class="cmtt-12">[do</span><span
|
---|
4421 | class="cmtt-12">_not</span><span
|
---|
4422 | class="cmtt-12">_decode</span><span
|
---|
4423 | class="cmtt-12">_flag] </span>element <span
|
---|
4424 | class="cmtt-12">[ch] </span>is unset</dd></dl>
|
---|
4425 | </dd><dt class="enumerate-enumitem">
|
---|
4426 | ii. </dt><dd
|
---|
4427 | class="enumerate-enumitem">increment <span
|
---|
4428 | class="cmtt-12">[ch]</span></dd></dl>
|
---|
4429 | </dd></dl>
|
---|
4430 | </dd><dt class="enumerate-enumitem">
|
---|
4431 | 3. </dt><dd
|
---|
4432 | class="enumerate-enumitem"><span
|
---|
4433 | class="cmtt-12">[residue</span><span
|
---|
4434 | class="cmtt-12">_number] </span>= vector <span
|
---|
4435 | class="cmtt-12">[vorbis</span><span
|
---|
4436 | class="cmtt-12">_mapping</span><span
|
---|
4437 | class="cmtt-12">_submap</span><span
|
---|
4438 | class="cmtt-12">_residue] </span>element <span
|
---|
4439 | class="cmtt-12">[i]</span>
|
---|
4440 | </dd><dt class="enumerate-enumitem">
|
---|
4441 | 4. </dt><dd
|
---|
4442 | class="enumerate-enumitem"><span
|
---|
4443 | class="cmtt-12">[residue</span><span
|
---|
4444 | class="cmtt-12">_type] </span>= vector <span
|
---|
4445 | class="cmtt-12">[vorbis</span><span
|
---|
4446 | class="cmtt-12">_residue</span><span
|
---|
4447 | class="cmtt-12">_types] </span>element <span
|
---|
4448 | class="cmtt-12">[residue</span><span
|
---|
4449 | class="cmtt-12">_number]</span>
|
---|
4450 | </dd><dt class="enumerate-enumitem">
|
---|
4451 | 5. </dt><dd
|
---|
4452 | class="enumerate-enumitem">decode <span
|
---|
4453 | class="cmtt-12">[ch] </span>vectors using residue <span
|
---|
4454 | class="cmtt-12">[residue</span><span
|
---|
4455 | class="cmtt-12">_number]</span>, according to type <span
|
---|
4456 | class="cmtt-12">[residue</span><span
|
---|
4457 | class="cmtt-12">_type]</span>,
|
---|
4458 |
|
---|
4459 |
|
---|
4460 |
|
---|
4461 | also passing vector <span
|
---|
4462 | class="cmtt-12">[do</span><span
|
---|
4463 | class="cmtt-12">_not</span><span
|
---|
4464 | class="cmtt-12">_decode</span><span
|
---|
4465 | class="cmtt-12">_flag] </span>to indicate which vectors in the bundle should
|
---|
4466 | not be decoded. Correct per-vector decode length is <span
|
---|
4467 | class="cmtt-12">[n]</span>/2.
|
---|
4468 | </dd><dt class="enumerate-enumitem">
|
---|
4469 | 6. </dt><dd
|
---|
4470 | class="enumerate-enumitem"><span
|
---|
4471 | class="cmtt-12">[ch] </span>= 0
|
---|
4472 | </dd><dt class="enumerate-enumitem">
|
---|
4473 | 7. </dt><dd
|
---|
4474 | class="enumerate-enumitem">for each channel <span
|
---|
4475 | class="cmtt-12">[j] </span>in order from 0 ... <span
|
---|
4476 | class="cmtt-12">[audio</span><span
|
---|
4477 | class="cmtt-12">_channels]</span>
|
---|
4478 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4479 | a) </dt><dd
|
---|
4480 | class="enumerate-enumitem">if channel <span
|
---|
4481 | class="cmtt-12">[j] </span>is in submap <span
|
---|
4482 | class="cmtt-12">[i] </span>(vector <span
|
---|
4483 | class="cmtt-12">[vorbis</span><span
|
---|
4484 | class="cmtt-12">_mapping</span><span
|
---|
4485 | class="cmtt-12">_mux] </span>element <span
|
---|
4486 | class="cmtt-12">[j] </span>is equal
|
---|
4487 | to <span
|
---|
4488 | class="cmtt-12">[i]</span>)
|
---|
4489 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4490 | i. </dt><dd
|
---|
4491 | class="enumerate-enumitem">residue vector for channel <span
|
---|
4492 | class="cmtt-12">[j] </span>is set to decoded residue vector <span
|
---|
4493 | class="cmtt-12">[ch]</span>
|
---|
4494 | </dd><dt class="enumerate-enumitem">
|
---|
4495 | ii. </dt><dd
|
---|
4496 | class="enumerate-enumitem">increment <span
|
---|
4497 | class="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
|
---|
4504 | class="cmtt-12">[i] </span>from <span
|
---|
4505 | class="cmtt-12">[vorbis</span><span
|
---|
4506 | class="cmtt-12">_mapping</span><span
|
---|
4507 | class="cmtt-12">_coupling</span><span
|
---|
4508 | class="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
|
---|
4512 | class="enumerate-enumitem"><span
|
---|
4513 | class="cmtt-12">[magnitude</span><span
|
---|
4514 | class="cmtt-12">_vector] </span>= the residue vector for channel (vector
|
---|
4515 | <span
|
---|
4516 | class="cmtt-12">[vorbis</span><span
|
---|
4517 | class="cmtt-12">_mapping</span><span
|
---|
4518 | class="cmtt-12">_magnitude] </span>element <span
|
---|
4519 | class="cmtt-12">[i]</span>)
|
---|
4520 | </dd><dt class="enumerate-enumitem">
|
---|
4521 | 2. </dt><dd
|
---|
4522 | class="enumerate-enumitem"><span
|
---|
4523 | class="cmtt-12">[angle</span><span
|
---|
4524 | class="cmtt-12">_vector] </span>= the residue vector for channel (vector <span
|
---|
4525 | class="cmtt-12">[vorbis</span><span
|
---|
4526 | class="cmtt-12">_mapping</span><span
|
---|
4527 | class="cmtt-12">_angle]</span>
|
---|
4528 | element <span
|
---|
4529 | class="cmtt-12">[i]</span>)
|
---|
4530 | </dd><dt class="enumerate-enumitem">
|
---|
4531 | 3. </dt><dd
|
---|
4532 | class="enumerate-enumitem">for each scalar value <span
|
---|
4533 | class="cmtt-12">[M] </span>in vector <span
|
---|
4534 | class="cmtt-12">[magnitude</span><span
|
---|
4535 | class="cmtt-12">_vector] </span>and the corresponding scalar value
|
---|
4536 | <span
|
---|
4537 | class="cmtt-12">[A] </span>in vector <span
|
---|
4538 | class="cmtt-12">[angle</span><span
|
---|
4539 | class="cmtt-12">_vector]</span>:
|
---|
4540 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4541 | a) </dt><dd
|
---|
4542 | class="enumerate-enumitem">if (<span
|
---|
4543 | class="cmtt-12">[M] </span>is greater than zero)
|
---|
4544 |
|
---|
4545 |
|
---|
4546 |
|
---|
4547 | <dl class="enumerate-enumitem"><dt class="enumerate-enumitem">
|
---|
4548 | i. </dt><dd
|
---|
4549 | class="enumerate-enumitem">if (<span
|
---|
4550 | class="cmtt-12">[A] </span>is greater than zero)
|
---|
4551 | <dl class="enumerate-enumitem& |
---|