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.cse.ohio-state.edu/~gurari/TeX4ht/)"> 7<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> 8<!-- html --> 9<meta name="src" content="Vorbis_I_spec.tex"> 10<meta name="date" content="2010-02-03 17:32:00"> 11<link rel="stylesheet" type="text/css" href="Vorbis_I_spec.css"> 12</head><body 13> 14<div class="maketitle"> 15 16 17 18 19 20 21 22<h2 class="titleHead">Vorbis I specification</h2> 23<div class="author" ><span 24class="cmr-17">Xiph.org Foundation</span></div> 25<br /> 26<div class="date" ><span 27class="cmr-17">February 3, 2010</span></div> 28</div> 29<h3 class="likesectionHead"><a 30 id="x1-1000"></a>Contents</h3> 31<div class="tableofcontents"> 32 <span class="sectionToc" >1 <a 33href="#x1-20001" id="QQ2-1-2">Introduction and Description</a></span> 34<br />  <span class="subsectionToc" >1.1 <a 35href="#x1-30001.1" id="QQ2-1-3">Overview</a></span> 36<br />   <span class="subsubsectionToc" >1.1.1 <a 37href="#x1-40001.1.1" id="QQ2-1-4">Application</a></span> 38<br />   <span class="subsubsectionToc" >1.1.2 <a 39href="#x1-50001.1.2" id="QQ2-1-5">Classification</a></span> 40<br />   <span class="subsubsectionToc" >1.1.3 <a 41href="#x1-60001.1.3" id="QQ2-1-6">Assumptions</a></span> 42<br />   <span class="subsubsectionToc" >1.1.4 <a 43href="#x1-70001.1.4" id="QQ2-1-7">Codec Setup and Probability Model</a></span> 44<br />   <span class="subsubsectionToc" >1.1.5 <a 45href="#x1-90001.1.5" id="QQ2-1-9">Format Specification</a></span> 46<br />   <span class="subsubsectionToc" >1.1.6 <a 47href="#x1-100001.1.6" id="QQ2-1-10">Hardware Profile</a></span> 48<br />  <span class="subsectionToc" >1.2 <a 49href="#x1-110001.2" id="QQ2-1-11">Decoder Configuration</a></span> 50<br />   <span class="subsubsectionToc" >1.2.1 <a 51href="#x1-120001.2.1" id="QQ2-1-13">Global Config</a></span> 52<br />   <span class="subsubsectionToc" >1.2.2 <a 53href="#x1-130001.2.2" id="QQ2-1-14">Mode</a></span> 54 55 56 57<br />   <span class="subsubsectionToc" >1.2.3 <a 58href="#x1-140001.2.3" id="QQ2-1-15">Mapping</a></span> 59<br />   <span class="subsubsectionToc" >1.2.4 <a 60href="#x1-150001.2.4" id="QQ2-1-16">Floor</a></span> 61<br />   <span class="subsubsectionToc" >1.2.5 <a 62href="#x1-160001.2.5" id="QQ2-1-17">Residue</a></span> 63<br />   <span class="subsubsectionToc" >1.2.6 <a 64href="#x1-170001.2.6" id="QQ2-1-18">Codebooks</a></span> 65<br />  <span class="subsectionToc" >1.3 <a 66href="#x1-180001.3" id="QQ2-1-19">High-level Decode Process</a></span> 67<br />   <span class="subsubsectionToc" >1.3.1 <a 68href="#x1-190001.3.1" id="QQ2-1-20">Decode Setup</a></span> 69<br />   <span class="subsubsectionToc" >1.3.2 <a 70href="#x1-230001.3.2" id="QQ2-1-24">Decode Procedure</a></span> 71<br /> <span class="sectionToc" >2 <a 72href="#x1-360002" id="QQ2-1-39">Bitpacking Convention</a></span> 73<br />  <span class="subsectionToc" >2.1 <a 74href="#x1-370002.1" id="QQ2-1-40">Overview</a></span> 75<br />   <span class="subsubsectionToc" >2.1.1 <a 76href="#x1-380002.1.1" id="QQ2-1-41">octets, bytes and words</a></span> 77<br />   <span class="subsubsectionToc" >2.1.2 <a 78href="#x1-390002.1.2" id="QQ2-1-42">bit order</a></span> 79<br />   <span class="subsubsectionToc" >2.1.3 <a 80href="#x1-400002.1.3" id="QQ2-1-43">byte order</a></span> 81<br />   <span class="subsubsectionToc" >2.1.4 <a 82href="#x1-410002.1.4" id="QQ2-1-44">coding bits into byte sequences</a></span> 83<br />   <span class="subsubsectionToc" >2.1.5 <a 84href="#x1-420002.1.5" id="QQ2-1-45">signedness</a></span> 85<br />   <span class="subsubsectionToc" >2.1.6 <a 86href="#x1-430002.1.6" id="QQ2-1-46">coding example</a></span> 87<br />   <span class="subsubsectionToc" >2.1.7 <a 88href="#x1-440002.1.7" id="QQ2-1-47">decoding example</a></span> 89<br />   <span class="subsubsectionToc" >2.1.8 <a 90href="#x1-450002.1.8" id="QQ2-1-48">end-of-packet alignment</a></span> 91<br />   <span class="subsubsectionToc" >2.1.9 <a 92href="#x1-460002.1.9" id="QQ2-1-49">reading zero bits</a></span> 93<br /> <span class="sectionToc" >3 <a 94href="#x1-470003" id="QQ2-1-50">Probability Model and Codebooks</a></span> 95<br />  <span class="subsectionToc" >3.1 <a 96href="#x1-480003.1" id="QQ2-1-51">Overview</a></span> 97<br />   <span class="subsubsectionToc" >3.1.1 <a 98href="#x1-490003.1.1" id="QQ2-1-52">Bitwise operation</a></span> 99<br />  <span class="subsectionToc" >3.2 <a 100href="#x1-500003.2" id="QQ2-1-53">Packed codebook format</a></span> 101<br />   <span class="subsubsectionToc" >3.2.1 <a 102href="#x1-510003.2.1" id="QQ2-1-54">codebook decode</a></span> 103<br />  <span class="subsectionToc" >3.3 <a 104href="#x1-570003.3" id="QQ2-1-62">Use of the codebook abstraction</a></span> 105<br /> <span class="sectionToc" >4 <a 106href="#x1-580004" id="QQ2-1-63">Codec Setup and Packet Decode</a></span> 107<br />  <span class="subsectionToc" >4.1 <a 108href="#x1-590004.1" id="QQ2-1-64">Overview</a></span> 109<br />  <span class="subsectionToc" >4.2 <a 110href="#x1-600004.2" id="QQ2-1-65">Header decode and decode setup</a></span> 111<br />   <span class="subsubsectionToc" >4.2.1 <a 112href="#x1-610004.2.1" id="QQ2-1-66">Common header decode</a></span> 113<br />   <span class="subsubsectionToc" >4.2.2 <a 114href="#x1-620004.2.2" id="QQ2-1-67">Identification header</a></span> 115 116 117 118<br />   <span class="subsubsectionToc" >4.2.3 <a 119href="#x1-630004.2.3" id="QQ2-1-68">Comment header</a></span> 120<br />   <span class="subsubsectionToc" >4.2.4 <a 121href="#x1-640004.2.4" id="QQ2-1-69">Setup header</a></span> 122<br />  <span class="subsectionToc" >4.3 <a 123href="#x1-710004.3" id="QQ2-1-77">Audio packet decode and synthesis</a></span> 124<br />   <span class="subsubsectionToc" >4.3.1 <a 125href="#x1-720004.3.1" id="QQ2-1-78">packet type, mode and window decode</a></span> 126<br />   <span class="subsubsectionToc" >4.3.2 <a 127href="#x1-730004.3.2" id="QQ2-1-79">floor curve decode</a></span> 128<br />   <span class="subsubsectionToc" >4.3.3 <a 129href="#x1-740004.3.3" id="QQ2-1-80">nonzero vector propagate</a></span> 130<br />   <span class="subsubsectionToc" >4.3.4 <a 131href="#x1-750004.3.4" id="QQ2-1-81">residue decode</a></span> 132<br />   <span class="subsubsectionToc" >4.3.5 <a 133href="#x1-760004.3.5" id="QQ2-1-82">inverse coupling</a></span> 134<br />   <span class="subsubsectionToc" >4.3.6 <a 135href="#x1-770004.3.6" id="QQ2-1-83">dot product</a></span> 136<br />   <span class="subsubsectionToc" >4.3.7 <a 137href="#x1-780004.3.7" id="QQ2-1-84">inverse MDCT</a></span> 138<br />   <span class="subsubsectionToc" >4.3.8 <a 139href="#x1-790004.3.8" id="QQ2-1-85">overlap˙add</a></span> 140<br />   <span class="subsubsectionToc" >4.3.9 <a 141href="#x1-800004.3.9" id="QQ2-1-86">output channel order</a></span> 142<br /> <span class="sectionToc" >5 <a 143href="#x1-810005" id="QQ2-1-87">comment field and header specification</a></span> 144<br />  <span class="subsectionToc" >5.1 <a 145href="#x1-820005.1" id="QQ2-1-88">Overview</a></span> 146<br />  <span class="subsectionToc" >5.2 <a 147href="#x1-830005.2" id="QQ2-1-89">Comment encoding</a></span> 148<br />   <span class="subsubsectionToc" >5.2.1 <a 149href="#x1-840005.2.1" id="QQ2-1-90">Structure</a></span> 150<br />   <span class="subsubsectionToc" >5.2.2 <a 151href="#x1-850005.2.2" id="QQ2-1-91">Content vector format</a></span> 152<br />   <span class="subsubsectionToc" >5.2.3 <a 153href="#x1-880005.2.3" id="QQ2-1-94">Encoding</a></span> 154<br /> <span class="sectionToc" >6 <a 155href="#x1-890006" id="QQ2-1-95">Floor type 0 setup and decode</a></span> 156<br />  <span class="subsectionToc" >6.1 <a 157href="#x1-900006.1" id="QQ2-1-96">Overview</a></span> 158<br />  <span class="subsectionToc" >6.2 <a 159href="#x1-910006.2" id="QQ2-1-97">Floor 0 format</a></span> 160<br />   <span class="subsubsectionToc" >6.2.1 <a 161href="#x1-920006.2.1" id="QQ2-1-98">header decode</a></span> 162<br />   <span class="subsubsectionToc" >6.2.2 <a 163href="#x1-930006.2.2" id="QQ2-1-99">packet decode</a></span> 164<br />   <span class="subsubsectionToc" >6.2.3 <a 165href="#x1-940006.2.3" id="QQ2-1-100">curve computation</a></span> 166<br /> <span class="sectionToc" >7 <a 167href="#x1-950007" id="QQ2-1-101">Floor type 1 setup and decode</a></span> 168<br />  <span class="subsectionToc" >7.1 <a 169href="#x1-960007.1" id="QQ2-1-102">Overview</a></span> 170<br />  <span class="subsectionToc" >7.2 <a 171href="#x1-970007.2" id="QQ2-1-103">Floor 1 format</a></span> 172<br />   <span class="subsubsectionToc" >7.2.1 <a 173href="#x1-980007.2.1" id="QQ2-1-104">model</a></span> 174<br />   <span class="subsubsectionToc" >7.2.2 <a 175href="#x1-990007.2.2" id="QQ2-1-109">header decode</a></span> 176 177 178 179<br /> <span class="sectionToc" >8 <a 180href="#x1-1020008" id="QQ2-1-112">Residue setup and decode</a></span> 181<br />  <span class="subsectionToc" >8.1 <a 182href="#x1-1030008.1" id="QQ2-1-113">Overview</a></span> 183<br />  <span class="subsectionToc" >8.2 <a 184href="#x1-1040008.2" id="QQ2-1-114">Residue format</a></span> 185<br />  <span class="subsectionToc" >8.3 <a 186href="#x1-1050008.3" id="QQ2-1-116">residue 0</a></span> 187<br />  <span class="subsectionToc" >8.4 <a 188href="#x1-1060008.4" id="QQ2-1-117">residue 1</a></span> 189<br />  <span class="subsectionToc" >8.5 <a 190href="#x1-1070008.5" id="QQ2-1-118">residue 2</a></span> 191<br />  <span class="subsectionToc" >8.6 <a 192href="#x1-1080008.6" id="QQ2-1-120">Residue decode</a></span> 193<br />   <span class="subsubsectionToc" >8.6.1 <a 194href="#x1-1090008.6.1" id="QQ2-1-121">header decode</a></span> 195<br />   <span class="subsubsectionToc" >8.6.2 <a 196href="#x1-1100008.6.2" id="QQ2-1-122">packet decode</a></span> 197<br />   <span class="subsubsectionToc" >8.6.3 <a 198href="#x1-1110008.6.3" id="QQ2-1-123">format 0 specifics</a></span> 199<br />   <span class="subsubsectionToc" >8.6.4 <a 200href="#x1-1120008.6.4" id="QQ2-1-124">format 1 specifics</a></span> 201<br />   <span class="subsubsectionToc" >8.6.5 <a 202href="#x1-1130008.6.5" id="QQ2-1-125">format 2 specifics</a></span> 203<br /> <span class="sectionToc" >9 <a 204href="#x1-1140009" id="QQ2-1-126">Helper equations</a></span> 205<br />  <span class="subsectionToc" >9.1 <a 206href="#x1-1150009.1" id="QQ2-1-127">Overview</a></span> 207<br />  <span class="subsectionToc" >9.2 <a 208href="#x1-1160009.2" id="QQ2-1-128">Functions</a></span> 209<br />   <span class="subsubsectionToc" >9.2.1 <a 210href="#x1-1170009.2.1" id="QQ2-1-129">ilog</a></span> 211<br />   <span class="subsubsectionToc" >9.2.2 <a 212href="#x1-1180009.2.2" id="QQ2-1-130">float32˙unpack</a></span> 213<br />   <span class="subsubsectionToc" >9.2.3 <a 214href="#x1-1190009.2.3" id="QQ2-1-131">lookup1˙values</a></span> 215<br />   <span class="subsubsectionToc" >9.2.4 <a 216href="#x1-1200009.2.4" id="QQ2-1-132">low˙neighbor</a></span> 217<br />   <span class="subsubsectionToc" >9.2.5 <a 218href="#x1-1210009.2.5" id="QQ2-1-133">high˙neighbor</a></span> 219<br />   <span class="subsubsectionToc" >9.2.6 <a 220href="#x1-1220009.2.6" id="QQ2-1-134">render˙point</a></span> 221<br />   <span class="subsubsectionToc" >9.2.7 <a 222href="#x1-1230009.2.7" id="QQ2-1-135">render˙line</a></span> 223<br /> <span class="sectionToc" >10 <a 224href="#x1-12400010" id="QQ2-1-136">Tables</a></span> 225<br />  <span class="subsectionToc" >10.1 <a 226href="#x1-12500010.1" id="QQ2-1-137">floor1_inverse_dB_table</a></span> 227<br /> <span class="sectionToc" >A <a 228href="#x1-126000A" id="QQ2-1-138">Embedding Vorbis into an Ogg stream</a></span> 229<br />  <span class="subsectionToc" >A.1 <a 230href="#x1-127000A.1" id="QQ2-1-139">Overview</a></span> 231<br />   <span class="subsubsectionToc" >A.1.1 <a 232href="#x1-128000A.1.1" id="QQ2-1-140">Restrictions</a></span> 233<br />   <span class="subsubsectionToc" >A.1.2 <a 234href="#x1-129000A.1.2" id="QQ2-1-141">MIME type</a></span> 235<br />  <span class="subsectionToc" >A.2 <a 236href="#x1-130000A.2" id="QQ2-1-142">Encapsulation</a></span> 237 238 239 240<br /> <span class="sectionToc" >B <a 241href="#x1-132000B" id="QQ2-1-144">Vorbis encapsulation in RTP</a></span> 242</div> 243 244 245 246<h3 class="sectionHead"><span class="titlemark">1 </span> <a 247 id="x1-20001"></a>Introduction and Description</h3> 248<!--l. 6--><p class="noindent" > 249<h4 class="subsectionHead"><span class="titlemark">1.1 </span> <a 250 id="x1-30001.1"></a>Overview</h4> 251<!--l. 8--><p class="noindent" >This document provides a high level description of the Vorbis codec’s construction. A bit-by-bit 252specification appears beginning in <a 253href="#x1-580004">Section 4</a>, “<a 254href="#x1-580004">Codec Setup and Packet Decode<!--tex4ht:ref: vorbis:spec:codec --></a>”. The later 255sections assume a high-level understanding of the Vorbis decode process, which is provided 256here. 257<!--l. 15--><p class="noindent" > 258<h5 class="subsubsectionHead"><span class="titlemark">1.1.1 </span> <a 259 id="x1-40001.1.1"></a>Application</h5> 260<!--l. 16--><p class="noindent" >Vorbis is a general purpose perceptual audio CODEC intended to allow maximum encoder 261flexibility, thus allowing it to scale competitively over an exceptionally wide range of bitrates. At 262the high quality/bitrate end of the scale (CD or DAT rate stereo, 16/24 bits) it is in the same 263league as MPEG-2 and MPC. Similarly, the 1.0 encoder can encode high-quality CD and DAT 264rate stereo at below 48kbps without resampling to a lower rate. Vorbis is also intended for lower 265and higher sample rates (from 8kHz telephony to 192kHz digital masters) and a range of channel 266representations (monaural, polyphonic, stereo, quadraphonic, 5.1, ambisonic, or up to 255 267discrete channels). 268<!--l. 29--><p class="noindent" > 269<h5 class="subsubsectionHead"><span class="titlemark">1.1.2 </span> <a 270 id="x1-50001.1.2"></a>Classification</h5> 271<!--l. 30--><p class="noindent" >Vorbis I is a forward-adaptive monolithic transform CODEC based on the Modified Discrete 272Cosine Transform. The codec is structured to allow addition of a hybrid wavelet filterbank in 273Vorbis II to offer better transient response and reproduction using a transform better suited to 274localized time events. 275 276 277 278<!--l. 37--><p class="noindent" > 279<h5 class="subsubsectionHead"><span class="titlemark">1.1.3 </span> <a 280 id="x1-60001.1.3"></a>Assumptions</h5> 281<!--l. 39--><p class="noindent" >The Vorbis CODEC design assumes a complex, psychoacoustically-aware encoder and simple, 282low-complexity decoder. Vorbis decode is computationally simpler than mp3, although it does 283require more working memory as Vorbis has no static probability model; the vector codebooks 284used in the first stage of decoding from the bitstream are packed in their entirety into the Vorbis 285bitstream headers. In packed form, these codebooks occupy only a few kilobytes; the extent to 286which they are pre-decoded into a cache is the dominant factor in decoder memory 287usage. 288<!--l. 50--><p class="noindent" >Vorbis provides none of its own framing, synchronization or protection against errors; it 289is solely a method of accepting input audio, dividing it into individual frames and 290compressing these frames into raw, unformatted ’packets’. The decoder then accepts 291these raw packets in sequence, decodes them, synthesizes audio frames from them, and 292reassembles the frames into a facsimile of the original audio stream. Vorbis is a free-form 293variable bit rate (VBR) codec and packets have no minimum size, maximum size, or 294fixed/expected size. Packets are designed that they may be truncated (or padded) 295and remain decodable; this is not to be considered an error condition and is used 296extensively in bitrate management in peeling. Both the transport mechanism and 297decoder must allow that a packet may be any size, or end before or after packet decode 298expects. 299<!--l. 64--><p class="noindent" >Vorbis packets are thus intended to be used with a transport mechanism that provides free-form 300framing, sync, positioning and error correction in accordance with these design assumptions, such 301as Ogg (for file transport) or RTP (for network multicast). For purposes of a few examples in this 302document, we will assume that Vorbis is to be embedded in an Ogg stream specifically, 303although this is by no means a requirement or fundamental assumption in the Vorbis 304design. 305<!--l. 72--><p class="noindent" >The specification for embedding Vorbis into an Ogg transport stream is in <a 306href="#x1-126000A">Section A</a>, 307“<a 308href="#x1-126000A">Embedding Vorbis into an Ogg stream<!--tex4ht:ref: vorbis:over:ogg --></a>”. 309<!--l. 77--><p class="noindent" > 310<h5 class="subsubsectionHead"><span class="titlemark">1.1.4 </span> <a 311 id="x1-70001.1.4"></a>Codec Setup and Probability Model</h5> 312<!--l. 79--><p class="noindent" >Vorbis’ heritage is as a research CODEC and its current design reflects a desire to allow multiple 313decades of continuous encoder improvement before running out of room within the codec 314specification. For these reasons, configurable aspects of codec setup intentionally lean toward the 315extreme of forward adaptive. 316 317 318 319<!--l. 85--><p class="noindent" >The single most controversial design decision in Vorbis (and the most unusual for a Vorbis 320developer to keep in mind) is that the entire probability model of the codec, the Huffman and 321VQ codebooks, is packed into the bitstream header along with extensive CODEC setup 322parameters (often several hundred fields). This makes it impossible, as it would be with 323MPEG audio layers, to embed a simple frame type flag in each audio packet, or begin 324decode at any frame in the stream without having previously fetched the codec setup 325header. 326<!--l. 95--><p class="noindent" ><span class="likesubparagraphHead"><a 327 id="x1-80001.1.4"></a><span 328class="cmbx-12">Note:</span></span> Vorbis <span 329class="cmti-12">can </span>initiate decode at any arbitrary packet within a bitstream so long as the codec 330has been initialized/setup with the setup headers. 331<!--l. 101--><p class="noindent" >Thus, Vorbis headers are both required for decode to begin and relatively large as bitstream 332headers go. The header size is unbounded, although for streaming a rule-of-thumb of 4kB or less 333is recommended (and Xiph.Org’s Vorbis encoder follows this suggestion). 334<!--l. 106--><p class="noindent" >Our own design work indicates the primary liability of the required header is in mindshare; it is 335an unusual design and thus causes some amount of complaint among engineers as this runs 336against current design trends (and also points out limitations in some existing software/interface 337designs, such as Windows’ ACM codec framework). However, we find that it does not 338fundamentally limit Vorbis’ suitable application space. 339<!--l. 115--><p class="noindent" > 340<h5 class="subsubsectionHead"><span class="titlemark">1.1.5 </span> <a 341 id="x1-90001.1.5"></a>Format Specification</h5> 342<!--l. 116--><p class="noindent" >The Vorbis format is well-defined by its decode specification; any encoder that produces packets 343that are correctly decoded by the reference Vorbis decoder described below may be considered 344a proper Vorbis encoder. A decoder must faithfully and completely implement the 345specification defined below (except where noted) to be considered a proper Vorbis 346decoder. 347<!--l. 123--><p class="noindent" > 348<h5 class="subsubsectionHead"><span class="titlemark">1.1.6 </span> <a 349 id="x1-100001.1.6"></a>Hardware Profile</h5> 350 351 352 353<!--l. 124--><p class="noindent" >Although Vorbis decode is computationally simple, it may still run into specific limitations of an 354embedded design. For this reason, embedded designs are allowed to deviate in limited ways from 355the ‘full’ decode specification yet still be certified compliant. These optional omissions are 356labelled in the spec where relevant. 357<!--l. 131--><p class="noindent" > 358<h4 class="subsectionHead"><span class="titlemark">1.2 </span> <a 359 id="x1-110001.2"></a>Decoder Configuration</h4> 360<!--l. 133--><p class="noindent" >Decoder setup consists of configuration of multiple, self-contained component abstractions that 361perform specific functions in the decode pipeline. Each different component instance of a specific 362type is semantically interchangeable; decoder configuration consists both of internal component 363configuration, as well as arrangement of specific instances into a decode pipeline. Componentry 364arrangement is roughly as follows: 365<div class="center" 366> 367<!--l. 141--><p class="noindent" > 368 369<!--l. 142--><p class="noindent" ><img 370src="components.png" alt="PIC" 371> 372<br /> <div class="caption" 373><span class="id">Figure 1: </span><span 374class="content">decoder pipeline configuration</span></div><!--tex4ht:label?: x1-110011 --> 375</div> 376<!--l. 146--><p class="noindent" > 377<h5 class="subsubsectionHead"><span class="titlemark">1.2.1 </span> <a 378 id="x1-120001.2.1"></a>Global Config</h5> 379<!--l. 147--><p class="noindent" >Global codec configuration consists of a few audio related fields (sample rate, channels), Vorbis 380version (always ’0’ in Vorbis I), bitrate hints, and the lists of component instances. All other 381configuration is in the context of specific components. 382<!--l. 152--><p class="noindent" > 383<h5 class="subsubsectionHead"><span class="titlemark">1.2.2 </span> <a 384 id="x1-130001.2.2"></a>Mode</h5> 385 386 387 388<!--l. 154--><p class="noindent" >Each Vorbis frame is coded according to a master ’mode’. A bitstream may use one or many 389modes. 390<!--l. 157--><p class="noindent" >The mode mechanism is used to encode a frame according to one of multiple possible 391methods with the intention of choosing a method best suited to that frame. Different 392modes are, e.g. how frame size is changed from frame to frame. The mode number of a 393frame serves as a top level configuration switch for all other specific aspects of frame 394decode. 395<!--l. 164--><p class="noindent" >A ’mode’ configuration consists of a frame size setting, window type (always 0, the Vorbis 396window, in Vorbis I), transform type (always type 0, the MDCT, in Vorbis I) and a mapping 397number. The mapping number specifies which mapping configuration instance to use for low-level 398packet decode and synthesis. 399<!--l. 171--><p class="noindent" > 400<h5 class="subsubsectionHead"><span class="titlemark">1.2.3 </span> <a 401 id="x1-140001.2.3"></a>Mapping</h5> 402<!--l. 173--><p class="noindent" >A mapping contains a channel coupling description and a list of ’submaps’ that bundle sets 403of channel vectors together for grouped encoding and decoding. These submaps are 404not references to external components; the submap list is internal and specific to a 405mapping. 406<!--l. 178--><p class="noindent" >A ’submap’ is a configuration/grouping that applies to a subset of floor and residue vectors 407within a mapping. The submap functions as a last layer of indirection such that specific special 408floor or residue settings can be applied not only to all the vectors in a given mode, but also 409specific vectors in a specific mode. Each submap specifies the proper floor and residue 410instance number to use for decoding that submap’s spectral floor and spectral residue 411vectors. 412<!--l. 186--><p class="noindent" >As an example: 413<!--l. 188--><p class="noindent" >Assume a Vorbis stream that contains six channels in the standard 5.1 format. The sixth 414channel, as is normal in 5.1, is bass only. Therefore it would be wasteful to encode a 415full-spectrum version of it as with the other channels. The submapping mechanism can be used 416to apply a full range floor and residue encoding to channels 0 through 4, and a bass-only 417representation to the bass channel, thus saving space. In this example, channels 0-4 belong to 418submap 0 (which indicates use of a full-range floor) and channel 5 belongs to submap 1, which 419uses a bass-only representation. 420 421 422 423<!--l. 199--><p class="noindent" > 424<h5 class="subsubsectionHead"><span class="titlemark">1.2.4 </span> <a 425 id="x1-150001.2.4"></a>Floor</h5> 426<!--l. 201--><p class="noindent" >Vorbis encodes a spectral ’floor’ vector for each PCM channel. This vector is a low-resolution 427representation of the audio spectrum for the given channel in the current frame, generally used 428akin to a whitening filter. It is named a ’floor’ because the Xiph.Org reference encoder has 429historically used it as a unit-baseline for spectral resolution. 430<!--l. 208--><p class="noindent" >A floor encoding may be of two types. Floor 0 uses a packed LSP representation on a dB 431amplitude scale and Bark frequency scale. Floor 1 represents the curve as a piecewise linear 432interpolated representation on a dB amplitude scale and linear frequency scale. The two floors 433are semantically interchangeable in encoding/decoding. However, floor type 1 provides more 434stable inter-frame behavior, and so is the preferred choice in all coupled-stereo and 435high bitrate modes. Floor 1 is also considerably less expensive to decode than floor 4360. 437<!--l. 218--><p class="noindent" >Floor 0 is not to be considered deprecated, but it is of limited modern use. No known Vorbis 438encoder past Xiph.org’s own beta 4 makes use of floor 0. 439<!--l. 222--><p class="noindent" >The values coded/decoded by a floor are both compactly formatted and make use of entropy 440coding to save space. For this reason, a floor configuration generally refers to multiple 441codebooks in the codebook component list. Entropy coding is thus provided as an 442abstraction, and each floor instance may choose from any and all available codebooks when 443coding/decoding. 444<!--l. 230--><p class="noindent" > 445<h5 class="subsubsectionHead"><span class="titlemark">1.2.5 </span> <a 446 id="x1-160001.2.5"></a>Residue</h5> 447<!--l. 231--><p class="noindent" >The spectral residue is the fine structure of the audio spectrum once the floor curve has been 448subtracted out. In simplest terms, it is coded in the bitstream using cascaded (multi-pass) vector 449quantization according to one of three specific packing/coding algorithms numbered 4500 through 2. The packing algorithm details are configured by residue instance. As 451with the floor components, the final VQ/entropy encoding is provided by external 452codebook instances and each residue instance may choose from any and all available 453codebooks. 454<!--l. 241--><p class="noindent" > 455 456 457 458<h5 class="subsubsectionHead"><span class="titlemark">1.2.6 </span> <a 459 id="x1-170001.2.6"></a>Codebooks</h5> 460<!--l. 243--><p class="noindent" >Codebooks are a self-contained abstraction that perform entropy decoding and, optionally, use 461the entropy-decoded integer value as an offset into an index of output value vectors, returning 462the indicated vector of values. 463<!--l. 248--><p class="noindent" >The entropy coding in a Vorbis I codebook is provided by a standard Huffman binary tree 464representation. This tree is tightly packed using one of several methods, depending on whether 465codeword lengths are ordered or unordered, or the tree is sparse. 466<!--l. 253--><p class="noindent" >The codebook vector index is similarly packed according to index characteristic. Most commonly, 467the vector index is encoded as a single list of values of possible values that are then permuted 468into a list of n-dimensional rows (lattice VQ). 469<!--l. 260--><p class="noindent" > 470<h4 class="subsectionHead"><span class="titlemark">1.3 </span> <a 471 id="x1-180001.3"></a>High-level Decode Process</h4> 472<!--l. 262--><p class="noindent" > 473<h5 class="subsubsectionHead"><span class="titlemark">1.3.1 </span> <a 474 id="x1-190001.3.1"></a>Decode Setup</h5> 475<!--l. 264--><p class="noindent" >Before decoding can begin, a decoder must initialize using the bitstream headers matching the 476stream to be decoded. Vorbis uses three header packets; all are required, in-order, by 477this specification. Once set up, decode may begin at any audio packet belonging to 478the Vorbis stream. In Vorbis I, all packets after the three initial headers are audio 479packets. 480<!--l. 271--><p class="noindent" >The header packets are, in order, the identification header, the comments header, and the setup 481header. 482<!--l. 274--><p class="noindent" ><span class="paragraphHead"><a 483 id="x1-200001.3.1"></a><span 484class="cmbx-12">Identification Header</span></span> 485The identification header identifies the bitstream as Vorbis, Vorbis version, and the simple audio 486characteristics of the stream such as sample rate and number of channels. 487 488 489 490<!--l. 279--><p class="noindent" ><span class="paragraphHead"><a 491 id="x1-210001.3.1"></a><span 492class="cmbx-12">Comment Header</span></span> 493The comment header includes user text comments (“tags”) and a vendor string for the 494application/library that produced the bitstream. The encoding and proper use of the comment 495header is described in <a 496href="#x1-810005">Section 5</a>, “<a 497href="#x1-810005">comment field and header specification<!--tex4ht:ref: vorbis:spec:comment --></a>”. 498<!--l. 284--><p class="noindent" ><span class="paragraphHead"><a 499 id="x1-220001.3.1"></a><span 500class="cmbx-12">Setup Header</span></span> 501The setup header includes extensive CODEC setup information as well as the complete VQ and 502Huffman codebooks needed for decode. 503<!--l. 289--><p class="noindent" > 504<h5 class="subsubsectionHead"><span class="titlemark">1.3.2 </span> <a 505 id="x1-230001.3.2"></a>Decode Procedure</h5> 506<!--l. 291--><p class="noindent" >The decoding and synthesis procedure for all audio packets is fundamentally the same. 507 <ol class="enumerate1" > 508 <li 509 class="enumerate" id="x1-23002x1">decode packet type flag 510 </li> 511 <li 512 class="enumerate" id="x1-23004x2">decode mode number 513 </li> 514 <li 515 class="enumerate" id="x1-23006x3">decode window shape (long windows only) 516 </li> 517 <li 518 class="enumerate" id="x1-23008x4">decode floor 519 </li> 520 <li 521 class="enumerate" id="x1-23010x5">decode residue into residue vectors 522 </li> 523 <li 524 class="enumerate" id="x1-23012x6">inverse channel coupling of residue vectors 525 </li> 526 <li 527 class="enumerate" id="x1-23014x7">generate floor curve from decoded floor data 528 </li> 529 <li 530 class="enumerate" id="x1-23016x8">compute dot product of floor and residue, producing audio spectrum vector 531 </li> 532 <li 533 class="enumerate" id="x1-23018x9">inverse monolithic transform of audio spectrum vector, always an MDCT in Vorbis 534 I 535 536 537 538 </li> 539 <li 540 class="enumerate" id="x1-23020x10">overlap/add left-hand output of transform with right-hand output of previous frame 541 </li> 542 <li 543 class="enumerate" id="x1-23022x11">store right hand-data from transform of current frame for future lapping 544 </li> 545 <li 546 class="enumerate" id="x1-23024x12">if not first frame, return results of overlap/add as audio result of current frame</li></ol> 547<!--l. 308--><p class="noindent" >Note that clever rearrangement of the synthesis arithmetic is possible; as an example, one can 548take advantage of symmetries in the MDCT to store the right-hand transform data of a partial 549MDCT for a 50% inter-frame buffer space savings, and then complete the transform later before 550overlap/add with the next frame. This optimization produces entirely equivalent output and is 551naturally perfectly legal. The decoder must be <span 552class="cmti-12">entirely mathematically equivalent </span>to the 553specification, it need not be a literal semantic implementation. 554<!--l. 317--><p class="noindent" ><span class="paragraphHead"><a 555 id="x1-240001.3.2"></a><span 556class="cmbx-12">Packet type decode</span></span> 557Vorbis I uses four packet types. The first three packet types mark each of the three Vorbis 558headers described above. The fourth packet type marks an audio packet. All other packet types 559are reserved; packets marked with a reserved type should be ignored. 560<!--l. 324--><p class="noindent" >Following the three header packets, all packets in a Vorbis I stream are audio. The first step of 561audio packet decode is to read and verify the packet type; <span 562class="cmti-12">a non-audio packet when audio is</span> 563<span 564class="cmti-12">expected indicates stream corruption or a non-compliant stream. The decoder must ignore the</span> 565<span 566class="cmti-12">packet and not attempt decoding it to audio</span>. 567<!--l. 334--><p class="noindent" ><span class="paragraphHead"><a 568 id="x1-250001.3.2"></a><span 569class="cmbx-12">Mode decode</span></span> 570Vorbis allows an encoder to set up multiple, numbered packet ’modes’, as described earlier, all of 571which may be used in a given Vorbis stream. The mode is encoded as an integer used as a direct 572offset into the mode instance index. 573<!--l. 341--><p class="noindent" ><span class="paragraphHead"><a 574 id="x1-260001.3.2"></a><span 575class="cmbx-12">Window shape decode (long windows only)</span></span> 576Vorbis frames may be one of two PCM sample sizes specified during codec setup. In Vorbis I, 577legal frame sizes are powers of two from 64 to 8192 samples. Aside from coupling, Vorbis 578handles channels as independent vectors and these frame sizes are in samples per 579channel. 580 581 582 583<!--l. 348--><p class="noindent" >Vorbis uses an overlapping transform, namely the MDCT, to blend one frame into the next, 584avoiding most inter-frame block boundary artifacts. The MDCT output of one frame is windowed 585according to MDCT requirements, overlapped 50% with the output of the previous frame and 586added. The window shape assures seamless reconstruction. 587<!--l. 354--><p class="noindent" >This is easy to visualize in the case of equal sized-windows: 588<div class="center" 589> 590<!--l. 356--><p class="noindent" > 591 592<!--l. 357--><p class="noindent" ><img 593src="window1.png" alt="PIC" 594> 595<br /> <div class="caption" 596><span class="id">Figure 2: </span><span 597class="content">overlap of two equal-sized windows</span></div><!--tex4ht:label?: x1-260012 --> 598</div> 599<!--l. 361--><p class="noindent" >And slightly more complex in the case of overlapping unequal sized windows: 600<div class="center" 601> 602<!--l. 364--><p class="noindent" > 603 604<!--l. 365--><p class="noindent" ><img 605src="window2.png" alt="PIC" 606> 607<br /> <div class="caption" 608><span class="id">Figure 3: </span><span 609class="content">overlap of a long and a short window</span></div><!--tex4ht:label?: x1-260023 --> 610</div> 611<!--l. 369--><p class="noindent" >In the unequal-sized window case, the window shape of the long window must be modified for 612seamless lapping as above. It is possible to correctly infer window shape to be applied to the 613current window from knowing the sizes of the current, previous and next window. It is legal for a 614decoder to use this method. However, in the case of a long window (short windows require no 615modification), Vorbis also codes two flag bits to specify pre- and post- window shape. Although 616not strictly necessary for function, this minor redundancy allows a packet to be fully decoded to 617the point of lapping entirely independently of any other packet, allowing easier abstraction of 618decode layers as well as allowing a greater level of easy parallelism in encode and 619decode. 620<!--l. 382--><p class="noindent" >A description of valid window functions for use with an inverse MDCT can be found in <span class="cite">[<a 621href="#XSporer/Brandenburg/Edler">1</a>]</span>. 622Vorbis windows all use the slope function 623<center class="math-display" > 624<img 625src="Vorbis_I_spec0x.png" alt="y = sin (.5 ∗ π sin2((x + .5)∕n ∗ π)). 626 627 628 629" class="math-display" ></center> 630<!--l. 385--><p class="nopar" > 631<!--l. 389--><p class="noindent" ><span class="paragraphHead"><a 632 id="x1-270001.3.2"></a><span 633class="cmbx-12">floor decode</span></span> 634Each floor is encoded/decoded in channel order, however each floor belongs to a ’submap’ that 635specifies which floor configuration to use. All floors are decoded before residue decode 636begins. 637<!--l. 395--><p class="noindent" ><span class="paragraphHead"><a 638 id="x1-280001.3.2"></a><span 639class="cmbx-12">residue decode</span></span> 640Although the number of residue vectors equals the number of channels, channel coupling may 641mean that the raw residue vectors extracted during decode do not map directly to specific 642channels. When channel coupling is in use, some vectors will correspond to coupled magnitude or 643angle. The coupling relationships are described in the codec setup and may differ from frame to 644frame, due to different mode numbers. 645<!--l. 404--><p class="noindent" >Vorbis codes residue vectors in groups by submap; the coding is done in submap order from 646submap 0 through n-1. This differs from floors which are coded using a configuration provided by 647submap number, but are coded individually in channel order. 648<!--l. 411--><p class="noindent" ><span class="paragraphHead"><a 649 id="x1-290001.3.2"></a><span 650class="cmbx-12">inverse channel coupling</span></span> 651A detailed discussion of stereo in the Vorbis codec can be found in the document 652<a 653href="stereo.html" >Stereo Channel Coupling in the Vorbis CODEC</a>. Vorbis is not limited to only stereo 654coupling, but the stereo document also gives a good overview of the generic coupling 655mechanism. 656<!--l. 419--><p class="noindent" >Vorbis coupling applies to pairs of residue vectors at a time; decoupling is done in-place a 657pair at a time in the order and using the vectors specified in the current mapping 658configuration. The decoupling operation is the same for all pairs, converting square polar 659representation (where one vector is magnitude and the second angle) back to Cartesian 660representation. 661<!--l. 426--><p class="noindent" >After decoupling, in order, each pair of vectors on the coupling list, the resulting residue vectors 662represent the fine spectral detail of each output channel. 663 664 665 666<!--l. 432--><p class="noindent" ><span class="paragraphHead"><a 667 id="x1-300001.3.2"></a><span 668class="cmbx-12">generate floor curve</span></span> 669The decoder may choose to generate the floor curve at any appropriate time. It is reasonable to 670generate the output curve when the floor data is decoded from the raw packet, or it 671can be generated after inverse coupling and applied to the spectral residue directly, 672combining generation and the dot product into one step and eliminating some working 673space. 674<!--l. 441--><p class="noindent" >Both floor 0 and floor 1 generate a linear-range, linear-domain output vector to be multiplied 675(dot product) by the linear-range, linear-domain spectral residue. 676<!--l. 447--><p class="noindent" ><span class="paragraphHead"><a 677 id="x1-310001.3.2"></a><span 678class="cmbx-12">compute floor/residue dot product</span></span> 679This step is straightforward; for each output channel, the decoder multiplies the floor curve and 680residue vectors element by element, producing the finished audio spectrum of each 681channel. 682<!--l. 455--><p class="noindent" >One point is worth mentioning about this dot product; a common mistake in a fixed point 683implementation might be to assume that a 32 bit fixed-point representation for floor and 684residue and direct multiplication of the vectors is sufficient for acceptable spectral depth 685in all cases because it happens to mostly work with the current Xiph.Org reference 686encoder. 687<!--l. 462--><p class="noindent" >However, floor vector values can span <span 688class="cmsy-10x-x-120">∼</span>140dB (<span 689class="cmsy-10x-x-120">∼</span>24 bits unsigned), and the audio spectrum 690vector should represent a minimum of 120dB (<span 691class="cmsy-10x-x-120">∼</span>21 bits with sign), even when output is to a 16 692bit PCM device. For the residue vector to represent full scale if the floor is nailed 693to <span 694class="cmsy-10x-x-120">−</span>140dB, it must be able to span 0 to +140dB. For the residue vector to reach 695full scale if the floor is nailed at 0dB, it must be able to represent <span 696class="cmsy-10x-x-120">−</span>140dB to +0dB. 697Thus, in order to handle full range dynamics, a residue vector may span <span 698class="cmsy-10x-x-120">−</span>140dB to 699+140dB entirely within spec. A 280dB range is approximately 48 bits with sign; thus the 700residue vector must be able to represent a 48 bit range and the dot product must 701be able to handle an effective 48 bit times 24 bit multiplication. This range may be 702achieved using large (64 bit or larger) integers, or implementing a movable binary point 703representation. 704<!--l. 479--><p class="noindent" ><span class="paragraphHead"><a 705 id="x1-320001.3.2"></a><span 706class="cmbx-12">inverse monolithic transform (MDCT)</span></span> 707The audio spectrum is converted back into time domain PCM audio via an inverse Modified 708Discrete Cosine Transform (MDCT). A detailed description of the MDCT is available in 709<span class="cite">[<a 710href="#XSporer/Brandenburg/Edler">1</a>]</span>. 711<!--l. 485--><p class="noindent" >Note that the PCM produced directly from the MDCT is not yet finished audio; it must be 712 713 714 715lapped with surrounding frames using an appropriate window (such as the Vorbis window) before 716the MDCT can be considered orthogonal. 717<!--l. 492--><p class="noindent" ><span class="paragraphHead"><a 718 id="x1-330001.3.2"></a><span 719class="cmbx-12">overlap/add data</span></span> 720Windowed MDCT output is overlapped and added with the right hand data of the previous 721window such that the 3/4 point of the previous window is aligned with the 1/4 point of the 722current window (as illustrated in the window overlap diagram). At this point, the audio data 723between the center of the previous frame and the center of the current frame is now finished and 724ready to be returned. 725<!--l. 501--><p class="noindent" ><span class="paragraphHead"><a 726 id="x1-340001.3.2"></a><span 727class="cmbx-12">cache right hand data</span></span> 728The decoder must cache the right hand portion of the current frame to be lapped with the left 729hand portion of the next frame. 730<!--l. 507--><p class="noindent" ><span class="paragraphHead"><a 731 id="x1-350001.3.2"></a><span 732class="cmbx-12">return finished audio data</span></span> 733The overlapped portion produced from overlapping the previous and current frame data 734is finished data to be returned by the decoder. This data spans from the center of 735the previous window to the center of the current window. In the case of same-sized 736windows, the amount of data to return is one-half block consisting of and only of the 737overlapped portions. When overlapping a short and long window, much of the returned 738range is not actually overlap. This does not damage transform orthogonality. Pay 739attention however to returning the correct data range; the amount of data to be returned 740is: 741<!--l. 519--><p class="noindent" > 742<div class="fancyvrb" id="fancyvrb1"> 743<a 744 id="x1-35002r1"></a><span 745class="cmr-6">1</span><span 746class="cmtt-8"> </span><span 747class="cmtt-8"> window_blocksize(previous_window)/4+window_blocksize(current_window)/4</span> 748</div> 749<!--l. 523--><p class="noindent" >from the center of the previous window to the center of the current window. 750<!--l. 526--><p class="noindent" >Data is not returned from the first frame; it must be used to ’prime’ the decode engine. The 751encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper 752PCM 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. 6--><p class="noindent" > 762<h4 class="subsectionHead"><span class="titlemark">2.1 </span> <a 763 id="x1-370002.1"></a>Overview</h4> 764<!--l. 8--><p class="noindent" >The Vorbis codec uses relatively unstructured raw packets containing arbitrary-width binary 765integer fields. Logically, these packets are a bitstream in which bits are coded one-by-one by the 766encoder and then read one-by-one in the same monotonically increasing order by the decoder. 767Most current binary storage arrangements group bits into a native word size of eight bits 768(octets), sixteen bits, thirty-two bits or, less commonly other fixed word sizes. The Vorbis 769bitpacking convention specifies the correct mapping of the logical packet bitstream into an actual 770representation in fixed-width words. 771<!--l. 19--><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. 21--><p class="noindent" >In most contemporary architectures, a ’byte’ is synonymous with an ’octet’, that is, eight bits. 775This has not always been the case; seven, ten, eleven and sixteen bit ’bytes’ have been used. 776For purposes of the bitpacking convention, a byte implies the native, smallest integer 777storage representation offered by a platform. On modern platforms, this is generally 778assumed to be eight bits (not necessarily because of the processor but because of the 779filesystem/memory architecture. Modern filesystems invariably offer bytes as the fundamental 780atom of storage). A ’word’ is an integer size that is a grouped multiple of this smallest 781size. 782<!--l. 32--><p class="noindent" >The most ubiquitous architectures today consider a ’byte’ to be an octet (eight bits) and a word 783to be a group of two, four or eight bytes (16, 32 or 64 bits). Note however that the Vorbis 784bitpacking convention is still well defined for any native byte size; Vorbis uses the native 785bit-width of a given storage system. This document assumes that a byte is one octet for purposes 786of example. 787<!--l. 39--><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. 41--><p class="noindent" >A byte has a well-defined ’least significant’ bit (LSb), which is the only bit set when the byte is 794storing the two’s complement integer value +1. A byte’s ’most significant’ bit (MSb) is at the 795opposite end of the byte. Bits in a byte are numbered from zero at the LSb to <span 796class="cmmi-12">n </span>(<span 797class="cmmi-12">n </span>= 7 in an 798octet) for the MSb. 799<!--l. 50--><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. 52--><p class="noindent" >Words are native groupings of multiple bytes. Several byte orderings are possible in a word; the 803common ones are 3-2-1-0 (’big endian’ or ’most significant byte first’ in which the 804highest-valued byte comes first), 0-1-2-3 (’little endian’ or ’least significant byte first’ in 805which the lowest value byte comes first) and less commonly 3-1-2-0 and 0-2-1-3 (’mixed 806endian’). 807<!--l. 59--><p class="noindent" >The Vorbis bitpacking convention specifies storage and bitstream manipulation at the byte, not 808word, level, thus host word ordering is of a concern only during optimization when writing high 809performance code that operates on a word of storage at a time rather than by byte. 810Logically, bytes are always coded and decoded in order from byte zero through byte 811<span 812class="cmmi-12">n</span>. 813<!--l. 68--><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. 70--><p class="noindent" >The Vorbis codec has need to code arbitrary bit-width integers, from zero to 32 bits 817wide, into packets. These integer fields are not aligned to the boundaries of the byte 818representation; the next field is written at the bit position at which the previous field 819ends. 820<!--l. 75--><p class="noindent" >The encoder logically packs integers by writing the LSb of a binary integer to the logical 821bitstream first, followed by next least significant bit, etc, until the requested number of bits 822have been coded. When packing the bits into bytes, the encoder begins by placing 823the LSb of the integer to be written into the least significant unused bit position of 824the destination byte, followed by the next-least significant bit of the source integer 825and so on up to the requested number of bits. When all bits of the destination byte 826have been filled, encoding continues by zeroing all bits of the next byte and writing 827the next bit into the bit position 0 of that byte. Decoding follows the same process 828 829 830 831as encoding, but by reading bits from the byte stream and reassembling them into 832integers. 833<!--l. 90--><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. 92--><p class="noindent" >The signedness of a specific number resulting from decode is to be interpreted by the decoder 837given decode context. That is, the three bit binary pattern ’b111’ can be taken to represent 838either ’seven’ as an unsigned integer, or ’-1’ as a signed, two’s complement integer. The 839encoder and decoder are responsible for knowing if fields are to be treated as signed or 840unsigned. 841<!--l. 101--><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. 103--><p class="noindent" >Code the 4 bit integer value ’12’ [b1100] into an empty bytestream. Bytestream result: 845<!--l. 106--><p class="noindent" > 846<div class="fancyvrb" id="fancyvrb2"> 847<a 848 id="x1-43002r1"></a><span 849class="cmr-6">1</span><span 850class="cmtt-8"> </span><span 851class="cmtt-8"> </span><span 852class="cmtt-8"> </span><span 853class="cmtt-8"> </span><span 854class="cmtt-8"> </span><span 855class="cmtt-8"> </span><span 856class="cmtt-8"> </span><span 857class="cmtt-8"> </span><span 858class="cmtt-8"> </span><span 859class="cmtt-8"> </span><span 860class="cmtt-8"> </span><span 861class="cmtt-8"> </span><span 862class="cmtt-8"> </span><span 863class="cmtt-8"> </span><span 864class="cmtt-8"> </span><span 865class="cmtt-8"> |</span> 866<br class="fancyvrb" /><a 867 id="x1-43004r2"></a><span 868class="cmr-6">2</span><span 869class="cmtt-8"> </span><span 870class="cmtt-8"> </span><span 871class="cmtt-8"> </span><span 872class="cmtt-8"> </span><span 873class="cmtt-8"> </span><span 874class="cmtt-8"> </span><span 875class="cmtt-8"> </span><span 876class="cmtt-8"> </span><span 877class="cmtt-8"> </span><span 878class="cmtt-8"> </span><span 879class="cmtt-8"> </span><span 880class="cmtt-8"> </span><span 881class="cmtt-8"> </span><span 882class="cmtt-8"> </span><span 883class="cmtt-8"> </span><span 884class="cmtt-8"> V</span> 885<br class="fancyvrb" /><a 886 id="x1-43006r3"></a><span 887class="cmr-6">3</span><span 888class="cmtt-8"> </span><span 889class="cmtt-8"> </span> 890<br class="fancyvrb" /><a 891 id="x1-43008r4"></a><span 892class="cmr-6">4</span><span 893class="cmtt-8"> </span><span 894class="cmtt-8"> </span><span 895class="cmtt-8"> </span><span 896class="cmtt-8"> </span><span 897class="cmtt-8"> </span><span 898class="cmtt-8"> </span><span 899class="cmtt-8"> </span><span 900class="cmtt-8"> </span><span 901class="cmtt-8"> </span><span 902class="cmtt-8"> 7</span><span 903class="cmtt-8"> 6</span><span 904class="cmtt-8"> 5</span><span 905class="cmtt-8"> 4</span><span 906class="cmtt-8"> 3</span><span 907class="cmtt-8"> 2</span><span 908class="cmtt-8"> 1</span><span 909class="cmtt-8"> 0</span> 910<br class="fancyvrb" /><a 911 id="x1-43010r5"></a><span 912class="cmr-6">5</span><span 913class="cmtt-8"> </span><span 914class="cmtt-8"> byte</span><span 915class="cmtt-8"> 0</span><span 916class="cmtt-8"> [0</span><span 917class="cmtt-8"> 0</span><span 918class="cmtt-8"> 0</span><span 919class="cmtt-8"> 0</span><span 920class="cmtt-8"> 1</span><span 921class="cmtt-8"> 1</span><span 922class="cmtt-8"> 0</span><span 923class="cmtt-8"> 0]</span><span 924class="cmtt-8"> </span><span 925class="cmtt-8"> <-</span> 926<br class="fancyvrb" /><a 927 id="x1-43012r6"></a><span 928class="cmr-6">6</span><span 929class="cmtt-8"> </span><span 930class="cmtt-8"> byte</span><span 931class="cmtt-8"> 1</span><span 932class="cmtt-8"> [</span><span 933class="cmtt-8"> </span><span 934class="cmtt-8"> </span><span 935class="cmtt-8"> </span><span 936class="cmtt-8"> </span><span 937class="cmtt-8"> </span><span 938class="cmtt-8"> </span><span 939class="cmtt-8"> </span><span 940class="cmtt-8"> </span><span 941class="cmtt-8"> </span><span 942class="cmtt-8"> </span><span 943class="cmtt-8"> </span><span 944class="cmtt-8"> </span><span 945class="cmtt-8"> </span><span 946class="cmtt-8"> </span><span 947class="cmtt-8"> ]</span> 948<br class="fancyvrb" /><a 949 id="x1-43014r7"></a><span 950class="cmr-6">7</span><span 951class="cmtt-8"> </span><span 952class="cmtt-8"> byte</span><span 953class="cmtt-8"> 2</span><span 954class="cmtt-8"> [</span><span 955class="cmtt-8"> </span><span 956class="cmtt-8"> </span><span 957class="cmtt-8"> </span><span 958class="cmtt-8"> </span><span 959class="cmtt-8"> </span><span 960class="cmtt-8"> </span><span 961class="cmtt-8"> </span><span 962class="cmtt-8"> </span><span 963class="cmtt-8"> </span><span 964class="cmtt-8"> </span><span 965class="cmtt-8"> </span><span 966class="cmtt-8"> </span><span 967class="cmtt-8"> </span><span 968class="cmtt-8"> </span><span 969class="cmtt-8"> ]</span> 970<br class="fancyvrb" /><a 971 id="x1-43016r8"></a><span 972class="cmr-6">8</span><span 973class="cmtt-8"> </span><span 974class="cmtt-8"> byte</span><span 975class="cmtt-8"> 3</span><span 976class="cmtt-8"> [</span><span 977class="cmtt-8"> </span><span 978class="cmtt-8"> </span><span 979class="cmtt-8"> </span><span 980class="cmtt-8"> </span><span 981class="cmtt-8"> </span><span 982class="cmtt-8"> </span><span 983class="cmtt-8"> </span><span 984class="cmtt-8"> </span><span 985class="cmtt-8"> </span><span 986class="cmtt-8"> </span><span 987class="cmtt-8"> </span><span 988class="cmtt-8"> </span><span 989class="cmtt-8"> </span><span 990class="cmtt-8"> </span><span 991class="cmtt-8"> ]</span> 992<br class="fancyvrb" /><a 993 id="x1-43018r9"></a><span 994class="cmr-6">9</span><span 995class="cmtt-8"> </span><span 996class="cmtt-8"> </span><span 997class="cmtt-8"> </span><span 998class="cmtt-8"> </span><span 999class="cmtt-8"> </span><span 1000class="cmtt-8"> </span><span 1001class="cmtt-8"> </span><span 1002class="cmtt-8"> </span><span 1003class="cmtt-8"> </span><span 1004class="cmtt-8"> </span><span 1005class="cmtt-8"> </span><span 1006class="cmtt-8"> </span><span 1007class="cmtt-8"> </span><span 1008class="cmtt-8"> </span><span 1009class="cmtt-8"> ...</span> 1010<br class="fancyvrb" /><a 1011 id="x1-43020r10"></a><span 1012class="cmr-6">10</span><span 1013class="cmtt-8"> </span><span 1014class="cmtt-8"> byte</span><span 1015class="cmtt-8"> n</span><span 1016class="cmtt-8"> [</span><span 1017class="cmtt-8"> </span><span 1018class="cmtt-8"> </span><span 1019class="cmtt-8"> </span><span 1020class="cmtt-8"> </span><span 1021class="cmtt-8"> </span><span 1022class="cmtt-8"> </span><span 1023class="cmtt-8"> </span><span 1024class="cmtt-8"> </span><span 1025class="cmtt-8"> </span><span 1026class="cmtt-8"> </span><span 1027class="cmtt-8"> </span><span 1028class="cmtt-8"> </span><span 1029class="cmtt-8"> </span><span 1030class="cmtt-8"> </span><span 1031class="cmtt-8"> ]</span><span 1032class="cmtt-8"> </span><span 1033class="cmtt-8"> bytestream</span><span 1034class="cmtt-8"> length</span><span 1035class="cmtt-8"> ==</span><span 1036class="cmtt-8"> 1</span><span 1037class="cmtt-8"> byte</span> 1038<br class="fancyvrb" /><a 1039 id="x1-43022r11"></a><span 1040class="cmr-6">11</span><span 1041class="cmtt-8"> </span><span 1042class="cmtt-8"> </span> 1043</div> 1044<!--l. 121--><p class="noindent" >Continue by coding the 3 bit integer value ’-1’ [b111]: 1045<!--l. 123--><p class="noindent" > 1046<div class="fancyvrb" id="fancyvrb3"> 1047<a 1048 id="x1-43024r1"></a><span 1049class="cmr-6">1</span><span 1050class="cmtt-8"> </span><span 1051class="cmtt-8"> </span><span 1052class="cmtt-8"> </span><span 1053class="cmtt-8"> </span><span 1054class="cmtt-8"> </span><span 1055class="cmtt-8"> </span><span 1056class="cmtt-8"> </span><span 1057class="cmtt-8"> </span><span 1058class="cmtt-8"> </span><span 1059class="cmtt-8"> |</span> 1060<br class="fancyvrb" /><a 1061 id="x1-43026r2"></a><span 1062class="cmr-6">2</span><span 1063class="cmtt-8"> </span><span 1064class="cmtt-8"> </span><span 1065class="cmtt-8"> </span><span 1066class="cmtt-8"> </span><span 1067class="cmtt-8"> </span><span 1068class="cmtt-8"> </span><span 1069class="cmtt-8"> </span><span 1070class="cmtt-8"> </span><span 1071class="cmtt-8"> </span><span 1072class="cmtt-8"> V</span> 1073<br class="fancyvrb" /><a 1074 id="x1-43028r3"></a><span 1075class="cmr-6">3</span><span 1076class="cmtt-8"> </span><span 1077class="cmtt-8"> </span> 1078<br class="fancyvrb" /><a 1079 id="x1-43030r4"></a><span 1080class="cmr-6">4</span><span 1081class="cmtt-8"> </span><span 1082class="cmtt-8"> </span><span 1083class="cmtt-8"> </span><span 1084class="cmtt-8"> </span><span 1085class="cmtt-8"> </span><span 1086class="cmtt-8"> </span><span 1087class="cmtt-8"> </span><span 1088class="cmtt-8"> </span><span 1089class="cmtt-8"> </span><span 1090class="cmtt-8"> 7</span><span 1091class="cmtt-8"> 6</span><span 1092class="cmtt-8"> 5</span><span 1093class="cmtt-8"> 4</span><span 1094class="cmtt-8"> 3</span><span 1095class="cmtt-8"> 2</span><span 1096class="cmtt-8"> 1</span><span 1097class="cmtt-8"> 0</span> 1098<br class="fancyvrb" /><a 1099 id="x1-43032r5"></a><span 1100class="cmr-6">5</span><span 1101class="cmtt-8"> </span><span 1102class="cmtt-8"> byte</span><span 1103class="cmtt-8"> 0</span><span 1104class="cmtt-8"> [0</span><span 1105class="cmtt-8"> 1</span><span 1106class="cmtt-8"> 1</span><span 1107class="cmtt-8"> 1</span><span 1108class="cmtt-8"> 1</span><span 1109class="cmtt-8"> 1</span><span 1110class="cmtt-8"> 0</span><span 1111class="cmtt-8"> 0]</span><span 1112class="cmtt-8"> </span><span 1113class="cmtt-8"> <-</span> 1114<br class="fancyvrb" /><a 1115 id="x1-43034r6"></a><span 1116class="cmr-6">6</span><span 1117class="cmtt-8"> </span><span 1118class="cmtt-8"> byte</span><span 1119class="cmtt-8"> 1</span><span 1120class="cmtt-8"> [</span><span 1121class="cmtt-8"> </span><span 1122class="cmtt-8"> </span><span 1123class="cmtt-8"> </span><span 1124class="cmtt-8"> </span><span 1125class="cmtt-8"> </span><span 1126class="cmtt-8"> </span><span 1127class="cmtt-8"> </span><span 1128class="cmtt-8"> </span><span 1129class="cmtt-8"> </span><span 1130class="cmtt-8"> </span><span 1131class="cmtt-8"> </span><span 1132class="cmtt-8"> </span><span 1133class="cmtt-8"> </span><span 1134class="cmtt-8"> </span><span 1135class="cmtt-8"> ]</span> 1136 1137 1138 1139<br class="fancyvrb" /><a 1140 id="x1-43036r7"></a><span 1141class="cmr-6">7</span><span 1142class="cmtt-8"> </span><span 1143class="cmtt-8"> byte</span><span 1144class="cmtt-8"> 2</span><span 1145class="cmtt-8"> [</span><span 1146class="cmtt-8"> </span><span 1147class="cmtt-8"> </span><span 1148class="cmtt-8"> </span><span 1149class="cmtt-8"> </span><span 1150class="cmtt-8"> </span><span 1151class="cmtt-8"> </span><span 1152class="cmtt-8"> </span><span 1153class="cmtt-8"> </span><span 1154class="cmtt-8"> </span><span 1155class="cmtt-8"> </span><span 1156class="cmtt-8"> </span><span 1157class="cmtt-8"> </span><span 1158class="cmtt-8"> </span><span 1159class="cmtt-8"> </span><span 1160class="cmtt-8"> ]</span> 1161<br class="fancyvrb" /><a 1162 id="x1-43038r8"></a><span 1163class="cmr-6">8</span><span 1164class="cmtt-8"> </span><span 1165class="cmtt-8"> byte</span><span 1166class="cmtt-8"> 3</span><span 1167class="cmtt-8"> [</span><span 1168class="cmtt-8"> </span><span 1169class="cmtt-8"> </span><span 1170class="cmtt-8"> </span><span 1171class="cmtt-8"> </span><span 1172class="cmtt-8"> </span><span 1173class="cmtt-8"> </span><span 1174class="cmtt-8"> </span><span 1175class="cmtt-8"> </span><span 1176class="cmtt-8"> </span><span 1177class="cmtt-8"> </span><span 1178class="cmtt-8"> </span><span 1179class="cmtt-8"> </span><span 1180class="cmtt-8"> </span><span 1181class="cmtt-8"> </span><span 1182class="cmtt-8"> ]</span> 1183<br class="fancyvrb" /><a 1184 id="x1-43040r9"></a><span 1185class="cmr-6">9</span><span 1186class="cmtt-8"> </span><span 1187class="cmtt-8"> </span><span 1188class="cmtt-8"> </span><span 1189class="cmtt-8"> </span><span 1190class="cmtt-8"> </span><span 1191class="cmtt-8"> </span><span 1192class="cmtt-8"> </span><span 1193class="cmtt-8"> </span><span 1194class="cmtt-8"> </span><span 1195class="cmtt-8"> </span><span 1196class="cmtt-8"> </span><span 1197class="cmtt-8"> </span><span 1198class="cmtt-8"> </span><span 1199class="cmtt-8"> </span><span 1200class="cmtt-8"> ...</span> 1201<br class="fancyvrb" /><a 1202 id="x1-43042r10"></a><span 1203class="cmr-6">10</span><span 1204class="cmtt-8"> </span><span 1205class="cmtt-8"> byte</span><span 1206class="cmtt-8"> n</span><span 1207class="cmtt-8"> [</span><span 1208class="cmtt-8"> </span><span 1209class="cmtt-8"> </span><span 1210class="cmtt-8"> </span><span 1211class="cmtt-8"> </span><span 1212class="cmtt-8"> </span><span 1213class="cmtt-8"> </span><span 1214class="cmtt-8"> </span><span 1215class="cmtt-8"> </span><span 1216class="cmtt-8"> </span><span 1217class="cmtt-8"> </span><span 1218class="cmtt-8"> </span><span 1219class="cmtt-8"> </span><span 1220class="cmtt-8"> </span><span 1221class="cmtt-8"> </span><span 1222class="cmtt-8"> ]</span><span 1223class="cmtt-8"> </span><span 1224class="cmtt-8"> bytestream</span><span 1225class="cmtt-8"> length</span><span 1226class="cmtt-8"> ==</span><span 1227class="cmtt-8"> 1</span><span 1228class="cmtt-8"> byte</span> 1229</div> 1230<!--l. 137--><p class="noindent" >Continue by coding the 7 bit integer value ’17’ [b0010001]: 1231<!--l. 139--><p class="noindent" > 1232<div class="fancyvrb" id="fancyvrb4"> 1233<a 1234 id="x1-43044r1"></a><span 1235class="cmr-6">1</span><span 1236class="cmtt-8"> </span><span 1237class="cmtt-8"> </span><span 1238class="cmtt-8"> </span><span 1239class="cmtt-8"> </span><span 1240class="cmtt-8"> </span><span 1241class="cmtt-8"> </span><span 1242class="cmtt-8"> </span><span 1243class="cmtt-8"> </span><span 1244class="cmtt-8"> </span><span 1245class="cmtt-8"> </span><span 1246class="cmtt-8"> </span><span 1247class="cmtt-8"> |</span> 1248<br class="fancyvrb" /><a 1249 id="x1-43046r2"></a><span 1250class="cmr-6">2</span><span 1251class="cmtt-8"> </span><span 1252class="cmtt-8"> </span><span 1253class="cmtt-8"> </span><span 1254class="cmtt-8"> </span><span 1255class="cmtt-8"> </span><span 1256class="cmtt-8"> </span><span 1257class="cmtt-8"> </span><span 1258class="cmtt-8"> </span><span 1259class="cmtt-8"> </span><span 1260class="cmtt-8"> </span><span 1261class="cmtt-8"> </span><span 1262class="cmtt-8"> V</span> 1263<br class="fancyvrb" /><a 1264 id="x1-43048r3"></a><span 1265class="cmr-6">3</span><span 1266class="cmtt-8"> </span><span 1267class="cmtt-8"> </span> 1268<br class="fancyvrb" /><a 1269 id="x1-43050r4"></a><span 1270class="cmr-6">4</span><span 1271class="cmtt-8"> </span><span 1272class="cmtt-8"> </span><span 1273class="cmtt-8"> </span><span 1274class="cmtt-8"> </span><span 1275class="cmtt-8"> </span><span 1276class="cmtt-8"> </span><span 1277class="cmtt-8"> </span><span 1278class="cmtt-8"> </span><span 1279class="cmtt-8"> </span><span 1280class="cmtt-8"> 7</span><span 1281class="cmtt-8"> 6</span><span 1282class="cmtt-8"> 5</span><span 1283class="cmtt-8"> 4</span><span 1284class="cmtt-8"> 3</span><span 1285class="cmtt-8"> 2</span><span 1286class="cmtt-8"> 1</span><span 1287class="cmtt-8"> 0</span> 1288<br class="fancyvrb" /><a 1289 id="x1-43052r5"></a><span 1290class="cmr-6">5</span><span 1291class="cmtt-8"> </span><span 1292class="cmtt-8"> byte</span><span 1293class="cmtt-8"> 0</span><span 1294class="cmtt-8"> [1</span><span 1295class="cmtt-8"> 1</span><span 1296class="cmtt-8"> 1</span><span 1297class="cmtt-8"> 1</span><span 1298class="cmtt-8"> 1</span><span 1299class="cmtt-8"> 1</span><span 1300class="cmtt-8"> 0</span><span 1301class="cmtt-8"> 0]</span> 1302<br class="fancyvrb" /><a 1303 id="x1-43054r6"></a><span 1304class="cmr-6">6</span><span 1305class="cmtt-8"> </span><span 1306class="cmtt-8"> byte</span><span 1307class="cmtt-8"> 1</span><span 1308class="cmtt-8"> [0</span><span 1309class="cmtt-8"> 0</span><span 1310class="cmtt-8"> 0</span><span 1311class="cmtt-8"> 0</span><span 1312class="cmtt-8"> 1</span><span 1313class="cmtt-8"> 0</span><span 1314class="cmtt-8"> 0</span><span 1315class="cmtt-8"> 0]</span><span 1316class="cmtt-8"> </span><span 1317class="cmtt-8"> <-</span> 1318<br class="fancyvrb" /><a 1319 id="x1-43056r7"></a><span 1320class="cmr-6">7</span><span 1321class="cmtt-8"> </span><span 1322class="cmtt-8"> byte</span><span 1323class="cmtt-8"> 2</span><span 1324class="cmtt-8"> [</span><span 1325class="cmtt-8"> </span><span 1326class="cmtt-8"> </span><span 1327class="cmtt-8"> </span><span 1328class="cmtt-8"> </span><span 1329class="cmtt-8"> </span><span 1330class="cmtt-8"> </span><span 1331class="cmtt-8"> </span><span 1332class="cmtt-8"> </span><span 1333class="cmtt-8"> </span><span 1334class="cmtt-8"> </span><span 1335class="cmtt-8"> </span><span 1336class="cmtt-8"> </span><span 1337class="cmtt-8"> </span><span 1338class="cmtt-8"> </span><span 1339class="cmtt-8"> ]</span> 1340<br class="fancyvrb" /><a 1341 id="x1-43058r8"></a><span 1342class="cmr-6">8</span><span 1343class="cmtt-8"> </span><span 1344class="cmtt-8"> byte</span><span 1345class="cmtt-8"> 3</span><span 1346class="cmtt-8"> [</span><span 1347class="cmtt-8"> </span><span 1348class="cmtt-8"> </span><span 1349class="cmtt-8"> </span><span 1350class="cmtt-8"> </span><span 1351class="cmtt-8"> </span><span 1352class="cmtt-8"> </span><span 1353class="cmtt-8"> </span><span 1354class="cmtt-8"> </span><span 1355class="cmtt-8"> </span><span 1356class="cmtt-8"> </span><span 1357class="cmtt-8"> </span><span 1358class="cmtt-8"> </span><span 1359class="cmtt-8"> </span><span 1360class="cmtt-8"> </span><span 1361class="cmtt-8"> ]</span> 1362<br class="fancyvrb" /><a 1363 id="x1-43060r9"></a><span 1364class="cmr-6">9</span><span 1365class="cmtt-8"> </span><span 1366class="cmtt-8"> </span><span 1367class="cmtt-8"> </span><span 1368class="cmtt-8"> </span><span 1369class="cmtt-8"> </span><span 1370class="cmtt-8"> </span><span 1371class="cmtt-8"> </span><span 1372class="cmtt-8"> </span><span 1373class="cmtt-8"> </span><span 1374class="cmtt-8"> </span><span 1375class="cmtt-8"> </span><span 1376class="cmtt-8"> </span><span 1377class="cmtt-8"> </span><span 1378class="cmtt-8"> </span><span 1379class="cmtt-8"> ...</span> 1380<br class="fancyvrb" /><a 1381 id="x1-43062r10"></a><span 1382class="cmr-6">10</span><span 1383class="cmtt-8"> </span><span 1384class="cmtt-8"> byte</span><span 1385class="cmtt-8"> n</span><span 1386class="cmtt-8"> [</span><span 1387class="cmtt-8"> </span><span 1388class="cmtt-8"> </span><span 1389class="cmtt-8"> </span><span 1390class="cmtt-8"> </span><span 1391class="cmtt-8"> </span><span 1392class="cmtt-8"> </span><span 1393class="cmtt-8"> </span><span 1394class="cmtt-8"> </span><span 1395class="cmtt-8"> </span><span 1396class="cmtt-8"> </span><span 1397class="cmtt-8"> </span><span 1398class="cmtt-8"> </span><span 1399class="cmtt-8"> </span><span 1400class="cmtt-8"> </span><span 1401class="cmtt-8"> ]</span><span 1402class="cmtt-8"> </span><span 1403class="cmtt-8"> bytestream</span><span 1404class="cmtt-8"> length</span><span 1405class="cmtt-8"> ==</span><span 1406class="cmtt-8"> 2</span><span 1407class="cmtt-8"> bytes</span> 1408<br class="fancyvrb" /><a 1409 id="x1-43064r11"></a><span 1410class="cmr-6">11</span><span 1411class="cmtt-8"> </span><span 1412class="cmtt-8"> </span><span 1413class="cmtt-8"> </span><span 1414class="cmtt-8"> </span><span 1415class="cmtt-8"> </span><span 1416class="cmtt-8"> </span><span 1417class="cmtt-8"> </span><span 1418class="cmtt-8"> </span><span 1419class="cmtt-8"> </span><span 1420class="cmtt-8"> </span><span 1421class="cmtt-8"> </span><span 1422class="cmtt-8"> </span><span 1423class="cmtt-8"> </span><span 1424class="cmtt-8"> </span><span 1425class="cmtt-8"> </span><span 1426class="cmtt-8"> </span><span 1427class="cmtt-8"> </span><span 1428class="cmtt-8"> </span><span 1429class="cmtt-8"> </span><span 1430class="cmtt-8"> </span><span 1431class="cmtt-8"> </span><span 1432class="cmtt-8"> </span><span 1433class="cmtt-8"> </span><span 1434class="cmtt-8"> </span><span 1435class="cmtt-8"> </span><span 1436class="cmtt-8"> </span><span 1437class="cmtt-8"> </span><span 1438class="cmtt-8"> bit</span><span 1439class="cmtt-8"> cursor</span><span 1440class="cmtt-8"> ==</span><span 1441class="cmtt-8"> 6</span> 1442</div> 1443<!--l. 154--><p class="noindent" >Continue by coding the 13 bit integer value ’6969’ [b110 11001110 01]: 1444<!--l. 156--><p class="noindent" > 1445<div class="fancyvrb" id="fancyvrb5"> 1446<a 1447 id="x1-43066r1"></a><span 1448class="cmr-6">1</span><span 1449class="cmtt-8"> </span><span 1450class="cmtt-8"> </span><span 1451class="cmtt-8"> </span><span 1452class="cmtt-8"> </span><span 1453class="cmtt-8"> </span><span 1454class="cmtt-8"> </span><span 1455class="cmtt-8"> </span><span 1456class="cmtt-8"> </span><span 1457class="cmtt-8"> </span><span 1458class="cmtt-8"> </span><span 1459class="cmtt-8"> </span><span 1460class="cmtt-8"> </span><span 1461class="cmtt-8"> </span><span 1462class="cmtt-8"> </span><span 1463class="cmtt-8"> </span><span 1464class="cmtt-8"> </span><span 1465class="cmtt-8"> </span><span 1466class="cmtt-8"> |</span> 1467<br class="fancyvrb" /><a 1468 id="x1-43068r2"></a><span 1469class="cmr-6">2</span><span 1470class="cmtt-8"> </span><span 1471class="cmtt-8"> </span><span 1472class="cmtt-8"> </span><span 1473class="cmtt-8"> </span><span 1474class="cmtt-8"> </span><span 1475class="cmtt-8"> </span><span 1476class="cmtt-8"> </span><span 1477class="cmtt-8"> </span><span 1478class="cmtt-8"> </span><span 1479class="cmtt-8"> </span><span 1480class="cmtt-8"> </span><span 1481class="cmtt-8"> </span><span 1482class="cmtt-8"> </span><span 1483class="cmtt-8"> </span><span 1484class="cmtt-8"> </span><span 1485class="cmtt-8"> </span><span 1486class="cmtt-8"> </span><span 1487class="cmtt-8"> V</span> 1488<br class="fancyvrb" /><a 1489 id="x1-43070r3"></a><span 1490class="cmr-6">3</span><span 1491class="cmtt-8"> </span><span 1492class="cmtt-8"> </span> 1493<br class="fancyvrb" /><a 1494 id="x1-43072r4"></a><span 1495class="cmr-6">4</span><span 1496class="cmtt-8"> </span><span 1497class="cmtt-8"> </span><span 1498class="cmtt-8"> </span><span 1499class="cmtt-8"> </span><span 1500class="cmtt-8"> </span><span 1501class="cmtt-8"> </span><span 1502class="cmtt-8"> </span><span 1503class="cmtt-8"> </span><span 1504class="cmtt-8"> </span><span 1505class="cmtt-8"> 7</span><span 1506class="cmtt-8"> 6</span><span 1507class="cmtt-8"> 5</span><span 1508class="cmtt-8"> 4</span><span 1509class="cmtt-8"> 3</span><span 1510class="cmtt-8"> 2</span><span 1511class="cmtt-8"> 1</span><span 1512class="cmtt-8"> 0</span> 1513<br class="fancyvrb" /><a 1514 id="x1-43074r5"></a><span 1515class="cmr-6">5</span><span 1516class="cmtt-8"> </span><span 1517class="cmtt-8"> byte</span><span 1518class="cmtt-8"> 0</span><span 1519class="cmtt-8"> [1</span><span 1520class="cmtt-8"> 1</span><span 1521class="cmtt-8"> 1</span><span 1522class="cmtt-8"> 1</span><span 1523class="cmtt-8"> 1</span><span 1524class="cmtt-8"> 1</span><span 1525class="cmtt-8"> 0</span><span 1526class="cmtt-8"> 0]</span> 1527<br class="fancyvrb" /><a 1528 id="x1-43076r6"></a><span 1529class="cmr-6">6</span><span 1530class="cmtt-8"> </span><span 1531class="cmtt-8"> byte</span><span 1532class="cmtt-8"> 1</span><span 1533class="cmtt-8"> [0</span><span 1534class="cmtt-8"> 1</span><span 1535class="cmtt-8"> 0</span><span 1536class="cmtt-8"> 0</span><span 1537class="cmtt-8"> 1</span><span 1538class="cmtt-8"> 0</span><span 1539class="cmtt-8"> 0</span><span 1540class="cmtt-8"> 0]</span> 1541<br class="fancyvrb" /><a 1542 id="x1-43078r7"></a><span 1543class="cmr-6">7</span><span 1544class="cmtt-8"> </span><span 1545class="cmtt-8"> byte</span><span 1546class="cmtt-8"> 2</span><span 1547class="cmtt-8"> [1</span><span 1548class="cmtt-8"> 1</span><span 1549class="cmtt-8"> 0</span><span 1550class="cmtt-8"> 0</span><span 1551class="cmtt-8"> 1</span><span 1552class="cmtt-8"> 1</span><span 1553class="cmtt-8"> 1</span><span 1554class="cmtt-8"> 0]</span> 1555<br class="fancyvrb" /><a 1556 id="x1-43080r8"></a><span 1557class="cmr-6">8</span><span 1558class="cmtt-8"> </span><span 1559class="cmtt-8"> byte</span><span 1560class="cmtt-8"> 3</span><span 1561class="cmtt-8"> [0</span><span 1562class="cmtt-8"> 0</span><span 1563class="cmtt-8"> 0</span><span 1564class="cmtt-8"> 0</span><span 1565class="cmtt-8"> 0</span><span 1566class="cmtt-8"> 1</span><span 1567class="cmtt-8"> 1</span><span 1568class="cmtt-8"> 0]</span><span 1569class="cmtt-8"> </span><span 1570class="cmtt-8"> <-</span> 1571<br class="fancyvrb" /><a 1572 id="x1-43082r9"></a><span 1573class="cmr-6">9</span><span 1574class="cmtt-8"> </span><span 1575class="cmtt-8"> </span><span 1576class="cmtt-8"> </span><span 1577class="cmtt-8"> </span><span 1578class="cmtt-8"> </span><span 1579class="cmtt-8"> </span><span 1580class="cmtt-8"> </span><span 1581class="cmtt-8"> </span><span 1582class="cmtt-8"> </span><span 1583class="cmtt-8"> </span><span 1584class="cmtt-8"> </span><span 1585class="cmtt-8"> </span><span 1586class="cmtt-8"> </span><span 1587class="cmtt-8"> </span><span 1588class="cmtt-8"> ...</span> 1589<br class="fancyvrb" /><a 1590 id="x1-43084r10"></a><span 1591class="cmr-6">10</span><span 1592class="cmtt-8"> </span><span 1593class="cmtt-8"> byte</span><span 1594class="cmtt-8"> n</span><span 1595class="cmtt-8"> [</span><span 1596class="cmtt-8"> </span><span 1597class="cmtt-8"> </span><span 1598class="cmtt-8"> </span><span 1599class="cmtt-8"> </span><span 1600class="cmtt-8"> </span><span 1601class="cmtt-8"> </span><span 1602class="cmtt-8"> </span><span 1603class="cmtt-8"> </span><span 1604class="cmtt-8"> </span><span 1605class="cmtt-8"> </span><span 1606class="cmtt-8"> </span><span 1607class="cmtt-8"> </span><span 1608class="cmtt-8"> </span><span 1609class="cmtt-8"> </span><span 1610class="cmtt-8"> ]</span><span 1611class="cmtt-8"> </span><span 1612class="cmtt-8"> bytestream</span><span 1613class="cmtt-8"> length</span><span 1614class="cmtt-8"> ==</span><span 1615class="cmtt-8"> 4</span><span 1616class="cmtt-8"> bytes</span> 1617<br class="fancyvrb" /><a 1618 id="x1-43086r11"></a><span 1619class="cmr-6">11</span><span 1620class="cmtt-8"> </span><span 1621class="cmtt-8"> </span> 1622</div> 1623<!--l. 173--><p class="noindent" > 1624<h5 class="subsubsectionHead"><span class="titlemark">2.1.7 </span> <a 1625 id="x1-440002.1.7"></a>decoding example</h5> 1626<!--l. 175--><p class="noindent" >Reading from the beginning of the bytestream encoded in the above example: 1627<!--l. 177--><p class="noindent" > 1628<div class="fancyvrb" id="fancyvrb6"> 1629 1630 1631 1632<a 1633 id="x1-44002r1"></a><span 1634class="cmr-6">1</span><span 1635class="cmtt-8"> </span><span 1636class="cmtt-8"> </span><span 1637class="cmtt-8"> </span><span 1638class="cmtt-8"> </span><span 1639class="cmtt-8"> </span><span 1640class="cmtt-8"> </span><span 1641class="cmtt-8"> </span><span 1642class="cmtt-8"> </span><span 1643class="cmtt-8"> </span><span 1644class="cmtt-8"> </span><span 1645class="cmtt-8"> </span><span 1646class="cmtt-8"> </span><span 1647class="cmtt-8"> </span><span 1648class="cmtt-8"> </span><span 1649class="cmtt-8"> </span><span 1650class="cmtt-8"> </span><span 1651class="cmtt-8"> </span><span 1652class="cmtt-8"> </span><span 1653class="cmtt-8"> </span><span 1654class="cmtt-8"> </span><span 1655class="cmtt-8"> </span><span 1656class="cmtt-8"> </span><span 1657class="cmtt-8"> </span><span 1658class="cmtt-8"> |</span> 1659<br class="fancyvrb" /><a 1660 id="x1-44004r2"></a><span 1661class="cmr-6">2</span><span 1662class="cmtt-8"> </span><span 1663class="cmtt-8"> </span><span 1664class="cmtt-8"> </span><span 1665class="cmtt-8"> </span><span 1666class="cmtt-8"> </span><span 1667class="cmtt-8"> </span><span 1668class="cmtt-8"> </span><span 1669class="cmtt-8"> </span><span 1670class="cmtt-8"> </span><span 1671class="cmtt-8"> </span><span 1672class="cmtt-8"> </span><span 1673class="cmtt-8"> </span><span 1674class="cmtt-8"> </span><span 1675class="cmtt-8"> </span><span 1676class="cmtt-8"> </span><span 1677class="cmtt-8"> </span><span 1678class="cmtt-8"> </span><span 1679class="cmtt-8"> </span><span 1680class="cmtt-8"> </span><span 1681class="cmtt-8"> </span><span 1682class="cmtt-8"> </span><span 1683class="cmtt-8"> </span><span 1684class="cmtt-8"> </span><span 1685class="cmtt-8"> V</span> 1686<br class="fancyvrb" /><a 1687 id="x1-44006r3"></a><span 1688class="cmr-6">3</span><span 1689class="cmtt-8"> </span><span 1690class="cmtt-8"> </span> 1691<br class="fancyvrb" /><a 1692 id="x1-44008r4"></a><span 1693class="cmr-6">4</span><span 1694class="cmtt-8"> </span><span 1695class="cmtt-8"> </span><span 1696class="cmtt-8"> </span><span 1697class="cmtt-8"> </span><span 1698class="cmtt-8"> </span><span 1699class="cmtt-8"> </span><span 1700class="cmtt-8"> </span><span 1701class="cmtt-8"> </span><span 1702class="cmtt-8"> </span><span 1703class="cmtt-8"> 7</span><span 1704class="cmtt-8"> 6</span><span 1705class="cmtt-8"> 5</span><span 1706class="cmtt-8"> 4</span><span 1707class="cmtt-8"> 3</span><span 1708class="cmtt-8"> 2</span><span 1709class="cmtt-8"> 1</span><span 1710class="cmtt-8"> 0</span> 1711<br class="fancyvrb" /><a 1712 id="x1-44010r5"></a><span 1713class="cmr-6">5</span><span 1714class="cmtt-8"> </span><span 1715class="cmtt-8"> byte</span><span 1716class="cmtt-8"> 0</span><span 1717class="cmtt-8"> [1</span><span 1718class="cmtt-8"> 1</span><span 1719class="cmtt-8"> 1</span><span 1720class="cmtt-8"> 1</span><span 1721class="cmtt-8"> 1</span><span 1722class="cmtt-8"> 1</span><span 1723class="cmtt-8"> 0</span><span 1724class="cmtt-8"> 0]</span><span 1725class="cmtt-8"> </span><span 1726class="cmtt-8"> <-</span> 1727<br class="fancyvrb" /><a 1728 id="x1-44012r6"></a><span 1729class="cmr-6">6</span><span 1730class="cmtt-8"> </span><span 1731class="cmtt-8"> byte</span><span 1732class="cmtt-8"> 1</span><span 1733class="cmtt-8"> [0</span><span 1734class="cmtt-8"> 1</span><span 1735class="cmtt-8"> 0</span><span 1736class="cmtt-8"> 0</span><span 1737class="cmtt-8"> 1</span><span 1738class="cmtt-8"> 0</span><span 1739class="cmtt-8"> 0</span><span 1740class="cmtt-8"> 0]</span> 1741<br class="fancyvrb" /><a 1742 id="x1-44014r7"></a><span 1743class="cmr-6">7</span><span 1744class="cmtt-8"> </span><span 1745class="cmtt-8"> byte</span><span 1746class="cmtt-8"> 2</span><span 1747class="cmtt-8"> [1</span><span 1748class="cmtt-8"> 1</span><span 1749class="cmtt-8"> 0</span><span 1750class="cmtt-8"> 0</span><span 1751class="cmtt-8"> 1</span><span 1752class="cmtt-8"> 1</span><span 1753class="cmtt-8"> 1</span><span 1754class="cmtt-8"> 0]</span> 1755<br class="fancyvrb" /><a 1756 id="x1-44016r8"></a><span 1757class="cmr-6">8</span><span 1758class="cmtt-8"> </span><span 1759class="cmtt-8"> byte</span><span 1760class="cmtt-8"> 3</span><span 1761class="cmtt-8"> [0</span><span 1762class="cmtt-8"> 0</span><span 1763class="cmtt-8"> 0</span><span 1764class="cmtt-8"> 0</span><span 1765class="cmtt-8"> 0</span><span 1766class="cmtt-8"> 1</span><span 1767class="cmtt-8"> 1</span><span 1768class="cmtt-8"> 0]</span><span 1769class="cmtt-8"> </span><span 1770class="cmtt-8"> bytestream</span><span 1771class="cmtt-8"> length</span><span 1772class="cmtt-8"> ==</span><span 1773class="cmtt-8"> 4</span><span 1774class="cmtt-8"> bytes</span> 1775<br class="fancyvrb" /><a 1776 id="x1-44018r9"></a><span 1777class="cmr-6">9</span><span 1778class="cmtt-8"> </span><span 1779class="cmtt-8"> </span> 1780</div> 1781<!--l. 190--><p class="noindent" >We read two, two-bit integer fields, resulting in the returned numbers ’b00’ and ’b11’. Two things 1782are worth noting here: 1783 <ul class="itemize1"> 1784 <li class="itemize">Although these four bits were originally written as a single four-bit integer, reading 1785 some other combination of bit-widths from the bitstream is well defined. There are 1786 no artificial alignment boundaries maintained in the bitstream. 1787 </li> 1788 <li class="itemize">The second value is the two-bit-wide integer ’b11’. This value may be interpreted 1789 either as the unsigned value ’3’, or the signed value ’-1’. Signedness is dependent on 1790 decode context.</li></ul> 1791<!--l. 208--><p class="noindent" > 1792<h5 class="subsubsectionHead"><span class="titlemark">2.1.8 </span> <a 1793 id="x1-450002.1.8"></a>end-of-packet alignment</h5> 1794<!--l. 210--><p class="noindent" >The typical use of bitpacking is to produce many independent byte-aligned packets which are 1795embedded into a larger byte-aligned container structure, such as an Ogg transport bitstream. 1796Externally, each bytestream (encoded bitstream) must begin and end on a byte boundary. Often, 1797the encoded bitstream is not an integer number of bytes, and so there is unused (uncoded) space 1798in the last byte of a packet. 1799<!--l. 218--><p class="noindent" >Unused space in the last byte of a bytestream is always zeroed during the coding process. Thus, 1800should this unused space be read, it will return binary zeroes. 1801<!--l. 222--><p class="noindent" >Attempting to read past the end of an encoded packet results in an ’end-of-packet’ condition. 1802End-of-packet is not to be considered an error; it is merely a state indicating that there is 1803insufficient remaining data to fulfill the desired read size. Vorbis uses truncated packets as a 1804normal mode of operation, and as such, decoders must handle reading past the end of a packet as 1805a typical mode of operation. Any further read operations after an ’end-of-packet’ condition shall 1806also return ’end-of-packet’. 1807 1808 1809 1810<!--l. 233--><p class="noindent" > 1811<h5 class="subsubsectionHead"><span class="titlemark">2.1.9 </span> <a 1812 id="x1-460002.1.9"></a>reading zero bits</h5> 1813<!--l. 235--><p class="noindent" >Reading a zero-bit-wide integer returns the value ’0’ and does not increment the stream cursor. 1814Reading to the end of the packet (but not past, such that an ’end-of-packet’ condition has not 1815triggered) and then reading a zero bit integer shall succeed, returning 0, and not trigger an 1816end-of-packet condition. Reading a zero-bit-wide integer after a previous read sets ’end-of-packet’ 1817shall also fail with ’end-of-packet’. 1818 1819 1820 1821 1822 1823 1824<h3 class="sectionHead"><span class="titlemark">3 </span> <a 1825 id="x1-470003"></a>Probability Model and Codebooks</h3> 1826<!--l. 6--><p class="noindent" > 1827<h4 class="subsectionHead"><span class="titlemark">3.1 </span> <a 1828 id="x1-480003.1"></a>Overview</h4> 1829<!--l. 8--><p class="noindent" >Unlike practically every other mainstream audio codec, Vorbis has no statically configured 1830probability model, instead packing all entropy decoding configuration, VQ and Huffman, into the 1831bitstream itself in the third header, the codec setup header. This packed configuration consists of 1832multiple ’codebooks’, each containing a specific Huffman-equivalent representation for decoding 1833compressed codewords as well as an optional lookup table of output vector values to which a 1834decoded Huffman value is applied as an offset, generating the final decoded output corresponding 1835to a given compressed codeword. 1836<!--l. 18--><p class="noindent" > 1837<h5 class="subsubsectionHead"><span class="titlemark">3.1.1 </span> <a 1838 id="x1-490003.1.1"></a>Bitwise operation</h5> 1839<!--l. 19--><p class="noindent" >The codebook mechanism is built on top of the vorbis bitpacker. Both the codebooks themselves 1840and the codewords they decode are unrolled from a packet as a series of arbitrary-width values 1841read from the stream according to <a 1842href="#x1-360002">Section 2</a>, “<a 1843href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>”. 1844<!--l. 27--><p class="noindent" > 1845<h4 class="subsectionHead"><span class="titlemark">3.2 </span> <a 1846 id="x1-500003.2"></a>Packed codebook format</h4> 1847<!--l. 29--><p class="noindent" >For purposes of the examples below, we assume that the storage system’s native byte width is 1848eight bits. This is not universally true; see <a 1849href="#x1-360002">Section 2</a>, “<a 1850href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>” for discussion 1851relating to non-eight-bit bytes. 1852 1853 1854 1855<!--l. 34--><p class="noindent" > 1856<h5 class="subsubsectionHead"><span class="titlemark">3.2.1 </span> <a 1857 id="x1-510003.2.1"></a>codebook decode</h5> 1858<!--l. 36--><p class="noindent" >A codebook begins with a 24 bit sync pattern, 0x564342: 1859<!--l. 38--><p class="noindent" > 1860<div class="fancyvrb" id="fancyvrb7"> 1861<a 1862 id="x1-51002r1"></a><span 1863class="cmr-6">1</span><span 1864class="cmtt-8"> </span><span 1865class="cmtt-8"> byte</span><span 1866class="cmtt-8"> 0:</span><span 1867class="cmtt-8"> [</span><span 1868class="cmtt-8"> 0</span><span 1869class="cmtt-8"> 1</span><span 1870class="cmtt-8"> 0</span><span 1871class="cmtt-8"> 0</span><span 1872class="cmtt-8"> 0</span><span 1873class="cmtt-8"> 0</span><span 1874class="cmtt-8"> 1</span><span 1875class="cmtt-8"> 0</span><span 1876class="cmtt-8"> ]</span><span 1877class="cmtt-8"> (0x42)</span> 1878<br class="fancyvrb" /><a 1879 id="x1-51004r2"></a><span 1880class="cmr-6">2</span><span 1881class="cmtt-8"> </span><span 1882class="cmtt-8"> byte</span><span 1883class="cmtt-8"> 1:</span><span 1884class="cmtt-8"> [</span><span 1885class="cmtt-8"> 0</span><span 1886class="cmtt-8"> 1</span><span 1887class="cmtt-8"> 0</span><span 1888class="cmtt-8"> 0</span><span 1889class="cmtt-8"> 0</span><span 1890class="cmtt-8"> 0</span><span 1891class="cmtt-8"> 1</span><span 1892class="cmtt-8"> 1</span><span 1893class="cmtt-8"> ]</span><span 1894class="cmtt-8"> (0x43)</span> 1895<br class="fancyvrb" /><a 1896 id="x1-51006r3"></a><span 1897class="cmr-6">3</span><span 1898class="cmtt-8"> </span><span 1899class="cmtt-8"> byte</span><span 1900class="cmtt-8"> 2:</span><span 1901class="cmtt-8"> [</span><span 1902class="cmtt-8"> 0</span><span 1903class="cmtt-8"> 1</span><span 1904class="cmtt-8"> 0</span><span 1905class="cmtt-8"> 1</span><span 1906class="cmtt-8"> 0</span><span 1907class="cmtt-8"> 1</span><span 1908class="cmtt-8"> 1</span><span 1909class="cmtt-8"> 0</span><span 1910class="cmtt-8"> ]</span><span 1911class="cmtt-8"> (0x56)</span> 1912</div> 1913<!--l. 44--><p class="noindent" >16 bit <span 1914class="cmtt-12">[codebook_dimensions] </span>and 24 bit <span 1915class="cmtt-12">[codebook_entries] </span>fields: 1916<!--l. 46--><p class="noindent" > 1917<div class="fancyvrb" id="fancyvrb8"> 1918<a 1919 id="x1-51008r1"></a><span 1920class="cmr-6">1</span><span 1921class="cmtt-8"> </span><span 1922class="cmtt-8"> </span> 1923<br class="fancyvrb" /><a 1924 id="x1-51010r2"></a><span 1925class="cmr-6">2</span><span 1926class="cmtt-8"> </span><span 1927class="cmtt-8"> byte</span><span 1928class="cmtt-8"> 3:</span><span 1929class="cmtt-8"> [</span><span 1930class="cmtt-8"> X</span><span 1931class="cmtt-8"> X</span><span 1932class="cmtt-8"> X</span><span 1933class="cmtt-8"> X</span><span 1934class="cmtt-8"> X</span><span 1935class="cmtt-8"> X</span><span 1936class="cmtt-8"> X</span><span 1937class="cmtt-8"> X</span><span 1938class="cmtt-8"> ]</span> 1939<br class="fancyvrb" /><a 1940 id="x1-51012r3"></a><span 1941class="cmr-6">3</span><span 1942class="cmtt-8"> </span><span 1943class="cmtt-8"> byte</span><span 1944class="cmtt-8"> 4:</span><span 1945class="cmtt-8"> [</span><span 1946class="cmtt-8"> X</span><span 1947class="cmtt-8"> X</span><span 1948class="cmtt-8"> X</span><span 1949class="cmtt-8"> X</span><span 1950class="cmtt-8"> X</span><span 1951class="cmtt-8"> X</span><span 1952class="cmtt-8"> X</span><span 1953class="cmtt-8"> X</span><span 1954class="cmtt-8"> ]</span><span 1955class="cmtt-8"> [codebook_dimensions]</span><span 1956class="cmtt-8"> (16</span><span 1957class="cmtt-8"> bit</span><span 1958class="cmtt-8"> unsigned)</span> 1959<br class="fancyvrb" /><a 1960 id="x1-51014r4"></a><span 1961class="cmr-6">4</span><span 1962class="cmtt-8"> </span><span 1963class="cmtt-8"> </span> 1964<br class="fancyvrb" /><a 1965 id="x1-51016r5"></a><span 1966class="cmr-6">5</span><span 1967class="cmtt-8"> </span><span 1968class="cmtt-8"> byte</span><span 1969class="cmtt-8"> 5:</span><span 1970class="cmtt-8"> [</span><span 1971class="cmtt-8"> X</span><span 1972class="cmtt-8"> X</span><span 1973class="cmtt-8"> X</span><span 1974class="cmtt-8"> X</span><span 1975class="cmtt-8"> X</span><span 1976class="cmtt-8"> X</span><span 1977class="cmtt-8"> X</span><span 1978class="cmtt-8"> X</span><span 1979class="cmtt-8"> ]</span> 1980<br class="fancyvrb" /><a 1981 id="x1-51018r6"></a><span 1982class="cmr-6">6</span><span 1983class="cmtt-8"> </span><span 1984class="cmtt-8"> byte</span><span 1985class="cmtt-8"> 6:</span><span 1986class="cmtt-8"> [</span><span 1987class="cmtt-8"> X</span><span 1988class="cmtt-8"> X</span><span 1989class="cmtt-8"> X</span><span 1990class="cmtt-8"> X</span><span 1991class="cmtt-8"> X</span><span 1992class="cmtt-8"> X</span><span 1993class="cmtt-8"> X</span><span 1994class="cmtt-8"> X</span><span 1995class="cmtt-8"> ]</span> 1996<br class="fancyvrb" /><a 1997 id="x1-51020r7"></a><span 1998class="cmr-6">7</span><span 1999class="cmtt-8"> </span><span 2000class="cmtt-8"> byte</span><span 2001class="cmtt-8"> 7:</span><span 2002class="cmtt-8"> [</span><span 2003class="cmtt-8"> X</span><span 2004class="cmtt-8"> X</span><span 2005class="cmtt-8"> X</span><span 2006class="cmtt-8"> X</span><span 2007class="cmtt-8"> X</span><span 2008class="cmtt-8"> X</span><span 2009class="cmtt-8"> X</span><span 2010class="cmtt-8"> X</span><span 2011class="cmtt-8"> ]</span><span 2012class="cmtt-8"> [codebook_entries]</span><span 2013class="cmtt-8"> (24</span><span 2014class="cmtt-8"> bit</span><span 2015class="cmtt-8"> unsigned)</span> 2016<br class="fancyvrb" /><a 2017 id="x1-51022r8"></a><span 2018class="cmr-6">8</span><span 2019class="cmtt-8"> </span><span 2020class="cmtt-8"> </span> 2021</div> 2022<!--l. 57--><p class="noindent" >Next is the <span 2023class="cmtt-12">[ordered] </span>bit flag: 2024<!--l. 59--><p class="noindent" > 2025<div class="fancyvrb" id="fancyvrb9"> 2026<a 2027 id="x1-51024r1"></a><span 2028class="cmr-6">1</span><span 2029class="cmtt-8"> </span><span 2030class="cmtt-8"> </span> 2031<br class="fancyvrb" /><a 2032 id="x1-51026r2"></a><span 2033class="cmr-6">2</span><span 2034class="cmtt-8"> </span><span 2035class="cmtt-8"> byte</span><span 2036class="cmtt-8"> 8:</span><span 2037class="cmtt-8"> [</span><span 2038class="cmtt-8"> </span><span 2039class="cmtt-8"> </span><span 2040class="cmtt-8"> </span><span 2041class="cmtt-8"> </span><span 2042class="cmtt-8"> </span><span 2043class="cmtt-8"> </span><span 2044class="cmtt-8"> </span><span 2045class="cmtt-8"> </span><span 2046class="cmtt-8"> </span><span 2047class="cmtt-8"> </span><span 2048class="cmtt-8"> </span><span 2049class="cmtt-8"> </span><span 2050class="cmtt-8"> </span><span 2051class="cmtt-8"> </span><span 2052class="cmtt-8"> X</span><span 2053class="cmtt-8"> ]</span><span 2054class="cmtt-8"> [ordered]</span><span 2055class="cmtt-8"> (1</span><span 2056class="cmtt-8"> bit)</span> 2057<br class="fancyvrb" /><a 2058 id="x1-51028r3"></a><span 2059class="cmr-6">3</span><span 2060class="cmtt-8"> </span><span 2061class="cmtt-8"> </span> 2062</div> 2063<!--l. 65--><p class="noindent" >Each entry, numbering a total of <span 2064class="cmtt-12">[codebook_entries]</span>, is assigned a codeword length. 2065We now read the list of codeword lengths and store these lengths in the array 2066<span 2067class="cmtt-12">[codebook_codeword_lengths]</span>. Decode of lengths is according to whether the <span 2068class="cmtt-12">[ordered] </span>flag 2069is set or unset. 2070 <ul class="itemize1"> 2071 <li class="itemize">If the <span 2072class="cmtt-12">[ordered] </span>flag is unset, the codeword list is not length ordered and the decoder 2073 needs to read each codeword length one-by-one. 2074 <!--l. 77--><p class="noindent" >The decoder first reads one additional bit flag, the <span 2075class="cmtt-12">[sparse] </span>flag. This flag determines 2076 whether or not the codebook contains unused entries that are not to be included in 2077 2078 2079 2080 the codeword decode tree: 2081 <!--l. 82--><p class="noindent" > 2082 <div class="fancyvrb" id="fancyvrb10"> 2083<a 2084 id="x1-51030r1"></a><span 2085class="cmr-6">1</span><span 2086class="cmtt-8"> </span><span 2087class="cmtt-8"> byte</span><span 2088class="cmtt-8"> 8:</span><span 2089class="cmtt-8"> [</span><span 2090class="cmtt-8"> </span><span 2091class="cmtt-8"> </span><span 2092class="cmtt-8"> </span><span 2093class="cmtt-8"> </span><span 2094class="cmtt-8"> </span><span 2095class="cmtt-8"> </span><span 2096class="cmtt-8"> </span><span 2097class="cmtt-8"> </span><span 2098class="cmtt-8"> </span><span 2099class="cmtt-8"> </span><span 2100class="cmtt-8"> </span><span 2101class="cmtt-8"> </span><span 2102class="cmtt-8"> X</span><span 2103class="cmtt-8"> 1</span><span 2104class="cmtt-8"> ]</span><span 2105class="cmtt-8"> [sparse]</span><span 2106class="cmtt-8"> flag</span><span 2107class="cmtt-8"> (1</span><span 2108class="cmtt-8"> bit)</span> 2109</div> 2110 <!--l. 86--><p class="noindent" >The decoder now performs for each of the <span 2111class="cmtt-12">[codebook_entries] </span>codebook entries: 2112 <!--l. 89--><p class="noindent" > 2113 <div class="fancyvrb" id="fancyvrb11"> 2114<a 2115 id="x1-51032r1"></a><span 2116class="cmr-6">1</span><span 2117class="cmtt-8"> </span><span 2118class="cmtt-8"> </span> 2119<br class="fancyvrb" /><a 2120 id="x1-51034r2"></a><span 2121class="cmr-6">2</span><span 2122class="cmtt-8"> </span><span 2123class="cmtt-8"> </span><span 2124class="cmtt-8"> </span><span 2125class="cmtt-8"> 1)</span><span 2126class="cmtt-8"> if([sparse]</span><span 2127class="cmtt-8"> is</span><span 2128class="cmtt-8"> set)</span><span 2129class="cmtt-8"> </span><span 2130class="cmsy-8">{</span> 2131<br class="fancyvrb" /><a 2132 id="x1-51036r3"></a><span 2133class="cmr-6">3</span><span 2134class="cmtt-8"> </span><span 2135class="cmtt-8"> </span> 2136<br class="fancyvrb" /><a 2137 id="x1-51038r4"></a><span 2138class="cmr-6">4</span><span 2139class="cmtt-8"> </span><span 2140class="cmtt-8"> </span><span 2141class="cmtt-8"> </span><span 2142class="cmtt-8"> </span><span 2143class="cmtt-8"> </span><span 2144class="cmtt-8"> </span><span 2145class="cmtt-8"> </span><span 2146class="cmtt-8"> </span><span 2147class="cmtt-8"> </span><span 2148class="cmtt-8"> </span><span 2149class="cmtt-8"> 2)</span><span 2150class="cmtt-8"> [flag]</span><span 2151class="cmtt-8"> =</span><span 2152class="cmtt-8"> read</span><span 2153class="cmtt-8"> one</span><span 2154class="cmtt-8"> bit;</span> 2155<br class="fancyvrb" /><a 2156 id="x1-51040r5"></a><span 2157class="cmr-6">5</span><span 2158class="cmtt-8"> </span><span 2159class="cmtt-8"> </span><span 2160class="cmtt-8"> </span><span 2161class="cmtt-8"> </span><span 2162class="cmtt-8"> </span><span 2163class="cmtt-8"> </span><span 2164class="cmtt-8"> </span><span 2165class="cmtt-8"> </span><span 2166class="cmtt-8"> </span><span 2167class="cmtt-8"> </span><span 2168class="cmtt-8"> 3)</span><span 2169class="cmtt-8"> if([flag]</span><span 2170class="cmtt-8"> is</span><span 2171class="cmtt-8"> set)</span><span 2172class="cmtt-8"> </span><span 2173class="cmsy-8">{</span> 2174<br class="fancyvrb" /><a 2175 id="x1-51042r6"></a><span 2176class="cmr-6">6</span><span 2177class="cmtt-8"> </span><span 2178class="cmtt-8"> </span> 2179<br class="fancyvrb" /><a 2180 id="x1-51044r7"></a><span 2181class="cmr-6">7</span><span 2182class="cmtt-8"> </span><span 2183class="cmtt-8"> </span><span 2184class="cmtt-8"> </span><span 2185class="cmtt-8"> </span><span 2186class="cmtt-8"> </span><span 2187class="cmtt-8"> </span><span 2188class="cmtt-8"> </span><span 2189class="cmtt-8"> </span><span 2190class="cmtt-8"> </span><span 2191class="cmtt-8"> </span><span 2192class="cmtt-8"> </span><span 2193class="cmtt-8"> </span><span 2194class="cmtt-8"> </span><span 2195class="cmtt-8"> </span><span 2196class="cmtt-8"> </span><span 2197class="cmtt-8"> 4)</span><span 2198class="cmtt-8"> [length]</span><span 2199class="cmtt-8"> =</span><span 2200class="cmtt-8"> read</span><span 2201class="cmtt-8"> a</span><span 2202class="cmtt-8"> five</span><span 2203class="cmtt-8"> bit</span><span 2204class="cmtt-8"> unsigned</span><span 2205class="cmtt-8"> integer;</span> 2206<br class="fancyvrb" /><a 2207 id="x1-51046r8"></a><span 2208class="cmr-6">8</span><span 2209class="cmtt-8"> </span><span 2210class="cmtt-8"> </span><span 2211class="cmtt-8"> </span><span 2212class="cmtt-8"> </span><span 2213class="cmtt-8"> </span><span 2214class="cmtt-8"> </span><span 2215class="cmtt-8"> </span><span 2216class="cmtt-8"> </span><span 2217class="cmtt-8"> </span><span 2218class="cmtt-8"> </span><span 2219class="cmtt-8"> </span><span 2220class="cmtt-8"> </span><span 2221class="cmtt-8"> </span><span 2222class="cmtt-8"> </span><span 2223class="cmtt-8"> </span><span 2224class="cmtt-8"> 5)</span><span 2225class="cmtt-8"> codeword</span><span 2226class="cmtt-8"> length</span><span 2227class="cmtt-8"> for</span><span 2228class="cmtt-8"> this</span><span 2229class="cmtt-8"> entry</span><span 2230class="cmtt-8"> is</span><span 2231class="cmtt-8"> [length]+1;</span> 2232<br class="fancyvrb" /><a 2233 id="x1-51048r9"></a><span 2234class="cmr-6">9</span><span 2235class="cmtt-8"> </span><span 2236class="cmtt-8"> </span> 2237<br class="fancyvrb" /><a 2238 id="x1-51050r10"></a><span 2239class="cmr-6">10</span><span 2240class="cmtt-8"> </span><span 2241class="cmtt-8"> </span><span 2242class="cmtt-8"> </span><span 2243class="cmtt-8"> </span><span 2244class="cmtt-8"> </span><span 2245class="cmtt-8"> </span><span 2246class="cmtt-8"> </span><span 2247class="cmtt-8"> </span><span 2248class="cmtt-8"> </span><span 2249class="cmtt-8"> </span><span 2250class="cmtt-8"> </span><span 2251class="cmtt-8"> </span><span 2252class="cmtt-8"> </span><span 2253class="cmtt-8"> </span><span 2254class="cmsy-8">}</span><span 2255class="cmtt-8"> else</span><span 2256class="cmtt-8"> </span><span 2257class="cmsy-8">{</span> 2258<br class="fancyvrb" /><a 2259 id="x1-51052r11"></a><span 2260class="cmr-6">11</span><span 2261class="cmtt-8"> </span><span 2262class="cmtt-8"> </span> 2263<br class="fancyvrb" /><a 2264 id="x1-51054r12"></a><span 2265class="cmr-6">12</span><span 2266class="cmtt-8"> </span><span 2267class="cmtt-8"> </span><span 2268class="cmtt-8"> </span><span 2269class="cmtt-8"> </span><span 2270class="cmtt-8"> </span><span 2271class="cmtt-8"> </span><span 2272class="cmtt-8"> </span><span 2273class="cmtt-8"> </span><span 2274class="cmtt-8"> </span><span 2275class="cmtt-8"> </span><span 2276class="cmtt-8"> </span><span 2277class="cmtt-8"> </span><span 2278class="cmtt-8"> </span><span 2279class="cmtt-8"> </span><span 2280class="cmtt-8"> </span><span 2281class="cmtt-8"> 6)</span><span 2282class="cmtt-8"> this</span><span 2283class="cmtt-8"> entry</span><span 2284class="cmtt-8"> is</span><span 2285class="cmtt-8"> unused.</span><span 2286class="cmtt-8"> </span><span 2287class="cmtt-8"> mark</span><span 2288class="cmtt-8"> it</span><span 2289class="cmtt-8"> as</span><span 2290class="cmtt-8"> such.</span> 2291<br class="fancyvrb" /><a 2292 id="x1-51056r13"></a><span 2293class="cmr-6">13</span><span 2294class="cmtt-8"> </span><span 2295class="cmtt-8"> </span> 2296<br class="fancyvrb" /><a 2297 id="x1-51058r14"></a><span 2298class="cmr-6">14</span><span 2299class="cmtt-8"> </span><span 2300class="cmtt-8"> </span><span 2301class="cmtt-8"> </span><span 2302class="cmtt-8"> </span><span 2303class="cmtt-8"> </span><span 2304class="cmtt-8"> </span><span 2305class="cmtt-8"> </span><span 2306class="cmtt-8"> </span><span 2307class="cmtt-8"> </span><span 2308class="cmtt-8"> </span><span 2309class="cmtt-8"> </span><span 2310class="cmtt-8"> </span><span 2311class="cmtt-8"> </span><span 2312class="cmtt-8"> </span><span 2313class="cmsy-8">}</span> 2314<br class="fancyvrb" /><a 2315 id="x1-51060r15"></a><span 2316class="cmr-6">15</span><span 2317class="cmtt-8"> </span><span 2318class="cmtt-8"> </span> 2319<br class="fancyvrb" /><a 2320 id="x1-51062r16"></a><span 2321class="cmr-6">16</span><span 2322class="cmtt-8"> </span><span 2323class="cmtt-8"> </span><span 2324class="cmtt-8"> </span><span 2325class="cmtt-8"> </span><span 2326class="cmtt-8"> </span><span 2327class="cmtt-8"> </span><span 2328class="cmtt-8"> </span><span 2329class="cmsy-8">}</span><span 2330class="cmtt-8"> else</span><span 2331class="cmtt-8"> the</span><span 2332class="cmtt-8"> sparse</span><span 2333class="cmtt-8"> flag</span><span 2334class="cmtt-8"> is</span><span 2335class="cmtt-8"> not</span><span 2336class="cmtt-8"> set</span><span 2337class="cmtt-8"> </span><span 2338class="cmsy-8">{</span> 2339<br class="fancyvrb" /><a 2340 id="x1-51064r17"></a><span 2341class="cmr-6">17</span><span 2342class="cmtt-8"> </span><span 2343class="cmtt-8"> </span> 2344<br class="fancyvrb" /><a 2345 id="x1-51066r18"></a><span 2346class="cmr-6">18</span><span 2347class="cmtt-8"> </span><span 2348class="cmtt-8"> </span><span 2349class="cmtt-8"> </span><span 2350class="cmtt-8"> </span><span 2351class="cmtt-8"> </span><span 2352class="cmtt-8"> </span><span 2353class="cmtt-8"> </span><span 2354class="cmtt-8"> </span><span 2355class="cmtt-8"> </span><span 2356class="cmtt-8"> 7)</span><span 2357class="cmtt-8"> [length]</span><span 2358class="cmtt-8"> =</span><span 2359class="cmtt-8"> read</span><span 2360class="cmtt-8"> a</span><span 2361class="cmtt-8"> five</span><span 2362class="cmtt-8"> bit</span><span 2363class="cmtt-8"> unsigned</span><span 2364class="cmtt-8"> integer;</span> 2365<br class="fancyvrb" /><a 2366 id="x1-51068r19"></a><span 2367class="cmr-6">19</span><span 2368class="cmtt-8"> </span><span 2369class="cmtt-8"> </span><span 2370class="cmtt-8"> </span><span 2371class="cmtt-8"> </span><span 2372class="cmtt-8"> </span><span 2373class="cmtt-8"> </span><span 2374class="cmtt-8"> </span><span 2375class="cmtt-8"> </span><span 2376class="cmtt-8"> </span><span 2377class="cmtt-8"> 8)</span><span 2378class="cmtt-8"> the</span><span 2379class="cmtt-8"> codeword</span><span 2380class="cmtt-8"> length</span><span 2381class="cmtt-8"> for</span><span 2382class="cmtt-8"> this</span><span 2383class="cmtt-8"> entry</span><span 2384class="cmtt-8"> is</span><span 2385class="cmtt-8"> [length]+1;</span> 2386<br class="fancyvrb" /><a 2387 id="x1-51070r20"></a><span 2388class="cmr-6">20</span><span 2389class="cmtt-8"> </span><span 2390class="cmtt-8"> </span> 2391<br class="fancyvrb" /><a 2392 id="x1-51072r21"></a><span 2393class="cmr-6">21</span><span 2394class="cmtt-8"> </span><span 2395class="cmtt-8"> </span><span 2396class="cmtt-8"> </span><span 2397class="cmtt-8"> </span><span 2398class="cmtt-8"> </span><span 2399class="cmtt-8"> </span><span 2400class="cmtt-8"> </span><span 2401class="cmsy-8">}</span> 2402<br class="fancyvrb" /><a 2403 id="x1-51074r22"></a><span 2404class="cmr-6">22</span><span 2405class="cmtt-8"> </span><span 2406class="cmtt-8"> </span> 2407</div> 2408 </li> 2409 <li class="itemize">If the <span 2410class="cmtt-12">[ordered] </span>flag is set, the codeword list for this codebook is encoded in 2411 ascending length order. Rather than reading a length for every codeword, the 2412 encoder reads the number of codewords per length. That is, beginning at entry 2413 zero: 2414 <!--l. 120--><p class="noindent" > 2415 <div class="fancyvrb" id="fancyvrb12"> 2416<a 2417 id="x1-51076r1"></a><span 2418class="cmr-6">1</span><span 2419class="cmtt-8"> </span><span 2420class="cmtt-8"> </span><span 2421class="cmtt-8"> </span><span 2422class="cmtt-8"> 1)</span><span 2423class="cmtt-8"> [current_entry]</span><span 2424class="cmtt-8"> =</span><span 2425class="cmtt-8"> 0;</span> 2426<br class="fancyvrb" /><a 2427 id="x1-51078r2"></a><span 2428class="cmr-6">2</span><span 2429class="cmtt-8"> </span><span 2430class="cmtt-8"> </span><span 2431class="cmtt-8"> </span><span 2432class="cmtt-8"> 2)</span><span 2433class="cmtt-8"> [current_length]</span><span 2434class="cmtt-8"> =</span><span 2435class="cmtt-8"> read</span><span 2436class="cmtt-8"> a</span><span 2437class="cmtt-8"> five</span><span 2438class="cmtt-8"> bit</span><span 2439class="cmtt-8"> unsigned</span><span 2440class="cmtt-8"> integer</span><span 2441class="cmtt-8"> and</span><span 2442class="cmtt-8"> add</span><span 2443class="cmtt-8"> 1;</span> 2444<br class="fancyvrb" /><a 2445 id="x1-51080r3"></a><span 2446class="cmr-6">3</span><span 2447class="cmtt-8"> </span><span 2448class="cmtt-8"> </span><span 2449class="cmtt-8"> </span><span 2450class="cmtt-8"> 3)</span><span 2451class="cmtt-8"> [number]</span><span 2452class="cmtt-8"> =</span><span 2453class="cmtt-8"> read</span><span 2454class="cmtt-8"> </span><a 2455href="#x1-1170009.2.1"><span 2456class="cmtt-8">ilog</span></a><span 2457class="cmtt-8">([codebook_entries]</span><span 2458class="cmtt-8"> -</span><span 2459class="cmtt-8"> [current_entry])</span><span 2460class="cmtt-8"> bits</span><span 2461class="cmtt-8"> as</span><span 2462class="cmtt-8"> an</span><span 2463class="cmtt-8"> unsigned</span><span 2464class="cmtt-8"> integer</span> 2465<br class="fancyvrb" /><a 2466 id="x1-51082r4"></a><span 2467class="cmr-6">4</span><span 2468class="cmtt-8"> </span><span 2469class="cmtt-8"> </span><span 2470class="cmtt-8"> </span><span 2471class="cmtt-8"> 4)</span><span 2472class="cmtt-8"> set</span><span 2473class="cmtt-8"> the</span><span 2474class="cmtt-8"> entries</span><span 2475class="cmtt-8"> [current_entry]</span><span 2476class="cmtt-8"> through</span><span 2477class="cmtt-8"> [current_entry]+[number]-1,</span><span 2478class="cmtt-8"> inclusive,</span> 2479<br class="fancyvrb" /><a 2480 id="x1-51084r5"></a><span 2481class="cmr-6">5</span><span 2482class="cmtt-8"> </span><span 2483class="cmtt-8"> </span><span 2484class="cmtt-8"> </span><span 2485class="cmtt-8"> </span><span 2486class="cmtt-8"> </span><span 2487class="cmtt-8"> of</span><span 2488class="cmtt-8"> the</span><span 2489class="cmtt-8"> [codebook_codeword_lengths]</span><span 2490class="cmtt-8"> array</span><span 2491class="cmtt-8"> to</span><span 2492class="cmtt-8"> [current_length]</span> 2493<br class="fancyvrb" /><a 2494 id="x1-51086r6"></a><span 2495class="cmr-6">6</span><span 2496class="cmtt-8"> </span><span 2497class="cmtt-8"> </span><span 2498class="cmtt-8"> </span><span 2499class="cmtt-8"> 5)</span><span 2500class="cmtt-8"> set</span><span 2501class="cmtt-8"> [current_entry]</span><span 2502class="cmtt-8"> to</span><span 2503class="cmtt-8"> [number]</span><span 2504class="cmtt-8"> +</span><span 2505class="cmtt-8"> [current_entry]</span> 2506<br class="fancyvrb" /><a 2507 id="x1-51088r7"></a><span 2508class="cmr-6">7</span><span 2509class="cmtt-8"> </span><span 2510class="cmtt-8"> </span><span 2511class="cmtt-8"> </span><span 2512class="cmtt-8"> 6)</span><span 2513class="cmtt-8"> increment</span><span 2514class="cmtt-8"> [current_length]</span><span 2515class="cmtt-8"> by</span><span 2516class="cmtt-8"> 1</span> 2517<br class="fancyvrb" /><a 2518 id="x1-51090r8"></a><span 2519class="cmr-6">8</span><span 2520class="cmtt-8"> </span><span 2521class="cmtt-8"> </span><span 2522class="cmtt-8"> </span><span 2523class="cmtt-8"> 7)</span><span 2524class="cmtt-8"> if</span><span 2525class="cmtt-8"> [current_entry]</span><span 2526class="cmtt-8"> is</span><span 2527class="cmtt-8"> greater</span><span 2528class="cmtt-8"> than</span><span 2529class="cmtt-8"> [codebook_entries]</span><span 2530class="cmtt-8"> ERROR</span><span 2531class="cmtt-8"> CONDITION;</span> 2532<br class="fancyvrb" /><a 2533 id="x1-51092r9"></a><span 2534class="cmr-6">9</span><span 2535class="cmtt-8"> </span><span 2536class="cmtt-8"> </span><span 2537class="cmtt-8"> </span><span 2538class="cmtt-8"> </span><span 2539class="cmtt-8"> </span><span 2540class="cmtt-8"> the</span><span 2541class="cmtt-8"> decoder</span><span 2542class="cmtt-8"> will</span><span 2543class="cmtt-8"> not</span><span 2544class="cmtt-8"> be</span><span 2545class="cmtt-8"> able</span><span 2546class="cmtt-8"> to</span><span 2547class="cmtt-8"> read</span><span 2548class="cmtt-8"> this</span><span 2549class="cmtt-8"> stream.</span> 2550<br class="fancyvrb" /><a 2551 id="x1-51094r10"></a><span 2552class="cmr-6">10</span><span 2553class="cmtt-8"> </span><span 2554class="cmtt-8"> </span><span 2555class="cmtt-8"> </span><span 2556class="cmtt-8"> 8)</span><span 2557class="cmtt-8"> if</span><span 2558class="cmtt-8"> [current_entry]</span><span 2559class="cmtt-8"> is</span><span 2560class="cmtt-8"> less</span><span 2561class="cmtt-8"> than</span><span 2562class="cmtt-8"> [codebook_entries],</span><span 2563class="cmtt-8"> repeat</span><span 2564class="cmtt-8"> process</span><span 2565class="cmtt-8"> starting</span><span 2566class="cmtt-8"> at</span><span 2567class="cmtt-8"> 3)</span> 2568<br class="fancyvrb" /><a 2569 id="x1-51096r11"></a><span 2570class="cmr-6">11</span><span 2571class="cmtt-8"> </span><span 2572class="cmtt-8"> </span><span 2573class="cmtt-8"> </span><span 2574class="cmtt-8"> 9)</span><span 2575class="cmtt-8"> done.</span> 2576 2577 2578 2579</div> 2580 </li></ul> 2581<!--l. 136--><p class="noindent" >After all codeword lengths have been decoded, the decoder reads the vector lookup table. Vorbis 2582I supports three lookup types: 2583 <ol class="enumerate1" > 2584 <li 2585 class="enumerate" id="x1-51098x1">No lookup 2586 </li> 2587 <li 2588 class="enumerate" id="x1-51100x2">Implicitly populated value mapping (lattice VQ) 2589 </li> 2590 <li 2591 class="enumerate" id="x1-51102x3">Explicitly populated value mapping (tessellated or ’foam’ VQ)</li></ol> 2592<!--l. 149--><p class="noindent" >The lookup table type is read as a four bit unsigned integer: 2593<div class="fancyvrb" id="fancyvrb13"> 2594<a 2595 id="x1-51104r1"></a><span 2596class="cmr-6">1</span><span 2597class="cmtt-8"> </span><span 2598class="cmtt-8"> </span><span 2599class="cmtt-8"> </span><span 2600class="cmtt-8"> 1)</span><span 2601class="cmtt-8"> [codebook_lookup_type]</span><span 2602class="cmtt-8"> =</span><span 2603class="cmtt-8"> read</span><span 2604class="cmtt-8"> four</span><span 2605class="cmtt-8"> bits</span><span 2606class="cmtt-8"> as</span><span 2607class="cmtt-8"> an</span><span 2608class="cmtt-8"> unsigned</span><span 2609class="cmtt-8"> integer</span> 2610</div> 2611<!--l. 154--><p class="noindent" >Codebook decode precedes according to <span 2612class="cmtt-12">[codebook_lookup_type]</span>: 2613 <ul class="itemize1"> 2614 <li class="itemize">Lookup type zero indicates no lookup to be read. Proceed past lookup decode. 2615 </li> 2616 <li class="itemize">Lookup types one and two are similar, differing only in the number of lookup values to 2617 be read. Lookup type one reads a list of values that are permuted in a set pattern to 2618 build a list of vectors, each vector of order <span 2619class="cmtt-12">[codebook_dimensions] </span>scalars. Lookup 2620 type two builds the same vector list, but reads each scalar for each vector explicitly, 2621 rather than building vectors from a smaller list of possible scalar values. Lookup 2622 decode proceeds as follows: 2623 <!--l. 168--><p class="noindent" > 2624 <div class="fancyvrb" id="fancyvrb14"> 2625<a 2626 id="x1-51106r1"></a><span 2627class="cmr-6">1</span><span 2628class="cmtt-8"> </span><span 2629class="cmtt-8"> </span><span 2630class="cmtt-8"> </span><span 2631class="cmtt-8"> 1)</span><span 2632class="cmtt-8"> [codebook_minimum_value]</span><span 2633class="cmtt-8"> =</span><span 2634class="cmtt-8"> </span><a 2635href="#x1-1180009.2.2"><span 2636class="cmtt-8">float32_unpack</span></a><span 2637class="cmtt-8">(</span><span 2638class="cmtt-8"> read</span><span 2639class="cmtt-8"> 32</span><span 2640class="cmtt-8"> bits</span><span 2641class="cmtt-8"> as</span><span 2642class="cmtt-8"> an</span><span 2643class="cmtt-8"> unsigned</span><span 2644class="cmtt-8"> integer)</span> 2645<br class="fancyvrb" /><a 2646 id="x1-51108r2"></a><span 2647class="cmr-6">2</span><span 2648class="cmtt-8"> </span><span 2649class="cmtt-8"> </span><span 2650class="cmtt-8"> </span><span 2651class="cmtt-8"> 2)</span><span 2652class="cmtt-8"> [codebook_delta_value]</span><span 2653class="cmtt-8"> =</span><span 2654class="cmtt-8"> </span><a 2655href="#x1-1180009.2.2"><span 2656class="cmtt-8">float32_unpack</span></a><span 2657class="cmtt-8">(</span><span 2658class="cmtt-8"> read</span><span 2659class="cmtt-8"> 32</span><span 2660class="cmtt-8"> bits</span><span 2661class="cmtt-8"> as</span><span 2662class="cmtt-8"> an</span><span 2663class="cmtt-8"> unsigned</span><span 2664class="cmtt-8"> integer)</span> 2665<br class="fancyvrb" /><a 2666 id="x1-51110r3"></a><span 2667class="cmr-6">3</span><span 2668class="cmtt-8"> </span><span 2669class="cmtt-8"> </span><span 2670class="cmtt-8"> </span><span 2671class="cmtt-8"> 3)</span><span 2672class="cmtt-8"> [codebook_value_bits]</span><span 2673class="cmtt-8"> =</span><span 2674class="cmtt-8"> read</span><span 2675class="cmtt-8"> 4</span><span 2676class="cmtt-8"> bits</span><span 2677class="cmtt-8"> as</span><span 2678class="cmtt-8"> an</span><span 2679class="cmtt-8"> unsigned</span><span 2680class="cmtt-8"> integer</span><span 2681class="cmtt-8"> and</span><span 2682class="cmtt-8"> add</span><span 2683class="cmtt-8"> 1</span> 2684<br class="fancyvrb" /><a 2685 id="x1-51112r4"></a><span 2686class="cmr-6">4</span><span 2687class="cmtt-8"> </span><span 2688class="cmtt-8"> </span><span 2689class="cmtt-8"> </span><span 2690class="cmtt-8"> 4)</span><span 2691class="cmtt-8"> [codebook_sequence_p]</span><span 2692class="cmtt-8"> =</span><span 2693class="cmtt-8"> read</span><span 2694class="cmtt-8"> 1</span><span 2695class="cmtt-8"> bit</span><span 2696class="cmtt-8"> as</span><span 2697class="cmtt-8"> a</span><span 2698class="cmtt-8"> boolean</span><span 2699class="cmtt-8"> flag</span> 2700<br class="fancyvrb" /><a 2701 id="x1-51114r5"></a><span 2702class="cmr-6">5</span><span 2703class="cmtt-8"> </span><span 2704class="cmtt-8"> </span> 2705<br class="fancyvrb" /><a 2706 id="x1-51116r6"></a><span 2707class="cmr-6">6</span><span 2708class="cmtt-8"> </span><span 2709class="cmtt-8"> </span><span 2710class="cmtt-8"> </span><span 2711class="cmtt-8"> if</span><span 2712class="cmtt-8"> (</span><span 2713class="cmtt-8"> [codebook_lookup_type]</span><span 2714class="cmtt-8"> is</span><span 2715class="cmtt-8"> 1</span><span 2716class="cmtt-8"> )</span><span 2717class="cmtt-8"> </span><span 2718class="cmsy-8">{</span> 2719<br class="fancyvrb" /><a 2720 id="x1-51118r7"></a><span 2721class="cmr-6">7</span><span 2722class="cmtt-8"> </span><span 2723class="cmtt-8"> </span> 2724<br class="fancyvrb" /><a 2725 id="x1-51120r8"></a><span 2726class="cmr-6">8</span><span 2727class="cmtt-8"> </span><span 2728class="cmtt-8"> </span><span 2729class="cmtt-8"> </span><span 2730class="cmtt-8"> </span><span 2731class="cmtt-8"> </span><span 2732class="cmtt-8"> </span><span 2733class="cmtt-8"> 5)</span><span 2734class="cmtt-8"> [codebook_lookup_values]</span><span 2735class="cmtt-8"> =</span><span 2736class="cmtt-8"> </span><a 2737href="#x1-1190009.2.3"><span 2738class="cmtt-8">lookup1_values</span></a><span 2739class="cmtt-8">([codebook_entries],</span><span 2740class="cmtt-8"> [codebook_dimensions]</span><span 2741class="cmtt-8"> )</span> 2742<br class="fancyvrb" /><a 2743 id="x1-51122r9"></a><span 2744class="cmr-6">9</span><span 2745class="cmtt-8"> </span><span 2746class="cmtt-8"> </span> 2747<br class="fancyvrb" /><a 2748 id="x1-51124r10"></a><span 2749class="cmr-6">10</span><span 2750class="cmtt-8"> </span><span 2751class="cmtt-8"> </span><span 2752class="cmtt-8"> </span><span 2753class="cmtt-8"> </span><span 2754class="cmsy-8">}</span><span 2755class="cmtt-8"> else</span><span 2756class="cmtt-8"> </span><span 2757class="cmsy-8">{</span> 2758<br class="fancyvrb" /><a 2759 id="x1-51126r11"></a><span 2760class="cmr-6">11</span><span 2761class="cmtt-8"> </span><span 2762class="cmtt-8"> </span> 2763<br class="fancyvrb" /><a 2764 id="x1-51128r12"></a><span 2765class="cmr-6">12</span><span 2766class="cmtt-8"> </span><span 2767class="cmtt-8"> </span><span 2768class="cmtt-8"> </span><span 2769class="cmtt-8"> </span><span 2770class="cmtt-8"> </span><span 2771class="cmtt-8"> </span><span 2772class="cmtt-8"> 6)</span><span 2773class="cmtt-8"> [codebook_lookup_values]</span><span 2774class="cmtt-8"> =</span><span 2775class="cmtt-8"> [codebook_entries]</span><span 2776class="cmtt-8"> *</span><span 2777class="cmtt-8"> [codebook_dimensions]</span> 2778<br class="fancyvrb" /><a 2779 id="x1-51130r13"></a><span 2780class="cmr-6">13</span><span 2781class="cmtt-8"> </span><span 2782class="cmtt-8"> </span> 2783<br class="fancyvrb" /><a 2784 id="x1-51132r14"></a><span 2785class="cmr-6">14</span><span 2786class="cmtt-8"> </span><span 2787class="cmtt-8"> </span><span 2788class="cmtt-8"> </span><span 2789class="cmtt-8"> </span><span 2790class="cmsy-8">}</span> 2791<br class="fancyvrb" /><a 2792 id="x1-51134r15"></a><span 2793class="cmr-6">15</span><span 2794class="cmtt-8"> </span><span 2795class="cmtt-8"> </span> 2796<br class="fancyvrb" /><a 2797 id="x1-51136r16"></a><span 2798class="cmr-6">16</span><span 2799class="cmtt-8"> </span><span 2800class="cmtt-8"> </span><span 2801class="cmtt-8"> </span><span 2802class="cmtt-8"> 7)</span><span 2803class="cmtt-8"> read</span><span 2804class="cmtt-8"> a</span><span 2805class="cmtt-8"> total</span><span 2806class="cmtt-8"> of</span><span 2807class="cmtt-8"> [codebook_lookup_values]</span><span 2808class="cmtt-8"> unsigned</span><span 2809class="cmtt-8"> integers</span><span 2810class="cmtt-8"> of</span><span 2811class="cmtt-8"> [codebook_value_bits]</span><span 2812class="cmtt-8"> each;</span> 2813 2814 2815 2816<br class="fancyvrb" /><a 2817 id="x1-51138r17"></a><span 2818class="cmr-6">17</span><span 2819class="cmtt-8"> </span><span 2820class="cmtt-8"> </span><span 2821class="cmtt-8"> </span><span 2822class="cmtt-8"> </span><span 2823class="cmtt-8"> </span><span 2824class="cmtt-8"> </span><span 2825class="cmtt-8"> store</span><span 2826class="cmtt-8"> these</span><span 2827class="cmtt-8"> in</span><span 2828class="cmtt-8"> order</span><span 2829class="cmtt-8"> in</span><span 2830class="cmtt-8"> the</span><span 2831class="cmtt-8"> array</span><span 2832class="cmtt-8"> [codebook_multiplicands]</span> 2833</div> 2834 </li> 2835 <li class="itemize">A <span 2836class="cmtt-12">[codebook_lookup_type] </span>of greater than two is reserved and indicates a stream that is 2837 not decodable by the specification in this document. 2838 </li></ul> 2839<!--l. 195--><p class="noindent" >An ’end of packet’ during any read operation in the above steps is considered an error condition 2840rendering the stream undecodable. 2841<!--l. 198--><p class="noindent" ><span class="paragraphHead"><a 2842 id="x1-520003.2.1"></a><span 2843class="cmbx-12">Huffman decision tree representation</span></span> 2844The <span 2845class="cmtt-12">[codebook_codeword_lengths] </span>array and <span 2846class="cmtt-12">[codebook_entries] </span>value uniquely define the 2847Huffman decision tree used for entropy decoding. 2848<!--l. 204--><p class="noindent" >Briefly, each used codebook entry (recall that length-unordered codebooks support unused 2849codeword entries) is assigned, in order, the lowest valued unused binary Huffman codeword 2850possible. Assume the following codeword length list: 2851<!--l. 209--><p class="noindent" > 2852<div class="fancyvrb" id="fancyvrb15"> 2853<a 2854 id="x1-52002r1"></a><span 2855class="cmr-6">1</span><span 2856class="cmtt-8"> </span><span 2857class="cmtt-8"> entry</span><span 2858class="cmtt-8"> 0:</span><span 2859class="cmtt-8"> length</span><span 2860class="cmtt-8"> 2</span> 2861<br class="fancyvrb" /><a 2862 id="x1-52004r2"></a><span 2863class="cmr-6">2</span><span 2864class="cmtt-8"> </span><span 2865class="cmtt-8"> entry</span><span 2866class="cmtt-8"> 1:</span><span 2867class="cmtt-8"> length</span><span 2868class="cmtt-8"> 4</span> 2869<br class="fancyvrb" /><a 2870 id="x1-52006r3"></a><span 2871class="cmr-6">3</span><span 2872class="cmtt-8"> </span><span 2873class="cmtt-8"> entry</span><span 2874class="cmtt-8"> 2:</span><span 2875class="cmtt-8"> length</span><span 2876class="cmtt-8"> 4</span> 2877<br class="fancyvrb" /><a 2878 id="x1-52008r4"></a><span 2879class="cmr-6">4</span><span 2880class="cmtt-8"> </span><span 2881class="cmtt-8"> entry</span><span 2882class="cmtt-8"> 3:</span><span 2883class="cmtt-8"> length</span><span 2884class="cmtt-8"> 4</span> 2885<br class="fancyvrb" /><a 2886 id="x1-52010r5"></a><span 2887class="cmr-6">5</span><span 2888class="cmtt-8"> </span><span 2889class="cmtt-8"> entry</span><span 2890class="cmtt-8"> 4:</span><span 2891class="cmtt-8"> length</span><span 2892class="cmtt-8"> 4</span> 2893<br class="fancyvrb" /><a 2894 id="x1-52012r6"></a><span 2895class="cmr-6">6</span><span 2896class="cmtt-8"> </span><span 2897class="cmtt-8"> entry</span><span 2898class="cmtt-8"> 5:</span><span 2899class="cmtt-8"> length</span><span 2900class="cmtt-8"> 2</span> 2901<br class="fancyvrb" /><a 2902 id="x1-52014r7"></a><span 2903class="cmr-6">7</span><span 2904class="cmtt-8"> </span><span 2905class="cmtt-8"> entry</span><span 2906class="cmtt-8"> 6:</span><span 2907class="cmtt-8"> length</span><span 2908class="cmtt-8"> 3</span> 2909<br class="fancyvrb" /><a 2910 id="x1-52016r8"></a><span 2911class="cmr-6">8</span><span 2912class="cmtt-8"> </span><span 2913class="cmtt-8"> entry</span><span 2914class="cmtt-8"> 7:</span><span 2915class="cmtt-8"> length</span><span 2916class="cmtt-8"> 3</span> 2917</div> 2918<!--l. 220--><p class="noindent" >Assigning codewords in order (lowest possible value of the appropriate length to highest) results 2919in the following codeword list: 2920<!--l. 223--><p class="noindent" > 2921<div class="fancyvrb" id="fancyvrb16"> 2922<a 2923 id="x1-52018r1"></a><span 2924class="cmr-6">1</span><span 2925class="cmtt-8"> </span><span 2926class="cmtt-8"> entry</span><span 2927class="cmtt-8"> 0:</span><span 2928class="cmtt-8"> length</span><span 2929class="cmtt-8"> 2</span><span 2930class="cmtt-8"> codeword</span><span 2931class="cmtt-8"> 00</span> 2932<br class="fancyvrb" /><a 2933 id="x1-52020r2"></a><span 2934class="cmr-6">2</span><span 2935class="cmtt-8"> </span><span 2936class="cmtt-8"> entry</span><span 2937class="cmtt-8"> 1:</span><span 2938class="cmtt-8"> length</span><span 2939class="cmtt-8"> 4</span><span 2940class="cmtt-8"> codeword</span><span 2941class="cmtt-8"> 0100</span> 2942<br class="fancyvrb" /><a 2943 id="x1-52022r3"></a><span 2944class="cmr-6">3</span><span 2945class="cmtt-8"> </span><span 2946class="cmtt-8"> entry</span><span 2947class="cmtt-8"> 2:</span><span 2948class="cmtt-8"> length</span><span 2949class="cmtt-8"> 4</span><span 2950class="cmtt-8"> codeword</span><span 2951class="cmtt-8"> 0101</span> 2952<br class="fancyvrb" /><a 2953 id="x1-52024r4"></a><span 2954class="cmr-6">4</span><span 2955class="cmtt-8"> </span><span 2956class="cmtt-8"> entry</span><span 2957class="cmtt-8"> 3:</span><span 2958class="cmtt-8"> length</span><span 2959class="cmtt-8"> 4</span><span 2960class="cmtt-8"> codeword</span><span 2961class="cmtt-8"> 0110</span> 2962<br class="fancyvrb" /><a 2963 id="x1-52026r5"></a><span 2964class="cmr-6">5</span><span 2965class="cmtt-8"> </span><span 2966class="cmtt-8"> entry</span><span 2967class="cmtt-8"> 4:</span><span 2968class="cmtt-8"> length</span><span 2969class="cmtt-8"> 4</span><span 2970class="cmtt-8"> codeword</span><span 2971class="cmtt-8"> 0111</span> 2972<br class="fancyvrb" /><a 2973 id="x1-52028r6"></a><span 2974class="cmr-6">6</span><span 2975class="cmtt-8"> </span><span 2976class="cmtt-8"> entry</span><span 2977class="cmtt-8"> 5:</span><span 2978class="cmtt-8"> length</span><span 2979class="cmtt-8"> 2</span><span 2980class="cmtt-8"> codeword</span><span 2981class="cmtt-8"> 10</span> 2982<br class="fancyvrb" /><a 2983 id="x1-52030r7"></a><span 2984class="cmr-6">7</span><span 2985class="cmtt-8"> </span><span 2986class="cmtt-8"> entry</span><span 2987class="cmtt-8"> 6:</span><span 2988class="cmtt-8"> length</span><span 2989class="cmtt-8"> 3</span><span 2990class="cmtt-8"> codeword</span><span 2991class="cmtt-8"> 110</span> 2992<br class="fancyvrb" /><a 2993 id="x1-52032r8"></a><span 2994class="cmr-6">8</span><span 2995class="cmtt-8"> </span><span 2996class="cmtt-8"> entry</span><span 2997class="cmtt-8"> 7:</span><span 2998class="cmtt-8"> length</span><span 2999class="cmtt-8"> 3</span><span 3000class="cmtt-8"> codeword</span><span 3001class="cmtt-8"> 111</span> 3002</div> 3003 3004 3005 3006<!--l. 235--><p class="noindent" ><span class="likesubparagraphHead"><a 3007 id="x1-530003.2.1"></a><span 3008class="cmbx-12">Note:</span></span> Unlike most binary numerical values in this document, we intend the above codewords to 3009be read and used bit by bit from left to right, thus the codeword ’001’ is the bit string ’zero, zero, 3010one’. When determining ’lowest possible value’ in the assignment definition above, the leftmost 3011bit is the MSb. 3012<!--l. 243--><p class="noindent" >It is clear that the codeword length list represents a Huffman decision tree with the entry 3013numbers equivalent to the leaves numbered left-to-right: 3014<div class="center" 3015> 3016<!--l. 247--><p class="noindent" > 3017 3018<!--l. 248--><p class="noindent" ><img 3019src="hufftree.png" alt="PIC" 3020> 3021<br /> <div class="caption" 3022><span class="id">Figure 4: </span><span 3023class="content">huffman tree illustration</span></div><!--tex4ht:label?: x1-530014 --> 3024</div> 3025<!--l. 253--><p class="noindent" >As we assign codewords in order, we see that each choice constructs a new leaf in the leftmost 3026possible position. 3027<!--l. 256--><p class="noindent" >Note that it’s possible to underspecify or overspecify a Huffman tree via the length list. 3028In the above example, if codeword seven were eliminated, it’s clear that the tree is 3029unfinished: 3030<div class="center" 3031> 3032<!--l. 260--><p class="noindent" > 3033 3034<!--l. 261--><p class="noindent" ><img 3035src="hufftree-under.png" alt="PIC" 3036> 3037<br /> <div class="caption" 3038><span class="id">Figure 5: </span><span 3039class="content">underspecified huffman tree illustration</span></div><!--tex4ht:label?: x1-530025 --> 3040</div> 3041<!--l. 266--><p class="noindent" >Similarly, in the original codebook, it’s clear that the tree is fully populated and a ninth 3042codeword is impossible. Both underspecified and overspecified trees are an error condition 3043rendering the stream undecodable. Take special care that a codebook with a single used 3044entry is handled properly; it consists of a single codework of zero bits and ’reading’ 3045a value out of such a codebook always returns the single used value and sinks zero 3046bits. 3047<!--l. 274--><p class="noindent" >Codebook entries marked ’unused’ are simply skipped in the assigning process. They have no 3048codeword and do not appear in the decision tree, thus it’s impossible for any bit pattern read 3049from the stream to decode to that entry number. 3050 3051 3052 3053<!--l. 281--><p class="noindent" ><span class="paragraphHead"><a 3054 id="x1-540003.2.1"></a><span 3055class="cmbx-12">VQ lookup table vector representation</span></span> 3056Unpacking the VQ lookup table vectors relies on the following values: 3057<div class="fancyvrb" id="fancyvrb17"> 3058<a 3059 id="x1-54002r1"></a><span 3060class="cmr-6">1</span><span 3061class="cmtt-8"> </span><span 3062class="cmtt-8"> the</span><span 3063class="cmtt-8"> [codebook_multiplicands]</span><span 3064class="cmtt-8"> array</span> 3065<br class="fancyvrb" /><a 3066 id="x1-54004r2"></a><span 3067class="cmr-6">2</span><span 3068class="cmtt-8"> </span><span 3069class="cmtt-8"> [codebook_minimum_value]</span> 3070<br class="fancyvrb" /><a 3071 id="x1-54006r3"></a><span 3072class="cmr-6">3</span><span 3073class="cmtt-8"> </span><span 3074class="cmtt-8"> [codebook_delta_value]</span> 3075<br class="fancyvrb" /><a 3076 id="x1-54008r4"></a><span 3077class="cmr-6">4</span><span 3078class="cmtt-8"> </span><span 3079class="cmtt-8"> [codebook_sequence_p]</span> 3080<br class="fancyvrb" /><a 3081 id="x1-54010r5"></a><span 3082class="cmr-6">5</span><span 3083class="cmtt-8"> </span><span 3084class="cmtt-8"> [codebook_lookup_type]</span> 3085<br class="fancyvrb" /><a 3086 id="x1-54012r6"></a><span 3087class="cmr-6">6</span><span 3088class="cmtt-8"> </span><span 3089class="cmtt-8"> [codebook_entries]</span> 3090<br class="fancyvrb" /><a 3091 id="x1-54014r7"></a><span 3092class="cmr-6">7</span><span 3093class="cmtt-8"> </span><span 3094class="cmtt-8"> [codebook_dimensions]</span> 3095<br class="fancyvrb" /><a 3096 id="x1-54016r8"></a><span 3097class="cmr-6">8</span><span 3098class="cmtt-8"> </span><span 3099class="cmtt-8"> [codebook_lookup_values]</span> 3100</div> 3101<!--l. 297--><p class="noindent" >Decoding (unpacking) a specific vector in the vector lookup table proceeds according to 3102<span 3103class="cmtt-12">[codebook_lookup_type]</span>. The unpacked vector values are what a codebook would return 3104during audio packet decode in a VQ context. 3105<!--l. 302--><p class="noindent" ><span class="paragraphHead"><a 3106 id="x1-550003.2.1"></a><span 3107class="cmbx-12">Vector value decode: Lookup type 1</span></span> 3108Lookup type one specifies a lattice VQ lookup table built algorithmically from a list of 3109scalar values. Calculate (unpack) the final values of a codebook entry vector from 3110the entries in <span 3111class="cmtt-12">[codebook_multiplicands] </span>as follows (<span 3112class="cmtt-12">[value_vector] </span>is the output 3113vector representing the vector of values for entry number <span 3114class="cmtt-12">[lookup_offset] </span>in this 3115codebook): 3116<!--l. 311--><p class="noindent" > 3117<div class="fancyvrb" id="fancyvrb18"> 3118<a 3119 id="x1-55002r1"></a><span 3120class="cmr-6">1</span><span 3121class="cmtt-8"> </span><span 3122class="cmtt-8"> </span><span 3123class="cmtt-8"> </span><span 3124class="cmtt-8"> 1)</span><span 3125class="cmtt-8"> [last]</span><span 3126class="cmtt-8"> =</span><span 3127class="cmtt-8"> 0;</span> 3128<br class="fancyvrb" /><a 3129 id="x1-55004r2"></a><span 3130class="cmr-6">2</span><span 3131class="cmtt-8"> </span><span 3132class="cmtt-8"> </span><span 3133class="cmtt-8"> </span><span 3134class="cmtt-8"> 2)</span><span 3135class="cmtt-8"> [index_divisor]</span><span 3136class="cmtt-8"> =</span><span 3137class="cmtt-8"> 1;</span> 3138<br class="fancyvrb" /><a 3139 id="x1-55006r3"></a><span 3140class="cmr-6">3</span><span 3141class="cmtt-8"> </span><span 3142class="cmtt-8"> </span><span 3143class="cmtt-8"> </span><span 3144class="cmtt-8"> 3)</span><span 3145class="cmtt-8"> iterate</span><span 3146class="cmtt-8"> [i]</span><span 3147class="cmtt-8"> over</span><span 3148class="cmtt-8"> the</span><span 3149class="cmtt-8"> range</span><span 3150class="cmtt-8"> 0</span><span 3151class="cmtt-8"> ...</span><span 3152class="cmtt-8"> [codebook_dimensions]-1</span><span 3153class="cmtt-8"> (once</span><span 3154class="cmtt-8"> for</span><span 3155class="cmtt-8"> each</span><span 3156class="cmtt-8"> scalar</span><span 3157class="cmtt-8"> value</span><span 3158class="cmtt-8"> in</span><span 3159class="cmtt-8"> the</span><span 3160class="cmtt-8"> value</span><span 3161class="cmtt-8"> vector)</span><span 3162class="cmtt-8"> </span><span 3163class="cmsy-8">{</span> 3164<br class="fancyvrb" /><a 3165 id="x1-55008r4"></a><span 3166class="cmr-6">4</span><span 3167class="cmtt-8"> </span><span 3168class="cmtt-8"> </span> 3169<br class="fancyvrb" /><a 3170 id="x1-55010r5"></a><span 3171class="cmr-6">5</span><span 3172class="cmtt-8"> </span><span 3173class="cmtt-8"> </span><span 3174class="cmtt-8"> </span><span 3175class="cmtt-8"> </span><span 3176class="cmtt-8"> </span><span 3177class="cmtt-8"> </span><span 3178class="cmtt-8"> </span><span 3179class="cmtt-8"> </span><span 3180class="cmtt-8"> 4)</span><span 3181class="cmtt-8"> [multiplicand_offset]</span><span 3182class="cmtt-8"> =</span><span 3183class="cmtt-8"> (</span><span 3184class="cmtt-8"> [lookup_offset]</span><span 3185class="cmtt-8"> divided</span><span 3186class="cmtt-8"> by</span><span 3187class="cmtt-8"> [index_divisor]</span><span 3188class="cmtt-8"> using</span><span 3189class="cmtt-8"> integer</span> 3190<br class="fancyvrb" /><a 3191 id="x1-55012r6"></a><span 3192class="cmr-6">6</span><span 3193class="cmtt-8"> </span><span 3194class="cmtt-8"> </span><span 3195class="cmtt-8"> </span><span 3196class="cmtt-8"> </span><span 3197class="cmtt-8"> </span><span 3198class="cmtt-8"> </span><span 3199class="cmtt-8"> </span><span 3200class="cmtt-8"> </span><span 3201class="cmtt-8"> </span><span 3202class="cmtt-8"> </span><span 3203class="cmtt-8"> </span><span 3204class="cmtt-8"> division</span><span 3205class="cmtt-8"> )</span><span 3206class="cmtt-8"> integer</span><span 3207class="cmtt-8"> modulo</span><span 3208class="cmtt-8"> [codebook_lookup_values]</span> 3209<br class="fancyvrb" /><a 3210 id="x1-55014r7"></a><span 3211class="cmr-6">7</span><span 3212class="cmtt-8"> </span><span 3213class="cmtt-8"> </span> 3214<br class="fancyvrb" /><a 3215 id="x1-55016r8"></a><span 3216class="cmr-6">8</span><span 3217class="cmtt-8"> </span><span 3218class="cmtt-8"> </span><span 3219class="cmtt-8"> </span><span 3220class="cmtt-8"> </span><span 3221class="cmtt-8"> </span><span 3222class="cmtt-8"> </span><span 3223class="cmtt-8"> </span><span 3224class="cmtt-8"> </span><span 3225class="cmtt-8"> 5)</span><span 3226class="cmtt-8"> vector</span><span 3227class="cmtt-8"> [value_vector]</span><span 3228class="cmtt-8"> element</span><span 3229class="cmtt-8"> [i]</span><span 3230class="cmtt-8"> =</span> 3231<br class="fancyvrb" /><a 3232 id="x1-55018r9"></a><span 3233class="cmr-6">9</span><span 3234class="cmtt-8"> </span><span 3235class="cmtt-8"> </span><span 3236class="cmtt-8"> </span><span 3237class="cmtt-8"> </span><span 3238class="cmtt-8"> </span><span 3239class="cmtt-8"> </span><span 3240class="cmtt-8"> </span><span 3241class="cmtt-8"> </span><span 3242class="cmtt-8"> </span><span 3243class="cmtt-8"> </span><span 3244class="cmtt-8"> </span><span 3245class="cmtt-8"> </span><span 3246class="cmtt-8"> </span><span 3247class="cmtt-8"> (</span><span 3248class="cmtt-8"> [codebook_multiplicands]</span><span 3249class="cmtt-8"> array</span><span 3250class="cmtt-8"> element</span><span 3251class="cmtt-8"> number</span><span 3252class="cmtt-8"> [multiplicand_offset]</span><span 3253class="cmtt-8"> )</span><span 3254class="cmtt-8"> *</span> 3255<br class="fancyvrb" /><a 3256 id="x1-55020r10"></a><span 3257class="cmr-6">10</span><span 3258class="cmtt-8"> </span><span 3259class="cmtt-8"> </span><span 3260class="cmtt-8"> </span><span 3261class="cmtt-8"> </span><span 3262class="cmtt-8"> </span><span 3263class="cmtt-8"> </span><span 3264class="cmtt-8"> </span><span 3265class="cmtt-8"> </span><span 3266class="cmtt-8"> </span><span 3267class="cmtt-8"> </span><span 3268class="cmtt-8"> </span><span 3269class="cmtt-8"> </span><span 3270class="cmtt-8"> </span><span 3271class="cmtt-8"> [codebook_delta_value]</span><span 3272class="cmtt-8"> +</span><span 3273class="cmtt-8"> [codebook_minimum_value]</span><span 3274class="cmtt-8"> +</span><span 3275class="cmtt-8"> [last];</span> 3276<br class="fancyvrb" /><a 3277 id="x1-55022r11"></a><span 3278class="cmr-6">11</span><span 3279class="cmtt-8"> </span><span 3280class="cmtt-8"> </span> 3281<br class="fancyvrb" /><a 3282 id="x1-55024r12"></a><span 3283class="cmr-6">12</span><span 3284class="cmtt-8"> </span><span 3285class="cmtt-8"> </span><span 3286class="cmtt-8"> </span><span 3287class="cmtt-8"> </span><span 3288class="cmtt-8"> </span><span 3289class="cmtt-8"> </span><span 3290class="cmtt-8"> </span><span 3291class="cmtt-8"> </span><span 3292class="cmtt-8"> 6)</span><span 3293class="cmtt-8"> if</span><span 3294class="cmtt-8"> (</span><span 3295class="cmtt-8"> [codebook_sequence_p]</span><span 3296class="cmtt-8"> is</span><span 3297class="cmtt-8"> set</span><span 3298class="cmtt-8"> )</span><span 3299class="cmtt-8"> then</span><span 3300class="cmtt-8"> set</span><span 3301class="cmtt-8"> [last]</span><span 3302class="cmtt-8"> =</span><span 3303class="cmtt-8"> vector</span><span 3304class="cmtt-8"> [value_vector]</span><span 3305class="cmtt-8"> element</span><span 3306class="cmtt-8"> [i]</span> 3307<br class="fancyvrb" /><a 3308 id="x1-55026r13"></a><span 3309class="cmr-6">13</span><span 3310class="cmtt-8"> </span><span 3311class="cmtt-8"> </span> 3312<br class="fancyvrb" /><a 3313 id="x1-55028r14"></a><span 3314class="cmr-6">14</span><span 3315class="cmtt-8"> </span><span 3316class="cmtt-8"> </span><span 3317class="cmtt-8"> </span><span 3318class="cmtt-8"> </span><span 3319class="cmtt-8"> </span><span 3320class="cmtt-8"> </span><span 3321class="cmtt-8"> </span><span 3322class="cmtt-8"> </span><span 3323class="cmtt-8"> 7)</span><span 3324class="cmtt-8"> [index_divisor]</span><span 3325class="cmtt-8"> =</span><span 3326class="cmtt-8"> [index_divisor]</span><span 3327class="cmtt-8"> *</span><span 3328class="cmtt-8"> [codebook_lookup_values]</span> 3329<br class="fancyvrb" /><a 3330 id="x1-55030r15"></a><span 3331class="cmr-6">15</span><span 3332class="cmtt-8"> </span><span 3333class="cmtt-8"> </span> 3334<br class="fancyvrb" /><a 3335 id="x1-55032r16"></a><span 3336class="cmr-6">16</span><span 3337class="cmtt-8"> </span><span 3338class="cmtt-8"> </span><span 3339class="cmtt-8"> </span><span 3340class="cmtt-8"> </span><span 3341class="cmtt-8"> </span><span 3342class="cmtt-8"> </span><span 3343class="cmtt-8"> </span><span 3344class="cmsy-8">}</span> 3345<br class="fancyvrb" /><a 3346 id="x1-55034r17"></a><span 3347class="cmr-6">17</span><span 3348class="cmtt-8"> </span><span 3349class="cmtt-8"> </span> 3350<br class="fancyvrb" /><a 3351 id="x1-55036r18"></a><span 3352class="cmr-6">18</span><span 3353class="cmtt-8"> </span><span 3354class="cmtt-8"> </span><span 3355class="cmtt-8"> </span><span 3356class="cmtt-8"> 8)</span><span 3357class="cmtt-8"> vector</span><span 3358class="cmtt-8"> calculation</span><span 3359class="cmtt-8"> completed.</span> 3360</div> 3361 3362 3363 3364<!--l. 334--><p class="noindent" ><span class="paragraphHead"><a 3365 id="x1-560003.2.1"></a><span 3366class="cmbx-12">Vector value decode: Lookup type 2</span></span> 3367Lookup type two specifies a VQ lookup table in which each scalar in each vector is explicitly set 3368by the <span 3369class="cmtt-12">[codebook_multiplicands] </span>array in a one-to-one mapping. Calculate [unpack] the final 3370values of a codebook entry vector from the entries in <span 3371class="cmtt-12">[codebook_multiplicands] </span>as follows 3372(<span 3373class="cmtt-12">[value_vector] </span>is the output vector representing the vector of values for entry number 3374<span 3375class="cmtt-12">[lookup_offset] </span>in this codebook): 3376<!--l. 344--><p class="noindent" > 3377<div class="fancyvrb" id="fancyvrb19"> 3378<a 3379 id="x1-56002r1"></a><span 3380class="cmr-6">1</span><span 3381class="cmtt-8"> </span><span 3382class="cmtt-8"> </span><span 3383class="cmtt-8"> </span><span 3384class="cmtt-8"> 1)</span><span 3385class="cmtt-8"> [last]</span><span 3386class="cmtt-8"> =</span><span 3387class="cmtt-8"> 0;</span> 3388<br class="fancyvrb" /><a 3389 id="x1-56004r2"></a><span 3390class="cmr-6">2</span><span 3391class="cmtt-8"> </span><span 3392class="cmtt-8"> </span><span 3393class="cmtt-8"> </span><span 3394class="cmtt-8"> 2)</span><span 3395class="cmtt-8"> [multiplicand_offset]</span><span 3396class="cmtt-8"> =</span><span 3397class="cmtt-8"> [lookup_offset]</span><span 3398class="cmtt-8"> *</span><span 3399class="cmtt-8"> [codebook_dimensions]</span> 3400<br class="fancyvrb" /><a 3401 id="x1-56006r3"></a><span 3402class="cmr-6">3</span><span 3403class="cmtt-8"> </span><span 3404class="cmtt-8"> </span><span 3405class="cmtt-8"> </span><span 3406class="cmtt-8"> 3)</span><span 3407class="cmtt-8"> iterate</span><span 3408class="cmtt-8"> [i]</span><span 3409class="cmtt-8"> over</span><span 3410class="cmtt-8"> the</span><span 3411class="cmtt-8"> range</span><span 3412class="cmtt-8"> 0</span><span 3413class="cmtt-8"> ...</span><span 3414class="cmtt-8"> [codebook_dimensions]-1</span><span 3415class="cmtt-8"> (once</span><span 3416class="cmtt-8"> for</span><span 3417class="cmtt-8"> each</span><span 3418class="cmtt-8"> scalar</span><span 3419class="cmtt-8"> value</span><span 3420class="cmtt-8"> in</span><span 3421class="cmtt-8"> the</span><span 3422class="cmtt-8"> value</span><span 3423class="cmtt-8"> vector)</span><span 3424class="cmtt-8"> </span><span 3425class="cmsy-8">{</span> 3426<br class="fancyvrb" /><a 3427 id="x1-56008r4"></a><span 3428class="cmr-6">4</span><span 3429class="cmtt-8"> </span><span 3430class="cmtt-8"> </span> 3431<br class="fancyvrb" /><a 3432 id="x1-56010r5"></a><span 3433class="cmr-6">5</span><span 3434class="cmtt-8"> </span><span 3435class="cmtt-8"> </span><span 3436class="cmtt-8"> </span><span 3437class="cmtt-8"> </span><span 3438class="cmtt-8"> </span><span 3439class="cmtt-8"> </span><span 3440class="cmtt-8"> </span><span 3441class="cmtt-8"> </span><span 3442class="cmtt-8"> 4)</span><span 3443class="cmtt-8"> vector</span><span 3444class="cmtt-8"> [value_vector]</span><span 3445class="cmtt-8"> element</span><span 3446class="cmtt-8"> [i]</span><span 3447class="cmtt-8"> =</span> 3448<br class="fancyvrb" /><a 3449 id="x1-56012r6"></a><span 3450class="cmr-6">6</span><span 3451class="cmtt-8"> </span><span 3452class="cmtt-8"> </span><span 3453class="cmtt-8"> </span><span 3454class="cmtt-8"> </span><span 3455class="cmtt-8"> </span><span 3456class="cmtt-8"> </span><span 3457class="cmtt-8"> </span><span 3458class="cmtt-8"> </span><span 3459class="cmtt-8"> </span><span 3460class="cmtt-8"> </span><span 3461class="cmtt-8"> </span><span 3462class="cmtt-8"> </span><span 3463class="cmtt-8"> </span><span 3464class="cmtt-8"> (</span><span 3465class="cmtt-8"> [codebook_multiplicands]</span><span 3466class="cmtt-8"> array</span><span 3467class="cmtt-8"> element</span><span 3468class="cmtt-8"> number</span><span 3469class="cmtt-8"> [multiplicand_offset]</span><span 3470class="cmtt-8"> )</span><span 3471class="cmtt-8"> *</span> 3472<br class="fancyvrb" /><a 3473 id="x1-56014r7"></a><span 3474class="cmr-6">7</span><span 3475class="cmtt-8"> </span><span 3476class="cmtt-8"> </span><span 3477class="cmtt-8"> </span><span 3478class="cmtt-8"> </span><span 3479class="cmtt-8"> </span><span 3480class="cmtt-8"> </span><span 3481class="cmtt-8"> </span><span 3482class="cmtt-8"> </span><span 3483class="cmtt-8"> </span><span 3484class="cmtt-8"> </span><span 3485class="cmtt-8"> </span><span 3486class="cmtt-8"> </span><span 3487class="cmtt-8"> </span><span 3488class="cmtt-8"> [codebook_delta_value]</span><span 3489class="cmtt-8"> +</span><span 3490class="cmtt-8"> [codebook_minimum_value]</span><span 3491class="cmtt-8"> +</span><span 3492class="cmtt-8"> [last];</span> 3493<br class="fancyvrb" /><a 3494 id="x1-56016r8"></a><span 3495class="cmr-6">8</span><span 3496class="cmtt-8"> </span><span 3497class="cmtt-8"> </span> 3498<br class="fancyvrb" /><a 3499 id="x1-56018r9"></a><span 3500class="cmr-6">9</span><span 3501class="cmtt-8"> </span><span 3502class="cmtt-8"> </span><span 3503class="cmtt-8"> </span><span 3504class="cmtt-8"> </span><span 3505class="cmtt-8"> </span><span 3506class="cmtt-8"> </span><span 3507class="cmtt-8"> </span><span 3508class="cmtt-8"> </span><span 3509class="cmtt-8"> 5)</span><span 3510class="cmtt-8"> if</span><span 3511class="cmtt-8"> (</span><span 3512class="cmtt-8"> [codebook_sequence_p]</span><span 3513class="cmtt-8"> is</span><span 3514class="cmtt-8"> set</span><span 3515class="cmtt-8"> )</span><span 3516class="cmtt-8"> then</span><span 3517class="cmtt-8"> set</span><span 3518class="cmtt-8"> [last]</span><span 3519class="cmtt-8"> =</span><span 3520class="cmtt-8"> vector</span><span 3521class="cmtt-8"> [value_vector]</span><span 3522class="cmtt-8"> element</span><span 3523class="cmtt-8"> [i]</span> 3524<br class="fancyvrb" /><a 3525 id="x1-56020r10"></a><span 3526class="cmr-6">10</span><span 3527class="cmtt-8"> </span><span 3528class="cmtt-8"> </span> 3529<br class="fancyvrb" /><a 3530 id="x1-56022r11"></a><span 3531class="cmr-6">11</span><span 3532class="cmtt-8"> </span><span 3533class="cmtt-8"> </span><span 3534class="cmtt-8"> </span><span 3535class="cmtt-8"> </span><span 3536class="cmtt-8"> </span><span 3537class="cmtt-8"> </span><span 3538class="cmtt-8"> </span><span 3539class="cmtt-8"> </span><span 3540class="cmtt-8"> 6)</span><span 3541class="cmtt-8"> increment</span><span 3542class="cmtt-8"> [multiplicand_offset]</span> 3543<br class="fancyvrb" /><a 3544 id="x1-56024r12"></a><span 3545class="cmr-6">12</span><span 3546class="cmtt-8"> </span><span 3547class="cmtt-8"> </span> 3548<br class="fancyvrb" /><a 3549 id="x1-56026r13"></a><span 3550class="cmr-6">13</span><span 3551class="cmtt-8"> </span><span 3552class="cmtt-8"> </span><span 3553class="cmtt-8"> </span><span 3554class="cmtt-8"> </span><span 3555class="cmtt-8"> </span><span 3556class="cmtt-8"> </span><span 3557class="cmtt-8"> </span><span 3558class="cmsy-8">}</span> 3559<br class="fancyvrb" /><a 3560 id="x1-56028r14"></a><span 3561class="cmr-6">14</span><span 3562class="cmtt-8"> </span><span 3563class="cmtt-8"> </span> 3564<br class="fancyvrb" /><a 3565 id="x1-56030r15"></a><span 3566class="cmr-6">15</span><span 3567class="cmtt-8"> </span><span 3568class="cmtt-8"> </span><span 3569class="cmtt-8"> </span><span 3570class="cmtt-8"> 7)</span><span 3571class="cmtt-8"> vector</span><span 3572class="cmtt-8"> calculation</span><span 3573class="cmtt-8"> completed.</span> 3574</div> 3575<!--l. 370--><p class="noindent" > 3576<h4 class="subsectionHead"><span class="titlemark">3.3 </span> <a 3577 id="x1-570003.3"></a>Use of the codebook abstraction</h4> 3578<!--l. 372--><p class="noindent" >The decoder uses the codebook abstraction much as it does the bit-unpacking convention; a 3579specific codebook reads a codeword from the bitstream, decoding it into an entry number, and 3580then returns that entry number to the decoder (when used in a scalar entropy coding context), or 3581uses that entry number as an offset into the VQ lookup table, returning a vector of values (when 3582used in a context desiring a VQ value). Scalar or VQ context is always explicit; any 3583call to the codebook mechanism requests either a scalar entry number or a lookup 3584vector. 3585<!--l. 382--><p class="noindent" >Note that VQ lookup type zero indicates that there is no lookup table; requesting 3586decode using a codebook of lookup type 0 in any context expecting a vector return 3587value (even in a case where a vector of dimension one) is forbidden. If decoder setup 3588or decode requests such an action, that is an error condition rendering the packet 3589 3590 3591 3592undecodable. 3593<!--l. 389--><p class="noindent" >Using a codebook to read from the packet bitstream consists first of reading and decoding the 3594next codeword in the bitstream. The decoder reads bits until the accumulated bits match a 3595codeword in the codebook. This process can be though of as logically walking the 3596Huffman decode tree by reading one bit at a time from the bitstream, and using the 3597bit as a decision boolean to take the 0 branch (left in the above examples) or the 1 3598branch (right in the above examples). Walking the tree finishes when the decode process 3599hits a leaf in the decision tree; the result is the entry number corresponding to that 3600leaf. Reading past the end of a packet propagates the ’end-of-stream’ condition to the 3601decoder. 3602<!--l. 401--><p class="noindent" >When used in a scalar context, the resulting codeword entry is the desired return 3603value. 3604<!--l. 404--><p class="noindent" >When used in a VQ context, the codeword entry number is used as an offset into the VQ lookup 3605table. The value returned to the decoder is the vector of scalars corresponding to this 3606offset. 3607 3608 3609 3610 3611 3612 3613<h3 class="sectionHead"><span class="titlemark">4 </span> <a 3614 id="x1-580004"></a>Codec Setup and Packet Decode</h3> 3615<!--l. 7--><p class="noindent" > 3616<h4 class="subsectionHead"><span class="titlemark">4.1 </span> <a 3617 id="x1-590004.1"></a>Overview</h4> 3618<!--l. 9--><p class="noindent" >This document serves as the top-level reference document for the bit-by-bit decode specification 3619of Vorbis I. This document assumes a high-level understanding of the Vorbis decode 3620process, which is provided in <a 3621href="#x1-20001">Section 1</a>, “<a 3622href="#x1-20001">Introduction and Description<!--tex4ht:ref: vorbis:spec:intro --></a>”. <a 3623href="#x1-360002">Section 2</a>, 3624“<a 3625href="#x1-360002">Bitpacking Convention<!--tex4ht:ref: vorbis:spec:bitpacking --></a>” covers reading and writing bit fields from and to bitstream 3626packets. 3627<!--l. 17--><p class="noindent" > 3628<h4 class="subsectionHead"><span class="titlemark">4.2 </span> <a 3629 id="x1-600004.2"></a>Header decode and decode setup</h4> 3630<!--l. 19--><p class="noindent" >A Vorbis bitstream begins with three header packets. The header packets are, in order, the 3631identification header, the comments header, and the setup header. All are required for decode 3632compliance. An end-of-packet condition during decoding the first or third header packet renders 3633the stream undecodable. End-of-packet decoding the comment header is a non-fatal error 3634condition. 3635<!--l. 26--><p class="noindent" > 3636<h5 class="subsubsectionHead"><span class="titlemark">4.2.1 </span> <a 3637 id="x1-610004.2.1"></a>Common header decode</h5> 3638<!--l. 28--><p class="noindent" >Each header packet begins with the same header fields. 3639<!--l. 31--><p class="noindent" > 3640<div class="fancyvrb" id="fancyvrb20"> 3641<a 3642 id="x1-61002r1"></a><span 3643class="cmr-6">1</span><span 3644class="cmtt-8"> </span><span 3645class="cmtt-8"> </span><span 3646class="cmtt-8"> </span><span 3647class="cmtt-8"> 1)</span><span 3648class="cmtt-8"> [packet_type]</span><span 3649class="cmtt-8"> :</span><span 3650class="cmtt-8"> 8</span><span 3651class="cmtt-8"> bit</span><span 3652class="cmtt-8"> value</span> 3653<br class="fancyvrb" /><a 3654 id="x1-61004r2"></a><span 3655class="cmr-6">2</span><span 3656class="cmtt-8"> </span><span 3657class="cmtt-8"> </span><span 3658class="cmtt-8"> </span><span 3659class="cmtt-8"> 2)</span><span 3660class="cmtt-8"> 0x76,</span><span 3661class="cmtt-8"> 0x6f,</span><span 3662class="cmtt-8"> 0x72,</span><span 3663class="cmtt-8"> 0x62,</span><span 3664class="cmtt-8"> 0x69,</span><span 3665class="cmtt-8"> 0x73:</span><span 3666class="cmtt-8"> the</span><span 3667class="cmtt-8"> characters</span><span 3668class="cmtt-8"> ’v’,’o’,’r’,’b’,’i’,’s’</span><span 3669class="cmtt-8"> as</span><span 3670class="cmtt-8"> six</span><span 3671class="cmtt-8"> octets</span> 3672</div> 3673 3674 3675 3676<!--l. 36--><p class="noindent" >Decode continues according to packet type; the identification header is type 1, the comment 3677header type 3 and the setup header type 5 (these types are all odd as a packet with a leading 3678single bit of ’0’ is an audio packet). The packets must occur in the order of identification, 3679comment, setup. 3680<!--l. 44--><p class="noindent" > 3681<h5 class="subsubsectionHead"><span class="titlemark">4.2.2 </span> <a 3682 id="x1-620004.2.2"></a>Identification header</h5> 3683<!--l. 46--><p class="noindent" >The identification header is a short header of only a few fields used to declare the stream 3684definitively as Vorbis, and provide a few externally relevant pieces of information about the audio 3685stream. The identification header is coded as follows: 3686<!--l. 51--><p class="noindent" > 3687<div class="fancyvrb" id="fancyvrb21"> 3688<a 3689 id="x1-62002r1"></a><span 3690class="cmr-6">1</span><span 3691class="cmtt-8"> </span><span 3692class="cmtt-8"> </span><span 3693class="cmtt-8"> 1)</span><span 3694class="cmtt-8"> [vorbis_version]</span><span 3695class="cmtt-8"> =</span><span 3696class="cmtt-8"> read</span><span 3697class="cmtt-8"> 32</span><span 3698class="cmtt-8"> bits</span><span 3699class="cmtt-8"> as</span><span 3700class="cmtt-8"> unsigned</span><span 3701class="cmtt-8"> integer</span> 3702<br class="fancyvrb" /><a 3703 id="x1-62004r2"></a><span 3704class="cmr-6">2</span><span 3705class="cmtt-8"> </span><span 3706class="cmtt-8"> </span><span 3707class="cmtt-8"> 2)</span><span 3708class="cmtt-8"> [audio_channels]</span><span 3709class="cmtt-8"> =</span><span 3710class="cmtt-8"> read</span><span 3711class="cmtt-8"> 8</span><span 3712class="cmtt-8"> bit</span><span 3713class="cmtt-8"> integer</span><span 3714class="cmtt-8"> as</span><span 3715class="cmtt-8"> unsigned</span> 3716<br class="fancyvrb" /><a 3717 id="x1-62006r3"></a><span 3718class="cmr-6">3</span><span 3719class="cmtt-8"> </span><span 3720class="cmtt-8"> </span><span 3721class="cmtt-8"> 3)</span><span 3722class="cmtt-8"> [audio_sample_rate]</span><span 3723class="cmtt-8"> =</span><span 3724class="cmtt-8"> read</span><span 3725class="cmtt-8"> 32</span><span 3726class="cmtt-8"> bits</span><span 3727class="cmtt-8"> as</span><span 3728class="cmtt-8"> unsigned</span><span 3729class="cmtt-8"> integer</span> 3730<br class="fancyvrb" /><a 3731 id="x1-62008r4"></a><span 3732class="cmr-6">4</span><span 3733class="cmtt-8"> </span><span 3734class="cmtt-8"> </span><span 3735class="cmtt-8"> 4)</span><span 3736class="cmtt-8"> [bitrate_maximum]</span><span 3737class="cmtt-8"> =</span><span 3738class="cmtt-8"> read</span><span 3739class="cmtt-8"> 32</span><span 3740class="cmtt-8"> bits</span><span 3741class="cmtt-8"> as</span><span 3742class="cmtt-8"> signed</span><span 3743class="cmtt-8"> integer</span> 3744<br class="fancyvrb" /><a 3745 id="x1-62010r5"></a><span 3746class="cmr-6">5</span><span 3747class="cmtt-8"> </span><span 3748class="cmtt-8"> </span><span 3749class="cmtt-8"> 5)</span><span 3750class="cmtt-8"> [bitrate_nominal]</span><span 3751class="cmtt-8"> =</span><span 3752class="cmtt-8"> read</span><span 3753class="cmtt-8"> 32</span><span 3754class="cmtt-8"> bits</span><span 3755class="cmtt-8"> as</span><span 3756class="cmtt-8"> signed</span><span 3757class="cmtt-8"> integer</span> 3758<br class="fancyvrb" /><a 3759 id="x1-62012r6"></a><span 3760class="cmr-6">6</span><span 3761class="cmtt-8"> </span><span 3762class="cmtt-8"> </span><span 3763class="cmtt-8"> 6)</span><span 3764class="cmtt-8"> [bitrate_minimum]</span><span 3765class="cmtt-8"> =</span><span 3766class="cmtt-8"> read</span><span 3767class="cmtt-8"> 32</span><span 3768class="cmtt-8"> bits</span><span 3769class="cmtt-8"> as</span><span 3770class="cmtt-8"> signed</span><span 3771class="cmtt-8"> integer</span> 3772<br class="fancyvrb" /><a 3773 id="x1-62014r7"></a><span 3774class="cmr-6">7</span><span 3775class="cmtt-8"> </span><span 3776class="cmtt-8"> </span><span 3777class="cmtt-8"> 7)</span><span 3778class="cmtt-8"> [blocksize_0]</span><span 3779class="cmtt-8"> =</span><span 3780class="cmtt-8"> 2</span><span 3781class="cmtt-8"> exponent</span><span 3782class="cmtt-8"> (read</span><span 3783class="cmtt-8"> 4</span><span 3784class="cmtt-8"> bits</span><span 3785class="cmtt-8"> as</span><span 3786class="cmtt-8"> unsigned</span><span 3787class="cmtt-8"> integer)</span> 3788<br class="fancyvrb" /><a 3789 id="x1-62016r8"></a><span 3790class="cmr-6">8</span><span 3791class="cmtt-8"> </span><span 3792class="cmtt-8"> </span><span 3793class="cmtt-8"> 8)</span><span 3794class="cmtt-8"> [blocksize_1]</span><span 3795class="cmtt-8"> =</span><span 3796class="cmtt-8"> 2</span><span 3797class="cmtt-8"> exponent</span><span 3798class="cmtt-8"> (read</span><span 3799class="cmtt-8"> 4</span><span 3800class="cmtt-8"> bits</span><span 3801class="cmtt-8"> as</span><span 3802class="cmtt-8"> unsigned</span><span 3803class="cmtt-8"> integer)</span> 3804<br class="fancyvrb" /><a 3805 id="x1-62018r9"></a><span 3806class="cmr-6">9</span><span 3807class="cmtt-8"> </span><span 3808class="cmtt-8"> </span><span 3809class="cmtt-8"> 9)</span><span 3810class="cmtt-8"> [framing_flag]</span><span 3811class="cmtt-8"> =</span><span 3812class="cmtt-8"> read</span><span 3813class="cmtt-8"> one</span><span 3814class="cmtt-8"> bit</span> 3815</div> 3816<!--l. 63--><p class="noindent" ><span 3817class="cmtt-12">[vorbis_version] </span>is to read ’0’ in order to be compatible with this document. Both 3818<span 3819class="cmtt-12">[audio_channels] </span>and <span 3820class="cmtt-12">[audio_sample_rate] </span>must read greater than zero. Allowed final 3821blocksize values are 64, 128, 256, 512, 1024, 2048, 4096 and 8192 in Vorbis I. <span 3822class="cmtt-12">[blocksize_0]</span> 3823must be less than or equal to <span 3824class="cmtt-12">[blocksize_1]</span>. The framing bit must be nonzero. Failure to meet 3825any of these conditions renders a stream undecodable. 3826<!--l. 71--><p class="noindent" >The bitrate fields above are used only as hints. The nominal bitrate field especially may be 3827considerably off in purely VBR streams. The fields are meaningful only when greater than 3828zero. 3829 <ul class="itemize1"> 3830 <li class="itemize">All three fields set to the same value implies a fixed rate, or tightly bounded, nearly 3831 fixed-rate bitstream 3832 </li> 3833 <li class="itemize">Only nominal set implies a VBR or ABR stream that averages the nominal bitrate 3834 3835 3836 3837 </li> 3838 <li class="itemize">Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits 3839 </li> 3840 <li class="itemize">None set indicates the encoder does not care to speculate.</li></ul> 3841<!--l. 85--><p class="noindent" > 3842<h5 class="subsubsectionHead"><span class="titlemark">4.2.3 </span> <a 3843 id="x1-630004.2.3"></a>Comment header</h5> 3844<!--l. 86--><p class="noindent" >Comment header decode and data specification is covered in <a 3845href="#x1-810005">Section 5</a>, “<a 3846href="#x1-810005">comment field and 3847header specification<!--tex4ht:ref: vorbis:spec:comment --></a>”. 3848<!--l. 90--><p class="noindent" > 3849<h5 class="subsubsectionHead"><span class="titlemark">4.2.4 </span> <a 3850 id="x1-640004.2.4"></a>Setup header</h5> 3851<!--l. 92--><p class="noindent" >Vorbis codec setup is configurable to an extreme degree: 3852<div class="center" 3853> 3854<!--l. 94--><p class="noindent" > 3855 3856<!--l. 95--><p class="noindent" ><img 3857src="components.png" alt="PIC" 3858> 3859<br /> <div class="caption" 3860><span class="id">Figure 6: </span><span 3861class="content">decoder pipeline configuration</span></div><!--tex4ht:label?: x1-640016 --> 3862</div> 3863<!--l. 100--><p class="noindent" >The setup header contains the bulk of the codec setup information needed for decode. The setup 3864header contains, in order, the lists of codebook configurations, time-domain transform 3865configurations (placeholders in Vorbis I), floor configurations, residue configurations, channel 3866mapping configurations and mode configurations. It finishes with a framing bit of ’1’. Header 3867decode proceeds in the following order: 3868<!--l. 108--><p class="noindent" ><span class="paragraphHead"><a 3869 id="x1-650004.2.4"></a><span 3870class="cmbx-12">Codebooks</span></span> 3871 3872 3873 3874 <ol class="enumerate1" > 3875 <li 3876 class="enumerate" id="x1-65002x1"><span 3877class="cmtt-12">[vorbis_codebook_count] </span>= read eight bits as unsigned integer and add one 3878 </li> 3879 <li 3880 class="enumerate" id="x1-65004x2">Decode <span 3881class="cmtt-12">[vorbis_codebook_count] </span>codebooks in order as defined in <a 3882href="#x1-470003">Section 3</a>, 3883 “<a 3884href="#x1-470003">Probability Model and Codebooks<!--tex4ht:ref: vorbis:spec:codebook --></a>”. Save each configuration, in order, in an array 3885 of codebook configurations <span 3886class="cmtt-12">[vorbis_codebook_configurations]</span>.</li></ol> 3887<!--l. 120--><p class="noindent" ><span class="paragraphHead"><a 3888 id="x1-660004.2.4"></a><span 3889class="cmbx-12">Time domain transforms</span></span> 3890These hooks are placeholders in Vorbis I. Nevertheless, the configuration placeholder values must 3891be read to maintain bitstream sync. 3892<!--l. 126--><p class="noindent" > 3893 <ol class="enumerate1" > 3894 <li 3895 class="enumerate" id="x1-66002x1"><span 3896class="cmtt-12">[vorbis_time_count] </span>= read 6 bits as unsigned integer and add one 3897 </li> 3898 <li 3899 class="enumerate" id="x1-66004x2">read <span 3900class="cmtt-12">[vorbis_time_count] </span>16 bit values; each value should be zero. If any value is 3901 nonzero, this is an error condition and the stream is undecodable.</li></ol> 3902<!--l. 133--><p class="noindent" ><span class="paragraphHead"><a 3903 id="x1-670004.2.4"></a><span 3904class="cmbx-12">Floors</span></span> 3905Vorbis uses two floor types; header decode is handed to the decode abstraction of the appropriate 3906type. 3907<!--l. 138--><p class="noindent" > 3908 <ol class="enumerate1" > 3909 <li 3910 class="enumerate" id="x1-67002x1"><span 3911class="cmtt-12">[vorbis_floor_count] </span>= read 6 bits as unsigned integer and add one 3912 </li> 3913 <li 3914 class="enumerate" id="x1-67004x2">For each <span 3915class="cmtt-12">[i] </span>of <span 3916class="cmtt-12">[vorbis_floor_count] </span>floor numbers: 3917 <ol class="enumerate2" > 3918 <li 3919 class="enumerate" id="x1-67006x1">read the floor type: vector <span 3920class="cmtt-12">[vorbis_floor_types] </span>element <span 3921class="cmtt-12">[i] </span>= read 16 bits 3922 as unsigned integer 3923 </li> 3924 <li 3925 class="enumerate" id="x1-67008x2">If the floor type is zero, decode the floor configuration as defined in <a 3926href="#x1-890006">Section 6</a>, 3927 “<a 3928href="#x1-890006">Floor type 0 setup and decode<!--tex4ht:ref: vorbis:spec:floor0 --></a>”; save this configuration in slot <span 3929class="cmtt-12">[i] </span>of the floor 3930 configuration array <span 3931class="cmtt-12">[vorbis_floor_configurations]</span>. 3932 3933 3934 3935 </li> 3936 <li 3937 class="enumerate" id="x1-67010x3">If the floor type is one, decode the floor configuration as defined in <a 3938href="#x1-950007">Section 7</a>, 3939 “<a 3940href="#x1-950007">Floor type 1 setup and decode<!--tex4ht:ref: vorbis:spec:floor1 --></a>”; save this configuration in slot <span 3941class="cmtt-12">[i] </span>of the floor 3942 configuration array <span 3943class="cmtt-12">[vorbis_floor_configurations]</span>. 3944 </li> 3945 <li 3946 class="enumerate" id="x1-67012x4">If the the floor type is greater than one, this stream is undecodable; ERROR 3947 CONDITION</li></ol> 3948 </li></ol> 3949<!--l. 157--><p class="noindent" ><span class="paragraphHead"><a 3950 id="x1-680004.2.4"></a><span 3951class="cmbx-12">Residues</span></span> 3952Vorbis uses three residue types; header decode of each type is identical. 3953<!--l. 162--><p class="noindent" > 3954 <ol class="enumerate1" > 3955 <li 3956 class="enumerate" id="x1-68002x1"><span 3957class="cmtt-12">[vorbis_residue_count] </span>= read 6 bits as unsigned integer and add one 3958 </li> 3959 <li 3960 class="enumerate" id="x1-68004x2">For each of <span 3961class="cmtt-12">[vorbis_residue_count] </span>residue numbers: 3962 <ol class="enumerate2" > 3963 <li 3964 class="enumerate" id="x1-68006x1">read the residue type; vector <span 3965class="cmtt-12">[vorbis_residue_types] </span>element <span 3966class="cmtt-12">[i] </span>= read 16 3967 bits as unsigned integer 3968 </li> 3969 <li 3970 class="enumerate" id="x1-68008x2">If the residue type is zero, one or two, decode the residue configuration as defined 3971 in <a 3972href="#x1-1020008">Section 8</a>, “<a 3973href="#x1-1020008">Residue setup and decode<!--tex4ht:ref: vorbis:spec:residue --></a>”; save this configuration in slot <span 3974class="cmtt-12">[i] </span>of 3975 the residue configuration array <span 3976class="cmtt-12">[vorbis_residue_configurations]</span>. 3977 </li> 3978 <li 3979 class="enumerate" id="x1-68010x3">If the the residue type is greater than two, this stream is undecodable; ERROR 3980 CONDITION</li></ol> 3981 </li></ol> 3982<!--l. 177--><p class="noindent" ><span class="paragraphHead"><a 3983 id="x1-690004.2.4"></a><span 3984class="cmbx-12">Mappings</span></span> 3985Mappings are used to set up specific pipelines for encoding multichannel audio with varying 3986channel mapping applications. Vorbis I uses a single mapping type (0), with implicit PCM 3987channel mappings. 3988 3989 3990 3991<!--l. 187--><p class="noindent" > 3992 <ol class="enumerate1" > 3993 <li 3994 class="enumerate" id="x1-69002x1"><span 3995class="cmtt-12">[vorbis_mapping_count] </span>= read 6 bits as unsigned integer and add one 3996 </li> 3997 <li 3998 class="enumerate" id="x1-69004x2">For each <span 3999class="cmtt-12">[i] </span>of <span 4000class="cmtt-12">[vorbis_mapping_count] </span>mapping numbers: 4001 <ol class="enumerate2" > 4002 <li 4003 class="enumerate" id="x1-69006x1">read the mapping type: 16 bits as unsigned integer. There’s no reason to save 4004 the mapping type in Vorbis I. 4005 </li> 4006 <li 4007 class="enumerate" id="x1-69008x2">If the mapping type is nonzero, the stream is undecodable 4008 </li> 4009 <li 4010 class="enumerate" id="x1-69010x3">If the mapping type is zero: 4011 <ol class="enumerate3" > 4012 <li 4013 class="enumerate" id="x1-69012x1">read 1 bit as a boolean flag 4014 <ol class="enumerate4" > 4015 <li 4016 class="enumerate" id="x1-69014x1">if set, <span 4017class="cmtt-12">[vorbis_mapping_submaps] </span>= read 4 bits as unsigned integer 4018 and add one 4019 </li> 4020 <li 4021 class="enumerate" id="x1-69016x2">if unset, <span 4022class="cmtt-12">[vorbis_mapping_submaps] </span>= 1</li></ol> 4023 </li> 4024 <li 4025 class="enumerate" id="x1-69018x2">read 1 bit as a boolean flag 4026 <ol class="enumerate4" > 4027 <li 4028 class="enumerate" id="x1-69020x1">if set, square polar channel mapping is in use: 4029 <ul class="itemize1"> 4030 <li class="itemize"><span 4031class="cmtt-12">[vorbis_mapping_coupling_steps] </span>= read 8 bits as unsigned 4032 integer and add one 4033 </li> 4034 <li class="itemize">for <span 4035class="cmtt-12">[j] </span>each of <span 4036class="cmtt-12">[vorbis_mapping_coupling_steps] </span>steps: 4037 <ul class="itemize2"> 4038 <li class="itemize">vector <span 4039class="cmtt-12">[vorbis_mapping_magnitude] </span>element <span 4040class="cmtt-12">[j]</span>= read 4041 <a 4042href="#x1-1170009.2.1">ilog</a>(<span 4043class="cmtt-12">[audio_channels] </span>- 1) bits as unsigned integer 4044 </li> 4045 <li class="itemize">vector <span 4046class="cmtt-12">[vorbis_mapping_angle] </span>element <span 4047class="cmtt-12">[j]</span>= read 4048 <a 4049href="#x1-1170009.2.1">ilog</a>(<span 4050class="cmtt-12">[audio_channels] </span>- 1) bits as unsigned integer 4051 </li> 4052 4053 4054 4055 <li class="itemize">the numbers read in the above two steps are channel numbers 4056 representing the channel to treat as magnitude and the channel 4057 to treat as angle, respectively. If for any coupling step the 4058 angle channel number equals the magnitude channel number, the 4059 magnitude channel number is greater than <span 4060class="cmtt-12">[audio_channels]</span>-1, or 4061 the angle channel is greater than <span 4062class="cmtt-12">[audio_channels]</span>-1, the stream 4063 is undecodable.</li></ul> 4064 </li></ul> 4065 </li> 4066 <li 4067 class="enumerate" id="x1-69022x2">if unset, <span 4068class="cmtt-12">[vorbis_mapping_coupling_steps] </span>= 0</li></ol> 4069 </li> 4070 <li 4071 class="enumerate" id="x1-69024x3">read 2 bits (reserved field); if the value is nonzero, the stream is undecodable 4072 </li> 4073 <li 4074 class="enumerate" id="x1-69026x4">if <span 4075class="cmtt-12">[vorbis_mapping_submaps] </span>is greater than one, we read channel multiplex 4076 settings. For each <span 4077class="cmtt-12">[j] </span>of <span 4078class="cmtt-12">[audio_channels] </span>channels: 4079 <ol class="enumerate4" > 4080 <li 4081 class="enumerate" id="x1-69028x1">vector <span 4082class="cmtt-12">[vorbis_mapping_mux] </span>element <span 4083class="cmtt-12">[j] </span>= read 4 bits as unsigned 4084 integer 4085 </li> 4086 <li 4087 class="enumerate" id="x1-69030x2">if the value is greater than the highest numbered submap 4088 (<span 4089class="cmtt-12">[vorbis_mapping_submaps] </span>- 1), this in an error condition rendering 4090 the stream undecodable</li></ol> 4091 </li> 4092 <li 4093 class="enumerate" id="x1-69032x5">for each submap <span 4094class="cmtt-12">[j] </span>of <span 4095class="cmtt-12">[vorbis_mapping_submaps] </span>submaps, read the floor and 4096 residue numbers for use in decoding that submap: 4097 <ol class="enumerate4" > 4098 <li 4099 class="enumerate" id="x1-69034x1">read and discard 8 bits (the unused time configuration placeholder) 4100 </li> 4101 <li 4102 class="enumerate" id="x1-69036x2">read 8 bits as unsigned integer for the floor number; save in vector 4103 <span 4104class="cmtt-12">[vorbis_mapping_submap_floor] </span>element <span 4105class="cmtt-12">[j]</span> 4106 </li> 4107 <li 4108 class="enumerate" id="x1-69038x3">verify the floor number is not greater than the highest number floor 4109 configured for the bitstream. If it is, the bitstream is undecodable 4110 </li> 4111 <li 4112 class="enumerate" id="x1-69040x4">read 8 bits as unsigned integer for the residue number; save in vector 4113 <span 4114class="cmtt-12">[vorbis_mapping_submap_residue] </span>element <span 4115class="cmtt-12">[j]</span> 4116 4117 4118 4119 </li> 4120 <li 4121 class="enumerate" id="x1-69042x5">verify the residue number is not greater than the highest number residue 4122 configured for the bitstream. If it is, the bitstream is undecodable</li></ol> 4123 </li> 4124 <li 4125 class="enumerate" id="x1-69044x6">save this mapping configuration in slot <span 4126class="cmtt-12">[i] </span>of the mapping configuration array 4127 <span 4128class="cmtt-12">[vorbis_mapping_configurations]</span>.</li></ol> 4129 </li></ol> 4130 </li></ol> 4131<!--l. 247--><p class="noindent" ><span class="paragraphHead"><a 4132 id="x1-700004.2.4"></a><span 4133class="cmbx-12">Modes</span></span> 4134 <ol class="enumerate1" > 4135 <li 4136 class="enumerate" id="x1-70002x1"><span 4137class="cmtt-12">[vorbis_mode_count] </span>= read 6 bits as unsigned integer and add one 4138 </li> 4139 <li 4140 class="enumerate" id="x1-70004x2">For each of <span 4141class="cmtt-12">[vorbis_mode_count] </span>mode numbers: 4142 <ol class="enumerate2" > 4143 <li 4144 class="enumerate" id="x1-70006x1"><span 4145class="cmtt-12">[vorbis_mode_blockflag] </span>= read 1 bit 4146 </li> 4147 <li 4148 class="enumerate" id="x1-70008x2"><span 4149class="cmtt-12">[vorbis_mode_windowtype] </span>= read 16 bits as unsigned integer 4150 </li> 4151 <li 4152 class="enumerate" id="x1-70010x3"><span 4153class="cmtt-12">[vorbis_mode_transformtype] </span>= read 16 bits as unsigned integer 4154 </li> 4155 <li 4156 class="enumerate" id="x1-70012x4"><span 4157class="cmtt-12">[vorbis_mode_mapping] </span>= read 8 bits as unsigned integer 4158 </li> 4159 <li 4160 class="enumerate" id="x1-70014x5">verify ranges; zero is the only legal value in 4161 Vorbis I for <span 4162class="cmtt-12">[vorbis_mode_windowtype] </span>and <span 4163class="cmtt-12">[vorbis_mode_transformtype]</span>. 4164 <span 4165class="cmtt-12">[vorbis_mode_mapping] </span>must not be greater than the highest number mapping 4166 in use. Any illegal values render the stream undecodable. 4167 </li> 4168 <li 4169 class="enumerate" id="x1-70016x6">save this mode configuration in slot <span 4170class="cmtt-12">[i] </span>of the mode configuration array 4171 <span 4172class="cmtt-12">[vorbis_mode_configurations]</span>.</li></ol> 4173 </li> 4174 <li 4175 class="enumerate" id="x1-70018x3">read 1 bit as a framing flag. If unset, a framing error occurred and the stream is not 4176 decodable.</li></ol> 4177 4178 4179 4180<!--l. 268--><p class="noindent" >After reading mode descriptions, setup header decode is complete. 4181<!--l. 277--><p class="noindent" > 4182<h4 class="subsectionHead"><span class="titlemark">4.3 </span> <a 4183 id="x1-710004.3"></a>Audio packet decode and synthesis</h4> 4184<!--l. 279--><p class="noindent" >Following the three header packets, all packets in a Vorbis I stream are audio. The first step of 4185audio packet decode is to read and verify the packet type. <span 4186class="cmti-12">A non-audio packet when audio is</span> 4187<span 4188class="cmti-12">expected indicates stream corruption or a non-compliant stream. The decoder must ignore the</span> 4189<span 4190class="cmti-12">packet and not attempt decoding it to audio</span>. 4191<!--l. 286--><p class="noindent" > 4192<h5 class="subsubsectionHead"><span class="titlemark">4.3.1 </span> <a 4193 id="x1-720004.3.1"></a>packet type, mode and window decode</h5> 4194<!--l. 288--><p class="noindent" > 4195 <ol class="enumerate1" > 4196 <li 4197 class="enumerate" id="x1-72002x1">read 1 bit <span 4198class="cmtt-12">[packet_type]</span>; check that packet type is 0 (audio) 4199 </li> 4200 <li 4201 class="enumerate" id="x1-72004x2">read <a 4202href="#x1-1170009.2.1">ilog</a>([vorbis˙mode˙count]-1) bits <span 4203class="cmtt-12">[mode_number]</span> 4204 </li> 4205 <li 4206 class="enumerate" id="x1-72006x3">decode blocksize <span 4207class="cmtt-12">[n] </span>is equal to <span 4208class="cmtt-12">[blocksize_0] </span>if <span 4209class="cmtt-12">[vorbis_mode_blockflag] </span>is 0, 4210 else <span 4211class="cmtt-12">[n] </span>is equal to <span 4212class="cmtt-12">[blocksize_1]</span>. 4213 </li> 4214 <li 4215 class="enumerate" id="x1-72008x4">perform window selection and setup; this window is used later by the inverse 4216 MDCT: 4217 <ol class="enumerate2" > 4218 <li 4219 class="enumerate" id="x1-72010x1">if this is a long window (the <span 4220class="cmtt-12">[vorbis_mode_blockflag] </span>flag of this mode is 4221 set): 4222 <ol class="enumerate3" > 4223 <li 4224 class="enumerate" id="x1-72012x1">read 1 bit for <span 4225class="cmtt-12">[previous_window_flag]</span> 4226 </li> 4227 <li 4228 class="enumerate" id="x1-72014x2">read 1 bit for <span 4229class="cmtt-12">[next_window_flag]</span> 4230 4231 4232 4233 </li> 4234 <li 4235 class="enumerate" id="x1-72016x3">if <span 4236class="cmtt-12">[previous_window_flag] </span>is not set, the left half of the window will 4237 be a hybrid window for lapping with a short block. See <a 4238href="#paragraph.1" >paragraph <a 4239href="#x1-260001.3.2">1.3.2</a></a>, 4240 “<a 4241href="#x1-260001.3.2">Window shape decode (long windows only)<!--tex4ht:ref: vorbis:spec:window --></a>” for an illustration of 4242 overlapping dissimilar windows. Else, the left half window will have normal 4243 long shape. 4244 </li> 4245 <li 4246 class="enumerate" id="x1-72018x4">if <span 4247class="cmtt-12">[next_window_flag] </span>is not set, the right half of the window will be 4248 a hybrid window for lapping with a short block. See <a 4249href="#x1-260001.3.2">paragraph 1.3.2</a>, 4250 “<a 4251href="#x1-260001.3.2">Window shape decode (long windows only)<!--tex4ht:ref: vorbis:spec:window --></a>” for an illustration of 4252 overlapping dissimilar windows. Else, the left right window will have normal 4253 long shape.</li></ol> 4254 </li> 4255 <li 4256 class="enumerate" id="x1-72020x2">if this is a short window, the window is always the same short-window 4257 shape.</li></ol> 4258 </li></ol> 4259<!--l. 321--><p class="noindent" >Vorbis windows all use the slope function <span 4260class="cmmi-12">y </span>= sin(<img 4261src="Vorbis_I_spec1x.png" alt="π2" class="frac" align="middle"> <span 4262class="cmsy-10x-x-120">∗</span> sin <sup><span 4263class="cmr-8">2</span></sup>((<span 4264class="cmmi-12">x </span>+ 0<span 4265class="cmmi-12">.</span>5)<span 4266class="cmmi-12">∕n </span><span 4267class="cmsy-10x-x-120">∗ </span><span 4268class="cmmi-12">π</span>)), where <span 4269class="cmmi-12">n </span>is window 4270size and <span 4271class="cmmi-12">x </span>ranges 0<span 4272class="cmmi-12">…</span><span 4273class="cmmi-12">n</span><span 4274class="cmsy-10x-x-120">− </span>1, but dissimilar lapping requirements can affect overall shape. Window 4275generation proceeds as follows: 4276<!--l. 326--><p class="noindent" > 4277 <ol class="enumerate1" > 4278 <li 4279 class="enumerate" id="x1-72022x1"><span 4280class="cmtt-12">[window_center] </span>= <span 4281class="cmtt-12">[n] </span>/ 2 4282 </li> 4283 <li 4284 class="enumerate" id="x1-72024x2">if (<span 4285class="cmtt-12">[vorbis_mode_blockflag] </span>is set and <span 4286class="cmtt-12">[previous_window_flag] </span>is not set) 4287 then 4288 <ol class="enumerate2" > 4289 <li 4290 class="enumerate" id="x1-72026x1"><span 4291class="cmtt-12">[left_window_start] </span>= <span 4292class="cmtt-12">[n]</span>/4 - <span 4293class="cmtt-12">[blocksize_0]</span>/4 4294 </li> 4295 <li 4296 class="enumerate" id="x1-72028x2"><span 4297class="cmtt-12">[left_window_end] </span>= <span 4298class="cmtt-12">[n]</span>/4 + <span 4299class="cmtt-12">[blocksize_0]</span>/4 4300 </li> 4301 <li 4302 class="enumerate" id="x1-72030x3"><span 4303class="cmtt-12">[left_n] </span>= <span 4304class="cmtt-12">[blocksize_0]</span>/2</li></ol> 4305 <!--l. 336--><p class="noindent" >else 4306 <ol class="enumerate2" > 4307 <li 4308 class="enumerate" id="x1-72032x1"><span 4309class="cmtt-12">[left_window_start] </span>= 0 4310 </li> 4311 <li 4312 class="enumerate" id="x1-72034x2"><span 4313class="cmtt-12">[left_window_end] </span>= <span 4314class="cmtt-12">[window_center]</span> 4315 4316 4317 4318 </li> 4319 <li 4320 class="enumerate" id="x1-72036x3"><span 4321class="cmtt-12">[left_n] </span>= <span 4322class="cmtt-12">[n]</span>/2</li></ol> 4323 </li> 4324 <li 4325 class="enumerate" id="x1-72038x3">if (<span 4326class="cmtt-12">[vorbis_mode_blockflag] </span>is set and <span 4327class="cmtt-12">[next_window_flag] </span>is not set) then 4328 <ol class="enumerate2" > 4329 <li 4330 class="enumerate" id="x1-72040x1"><span 4331class="cmtt-12">[right_window_start] </span>= <span 4332class="cmtt-12">[n]*3</span>/4 - <span 4333class="cmtt-12">[blocksize_0]</span>/4 4334 </li> 4335 <li 4336 class="enumerate" id="x1-72042x2"><span 4337class="cmtt-12">[right_window_end] </span>= <span 4338class="cmtt-12">[n]*3</span>/4 + <span 4339class="cmtt-12">[blocksize_0]</span>/4 4340 </li> 4341 <li 4342 class="enumerate" id="x1-72044x3"><span 4343class="cmtt-12">[right_n] </span>= <span 4344class="cmtt-12">[blocksize_0]</span>/2</li></ol> 4345 <!--l. 352--><p class="noindent" >else 4346 <ol class="enumerate2" > 4347 <li 4348 class="enumerate" id="x1-72046x1"><span 4349class="cmtt-12">[right_window_start] </span>= <span 4350class="cmtt-12">[window_center]</span> 4351 </li> 4352 <li 4353 class="enumerate" id="x1-72048x2"><span 4354class="cmtt-12">[right_window_end] </span>= <span 4355class="cmtt-12">[n]</span> 4356 </li> 4357 <li 4358 class="enumerate" id="x1-72050x3"><span 4359class="cmtt-12">[right_n] </span>= <span 4360class="cmtt-12">[n]</span>/2</li></ol> 4361 </li> 4362 <li 4363 class="enumerate" id="x1-72052x4">window from range 0 ... <span 4364class="cmtt-12">[left_window_start]</span>-1 inclusive is zero 4365 </li> 4366 <li 4367 class="enumerate" id="x1-72054x5">for <span 4368class="cmtt-12">[i] </span>in range <span 4369class="cmtt-12">[left_window_start] </span>... <span 4370class="cmtt-12">[left_window_end]</span>-1, window(<span 4371class="cmtt-12">[i]</span>) = 4372 sin(<img 4373src="Vorbis_I_spec2x.png" alt="π 43742" class="frac" align="middle"> <span 4375class="cmsy-10x-x-120">∗</span> sin <sup><span 4376class="cmr-8">2</span></sup>( (<span 4377class="cmtt-12">[i]</span>-<span 4378class="cmtt-12">[left_window_start]</span>+0.5) / <span 4379class="cmtt-12">[left_n] </span><span 4380class="cmsy-10x-x-120">∗</span><img 4381src="Vorbis_I_spec3x.png" alt="π 43822" class="frac" align="middle">) ) 4383 </li> 4384 <li 4385 class="enumerate" id="x1-72056x6">window from range <span 4386class="cmtt-12">[left_window_end] </span>... <span 4387class="cmtt-12">[right_window_start]</span>-1 inclusive is 4388 one 4389 </li> 4390 <li 4391 class="enumerate" id="x1-72058x7">for <span 4392class="cmtt-12">[i] </span>in range <span 4393class="cmtt-12">[right_window_start] </span>... <span 4394class="cmtt-12">[right_window_end]</span>-1, window(<span 4395class="cmtt-12">[i]</span>) = 4396 sin(<img 4397src="Vorbis_I_spec4x.png" alt="π 43982" class="frac" align="middle"> <span 4399class="cmsy-10x-x-120">∗</span> sin <sup><span 4400class="cmr-8">2</span></sup>( (<span 4401class="cmtt-12">[i]</span>-<span 4402class="cmtt-12">[right_window_start]</span>+0.5) / <span 4403class="cmtt-12">[right_n] </span><span 4404class="cmsy-10x-x-120">∗</span><img 4405src="Vorbis_I_spec5x.png" alt="π 44062" class="frac" align="middle"> + <img 4407src="Vorbis_I_spec6x.png" alt="π 44082" class="frac" align="middle">) ) 4409 </li> 4410 <li 4411 class="enumerate" id="x1-72060x8">window from range <span 4412class="cmtt-12">[right_window_start] </span>... <span 4413class="cmtt-12">[n]</span>-1 is zero</li></ol> 4414<!--l. 368--><p class="noindent" >An end-of-packet condition up to this point should be considered an error that discards this 4415packet from the stream. An end of packet condition past this point is to be considered a possible 4416nominal occurrence. 4417 4418 4419 4420<!--l. 375--><p class="noindent" > 4421<h5 class="subsubsectionHead"><span class="titlemark">4.3.2 </span> <a 4422 id="x1-730004.3.2"></a>floor curve decode</h5> 4423<!--l. 377--><p class="noindent" >From this point on, we assume out decode context is using mode number <span 4424class="cmtt-12">[mode_number]</span> 4425from configuration array <span 4426class="cmtt-12">[vorbis_mode_configurations] </span>and the map number 4427<span 4428class="cmtt-12">[vorbis_mode_mapping] </span>(specified by the current mode) taken from the mapping configuration 4429array <span 4430class="cmtt-12">[vorbis_mapping_configurations]</span>. 4431<!--l. 384--><p class="noindent" >Floor curves are decoded one-by-one in channel order. 4432<!--l. 386--><p class="noindent" >For each floor <span 4433class="cmtt-12">[i] </span>of <span 4434class="cmtt-12">[audio_channels]</span> 4435 <ol class="enumerate1" > 4436 <li 4437 class="enumerate" id="x1-73002x1"><span 4438class="cmtt-12">[submap_number] </span>= element <span 4439class="cmtt-12">[i] </span>of vector [vorbis˙mapping˙mux] 4440 </li> 4441 <li 4442 class="enumerate" id="x1-73004x2"><span 4443class="cmtt-12">[floor_number] </span>= element <span 4444class="cmtt-12">[submap_number] </span>of vector [vorbis˙submap˙floor] 4445 </li> 4446 <li 4447 class="enumerate" id="x1-73006x3">if the floor type of this floor (vector 4448 <span 4449class="cmtt-12">[vorbis_floor_types] </span>element <span 4450class="cmtt-12">[floor_number]</span>) is zero then decode the floor for 4451 channel <span 4452class="cmtt-12">[i] </span>according to the <a 4453href="#x1-930006.2.2">subsubsection 6.2.2</a>, “<a 4454href="#x1-930006.2.2">packet decode<!--tex4ht:ref: vorbis:spec:floor0-decode --></a>” 4455 </li> 4456 <li 4457 class="enumerate" id="x1-73008x4">if the type of this floor is one then decode the floor for channel <span 4458class="cmtt-12">[i] </span>according to the 4459 <a 4460href="#x1-1000007.2.2">paragraph 7.2.2</a>, “<a 4461href="#x1-1000007.2.2">packet decode<!--tex4ht:ref: vorbis:spec:floor1-decode --></a>” 4462 </li> 4463 <li 4464 class="enumerate" id="x1-73010x5">save the needed decoded floor information for channel for later synthesis 4465 </li> 4466 <li 4467 class="enumerate" id="x1-73012x6">if the decoded floor returned ’unused’, set vector <span 4468class="cmtt-12">[no_residue] </span>element <span 4469class="cmtt-12">[i] </span>to true, 4470 else set vector <span 4471class="cmtt-12">[no_residue] </span>element <span 4472class="cmtt-12">[i] </span>to false</li></ol> 4473<!--l. 406--><p class="noindent" >An end-of-packet condition during floor decode shall result in packet decode zeroing all channel 4474output vectors and skipping to the add/overlap output stage. 4475<!--l. 412--><p class="noindent" > 4476<h5 class="subsubsectionHead"><span class="titlemark">4.3.3 </span> <a 4477 id="x1-740004.3.3"></a>nonzero vector propagate</h5> 4478<!--l. 414--><p class="noindent" >A possible result of floor decode is that a specific vector is marked ’unused’ which indicates that 4479that final output vector is all-zero values (and the floor is zero). The residue for that vector is not 4480coded in the stream, save for one complication. If some vectors are used and some are not, 4481 4482 4483 4484channel coupling could result in mixing a zeroed and nonzeroed vector to produce two nonzeroed 4485vectors. 4486<!--l. 421--><p class="noindent" >for each <span 4487class="cmtt-12">[i] </span>from 0 ... <span 4488class="cmtt-12">[vorbis_mapping_coupling_steps]</span>-1 4489<!--l. 423--><p class="noindent" > 4490 <ol class="enumerate1" > 4491 <li 4492 class="enumerate" id="x1-74002x1">if either <span 4493class="cmtt-12">[no_residue] </span>entry for channel (<span 4494class="cmtt-12">[vorbis_mapping_magnitude] </span>element 4495 <span 4496class="cmtt-12">[i]</span>) or channel (<span 4497class="cmtt-12">[vorbis_mapping_angle] </span>element <span 4498class="cmtt-12">[i]</span>) are set to false, then both 4499 must be set to false. Note that an ’unused’ floor has no decoded floor information; it 4500 is important that this is remembered at floor curve synthesis time.</li></ol> 4501<!--l. 436--><p class="noindent" > 4502<h5 class="subsubsectionHead"><span class="titlemark">4.3.4 </span> <a 4503 id="x1-750004.3.4"></a>residue decode</h5> 4504<!--l. 438--><p class="noindent" >Unlike floors, which are decoded in channel order, the residue vectors are decoded in submap 4505order. 4506<!--l. 441--><p class="noindent" >for each submap <span 4507class="cmtt-12">[i] </span>in order from 0 ... <span 4508class="cmtt-12">[vorbis_mapping_submaps]</span>-1 4509<!--l. 443--><p class="noindent" > 4510 <ol class="enumerate1" > 4511 <li 4512 class="enumerate" id="x1-75002x1"><span 4513class="cmtt-12">[ch] </span>= 0 4514 </li> 4515 <li 4516 class="enumerate" id="x1-75004x2">for each channel <span 4517class="cmtt-12">[j] </span>in order from 0 ... <span 4518class="cmtt-12">[audio_channels] </span>- 1 4519 <ol class="enumerate2" > 4520 <li 4521 class="enumerate" id="x1-75006x1">if channel <span 4522class="cmtt-12">[j] </span>in submap <span 4523class="cmtt-12">[i] </span>(vector <span 4524class="cmtt-12">[vorbis_mapping_mux] </span>element <span 4525class="cmtt-12">[j] </span>is equal to 4526 <span 4527class="cmtt-12">[i]</span>) 4528 <ol class="enumerate3" > 4529 <li 4530 class="enumerate" id="x1-75008x1">if vector <span 4531class="cmtt-12">[no_residue] </span>element <span 4532class="cmtt-12">[j] </span>is true 4533 <ol class="enumerate4" > 4534 <li 4535 class="enumerate" id="x1-75010x1">vector <span 4536class="cmtt-12">[do_not_decode_flag] </span>element <span 4537class="cmtt-12">[ch] </span>is set</li></ol> 4538 <!--l. 453--><p class="noindent" >else 4539 <ol class="enumerate4" > 4540 <li 4541 class="enumerate" id="x1-75012x1">vector <span 4542class="cmtt-12">[do_not_decode_flag] </span>element <span 4543class="cmtt-12">[ch] </span>is unset</li></ol> 4544 </li> 4545 <li 4546 class="enumerate" id="x1-75014x2">increment <span 4547class="cmtt-12">[ch]</span></li></ol> 4548 4549 4550 4551 </li></ol> 4552 </li> 4553 <li 4554 class="enumerate" id="x1-75016x3"><span 4555class="cmtt-12">[residue_number] </span>= vector <span 4556class="cmtt-12">[vorbis_mapping_submap_residue] </span>element <span 4557class="cmtt-12">[i]</span> 4558 </li> 4559 <li 4560 class="enumerate" id="x1-75018x4"><span 4561class="cmtt-12">[residue_type] </span>= vector <span 4562class="cmtt-12">[vorbis_residue_types] </span>element <span 4563class="cmtt-12">[residue_number]</span> 4564 </li> 4565 <li 4566 class="enumerate" id="x1-75020x5">decode <span 4567class="cmtt-12">[ch] </span>vectors using residue <span 4568class="cmtt-12">[residue_number]</span>, according to type <span 4569class="cmtt-12">[residue_type]</span>, 4570 also passing vector <span 4571class="cmtt-12">[do_not_decode_flag] </span>to indicate which vectors in the bundle should 4572 not be decoded. Correct per-vector decode length is <span 4573class="cmtt-12">[n]</span>/2. 4574 </li> 4575 <li 4576 class="enumerate" id="x1-75022x6"><span 4577class="cmtt-12">[ch] </span>= 0 4578 </li> 4579 <li 4580 class="enumerate" id="x1-75024x7">for each channel <span 4581class="cmtt-12">[j] </span>in order from 0 ... <span 4582class="cmtt-12">[audio_channels]</span> 4583 <ol class="enumerate2" > 4584 <li 4585 class="enumerate" id="x1-75026x1">if channel <span 4586class="cmtt-12">[j] </span>is in submap <span 4587class="cmtt-12">[i] </span>(vector <span 4588class="cmtt-12">[vorbis_mapping_mux] </span>element <span 4589class="cmtt-12">[j] </span>is equal 4590 to <span 4591class="cmtt-12">[i]</span>) 4592 <ol class="enumerate3" > 4593 <li 4594 class="enumerate" id="x1-75028x1">residue vector for channel <span 4595class="cmtt-12">[j] </span>is set to decoded residue vector <span 4596class="cmtt-12">[ch]</span> 4597 </li> 4598 <li 4599 class="enumerate" id="x1-75030x2">increment <span 4600class="cmtt-12">[ch]</span></li></ol> 4601 </li></ol> 4602 </li></ol> 4603<!--l. 480--><p class="noindent" > 4604<h5 class="subsubsectionHead"><span class="titlemark">4.3.5 </span> <a 4605 id="x1-760004.3.5"></a>inverse coupling</h5> 4606<!--l. 482--><p class="noindent" >for each <span 4607class="cmtt-12">[i] </span>from <span 4608class="cmtt-12">[vorbis_mapping_coupling_steps]</span>-1 descending to 0 4609<!--l. 484--><p class="noindent" > 4610 <ol class="enumerate1" > 4611 <li 4612 class="enumerate" id="x1-76002x1"><span 4613class="cmtt-12">[magnitude_vector] </span>= the residue vector for channel (vector 4614 <span 4615class="cmtt-12">[vorbis_mapping_magnitude] </span>element <span 4616class="cmtt-12">[i]</span>) 4617 </li> 4618 <li 4619 class="enumerate" id="x1-76004x2"><span 4620class="cmtt-12">[angle_vector] </span>= the residue vector for channel (vector <span 4621class="cmtt-12">[vorbis_mapping_angle]</span> 4622 4623 4624 4625 element <span 4626class="cmtt-12">[i]</span>) 4627 </li> 4628 <li 4629 class="enumerate" id="x1-76006x3">for each scalar value <span 4630class="cmtt-12">[M] </span>in vector <span 4631class="cmtt-12">[magnitude_vector] </span>and the corresponding scalar value 4632 <span 4633class="cmtt-12">[A] </span>in vector <span 4634class="cmtt-12">[angle_vector]</span>: 4635 <ol class="enumerate2" > 4636 <li 4637 class="enumerate" id="x1-76008x1">if (<span 4638class="cmtt-12">[M] </span>is greater than zero) 4639 <ol class="enumerate3" > 4640 <li 4641 class="enumerate" id="x1-76010x1">if (<span 4642class="cmtt-12">[A] </span>is greater than zero) 4643 <ol class="enumerate4" > 4644 <li 4645 class="enumerate" id="x1-76012x1"><span 4646class="cmtt-12">[new_M] </span>= <span 4647class="cmtt-12">[M]</span> 4648 </li> 4649 <li 4650 class="enumerate" id="x1-76014x2"><span 4651class="cmtt-12">[new_A] </span>= <span 4652class="cmtt-12">[M]</span>-<span 4653class="cmtt-12">[A]</span></li></ol> 4654 <!--l. 498--><p class="noindent" >else 4655 <ol class="enumerate4" > 4656 <li 4657 class="enumerate" id="x1-76016x1"><span 4658class="cmtt-12">[new_A] </span>= <span 4659class="cmtt-12">[M]</span> 4660 </li> 4661 <li 4662 class="enumerate" id="x1-76018x2"><span 4663class="cmtt-12">[new_M] </span>= <span 4664class="cmtt-12">[M]</span>+<span 4665class="cmtt-12">[A]</span></li></ol> 4666 </li></ol> 4667 <!--l. 505--><p class="noindent" >else 4668 <ol class="enumerate3" > 4669 <li 4670 class="enumerate" id="x1-76020x1">if (<span 4671class="cmtt-12">[A] </span>is greater than zero) 4672 <ol class="enumerate4" > 4673 <li 4674 class="enumerate" id="x1-76022x1"><span 4675class="cmtt-12">[new_M] </span>= <span 4676class="cmtt-12">[M]</span> 4677 </li> 4678 <li 4679 class="enumerate" id="x1-76024x2"><span 4680class="cmtt-12">[new_A] </span>= <span 4681class="cmtt-12">[M]</span>+<span 4682class="cmtt-12">[A]</span></li></ol> 4683 <!--l. 512--><p class="noindent" >else 4684 <ol class="enumerate4" > 4685 <li 4686 class="enumerate" id="x1-76026x1"><span 4687class="cmtt-12">[new_A] </span>= <span 4688class="cmtt-12">[M]</span> 4689 </li> 4690 <li 4691 class="enumerate" id="x1-76028x2"><span 4692class="cmtt-12">[new_M] </span>= <span 4693class="cmtt-12">[M]</span>-<span 4694class="cmtt-12">[A]</span></li></ol> 4695 </li></ol> 4696 </li> 4697 <li 4698 class="enumerate" id="x1-76030x2">set scalar value <span 4699class="cmtt-12">[M] </span>in vector <span 4700class="cmtt-12">[magnitude_vector] </span>to <span 4701class="cmtt-12">[new_M]</span> 4702 4703 4704 4705 </li> 4706 <li 4707 class="enumerate" id="x1-76032x3">set scalar value <span 4708class="cmtt-12">[A] </span>in vector <span 4709class="cmtt-12">[angle_vector] </span>to <span 4710class="cmtt-12">[new_A]</span></li></ol> 4711 </li></ol> 4712<!--l. 529--><p class="noindent" > 4713<h5 class="subsubsectionHead"><span class="titlemark">4.3.6 </span> <a 4714 id="x1-770004.3.6"></a>dot product</h5> 4715<!--l. 531--><p class="noindent" >For each channel, synthesize the floor curve from the decoded floor information, according to 4716packet type. Note that the vector synthesis length for floor computation is <span 4717class="cmtt-12">[n]</span>/2. 4718<!--l. 535--><p class="noindent" >For each channel, multiply each element of the floor curve by each element of that 4719channel’s residue vector. The result is the dot product of the floor and residue vectors for 4720each channel; the produced vectors are the length <span 4721class="cmtt-12">[n]</span>/2 audio spectrum for each 4722channel. 4723<!--l. 543--><p class="noindent" >One point is worth mentioning about this dot product; a common mistake in a fixed point 4724implementation might be to assume that a 32 bit fixed-point representation for floor and 4725residue and direct multiplication of the vectors is sufficient for acceptable spectral depth 4726in all cases because it happens to mostly work with the current Xiph.Org reference 4727encoder. 4728<!--l. 550--><p class="noindent" >However, floor vector values can span <span 4729class="cmsy-10x-x-120">∼</span>140dB (<span 4730class="cmsy-10x-x-120">∼</span>24 bits unsigned), and the audio spectrum 4731vector should represent a minimum of 120dB (<span 4732class="cmsy-10x-x-120">∼</span>21 bits with sign), even when output is to a 16 4733bit PCM device. For the residue vector to represent full scale if the floor is nailed 4734to <span 4735class="cmsy-10x-x-120">−</span>140dB, it must be able to span 0 to +140dB. For the residue vector to reach 4736full scale if the floor is nailed at 0dB, it must be able to represent <span 4737class="cmsy-10x-x-120">−</span>140dB to +0dB. 4738Thus, in order to handle full range dynamics, a residue vector may span <span 4739class="cmsy-10x-x-120">−</span>140dB to 4740+140dB entirely within spec. A 280dB range is approximately 48 bits with sign; thus the 4741residue vector must be able to represent a 48 bit range and the dot product must 4742be able to handle an effective 48 bit times 24 bit multiplication. This range may be 4743achieved using large (64 bit or larger) integers, or implementing a movable binary point 4744representation. 4745<!--l. 567--><p class="noindent" > 4746<h5 class="subsubsectionHead"><span class="titlemark">4.3.7 </span> <a 4747 id="x1-780004.3.7"></a>inverse MDCT</h5> 4748<!--l. 569--><p class="noindent" >Convert the audio spectrum vector of each channel back into time domain PCM audio via an 4749 4750 4751 4752inverse Modified Discrete Cosine Transform (MDCT). A detailed description of the MDCT is 4753available in <span class="cite">[<a 4754href="#XSporer/Brandenburg/Edler">1</a>]</span>. The window function used for the MDCT is the function described 4755earlier. 4756<!--l. 576--><p class="noindent" > 4757<h5 class="subsubsectionHead"><span class="titlemark">4.3.8 </span> <a 4758 id="x1-790004.3.8"></a>overlap˙add</h5> 4759<!--l. 578--><p class="noindent" >Windowed MDCT output is overlapped and added with the right hand data of the previous 4760window such that the 3/4 point of the previous window is aligned with the 1/4 point of the 4761current window (as illustrated in <a 4762href="#x1-260001.3.2">paragraph 1.3.2</a>, “<a 4763href="#x1-260001.3.2">Window shape decode (long windows 4764only)<!--tex4ht:ref: vorbis:spec:window --></a>”). The overlapped portion produced from overlapping the previous and current frame data 4765is finished data to be returned by the decoder. This data spans from the center of 4766the previous window to the center of the current window. In the case of same-sized 4767windows, the amount of data to return is one-half block consisting of and only of the 4768overlapped portions. When overlapping a short and long window, much of the returned 4769range does not actually overlap. This does not damage transform orthogonality. Pay 4770attention however to returning the correct data range; the amount of data to be returned 4771is: 4772<!--l. 592--><p class="noindent" > 4773<div class="fancyvrb" id="fancyvrb22"> 4774<a 4775 id="x1-79002r1"></a><span 4776class="cmr-6">1</span><span 4777class="cmtt-8"> </span><span 4778class="cmtt-8"> window_blocksize(previous_window)/4+window_blocksize(current_window)/4</span> 4779</div> 4780<!--l. 596--><p class="noindent" >from the center (element windowsize/2) of the previous window to the center (element 4781windowsize/2-1, inclusive) of the current window. 4782<!--l. 599--><p class="noindent" >Data is not returned from the first frame; it must be used to ’prime’ the decode engine. The 4783encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper 4784PCM output offset is ’0’ (as no data has been returned yet). 4785<!--l. 606--><p class="noindent" > 4786<h5 class="subsubsectionHead"><span class="titlemark">4.3.9 </span> <a 4787 id="x1-800004.3.9"></a>output channel order</h5> 4788<!--l. 608--><p class="noindent" >Vorbis I specifies only a channel mapping type 0. In mapping type 0, channel mapping is 4789implicitly defined as follows for standard audio applications. As of revision 16781 (20100113), the 4790specification adds defined channel locations for 6.1 and 7.1 surround. Ordering/location for 4791 4792 4793 4794greater-than-eight channels remains ’left to the implementation’. 4795<!--l. 614--><p class="noindent" >These channel orderings refer to order within the encoded stream. It is naturally possible for a 4796decoder to produce output with channels in any order. Any such decoder should explicitly 4797document channel reordering behavior. 4798<!--l. 619--><p class="noindent" > 4799 <dl class="description"><dt class="description"> 4800<span 4801class="cmssbx-10x-x-120">one channel</span> </dt><dd 4802class="description">the stream is monophonic 4803 </dd><dt class="description"> 4804<span 4805class="cmssbx-10x-x-120">two channels</span> </dt><dd 4806class="description">the stream is stereo. channel order: left, right 4807 </dd><dt class="description"> 4808<span 4809class="cmssbx-10x-x-120">three channels</span> </dt><dd 4810class="description">the stream is a 1d-surround encoding. channel order: left, center, right 4811 </dd><dt class="description"> 4812<span 4813class="cmssbx-10x-x-120">four channels</span> </dt><dd 4814class="description">the stream is quadraphonic surround. channel order: front left, front right, 4815 rear left, rear right 4816 </dd><dt class="description"> 4817<span 4818class="cmssbx-10x-x-120">five channels</span> </dt><dd 4819class="description">the stream is five-channel surround. channel order: front left, center, front 4820 right, rear left, rear right 4821 </dd><dt class="description"> 4822<span 4823class="cmssbx-10x-x-120">six channels</span> </dt><dd 4824class="description">the stream is 5.1 surround. channel order: front left, center, front right, rear 4825 left, rear right, LFE 4826 </dd><dt class="description"> 4827<span 4828class="cmssbx-10x-x-120">seven channels</span> </dt><dd 4829class="description">the stream is 6.1 surround. channel order: front left, center, front right, 4830 side left, side right, rear center, LFE 4831 </dd><dt class="description"> 4832<span 4833class="cmssbx-10x-x-120">eight channels</span> </dt><dd 4834class="description">the stream is 7.1 surround. channel order: front left, center, front right, 4835 side left, side right, rear left, rear right, LFE 4836 </dd><dt class="description"> 4837<span 4838class="cmssbx-10x-x-120">greater than eight channels</span> </dt><dd 4839class="description">channel use and order is defined by the application 4840 </dd></dl> 4841<!--l. 656--><p class="noindent" >Applications using Vorbis for dedicated purposes may define channel mapping as seen fit. Future 4842channel mappings (such as three and four channel <a 4843href="http://www.ambisonic.net/" >Ambisonics</a>) will make use of channel 4844mappings other than mapping 0. 4845 4846 4847 4848 4849 4850 4851<h3 class="sectionHead"><span class="titlemark">5 </span> <a 4852 id="x1-810005"></a>comment field and header specification</h3> 4853<!--l. 6--><p class="noindent" > 4854<h4 class="subsectionHead"><span class="titlemark">5.1 </span> <a 4855 id="x1-820005.1"></a>Overview</h4> 4856<!--l. 8--><p class="noindent" >The Vorbis text comment header is the second (of three) header packets that begin a Vorbis 4857bitstream. It is meant for short text comments, not arbitrary metadata; arbitrary metadata 4858belongs in a separate logical bitstream (usually an XML stream type) that provides greater 4859structure and machine parseability. 4860<!--l. 14--><p class="noindent" >The comment field is meant to be used much like someone jotting a quick note on the bottom of 4861a CDR. It should be a little information to remember the disc by and explain it to others; a 4862short, to-the-point text note that need not only be a couple words, but isn’t going to be more 4863than a short paragraph. The essentials, in other words, whatever they turn out to be, 4864eg: 4865<!--l. 21--><p class="noindent" > 4866 <div class="quote"> 4867 <!--l. 22--><p class="noindent" >Honest Bob and the Factory-to-Dealer-Incentives, <span 4868class="cmti-12">“I’m Still Around”</span>, opening 4869 for Moxy Fr�vous, 1997.</div> 4870<!--l. 29--><p class="noindent" > 4871<h4 class="subsectionHead"><span class="titlemark">5.2 </span> <a 4872 id="x1-830005.2"></a>Comment encoding</h4> 4873<!--l. 31--><p class="noindent" > 4874<h5 class="subsubsectionHead"><span class="titlemark">5.2.1 </span> <a 4875 id="x1-840005.2.1"></a>Structure</h5> 4876<!--l. 33--><p class="noindent" >The comment header is logically a list of eight-bit-clean vectors; the number of vectors is 4877bounded to 2<sup><span 4878class="cmr-8">32</span></sup> <span 4879class="cmsy-10x-x-120">− </span>1 and the length of each vector is limited to 2<sup><span 4880class="cmr-8">32</span></sup> <span 4881class="cmsy-10x-x-120">− </span>1 bytes. The vector length is 4882 4883 4884 4885encoded; the vector contents themselves are not null terminated. In addition to the vector list, 4886there is a single vector for vendor name (also 8 bit clean, length encoded in 32 bits). For 4887example, the 1.0 release of libvorbis set the vendor string to “Xiph.Org libVorbis I 488820020717”. 4889<!--l. 41--><p class="noindent" >The vector lengths and number of vectors are stored lsb first, according to the bit 4890packing conventions of the vorbis codec. However, since data in the comment header 4891is octet-aligned, they can simply be read as unaligned 32 bit little endian unsigned 4892integers. 4893<!--l. 46--><p class="noindent" >The comment header is decoded as follows: 4894<!--l. 48--><p class="noindent" > 4895<div class="fancyvrb" id="fancyvrb23"> 4896<a 4897 id="x1-84002r1"></a><span 4898class="cmr-6">1</span><span 4899class="cmtt-8"> </span><span 4900class="cmtt-8"> </span><span 4901class="cmtt-8"> </span><span 4902class="cmtt-8"> 1)</span><span 4903class="cmtt-8"> [vendor_length]</span><span 4904class="cmtt-8"> =</span><span 4905class="cmtt-8"> read</span><span 4906class="cmtt-8"> an</span><span 4907class="cmtt-8"> unsigned</span><span 4908class="cmtt-8"> integer</span><span 4909class="cmtt-8"> of</span><span 4910class="cmtt-8"> 32</span><span 4911class="cmtt-8"> bits</span> 4912<br class="fancyvrb" /><a 4913 id="x1-84004r2"></a><span 4914class="cmr-6">2</span><span 4915class="cmtt-8"> </span><span 4916class="cmtt-8"> </span><span 4917class="cmtt-8"> </span><span 4918class="cmtt-8"> 2)</span><span 4919class="cmtt-8"> [vendor_string]</span><span 4920class="cmtt-8"> =</span><span 4921class="cmtt-8"> read</span><span 4922class="cmtt-8"> a</span><span 4923class="cmtt-8"> UTF-8</span><span 4924class="cmtt-8"> vector</span><span 4925class="cmtt-8"> as</span><span 4926class="cmtt-8"> [vendor_length]</span><span 4927class="cmtt-8"> octets</span> 4928<br class="fancyvrb" /><a 4929 id="x1-84006r3"></a><span 4930class="cmr-6">3</span><span 4931class="cmtt-8"> </span><span 4932class="cmtt-8"> </span><span 4933class="cmtt-8"> </span><span 4934class="cmtt-8"> 3)</span><span 4935class="cmtt-8"> [user_comment_list_length]</span><span 4936class="cmtt-8"> =</span><span 4937class="cmtt-8"> read</span><span 4938class="cmtt-8"> an</span><span 4939class="cmtt-8"> unsigned</span><span 4940class="cmtt-8"> integer</span><span 4941class="cmtt-8"> of</span><span 4942class="cmtt-8"> 32</span><span 4943class="cmtt-8"> bits</span> 4944<br class="fancyvrb" /><a 4945 id="x1-84008r4"></a><span 4946class="cmr-6">4</span><span 4947class="cmtt-8"> </span><span 4948class="cmtt-8"> </span><span 4949class="cmtt-8"> </span><span 4950class="cmtt-8"> 4)</span><span 4951class="cmtt-8"> iterate</span><span 4952class="cmtt-8"> [user_comment_list_length]</span><span 4953class="cmtt-8"> times</span><span 4954class="cmtt-8"> {</span> 4955<br class="fancyvrb" /><a 4956 id="x1-84010r5"></a><span 4957class="cmr-6">5</span><span 4958class="cmtt-8"> </span><span 4959class="cmtt-8"> </span><span 4960class="cmtt-8"> </span><span 4961class="cmtt-8"> </span><span 4962class="cmtt-8"> </span><span 4963class="cmtt-8"> </span><span 4964class="cmtt-8"> </span><span 4965class="cmtt-8"> </span><span 4966class="cmtt-8"> 5)</span><span 4967class="cmtt-8"> [length]</span><span 4968class="cmtt-8"> =</span><span 4969class="cmtt-8"> read</span><span 4970class="cmtt-8"> an</span><span 4971class="cmtt-8"> unsigned</span><span 4972class="cmtt-8"> integer</span><span 4973class="cmtt-8"> of</span><span 4974class="cmtt-8"> 32</span><span 4975class="cmtt-8"> bits</span> 4976<br class="fancyvrb" /><a 4977 id="x1-84012r6"></a><span 4978class="cmr-6">6</span><span 4979class="cmtt-8"> </span><span 4980class="cmtt-8"> </span><span 4981class="cmtt-8"> </span><span 4982class="cmtt-8"> </span><span 4983class="cmtt-8"> </span><span 4984class="cmtt-8"> </span><span 4985class="cmtt-8"> </span><span 4986class="cmtt-8"> </span><span 4987class="cmtt-8"> 6)</span><span 4988class="cmtt-8"> this</span><span 4989class="cmtt-8"> iteration’s</span><span 4990class="cmtt-8"> user</span><span 4991class="cmtt-8"> comment</span><span 4992class="cmtt-8"> =</span><span 4993class="cmtt-8"> read</span><span 4994class="cmtt-8"> a</span><span 4995class="cmtt-8"> UTF-8</span><span 4996class="cmtt-8"> vector</span><span 4997class="cmtt-8"> as</span><span 4998class="cmtt-8"> [length]</span><span 4999class="cmtt-8"> octets</span> 5000<br class="fancyvrb" /><a 5001 id="x1-84014r7"></a><span 5002class="cmr-6">7</span><span 5003class="cmtt-8"> </span><span 5004class="cmtt-8"> </span><span 5005class="cmtt-8"> </span><span 5006class="cmtt-8"> </span><span 5007class="cmtt-8"> </span><span 5008class="cmtt-8"> </span><span 5009class="cmtt-8"> }</span> 5010<br class="fancyvrb" /><a 5011 id="x1-84016r8"></a><span 5012class="cmr-6">8</span><span 5013class="cmtt-8"> </span><span 5014class="cmtt-8"> </span><span 5015class="cmtt-8"> </span><span 5016class="cmtt-8"> 7)</span><span 5017class="cmtt-8"> [framing_bit]</span><span 5018class="cmtt-8"> =</span><span 5019class="cmtt-8"> read</span><span 5020class="cmtt-8"> a</span><span 5021class="cmtt-8"> single</span><span 5022class="cmtt-8"> bit</span><span 5023class="cmtt-8"> as</span><span 5024class="cmtt-8"> boolean</span> 5025<br class="fancyvrb" /><a 5026 id="x1-84018r9"></a><span 5027class="cmr-6">9</span><span 5028class="cmtt-8"> </span><span 5029class="cmtt-8"> </span><span 5030class="cmtt-8"> </span><span 5031class="cmtt-8"> 8)</span><span 5032class="cmtt-8"> if</span><span 5033class="cmtt-8"> (</span><span 5034class="cmtt-8"> [framing_bit]</span><span 5035class="cmtt-8"> unset</span><span 5036class="cmtt-8"> or</span><span 5037class="cmtt-8"> end-of-packet</span><span 5038class="cmtt-8"> )</span><span 5039class="cmtt-8"> then</span><span 5040class="cmtt-8"> ERROR</span> 5041<br class="fancyvrb" /><a 5042 id="x1-84020r10"></a><span 5043class="cmr-6">10</span><span 5044class="cmtt-8"> </span><span 5045class="cmtt-8"> </span><span 5046class="cmtt-8"> </span><span 5047class="cmtt-8"> 9)</span><span 5048class="cmtt-8"> done.</span> 5049</div> 5050<!--l. 64--><p class="noindent" > 5051<h5 class="subsubsectionHead"><span class="titlemark">5.2.2 </span> <a 5052 id="x1-850005.2.2"></a>Content vector format</h5> 5053<!--l. 66--><p class="noindent" >The comment vectors are structured similarly to a UNIX environment variable. That is, 5054comment fields consist of a field name and a corresponding value and look like: 5055<!--l. 70--><p class="noindent" > 5056 <div class="quote"> 5057 <!--l. 71--><p class="noindent" > 5058 <div class="fancyvrb" id="fancyvrb24"> 5059<a 5060 id="x1-85002r1"></a><span 5061class="cmr-6">1</span><span 5062class="cmtt-8"> </span><span 5063class="cmtt-8"> comment[0]="ARTIST=me";</span> 5064<br class="fancyvrb" /><a 5065 id="x1-85004r2"></a><span 5066class="cmr-6">2</span><span 5067class="cmtt-8"> </span><span 5068class="cmtt-8"> comment[1]="TITLE=the</span><span 5069class="cmtt-8"> sound</span><span 5070class="cmtt-8"> of</span><span 5071class="cmtt-8"> Vorbis";</span> 5072</div> 5073 </div> 5074 5075 5076 5077<!--l. 77--><p class="noindent" >The field name is case-insensitive and may consist of ASCII 0x20 through 0x7D, 0x3D (’=’) 5078excluded. ASCII 0x41 through 0x5A inclusive (characters A-Z) is to be considered equivalent to 5079ASCII 0x61 through 0x7A inclusive (characters a-z). 5080<!--l. 83--><p class="noindent" >The field name is immediately followed by ASCII 0x3D (’=’); this equals sign is used to 5081terminate the field name. 5082<!--l. 87--><p class="noindent" >0x3D is followed by 8 bit clean UTF-8 encoded value of the field contents to the end of the 5083field. 5084<!--l. 91--><p class="noindent" ><span class="paragraphHead"><a 5085 id="x1-860005.2.2"></a><span 5086class="cmbx-12">Field names</span></span> 5087Below is a proposed, minimal list of standard field names with a description of intended use. No 5088single or group of field names is mandatory; a comment header may contain one, all or none of 5089the names in this list. 5090<!--l. 98--><p class="noindent" > 5091 <dl class="description"><dt class="description"> 5092<span 5093class="cmssbx-10x-x-120">TITLE</span> </dt><dd 5094class="description">Track/Work name 5095 </dd><dt class="description"> 5096<span 5097class="cmssbx-10x-x-120">VERSION</span> </dt><dd 5098class="description">The version field may be used to differentiate multiple versions of the same 5099 track title in a single collection. (e.g. remix info) 5100 </dd><dt class="description"> 5101<span 5102class="cmssbx-10x-x-120">ALBUM</span> </dt><dd 5103class="description">The collection name to which this track belongs 5104 </dd><dt class="description"> 5105<span 5106class="cmssbx-10x-x-120">TRACKNUMBER</span> </dt><dd 5107class="description">The track number of this piece if part of a specific larger collection or 5108 album 5109 </dd><dt class="description"> 5110<span 5111class="cmssbx-10x-x-120">ARTIST</span> </dt><dd 5112class="description">The artist generally considered responsible for the work. In popular music this is 5113 usually the performing band or singer. For classical music it would be the composer. 5114 For an audio book it would be the author of the original text. 5115 </dd><dt class="description"> 5116<span 5117class="cmssbx-10x-x-120">PERFORMER</span> </dt><dd 5118class="description">The artist(s) who performed the work. In classical music this would be the 5119 conductor, orchestra, soloists. In an audio book it would be the actor who did the 5120 reading. In popular music this is typically the same as the ARTIST and is omitted. 5121 </dd><dt class="description"> 5122<span 5123class="cmssbx-10x-x-120">COPYRIGHT</span> </dt><dd 5124class="description">Copyright attribution, e.g., ’2001 Nobody’s Band’ or ’1999 Jack Moffitt’ 5125 </dd><dt class="description"> 5126 5127 5128 5129<span 5130class="cmssbx-10x-x-120">LICENSE</span> </dt><dd 5131class="description">License information, eg, ’All Rights Reserved’, ’Any Use Permitted’, a URL to 5132 a license such as a Creative 5133 Commons license (”www.creativecommons.org/blahblah/license.html”) or the EFF 5134 Open Audio License (’distributed under the terms of the Open Audio License. see 5135 http://www.eff.org/IP/Open˙licenses/eff˙oal.html for details’), etc. 5136 </dd><dt class="description"> 5137<span 5138class="cmssbx-10x-x-120">ORGANIZATION</span> </dt><dd 5139class="description">Name of the organization producing the track (i.e. the ’record label’) 5140 </dd><dt class="description"> 5141<span 5142class="cmssbx-10x-x-120">DESCRIPTION</span> </dt><dd 5143class="description">A short text description of the contents 5144 </dd><dt class="description"> 5145<span 5146class="cmssbx-10x-x-120">GENRE</span> </dt><dd 5147class="description">A short text indication of music genre 5148 </dd><dt class="description"> 5149<span 5150class="cmssbx-10x-x-120">DATE</span> </dt><dd 5151class="description">Date the track was recorded 5152 </dd><dt class="description"> 5153<span 5154class="cmssbx-10x-x-120">LOCATION</span> </dt><dd 5155class="description">Location where track was recorded 5156 </dd><dt class="description"> 5157<span 5158class="cmssbx-10x-x-120">CONTACT</span> </dt><dd 5159class="description">Contact information for the creators or distributors of the track. This could 5160 be a URL, an email address, the physical address of the producing label. 5161 </dd><dt class="description"> 5162<span 5163class="cmssbx-10x-x-120">ISRC</span> </dt><dd 5164class="description">International Standard Recording Code for the track; see <a 5165href="http://www.ifpi.org/isrc/" >the ISRC intro page</a> for 5166 more information on ISRC numbers. 5167 </dd></dl> 5168<!--l. 158--><p class="noindent" ><span class="paragraphHead"><a 5169 id="x1-870005.2.2"></a><span 5170class="cmbx-12">Implications</span></span> 5171Field names should not be ’internationalized’; this is a concession to simplicity not 5172an attempt to exclude the majority of the world that doesn’t speak English. Field 5173<span 5174class="cmti-12">contents</span>, however, use the UTF-8 character encoding to allow easy representation of any 5175language. 5176<!--l. 166--><p class="noindent" >We have the length of the entirety of the field and restrictions on the field name so that 5177the field name is bounded in a known way. Thus we also have the length of the field 5178contents. 5179<!--l. 170--><p class="noindent" >Individual ’vendors’ may use non-standard field names within reason. The proper 5180use of comment fields should be clear through context at this point. Abuse will be 5181discouraged. 5182 5183 5184 5185<!--l. 174--><p class="noindent" >There is no vendor-specific prefix to ’nonstandard’ field names. Vendors should make some effort 5186to avoid arbitrarily polluting the common namespace. We will generally collect the more useful 5187tags here to help with standardization. 5188<!--l. 179--><p class="noindent" >Field names are not required to be unique (occur once) within a comment header. As an 5189example, assume a track was recorded by three well know artists; the following is permissible, 5190and encouraged: 5191<!--l. 183--><p class="noindent" > 5192 <div class="quote"> 5193 <!--l. 184--><p class="noindent" > 5194 <div class="fancyvrb" id="fancyvrb25"> 5195<a 5196 id="x1-87002r1"></a><span 5197class="cmr-6">1</span><span 5198class="cmtt-8"> </span><span 5199class="cmtt-8"> ARTIST=Dizzy</span><span 5200class="cmtt-8"> Gillespie</span> 5201<br class="fancyvrb" /><a 5202 id="x1-87004r2"></a><span 5203class="cmr-6">2</span><span 5204class="cmtt-8"> </span><span 5205class="cmtt-8"> ARTIST=Sonny</span><span 5206class="cmtt-8"> Rollins</span> 5207<br class="fancyvrb" /><a 5208 id="x1-87006r3"></a><span 5209class="cmr-6">3</span><span 5210class="cmtt-8"> </span><span 5211class="cmtt-8"> ARTIST=Sonny</span><span 5212class="cmtt-8"> Stitt</span> 5213</div> 5214 </div> 5215<!--l. 197--><p class="noindent" > 5216<h5 class="subsubsectionHead"><span class="titlemark">5.2.3 </span> <a 5217 id="x1-880005.2.3"></a>Encoding</h5> 5218<!--l. 199--><p class="noindent" >The comment header comprises the entirety of the second bitstream header packet. Unlike the 5219first bitstream header packet, it is not generally the only packet on the second page and may not 5220be restricted to within the second bitstream page. The length of the comment header packet is 5221(practically) unbounded. The comment header packet is not optional; it must be present in the 5222bitstream even if it is effectively empty. 5223<!--l. 207--><p class="noindent" >The comment header is encoded as follows (as per Ogg’s standard bitstream mapping which 5224renders least-significant-bit of the word to be coded into the least significant available bit of the 5225current bitstream octet first): 5226<!--l. 212--><p class="noindent" > 5227 <ol class="enumerate1" > 5228 <li 5229 class="enumerate" id="x1-88002x1">Vendor string length (32 bit unsigned quantity specifying number of octets) 5230 </li> 5231 <li 5232 class="enumerate" id="x1-88004x2">Vendor string ([vendor string length] octets coded from beginning of string to end of 5233 string, not null terminated) 5234 5235 5236 5237 </li> 5238 <li 5239 class="enumerate" id="x1-88006x3">Number of comment fields (32 bit unsigned quantity specifying number of fields) 5240 </li> 5241 <li 5242 class="enumerate" id="x1-88008x4">Comment field 0 length (if [Number of comment fields] <span 5243class="cmmi-12">> </span>0; 32 bit unsigned quantity 5244 specifying number of octets) 5245 </li> 5246 <li 5247 class="enumerate" id="x1-88010x5">Comment field 0 ([Comment field 0 length] octets coded from beginning of string to 5248 end of string, not null terminated) 5249 </li> 5250 <li 5251 class="enumerate" id="x1-88012x6">Comment field 1 length (if [Number of comment fields] <span 5252class="cmmi-12">> </span>1...)... 5253 </li></ol> 5254<!--l. 234--><p class="noindent" >This is actually somewhat easier to describe in code; implementation of the above can be found 5255in <span 5256class="cmtt-12">vorbis/lib/info.c</span>, <span 5257class="cmtt-12">_vorbis_pack_comment() </span>and <span 5258class="cmtt-12">_vorbis_unpack_comment()</span>. 5259 5260 5261 5262 5263 5264 5265<h3 class="sectionHead"><span class="titlemark">6 </span> <a 5266 id="x1-890006"></a>Floor type 0 setup and decode</h3> 5267<!--l. 6--><p class="noindent" > 5268<h4 class="subsectionHead"><span class="titlemark">6.1 </span> <a 5269 id="x1-900006.1"></a>Overview</h4> 5270<!--l. 8--><p class="noindent" >Vorbis floor type zero uses Line Spectral Pair (LSP, also alternately known as Line Spectral 5271Frequency or LSF) representation to encode a smooth spectral envelope curve as the frequency 5272response of the LSP filter. This representation is equivalent to a traditional all-pole infinite 5273impulse response filter as would be used in linear predictive coding; LSP representation may be 5274converted to LPC representation and vice-versa. 5275<!--l. 18--><p class="noindent" > 5276<h4 class="subsectionHead"><span class="titlemark">6.2 </span> <a 5277 id="x1-910006.2"></a>Floor 0 format</h4> 5278<!--l. 20--><p class="noindent" >Floor zero configuration consists of six integer fields and a list of VQ codebooks for use in 5279coding/decoding the LSP filter coefficient values used by each frame. 5280<!--l. 24--><p class="noindent" > 5281<h5 class="subsubsectionHead"><span class="titlemark">6.2.1 </span> <a 5282 id="x1-920006.2.1"></a>header decode</h5> 5283<!--l. 26--><p class="noindent" >Configuration information for instances of floor zero decodes from the codec setup header (third 5284packet). configuration decode proceeds as follows: 5285<!--l. 30--><p class="noindent" > 5286<div class="fancyvrb" id="fancyvrb26"> 5287<a 5288 id="x1-92002r1"></a><span 5289class="cmr-6">1</span><span 5290class="cmtt-8"> </span><span 5291class="cmtt-8"> </span><span 5292class="cmtt-8"> </span><span 5293class="cmtt-8"> 1)</span><span 5294class="cmtt-8"> [floor0_order]</span><span 5295class="cmtt-8"> =</span><span 5296class="cmtt-8"> read</span><span 5297class="cmtt-8"> an</span><span 5298class="cmtt-8"> unsigned</span><span 5299class="cmtt-8"> integer</span><span 5300class="cmtt-8"> of</span><span 5301class="cmtt-8"> 8</span><span 5302class="cmtt-8"> bits</span> 5303<br class="fancyvrb" /><a 5304 id="x1-92004r2"></a><span 5305class="cmr-6">2</span><span 5306class="cmtt-8"> </span><span 5307class="cmtt-8"> </span><span 5308class="cmtt-8"> </span><span 5309class="cmtt-8"> 2)</span><span 5310class="cmtt-8"> [floor0_rate]</span><span 5311class="cmtt-8"> =</span><span 5312class="cmtt-8"> read</span><span 5313class="cmtt-8"> an</span><span 5314class="cmtt-8"> unsigned</span><span 5315class="cmtt-8"> integer</span><span 5316class="cmtt-8"> of</span><span 5317class="cmtt-8"> 16</span><span 5318class="cmtt-8"> bits</span> 5319<br class="fancyvrb" /><a 5320 id="x1-92006r3"></a><span 5321class="cmr-6">3</span><span 5322class="cmtt-8"> </span><span 5323class="cmtt-8"> </span><span 5324class="cmtt-8"> </span><span 5325class="cmtt-8"> 3)</span><span 5326class="cmtt-8"> [floor0_bark_map_size]</span><span 5327class="cmtt-8"> =</span><span 5328class="cmtt-8"> read</span><span 5329class="cmtt-8"> an</span><span 5330class="cmtt-8"> unsigned</span><span 5331class="cmtt-8"> integer</span><span 5332class="cmtt-8"> of</span><span 5333class="cmtt-8"> 16</span><span 5334class="cmtt-8"> bits</span> 5335<br class="fancyvrb" /><a 5336 id="x1-92008r4"></a><span 5337class="cmr-6">4</span><span 5338class="cmtt-8"> </span><span 5339class="cmtt-8"> </span><span 5340class="cmtt-8"> </span><span 5341class="cmtt-8"> 4)</span><span 5342class="cmtt-8"> [floor0_amplitude_bits]</span><span 5343class="cmtt-8"> =</span><span 5344class="cmtt-8"> read</span><span 5345class="cmtt-8"> an</span><span 5346class="cmtt-8"> unsigned</span><span 5347class="cmtt-8"> integer</span><span 5348class="cmtt-8"> of</span><span 5349class="cmtt-8"> six</span><span 5350class="cmtt-8"> bits</span> 5351<br class="fancyvrb" /><a 5352 id="x1-92010r5"></a><span 5353class="cmr-6">5</span><span 5354class="cmtt-8"> </span><span 5355class="cmtt-8"> </span><span 5356class="cmtt-8"> </span><span 5357class="cmtt-8"> 5)</span><span 5358class="cmtt-8"> [floor0_amplitude_offset]</span><span 5359class="cmtt-8"> =</span><span 5360class="cmtt-8"> read</span><span 5361class="cmtt-8"> an</span><span 5362class="cmtt-8"> unsigned</span><span 5363class="cmtt-8"> integer</span><span 5364class="cmtt-8"> of</span><span 5365class="cmtt-8"> eight</span><span 5366class="cmtt-8"> bits</span> 5367<br class="fancyvrb" /><a 5368 id="x1-92012r6"></a><span 5369class="cmr-6">6</span><span 5370class="cmtt-8"> </span><span 5371class="cmtt-8"> </span><span 5372class="cmtt-8"> </span><span 5373class="cmtt-8"> 6)</span><span 5374class="cmtt-8"> [floor0_number_of_books]</span><span 5375class="cmtt-8"> =</span><span 5376class="cmtt-8"> read</span><span 5377class="cmtt-8"> an</span><span 5378class="cmtt-8"> unsigned</span><span 5379class="cmtt-8"> integer</span><span 5380class="cmtt-8"> of</span><span 5381class="cmtt-8"> four</span><span 5382class="cmtt-8"> bits</span><span 5383class="cmtt-8"> and</span><span 5384class="cmtt-8"> add</span><span 5385class="cmtt-8"> 1</span> 5386<br class="fancyvrb" /><a 5387 id="x1-92014r7"></a><span 5388class="cmr-6">7</span><span 5389class="cmtt-8"> </span><span 5390class="cmtt-8"> </span><span 5391class="cmtt-8"> </span><span 5392class="cmtt-8"> 7)</span><span 5393class="cmtt-8"> array</span><span 5394class="cmtt-8"> [floor0_book_list]</span><span 5395class="cmtt-8"> =</span><span 5396class="cmtt-8"> read</span><span 5397class="cmtt-8"> a</span><span 5398class="cmtt-8"> list</span><span 5399class="cmtt-8"> of</span><span 5400class="cmtt-8"> [floor0_number_of_books]</span><span 5401class="cmtt-8"> unsigned</span><span 5402class="cmtt-8"> integers</span><span 5403class="cmtt-8"> of</span><span 5404class="cmtt-8"> eight</span><span 5405class="cmtt-8"> bits</span><span 5406class="cmtt-8"> each;</span> 5407</div> 5408 5409 5410 5411<!--l. 40--><p class="noindent" >An end-of-packet condition during any of these bitstream reads renders this stream undecodable. 5412In addition, any element of the array <span 5413class="cmtt-12">[floor0_book_list] </span>that is greater than the maximum 5414codebook number for this bitstream is an error condition that also renders the stream 5415undecodable. 5416<!--l. 48--><p class="noindent" > 5417<h5 class="subsubsectionHead"><span class="titlemark">6.2.2 </span> <a 5418 id="x1-930006.2.2"></a>packet decode</h5> 5419<!--l. 50--><p class="noindent" >Extracting a floor0 curve from an audio packet consists of first decoding the curve 5420amplitude and <span 5421class="cmtt-12">[floor0_order] </span>LSP coefficient values from the bitstream, and then 5422computing the floor curve, which is defined as the frequency response of the decoded LSP 5423filter. 5424<!--l. 56--><p class="noindent" >Packet decode proceeds as follows: 5425<div class="fancyvrb" id="fancyvrb27"> 5426<a 5427 id="x1-93002r1"></a><span 5428class="cmr-6">1</span><span 5429class="cmtt-8"> </span><span 5430class="cmtt-8"> </span><span 5431class="cmtt-8"> </span><span 5432class="cmtt-8"> 1)</span><span 5433class="cmtt-8"> [amplitude]</span><span 5434class="cmtt-8"> =</span><span 5435class="cmtt-8"> read</span><span 5436class="cmtt-8"> an</span><span 5437class="cmtt-8"> unsigned</span><span 5438class="cmtt-8"> integer</span><span 5439class="cmtt-8"> of</span><span 5440class="cmtt-8"> [floor0_amplitude_bits]</span><span 5441class="cmtt-8"> bits</span> 5442<br class="fancyvrb" /><a 5443 id="x1-93004r2"></a><span 5444class="cmr-6">2</span><span 5445class="cmtt-8"> </span><span 5446class="cmtt-8"> </span><span 5447class="cmtt-8"> </span><span 5448class="cmtt-8"> 2)</span><span 5449class="cmtt-8"> if</span><span 5450class="cmtt-8"> (</span><span 5451class="cmtt-8"> [amplitude]</span><span 5452class="cmtt-8"> is</span><span 5453class="cmtt-8"> greater</span><span 5454class="cmtt-8"> than</span><span 5455class="cmtt-8"> zero</span><span 5456class="cmtt-8"> )</span><span 5457class="cmtt-8"> </span><span 5458class="cmsy-8">{</span> 5459<br class="fancyvrb" /><a 5460 id="x1-93006r3"></a><span 5461class="cmr-6">3</span><span 5462class="cmtt-8"> </span><span 5463class="cmtt-8"> </span><span 5464class="cmtt-8"> </span><span 5465class="cmtt-8"> </span><span 5466class="cmtt-8"> </span><span 5467class="cmtt-8"> </span><span 5468class="cmtt-8"> </span><span 5469class="cmtt-8"> </span><span 5470class="cmtt-8"> 3)</span><span 5471class="cmtt-8"> [coefficients]</span><span 5472class="cmtt-8"> is</span><span 5473class="cmtt-8"> an</span><span 5474class="cmtt-8"> empty,</span><span 5475class="cmtt-8"> zero</span><span 5476class="cmtt-8"> length</span><span 5477class="cmtt-8"> vector</span> 5478<br class="fancyvrb" /><a 5479 id="x1-93008r4"></a><span 5480class="cmr-6">4</span><span 5481class="cmtt-8"> </span><span 5482class="cmtt-8"> </span><span 5483class="cmtt-8"> </span><span 5484class="cmtt-8"> </span><span 5485class="cmtt-8"> </span><span 5486class="cmtt-8"> </span><span 5487class="cmtt-8"> </span><span 5488class="cmtt-8"> </span><span 5489class="cmtt-8"> 4)</span><span 5490class="cmtt-8"> [booknumber]</span><span 5491class="cmtt-8"> =</span><span 5492class="cmtt-8"> read</span><span 5493class="cmtt-8"> an</span><span 5494class="cmtt-8"> unsigned</span><span 5495class="cmtt-8"> integer</span><span 5496class="cmtt-8"> of</span><span 5497class="cmtt-8"> </span><a 5498href="#x1-1170009.2.1"><span 5499class="cmtt-8">ilog</span></a><span 5500class="cmtt-8">(</span><span 5501class="cmtt-8"> [floor0_number_of_books]</span><span 5502class="cmtt-8"> )</span><span 5503class="cmtt-8"> bits</span> 5504<br class="fancyvrb" /><a 5505 id="x1-93010r5"></a><span 5506class="cmr-6">5</span><span 5507class="cmtt-8"> </span><span 5508class="cmtt-8"> </span><span 5509class="cmtt-8"> </span><span 5510class="cmtt-8"> </span><span 5511class="cmtt-8"> </span><span 5512class="cmtt-8"> </span><span 5513class="cmtt-8"> </span><span 5514class="cmtt-8"> </span><span 5515class="cmtt-8"> 5)</span><span 5516class="cmtt-8"> if</span><span 5517class="cmtt-8"> (</span><span 5518class="cmtt-8"> [booknumber]</span><span 5519class="cmtt-8"> is</span><span 5520class="cmtt-8"> greater</span><span 5521class="cmtt-8"> than</span><span 5522class="cmtt-8"> the</span><span 5523class="cmtt-8"> highest</span><span 5524class="cmtt-8"> number</span><span 5525class="cmtt-8"> decode</span><span 5526class="cmtt-8"> codebook</span><span 5527class="cmtt-8"> )</span><span 5528class="cmtt-8"> then</span><span 5529class="cmtt-8"> packet</span><span 5530class="cmtt-8"> is</span><span 5531class="cmtt-8"> undecodable</span> 5532<br class="fancyvrb" /><a 5533 id="x1-93012r6"></a><span 5534class="cmr-6">6</span><span 5535class="cmtt-8"> </span><span 5536class="cmtt-8"> </span><span 5537class="cmtt-8"> </span><span 5538class="cmtt-8"> </span><span 5539class="cmtt-8"> </span><span 5540class="cmtt-8"> </span><span 5541class="cmtt-8"> </span><span 5542class="cmtt-8"> </span><span 5543class="cmtt-8"> 6)</span><span 5544class="cmtt-8"> [last]</span><span 5545class="cmtt-8"> =</span><span 5546class="cmtt-8"> zero;</span> 5547<br class="fancyvrb" /><a 5548 id="x1-93014r7"></a><span 5549class="cmr-6">7</span><span 5550class="cmtt-8"> </span><span 5551class="cmtt-8"> </span><span 5552class="cmtt-8"> </span><span 5553class="cmtt-8"> </span><span 5554class="cmtt-8"> </span><span 5555class="cmtt-8"> </span><span 5556class="cmtt-8"> </span><span 5557class="cmtt-8"> </span><span 5558class="cmtt-8"> 7)</span><span 5559class="cmtt-8"> vector</span><span 5560class="cmtt-8"> [temp_vector]</span><span 5561class="cmtt-8"> =</span><span 5562class="cmtt-8"> read</span><span 5563class="cmtt-8"> vector</span><span 5564class="cmtt-8"> from</span><span 5565class="cmtt-8"> bitstream</span><span 5566class="cmtt-8"> using</span><span 5567class="cmtt-8"> codebook</span><span 5568class="cmtt-8"> number</span><span 5569class="cmtt-8"> [floor0_book_list]</span><span 5570class="cmtt-8"> element</span><span 5571class="cmtt-8"> [booknumber]</span><span 5572class="cmtt-8"> in</span><span 5573class="cmtt-8"> VQ</span><span 5574class="cmtt-8"> context.</span> 5575<br class="fancyvrb" /><a 5576 id="x1-93016r8"></a><span 5577class="cmr-6">8</span><span 5578class="cmtt-8"> </span><span 5579class="cmtt-8"> </span><span 5580class="cmtt-8"> </span><span 5581class="cmtt-8"> </span><span 5582class="cmtt-8"> </span><span 5583class="cmtt-8"> </span><span 5584class="cmtt-8"> </span><span 5585class="cmtt-8"> </span><span 5586class="cmtt-8"> 8)</span><span 5587class="cmtt-8"> add</span><span 5588class="cmtt-8"> the</span><span 5589class="cmtt-8"> scalar</span><span 5590class="cmtt-8"> value</span><span 5591class="cmtt-8"> [last]</span><span 5592class="cmtt-8"> to</span><span 5593class="cmtt-8"> each</span><span 5594class="cmtt-8"> scalar</span><span 5595class="cmtt-8"> in</span><span 5596class="cmtt-8"> vector</span><span 5597class="cmtt-8"> [temp_vector]</span> 5598<br class="fancyvrb" /><a 5599 id="x1-93018r9"></a><span 5600class="cmr-6">9</span><span 5601class="cmtt-8"> </span><span 5602class="cmtt-8"> </span><span 5603class="cmtt-8"> </span><span 5604class="cmtt-8"> </span><span 5605class="cmtt-8"> </span><span 5606class="cmtt-8"> </span><span 5607class="cmtt-8"> </span><span 5608class="cmtt-8"> </span><span 5609class="cmtt-8"> 9)</span><span 5610class="cmtt-8"> [last]</span><span 5611class="cmtt-8"> =</span><span 5612class="cmtt-8"> the</span><span 5613class="cmtt-8"> value</span><span 5614class="cmtt-8"> of</span><span 5615class="cmtt-8"> the</span><span 5616class="cmtt-8"> last</span><span 5617class="cmtt-8"> scalar</span><span 5618class="cmtt-8"> in</span><span 5619class="cmtt-8"> vector</span><span 5620class="cmtt-8"> [temp_vector]</span> 5621<br class="fancyvrb" /><a 5622 id="x1-93020r10"></a><span 5623class="cmr-6">10</span><span 5624class="cmtt-8"> </span><span 5625class="cmtt-8"> </span><span 5626class="cmtt-8"> </span><span 5627class="cmtt-8"> </span><span 5628class="cmtt-8"> </span><span 5629class="cmtt-8"> </span><span 5630class="cmtt-8"> </span><span 5631class="cmtt-8"> 10)</span><span 5632class="cmtt-8"> concatenate</span><span 5633class="cmtt-8"> [temp_vector]</span><span 5634class="cmtt-8"> onto</span><span 5635class="cmtt-8"> the</span><span 5636class="cmtt-8"> end</span><span 5637class="cmtt-8"> of</span><span 5638class="cmtt-8"> the</span><span 5639class="cmtt-8"> [coefficients]</span><span 5640class="cmtt-8"> vector</span> 5641<br class="fancyvrb" /><a 5642 id="x1-93022r11"></a><span 5643class="cmr-6">11</span><span 5644class="cmtt-8"> </span><span 5645class="cmtt-8"> </span><span 5646class="cmtt-8"> </span><span 5647class="cmtt-8"> </span><span 5648class="cmtt-8"> </span><span 5649class="cmtt-8"> </span><span 5650class="cmtt-8"> </span><span 5651class="cmtt-8"> 11)</span><span 5652class="cmtt-8"> if</span><span 5653class="cmtt-8"> (length</span><span 5654class="cmtt-8"> of</span><span 5655class="cmtt-8"> vector</span><span 5656class="cmtt-8"> [coefficients]</span><span 5657class="cmtt-8"> is</span><span 5658class="cmtt-8"> less</span><span 5659class="cmtt-8"> than</span><span 5660class="cmtt-8"> [floor0_order],</span><span 5661class="cmtt-8"> continue</span><span 5662class="cmtt-8"> at</span><span 5663class="cmtt-8"> step</span><span 5664class="cmtt-8"> 6</span> 5665<br class="fancyvrb" /><a 5666 id="x1-93024r12"></a><span 5667class="cmr-6">12</span><span 5668class="cmtt-8"> </span><span 5669class="cmtt-8"> </span> 5670<br class="fancyvrb" /><a 5671 id="x1-93026r13"></a><span 5672class="cmr-6">13</span><span 5673class="cmtt-8"> </span><span 5674class="cmtt-8"> </span><span 5675class="cmtt-8"> </span><span 5676class="cmtt-8"> </span><span 5677class="cmtt-8"> </span><span 5678class="cmtt-8"> </span><span 5679class="cmtt-8"> </span><span 5680class="cmsy-8">}</span> 5681<br class="fancyvrb" /><a 5682 id="x1-93028r14"></a><span 5683class="cmr-6">14</span><span 5684class="cmtt-8"> </span><span 5685class="cmtt-8"> </span> 5686<br class="fancyvrb" /><a 5687 id="x1-93030r15"></a><span 5688class="cmr-6">15</span><span 5689class="cmtt-8"> </span><span 5690class="cmtt-8"> </span><span 5691class="cmtt-8"> 12)</span><span 5692class="cmtt-8"> done.</span> 5693<br class="fancyvrb" /><a 5694 id="x1-93032r16"></a><span 5695class="cmr-6">16</span><span 5696class="cmtt-8"> </span><span 5697class="cmtt-8"> </span> 5698</div> 5699<!--l. 76--><p class="noindent" >Take note of the following properties of decode: 5700 <ul class="itemize1"> 5701 <li class="itemize">An <span 5702class="cmtt-12">[amplitude] </span>value of zero must result in a return code that indicates this channel 5703 is unused in this frame (the output of the channel will be all-zeroes in synthesis). 5704 Several later stages of decode don’t occur for an unused channel. 5705 </li> 5706 <li class="itemize">An end-of-packet condition during decode should be considered a nominal occruence; 5707 if end-of-packet is reached during any read operation above, floor decode is to return 5708 ’unused’ status as if the <span 5709class="cmtt-12">[amplitude] </span>value had read zero at the beginning of decode. 5710 </li> 5711 <li class="itemize">The book number used for decode can, in fact, be stored in the bitstream in <a 5712href="#x1-1170009.2.1">ilog</a>( 5713 5714 5715 5716 <span 5717class="cmtt-12">[floor0_number_of_books] </span>- 1 ) bits. Nevertheless, the above specification is correct 5718 and values greater than the maximum possible book value are reserved. 5719 </li> 5720 <li class="itemize">The number of scalars read into the vector <span 5721class="cmtt-12">[coefficients] </span>may be greater 5722 than <span 5723class="cmtt-12">[floor0_order]</span>, the number actually required for curve computation. For 5724 example, if the VQ codebook used for the floor currently being decoded has a 5725 <span 5726class="cmtt-12">[codebook_dimensions] </span>value of three and <span 5727class="cmtt-12">[floor0_order] </span>is ten, the only way to 5728 fill all the needed scalars in <span 5729class="cmtt-12">[coefficients] </span>is to to read a total of twelve scalars 5730 as four vectors of three scalars each. This is not an error condition, and care must 5731 be taken not to allow a buffer overflow in decode. The extra values are not used and 5732 may be ignored or discarded.</li></ul> 5733<!--l. 104--><p class="noindent" > 5734<h5 class="subsubsectionHead"><span class="titlemark">6.2.3 </span> <a 5735 id="x1-940006.2.3"></a>curve computation</h5> 5736<!--l. 106--><p class="noindent" >Given an <span 5737class="cmtt-12">[amplitude] </span>integer and <span 5738class="cmtt-12">[coefficients] </span>vector from packet decode as well 5739as the [floor0˙order], [floor0˙rate], [floor0˙bark˙map˙size], [floor0˙amplitude˙bits] and 5740[floor0˙amplitude˙offset] values from floor setup, and an output vector size <span 5741class="cmtt-12">[n] </span>specified by the 5742decode process, we compute a floor output vector. 5743<!--l. 113--><p class="noindent" >If the value <span 5744class="cmtt-12">[amplitude] </span>is zero, the return value is a length <span 5745class="cmtt-12">[n] </span>vector with all-zero 5746scalars. Otherwise, begin by assuming the following definitions for the given vector to be 5747synthesized: 5748<center class="par-math-display" > 5749<img 5750src="Vorbis_I_spec7x.png" alt=" { 5751 min (floor0xbarkxmapxsize − 1,foobar ) for i ∈ [0,n − 1 ] 5752mapi = − 1 for i = n 5753" class="par-math-display" ></center> 5754<!--l. 128--><p class="nopar" > 5755<!--l. 130--><p class="noindent" >where 5756<center class="par-math-display" > 5757<img 5758src="Vorbis_I_spec8x.png" alt=" ⌊ ⌋ 5759 (floor0xrate ⋅ i) floor0xbarkxmapxsize 5760foobar = bark -------2n------- ⋅-bark(.5 ⋅ floor0xrate-) 5761" class="par-math-display" ></center> 5762 5763 5764 5765<!--l. 137--><p class="nopar" > 5766<!--l. 139--><p class="noindent" >and 5767<center class="par-math-display" > 5768<img 5769src="Vorbis_I_spec9x.png" alt=" 2 5770bark(x) = 13.1arctan (.00074x ) + 2.24 arctan(.0000000185x + .0001x ) 5771" class="par-math-display" ></center> 5772<!--l. 143--><p class="nopar" > 5773<!--l. 145--><p class="noindent" >The above is used to synthesize the LSP curve on a Bark-scale frequency axis, then map the 5774result to a linear-scale frequency axis. Similarly, the below calculation synthesizes the output 5775LSP curve <span 5776class="cmtt-12">[output] </span>on a log (dB) amplitude scale, mapping it to linear amplitude in the last 5777step: 5778<!--l. 150--><p class="noindent" > 5779 <ol class="enumerate1" > 5780 <li 5781 class="enumerate" id="x1-94002x1"><span 5782class="cmtt-12">[i] </span>= 0 5783 </li> 5784 <li 5785 class="enumerate" id="x1-94004x2"><span 5786class="cmtt-12">[</span><span 5787class="cmmi-12">ω</span><span 5788class="cmtt-12">] </span>= <span 5789class="cmmi-12">π </span>* map element <span 5790class="cmtt-12">[i] </span>/ <span 5791class="cmtt-12">[floor0_bark_map_size]</span> 5792 </li> 5793 <li 5794 class="enumerate" id="x1-94006x3">if ( <span 5795class="cmtt-12">[floor0_order] </span>is odd ) 5796 <ol class="enumerate2" > 5797 <li 5798 class="enumerate" id="x1-94008x1">calculate <span 5799class="cmtt-12">[p] </span>and <span 5800class="cmtt-12">[q] </span>according to: <div class="eqnarray"> 5801 <center class="math-display" > 5802 <img 5803src="Vorbis_I_spec10x.png" alt=" floor0xorder−3 5804 2 ∏2 2 5805p = (1 − cos ω) 4(cos([coefficients ]2j+1) − cosω ) 5806 j=0 5807 floor0x∏or2der−1 5808q = 1- 4(cos([coefficients ]2j) − cosω )2 5809 4 j=0 5810 5811 5812 5813 " class="math-display" ></center> 5814 </div> 5815 </li></ol> 5816 <!--l. 162--><p class="noindent" >else <span 5817class="cmtt-12">[floor0_order] </span>is even 5818 <ol class="enumerate2" > 5819 <li 5820 class="enumerate" id="x1-94011x1">calculate <span 5821class="cmtt-12">[p] </span>and <span 5822class="cmtt-12">[q] </span>according to: <div class="eqnarray"> 5823 <center class="math-display" > 5824 <img 5825src="Vorbis_I_spec11x.png" alt=" floor0xorder−2 5826 (1 − cos2ω) ∏2 2 5827p = -----2------ 4(cos([coefficients ]2j+1) − cosω ) 5828 j=0 5829 2 floor0xor2der−2 5830q = (1 +-cos-ω)- ∏ 4(cos([coefficients ] ) − cosω )2 5831 2 j=0 2j 5832 " class="math-display" ></center> 5833 </div> 5834 </li></ol> 5835 </li> 5836 <li 5837 class="enumerate" id="x1-94014x4">calculate <span 5838class="cmtt-12">[linear_floor_value] </span>according to: 5839 <center class="math-display" > 5840 <img 5841src="Vorbis_I_spec12x.png" alt=" ( ( )) 5842 amplitude---⋅ floor0xamplitutexoffset--- 5843exp .11512925 (2floor0xamplitudexbits − 1)√ p + q − floor0xamplitudexoffset 5844 " class="math-display" ></center> 5845 <!--l. 177--><p class="nopar" > 5846 </li> 5847 <li 5848 class="enumerate" id="x1-94016x5"><span 5849class="cmtt-12">[iteration_condition] </span>= map element <span 5850class="cmtt-12">[i]</span> 5851 5852 5853 5854 </li> 5855 <li 5856 class="enumerate" id="x1-94018x6"><span 5857class="cmtt-12">[output] </span>element <span 5858class="cmtt-12">[i] </span>= <span 5859class="cmtt-12">[linear_floor_value]</span> 5860 </li> 5861 <li 5862 class="enumerate" id="x1-94020x7">increment <span 5863class="cmtt-12">[i]</span> 5864 </li> 5865 <li 5866 class="enumerate" id="x1-94022x8">if ( map element <span 5867class="cmtt-12">[i] </span>is equal to <span 5868class="cmtt-12">[iteration_condition] </span>) continue at step 5869 5 5870 </li> 5871 <li 5872 class="enumerate" id="x1-94024x9">if ( <span 5873class="cmtt-12">[i] </span>is less than <span 5874class="cmtt-12">[n] </span>) continue at step 2 5875 </li> 5876 <li 5877 class="enumerate" id="x1-94026x10">done</li></ol> 5878 5879 5880 5881 5882 5883 5884<h3 class="sectionHead"><span class="titlemark">7 </span> <a 5885 id="x1-950007"></a>Floor type 1 setup and decode</h3> 5886<!--l. 6--><p class="noindent" > 5887<h4 class="subsectionHead"><span class="titlemark">7.1 </span> <a 5888 id="x1-960007.1"></a>Overview</h4> 5889<!--l. 8--><p class="noindent" >Vorbis floor type one uses a piecewise straight-line representation to encode a spectral envelope 5890curve. The representation plots this curve mechanically on a linear frequency axis and a 5891logarithmic (dB) amplitude axis. The integer plotting algorithm used is similar to Bresenham’s 5892algorithm. 5893<!--l. 16--><p class="noindent" > 5894<h4 class="subsectionHead"><span class="titlemark">7.2 </span> <a 5895 id="x1-970007.2"></a>Floor 1 format</h4> 5896<!--l. 18--><p class="noindent" > 5897<h5 class="subsubsectionHead"><span class="titlemark">7.2.1 </span> <a 5898 id="x1-980007.2.1"></a>model</h5> 5899<!--l. 20--><p class="noindent" >Floor type one represents a spectral curve as a series of line segments. Synthesis constructs a 5900floor curve using iterative prediction in a process roughly equivalent to the following simplified 5901description: 5902 <ul class="itemize1"> 5903 <li class="itemize">the first line segment (base case) is a logical line spanning from x˙0,y˙0 to x˙1,y˙1 5904 where in the base case x˙0=0 and x˙1=[n], the full range of the spectral floor to be 5905 computed. 5906 </li> 5907 <li class="itemize">the induction step chooses a point x˙new within an existing logical line segment and 5908 produces a y˙new value at that point computed from the existing line’s y value at 5909 x˙new (as plotted by the line) and a difference value decoded from the bitstream 5910 packet. 5911 5912 5913 5914 </li> 5915 <li class="itemize">floor computation produces two new line segments, one running from x˙0,y˙0 to 5916 x˙new,y˙new and from x˙new,y˙new to x˙1,y˙1. This step is performed logically even if 5917 y˙new represents no change to the amplitude value at x˙new so that later refinement 5918 is additionally bounded at x˙new. 5919 </li> 5920 <li class="itemize">the induction step repeats, using a list of x values specified in the codec setup header 5921 at floor 1 initialization time. Computation is completed at the end of the x value list. 5922 </li></ul> 5923<!--l. 48--><p class="noindent" >Consider the following example, with values chosen for ease of understanding rather than 5924representing typical configuration: 5925<!--l. 51--><p class="noindent" >For the below example, we assume a floor setup with an [n] of 128. The list of selected X values 5926in increasing order is 0,16,32,48,64,80,96,112 and 128. In list order, the values interleave as 0, 5927128, 64, 32, 96, 16, 48, 80 and 112. The corresponding list-order Y values as decoded from an 5928example packet are 110, 20, -5, -45, 0, -25, -10, 30 and -10. We compute the floor in the following 5929way, beginning with the first line: 5930<div class="center" 5931> 5932<!--l. 59--><p class="noindent" > 5933 5934<!--l. 60--><p class="noindent" ><img 5935src="floor1-1.png" alt="PIC" 5936> 5937<br /> <div class="caption" 5938><span class="id">Figure 7: </span><span 5939class="content">graph of example floor</span></div><!--tex4ht:label?: x1-980017 --> 5940</div> 5941<!--l. 64--><p class="noindent" >We now draw new logical lines to reflect the correction to new˙Y, and iterate for X positions 32 5942and 96: 5943<div class="center" 5944> 5945<!--l. 67--><p class="noindent" > 5946 5947<!--l. 68--><p class="noindent" ><img 5948src="floor1-2.png" alt="PIC" 5949> 5950<br /> <div class="caption" 5951><span class="id">Figure 8: </span><span 5952class="content">graph of example floor</span></div><!--tex4ht:label?: x1-980028 --> 5953</div> 5954<!--l. 72--><p class="noindent" >Although the new Y value at X position 96 is unchanged, it is still used later as an endpoint for 5955further refinement. From here on, the pattern should be clear; we complete the floor computation 5956as follows: 5957 5958 5959 5960<div class="center" 5961> 5962<!--l. 76--><p class="noindent" > 5963 5964<!--l. 77--><p class="noindent" ><img 5965src="floor1-3.png" alt="PIC" 5966> 5967<br /> <div class="caption" 5968><span class="id">Figure 9: </span><span 5969class="content">graph of example floor</span></div><!--tex4ht:label?: x1-980039 --> 5970</div> 5971<div class="center" 5972> 5973<!--l. 81--><p class="noindent" > 5974 5975<!--l. 82--><p class="noindent" ><img 5976src="floor1-4.png" alt="PIC" 5977> 5978<br /> <div class="caption" 5979><span class="id">Figure 10: </span><span 5980class="content">graph of example floor</span></div><!--tex4ht:label?: x1-9800410 --> 5981</div> 5982<!--l. 86--><p class="noindent" >A more efficient algorithm with carefully defined integer rounding behavior is used for actual 5983decode, as described later. The actual algorithm splits Y value computation and line plotting 5984into two steps with modifications to the above algorithm to eliminate noise accumulation 5985through integer roundoff/truncation. 5986<!--l. 94--><p class="noindent" > 5987<h5 class="subsubsectionHead"><span class="titlemark">7.2.2 </span> <a 5988 id="x1-990007.2.2"></a>header decode</h5> 5989<!--l. 96--><p class="noindent" >A list of floor X values is stored in the packet header in interleaved format (used in list order 5990during packet decode and synthesis). This list is split into partitions, and each partition is 5991assigned to a partition class. X positions 0 and [n] are implicit and do not belong to an explicit 5992partition or partition class. 5993<!--l. 102--><p class="noindent" >A partition class consists of a representation vector width (the number of Y values which 5994the partition class encodes at once), a ’subclass’ value representing the number of 5995alternate entropy books the partition class may use in representing Y values, the list of 5996[subclass] books and a master book used to encode which alternate books were chosen 5997for representation in a given packet. The master/subclass mechanism is meant to be 5998used as a flexible representation cascade while still using codebooks only in a scalar 5999context. 6000 6001 6002 6003<!--l. 112--><p class="noindent" > 6004<div class="fancyvrb" id="fancyvrb28"> 6005<a 6006 id="x1-99002r1"></a><span 6007class="cmr-6">1</span><span 6008class="cmtt-8"> </span><span 6009class="cmtt-8"> </span> 6010<br class="fancyvrb" /><a 6011 id="x1-99004r2"></a><span 6012class="cmr-6">2</span><span 6013class="cmtt-8"> </span><span 6014class="cmtt-8"> </span><span 6015class="cmtt-8"> </span><span 6016class="cmtt-8"> 1)</span><span 6017class="cmtt-8"> [floor1_partitions]</span><span 6018class="cmtt-8"> =</span><span 6019class="cmtt-8"> read</span><span 6020class="cmtt-8"> 5</span><span 6021class="cmtt-8"> bits</span><span 6022class="cmtt-8"> as</span><span 6023class="cmtt-8"> unsigned</span><span 6024class="cmtt-8"> integer</span> 6025<br class="fancyvrb" /><a 6026 id="x1-99006r3"></a><span 6027class="cmr-6">3</span><span 6028class="cmtt-8"> </span><span 6029class="cmtt-8"> </span><span 6030class="cmtt-8"> </span><span 6031class="cmtt-8"> 2)</span><span 6032class="cmtt-8"> [maximum_class]</span><span 6033class="cmtt-8"> =</span><span 6034class="cmtt-8"> -1</span> 6035<br class="fancyvrb" /><a 6036 id="x1-99008r4"></a><span 6037class="cmr-6">4</span><span 6038class="cmtt-8"> </span><span 6039class="cmtt-8"> </span><span 6040class="cmtt-8"> </span><span 6041class="cmtt-8"> 3)</span><span 6042class="cmtt-8"> iterate</span><span 6043class="cmtt-8"> [i]</span><span 6044class="cmtt-8"> over</span><span 6045class="cmtt-8"> the</span><span 6046class="cmtt-8"> range</span><span 6047class="cmtt-8"> 0</span><span 6048class="cmtt-8"> ...</span><span 6049class="cmtt-8"> [floor1_partitions]-1</span><span 6050class="cmtt-8"> </span><span 6051class="cmsy-8">{</span> 6052<br class="fancyvrb" /><a 6053 id="x1-99010r5"></a><span 6054class="cmr-6">5</span><span 6055class="cmtt-8"> </span><span 6056class="cmtt-8"> </span> 6057<br class="fancyvrb" /><a 6058 id="x1-99012r6"></a><span 6059class="cmr-6">6</span><span 6060class="cmtt-8"> </span><span 6061class="cmtt-8"> </span><span 6062class="cmtt-8"> </span><span 6063class="cmtt-8"> </span><span 6064class="cmtt-8"> </span><span 6065class="cmtt-8"> </span><span 6066class="cmtt-8"> </span><span 6067class="cmtt-8"> </span><span 6068class="cmtt-8"> </span><span 6069class="cmtt-8"> 4)</span><span 6070class="cmtt-8"> vector</span><span 6071class="cmtt-8"> [floor1_partition_class_list]</span><span 6072class="cmtt-8"> element</span><span 6073class="cmtt-8"> [i]</span><span 6074class="cmtt-8"> =</span><span 6075class="cmtt-8"> read</span><span 6076class="cmtt-8"> 4</span><span 6077class="cmtt-8"> bits</span><span 6078class="cmtt-8"> as</span><span 6079class="cmtt-8"> unsigned</span><span 6080class="cmtt-8"> integer</span> 6081<br class="fancyvrb" /><a 6082 id="x1-99014r7"></a><span 6083class="cmr-6">7</span><span 6084class="cmtt-8"> </span><span 6085class="cmtt-8"> </span> 6086<br class="fancyvrb" /><a 6087 id="x1-99016r8"></a><span 6088class="cmr-6">8</span><span 6089class="cmtt-8"> </span><span 6090class="cmtt-8"> </span><span 6091class="cmtt-8"> </span><span 6092class="cmtt-8"> </span><span 6093class="cmtt-8"> </span><span 6094class="cmtt-8"> </span><span 6095class="cmtt-8"> </span><span 6096class="cmsy-8">}</span> 6097<br class="fancyvrb" /><a 6098 id="x1-99018r9"></a><span 6099class="cmr-6">9</span><span 6100class="cmtt-8"> </span><span 6101class="cmtt-8"> </span> 6102<br class="fancyvrb" /><a 6103 id="x1-99020r10"></a><span 6104class="cmr-6">10</span><span 6105class="cmtt-8"> </span><span 6106class="cmtt-8"> </span><span 6107class="cmtt-8"> </span><span 6108class="cmtt-8"> 5)</span><span 6109class="cmtt-8"> [maximum_class]</span><span 6110class="cmtt-8"> =</span><span 6111class="cmtt-8"> largest</span><span 6112class="cmtt-8"> integer</span><span 6113class="cmtt-8"> scalar</span><span 6114class="cmtt-8"> value</span><span 6115class="cmtt-8"> in</span><span 6116class="cmtt-8"> vector</span><span 6117class="cmtt-8"> [floor1_partition_class_list]</span> 6118<br class="fancyvrb" /><a 6119 id="x1-99022r11"></a><span 6120class="cmr-6">11</span><span 6121class="cmtt-8"> </span><span 6122class="cmtt-8"> </span><span 6123class="cmtt-8"> </span><span 6124class="cmtt-8"> 6)</span><span 6125class="cmtt-8"> iterate</span><span 6126class="cmtt-8"> [i]</span><span 6127class="cmtt-8"> over</span><span 6128class="cmtt-8"> the</span><span 6129class="cmtt-8"> range</span><span 6130class="cmtt-8"> 0</span><span 6131class="cmtt-8"> ...</span><span 6132class="cmtt-8"> [maximum_class]</span><span 6133class="cmtt-8"> </span><span 6134class="cmsy-8">{</span> 6135<br class="fancyvrb" /><a 6136 id="x1-99024r12"></a><span 6137class="cmr-6">12</span><span 6138class="cmtt-8"> </span><span 6139class="cmtt-8"> </span> 6140<br class="fancyvrb" /><a 6141 id="x1-99026r13"></a><span 6142class="cmr-6">13</span><span 6143class="cmtt-8"> </span><span 6144class="cmtt-8"> </span><span 6145class="cmtt-8"> </span><span 6146class="cmtt-8"> </span><span 6147class="cmtt-8"> </span><span 6148class="cmtt-8"> </span><span 6149class="cmtt-8"> </span><span 6150class="cmtt-8"> </span><span 6151class="cmtt-8"> </span><span 6152class="cmtt-8"> 7)</span><span 6153class="cmtt-8"> vector</span><span 6154class="cmtt-8"> [floor1_class_dimensions]</span><span 6155class="cmtt-8"> element</span><span 6156class="cmtt-8"> [i]</span><span 6157class="cmtt-8"> =</span><span 6158class="cmtt-8"> read</span><span 6159class="cmtt-8"> 3</span><span 6160class="cmtt-8"> bits</span><span 6161class="cmtt-8"> as</span><span 6162class="cmtt-8"> unsigned</span><span 6163class="cmtt-8"> integer</span><span 6164class="cmtt-8"> and</span><span 6165class="cmtt-8"> add</span><span 6166class="cmtt-8"> 1</span> 6167<br class="fancyvrb" /><a 6168 id="x1-99028r14"></a><span 6169class="cmr-6">14</span><span 6170class="cmtt-8"> </span><span 6171class="cmtt-8">  8)</span><span 6172class="cmtt-8"> vector</span><span 6173class="cmtt-8"> [floor1_class_subclasses]</span><span 6174class="cmtt-8"> element</span><span 6175class="cmtt-8"> [i]</span><span 6176class="cmtt-8"> =</span><span 6177class="cmtt-8"> read</span><span 6178class="cmtt-8"> 2</span><span 6179class="cmtt-8"> bits</span><span 6180class="cmtt-8"> as</span><span 6181class="cmtt-8"> unsigned</span><span 6182class="cmtt-8"> integer</span> 6183<br class="fancyvrb" /><a 6184 id="x1-99030r15"></a><span 6185class="cmr-6">15</span><span 6186class="cmtt-8"> </span><span 6187class="cmtt-8"> </span><span 6188class="cmtt-8"> </span><span 6189class="cmtt-8"> </span><span 6190class="cmtt-8"> </span><span 6191class="cmtt-8"> </span><span 6192class="cmtt-8"> </span><span 6193class="cmtt-8"> </span><span 6194class="cmtt-8"> </span><span 6195class="cmtt-8"> 9)</span><span 6196class="cmtt-8"> if</span><span 6197class="cmtt-8"> (</span><span 6198class="cmtt-8"> vector</span><span 6199class="cmtt-8"> [floor1_class_subclasses]</span><span 6200class="cmtt-8"> element</span><span 6201class="cmtt-8"> [i]</span><span 6202class="cmtt-8"> is</span><span 6203class="cmtt-8"> nonzero</span><span 6204class="cmtt-8"> )</span><span 6205class="cmtt-8"> </span><span 6206class="cmsy-8">{</span> 6207<br class="fancyvrb" /><a 6208 id="x1-99032r16"></a><span 6209class="cmr-6">16</span><span 6210class="cmtt-8"> </span><span 6211class="cmtt-8"> </span> 6212<br class="fancyvrb" /><a 6213 id="x1-99034r17"></a><span 6214class="cmr-6">17</span><span 6215class="cmtt-8"> </span><span 6216class="cmtt-8"> </span><span 6217class="cmtt-8"> </span><span 6218class="cmtt-8"> </span><span 6219class="cmtt-8"> </span><span 6220class="cmtt-8"> </span><span 6221class="cmtt-8"> </span><span 6222class="cmtt-8"> </span><span 6223class="cmtt-8"> </span><span 6224class="cmtt-8"> </span><span 6225class="cmtt-8"> </span><span 6226class="cmtt-8"> </span><span 6227class="cmtt-8"> </span><span 6228class="cmtt-8"> </span><span 6229class="cmtt-8"> 10)</span><span 6230class="cmtt-8"> vector</span><span 6231class="cmtt-8"> [floor1_class_masterbooks]</span><span 6232class="cmtt-8"> element</span><span 6233class="cmtt-8"> [i]</span><span 6234class="cmtt-8"> =</span><span 6235class="cmtt-8"> read</span><span 6236class="cmtt-8"> 8</span><span 6237class="cmtt-8"> bits</span><span 6238class="cmtt-8"> as</span><span 6239class="cmtt-8"> unsigned</span><span 6240class="cmtt-8"> integer</span> 6241<br class="fancyvrb" /><a 6242 id="x1-99036r18"></a><span 6243class="cmr-6">18</span><span 6244class="cmtt-8"> </span><span 6245class="cmtt-8"> </span> 6246<br class="fancyvrb" /><a 6247 id="x1-99038r19"></a><span 6248class="cmr-6">19</span><span 6249class="cmtt-8"> </span><span 6250class="cmtt-8"> </span><span 6251class="cmtt-8"> </span><span 6252class="cmtt-8"> </span><span 6253class="cmtt-8"> </span><span 6254class="cmtt-8"> </span><span 6255class="cmtt-8"> </span><span 6256class="cmtt-8"> </span><span 6257class="cmtt-8"> </span><span 6258class="cmtt-8"> </span><span 6259class="cmtt-8"> </span><span 6260class="cmtt-8"> </span><span 6261class="cmtt-8"> </span><span 6262class="cmsy-8">}</span> 6263<br class="fancyvrb" /><a 6264 id="x1-99040r20"></a><span 6265class="cmr-6">20</span><span 6266class="cmtt-8"> </span><span 6267class="cmtt-8"> </span> 6268<br class="fancyvrb" /><a 6269 id="x1-99042r21"></a><span 6270class="cmr-6">21</span><span 6271class="cmtt-8"> </span><span 6272class="cmtt-8"> </span><span 6273class="cmtt-8"> </span><span 6274class="cmtt-8"> </span><span 6275class="cmtt-8"> </span><span 6276class="cmtt-8"> </span><span 6277class="cmtt-8"> </span><span 6278class="cmtt-8"> </span><span 6279class="cmtt-8"> 11)</span><span 6280class="cmtt-8"> iterate</span><span 6281class="cmtt-8"> [j]</span><span 6282class="cmtt-8"> over</span><span 6283class="cmtt-8"> the</span><span 6284class="cmtt-8"> range</span><span 6285class="cmtt-8"> 0</span><span 6286class="cmtt-8"> ...</span><span 6287class="cmtt-8"> (2</span><span 6288class="cmtt-8"> exponent</span><span 6289class="cmtt-8"> [floor1_class_subclasses]</span><span 6290class="cmtt-8"> element</span><span 6291class="cmtt-8"> [i])</span><span 6292class="cmtt-8"> -</span><span 6293class="cmtt-8"> 1</span><span 6294class="cmtt-8"> </span><span 6295class="cmsy-8">{</span> 6296<br class="fancyvrb" /><a 6297 id="x1-99044r22"></a><span 6298class="cmr-6">22</span><span 6299class="cmtt-8"> </span><span 6300class="cmtt-8"> </span> 6301<br class="fancyvrb" /><a 6302 id="x1-99046r23"></a><span 6303class="cmr-6">23</span><span 6304class="cmtt-8"> </span><span 6305class="cmtt-8"> </span><span 6306class="cmtt-8"> </span><span 6307class="cmtt-8"> </span><span 6308class="cmtt-8"> </span><span 6309class="cmtt-8"> </span><span 6310class="cmtt-8"> </span><span 6311class="cmtt-8"> </span><span 6312class="cmtt-8"> </span><span 6313class="cmtt-8"> </span><span 6314class="cmtt-8"> </span><span 6315class="cmtt-8"> </span><span 6316class="cmtt-8"> </span><span 6317class="cmtt-8"> </span><span 6318class="cmtt-8"> 12)</span><span 6319class="cmtt-8"> array</span><span 6320class="cmtt-8"> [floor1_subclass_books]</span><span 6321class="cmtt-8"> element</span><span 6322class="cmtt-8"> [i],[j]</span><span 6323class="cmtt-8"> =</span> 6324<br class="fancyvrb" /><a 6325 id="x1-99048r24"></a><span 6326class="cmr-6">24</span><span 6327class="cmtt-8"> </span><span 6328class="cmtt-8"> </span><span 6329class="cmtt-8"> </span><span 6330class="cmtt-8"> </span><span 6331class="cmtt-8"> </span><span 6332class="cmtt-8"> </span><span 6333class="cmtt-8"> </span><span 6334class="cmtt-8"> </span><span 6335class="cmtt-8"> </span><span 6336class="cmtt-8"> </span><span 6337class="cmtt-8"> </span><span 6338class="cmtt-8"> </span><span 6339class="cmtt-8"> </span><span 6340class="cmtt-8"> </span><span 6341class="cmtt-8"> </span><span 6342class="cmtt-8"> </span><span 6343class="cmtt-8"> </span><span 6344class="cmtt-8"> </span><span 6345class="cmtt-8"> read</span><span 6346class="cmtt-8"> 8</span><span 6347class="cmtt-8"> bits</span><span 6348class="cmtt-8"> as</span><span 6349class="cmtt-8"> unsigned</span><span 6350class="cmtt-8"> integer</span><span 6351class="cmtt-8"> and</span><span 6352class="cmtt-8"> subtract</span><span 6353class="cmtt-8"> one</span> 6354<br class="fancyvrb" /><a 6355 id="x1-99050r25"></a><span 6356class="cmr-6">25</span><span 6357class="cmtt-8"> </span><span 6358class="cmtt-8"> </span><span 6359class="cmtt-8"> </span><span 6360class="cmtt-8"> </span><span 6361class="cmtt-8"> </span><span 6362class="cmtt-8"> </span><span 6363class="cmtt-8"> </span><span 6364class="cmtt-8"> </span><span 6365class="cmtt-8"> </span><span 6366class="cmtt-8"> </span><span 6367class="cmtt-8"> </span><span 6368class="cmtt-8"> </span><span 6369class="cmtt-8"> </span><span 6370class="cmsy-8">}</span> 6371<br class="fancyvrb" /><a 6372 id="x1-99052r26"></a><span 6373class="cmr-6">26</span><span 6374class="cmtt-8"> </span><span 6375class="cmtt-8"> </span><span 6376class="cmtt-8"> </span><span 6377class="cmtt-8"> </span><span 6378class="cmtt-8"> </span><span 6379class="cmtt-8"> </span><span 6380class="cmtt-8"> </span><span 6381class="cmtt-8"> </span><span 6382class="cmsy-8">}</span> 6383<br class="fancyvrb" /><a 6384 id="x1-99054r27"></a><span 6385class="cmr-6">27</span><span 6386class="cmtt-8"> </span><span 6387class="cmtt-8"> </span> 6388<br class="fancyvrb" /><a 6389 id="x1-99056r28"></a><span 6390class="cmr-6">28</span><span 6391class="cmtt-8"> </span><span 6392class="cmtt-8"> </span><span 6393class="cmtt-8"> 13)</span><span 6394class="cmtt-8"> [floor1_multiplier]</span><span 6395class="cmtt-8"> =</span><span 6396class="cmtt-8"> read</span><span 6397class="cmtt-8"> 2</span><span 6398class="cmtt-8"> bits</span><span 6399class="cmtt-8"> as</span><span 6400class="cmtt-8"> unsigned</span><span 6401class="cmtt-8"> integer</span><span 6402class="cmtt-8"> and</span><span 6403class="cmtt-8"> add</span><span 6404class="cmtt-8"> one</span> 6405<br class="fancyvrb" /><a 6406 id="x1-99058r29"></a><span 6407class="cmr-6">29</span><span 6408class="cmtt-8"> </span><span 6409class="cmtt-8"> </span><span 6410class="cmtt-8"> 14)</span><span 6411class="cmtt-8"> [rangebits]</span><span 6412class="cmtt-8"> =</span><span 6413class="cmtt-8"> read</span><span 6414class="cmtt-8"> 4</span><span 6415class="cmtt-8"> bits</span><span 6416class="cmtt-8"> as</span><span 6417class="cmtt-8"> unsigned</span><span 6418class="cmtt-8"> integer</span> 6419<br class="fancyvrb" /><a 6420 id="x1-99060r30"></a><span 6421class="cmr-6">30</span><span 6422class="cmtt-8"> </span><span 6423class="cmtt-8"> </span><span 6424class="cmtt-8"> 15)</span><span 6425class="cmtt-8"> vector</span><span 6426class="cmtt-8"> [floor1_X_list]</span><span 6427class="cmtt-8"> element</span><span 6428class="cmtt-8"> [0]</span><span 6429class="cmtt-8"> =</span><span 6430class="cmtt-8"> 0</span> 6431<br class="fancyvrb" /><a 6432 id="x1-99062r31"></a><span 6433class="cmr-6">31</span><span 6434class="cmtt-8"> </span><span 6435class="cmtt-8"> </span><span 6436class="cmtt-8"> 16)</span><span 6437class="cmtt-8"> vector</span><span 6438class="cmtt-8"> [floor1_X_list]</span><span 6439class="cmtt-8"> element</span><span 6440class="cmtt-8"> [1]</span><span 6441class="cmtt-8"> =</span><span 6442class="cmtt-8"> 2</span><span 6443class="cmtt-8"> exponent</span><span 6444class="cmtt-8"> [rangebits];</span> 6445<br class="fancyvrb" /><a 6446 id="x1-99064r32"></a><span 6447class="cmr-6">32</span><span 6448class="cmtt-8"> </span><span 6449class="cmtt-8"> </span><span 6450class="cmtt-8"> 17)</span><span 6451class="cmtt-8"> [floor1_values]</span><span 6452class="cmtt-8"> =</span><span 6453class="cmtt-8"> 2</span> 6454<br class="fancyvrb" /><a 6455 id="x1-99066r33"></a><span 6456class="cmr-6">33</span><span 6457class="cmtt-8"> </span><span 6458class="cmtt-8"> </span><span 6459class="cmtt-8"> 18)</span><span 6460class="cmtt-8"> iterate</span><span 6461class="cmtt-8"> [i]</span><span 6462class="cmtt-8"> over</span><span 6463class="cmtt-8"> the</span><span 6464class="cmtt-8"> range</span><span 6465class="cmtt-8"> 0</span><span 6466class="cmtt-8"> ...</span><span 6467class="cmtt-8"> [floor1_partitions]-1</span><span 6468class="cmtt-8"> </span><span 6469class="cmsy-8">{</span> 6470<br class="fancyvrb" /><a 6471 id="x1-99068r34"></a><span 6472class="cmr-6">34</span><span 6473class="cmtt-8"> </span><span 6474class="cmtt-8"> </span> 6475<br class="fancyvrb" /><a 6476 id="x1-99070r35"></a><span 6477class="cmr-6">35</span><span 6478class="cmtt-8"> </span><span 6479class="cmtt-8"> </span><span 6480class="cmtt-8"> </span><span 6481class="cmtt-8"> </span><span 6482class="cmtt-8"> </span><span 6483class="cmtt-8"> </span><span 6484class="cmtt-8"> </span><span 6485class="cmtt-8"> </span><span 6486class="cmtt-8"> 19)</span><span 6487class="cmtt-8"> [current_class_number]</span><span 6488class="cmtt-8"> =</span><span 6489class="cmtt-8"> vector</span><span 6490class="cmtt-8"> [floor1_partition_class_list]</span><span 6491class="cmtt-8"> element</span><span 6492class="cmtt-8"> [i]</span> 6493<br class="fancyvrb" /><a 6494 id="x1-99072r36"></a><span 6495class="cmr-6">36</span><span 6496class="cmtt-8"> </span><span 6497class="cmtt-8"> </span><span 6498class="cmtt-8"> </span><span 6499class="cmtt-8"> </span><span 6500class="cmtt-8"> </span><span 6501class="cmtt-8"> </span><span 6502class="cmtt-8"> </span><span 6503class="cmtt-8"> </span><span 6504class="cmtt-8"> 20)</span><span 6505class="cmtt-8"> iterate</span><span 6506class="cmtt-8"> [j]</span><span 6507class="cmtt-8"> over</span><span 6508class="cmtt-8"> the</span><span 6509class="cmtt-8"> range</span><span 6510class="cmtt-8"> 0</span><span 6511class="cmtt-8"> ...</span><span 6512class="cmtt-8"> ([floor1_class_dimensions]</span><span 6513class="cmtt-8"> element</span><span 6514class="cmtt-8"> [current_class_number])-1</span><span 6515class="cmtt-8"> </span><span 6516class="cmsy-8">{</span> 6517<br class="fancyvrb" /><a 6518 id="x1-99074r37"></a><span 6519class="cmr-6">37</span><span 6520class="cmtt-8"> </span><span 6521class="cmtt-8"> </span><span 6522class="cmtt-8"> </span><span 6523class="cmtt-8"> </span><span 6524class="cmtt-8"> </span><span 6525class="cmtt-8"> </span><span 6526class="cmtt-8"> </span><span 6527class="cmtt-8"> </span><span 6528class="cmtt-8"> </span><span 6529class="cmtt-8"> </span><span 6530class="cmtt-8"> </span><span 6531class="cmtt-8"> </span><span 6532class="cmtt-8"> </span><span 6533class="cmtt-8"> </span><span 6534class="cmtt-8"> 21)</span><span 6535class="cmtt-8"> vector</span><span 6536class="cmtt-8"> [floor1_X_list]</span><span 6537class="cmtt-8"> element</span><span 6538class="cmtt-8"> ([floor1_values])</span><span 6539class="cmtt-8"> =</span> 6540<br class="fancyvrb" /><a 6541 id="x1-99076r38"></a><span 6542class="cmr-6">38</span><span 6543class="cmtt-8"> </span><span 6544class="cmtt-8"> </span><span 6545class="cmtt-8"> </span><span 6546class="cmtt-8"> </span><span 6547class="cmtt-8"> </span><span 6548class="cmtt-8"> </span><span 6549class="cmtt-8"> </span><span 6550class="cmtt-8"> </span><span 6551class="cmtt-8"> </span><span 6552class="cmtt-8"> </span><span 6553class="cmtt-8"> </span><span 6554class="cmtt-8"> </span><span 6555class="cmtt-8"> </span><span 6556class="cmtt-8"> </span><span 6557class="cmtt-8"> </span><span 6558class="cmtt-8"> </span><span 6559class="cmtt-8"> </span><span 6560class="cmtt-8"> </span><span 6561class="cmtt-8"> read</span><span 6562class="cmtt-8"> [rangebits]</span><span 6563class="cmtt-8"> bits</span><span 6564class="cmtt-8"> as</span><span 6565class="cmtt-8"> unsigned</span><span 6566class="cmtt-8"> integer</span> 6567<br class="fancyvrb" /><a 6568 id="x1-99078r39"></a><span 6569class="cmr-6">39</span><span 6570class="cmtt-8"> </span><span 6571class="cmtt-8"> </span><span 6572class="cmtt-8"> </span><span 6573class="cmtt-8"> </span><span 6574class="cmtt-8"> </span><span 6575class="cmtt-8"> </span><span 6576class="cmtt-8"> </span><span 6577class="cmtt-8"> </span><span 6578class="cmtt-8"> </span><span 6579class="cmtt-8"> </span><span 6580class="cmtt-8"> </span><span 6581class="cmtt-8"> </span><span 6582class="cmtt-8"> </span><span 6583class="cmtt-8"> </span><span 6584class="cmtt-8"> 22)</span><span 6585class="cmtt-8"> increment</span><span 6586class="cmtt-8"> [floor1_values]</span><span 6587class="cmtt-8"> by</span><span 6588class="cmtt-8"> one</span> 6589<br class="fancyvrb" /><a 6590 id="x1-99080r40"></a><span 6591class="cmr-6">40</span><span 6592class="cmtt-8"> </span><span 6593class="cmtt-8"> </span><span 6594class="cmtt-8"> </span><span 6595class="cmtt-8"> </span><span 6596class="cmtt-8"> </span><span 6597class="cmtt-8"> </span><span 6598class="cmtt-8"> </span><span 6599class="cmtt-8"> </span><span 6600class="cmtt-8"> </span><span 6601class="cmtt-8"> </span><span 6602class="cmtt-8"> </span><span 6603class="cmtt-8"> </span><span 6604class="cmtt-8"> </span><span 6605class="cmsy-8">}</span> 6606<br class="fancyvrb" /><a 6607 id="x1-99082r41"></a><span 6608class="cmr-6">41</span><span 6609class="cmtt-8"> </span><span 6610class="cmtt-8"> </span><span 6611class="cmtt-8"> </span><span 6612class="cmtt-8"> </span><span 6613class="cmtt-8"> </span><span 6614class="cmtt-8"> </span><span 6615class="cmtt-8"> </span><span 6616class="cmsy-8">}</span> 6617<br class="fancyvrb" /><a 6618 id="x1-99084r42"></a><span 6619class="cmr-6">42</span><span 6620class="cmtt-8"> </span><span 6621class="cmtt-8"> </span> 6622<br class="fancyvrb" /><a 6623 id="x1-99086r43"></a><span 6624class="cmr-6">43</span><span 6625class="cmtt-8"> </span><span 6626class="cmtt-8"> </span><span 6627class="cmtt-8"> 23)</span><span 6628class="cmtt-8"> done</span> 6629</div> 6630<!--l. 158--><p class="noindent" >An end-of-packet condition while reading any aspect of a floor 1 configuration during 6631setup renders a stream undecodable. In addition, a <span 6632class="cmtt-12">[floor1_class_masterbooks] </span>or 6633<span 6634class="cmtt-12">[floor1_subclass_books] </span>scalar element greater than the highest numbered codebook 6635configured in this stream is an error condition that renders the stream undecodable. All vector 6636[floor1˙x˙list] element values must be unique within the vector; a non-unique value renders the 6637stream undecodable. 6638<!--l. 167--><p class="noindent" ><span class="paragraphHead"><a 6639 id="x1-1000007.2.2"></a><span 6640class="cmbx-12">packet decode</span></span> 6641 6642 6643 6644Packet decode begins by checking the <span 6645class="cmtt-12">[nonzero] </span>flag: 6646<!--l. 171--><p class="noindent" > 6647<div class="fancyvrb" id="fancyvrb29"> 6648<a 6649 id="x1-100002r1"></a><span 6650class="cmr-6">1</span><span 6651class="cmtt-8"> </span><span 6652class="cmtt-8"> </span><span 6653class="cmtt-8"> </span><span 6654class="cmtt-8"> 1)</span><span 6655class="cmtt-8"> [nonzero]</span><span 6656class="cmtt-8"> =</span><span 6657class="cmtt-8"> read</span><span 6658class="cmtt-8"> 1</span><span 6659class="cmtt-8"> bit</span><span 6660class="cmtt-8"> as</span><span 6661class="cmtt-8"> boolean</span> 6662</div> 6663<!--l. 175--><p class="noindent" >If <span 6664class="cmtt-12">[nonzero] </span>is unset, that indicates this channel contained no audio energy in this frame. 6665Decode immediately returns a status indicating this floor curve (and thus this channel) is unused 6666this frame. (A return status of ’unused’ is different from decoding a floor that has all 6667points set to minimum representation amplitude, which happens to be approximately 6668-140dB). 6669<!--l. 183--><p class="noindent" >Assuming <span 6670class="cmtt-12">[nonzero] </span>is set, decode proceeds as follows: 6671<!--l. 185--><p class="noindent" > 6672<div class="fancyvrb" id="fancyvrb30"> 6673<a 6674 id="x1-100004r1"></a><span 6675class="cmr-6">1</span><span 6676class="cmtt-8"> </span><span 6677class="cmtt-8"> </span><span 6678class="cmtt-8"> </span><span 6679class="cmtt-8"> 1)</span><span 6680class="cmtt-8"> [range]</span><span 6681class="cmtt-8"> =</span><span 6682class="cmtt-8"> vector</span><span 6683class="cmtt-8"> </span><span 6684class="cmsy-8">{</span><span 6685class="cmtt-8"> 256,</span><span 6686class="cmtt-8"> 128,</span><span 6687class="cmtt-8"> 86,</span><span 6688class="cmtt-8"> 64</span><span 6689class="cmtt-8"> </span><span 6690class="cmsy-8">}</span><span 6691class="cmtt-8"> element</span><span 6692class="cmtt-8"> ([floor1_multiplier]-1)</span> 6693<br class="fancyvrb" /><a 6694 id="x1-100006r2"></a><span 6695class="cmr-6">2</span><span 6696class="cmtt-8"> </span><span 6697class="cmtt-8"> </span><span 6698class="cmtt-8"> </span><span 6699class="cmtt-8"> 2)</span><span 6700class="cmtt-8"> vector</span><span 6701class="cmtt-8"> [floor1_Y]</span><span 6702class="cmtt-8"> element</span><span 6703class="cmtt-8"> [0]</span><span 6704class="cmtt-8"> =</span><span 6705class="cmtt-8"> read</span><span 6706class="cmtt-8"> </span><a 6707href="#x1-1170009.2.1"><span 6708class="cmtt-8">ilog</span></a><span 6709class="cmtt-8">([range]-1)</span><span 6710class="cmtt-8"> bits</span><span 6711class="cmtt-8"> as</span><span 6712class="cmtt-8"> unsigned</span><span 6713class="cmtt-8"> integer</span> 6714<br class="fancyvrb" /><a 6715 id="x1-100008r3"></a><span 6716class="cmr-6">3</span><span 6717class="cmtt-8"> </span><span 6718class="cmtt-8"> </span><span 6719class="cmtt-8"> </span><span 6720class="cmtt-8"> 3)</span><span 6721class="cmtt-8"> vector</span><span 6722class="cmtt-8"> [floor1_Y]</span><span 6723class="cmtt-8"> element</span><span 6724class="cmtt-8"> [1]</span><span 6725class="cmtt-8"> =</span><span 6726class="cmtt-8"> read</span><span 6727class="cmtt-8"> </span><a 6728href="#x1-1170009.2.1"><span 6729class="cmtt-8">ilog</span></a><span 6730class="cmtt-8">([range]-1)</span><span 6731class="cmtt-8"> bits</span><span 6732class="cmtt-8"> as</span><span 6733class="cmtt-8"> unsigned</span><span 6734class="cmtt-8"> integer</span> 6735<br class="fancyvrb" /><a 6736 id="x1-100010r4"></a><span 6737class="cmr-6">4</span><span 6738class="cmtt-8"> </span><span 6739class="cmtt-8"> </span><span 6740class="cmtt-8"> </span><span 6741class="cmtt-8"> 4)</span><span 6742class="cmtt-8"> [offset]</span><span 6743class="cmtt-8"> =</span><span 6744class="cmtt-8"> 2;</span> 6745<br class="fancyvrb" /><a 6746 id="x1-100012r5"></a><span 6747class="cmr-6">5</span><span 6748class="cmtt-8"> </span><span 6749class="cmtt-8"> </span><span 6750class="cmtt-8"> </span><span 6751class="cmtt-8"> 5)</span><span 6752class="cmtt-8"> iterate</span><span 6753class="cmtt-8"> [i]</span><span 6754class="cmtt-8"> over</span><span 6755class="cmtt-8"> the</span><span 6756class="cmtt-8"> range</span><span 6757class="cmtt-8"> 0</span><span 6758class="cmtt-8"> ...</span><span 6759class="cmtt-8"> [floor1_partitions]-1</span><span 6760class="cmtt-8"> </span><span 6761class="cmsy-8">{</span> 6762<br class="fancyvrb" /><a 6763 id="x1-100014r6"></a><span 6764class="cmr-6">6</span><span 6765class="cmtt-8"> </span><span 6766class="cmtt-8"> </span> 6767<br class="fancyvrb" /><a 6768 id="x1-100016r7"></a><span 6769class="cmr-6">7</span><span 6770class="cmtt-8"> </span><span 6771class="cmtt-8"> </span><span 6772class="cmtt-8"> </span><span 6773class="cmtt-8"> </span><span 6774class="cmtt-8"> </span><span 6775class="cmtt-8"> </span><span 6776class="cmtt-8"> </span><span 6777class="cmtt-8"> </span><span 6778class="cmtt-8"> 6)</span><span 6779class="cmtt-8"> [class]</span><span 6780class="cmtt-8"> =</span><span 6781class="cmtt-8"> vector</span><span 6782class="cmtt-8"> [floor1_partition_class]</span><span 6783class="cmtt-8"> </span><span 6784class="cmtt-8"> element</span><span 6785class="cmtt-8"> [i]</span> 6786<br class="fancyvrb" /><a 6787 id="x1-100018r8"></a><span 6788class="cmr-6">8</span><span 6789class="cmtt-8"> </span><span 6790class="cmtt-8"> </span><span 6791class="cmtt-8"> </span><span 6792class="cmtt-8"> </span><span 6793class="cmtt-8"> </span><span 6794class="cmtt-8"> </span><span 6795class="cmtt-8"> </span><span 6796class="cmtt-8"> </span><span 6797class="cmtt-8"> 7)</span><span 6798class="cmtt-8"> [cdim]</span><span 6799class="cmtt-8"> </span><span 6800class="cmtt-8"> =</span><span 6801class="cmtt-8"> vector</span><span 6802class="cmtt-8"> [floor1_class_dimensions]</span><span 6803class="cmtt-8"> element</span><span 6804class="cmtt-8"> [class]</span> 6805<br class="fancyvrb" /><a 6806 id="x1-100020r9"></a><span 6807class="cmr-6">9</span><span 6808class="cmtt-8"> </span><span 6809class="cmtt-8"> </span><span 6810class="cmtt-8"> </span><span 6811class="cmtt-8"> </span><span 6812class="cmtt-8"> </span><span 6813class="cmtt-8"> </span><span 6814class="cmtt-8"> </span><span 6815class="cmtt-8"> </span><span 6816class="cmtt-8"> 8)</span><span 6817class="cmtt-8"> [cbits]</span><span 6818class="cmtt-8"> =</span><span 6819class="cmtt-8"> vector</span><span 6820class="cmtt-8"> [floor1_class_subclasses]</span><span 6821class="cmtt-8"> element</span><span 6822class="cmtt-8"> [class]</span> 6823<br class="fancyvrb" /><a 6824 id="x1-100022r10"></a><span 6825class="cmr-6">10</span><span 6826class="cmtt-8"> </span><span 6827class="cmtt-8"> </span><span 6828class="cmtt-8"> </span><span 6829class="cmtt-8"> </span><span 6830class="cmtt-8"> </span><span 6831class="cmtt-8"> </span><span 6832class="cmtt-8"> </span><span 6833class="cmtt-8"> </span><span 6834class="cmtt-8"> 9)</span><span 6835class="cmtt-8"> [csub]</span><span 6836class="cmtt-8"> </span><span 6837class="cmtt-8"> =</span><span 6838class="cmtt-8"> (2</span><span 6839class="cmtt-8"> exponent</span><span 6840class="cmtt-8"> [cbits])-1</span> 6841<br class="fancyvrb" /><a 6842 id="x1-100024r11"></a><span 6843class="cmr-6">11</span><span 6844class="cmtt-8"> </span><span 6845class="cmtt-8"> </span><span 6846class="cmtt-8"> </span><span 6847class="cmtt-8"> </span><span 6848class="cmtt-8"> </span><span 6849class="cmtt-8"> </span><span 6850class="cmtt-8"> </span><span 6851class="cmtt-8"> 10)</span><span 6852class="cmtt-8"> [cval]</span><span 6853class="cmtt-8"> </span><span 6854class="cmtt-8"> =</span><span 6855class="cmtt-8"> 0</span> 6856<br class="fancyvrb" /><a 6857 id="x1-100026r12"></a><span 6858class="cmr-6">12</span><span 6859class="cmtt-8"> </span><span 6860class="cmtt-8"> </span><span 6861class="cmtt-8"> </span><span 6862class="cmtt-8"> </span><span 6863class="cmtt-8"> </span><span 6864class="cmtt-8"> </span><span 6865class="cmtt-8"> </span><span 6866class="cmtt-8"> 11)</span><span 6867class="cmtt-8"> if</span><span 6868class="cmtt-8"> (</span><span 6869class="cmtt-8"> [cbits]</span><span 6870class="cmtt-8"> is</span><span 6871class="cmtt-8"> greater</span><span 6872class="cmtt-8"> than</span><span 6873class="cmtt-8"> zero</span><span 6874class="cmtt-8"> )</span><span 6875class="cmtt-8"> </span><span 6876class="cmsy-8">{</span> 6877<br class="fancyvrb" /><a 6878 id="x1-100028r13"></a><span 6879class="cmr-6">13</span><span 6880class="cmtt-8"> </span><span 6881class="cmtt-8"> </span> 6882<br class="fancyvrb" /><a 6883 id="x1-100030r14"></a><span 6884class="cmr-6">14</span><span 6885class="cmtt-8"> </span><span 6886class="cmtt-8"> </span><span 6887class="cmtt-8"> </span><span 6888class="cmtt-8"> </span><span 6889class="cmtt-8"> </span><span 6890class="cmtt-8"> </span><span 6891class="cmtt-8"> </span><span 6892class="cmtt-8"> </span><span 6893class="cmtt-8"> </span><span 6894class="cmtt-8"> </span><span 6895class="cmtt-8"> </span><span 6896class="cmtt-8"> </span><span 6897class="cmtt-8"> </span><span 6898class="cmtt-8"> </span><span 6899class="cmtt-8"> 12)</span><span 6900class="cmtt-8"> [cval]</span><span 6901class="cmtt-8"> =</span><span 6902class="cmtt-8"> read</span><span 6903class="cmtt-8"> from</span><span 6904class="cmtt-8"> packet</span><span 6905class="cmtt-8"> using</span><span 6906class="cmtt-8"> codebook</span><span 6907class="cmtt-8"> number</span> 6908<br class="fancyvrb" /><a 6909 id="x1-100032r15"></a><span 6910class="cmr-6">15</span><span 6911class="cmtt-8"> </span><span 6912class="cmtt-8"> </span><span 6913class="cmtt-8"> </span><span 6914class="cmtt-8"> </span><span 6915class="cmtt-8"> </span><span 6916class="cmtt-8"> </span><span 6917class="cmtt-8"> </span><span 6918class="cmtt-8"> </span><span 6919class="cmtt-8"> </span><span 6920class="cmtt-8"> </span><span 6921class="cmtt-8"> </span><span 6922class="cmtt-8"> </span><span 6923class="cmtt-8"> </span><span 6924class="cmtt-8"> </span><span 6925class="cmtt-8"> </span><span 6926class="cmtt-8"> </span><span 6927class="cmtt-8"> </span><span 6928class="cmtt-8"> </span><span 6929class="cmtt-8"> (vector</span><span 6930class="cmtt-8"> [floor1_class_masterbooks]</span><span 6931class="cmtt-8"> element</span><span 6932class="cmtt-8"> [class])</span><span 6933class="cmtt-8"> in</span><span 6934class="cmtt-8"> scalar</span><span 6935class="cmtt-8"> context</span> 6936<br class="fancyvrb" /><a 6937 id="x1-100034r16"></a><span 6938class="cmr-6">16</span><span 6939class="cmtt-8"> </span><span 6940class="cmtt-8"> </span><span 6941class="cmtt-8"> </span><span 6942class="cmtt-8"> </span><span 6943class="cmtt-8"> </span><span 6944class="cmtt-8"> </span><span 6945class="cmtt-8"> </span><span 6946class="cmtt-8"> </span><span 6947class="cmtt-8"> </span><span 6948class="cmtt-8"> </span><span 6949class="cmtt-8"> </span><span 6950class="cmtt-8"> </span><span 6951class="cmsy-8">}</span> 6952<br class="fancyvrb" /><a 6953 id="x1-100036r17"></a><span 6954class="cmr-6">17</span><span 6955class="cmtt-8"> </span><span 6956class="cmtt-8"> </span> 6957<br class="fancyvrb" /><a 6958 id="x1-100038r18"></a><span 6959class="cmr-6">18</span><span 6960class="cmtt-8"> </span><span 6961class="cmtt-8"> </span><span 6962class="cmtt-8"> </span><span 6963class="cmtt-8"> </span><span 6964class="cmtt-8"> </span><span 6965class="cmtt-8"> </span><span 6966class="cmtt-8"> </span><span 6967class="cmtt-8"> 13)</span><span 6968class="cmtt-8"> iterate</span><span 6969class="cmtt-8"> [j]</span><span 6970class="cmtt-8"> over</span><span 6971class="cmtt-8"> the</span><span 6972class="cmtt-8"> range</span><span 6973class="cmtt-8"> 0</span><span 6974class="cmtt-8"> ...</span><span 6975class="cmtt-8"> [cdim]-1</span><span 6976class="cmtt-8"> </span><span 6977class="cmsy-8">{</span> 6978<br class="fancyvrb" /><a 6979 id="x1-100040r19"></a><span 6980class="cmr-6">19</span><span 6981class="cmtt-8"> </span><span 6982class="cmtt-8"> </span> 6983<br class="fancyvrb" /><a 6984 id="x1-100042r20"></a><span 6985class="cmr-6">20</span><span 6986class="cmtt-8"> </span><span 6987class="cmtt-8"> </span><span 6988class="cmtt-8"> </span><span 6989class="cmtt-8"> </span><span 6990class="cmtt-8"> </span><span 6991class="cmtt-8"> </span><span 6992class="cmtt-8"> </span><span 6993class="cmtt-8"> </span><span 6994class="cmtt-8"> </span><span 6995class="cmtt-8"> </span><span 6996class="cmtt-8"> </span><span 6997class="cmtt-8"> </span><span 6998class="cmtt-8"> </span><span 6999class="cmtt-8"> </span><span 7000class="cmtt-8"> 14)</span><span 7001class="cmtt-8"> [book]</span><span 7002class="cmtt-8"> =</span><span 7003class="cmtt-8"> array</span><span 7004class="cmtt-8"> [floor1_subclass_books]</span><span 7005class="cmtt-8"> element</span><span 7006class="cmtt-8"> [class],([cval]</span><span 7007class="cmtt-8"> bitwise</span><span 7008class="cmtt-8"> AND</span><span 7009class="cmtt-8"> [csub])</span> 7010<br class="fancyvrb" /><a 7011 id="x1-100044r21"></a><span 7012class="cmr-6">21</span><span 7013class="cmtt-8"> </span><span 7014class="cmtt-8"> </span><span 7015class="cmtt-8"> </span><span 7016class="cmtt-8"> </span><span 7017class="cmtt-8"> </span><span 7018class="cmtt-8"> </span><span 7019class="cmtt-8"> </span><span 7020class="cmtt-8"> </span><span 7021class="cmtt-8"> </span><span 7022class="cmtt-8"> </span><span 7023class="cmtt-8"> </span><span 7024class="cmtt-8"> </span><span 7025class="cmtt-8"> </span><span 7026class="cmtt-8"> </span><span 7027class="cmtt-8"> 15)</span><span 7028class="cmtt-8"> [cval]</span><span 7029class="cmtt-8"> =</span><span 7030class="cmtt-8"> [cval]</span><span 7031class="cmtt-8"> right</span><span 7032class="cmtt-8"> shifted</span><span 7033class="cmtt-8"> [cbits]</span><span 7034class="cmtt-8"> bits</span> 7035<br class="fancyvrb" /><a 7036 id="x1-100046r22"></a><span 7037class="cmr-6">22</span><span 7038class="cmtt-8"> </span><span 7039class="cmtt-8">  </span><span 7040class="cmtt-8"> </span><span 7041class="cmtt-8"> </span><span 7042class="cmtt-8"> </span><span 7043class="cmtt-8"> </span><span 7044class="cmtt-8"> 16)</span><span 7045class="cmtt-8"> if</span><span 7046class="cmtt-8"> (</span><span 7047class="cmtt-8"> [book]</span><span 7048class="cmtt-8"> is</span><span 7049class="cmtt-8"> not</span><span 7050class="cmtt-8"> less</span><span 7051class="cmtt-8"> than</span><span 7052class="cmtt-8"> zero</span><span 7053class="cmtt-8"> )</span><span 7054class="cmtt-8"> </span><span 7055class="cmsy-8">{</span> 7056<br class="fancyvrb" /><a 7057 id="x1-100048r23"></a><span 7058class="cmr-6">23</span><span 7059class="cmtt-8"> </span><span 7060class="cmtt-8"> </span> 7061<br class="fancyvrb" /><a 7062 id="x1-100050r24"></a><span 7063class="cmr-6">24</span><span 7064class="cmtt-8"> </span><span 7065class="cmtt-8">  </span><span 7066class="cmtt-8"> </span><span 7067class="cmtt-8"> </span><span 7068class="cmtt-8"> </span><span 7069class="cmtt-8"> </span><span 7070class="cmtt-8"> </span><span 7071class="cmtt-8"> </span><span 7072class="cmtt-8"> </span><span 7073class="cmtt-8"> </span><span 7074class="cmtt-8"> </span><span 7075class="cmtt-8"> </span><span 7076class="cmtt-8"> 17)</span><span 7077class="cmtt-8"> vector</span><span 7078class="cmtt-8"> [floor1_Y]</span><span 7079class="cmtt-8"> element</span><span 7080class="cmtt-8"> ([j]+[offset])</span><span 7081class="cmtt-8"> =</span><span 7082class="cmtt-8"> read</span><span 7083class="cmtt-8"> from</span><span 7084class="cmtt-8"> packet</span><span 7085class="cmtt-8"> using</span><span 7086class="cmtt-8"> codebook</span> 7087<br class="fancyvrb" /><a 7088 id="x1-100052r25"></a><span 7089class="cmr-6">25</span><span 7090class="cmtt-8"> </span><span 7091class="cmtt-8"> </span><span 7092class="cmtt-8"> </span><span 7093class="cmtt-8"> </span><span 7094class="cmtt-8"> </span><span 7095class="cmtt-8"> </span><span 7096class="cmtt-8"> </span><span 7097class="cmtt-8"> </span><span 7098class="cmtt-8"> </span><span 7099class="cmtt-8"> </span><span 7100class="cmtt-8"> </span><span 7101class="cmtt-8"> </span><span 7102class="cmtt-8"> </span><span 7103class="cmtt-8"> </span><span 7104class="cmtt-8"> </span><span 7105class="cmtt-8"> </span><span 7106class="cmtt-8"> </span><span 7107class="cmtt-8"> </span><span 7108class="cmtt-8"> </span><span 7109class="cmtt-8"> </span><span 7110class="cmtt-8"> </span><span 7111class="cmtt-8"> </span><span 7112class="cmtt-8"> </span><span 7113class="cmtt-8"> </span><span 7114class="cmtt-8"> [book]</span><span 7115class="cmtt-8"> in</span><span 7116class="cmtt-8"> scalar</span><span 7117class="cmtt-8"> context</span> 7118<br class="fancyvrb" /><a 7119 id="x1-100054r26"></a><span 7120class="cmr-6">26</span><span 7121class="cmtt-8"> </span><span 7122class="cmtt-8"> </span> 7123<br class="fancyvrb" /><a 7124 id="x1-100056r27"></a><span 7125class="cmr-6">27</span><span 7126class="cmtt-8"> </span><span 7127class="cmtt-8"> </span><span 7128class="cmtt-8"> </span><span 7129class="cmtt-8"> </span><span 7130class="cmtt-8"> </span><span 7131class="cmtt-8"> </span><span 7132class="cmtt-8"> </span><span 7133class="cmtt-8"> </span><span 7134class="cmtt-8"> </span><span 7135class="cmtt-8"> </span><span 7136class="cmtt-8"> </span><span 7137class="cmtt-8"> </span><span 7138class="cmtt-8"> </span><span 7139class="cmtt-8"> </span><span 7140class="cmtt-8"> </span><span 7141class="cmtt-8"> </span><span 7142class="cmtt-8"> </span><span 7143class="cmtt-8"> </span><span 7144class="cmtt-8"> </span><span 7145class="cmsy-8">}</span><span 7146class="cmtt-8"> else</span><span 7147class="cmtt-8"> [book]</span><span 7148class="cmtt-8"> is</span><span 7149class="cmtt-8"> less</span><span 7150class="cmtt-8"> than</span><span 7151class="cmtt-8"> zero</span><span 7152class="cmtt-8"> </span><span 7153class="cmsy-8">{</span> 7154<br class="fancyvrb" /><a 7155 id="x1-100058r28"></a><span 7156class="cmr-6">28</span><span 7157class="cmtt-8"> </span><span 7158class="cmtt-8"> </span> 7159<br class="fancyvrb" /><a 7160 id="x1-100060r29"></a><span 7161class="cmr-6">29</span><span 7162class="cmtt-8"> </span><span 7163class="cmtt-8">  </span><span 7164class="cmtt-8"> </span><span 7165class="cmtt-8"> </span><span 7166class="cmtt-8"> </span><span 7167class="cmtt-8"> </span><span 7168class="cmtt-8"> </span><span 7169class="cmtt-8"> </span><span 7170class="cmtt-8"> </span><span 7171class="cmtt-8"> </span><span 7172class="cmtt-8"> </span><span 7173class="cmtt-8"> </span><span 7174class="cmtt-8"> 18)</span><span 7175class="cmtt-8"> vector</span><span 7176class="cmtt-8"> [floor1_Y]</span><span 7177class="cmtt-8"> element</span><span 7178class="cmtt-8"> ([j]+[offset])</span><span 7179class="cmtt-8"> =</span><span 7180class="cmtt-8"> 0</span> 7181<br class="fancyvrb" /><a 7182 id="x1-100062r30"></a><span 7183class="cmr-6">30</span><span 7184class="cmtt-8"> </span><span 7185class="cmtt-8"> </span> 7186<br class="fancyvrb" /><a 7187 id="x1-100064r31"></a><span 7188class="cmr-6">31</span><span 7189class="cmtt-8"> </span><span 7190class="cmtt-8"> </span><span 7191class="cmtt-8"> </span><span 7192class="cmtt-8"> </span><span 7193class="cmtt-8"> </span><span 7194class="cmtt-8"> </span><span 7195class="cmtt-8"> </span><span 7196class="cmtt-8"> </span><span 7197class="cmtt-8"> </span><span 7198class="cmtt-8"> </span><span 7199class="cmtt-8"> </span><span 7200class="cmtt-8"> </span><span 7201class="cmtt-8"> </span><span 7202class="cmtt-8"> </span><span 7203class="cmtt-8"> </span><span 7204class="cmtt-8"> </span><span 7205class="cmtt-8"> </span><span 7206class="cmtt-8"> </span><span 7207class="cmtt-8"> </span><span 7208class="cmsy-8">}</span> 7209<br class="fancyvrb" /><a 7210 id="x1-100066r32"></a><span 7211class="cmr-6">32</span><span 7212class="cmtt-8"> </span><span 7213class="cmtt-8"> </span><span 7214class="cmtt-8"> </span><span 7215class="cmtt-8"> </span><span 7216class="cmtt-8"> </span><span 7217class="cmtt-8"> </span><span 7218class="cmtt-8"> </span><span 7219class="cmtt-8"> </span><span 7220class="cmtt-8"> </span><span 7221class="cmtt-8"> </span><span 7222class="cmtt-8"> </span><span 7223class="cmtt-8"> </span><span 7224class="cmsy-8">}</span> 7225<br class="fancyvrb" /><a 7226 id="x1-100068r33"></a><span 7227class="cmr-6">33</span><span 7228class="cmtt-8"> </span><span 7229class="cmtt-8"> </span> 7230<br class="fancyvrb" /><a 7231 id="x1-100070r34"></a><span 7232class="cmr-6">34</span><span 7233class="cmtt-8"> </span><span 7234class="cmtt-8"> </span><span 7235class="cmtt-8"> </span><span 7236class="cmtt-8"> </span><span 7237class="cmtt-8"> </span><span 7238class="cmtt-8"> </span><span 7239class="cmtt-8"> </span><span 7240class="cmtt-8"> 19)</span><span 7241class="cmtt-8"> [offset]</span><span 7242class="cmtt-8"> =</span><span 7243class="cmtt-8"> [offset]</span><span 7244class="cmtt-8"> +</span><span 7245class="cmtt-8"> [cdim]</span> 7246<br class="fancyvrb" /><a 7247 id="x1-100072r35"></a><span 7248class="cmr-6">35</span><span 7249class="cmtt-8"> </span><span 7250class="cmtt-8"> </span> 7251<br class="fancyvrb" /><a 7252 id="x1-100074r36"></a><span 7253class="cmr-6">36</span><span 7254class="cmtt-8"> </span><span 7255class="cmtt-8"> </span><span 7256class="cmtt-8"> </span><span 7257class="cmtt-8"> </span><span 7258class="cmtt-8"> </span><span 7259class="cmtt-8"> </span><span 7260class="cmtt-8"> </span><span 7261class="cmsy-8">}</span> 7262<br class="fancyvrb" /><a 7263 id="x1-100076r37"></a><span 7264class="cmr-6">37</span><span 7265class="cmtt-8"> </span><span 7266class="cmtt-8"> </span> 7267<br class="fancyvrb" /><a 7268 id="x1-100078r38"></a><span 7269class="cmr-6">38</span><span 7270class="cmtt-8"> </span><span 7271class="cmtt-8"> </span><span 7272class="cmtt-8"> 20)</span><span 7273class="cmtt-8"> done</span> 7274</div> 7275 7276 7277 7278<!--l. 226--><p class="noindent" >An end-of-packet condition during curve decode should be considered a nominal occurrence; if 7279end-of-packet is reached during any read operation above, floor decode is to return ’unused’ 7280status as if the <span 7281class="cmtt-12">[nonzero] </span>flag had been unset at the beginning of decode. 7282<!--l. 232--><p class="noindent" >Vector <span 7283class="cmtt-12">[floor1_Y] </span>contains the values from packet decode needed for floor 1 synthesis. 7284<!--l. 237--><p class="noindent" ><span class="paragraphHead"><a 7285 id="x1-1010007.2.2"></a><span 7286class="cmbx-12">curve computation</span></span> 7287Curve computation is split into two logical steps; the first step derives final Y amplitude values 7288from the encoded, wrapped difference values taken from the bitstream. The second step 7289plots the curve lines. Also, although zero-difference values are used in the iterative 7290prediction to find final Y values, these points are conditionally skipped during final 7291line computation in step two. Skipping zero-difference values allows a smoother line 7292fit. 7293<!--l. 247--><p class="noindent" >Although some aspects of the below algorithm look like inconsequential optimizations, 7294implementors are warned to follow the details closely. Deviation from implementing a strictly 7295equivalent algorithm can result in serious decoding errors. 7296<!--l. 252--><p class="noindent" > 7297 <dl class="description"><dt class="description"> 7298<span 7299class="cmssbx-10x-x-120">step 1: amplitude value synthesis</span> </dt><dd 7300class="description"> 7301 <!--l. 255--><p class="noindent" >Unwrap the always-positive-or-zero values read from the packet into +/- difference 7302 values, then apply to line prediction. 7303 <!--l. 258--><p class="noindent" > 7304 <div class="fancyvrb" id="fancyvrb31"> 7305<a 7306 id="x1-101002r1"></a><span 7307class="cmr-6">1</span><span 7308class="cmtt-8"> </span><span 7309class="cmtt-8"> </span><span 7310class="cmtt-8"> </span><span 7311class="cmtt-8"> 1)</span><span 7312class="cmtt-8"> [range]</span><span 7313class="cmtt-8"> =</span><span 7314class="cmtt-8"> vector</span><span 7315class="cmtt-8"> </span><span 7316class="cmsy-8">{</span><span 7317class="cmtt-8"> 256,</span><span 7318class="cmtt-8"> 128,</span><span 7319class="cmtt-8"> 86,</span><span 7320class="cmtt-8"> 64</span><span 7321class="cmtt-8"> </span><span 7322class="cmsy-8">}</span><span 7323class="cmtt-8"> element</span><span 7324class="cmtt-8"> ([floor1_multiplier]-1)</span> 7325<br class="fancyvrb" /><a 7326 id="x1-101004r2"></a><span 7327class="cmr-6">2</span><span 7328class="cmtt-8"> </span><span 7329class="cmtt-8"> </span><span 7330class="cmtt-8"> </span><span 7331class="cmtt-8"> 2)</span><span 7332class="cmtt-8"> vector</span><span 7333class="cmtt-8"> [floor1_step2_flag]</span><span 7334class="cmtt-8"> element</span><span 7335class="cmtt-8"> [0]</span><span 7336class="cmtt-8"> =</span><span 7337class="cmtt-8"> set</span> 7338<br class="fancyvrb" /><a 7339 id="x1-101006r3"></a><span 7340class="cmr-6">3</span><span 7341class="cmtt-8"> </span><span 7342class="cmtt-8"> </span><span 7343class="cmtt-8"> </span><span 7344class="cmtt-8"> 3)</span><span 7345class="cmtt-8"> vector</span><span 7346class="cmtt-8"> [floor1_step2_flag]</span><span 7347class="cmtt-8"> element</span><span 7348class="cmtt-8"> [1]</span><span 7349class="cmtt-8"> =</span><span 7350class="cmtt-8"> set</span> 7351<br class="fancyvrb" /><a 7352 id="x1-101008r4"></a><span 7353class="cmr-6">4</span><span 7354class="cmtt-8"> </span><span 7355class="cmtt-8"> </span><span 7356class="cmtt-8"> </span><span 7357class="cmtt-8"> 4)</span><span 7358class="cmtt-8"> vector</span><span 7359class="cmtt-8"> [floor1_final_Y]</span><span 7360class="cmtt-8"> element</span><span 7361class="cmtt-8"> [0]</span><span 7362class="cmtt-8"> =</span><span 7363class="cmtt-8"> vector</span><span 7364class="cmtt-8"> [floor1_Y]</span><span 7365class="cmtt-8"> element</span><span 7366class="cmtt-8"> [0]</span> 7367<br class="fancyvrb" /><a 7368 id="x1-101010r5"></a><span 7369class="cmr-6">5</span><span 7370class="cmtt-8"> </span><span 7371class="cmtt-8"> </span><span 7372class="cmtt-8"> </span><span 7373class="cmtt-8"> 5)</span><span 7374class="cmtt-8"> vector</span><span 7375class="cmtt-8"> [floor1_final_Y]</span><span 7376class="cmtt-8"> element</span><span 7377class="cmtt-8"> [1]</span><span 7378class="cmtt-8"> =</span><span 7379class="cmtt-8"> vector</span><span 7380class="cmtt-8"> [floor1_Y]</span><span 7381class="cmtt-8"> element</span><span 7382class="cmtt-8"> [1]</span> 7383<br class="fancyvrb" /><a 7384 id="x1-101012r6"></a><span 7385class="cmr-6">6</span><span 7386class="cmtt-8"> </span><span 7387class="cmtt-8"> </span><span 7388class="cmtt-8"> </span><span 7389class="cmtt-8"> 6)</span><span 7390class="cmtt-8"> iterate</span><span 7391class="cmtt-8"> [i]</span><span 7392class="cmtt-8"> over</span><span 7393class="cmtt-8"> the</span><span 7394class="cmtt-8"> range</span><span 7395class="cmtt-8"> 2</span><span 7396class="cmtt-8"> ...</span><span 7397class="cmtt-8"> [floor1_values]-1</span><span 7398class="cmtt-8"> </span><span 7399class="cmsy-8">{</span> 7400<br class="fancyvrb" /><a 7401 id="x1-101014r7"></a><span 7402class="cmr-6">7</span><span 7403class="cmtt-8"> </span><span 7404class="cmtt-8"> </span> 7405<br class="fancyvrb" /><a 7406 id="x1-101016r8"></a><span 7407class="cmr-6">8</span><span 7408class="cmtt-8"> </span><span 7409class="cmtt-8"> </span><span 7410class="cmtt-8"> </span><span 7411class="cmtt-8"> </span><span 7412class="cmtt-8"> </span><span 7413class="cmtt-8"> </span><span 7414class="cmtt-8"> </span><span 7415class="cmtt-8"> </span><span 7416class="cmtt-8"> 7)</span><span 7417class="cmtt-8"> [low_neighbor_offset]</span><span 7418class="cmtt-8"> =</span><span 7419class="cmtt-8"> </span><a 7420href="#x1-1200009.2.4"><span 7421class="cmtt-8">low_neighbor</span></a><span 7422class="cmtt-8">([floor1_X_list],[i])</span> 7423<br class="fancyvrb" /><a 7424 id="x1-101018r9"></a><span 7425class="cmr-6">9</span><span 7426class="cmtt-8"> </span><span 7427class="cmtt-8"> </span><span 7428class="cmtt-8"> </span><span 7429class="cmtt-8"> </span><span 7430class="cmtt-8"> </span><span 7431class="cmtt-8"> </span><span 7432class="cmtt-8"> </span><span 7433class="cmtt-8"> </span><span 7434class="cmtt-8"> 8)</span><span 7435class="cmtt-8"> [high_neighbor_offset]</span><span 7436class="cmtt-8"> =</span><span 7437class="cmtt-8"> </span><a 7438href="#x1-1210009.2.5"><span 7439class="cmtt-8">high_neighbor</span></a><span 7440class="cmtt-8">([floor1_X_list],[i])</span> 7441<br class="fancyvrb" /><a 7442 id="x1-101020r10"></a><span 7443class="cmr-6">10</span><span 7444class="cmtt-8"> </span><span 7445class="cmtt-8"> </span> 7446<br class="fancyvrb" /><a 7447 id="x1-101022r11"></a><span 7448class="cmr-6">11</span><span 7449class="cmtt-8"> </span><span 7450class="cmtt-8"> </span><span 7451class="cmtt-8"> </span><span 7452class="cmtt-8"> </span><span 7453class="cmtt-8"> </span><span 7454class="cmtt-8"> </span><span 7455class="cmtt-8"> </span><span 7456class="cmtt-8"> </span><span 7457class="cmtt-8"> 9)</span><span 7458class="cmtt-8"> [predicted]</span><span 7459class="cmtt-8"> =</span><span 7460class="cmtt-8"> </span><a 7461href="#x1-1220009.2.6"><span 7462class="cmtt-8">render_point</span></a><span 7463class="cmtt-8">(</span><span 7464class="cmtt-8"> vector</span><span 7465class="cmtt-8"> [floor1_X_list]</span><span 7466class="cmtt-8"> element</span><span 7467class="cmtt-8"> [low_neighbor_offset],</span> 7468<br class="fancyvrb" /><a 7469 id="x1-101024r12"></a><span 7470class="cmr-6">12</span><span 7471class="cmtt-8"> </span><span 7472class="cmtt-8">  </span><span 7473class="cmtt-8"> </span><span 7474class="cmtt-8"> </span><span 7475class="cmtt-8"> </span><span 7476class="cmtt-8"> </span><span 7477class="cmtt-8"> </span><span 7478class="cmtt-8"> vector</span><span 7479class="cmtt-8"> [floor1_final_Y]</span><span 7480class="cmtt-8"> element</span><span 7481class="cmtt-8"> [low_neighbor_offset],</span> 7482<br class="fancyvrb" /><a 7483 id="x1-101026r13"></a><span 7484class="cmr-6">13</span><span 7485class="cmtt-8"> </span><span 7486class="cmtt-8"> </span><span 7487class="cmtt-8"> </span><span 7488class="cmtt-8"> </span><span 7489class="cmtt-8"> </span><span 7490class="cmtt-8"> </span><span 7491class="cmtt-8"> </span><span 7492class="cmtt-8"> </span><span 7493class="cmtt-8"> </span><span 7494class="cmtt-8"> </span><span 7495class="cmtt-8"> </span><span 7496class="cmtt-8"> </span><span 7497class="cmtt-8"> </span><span 7498class="cmtt-8"> </span><span 7499class="cmtt-8"> </span><span 7500class="cmtt-8"> </span><span 7501class="cmtt-8"> </span><span 7502class="cmtt-8"> </span><span 7503class="cmtt-8"> </span><span 7504class="cmtt-8"> </span><span 7505class="cmtt-8"> </span><span 7506class="cmtt-8"> </span><span 7507class="cmtt-8"> </span><span 7508class="cmtt-8"> </span><span 7509class="cmtt-8"> </span><span 7510class="cmtt-8"> </span><span 7511class="cmtt-8"> </span><span 7512class="cmtt-8"> </span><span 7513class="cmtt-8"> </span><span 7514class="cmtt-8"> </span><span 7515class="cmtt-8"> </span><span 7516class="cmtt-8"> </span><span 7517class="cmtt-8"> </span><span 7518class="cmtt-8"> </span><span 7519class="cmtt-8"> </span><span 7520class="cmtt-8"> </span><span 7521class="cmtt-8"> </span><span 7522class="cmtt-8"> </span><span 7523class="cmtt-8"> </span><span 7524class="cmtt-8"> vector</span><span 7525class="cmtt-8"> [floor1_X_list]</span><span 7526class="cmtt-8"> element</span><span 7527class="cmtt-8"> [high_neighbor_offset],</span> 7528<br class="fancyvrb" /><a 7529 id="x1-101028r14"></a><span 7530class="cmr-6">14</span><span 7531class="cmtt-8"> </span><span 7532class="cmtt-8">  </span><span 7533class="cmtt-8"> </span><span 7534class="cmtt-8"> </span><span 7535class="cmtt-8"> </span><span 7536class="cmtt-8"> </span><span 7537class="cmtt-8"> </span><span 7538class="cmtt-8"> vector</span><span 7539class="cmtt-8"> [floor1_final_Y]</span><span 7540class="cmtt-8"> element</span><span 7541class="cmtt-8"> [high_neighbor_offset],</span> 7542<br class="fancyvrb" /><a 7543 id="x1-101030r15"></a><span 7544class="cmr-6">15</span><span 7545class="cmtt-8"> </span><span 7546class="cmtt-8"> </span><span 7547class="cmtt-8"> </span><span 7548class="cmtt-8"> </span><span 7549class="cmtt-8"> </span><span 7550class="cmtt-8"> </span><span 7551class="cmtt-8"> </span><span 7552class="cmtt-8"> </span><span 7553class="cmtt-8"> </span><span 7554class="cmtt-8"> </span><span 7555class="cmtt-8"> </span><span 7556class="cmtt-8"> </span><span 7557class="cmtt-8"> </span><span 7558class="cmtt-8"> </span><span 7559class="cmtt-8"> </span><span 7560class="cmtt-8"> </span><span 7561class="cmtt-8"> </span><span 7562class="cmtt-8"> </span><span 7563class="cmtt-8"> </span><span 7564class="cmtt-8"> </span><span 7565class="cmtt-8"> </span><span 7566class="cmtt-8"> </span><span 7567class="cmtt-8"> </span><span 7568class="cmtt-8"> </span><span 7569class="cmtt-8"> </span><span 7570class="cmtt-8"> </span><span 7571class="cmtt-8"> </span><span 7572class="cmtt-8"> </span><span 7573class="cmtt-8"> </span><span 7574class="cmtt-8"> </span><span 7575class="cmtt-8"> </span><span 7576class="cmtt-8"> </span><span 7577class="cmtt-8"> </span><span 7578class="cmtt-8"> </span><span 7579class="cmtt-8"> </span><span 7580class="cmtt-8"> </span><span 7581class="cmtt-8"> </span><span 7582class="cmtt-8"> </span><span 7583class="cmtt-8"> </span><span 7584class="cmtt-8"> vector</span><span 7585class="cmtt-8"> [floor1_X_list]</span><span 7586class="cmtt-8"> element</span><span 7587class="cmtt-8"> [i]</span><span 7588class="cmtt-8"> )</span> 7589<br class="fancyvrb" /><a 7590 id="x1-101032r16"></a><span 7591class="cmr-6">16</span><span 7592class="cmtt-8"> </span><span 7593class="cmtt-8"> </span> 7594<br class="fancyvrb" /><a 7595 id="x1-101034r17"></a><span 7596class="cmr-6">17</span><span 7597class="cmtt-8"> </span><span 7598class="cmtt-8"> </span><span 7599class="cmtt-8"> </span><span 7600class="cmtt-8"> </span><span 7601class="cmtt-8"> </span><span 7602class="cmtt-8"> </span><span 7603class="cmtt-8"> </span><span 7604class="cmtt-8"> 10)</span><span 7605class="cmtt-8"> [val]</span><span 7606class="cmtt-8"> =</span><span 7607class="cmtt-8"> vector</span><span 7608class="cmtt-8"> [floor1_Y]</span><span 7609class="cmtt-8"> element</span><span 7610class="cmtt-8"> [i]</span> 7611<br class="fancyvrb" /><a 7612 id="x1-101036r18"></a><span 7613class="cmr-6">18</span><span 7614class="cmtt-8"> </span><span 7615class="cmtt-8"> </span><span 7616class="cmtt-8"> </span><span 7617class="cmtt-8"> </span><span 7618class="cmtt-8"> </span><span 7619class="cmtt-8"> </span><span 7620class="cmtt-8"> </span><span 7621class="cmtt-8"> 11)</span><span 7622class="cmtt-8"> [highroom]</span><span 7623class="cmtt-8"> =</span><span 7624class="cmtt-8"> [range]</span><span 7625class="cmtt-8"> -</span><span 7626class="cmtt-8"> [predicted]</span> 7627<br class="fancyvrb" /><a 7628 id="x1-101038r19"></a><span 7629class="cmr-6">19</span><span 7630class="cmtt-8"> </span><span 7631class="cmtt-8"> </span><span 7632class="cmtt-8"> </span><span 7633class="cmtt-8"> </span><span 7634class="cmtt-8"> </span><span 7635class="cmtt-8"> </span><span 7636class="cmtt-8"> </span><span 7637class="cmtt-8"> 12)</span><span 7638class="cmtt-8"> [lowroom]</span><span 7639class="cmtt-8"> </span><span 7640class="cmtt-8"> =</span><span 7641class="cmtt-8"> [predicted]</span> 7642<br class="fancyvrb" /><a 7643 id="x1-101040r20"></a><span 7644class="cmr-6">20</span><span 7645class="cmtt-8"> </span><span 7646class="cmtt-8"> </span><span 7647class="cmtt-8"> </span><span 7648class="cmtt-8"> </span><span 7649class="cmtt-8"> </span><span 7650class="cmtt-8"> </span><span 7651class="cmtt-8"> </span><span 7652class="cmtt-8"> 13)</span><span 7653class="cmtt-8"> if</span><span 7654class="cmtt-8"> (</span><span 7655class="cmtt-8"> [highroom]</span><span 7656class="cmtt-8"> is</span><span 7657class="cmtt-8"> less</span><span 7658class="cmtt-8"> than</span><span 7659class="cmtt-8"> [lowroom]</span><span 7660class="cmtt-8"> )</span><span 7661class="cmtt-8"> </span><span 7662class="cmsy-8">{</span> 7663<br class="fancyvrb" /><a 7664 id="x1-101042r21"></a><span 7665class="cmr-6">21</span><span 7666class="cmtt-8"> </span><span 7667class="cmtt-8"> </span> 7668<br class="fancyvrb" /><a 7669 id="x1-101044r22"></a><span 7670class="cmr-6">22</span><span 7671class="cmtt-8"> </span><span 7672class="cmtt-8"> </span><span 7673class="cmtt-8"> </span><span 7674class="cmtt-8"> </span><span 7675class="cmtt-8"> </span><span 7676class="cmtt-8"> </span><span 7677class="cmtt-8"> </span><span 7678class="cmtt-8"> </span><span 7679class="cmtt-8"> </span><span 7680class="cmtt-8"> </span><span 7681class="cmtt-8"> </span><span 7682class="cmtt-8"> </span><span 7683class="cmtt-8"> </span><span 7684class="cmtt-8"> 14)</span><span 7685class="cmtt-8"> [room]</span><span 7686class="cmtt-8"> =</span><span 7687class="cmtt-8"> [highroom]</span><span 7688class="cmtt-8"> *</span><span 7689class="cmtt-8"> 2</span> 7690 7691 7692 7693<br class="fancyvrb" /><a 7694 id="x1-101046r23"></a><span 7695class="cmr-6">23</span><span 7696class="cmtt-8"> </span><span 7697class="cmtt-8"> </span> 7698<br class="fancyvrb" /><a 7699 id="x1-101048r24"></a><span 7700class="cmr-6">24</span><span 7701class="cmtt-8"> </span><span 7702class="cmtt-8"> </span><span 7703class="cmtt-8"> </span><span 7704class="cmtt-8"> </span><span 7705class="cmtt-8"> </span><span 7706class="cmtt-8"> </span><span 7707class="cmtt-8"> </span><span 7708class="cmtt-8"> </span><span 7709class="cmtt-8"> </span><span 7710class="cmtt-8"> </span><span 7711class="cmtt-8"> </span><span 7712class="cmtt-8"> </span><span 7713class="cmsy-8">}</span><span 7714class="cmtt-8"> else</span><span 7715class="cmtt-8"> [highroom]</span><span 7716class="cmtt-8"> is</span><span 7717class="cmtt-8"> not</span><span 7718class="cmtt-8"> less</span><span 7719class="cmtt-8"> than</span><span 7720class="cmtt-8"> [lowroom]</span><span 7721class="cmtt-8"> </span><span 7722class="cmsy-8">{</span> 7723<br class="fancyvrb" /><a 7724 id="x1-101050r25"></a><span 7725class="cmr-6">25</span><span 7726class="cmtt-8"> </span><span 7727class="cmtt-8"> </span> 7728<br class="fancyvrb" /><a 7729 id="x1-101052r26"></a><span 7730class="cmr-6">26</span><span 7731class="cmtt-8"> </span><span 7732class="cmtt-8"> </span><span 7733class="cmtt-8"> </span><span 7734class="cmtt-8"> </span><span 7735class="cmtt-8"> </span><span 7736class="cmtt-8"> </span><span 7737class="cmtt-8"> </span><span 7738class="cmtt-8"> </span><span 7739class="cmtt-8"> </span><span 7740class="cmtt-8"> </span><span 7741class="cmtt-8"> </span><span 7742class="cmtt-8"> </span><span 7743class="cmtt-8"> </span><span 7744class="cmtt-8"> 15)</span><span 7745class="cmtt-8"> [room]</span><span 7746class="cmtt-8"> =</span><span 7747class="cmtt-8"> [lowroom]</span><span 7748class="cmtt-8"> *</span><span 7749class="cmtt-8"> 2</span> 7750<br class="fancyvrb" /><a 7751 id="x1-101054r27"></a><span 7752class="cmr-6">27</span><span 7753class="cmtt-8"> </span><span 7754class="cmtt-8"> </span> 7755<br class="fancyvrb" /><a 7756 id="x1-101056r28"></a><span 7757class="cmr-6">28</span><span 7758class="cmtt-8"> </span><span 7759class="cmtt-8"> </span><span 7760class="cmtt-8"> </span><span 7761class="cmtt-8"> </span><span 7762class="cmtt-8"> </span><span 7763class="cmtt-8"> </span><span 7764class="cmtt-8"> </span><span 7765class="cmtt-8"> </span><span 7766class="cmtt-8"> </span><span 7767class="cmtt-8"> </span><span 7768class="cmtt-8"> </span><span 7769class="cmtt-8"> </span><span 7770class="cmsy-8">}</span> 7771<br class="fancyvrb" /><a 7772 id="x1-101058r29"></a><span 7773class="cmr-6">29</span><span 7774class="cmtt-8"> </span><span 7775class="cmtt-8"> </span> 7776<br class="fancyvrb" /><a 7777 id="x1-101060r30"></a><span 7778class="cmr-6">30</span><span 7779class="cmtt-8"> </span><span 7780class="cmtt-8"> </span><span 7781class="cmtt-8"> </span><span 7782class="cmtt-8"> </span><span 7783class="cmtt-8"> </span><span 7784class="cmtt-8"> </span><span 7785class="cmtt-8"> </span><span 7786class="cmtt-8"> 16)</span><span 7787class="cmtt-8"> if</span><span 7788class="cmtt-8"> (</span><span 7789class="cmtt-8"> [val]</span><span 7790class="cmtt-8"> is</span><span 7791class="cmtt-8"> nonzero</span><span 7792class="cmtt-8"> )</span><span 7793class="cmtt-8"> </span><span 7794class="cmsy-8">{</span> 7795<br class="fancyvrb" /><a 7796 id="x1-101062r31"></a><span 7797class="cmr-6">31</span><span 7798class="cmtt-8"> </span><span 7799class="cmtt-8"> </span> 7800<br class="fancyvrb" /><a 7801 id="x1-101064r32"></a><span 7802class="cmr-6">32</span><span 7803class="cmtt-8"> </span><span 7804class="cmtt-8"> </span><span 7805class="cmtt-8"> </span><span 7806class="cmtt-8"> </span><span 7807class="cmtt-8"> </span><span 7808class="cmtt-8"> </span><span 7809class="cmtt-8"> </span><span 7810class="cmtt-8"> </span><span 7811class="cmtt-8"> </span><span 7812class="cmtt-8"> </span><span 7813class="cmtt-8"> </span><span 7814class="cmtt-8"> </span><span 7815class="cmtt-8"> </span><span 7816class="cmtt-8"> 17)</span><span 7817class="cmtt-8"> vector</span><span 7818class="cmtt-8"> [floor1_step2_flag]</span><span 7819class="cmtt-8"> element</span><span 7820class="cmtt-8"> [low_neighbor_offset]</span><span 7821class="cmtt-8"> =</span><span 7822class="cmtt-8"> set</span> 7823<br class="fancyvrb" /><a 7824 id="x1-101066r33"></a><span 7825class="cmr-6">33</span><span 7826class="cmtt-8"> </span><span 7827class="cmtt-8"> </span><span 7828class="cmtt-8"> </span><span 7829class="cmtt-8"> </span><span 7830class="cmtt-8"> </span><span 7831class="cmtt-8"> </span><span 7832class="cmtt-8"> </span><span 7833class="cmtt-8"> </span><span 7834class="cmtt-8"> </span><span 7835class="cmtt-8"> </span><span 7836class="cmtt-8"> </span><span 7837class="cmtt-8"> </span><span 7838class="cmtt-8"> </span><span 7839class="cmtt-8"> 18)</span><span 7840class="cmtt-8"> vector</span><span 7841class="cmtt-8"> [floor1_step2_flag]</span><span 7842class="cmtt-8"> element</span><span 7843class="cmtt-8"> [high_neighbor_offset]</span><span 7844class="cmtt-8"> =</span><span 7845class="cmtt-8"> set</span> 7846<br class="fancyvrb" /><a 7847 id="x1-101068r34"></a><span 7848class="cmr-6">34</span><span 7849class="cmtt-8"> </span><span 7850class="cmtt-8"> </span><span 7851class="cmtt-8"> </span><span 7852class="cmtt-8"> </span><span 7853class="cmtt-8"> </span><span 7854class="cmtt-8"> </span><span 7855class="cmtt-8"> </span><span 7856class="cmtt-8"> </span><span 7857class="cmtt-8"> </span><span 7858class="cmtt-8"> </span><span 7859class="cmtt-8"> </span><span 7860class="cmtt-8"> </span><span 7861class="cmtt-8"> </span><span 7862class="cmtt-8"> 19)</span><span 7863class="cmtt-8"> vector</span><span 7864class="cmtt-8"> [floor1_step2_flag]</span><span 7865class="cmtt-8"> element</span><span 7866class="cmtt-8"> [i]</span><span 7867class="cmtt-8"> =</span><span 7868class="cmtt-8"> set</span> 7869<br class="fancyvrb" /><a 7870 id="x1-101070r35"></a><span 7871class="cmr-6">35</span><span 7872class="cmtt-8"> </span><span 7873class="cmtt-8"> </span><span 7874class="cmtt-8"> </span><span 7875class="cmtt-8"> </span><span 7876class="cmtt-8"> </span><span 7877class="cmtt-8"> </span><span 7878class="cmtt-8"> </span><span 7879class="cmtt-8"> </span><span 7880class="cmtt-8"> </span><span 7881class="cmtt-8"> </span><span 7882class="cmtt-8"> </span><span 7883class="cmtt-8"> </span><span 7884class="cmtt-8"> </span><span 7885class="cmtt-8"> 20)</span><span 7886class="cmtt-8"> if</span><span 7887class="cmtt-8"> (</span><span 7888class="cmtt-8"> [val]</span><span 7889class="cmtt-8"> is</span><span 7890class="cmtt-8"> greater</span><span 7891class="cmtt-8"> than</span><span 7892class="cmtt-8"> or</span><span 7893class="cmtt-8"> equal</span><span 7894class="cmtt-8"> to</span><span 7895class="cmtt-8"> [room]</span><span 7896class="cmtt-8"> )</span><span 7897class="cmtt-8"> </span><span 7898class="cmsy-8">{</span> 7899<br class="fancyvrb" /><a 7900 id="x1-101072r36"></a><span 7901class="cmr-6">36</span><span 7902class="cmtt-8"> </span><span 7903class="cmtt-8"> </span> 7904<br class="fancyvrb" /><a 7905 id="x1-101074r37"></a><span 7906class="cmr-6">37</span><span 7907class="cmtt-8"> </span><span 7908class="cmtt-8"> </span><span 7909class="cmtt-8"> </span><span 7910class="cmtt-8"> </span><span 7911class="cmtt-8"> </span><span 7912class="cmtt-8"> </span><span 7913class="cmtt-8"> </span><span 7914class="cmtt-8"> </span><span 7915class="cmtt-8"> </span><span 7916class="cmtt-8"> </span><span 7917class="cmtt-8"> </span><span 7918class="cmtt-8"> </span><span 7919class="cmtt-8"> </span><span 7920class="cmtt-8"> </span><span 7921class="cmtt-8"> </span><span 7922class="cmtt-8"> </span><span 7923class="cmtt-8"> </span><span 7924class="cmtt-8"> </span><span 7925class="cmtt-8"> </span><span 7926class="cmtt-8"> 21)</span><span 7927class="cmtt-8"> if</span><span 7928class="cmtt-8"> (</span><span 7929class="cmtt-8"> [highroom]</span><span 7930class="cmtt-8"> is</span><span 7931class="cmtt-8"> greater</span><span 7932class="cmtt-8"> than</span><span 7933class="cmtt-8"> [lowroom]</span><span 7934class="cmtt-8"> )</span><span 7935class="cmtt-8"> </span><span 7936class="cmsy-8">{</span> 7937<br class="fancyvrb" /><a 7938 id="x1-101076r38"></a><span 7939class="cmr-6">38</span><span 7940class="cmtt-8"> </span><span 7941class="cmtt-8"> </span> 7942<br class="fancyvrb" /><a 7943 id="x1-101078r39"></a><span 7944class="cmr-6">39</span><span 7945class="cmtt-8"> </span><span 7946class="cmtt-8"> </span><span 7947class="cmtt-8"> </span><span 7948class="cmtt-8"> </span><span 7949class="cmtt-8"> </span><span 7950class="cmtt-8"> </span><span 7951class="cmtt-8"> </span><span 7952class="cmtt-8"> </span><span 7953class="cmtt-8"> </span><span 7954class="cmtt-8"> </span><span 7955class="cmtt-8"> </span><span 7956class="cmtt-8"> </span><span 7957class="cmtt-8"> </span><span 7958class="cmtt-8"> </span><span 7959class="cmtt-8"> </span><span 7960class="cmtt-8"> </span><span 7961class="cmtt-8"> </span><span 7962class="cmtt-8"> </span><span 7963class="cmtt-8"> </span><span 7964class="cmtt-8"> </span><span 7965class="cmtt-8"> </span><span 7966class="cmtt-8"> </span><span 7967class="cmtt-8"> </span><span 7968class="cmtt-8"> </span><span 7969class="cmtt-8"> </span><span 7970class="cmtt-8"> 22)</span><span 7971class="cmtt-8"> vector</span><span 7972class="cmtt-8"> [floor1_final_Y]</span><span 7973class="cmtt-8"> element</span><span 7974class="cmtt-8"> [i]</span><span 7975class="cmtt-8"> =</span><span 7976class="cmtt-8"> [val]</span><span 7977class="cmtt-8"> -</span><span 7978class="cmtt-8"> [lowroom]</span><span 7979class="cmtt-8"> +</span><span 7980class="cmtt-8"> [predicted]</span> 7981<br class="fancyvrb" /><a 7982 id="x1-101080r40"></a><span 7983class="cmr-6">40</span><span 7984class="cmtt-8"> </span><span 7985class="cmtt-8"> </span> 7986<br class="fancyvrb" /><a 7987 id="x1-101082r41"></a><span 7988class="cmr-6">41</span><span 7989class="cmtt-8"> </span><span 7990class="cmtt-8">  </span><span 7991class="cmtt-8"> </span><span 7992class="cmtt-8"> </span><span 7993class="cmtt-8"> </span><span 7994class="cmtt-8"> </span><span 7995class="cmtt-8"> </span><span 7996class="cmtt-8"> </span><span 7997class="cmsy-8">}</span><span 7998class="cmtt-8"> else</span><span 7999class="cmtt-8"> [highroom]</span><span 8000class="cmtt-8"> is</span><span 8001class="cmtt-8"> not</span><span 8002class="cmtt-8"> greater</span><span 8003class="cmtt-8"> than</span><span 8004class="cmtt-8"> [lowroom]</span><span 8005class="cmtt-8"> </span><span 8006class="cmsy-8">{</span> 8007<br class="fancyvrb" /><a 8008 id="x1-101084r42"></a><span 8009class="cmr-6">42</span><span 8010class="cmtt-8"> </span><span 8011class="cmtt-8"> </span> 8012<br class="fancyvrb" /><a 8013 id="x1-101086r43"></a><span 8014class="cmr-6">43</span><span 8015class="cmtt-8"> </span><span 8016class="cmtt-8"> </span><span 8017class="cmtt-8"> </span><span 8018class="cmtt-8"> </span><span 8019class="cmtt-8"> </span><span 8020class="cmtt-8"> </span><span 8021class="cmtt-8"> </span><span 8022class="cmtt-8"> </span><span 8023class="cmtt-8"> </span><span 8024class="cmtt-8"> </span><span 8025class="cmtt-8"> </span><span 8026class="cmtt-8"> </span><span 8027class="cmtt-8"> </span><span 8028class="cmtt-8"> </span><span 8029class="cmtt-8"> </span><span 8030class="cmtt-8"> </span><span 8031class="cmtt-8"> </span><span 8032class="cmtt-8"> </span><span 8033class="cmtt-8"> </span><span 8034class="cmtt-8"> </span><span 8035class="cmtt-8"> </span><span 8036class="cmtt-8"> </span><span 8037class="cmtt-8"> </span><span 8038class="cmtt-8"> </span><span 8039class="cmtt-8"> </span><span 8040class="cmtt-8"> 23)</span><span 8041class="cmtt-8"> vector</span><span 8042class="cmtt-8"> [floor1_final_Y]</span><span 8043class="cmtt-8"> element</span><span 8044class="cmtt-8"> [i]</span><span 8045class="cmtt-8"> =</span><span 8046class="cmtt-8"> [predicted]</span><span 8047class="cmtt-8"> -</span><span 8048class="cmtt-8"> [val]</span><span 8049class="cmtt-8"> +</span><span 8050class="cmtt-8"> [highroom]</span><span 8051class="cmtt-8"> -</span><span 8052class="cmtt-8"> 1</span> 8053<br class="fancyvrb" /><a 8054 id="x1-101088r44"></a><span 8055class="cmr-6">44</span><span 8056class="cmtt-8"> </span><span 8057class="cmtt-8"> </span> 8058<br class="fancyvrb" /><a 8059 id="x1-101090r45"></a><span 8060class="cmr-6">45</span><span 8061class="cmtt-8"> </span><span 8062class="cmtt-8"> </span><span 8063class="cmtt-8"> </span><span 8064class="cmtt-8"> </span><span 8065class="cmtt-8"> </span><span 8066class="cmtt-8"> </span><span 8067class="cmtt-8"> </span><span 8068class="cmtt-8"> </span><span 8069class="cmtt-8"> </span><span 8070class="cmtt-8"> </span><span 8071class="cmtt-8"> </span><span 8072class="cmtt-8"> </span><span 8073class="cmtt-8"> </span><span 8074class="cmtt-8"> </span><span 8075class="cmtt-8"> </span><span 8076class="cmtt-8"> </span><span 8077class="cmtt-8"> </span><span 8078class="cmtt-8"> </span><span 8079class="cmtt-8"> </span><span 8080class="cmtt-8"> </span><span 8081class="cmtt-8"> </span><span 8082class="cmtt-8"> </span><span 8083class="cmtt-8"> </span><span 8084class="cmtt-8"> </span><span 8085class="cmsy-8">}</span> 8086<br class="fancyvrb" /><a 8087 id="x1-101092r46"></a><span 8088class="cmr-6">46</span><span 8089class="cmtt-8"> </span><span 8090class="cmtt-8"> </span> 8091<br class="fancyvrb" /><a 8092 id="x1-101094r47"></a><span 8093class="cmr-6">47</span><span 8094class="cmtt-8"> </span><span 8095class="cmtt-8"> </span><span 8096class="cmtt-8"> </span><span 8097class="cmtt-8"> </span><span 8098class="cmtt-8"> </span><span 8099class="cmtt-8"> </span><span 8100class="cmtt-8"> </span><span 8101class="cmtt-8"> </span><span 8102class="cmtt-8"> </span><span 8103class="cmtt-8"> </span><span 8104class="cmtt-8"> </span><span 8105class="cmtt-8"> </span><span 8106class="cmtt-8"> </span><span 8107class="cmtt-8"> </span><span 8108class="cmtt-8"> </span><span 8109class="cmtt-8"> </span><span 8110class="cmtt-8"> </span><span 8111class="cmtt-8"> </span><span 8112class="cmsy-8">}</span><span 8113class="cmtt-8"> else</span><span 8114class="cmtt-8"> [val]</span><span 8115class="cmtt-8"> is</span><span 8116class="cmtt-8"> less</span><span 8117class="cmtt-8"> than</span><span 8118class="cmtt-8"> [room]</span><span 8119class="cmtt-8"> </span><span 8120class="cmsy-8">{</span> 8121<br class="fancyvrb" /><a 8122 id="x1-101096r48"></a><span 8123class="cmr-6">48</span><span 8124class="cmtt-8"> </span><span 8125class="cmtt-8"> </span> 8126<br class="fancyvrb" /><a 8127 id="x1-101098r49"></a><span 8128class="cmr-6">49</span><span 8129class="cmtt-8"> </span><span 8130class="cmtt-8">  </span><span 8131class="cmtt-8"> </span><span 8132class="cmtt-8"> 24)</span><span 8133class="cmtt-8"> if</span><span 8134class="cmtt-8"> ([val]</span><span 8135class="cmtt-8"> is</span><span 8136class="cmtt-8"> odd)</span><span 8137class="cmtt-8"> </span><span 8138class="cmsy-8">{</span> 8139<br class="fancyvrb" /><a 8140 id="x1-101100r50"></a><span 8141class="cmr-6">50</span><span 8142class="cmtt-8"> </span><span 8143class="cmtt-8"> </span> 8144<br class="fancyvrb" /><a 8145 id="x1-101102r51"></a><span 8146class="cmr-6">51</span><span 8147class="cmtt-8"> </span><span 8148class="cmtt-8"> </span><span 8149class="cmtt-8"> </span><span 8150class="cmtt-8"> </span><span 8151class="cmtt-8"> </span><span 8152class="cmtt-8"> </span><span 8153class="cmtt-8"> </span><span 8154class="cmtt-8"> </span><span 8155class="cmtt-8"> </span><span 8156class="cmtt-8"> </span><span 8157class="cmtt-8"> </span><span 8158class="cmtt-8"> </span><span 8159class="cmtt-8"> </span><span 8160class="cmtt-8"> </span><span 8161class="cmtt-8"> </span><span 8162class="cmtt-8"> </span><span 8163class="cmtt-8"> </span><span 8164class="cmtt-8"> </span><span 8165class="cmtt-8"> </span><span 8166class="cmtt-8"> </span><span 8167class="cmtt-8"> </span><span 8168class="cmtt-8"> </span><span 8169class="cmtt-8"> </span><span 8170class="cmtt-8"> </span><span 8171class="cmtt-8"> </span><span 8172class="cmtt-8"> 25)</span><span 8173class="cmtt-8"> vector</span><span 8174class="cmtt-8"> [floor1_final_Y]</span><span 8175class="cmtt-8"> element</span><span 8176class="cmtt-8"> [i]</span><span 8177class="cmtt-8"> =</span> 8178<br class="fancyvrb" /><a 8179 id="x1-101104r52"></a><span 8180class="cmr-6">52</span><span 8181class="cmtt-8"> </span><span 8182class="cmtt-8"> </span><span 8183class="cmtt-8"> </span><span 8184class="cmtt-8"> </span><span 8185class="cmtt-8"> </span><span 8186class="cmtt-8"> </span><span 8187class="cmtt-8"> </span><span 8188class="cmtt-8"> </span><span 8189class="cmtt-8"> </span><span 8190class="cmtt-8"> </span><span 8191class="cmtt-8"> </span><span 8192class="cmtt-8"> </span><span 8193class="cmtt-8"> </span><span 8194class="cmtt-8"> </span><span 8195class="cmtt-8"> </span><span 8196class="cmtt-8"> </span><span 8197class="cmtt-8"> </span><span 8198class="cmtt-8"> </span><span 8199class="cmtt-8"> </span><span 8200class="cmtt-8"> </span><span 8201class="cmtt-8"> </span><span 8202class="cmtt-8"> </span><span 8203class="cmtt-8"> </span><span 8204class="cmtt-8"> </span><span 8205class="cmtt-8"> </span><span 8206class="cmtt-8"> </span><span 8207class="cmtt-8"> </span><span 8208class="cmtt-8"> </span><span 8209class="cmtt-8"> </span><span 8210class="cmtt-8"> [predicted]</span><span 8211class="cmtt-8"> -</span><span 8212class="cmtt-8"> (([val]</span><span 8213class="cmtt-8"> +</span><span 8214class="cmtt-8"> 1)</span><span 8215class="cmtt-8"> divided</span><span 8216class="cmtt-8"> by</span><span 8217class="cmtt-8"> </span><span 8218class="cmtt-8"> 2</span><span 8219class="cmtt-8"> using</span><span 8220class="cmtt-8"> integer</span><span 8221class="cmtt-8"> division)</span> 8222<br class="fancyvrb" /><a 8223 id="x1-101106r53"></a><span 8224class="cmr-6">53</span><span 8225class="cmtt-8"> </span><span 8226class="cmtt-8"> </span> 8227<br class="fancyvrb" /><a 8228 id="x1-101108r54"></a><span 8229class="cmr-6">54</span><span 8230class="cmtt-8"> </span><span 8231class="cmtt-8"> </span><span 8232class="cmtt-8"> </span><span 8233class="cmtt-8"> </span><span 8234class="cmtt-8"> </span><span 8235class="cmtt-8"> </span><span 8236class="cmtt-8"> </span><span 8237class="cmtt-8"> </span><span 8238class="cmtt-8"> </span><span 8239class="cmtt-8"> </span><span 8240class="cmtt-8"> </span><span 8241class="cmtt-8"> </span><span 8242class="cmtt-8"> </span><span 8243class="cmtt-8"> </span><span 8244class="cmtt-8"> </span><span 8245class="cmtt-8"> </span><span 8246class="cmtt-8"> </span><span 8247class="cmtt-8"> </span><span 8248class="cmtt-8"> </span><span 8249class="cmtt-8"> </span><span 8250class="cmtt-8"> </span><span 8251class="cmtt-8"> </span><span 8252class="cmtt-8"> </span><span 8253class="cmtt-8"> </span><span 8254class="cmsy-8">}</span><span 8255class="cmtt-8"> else</span><span 8256class="cmtt-8"> [val]</span><span 8257class="cmtt-8"> is</span><span 8258class="cmtt-8"> even</span><span 8259class="cmtt-8"> </span><span 8260class="cmsy-8">{</span> 8261<br class="fancyvrb" /><a 8262 id="x1-101110r55"></a><span 8263class="cmr-6">55</span><span 8264class="cmtt-8"> </span><span 8265class="cmtt-8"> </span> 8266<br class="fancyvrb" /><a 8267 id="x1-101112r56"></a><span 8268class="cmr-6">56</span><span 8269class="cmtt-8"> </span><span 8270class="cmtt-8"> </span><span 8271class="cmtt-8"> </span><span 8272class="cmtt-8"> </span><span 8273class="cmtt-8"> </span><span 8274class="cmtt-8"> </span><span 8275class="cmtt-8"> </span><span 8276class="cmtt-8"> </span><span 8277class="cmtt-8"> </span><span 8278class="cmtt-8"> </span><span 8279class="cmtt-8"> </span><span 8280class="cmtt-8"> </span><span 8281class="cmtt-8"> </span><span 8282class="cmtt-8"> </span><span 8283class="cmtt-8"> </span><span 8284class="cmtt-8"> </span><span 8285class="cmtt-8"> </span><span 8286class="cmtt-8"> </span><span 8287class="cmtt-8"> </span><span 8288class="cmtt-8"> </span><span 8289class="cmtt-8"> </span><span 8290class="cmtt-8"> </span><span 8291class="cmtt-8"> </span><span 8292class="cmtt-8"> </span><span 8293class="cmtt-8"> </span><span 8294class="cmtt-8"> 26)</span><span 8295class="cmtt-8"> vector</span><span 8296class="cmtt-8"> [floor1_final_Y]</span><span 8297class="cmtt-8"> element</span><span 8298class="cmtt-8"> [i]</span><span 8299class="cmtt-8"> =</span> 8300<br class="fancyvrb" /><a 8301 id="x1-101114r57"></a><span 8302class="cmr-6">57</span><span 8303class="cmtt-8"> </span><span 8304class="cmtt-8"> </span><span 8305class="cmtt-8"> </span><span 8306class="cmtt-8"> </span><span 8307class="cmtt-8"> </span><span 8308class="cmtt-8"> </span><span 8309class="cmtt-8"> </span><span 8310class="cmtt-8"> </span><span 8311class="cmtt-8"> </span><span 8312class="cmtt-8"> </span><span 8313class="cmtt-8"> </span><span 8314class="cmtt-8"> </span><span 8315class="cmtt-8"> </span><span 8316class="cmtt-8"> </span><span 8317class="cmtt-8"> </span><span 8318class="cmtt-8"> </span><span 8319class="cmtt-8"> </span><span 8320class="cmtt-8"> </span><span 8321class="cmtt-8"> </span><span 8322class="cmtt-8"> </span><span 8323class="cmtt-8"> </span><span 8324class="cmtt-8"> </span><span 8325class="cmtt-8"> </span><span 8326class="cmtt-8"> </span><span 8327class="cmtt-8"> </span><span 8328class="cmtt-8"> </span><span 8329class="cmtt-8"> </span><span 8330class="cmtt-8"> </span><span 8331class="cmtt-8"> </span><span 8332class="cmtt-8"> [predicted]</span><span 8333class="cmtt-8"> +</span><span 8334class="cmtt-8"> ([val]</span><span 8335class="cmtt-8"> /</span><span 8336class="cmtt-8"> 2</span><span 8337class="cmtt-8"> using</span><span 8338class="cmtt-8"> integer</span><span 8339class="cmtt-8"> division)</span> 8340<br class="fancyvrb" /><a 8341 id="x1-101116r58"></a><span 8342class="cmr-6">58</span><span 8343class="cmtt-8"> </span><span 8344class="cmtt-8"> </span> 8345<br class="fancyvrb" /><a 8346 id="x1-101118r59"></a><span 8347class="cmr-6">59</span><span 8348class="cmtt-8"> </span><span 8349class="cmtt-8"> </span><span 8350class="cmtt-8"> </span><span 8351class="cmtt-8"> </span><span 8352class="cmtt-8"> </span><span 8353class="cmtt-8"> </span><span 8354class="cmtt-8"> </span><span 8355class="cmtt-8"> </span><span 8356class="cmtt-8"> </span><span 8357class="cmtt-8"> </span><span 8358class="cmtt-8"> </span><span 8359class="cmtt-8"> </span><span 8360class="cmtt-8"> </span><span 8361class="cmtt-8"> </span><span 8362class="cmtt-8"> </span><span 8363class="cmtt-8"> </span><span 8364class="cmtt-8"> </span><span 8365class="cmtt-8"> </span><span 8366class="cmtt-8"> </span><span 8367class="cmtt-8"> </span><span 8368class="cmtt-8"> </span><span 8369class="cmtt-8"> </span><span 8370class="cmtt-8"> </span><span 8371class="cmtt-8"> </span><span 8372class="cmsy-8">}</span> 8373<br class="fancyvrb" /><a 8374 id="x1-101120r60"></a><span 8375class="cmr-6">60</span><span 8376class="cmtt-8"> </span><span 8377class="cmtt-8"> </span> 8378<br class="fancyvrb" /><a 8379 id="x1-101122r61"></a><span 8380class="cmr-6">61</span><span 8381class="cmtt-8"> </span><span 8382class="cmtt-8"> </span><span 8383class="cmtt-8"> </span><span 8384class="cmtt-8"> </span><span 8385class="cmtt-8"> </span><span 8386class="cmtt-8"> </span><span 8387class="cmtt-8"> </span><span 8388class="cmtt-8"> </span><span 8389class="cmtt-8"> </span><span 8390class="cmtt-8"> </span><span 8391class="cmtt-8"> </span><span 8392class="cmtt-8"> </span><span 8393class="cmtt-8"> </span><span 8394class="cmtt-8"> </span><span 8395class="cmtt-8"> </span><span 8396class="cmtt-8"> </span><span 8397class="cmtt-8"> </span><span 8398class="cmtt-8"> </span><span 8399class="cmsy-8">}</span> 8400<br class="fancyvrb" /><a 8401 id="x1-101124r62"></a><span 8402class="cmr-6">62</span><span 8403class="cmtt-8"> </span><span 8404class="cmtt-8"> </span> 8405<br class="fancyvrb" /><a 8406 id="x1-101126r63"></a><span 8407class="cmr-6">63</span><span 8408class="cmtt-8"> </span><span 8409class="cmtt-8"> </span><span 8410class="cmtt-8"> </span><span 8411class="cmtt-8"> </span><span 8412class="cmtt-8"> </span><span 8413class="cmtt-8"> </span><span 8414class="cmtt-8"> </span><span 8415class="cmtt-8"> </span><span 8416class="cmtt-8"> </span><span 8417class="cmtt-8"> </span><span 8418class="cmtt-8"> </span><span 8419class="cmtt-8"> </span><span 8420class="cmsy-8">}</span><span 8421class="cmtt-8"> else</span><span 8422class="cmtt-8"> [val]</span><span 8423class="cmtt-8"> is</span><span 8424class="cmtt-8"> zero</span><span 8425class="cmtt-8"> </span><span 8426class="cmsy-8">{</span> 8427<br class="fancyvrb" /><a 8428 id="x1-101128r64"></a><span 8429class="cmr-6">64</span><span 8430class="cmtt-8"> </span><span 8431class="cmtt-8"> </span> 8432<br class="fancyvrb" /><a 8433 id="x1-101130r65"></a><span 8434class="cmr-6">65</span><span 8435class="cmtt-8"> </span><span 8436class="cmtt-8"> </span><span 8437class="cmtt-8"> </span><span 8438class="cmtt-8"> </span><span 8439class="cmtt-8"> </span><span 8440class="cmtt-8"> </span><span 8441class="cmtt-8"> </span><span 8442class="cmtt-8"> </span><span 8443class="cmtt-8"> </span><span 8444class="cmtt-8"> </span><span 8445class="cmtt-8"> </span><span 8446class="cmtt-8"> </span><span 8447class="cmtt-8"> </span><span 8448class="cmtt-8"> 27)</span><span 8449class="cmtt-8"> vector</span><span 8450class="cmtt-8"> [floor1_step2_flag]</span><span 8451class="cmtt-8"> element</span><span 8452class="cmtt-8"> [i]</span><span 8453class="cmtt-8"> =</span><span 8454class="cmtt-8"> unset</span> 8455<br class="fancyvrb" /><a 8456 id="x1-101132r66"></a><span 8457class="cmr-6">66</span><span 8458class="cmtt-8"> </span><span 8459class="cmtt-8"> </span><span 8460class="cmtt-8"> </span><span 8461class="cmtt-8"> </span><span 8462class="cmtt-8"> </span><span 8463class="cmtt-8"> </span><span 8464class="cmtt-8"> </span><span 8465class="cmtt-8"> </span><span 8466class="cmtt-8"> </span><span 8467class="cmtt-8"> </span><span 8468class="cmtt-8"> </span><span 8469class="cmtt-8"> </span><span 8470class="cmtt-8"> </span><span 8471class="cmtt-8"> 28)</span><span 8472class="cmtt-8"> vector</span><span 8473class="cmtt-8"> [floor1_final_Y]</span><span 8474class="cmtt-8"> element</span><span 8475class="cmtt-8"> [i]</span><span 8476class="cmtt-8"> =</span><span 8477class="cmtt-8"> [predicted]</span> 8478<br class="fancyvrb" /><a 8479 id="x1-101134r67"></a><span 8480class="cmr-6">67</span><span 8481class="cmtt-8"> </span><span 8482class="cmtt-8"> </span> 8483<br class="fancyvrb" /><a 8484 id="x1-101136r68"></a><span 8485class="cmr-6">68</span><span 8486class="cmtt-8"> </span><span 8487class="cmtt-8"> </span><span 8488class="cmtt-8"> </span><span 8489class="cmtt-8"> </span><span 8490class="cmtt-8"> </span><span 8491class="cmtt-8"> </span><span 8492class="cmtt-8"> </span><span 8493class="cmtt-8"> </span><span 8494class="cmtt-8"> </span><span 8495class="cmtt-8"> </span><span 8496class="cmtt-8"> </span><span 8497class="cmtt-8"> </span><span 8498class="cmsy-8">}</span> 8499<br class="fancyvrb" /><a 8500 id="x1-101138r69"></a><span 8501class="cmr-6">69</span><span 8502class="cmtt-8"> </span><span 8503class="cmtt-8"> </span> 8504<br class="fancyvrb" /><a 8505 id="x1-101140r70"></a><span 8506class="cmr-6">70</span><span 8507class="cmtt-8"> </span><span 8508class="cmtt-8"> </span><span 8509class="cmtt-8"> </span><span 8510class="cmtt-8"> </span><span 8511class="cmtt-8"> </span><span 8512class="cmtt-8"> </span><span 8513class="cmtt-8"> </span><span 8514class="cmsy-8">}</span> 8515<br class="fancyvrb" /><a 8516 id="x1-101142r71"></a><span 8517class="cmr-6">71</span><span 8518class="cmtt-8"> </span><span 8519class="cmtt-8"> </span> 8520<br class="fancyvrb" /><a 8521 id="x1-101144r72"></a><span 8522class="cmr-6">72</span><span 8523class="cmtt-8"> </span><span 8524class="cmtt-8"> </span><span 8525class="cmtt-8"> 29)</span><span 8526class="cmtt-8"> done</span> 8527<br class="fancyvrb" /><a 8528 id="x1-101146r73"></a><span 8529class="cmr-6">73</span><span 8530class="cmtt-8"> </span><span 8531class="cmtt-8"> </span> 8532</div> 8533 </dd><dt class="description"> 8534<span 8535class="cmssbx-10x-x-120">step 2: curve synthesis</span> </dt><dd 8536class="description"> 8537 <!--l. 338--><p class="noindent" >Curve synthesis generates a return vector <span 8538class="cmtt-12">[floor] </span>of length <span 8539class="cmtt-12">[n] </span>(where <span 8540class="cmtt-12">[n] </span>is provided by 8541 the decode process calling to floor decode). Floor 1 curve synthesis makes use of the 8542 <span 8543class="cmtt-12">[floor1_X_list]</span>, <span 8544class="cmtt-12">[floor1_final_Y] </span>and <span 8545class="cmtt-12">[floor1_step2_flag] </span>vectors, as well as 8546 [floor1˙multiplier] and [floor1˙values] values. 8547 8548 8549 8550 <!--l. 345--><p class="noindent" >Decode begins by sorting the scalars from vectors <span 8551class="cmtt-12">[floor1_X_list]</span>, <span 8552class="cmtt-12">[floor1_final_Y] </span>and 8553 <span 8554class="cmtt-12">[floor1_step2_flag] </span>together into new vectors <span 8555class="cmtt-12">[floor1_X_list]’</span>, <span 8556class="cmtt-12">[floor1_final_Y]’</span> 8557 and <span 8558class="cmtt-12">[floor1_step2_flag]’ </span>according to ascending sort order of the values in 8559 <span 8560class="cmtt-12">[floor1_X_list]</span>. That is, sort the values of <span 8561class="cmtt-12">[floor1_X_list] </span>and then apply the same 8562 permutation to elements of the other two vectors so that the X, Y and step2˙flag values still 8563 match. 8564 <!--l. 355--><p class="noindent" >Then compute the final curve in one pass: 8565 <!--l. 357--><p class="noindent" > 8566 <div class="fancyvrb" id="fancyvrb32"> 8567<a 8568 id="x1-101148r1"></a><span 8569class="cmr-6">1</span><span 8570class="cmtt-8"> </span><span 8571class="cmtt-8"> </span><span 8572class="cmtt-8"> </span><span 8573class="cmtt-8"> 1)</span><span 8574class="cmtt-8"> [hx]</span><span 8575class="cmtt-8"> =</span><span 8576class="cmtt-8"> 0</span> 8577<br class="fancyvrb" /><a 8578 id="x1-101150r2"></a><span 8579class="cmr-6">2</span><span 8580class="cmtt-8"> </span><span 8581class="cmtt-8"> </span><span 8582class="cmtt-8"> </span><span 8583class="cmtt-8"> 2)</span><span 8584class="cmtt-8"> [lx]</span><span 8585class="cmtt-8"> =</span><span 8586class="cmtt-8"> 0</span> 8587<br class="fancyvrb" /><a 8588 id="x1-101152r3"></a><span 8589class="cmr-6">3</span><span 8590class="cmtt-8"> </span><span 8591class="cmtt-8"> </span><span 8592class="cmtt-8"> </span><span 8593class="cmtt-8"> 3)</span><span 8594class="cmtt-8"> [ly]</span><span 8595class="cmtt-8"> =</span><span 8596class="cmtt-8"> vector</span><span 8597class="cmtt-8"> [floor1_final_Y]’</span><span 8598class="cmtt-8"> element</span><span 8599class="cmtt-8"> [0]</span><span 8600class="cmtt-8"> *</span><span 8601class="cmtt-8"> [floor1_multiplier]</span> 8602<br class="fancyvrb" /><a 8603 id="x1-101154r4"></a><span 8604class="cmr-6">4</span><span 8605class="cmtt-8"> </span><span 8606class="cmtt-8"> </span><span 8607class="cmtt-8"> </span><span 8608class="cmtt-8"> 4)</span><span 8609class="cmtt-8"> iterate</span><span 8610class="cmtt-8"> [i]</span><span 8611class="cmtt-8"> over</span><span 8612class="cmtt-8"> the</span><span 8613class="cmtt-8"> range</span><span 8614class="cmtt-8"> 1</span><span 8615class="cmtt-8"> ...</span><span 8616class="cmtt-8"> [floor1_values]-1</span><span 8617class="cmtt-8"> </span><span 8618class="cmsy-8">{</span> 8619<br class="fancyvrb" /><a 8620 id="x1-101156r5"></a><span 8621class="cmr-6">5</span><span 8622class="cmtt-8"> </span><span 8623class="cmtt-8"> </span> 8624<br class="fancyvrb" /><a 8625 id="x1-101158r6"></a><span 8626class="cmr-6">6</span><span 8627class="cmtt-8"> </span><span 8628class="cmtt-8"> </span><span 8629class="cmtt-8"> </span><span 8630class="cmtt-8"> </span><span 8631class="cmtt-8"> </span><span 8632class="cmtt-8"> </span><span 8633class="cmtt-8"> </span><span 8634class="cmtt-8"> </span><span 8635class="cmtt-8"> 5)</span><span 8636class="cmtt-8"> if</span><span 8637class="cmtt-8"> (</span><span 8638class="cmtt-8"> [floor1_step2_flag]’</span><span 8639class="cmtt-8"> element</span><span 8640class="cmtt-8"> [i]</span><span 8641class="cmtt-8"> is</span><span 8642class="cmtt-8"> set</span><span 8643class="cmtt-8"> )</span><span 8644class="cmtt-8"> </span><span 8645class="cmsy-8">{</span> 8646<br class="fancyvrb" /><a 8647 id="x1-101160r7"></a><span 8648class="cmr-6">7</span><span 8649class="cmtt-8"> </span><span 8650class="cmtt-8"> </span> 8651<br class="fancyvrb" /><a 8652 id="x1-101162r8"></a><span 8653class="cmr-6">8</span><span 8654class="cmtt-8"> </span><span 8655class="cmtt-8"> </span><span 8656class="cmtt-8"> </span><span 8657class="cmtt-8"> </span><span 8658class="cmtt-8"> </span><span 8659class="cmtt-8"> </span><span 8660class="cmtt-8"> </span><span 8661class="cmtt-8"> </span><span 8662class="cmtt-8"> </span><span 8663class="cmtt-8"> </span><span 8664class="cmtt-8"> </span><span 8665class="cmtt-8"> </span><span 8666class="cmtt-8"> </span><span 8667class="cmtt-8"> </span><span 8668class="cmtt-8"> 6)</span><span 8669class="cmtt-8"> [hy]</span><span 8670class="cmtt-8"> =</span><span 8671class="cmtt-8"> [floor1_final_Y]’</span><span 8672class="cmtt-8"> element</span><span 8673class="cmtt-8"> [i]</span><span 8674class="cmtt-8"> *</span><span 8675class="cmtt-8"> [floor1_multiplier]</span> 8676<br class="fancyvrb" /><a 8677 id="x1-101164r9"></a><span 8678class="cmr-6">9</span><span 8679class="cmtt-8"> </span><span 8680class="cmtt-8"> </span><span 8681class="cmtt-8">  </span><span 8682class="cmtt-8"> </span><span 8683class="cmtt-8"> </span><span 8684class="cmtt-8"> </span><span 8685class="cmtt-8"> </span><span 8686class="cmtt-8"> 7)</span><span 8687class="cmtt-8"> [hx]</span><span 8688class="cmtt-8"> =</span><span 8689class="cmtt-8"> [floor1_X_list]’</span><span 8690class="cmtt-8"> element</span><span 8691class="cmtt-8"> [i]</span> 8692<br class="fancyvrb" /><a 8693 id="x1-101166r10"></a><span 8694class="cmr-6">10</span><span 8695class="cmtt-8"> </span><span 8696class="cmtt-8"> </span><span 8697class="cmtt-8"> </span><span 8698class="cmtt-8"> </span><span 8699class="cmtt-8"> </span><span 8700class="cmtt-8"> </span><span 8701class="cmtt-8"> </span><span 8702class="cmtt-8"> </span><span 8703class="cmtt-8"> </span><span 8704class="cmtt-8"> </span><span 8705class="cmtt-8"> </span><span 8706class="cmtt-8"> </span><span 8707class="cmtt-8"> </span><span 8708class="cmtt-8"> </span><span 8709class="cmtt-8"> 8)</span><span 8710class="cmtt-8"> </span><a 8711href="#x1-1230009.2.7"><span 8712class="cmtt-8">render_line</span></a><span 8713class="cmtt-8">(</span><span 8714class="cmtt-8"> [lx],</span><span 8715class="cmtt-8"> [ly],</span><span 8716class="cmtt-8"> [hx],</span><span 8717class="cmtt-8"> [hy],</span><span 8718class="cmtt-8"> [floor]</span><span 8719class="cmtt-8"> )</span> 8720<br class="fancyvrb" /><a 8721 id="x1-101168r11"></a><span 8722class="cmr-6">11</span><span 8723class="cmtt-8"> </span><span 8724class="cmtt-8"> </span><span 8725class="cmtt-8"> </span><span 8726class="cmtt-8"> </span><span 8727class="cmtt-8"> </span><span 8728class="cmtt-8"> </span><span 8729class="cmtt-8"> </span><span 8730class="cmtt-8"> </span><span 8731class="cmtt-8"> </span><span 8732class="cmtt-8"> </span><span 8733class="cmtt-8"> </span><span 8734class="cmtt-8"> </span><span 8735class="cmtt-8"> </span><span 8736class="cmtt-8"> </span><span 8737class="cmtt-8"> 9)</span><span 8738class="cmtt-8"> [lx]</span><span 8739class="cmtt-8"> =</span><span 8740class="cmtt-8"> [hx]</span> 8741<br class="fancyvrb" /><a 8742 id="x1-101170r12"></a><span 8743class="cmr-6">12</span><span 8744class="cmtt-8"> </span><span 8745class="cmtt-8">  </span><span 8746class="cmtt-8"> </span><span 8747class="cmtt-8"> </span><span 8748class="cmtt-8"> </span><span 8749class="cmtt-8"> 10)</span><span 8750class="cmtt-8"> [ly]</span><span 8751class="cmtt-8"> =</span><span 8752class="cmtt-8"> [hy]</span> 8753<br class="fancyvrb" /><a 8754 id="x1-101172r13"></a><span 8755class="cmr-6">13</span><span 8756class="cmtt-8"> </span><span 8757class="cmtt-8"> </span><span 8758class="cmtt-8"> </span><span 8759class="cmtt-8"> </span><span 8760class="cmtt-8"> </span><span 8761class="cmtt-8"> </span><span 8762class="cmtt-8"> </span><span 8763class="cmtt-8"> </span><span 8764class="cmtt-8"> </span><span 8765class="cmtt-8"> </span><span 8766class="cmtt-8"> </span><span 8767class="cmtt-8"> </span><span 8768class="cmsy-8">}</span> 8769<br class="fancyvrb" /><a 8770 id="x1-101174r14"></a><span 8771class="cmr-6">14</span><span 8772class="cmtt-8"> </span><span 8773class="cmtt-8"> </span><span 8774class="cmtt-8"> </span><span 8775class="cmtt-8"> </span><span 8776class="cmtt-8"> </span><span 8777class="cmtt-8"> </span><span 8778class="cmtt-8"> </span><span 8779class="cmsy-8">}</span> 8780<br class="fancyvrb" /><a 8781 id="x1-101176r15"></a><span 8782class="cmr-6">15</span><span 8783class="cmtt-8"> </span><span 8784class="cmtt-8"> </span> 8785<br class="fancyvrb" /><a 8786 id="x1-101178r16"></a><span 8787class="cmr-6">16</span><span 8788class="cmtt-8"> </span><span 8789class="cmtt-8"> </span><span 8790class="cmtt-8"> 11)</span><span 8791class="cmtt-8"> if</span><span 8792class="cmtt-8"> (</span><span 8793class="cmtt-8"> [hx]</span><span 8794class="cmtt-8"> is</span><span 8795class="cmtt-8"> less</span><span 8796class="cmtt-8"> than</span><span 8797class="cmtt-8"> [n]</span><span 8798class="cmtt-8"> )</span><span 8799class="cmtt-8"> </span><span 8800class="cmsy-8">{</span> 8801<br class="fancyvrb" /><a 8802 id="x1-101180r17"></a><span 8803class="cmr-6">17</span><span 8804class="cmtt-8"> </span><span 8805class="cmtt-8"> </span> 8806<br class="fancyvrb" /><a 8807 id="x1-101182r18"></a><span 8808class="cmr-6">18</span><span 8809class="cmtt-8"> </span><span 8810class="cmtt-8"> </span><span 8811class="cmtt-8"> </span><span 8812class="cmtt-8"> </span><span 8813class="cmtt-8"> </span><span 8814class="cmtt-8"> </span><span 8815class="cmtt-8"> </span><span 8816class="cmtt-8"> </span><span 8817class="cmtt-8"> </span><span 8818class="cmtt-8"> 12)</span><span 8819class="cmtt-8"> </span><a 8820href="#x1-1230009.2.7"><span 8821class="cmtt-8">render_line</span></a><span 8822class="cmtt-8">(</span><span 8823class="cmtt-8"> [hx],</span><span 8824class="cmtt-8"> [hy],</span><span 8825class="cmtt-8"> [n],</span><span 8826class="cmtt-8"> [hy],</span><span 8827class="cmtt-8"> [floor]</span><span 8828class="cmtt-8"> )</span> 8829<br class="fancyvrb" /><a 8830 id="x1-101184r19"></a><span 8831class="cmr-6">19</span><span 8832class="cmtt-8"> </span><span 8833class="cmtt-8"> </span> 8834<br class="fancyvrb" /><a 8835 id="x1-101186r20"></a><span 8836class="cmr-6">20</span><span 8837class="cmtt-8"> </span><span 8838class="cmtt-8"> </span><span 8839class="cmtt-8"> </span><span 8840class="cmtt-8"> </span><span 8841class="cmtt-8"> </span><span 8842class="cmtt-8"> </span><span 8843class="cmtt-8"> </span><span 8844class="cmsy-8">}</span> 8845<br class="fancyvrb" /><a 8846 id="x1-101188r21"></a><span 8847class="cmr-6">21</span><span 8848class="cmtt-8"> </span><span 8849class="cmtt-8"> </span> 8850<br class="fancyvrb" /><a 8851 id="x1-101190r22"></a><span 8852class="cmr-6">22</span><span 8853class="cmtt-8"> </span><span 8854class="cmtt-8"> </span><span 8855class="cmtt-8"> 13)</span><span 8856class="cmtt-8"> if</span><span 8857class="cmtt-8"> (</span><span 8858class="cmtt-8"> [hx]</span><span 8859class="cmtt-8"> is</span><span 8860class="cmtt-8"> greater</span><span 8861class="cmtt-8"> than</span><span 8862class="cmtt-8"> [n]</span><span 8863class="cmtt-8"> )</span><span 8864class="cmtt-8"> </span><span 8865class="cmsy-8">{</span> 8866<br class="fancyvrb" /><a 8867 id="x1-101192r23"></a><span 8868class="cmr-6">23</span><span 8869class="cmtt-8"> </span><span 8870class="cmtt-8"> </span> 8871<br class="fancyvrb" /><a 8872 id="x1-101194r24"></a><span 8873class="cmr-6">24</span><span 8874class="cmtt-8"> </span><span 8875class="cmtt-8"> </span><span 8876class="cmtt-8"> </span><span 8877class="cmtt-8"> </span><span 8878class="cmtt-8"> </span><span 8879class="cmtt-8"> </span><span 8880class="cmtt-8"> </span><span 8881class="cmtt-8"> </span><span 8882class="cmtt-8"> </span><span 8883class="cmtt-8"> </span><span 8884class="cmtt-8"> </span><span 8885class="cmtt-8"> </span><span 8886class="cmtt-8"> </span><span 8887class="cmtt-8"> 14)</span><span 8888class="cmtt-8"> truncate</span><span 8889class="cmtt-8"> vector</span><span 8890class="cmtt-8"> [floor]</span><span 8891class="cmtt-8"> to</span><span 8892class="cmtt-8"> [n]</span><span 8893class="cmtt-8"> elements</span> 8894<br class="fancyvrb" /><a 8895 id="x1-101196r25"></a><span 8896class="cmr-6">25</span><span 8897class="cmtt-8"> </span><span 8898class="cmtt-8"> </span> 8899<br class="fancyvrb" /><a 8900 id="x1-101198r26"></a><span 8901class="cmr-6">26</span><span 8902class="cmtt-8"> </span><span 8903class="cmtt-8"> </span><span 8904class="cmtt-8"> </span><span 8905class="cmtt-8"> </span><span 8906class="cmtt-8"> </span><span 8907class="cmtt-8"> </span><span 8908class="cmtt-8"> </span><span 8909class="cmsy-8">}</span> 8910<br class="fancyvrb" /><a 8911 id="x1-101200r27"></a><span 8912class="cmr-6">27</span><span 8913class="cmtt-8"> </span><span 8914class="cmtt-8"> </span> 8915<br class="fancyvrb" /><a 8916 id="x1-101202r28"></a><span 8917class="cmr-6">28</span><span 8918class="cmtt-8"> </span><span 8919class="cmtt-8"> </span><span 8920class="cmtt-8"> 15)</span><span 8921class="cmtt-8"> for</span><span 8922class="cmtt-8"> each</span><span 8923class="cmtt-8"> scalar</span><span 8924class="cmtt-8"> in</span><span 8925class="cmtt-8"> vector</span><span 8926class="cmtt-8"> [floor],</span><span 8927class="cmtt-8"> perform</span><span 8928class="cmtt-8"> a</span><span 8929class="cmtt-8"> lookup</span><span 8930class="cmtt-8"> substitution</span><span 8931class="cmtt-8"> using</span> 8932<br class="fancyvrb" /><a 8933 id="x1-101204r29"></a><span 8934class="cmr-6">29</span><span 8935class="cmtt-8"> </span><span 8936class="cmtt-8"> </span><span 8937class="cmtt-8"> </span><span 8938class="cmtt-8"> </span><span 8939class="cmtt-8"> </span><span 8940class="cmtt-8"> </span><span 8941class="cmtt-8"> the</span><span 8942class="cmtt-8"> scalar</span><span 8943class="cmtt-8"> value</span><span 8944class="cmtt-8"> from</span><span 8945class="cmtt-8"> [floor]</span><span 8946class="cmtt-8"> as</span><span 8947class="cmtt-8"> an</span><span 8948class="cmtt-8"> offset</span><span 8949class="cmtt-8"> into</span><span 8950class="cmtt-8"> the</span><span 8951class="cmtt-8"> vector</span><span 8952class="cmtt-8"> </span><a 8953href="#x1-12500010.1"><span 8954class="cmtt-8">[floor1_inverse_dB_static_table]</span></a> 8955<br class="fancyvrb" /><a 8956 id="x1-101206r30"></a><span 8957class="cmr-6">30</span><span 8958class="cmtt-8"> </span><span 8959class="cmtt-8"> </span> 8960<br class="fancyvrb" /><a 8961 id="x1-101208r31"></a><span 8962class="cmr-6">31</span><span 8963class="cmtt-8"> </span><span 8964class="cmtt-8"> </span><span 8965class="cmtt-8"> 16)</span><span 8966class="cmtt-8"> done</span> 8967<br class="fancyvrb" /><a 8968 id="x1-101210r32"></a><span 8969class="cmr-6">32</span><span 8970class="cmtt-8"> </span><span 8971class="cmtt-8"> </span> 8972</div> 8973 </dd></dl> 8974 8975 8976 8977<h3 class="sectionHead"><span class="titlemark">8 </span> <a 8978 id="x1-1020008"></a>Residue setup and decode</h3> 8979<!--l. 6--><p class="noindent" > 8980<h4 class="subsectionHead"><span class="titlemark">8.1 </span> <a 8981 id="x1-1030008.1"></a>Overview</h4> 8982<!--l. 8--><p class="noindent" >A residue vector represents the fine detail of the audio spectrum of one channel in an audio frame 8983after the encoder subtracts the floor curve and performs any channel coupling. A residue vector 8984may represent spectral lines, spectral magnitude, spectral phase or hybrids as mixed by channel 8985coupling. The exact semantic content of the vector does not matter to the residue 8986abstraction. 8987<!--l. 15--><p class="noindent" >Whatever the exact qualities, the Vorbis residue abstraction codes the residue vectors into the 8988bitstream packet, and then reconstructs the vectors during decode. Vorbis makes use of three 8989different encoding variants (numbered 0, 1 and 2) of the same basic vector encoding 8990abstraction. 8991<!--l. 23--><p class="noindent" > 8992<h4 class="subsectionHead"><span class="titlemark">8.2 </span> <a 8993 id="x1-1040008.2"></a>Residue format</h4> 8994<!--l. 25--><p class="noindent" >Residue format partitions each vector in the vector bundle into chunks, classifies each 8995chunk, encodes the chunk classifications and finally encodes the chunks themselves 8996using the the specific VQ arrangement defined for each selected classification. The 8997exact interleaving and partitioning vary by residue encoding number, however the 8998high-level process used to classify and encode the residue vector is the same in all three 8999variants. 9000<!--l. 33--><p class="noindent" >A set of coded residue vectors are all of the same length. High level coding structure, ignoring for 9001the moment exactly how a partition is encoded and simply trusting that it is, is as 9002follows: 9003 <ul class="itemize1"> 9004 <li class="itemize">Each vector is partitioned into multiple equal sized chunks according to configuration 9005 specified. If we have a vector size of <span 9006class="cmti-12">n</span>, a partition size <span 9007class="cmti-12">residue˙partition˙size</span>, and 9008 a total of <span 9009class="cmti-12">ch </span>residue vectors, the total number of partitioned chunks coded is 9010 9011 9012 9013 <span 9014class="cmti-12">n</span>/<span 9015class="cmti-12">residue˙partition˙size</span>*<span 9016class="cmti-12">ch</span>. It is important to note that the integer division truncates. 9017 In the below example, we assume an example <span 9018class="cmti-12">residue˙partition˙size </span>of 8. 9019 </li> 9020 <li class="itemize">Each partition in each vector has a classification number that specifies which of 9021 multiple configured VQ codebook setups are used to decode that partition. The 9022 classification numbers of each partition can be thought of as forming a vector in 9023 their own right, as in the illustration below. Just as the residue vectors are coded 9024 in grouped partitions to increase encoding efficiency, the classification vector is also 9025 partitioned into chunks. The integer elements of each scalar in a classification chunk 9026 are built into a single scalar that represents the classification numbers in that chunk. 9027 In the below example, the classification codeword encodes two classification numbers. 9028 </li> 9029 <li class="itemize">The values in a residue vector may be encoded monolithically in a single pass through 9030 the residue vector, but more often efficient codebook design dictates that each vector 9031 is encoded as the additive sum of several passes through the residue vector using 9032 more than one VQ codebook. Thus, each residue value potentially accumulates values 9033 from multiple decode passes. The classification value associated with a partition is 9034 the same in each pass, thus the classification codeword is coded only in the first pass. 9035 </li></ul> 9036<div class="center" 9037> 9038<!--l. 70--><p class="noindent" > 9039 9040<!--l. 71--><p class="noindent" ><img 9041src="residue-pack.png" alt="PIC" 9042> 9043<br /> <div class="caption" 9044><span class="id">Figure 11: </span><span 9045class="content">illustration of residue vector format</span></div><!--tex4ht:label?: x1-10400111 --> 9046</div> 9047<!--l. 77--><p class="noindent" > 9048<h4 class="subsectionHead"><span class="titlemark">8.3 </span> <a 9049 id="x1-1050008.3"></a>residue 0</h4> 9050<!--l. 79--><p class="noindent" >Residue 0 and 1 differ only in the way the values within a residue partition are interleaved during 9051partition encoding (visually treated as a black box–or cyan box or brown box–in the above 9052figure). 9053<!--l. 83--><p class="noindent" >Residue encoding 0 interleaves VQ encoding according to the dimension of the codebook used to 9054 9055 9056 9057encode a partition in a specific pass. The dimension of the codebook need not be the same in 9058multiple passes, however the partition size must be an even multiple of the codebook 9059dimension. 9060<!--l. 89--><p class="noindent" >As an example, assume a partition vector of size eight, to be encoded by residue 0 using 9061codebook sizes of 8, 4, 2 and 1: 9062<!--l. 92--><p class="noindent" > 9063<div class="fancyvrb" id="fancyvrb33"> 9064<a 9065 id="x1-105002r1"></a><span 9066class="cmr-6">1</span><span 9067class="cmtt-8"> </span><span 9068class="cmtt-8"> </span> 9069<br class="fancyvrb" /><a 9070 id="x1-105004r2"></a><span 9071class="cmr-6">2</span><span 9072class="cmtt-8"> </span><span 9073class="cmtt-8"> </span><span 9074class="cmtt-8"> </span><span 9075class="cmtt-8"> </span><span 9076class="cmtt-8"> </span><span 9077class="cmtt-8"> </span><span 9078class="cmtt-8"> </span><span 9079class="cmtt-8"> </span><span 9080class="cmtt-8"> </span><span 9081class="cmtt-8"> </span><span 9082class="cmtt-8"> </span><span 9083class="cmtt-8"> </span><span 9084class="cmtt-8"> </span><span 9085class="cmtt-8"> original</span><span 9086class="cmtt-8"> residue</span><span 9087class="cmtt-8"> vector:</span><span 9088class="cmtt-8"> [</span><span 9089class="cmtt-8"> 0</span><span 9090class="cmtt-8"> 1</span><span 9091class="cmtt-8"> 2</span><span 9092class="cmtt-8"> 3</span><span 9093class="cmtt-8"> 4</span><span 9094class="cmtt-8"> 5</span><span 9095class="cmtt-8"> 6</span><span 9096class="cmtt-8"> 7</span><span 9097class="cmtt-8"> ]</span> 9098<br class="fancyvrb" /><a 9099 id="x1-105006r3"></a><span 9100class="cmr-6">3</span><span 9101class="cmtt-8"> </span><span 9102class="cmtt-8"> </span> 9103<br class="fancyvrb" /><a 9104 id="x1-105008r4"></a><span 9105class="cmr-6">4</span><span 9106class="cmtt-8"> </span><span 9107class="cmtt-8"> codebook</span><span 9108class="cmtt-8"> dimensions</span><span 9109class="cmtt-8"> =</span><span 9110class="cmtt-8"> 8</span><span 9111class="cmtt-8"> </span><span 9112class="cmtt-8"> encoded</span><span 9113class="cmtt-8"> as:</span><span 9114class="cmtt-8"> [</span><span 9115class="cmtt-8"> 0</span><span 9116class="cmtt-8"> 1</span><span 9117class="cmtt-8"> 2</span><span 9118class="cmtt-8"> 3</span><span 9119class="cmtt-8"> 4</span><span 9120class="cmtt-8"> 5</span><span 9121class="cmtt-8"> 6</span><span 9122class="cmtt-8"> 7</span><span 9123class="cmtt-8"> ]</span> 9124<br class="fancyvrb" /><a 9125 id="x1-105010r5"></a><span 9126class="cmr-6">5</span><span 9127class="cmtt-8"> </span><span 9128class="cmtt-8"> </span> 9129<br class="fancyvrb" /><a 9130 id="x1-105012r6"></a><span 9131class="cmr-6">6</span><span 9132class="cmtt-8"> </span><span 9133class="cmtt-8"> codebook</span><span 9134class="cmtt-8"> dimensions</span><span 9135class="cmtt-8"> =</span><span 9136class="cmtt-8"> 4</span><span 9137class="cmtt-8"> </span><span 9138class="cmtt-8"> encoded</span><span 9139class="cmtt-8"> as:</span><span 9140class="cmtt-8"> [</span><span 9141class="cmtt-8"> 0</span><span 9142class="cmtt-8"> 2</span><span 9143class="cmtt-8"> 4</span><span 9144class="cmtt-8"> 6</span><span 9145class="cmtt-8"> ],</span><span 9146class="cmtt-8"> [</span><span 9147class="cmtt-8"> 1</span><span 9148class="cmtt-8"> 3</span><span 9149class="cmtt-8"> 5</span><span 9150class="cmtt-8"> 7</span><span 9151class="cmtt-8"> ]</span> 9152<br class="fancyvrb" /><a 9153 id="x1-105014r7"></a><span 9154class="cmr-6">7</span><span 9155class="cmtt-8"> </span><span 9156class="cmtt-8"> </span> 9157<br class="fancyvrb" /><a 9158 id="x1-105016r8"></a><span 9159class="cmr-6">8</span><span 9160class="cmtt-8"> </span><span 9161class="cmtt-8"> codebook</span><span 9162class="cmtt-8"> dimensions</span><span 9163class="cmtt-8"> =</span><span 9164class="cmtt-8"> 2</span><span 9165class="cmtt-8"> </span><span 9166class="cmtt-8"> encoded</span><span 9167class="cmtt-8"> as:</span><span 9168class="cmtt-8"> [</span><span 9169class="cmtt-8"> 0</span><span 9170class="cmtt-8"> 4</span><span 9171class="cmtt-8"> ],</span><span 9172class="cmtt-8"> [</span><span 9173class="cmtt-8"> 1</span><span 9174class="cmtt-8"> 5</span><span 9175class="cmtt-8"> ],</span><span 9176class="cmtt-8"> [</span><span 9177class="cmtt-8"> 2</span><span 9178class="cmtt-8"> 6</span><span 9179class="cmtt-8"> ],</span><span 9180class="cmtt-8"> [</span><span 9181class="cmtt-8"> 3</span><span 9182class="cmtt-8"> 7</span><span 9183class="cmtt-8"> ]</span> 9184<br class="fancyvrb" /><a 9185 id="x1-105018r9"></a><span 9186class="cmr-6">9</span><span 9187class="cmtt-8"> </span><span 9188class="cmtt-8"> </span> 9189<br class="fancyvrb" /><a 9190 id="x1-105020r10"></a><span 9191class="cmr-6">10</span><span 9192class="cmtt-8"> </span><span 9193class="cmtt-8"> codebook</span><span 9194class="cmtt-8"> dimensions</span><span 9195class="cmtt-8"> =</span><span 9196class="cmtt-8"> 1</span><span 9197class="cmtt-8"> </span><span 9198class="cmtt-8"> encoded</span><span 9199class="cmtt-8"> as:</span><span 9200class="cmtt-8"> [</span><span 9201class="cmtt-8"> 0</span><span 9202class="cmtt-8"> ],</span><span 9203class="cmtt-8"> [</span><span 9204class="cmtt-8"> 1</span><span 9205class="cmtt-8"> ],</span><span 9206class="cmtt-8"> [</span><span 9207class="cmtt-8"> 2</span><span 9208class="cmtt-8"> ],</span><span 9209class="cmtt-8"> [</span><span 9210class="cmtt-8"> 3</span><span 9211class="cmtt-8"> ],</span><span 9212class="cmtt-8"> [</span><span 9213class="cmtt-8"> 4</span><span 9214class="cmtt-8"> ],</span><span 9215class="cmtt-8"> [</span><span 9216class="cmtt-8"> 5</span><span 9217class="cmtt-8"> ],</span><span 9218class="cmtt-8"> [</span><span 9219class="cmtt-8"> 6</span><span 9220class="cmtt-8"> ],</span><span 9221class="cmtt-8"> [</span><span 9222class="cmtt-8"> 7</span><span 9223class="cmtt-8"> ]</span> 9224<br class="fancyvrb" /><a 9225 id="x1-105022r11"></a><span 9226class="cmr-6">11</span><span 9227class="cmtt-8"> </span><span 9228class="cmtt-8"> </span> 9229</div> 9230<!--l. 106--><p class="noindent" >It is worth mentioning at this point that no configurable value in the residue coding setup is 9231restricted to a power of two. 9232<!--l. 111--><p class="noindent" > 9233<h4 class="subsectionHead"><span class="titlemark">8.4 </span> <a 9234 id="x1-1060008.4"></a>residue 1</h4> 9235<!--l. 113--><p class="noindent" >Residue 1 does not interleave VQ encoding. It represents partition vector scalars in order. As 9236with residue 0, however, partition length must be an integer multiple of the codebook dimension, 9237although dimension may vary from pass to pass. 9238<!--l. 118--><p class="noindent" >As an example, assume a partition vector of size eight, to be encoded by residue 0 using 9239codebook sizes of 8, 4, 2 and 1: 9240<!--l. 121--><p class="noindent" > 9241<div class="fancyvrb" id="fancyvrb34"> 9242<a 9243 id="x1-106002r1"></a><span 9244class="cmr-6">1</span><span 9245class="cmtt-8"> </span><span 9246class="cmtt-8"> </span> 9247<br class="fancyvrb" /><a 9248 id="x1-106004r2"></a><span 9249class="cmr-6">2</span><span 9250class="cmtt-8"> </span><span 9251class="cmtt-8"> </span><span 9252class="cmtt-8"> </span><span 9253class="cmtt-8"> </span><span 9254class="cmtt-8"> </span><span 9255class="cmtt-8"> </span><span 9256class="cmtt-8"> </span><span 9257class="cmtt-8"> </span><span 9258class="cmtt-8"> </span><span 9259class="cmtt-8"> </span><span 9260class="cmtt-8"> </span><span 9261class="cmtt-8"> </span><span 9262class="cmtt-8"> </span><span 9263class="cmtt-8"> original</span><span 9264class="cmtt-8"> residue</span><span 9265class="cmtt-8"> vector:</span><span 9266class="cmtt-8"> [</span><span 9267class="cmtt-8"> 0</span><span 9268class="cmtt-8"> 1</span><span 9269class="cmtt-8"> 2</span><span 9270class="cmtt-8"> 3</span><span 9271class="cmtt-8"> 4</span><span 9272class="cmtt-8"> 5</span><span 9273class="cmtt-8"> 6</span><span 9274class="cmtt-8"> 7</span><span 9275class="cmtt-8"> ]</span> 9276<br class="fancyvrb" /><a 9277 id="x1-106006r3"></a><span 9278class="cmr-6">3</span><span 9279class="cmtt-8"> </span><span 9280class="cmtt-8"> </span> 9281<br class="fancyvrb" /><a 9282 id="x1-106008r4"></a><span 9283class="cmr-6">4</span><span 9284class="cmtt-8"> </span><span 9285class="cmtt-8"> codebook</span><span 9286class="cmtt-8"> dimensions</span><span 9287class="cmtt-8"> =</span><span 9288class="cmtt-8"> 8</span><span 9289class="cmtt-8"> </span><span 9290class="cmtt-8"> encoded</span><span 9291class="cmtt-8"> as:</span><span 9292class="cmtt-8"> [</span><span 9293class="cmtt-8"> 0</span><span 9294class="cmtt-8"> 1</span><span 9295class="cmtt-8"> 2</span><span 9296class="cmtt-8"> 3</span><span 9297class="cmtt-8"> 4</span><span 9298class="cmtt-8"> 5</span><span 9299class="cmtt-8"> 6</span><span 9300class="cmtt-8"> 7</span><span 9301class="cmtt-8"> ]</span> 9302<br class="fancyvrb" /><a 9303 id="x1-106010r5"></a><span 9304class="cmr-6">5</span><span 9305class="cmtt-8"> </span><span 9306class="cmtt-8"> </span> 9307<br class="fancyvrb" /><a 9308 id="x1-106012r6"></a><span 9309class="cmr-6">6</span><span 9310class="cmtt-8"> </span><span 9311class="cmtt-8"> codebook</span><span 9312class="cmtt-8"> dimensions</span><span 9313class="cmtt-8"> =</span><span 9314class="cmtt-8"> 4</span><span 9315class="cmtt-8"> </span><span 9316class="cmtt-8"> encoded</span><span 9317class="cmtt-8"> as:</span><span 9318class="cmtt-8"> [</span><span 9319class="cmtt-8"> 0</span><span 9320class="cmtt-8"> 1</span><span 9321class="cmtt-8"> 2</span><span 9322class="cmtt-8"> 3</span><span 9323class="cmtt-8"> ],</span><span 9324class="cmtt-8"> [</span><span 9325class="cmtt-8"> 4</span><span 9326class="cmtt-8"> 5</span><span 9327class="cmtt-8"> 6</span><span 9328class="cmtt-8"> 7</span><span 9329class="cmtt-8"> ]</span> 9330<br class="fancyvrb" /><a 9331 id="x1-106014r7"></a><span 9332class="cmr-6">7</span><span 9333class="cmtt-8"> </span><span 9334class="cmtt-8"> </span> 9335<br class="fancyvrb" /><a 9336 id="x1-106016r8"></a><span 9337class="cmr-6">8</span><span 9338class="cmtt-8"> </span><span 9339class="cmtt-8"> codebook</span><span 9340class="cmtt-8"> dimensions</span><span 9341class="cmtt-8"> =</span><span 9342class="cmtt-8"> 2</span><span 9343class="cmtt-8"> </span><span 9344class="cmtt-8"> encoded</span><span 9345class="cmtt-8"> as:</span><span 9346class="cmtt-8"> [</span><span 9347class="cmtt-8"> 0</span><span 9348class="cmtt-8"> 1</span><span 9349class="cmtt-8"> ],</span><span 9350class="cmtt-8"> [</span><span 9351class="cmtt-8"> 2</span><span 9352class="cmtt-8"> 3</span><span 9353class="cmtt-8"> ],</span><span 9354class="cmtt-8"> [</span><span 9355class="cmtt-8"> 4</span><span 9356class="cmtt-8"> 5</span><span 9357class="cmtt-8"> ],</span><span 9358class="cmtt-8"> [</span><span 9359class="cmtt-8"> 6</span><span 9360class="cmtt-8"> 7</span><span 9361class="cmtt-8"> ]</span> 9362<br class="fancyvrb" /><a 9363 id="x1-106018r9"></a><span 9364class="cmr-6">9</span><span 9365class="cmtt-8"> </span><span 9366class="cmtt-8"> </span> 9367<br class="fancyvrb" /><a 9368 id="x1-106020r10"></a><span 9369class="cmr-6">10</span><span 9370class="cmtt-8"> </span><span 9371class="cmtt-8"> codebook</span><span 9372class="cmtt-8"> dimensions</span><span 9373class="cmtt-8"> =</span><span 9374class="cmtt-8"> 1</span><span 9375class="cmtt-8"> </span><span 9376class="cmtt-8"> encoded</span><span 9377class="cmtt-8"> as:</span><span 9378class="cmtt-8"> [</span><span 9379class="cmtt-8"> 0</span><span 9380class="cmtt-8"> ],</span><span 9381class="cmtt-8"> [</span><span 9382class="cmtt-8"> 1</span><span 9383class="cmtt-8"> ],</span><span 9384class="cmtt-8"> [</span><span 9385class="cmtt-8"> 2</span><span 9386class="cmtt-8"> ],</span><span 9387class="cmtt-8"> [</span><span 9388class="cmtt-8"> 3</span><span 9389class="cmtt-8"> ],</span><span 9390class="cmtt-8"> [</span><span 9391class="cmtt-8"> 4</span><span 9392class="cmtt-8"> ],</span><span 9393class="cmtt-8"> [</span><span 9394class="cmtt-8"> 5</span><span 9395class="cmtt-8"> ],</span><span 9396class="cmtt-8"> [</span><span 9397class="cmtt-8"> 6</span><span 9398class="cmtt-8"> ],</span><span 9399class="cmtt-8"> [</span><span 9400class="cmtt-8"> 7</span><span 9401class="cmtt-8"> ]</span> 9402<br class="fancyvrb" /><a 9403 id="x1-106022r11"></a><span 9404class="cmr-6">11</span><span 9405class="cmtt-8"> </span><span 9406class="cmtt-8"> </span> 9407 9408 9409 9410</div> 9411<!--l. 137--><p class="noindent" > 9412<h4 class="subsectionHead"><span class="titlemark">8.5 </span> <a 9413 id="x1-1070008.5"></a>residue 2</h4> 9414<!--l. 139--><p class="noindent" >Residue type two can be thought of as a variant of residue type 1. Rather than encoding multiple 9415passed-in vectors as in residue type 1, the <span 9416class="cmti-12">ch </span>passed in vectors of length <span 9417class="cmti-12">n </span>are first interleaved 9418and flattened into a single vector of length <span 9419class="cmti-12">ch</span>*<span 9420class="cmti-12">n</span>. Encoding then proceeds as in type 1. Decoding 9421is as in type 1 with decode interleave reversed. If operating on a single vector to begin with, 9422residue type 1 and type 2 are equivalent. 9423<div class="center" 9424> 9425<!--l. 147--><p class="noindent" > 9426 9427<!--l. 148--><p class="noindent" ><img 9428src="residue2.png" alt="PIC" 9429> 9430<br /> <div class="caption" 9431><span class="id">Figure 12: </span><span 9432class="content">illustration of residue type 2</span></div><!--tex4ht:label?: x1-10700112 --> 9433</div> 9434<!--l. 153--><p class="noindent" > 9435<h4 class="subsectionHead"><span class="titlemark">8.6 </span> <a 9436 id="x1-1080008.6"></a>Residue decode</h4> 9437<!--l. 155--><p class="noindent" > 9438<h5 class="subsubsectionHead"><span class="titlemark">8.6.1 </span> <a 9439 id="x1-1090008.6.1"></a>header decode</h5> 9440<!--l. 157--><p class="noindent" >Header decode for all three residue types is identical. 9441<div class="fancyvrb" id="fancyvrb35"> 9442<a 9443 id="x1-109002r1"></a><span 9444class="cmr-6">1</span><span 9445class="cmtt-8"> </span><span 9446class="cmtt-8"> </span><span 9447class="cmtt-8"> </span><span 9448class="cmtt-8"> 1)</span><span 9449class="cmtt-8"> [residue_begin]</span><span 9450class="cmtt-8"> =</span><span 9451class="cmtt-8"> read</span><span 9452class="cmtt-8"> 24</span><span 9453class="cmtt-8"> bits</span><span 9454class="cmtt-8"> as</span><span 9455class="cmtt-8"> unsigned</span><span 9456class="cmtt-8"> integer</span> 9457<br class="fancyvrb" /><a 9458 id="x1-109004r2"></a><span 9459class="cmr-6">2</span><span 9460class="cmtt-8"> </span><span 9461class="cmtt-8"> </span><span 9462class="cmtt-8"> </span><span 9463class="cmtt-8"> 2)</span><span 9464class="cmtt-8"> [residue_end]</span><span 9465class="cmtt-8"> =</span><span 9466class="cmtt-8"> read</span><span 9467class="cmtt-8"> 24</span><span 9468class="cmtt-8"> bits</span><span 9469class="cmtt-8"> as</span><span 9470class="cmtt-8"> unsigned</span><span 9471class="cmtt-8"> integer</span> 9472<br class="fancyvrb" /><a 9473 id="x1-109006r3"></a><span 9474class="cmr-6">3</span><span 9475class="cmtt-8"> </span><span 9476class="cmtt-8"> </span><span 9477class="cmtt-8"> </span><span 9478class="cmtt-8"> 3)</span><span 9479class="cmtt-8"> [residue_partition_size]</span><span 9480class="cmtt-8"> =</span><span 9481class="cmtt-8"> read</span><span 9482class="cmtt-8"> 24</span><span 9483class="cmtt-8"> bits</span><span 9484class="cmtt-8"> as</span><span 9485class="cmtt-8"> unsigned</span><span 9486class="cmtt-8"> integer</span><span 9487class="cmtt-8"> and</span><span 9488class="cmtt-8"> add</span><span 9489class="cmtt-8"> one</span> 9490<br class="fancyvrb" /><a 9491 id="x1-109008r4"></a><span 9492class="cmr-6">4</span><span 9493class="cmtt-8"> </span><span 9494class="cmtt-8"> </span><span 9495class="cmtt-8"> </span><span 9496class="cmtt-8"> 4)</span><span 9497class="cmtt-8"> [residue_classifications]</span><span 9498class="cmtt-8"> =</span><span 9499class="cmtt-8"> read</span><span 9500class="cmtt-8"> 6</span><span 9501class="cmtt-8"> bits</span><span 9502class="cmtt-8"> as</span><span 9503class="cmtt-8"> unsigned</span><span 9504class="cmtt-8"> integer</span><span 9505class="cmtt-8"> and</span><span 9506class="cmtt-8"> add</span><span 9507class="cmtt-8"> one</span> 9508 9509 9510 9511<br class="fancyvrb" /><a 9512 id="x1-109010r5"></a><span 9513class="cmr-6">5</span><span 9514class="cmtt-8"> </span><span 9515class="cmtt-8"> </span><span 9516class="cmtt-8"> </span><span 9517class="cmtt-8"> 5)</span><span 9518class="cmtt-8"> [residue_classbook]</span><span 9519class="cmtt-8"> =</span><span 9520class="cmtt-8"> read</span><span 9521class="cmtt-8"> 8</span><span 9522class="cmtt-8"> bits</span><span 9523class="cmtt-8"> as</span><span 9524class="cmtt-8"> unsigned</span><span 9525class="cmtt-8"> integer</span> 9526</div> 9527<!--l. 166--><p class="noindent" ><span 9528class="cmtt-12">[residue_begin] </span>and <span 9529class="cmtt-12">[residue_end] </span>select the specific sub-portion of each vector that is 9530actually coded; it implements akin to a bandpass where, for coding purposes, the vector 9531effectively begins at element <span 9532class="cmtt-12">[residue_begin] </span>and ends at <span 9533class="cmtt-12">[residue_end]</span>. Preceding and 9534following values in the unpacked vectors are zeroed. Note that for residue type 2, these 9535values as well as <span 9536class="cmtt-12">[residue_partition_size]</span>apply to the interleaved vector, not the 9537individual vectors before interleave. <span 9538class="cmtt-12">[residue_partition_size] </span>is as explained above, 9539<span 9540class="cmtt-12">[residue_classifications] </span>is the number of possible classification to which a partition can 9541belong and <span 9542class="cmtt-12">[residue_classbook] </span>is the codebook number used to code classification 9543codewords. The number of dimensions in book <span 9544class="cmtt-12">[residue_classbook] </span>determines how 9545many classification values are grouped into a single classification codeword. Note that 9546the number of entries and dimensions in book <span 9547class="cmtt-12">[residue_classbook]</span>, along with 9548<span 9549class="cmtt-12">[residue_classifications]</span>, overdetermines to possible number of classification 9550codewords. If <span 9551class="cmtt-12">[residue_classifications]</span>ˆ<span 9552class="cmtt-12">[residue_classbook]</span>.dimensions exceeds 9553<span 9554class="cmtt-12">[residue_classbook]</span>.entries, the bitstream should be regarded to be undecodable. 9555<!--l. 190--><p class="noindent" >Next we read a bitmap pattern that specifies which partition classes code values in which 9556passes. 9557<!--l. 193--><p class="noindent" > 9558<div class="fancyvrb" id="fancyvrb36"> 9559<a 9560 id="x1-109012r1"></a><span 9561class="cmr-6">1</span><span 9562class="cmtt-8"> </span><span 9563class="cmtt-8"> </span><span 9564class="cmtt-8"> </span><span 9565class="cmtt-8"> 1)</span><span 9566class="cmtt-8"> iterate</span><span 9567class="cmtt-8"> [i]</span><span 9568class="cmtt-8"> over</span><span 9569class="cmtt-8"> the</span><span 9570class="cmtt-8"> range</span><span 9571class="cmtt-8"> 0</span><span 9572class="cmtt-8"> ...</span><span 9573class="cmtt-8"> [residue_classifications]-1</span><span 9574class="cmtt-8"> {</span> 9575<br class="fancyvrb" /><a 9576 id="x1-109014r2"></a><span 9577class="cmr-6">2</span><span 9578class="cmtt-8"> </span><span 9579class="cmtt-8"> </span> 9580<br class="fancyvrb" /><a 9581 id="x1-109016r3"></a><span 9582class="cmr-6">3</span><span 9583class="cmtt-8"> </span><span 9584class="cmtt-8"> </span><span 9585class="cmtt-8"> </span><span 9586class="cmtt-8"> </span><span 9587class="cmtt-8"> </span><span 9588class="cmtt-8"> </span><span 9589class="cmtt-8"> </span><span 9590class="cmtt-8"> </span><span 9591class="cmtt-8"> 2)</span><span 9592class="cmtt-8"> [high_bits]</span><span 9593class="cmtt-8"> =</span><span 9594class="cmtt-8"> 0</span> 9595<br class="fancyvrb" /><a 9596 id="x1-109018r4"></a><span 9597class="cmr-6">4</span><span 9598class="cmtt-8"> </span><span 9599class="cmtt-8"> </span><span 9600class="cmtt-8"> </span><span 9601class="cmtt-8"> </span><span 9602class="cmtt-8"> </span><span 9603class="cmtt-8"> </span><span 9604class="cmtt-8"> </span><span 9605class="cmtt-8"> </span><span 9606class="cmtt-8"> 3)</span><span 9607class="cmtt-8"> [low_bits]</span><span 9608class="cmtt-8"> =</span><span 9609class="cmtt-8"> read</span><span 9610class="cmtt-8"> 3</span><span 9611class="cmtt-8"> bits</span><span 9612class="cmtt-8"> as</span><span 9613class="cmtt-8"> unsigned</span><span 9614class="cmtt-8"> integer</span> 9615<br class="fancyvrb" /><a 9616 id="x1-109020r5"></a><span 9617class="cmr-6">5</span><span 9618class="cmtt-8"> </span><span 9619class="cmtt-8"> </span><span 9620class="cmtt-8"> </span><span 9621class="cmtt-8"> </span><span 9622class="cmtt-8"> </span><span 9623class="cmtt-8"> </span><span 9624class="cmtt-8"> </span><span 9625class="cmtt-8"> </span><span 9626class="cmtt-8"> 4)</span><span 9627class="cmtt-8"> [bitflag]</span><span 9628class="cmtt-8"> =</span><span 9629class="cmtt-8"> read</span><span 9630class="cmtt-8"> one</span><span 9631class="cmtt-8"> bit</span><span 9632class="cmtt-8"> as</span><span 9633class="cmtt-8"> boolean</span> 9634<br class="fancyvrb" /><a 9635 id="x1-109022r6"></a><span 9636class="cmr-6">6</span><span 9637class="cmtt-8"> </span><span 9638class="cmtt-8"> </span><span 9639class="cmtt-8"> </span><span 9640class="cmtt-8"> </span><span 9641class="cmtt-8"> </span><span 9642class="cmtt-8"> </span><span 9643class="cmtt-8"> </span><span 9644class="cmtt-8"> </span><span 9645class="cmtt-8"> 5)</span><span 9646class="cmtt-8"> if</span><span 9647class="cmtt-8"> (</span><span 9648class="cmtt-8"> [bitflag]</span><span 9649class="cmtt-8"> is</span><span 9650class="cmtt-8"> set</span><span 9651class="cmtt-8"> )</span><span 9652class="cmtt-8"> then</span><span 9653class="cmtt-8"> [high_bits]</span><span 9654class="cmtt-8"> =</span><span 9655class="cmtt-8"> read</span><span 9656class="cmtt-8"> five</span><span 9657class="cmtt-8"> bits</span><span 9658class="cmtt-8"> as</span><span 9659class="cmtt-8"> unsigned</span><span 9660class="cmtt-8"> integer</span> 9661<br class="fancyvrb" /><a 9662 id="x1-109024r7"></a><span 9663class="cmr-6">7</span><span 9664class="cmtt-8"> </span><span 9665class="cmtt-8"> </span><span 9666class="cmtt-8"> </span><span 9667class="cmtt-8"> </span><span 9668class="cmtt-8"> </span><span 9669class="cmtt-8"> </span><span 9670class="cmtt-8"> </span><span 9671class="cmtt-8"> </span><span 9672class="cmtt-8"> 6)</span><span 9673class="cmtt-8"> vector</span><span 9674class="cmtt-8"> [residue_cascade]</span><span 9675class="cmtt-8"> element</span><span 9676class="cmtt-8"> [i]</span><span 9677class="cmtt-8"> =</span><span 9678class="cmtt-8"> [high_bits]</span><span 9679class="cmtt-8"> *</span><span 9680class="cmtt-8"> 8</span><span 9681class="cmtt-8"> +</span><span 9682class="cmtt-8"> [low_bits]</span> 9683<br class="fancyvrb" /><a 9684 id="x1-109026r8"></a><span 9685class="cmr-6">8</span><span 9686class="cmtt-8"> </span><span 9687class="cmtt-8"> </span><span 9688class="cmtt-8"> </span><span 9689class="cmtt-8"> </span><span 9690class="cmtt-8"> </span><span 9691class="cmtt-8"> </span><span 9692class="cmtt-8"> }</span> 9693<br class="fancyvrb" /><a 9694 id="x1-109028r9"></a><span 9695class="cmr-6">9</span><span 9696class="cmtt-8"> </span><span 9697class="cmtt-8"> </span><span 9698class="cmtt-8"> </span><span 9699class="cmtt-8"> 7)</span><span 9700class="cmtt-8"> done</span> 9701</div> 9702<!--l. 205--><p class="noindent" >Finally, we read in a list of book numbers, each corresponding to specific bit set in the cascade 9703bitmap. We loop over the possible codebook classifications and the maximum possible number of 9704encoding stages (8 in Vorbis I, as constrained by the elements of the cascade bitmap being eight 9705bits): 9706<!--l. 211--><p class="noindent" > 9707<div class="fancyvrb" id="fancyvrb37"> 9708<a 9709 id="x1-109030r1"></a><span 9710class="cmr-6">1</span><span 9711class="cmtt-8"> </span><span 9712class="cmtt-8"> </span><span 9713class="cmtt-8"> </span><span 9714class="cmtt-8"> 1)</span><span 9715class="cmtt-8"> iterate</span><span 9716class="cmtt-8"> [i]</span><span 9717class="cmtt-8"> over</span><span 9718class="cmtt-8"> the</span><span 9719class="cmtt-8"> range</span><span 9720class="cmtt-8"> 0</span><span 9721class="cmtt-8"> ...</span><span 9722class="cmtt-8"> [residue_classifications]-1</span><span 9723class="cmtt-8"> {</span> 9724<br class="fancyvrb" /><a 9725 id="x1-109032r2"></a><span 9726class="cmr-6">2</span><span 9727class="cmtt-8"> </span><span 9728class="cmtt-8"> </span> 9729<br class="fancyvrb" /><a 9730 id="x1-109034r3"></a><span 9731class="cmr-6">3</span><span 9732class="cmtt-8"> </span><span 9733class="cmtt-8"> </span><span 9734class="cmtt-8"> </span><span 9735class="cmtt-8"> </span><span 9736class="cmtt-8"> </span><span 9737class="cmtt-8"> </span><span 9738class="cmtt-8"> </span><span 9739class="cmtt-8"> </span><span 9740class="cmtt-8"> 2)</span><span 9741class="cmtt-8"> iterate</span><span 9742class="cmtt-8"> [j]</span><span 9743class="cmtt-8"> over</span><span 9744class="cmtt-8"> the</span><span 9745class="cmtt-8"> range</span><span 9746class="cmtt-8"> 0</span><span 9747class="cmtt-8"> ...</span><span 9748class="cmtt-8"> 7</span><span 9749class="cmtt-8"> {</span> 9750<br class="fancyvrb" /><a 9751 id="x1-109036r4"></a><span 9752class="cmr-6">4</span><span 9753class="cmtt-8"> </span><span 9754class="cmtt-8"> </span> 9755<br class="fancyvrb" /><a 9756 id="x1-109038r5"></a><span 9757class="cmr-6">5</span><span 9758class="cmtt-8"> </span><span 9759class="cmtt-8"> </span><span 9760class="cmtt-8"> </span><span 9761class="cmtt-8"> </span><span 9762class="cmtt-8"> </span><span 9763class="cmtt-8"> </span><span 9764class="cmtt-8"> </span><span 9765class="cmtt-8"> </span><span 9766class="cmtt-8"> </span><span 9767class="cmtt-8"> </span><span 9768class="cmtt-8"> </span><span 9769class="cmtt-8"> </span><span 9770class="cmtt-8"> </span><span 9771class="cmtt-8"> 3)</span><span 9772class="cmtt-8"> if</span><span 9773class="cmtt-8"> (</span><span 9774class="cmtt-8"> vector</span><span 9775class="cmtt-8"> [residue_cascade]</span><span 9776class="cmtt-8"> element</span><span 9777class="cmtt-8"> [i]</span><span 9778class="cmtt-8"> bit</span><span 9779class="cmtt-8"> [j]</span><span 9780class="cmtt-8"> is</span><span 9781class="cmtt-8"> set</span><span 9782class="cmtt-8"> )</span><span 9783class="cmtt-8"> {</span> 9784<br class="fancyvrb" /><a 9785 id="x1-109040r6"></a><span 9786class="cmr-6">6</span><span 9787class="cmtt-8"> </span><span 9788class="cmtt-8"> </span> 9789<br class="fancyvrb" /><a 9790 id="x1-109042r7"></a><span 9791class="cmr-6">7</span><span 9792class="cmtt-8"> </span><span 9793class="cmtt-8"> </span><span 9794class="cmtt-8"> </span><span 9795class="cmtt-8"> </span><span 9796class="cmtt-8"> </span><span 9797class="cmtt-8"> </span><span 9798class="cmtt-8"> </span><span 9799class="cmtt-8"> </span><span 9800class="cmtt-8"> </span><span 9801class="cmtt-8"> </span><span 9802class="cmtt-8"> </span><span 9803class="cmtt-8"> </span><span 9804class="cmtt-8"> </span><span 9805class="cmtt-8"> </span><span 9806class="cmtt-8"> </span><span 9807class="cmtt-8"> </span><span 9808class="cmtt-8"> </span><span 9809class="cmtt-8"> </span><span 9810class="cmtt-8"> 4)</span><span 9811class="cmtt-8"> array</span><span 9812class="cmtt-8"> [residue_books]</span><span 9813class="cmtt-8"> element</span><span 9814class="cmtt-8"> [i][j]</span><span 9815class="cmtt-8"> =</span><span 9816class="cmtt-8"> read</span><span 9817class="cmtt-8"> 8</span><span 9818class="cmtt-8"> bits</span><span 9819class="cmtt-8"> as</span><span 9820class="cmtt-8"> unsigned</span><span 9821class="cmtt-8"> integer</span> 9822<br class="fancyvrb" /><a 9823 id="x1-109044r8"></a><span 9824class="cmr-6">8</span><span 9825class="cmtt-8"> </span><span 9826class="cmtt-8"> </span> 9827<br class="fancyvrb" /><a 9828 id="x1-109046r9"></a><span 9829class="cmr-6">9</span><span 9830class="cmtt-8"> </span><span 9831class="cmtt-8"> </span><span 9832class="cmtt-8"> </span><span 9833class="cmtt-8"> </span><span 9834class="cmtt-8"> </span><span 9835class="cmtt-8"> </span><span 9836class="cmtt-8"> </span><span 9837class="cmtt-8"> </span><span 9838class="cmtt-8"> </span><span 9839class="cmtt-8"> </span><span 9840class="cmtt-8"> </span><span 9841class="cmtt-8"> </span><span 9842class="cmtt-8"> </span><span 9843class="cmtt-8"> </span><span 9844class="cmtt-8"> </span><span 9845class="cmtt-8"> </span><span 9846class="cmtt-8"> }</span><span 9847class="cmtt-8"> else</span><span 9848class="cmtt-8"> {</span> 9849 9850 9851 9852<br class="fancyvrb" /><a 9853 id="x1-109048r10"></a><span 9854class="cmr-6">10</span><span 9855class="cmtt-8"> </span><span 9856class="cmtt-8"> </span> 9857<br class="fancyvrb" /><a 9858 id="x1-109050r11"></a><span 9859class="cmr-6">11</span><span 9860class="cmtt-8"> </span><span 9861class="cmtt-8"> </span><span 9862class="cmtt-8"> </span><span 9863class="cmtt-8"> </span><span 9864class="cmtt-8"> </span><span 9865class="cmtt-8"> </span><span 9866class="cmtt-8"> </span><span 9867class="cmtt-8"> </span><span 9868class="cmtt-8"> </span><span 9869class="cmtt-8"> </span><span 9870class="cmtt-8"> </span><span 9871class="cmtt-8"> </span><span 9872class="cmtt-8"> </span><span 9873class="cmtt-8"> </span><span 9874class="cmtt-8"> </span><span 9875class="cmtt-8"> </span><span 9876class="cmtt-8"> </span><span 9877class="cmtt-8"> </span><span 9878class="cmtt-8"> 5)</span><span 9879class="cmtt-8"> array</span><span 9880class="cmtt-8"> [residue_books]</span><span 9881class="cmtt-8"> element</span><span 9882class="cmtt-8"> [i][j]</span><span 9883class="cmtt-8"> =</span><span 9884class="cmtt-8"> unused</span> 9885<br class="fancyvrb" /><a 9886 id="x1-109052r12"></a><span 9887class="cmr-6">12</span><span 9888class="cmtt-8"> </span><span 9889class="cmtt-8"> </span> 9890<br class="fancyvrb" /><a 9891 id="x1-109054r13"></a><span 9892class="cmr-6">13</span><span 9893class="cmtt-8"> </span><span 9894class="cmtt-8"> </span><span 9895class="cmtt-8"> </span><span 9896class="cmtt-8"> </span><span 9897class="cmtt-8"> </span><span 9898class="cmtt-8"> </span><span 9899class="cmtt-8"> </span><span 9900class="cmtt-8"> </span><span 9901class="cmtt-8"> </span><span 9902class="cmtt-8"> </span><span 9903class="cmtt-8"> </span><span 9904class="cmtt-8"> </span><span 9905class="cmtt-8"> </span><span 9906class="cmtt-8"> </span><span 9907class="cmtt-8"> </span><span 9908class="cmtt-8"> </span><span 9909class="cmtt-8"> }</span> 9910<br class="fancyvrb" /><a 9911 id="x1-109056r14"></a><span 9912class="cmr-6">14</span><span 9913class="cmtt-8"> </span><span 9914class="cmtt-8"> </span><span 9915class="cmtt-8"> </span><span 9916class="cmtt-8"> </span><span 9917class="cmtt-8"> </span><span 9918class="cmtt-8"> </span><span 9919class="cmtt-8"> </span><span 9920class="cmtt-8"> </span><span 9921class="cmtt-8"> </span><span 9922class="cmtt-8"> </span><span 9923class="cmtt-8"> </span><span 9924class="cmtt-8"> }</span> 9925<br class="fancyvrb" /><a 9926 id="x1-109058r15"></a><span 9927class="cmr-6">15</span><span 9928class="cmtt-8"> </span><span 9929class="cmtt-8"> </span><span 9930class="cmtt-8"> </span><span 9931class="cmtt-8"> </span><span 9932class="cmtt-8"> </span><span 9933class="cmtt-8"> </span><span 9934class="cmtt-8"> </span><span 9935class="cmtt-8"> }</span> 9936<br class="fancyvrb" /><a 9937 id="x1-109060r16"></a><span 9938class="cmr-6">16</span><span 9939class="cmtt-8"> </span><span 9940class="cmtt-8"> </span> 9941<br class="fancyvrb" /><a 9942 id="x1-109062r17"></a><span 9943class="cmr-6">17</span><span 9944class="cmtt-8"> </span><span 9945class="cmtt-8"> </span><span 9946class="cmtt-8"> </span><span 9947class="cmtt-8"> 6)</span><span 9948class="cmtt-8"> done</span> 9949</div> 9950<!--l. 231--><p class="noindent" >An end-of-packet condition at any point in header decode renders the stream undecodable. 9951In addition, any codebook number greater than the maximum numbered codebook 9952set up in this stream also renders the stream undecodable. All codebooks in array 9953[residue˙books] are required to have a value mapping. The presence of codebook in array 9954[residue˙books] without a value mapping (maptype equals zero) renders the stream 9955undecodable. 9956<!--l. 241--><p class="noindent" > 9957<h5 class="subsubsectionHead"><span class="titlemark">8.6.2 </span> <a 9958 id="x1-1100008.6.2"></a>packet decode</h5> 9959<!--l. 243--><p class="noindent" >Format 0 and 1 packet decode is identical except for specific partition interleave. Format 2 packet 9960decode can be built out of the format 1 decode process. Thus we describe first the decode 9961infrastructure identical to all three formats. 9962<!--l. 248--><p class="noindent" >In addition to configuration information, the residue decode process is passed the number of 9963vectors in the submap bundle and a vector of flags indicating if any of the vectors are not to be 9964decoded. If the passed in number of vectors is 3 and vector number 1 is marked ’do not decode’, 9965decode skips vector 1 during the decode loop. However, even ’do not decode’ vectors are 9966allocated and zeroed. 9967<!--l. 255--><p class="noindent" >Depending on the values of <span 9968class="cmtt-12">[residue_begin] </span>and <span 9969class="cmtt-12">[residue_end]</span>, it is obvious that the 9970encoded portion of a residue vector may be the entire possible residue vector or some other strict 9971subset of the actual residue vector size with zero padding at either uncoded end. However, it is 9972also possible to set <span 9973class="cmtt-12">[residue_begin] </span>and <span 9974class="cmtt-12">[residue_end] </span>to specify a range partially or wholly 9975beyond the maximum vector size. Before beginning residue decode, limit <span 9976class="cmtt-12">[residue_begin]</span> 9977and <span 9978class="cmtt-12">[residue_end] </span>to the maximum possible vector size as follows. We assume that 9979the number of vectors being encoded, <span 9980class="cmtt-12">[ch] </span>is provided by the higher level decoding 9981process. 9982<!--l. 269--><p class="noindent" > 9983<div class="fancyvrb" id="fancyvrb38"> 9984<a 9985 id="x1-110002r1"></a><span 9986class="cmr-6">1</span><span 9987class="cmtt-8"> </span><span 9988class="cmtt-8"> </span><span 9989class="cmtt-8"> </span><span 9990class="cmtt-8"> 1)</span><span 9991class="cmtt-8"> [actual_size]</span><span 9992class="cmtt-8"> =</span><span 9993class="cmtt-8"> current</span><span 9994class="cmtt-8"> blocksize/2;</span> 9995<br class="fancyvrb" /><a 9996 id="x1-110004r2"></a><span 9997class="cmr-6">2</span><span 9998class="cmtt-8"> </span><span 9999class="cmtt-8"> </span><span 10000class="cmtt-8"> </span><span 10001class="cmtt-8"> 2)</span><span 10002class="cmtt-8"> if</span><span 10003class="cmtt-8"> residue</span><span 10004class="cmtt-8"> encoding</span><span 10005class="cmtt-8"> is</span><span 10006class="cmtt-8"> format</span><span 10007class="cmtt-8"> 2</span> 10008<br class="fancyvrb" /><a 10009 id="x1-110006r3"></a><span 10010class="cmr-6">3</span><span 10011class="cmtt-8"> </span><span 10012class="cmtt-8"> </span><span 10013class="cmtt-8"> </span><span 10014class="cmtt-8"> </span><span 10015class="cmtt-8"> </span><span 10016class="cmtt-8"> </span><span 10017class="cmtt-8"> </span><span 10018class="cmtt-8"> </span><span 10019class="cmtt-8"> 3)</span><span 10020class="cmtt-8"> [actual_size]</span><span 10021class="cmtt-8"> =</span><span 10022class="cmtt-8"> [actual_size]</span><span 10023class="cmtt-8"> *</span><span 10024class="cmtt-8"> [ch];</span> 10025 10026 10027 10028<br class="fancyvrb" /><a 10029 id="x1-110008r4"></a><span 10030class="cmr-6">4</span><span 10031class="cmtt-8"> </span><span 10032class="cmtt-8"> </span><span 10033class="cmtt-8"> </span><span 10034class="cmtt-8"> 4)</span><span 10035class="cmtt-8"> [limit_residue_begin]</span><span 10036class="cmtt-8"> =</span><span 10037class="cmtt-8"> maximum</span><span 10038class="cmtt-8"> of</span><span 10039class="cmtt-8"> ([residue_begin],[actual_size]);</span> 10040<br class="fancyvrb" /><a 10041 id="x1-110010r5"></a><span 10042class="cmr-6">5</span><span 10043class="cmtt-8"> </span><span 10044class="cmtt-8"> </span><span 10045class="cmtt-8"> </span><span 10046class="cmtt-8"> 5)</span><span 10047class="cmtt-8"> [limit_residue_end]</span><span 10048class="cmtt-8"> =</span><span 10049class="cmtt-8"> maximum</span><span 10050class="cmtt-8"> of</span><span 10051class="cmtt-8"> ([residue_end],[actual_size]);</span> 10052</div> 10053<!--l. 277--><p class="noindent" >The following convenience values are conceptually useful to clarifying the decode process: 10054<!--l. 280--><p class="noindent" > 10055<div class="fancyvrb" id="fancyvrb39"> 10056<a 10057 id="x1-110012r1"></a><span 10058class="cmr-6">1</span><span 10059class="cmtt-8"> </span><span 10060class="cmtt-8"> </span><span 10061class="cmtt-8"> </span><span 10062class="cmtt-8"> 1)</span><span 10063class="cmtt-8"> [classwords_per_codeword]</span><span 10064class="cmtt-8"> =</span><span 10065class="cmtt-8"> [codebook_dimensions]</span><span 10066class="cmtt-8"> value</span><span 10067class="cmtt-8"> of</span><span 10068class="cmtt-8"> codebook</span><span 10069class="cmtt-8"> [residue_classbook]</span> 10070<br class="fancyvrb" /><a 10071 id="x1-110014r2"></a><span 10072class="cmr-6">2</span><span 10073class="cmtt-8"> </span><span 10074class="cmtt-8"> </span><span 10075class="cmtt-8"> </span><span 10076class="cmtt-8"> 2)</span><span 10077class="cmtt-8"> [n_to_read]</span><span 10078class="cmtt-8"> =</span><span 10079class="cmtt-8"> [limit_residue_end]</span><span 10080class="cmtt-8"> -</span><span 10081class="cmtt-8"> [limit_residue_begin]</span> 10082<br class="fancyvrb" /><a 10083 id="x1-110016r3"></a><span 10084class="cmr-6">3</span><span 10085class="cmtt-8"> </span><span 10086class="cmtt-8"> </span><span 10087class="cmtt-8"> </span><span 10088class="cmtt-8"> 3)</span><span 10089class="cmtt-8"> [partitions_to_read]</span><span 10090class="cmtt-8"> =</span><span 10091class="cmtt-8"> [n_to_read]</span><span 10092class="cmtt-8"> /</span><span 10093class="cmtt-8"> [residue_partition_size]</span> 10094</div> 10095<!--l. 286--><p class="noindent" >Packet decode proceeds as follows, matching the description offered earlier in the document. 10096<div class="fancyvrb" id="fancyvrb40"> 10097<a 10098 id="x1-110018r1"></a><span 10099class="cmr-6">1</span><span 10100class="cmtt-8"> </span><span 10101class="cmtt-8"> </span><span 10102class="cmtt-8"> </span><span 10103class="cmtt-8"> 1)</span><span 10104class="cmtt-8"> allocate</span><span 10105class="cmtt-8"> and</span><span 10106class="cmtt-8"> zero</span><span 10107class="cmtt-8"> all</span><span 10108class="cmtt-8"> vectors</span><span 10109class="cmtt-8"> that</span><span 10110class="cmtt-8"> will</span><span 10111class="cmtt-8"> be</span><span 10112class="cmtt-8"> returned.</span> 10113<br class="fancyvrb" /><a 10114 id="x1-110020r2"></a><span 10115class="cmr-6">2</span><span 10116class="cmtt-8"> </span><span 10117class="cmtt-8"> </span><span 10118class="cmtt-8"> </span><span 10119class="cmtt-8"> 2)</span><span 10120class="cmtt-8"> if</span><span 10121class="cmtt-8"> ([n_to_read]</span><span 10122class="cmtt-8"> is</span><span 10123class="cmtt-8"> zero),</span><span 10124class="cmtt-8"> stop;</span><span 10125class="cmtt-8"> there</span><span 10126class="cmtt-8"> is</span><span 10127class="cmtt-8"> no</span><span 10128class="cmtt-8"> residue</span><span 10129class="cmtt-8"> to</span><span 10130class="cmtt-8"> decode.</span> 10131<br class="fancyvrb" /><a 10132 id="x1-110022r3"></a><span 10133class="cmr-6">3</span><span 10134class="cmtt-8"> </span><span 10135class="cmtt-8"> </span><span 10136class="cmtt-8"> </span><span 10137class="cmtt-8"> 3)</span><span 10138class="cmtt-8"> iterate</span><span 10139class="cmtt-8"> [pass]</span><span 10140class="cmtt-8"> over</span><span 10141class="cmtt-8"> the</span><span 10142class="cmtt-8"> range</span><span 10143class="cmtt-8"> 0</span><span 10144class="cmtt-8"> ...</span><span 10145class="cmtt-8"> 7</span><span 10146class="cmtt-8"> {</span> 10147<br class="fancyvrb" /><a 10148 id="x1-110024r4"></a><span 10149class="cmr-6">4</span><span 10150class="cmtt-8"> </span><span 10151class="cmtt-8"> </span> 10152<br class="fancyvrb" /><a 10153 id="x1-110026r5"></a><span 10154class="cmr-6">5</span><span 10155class="cmtt-8"> </span><span 10156class="cmtt-8"> </span><span 10157class="cmtt-8"> </span><span 10158class="cmtt-8"> </span><span 10159class="cmtt-8"> </span><span 10160class="cmtt-8"> </span><span 10161class="cmtt-8"> </span><span 10162class="cmtt-8"> </span><span 10163class="cmtt-8"> 4)</span><span 10164class="cmtt-8"> [partition_count]</span><span 10165class="cmtt-8"> =</span><span 10166class="cmtt-8"> 0</span> 10167<br class="fancyvrb" /><a 10168 id="x1-110028r6"></a><span 10169class="cmr-6">6</span><span 10170class="cmtt-8"> </span><span 10171class="cmtt-8"> </span> 10172<br class="fancyvrb" /><a 10173 id="x1-110030r7"></a><span 10174class="cmr-6">7</span><span 10175class="cmtt-8"> </span><span 10176class="cmtt-8"> </span><span 10177class="cmtt-8"> </span><span 10178class="cmtt-8"> </span><span 10179class="cmtt-8"> </span><span 10180class="cmtt-8"> </span><span 10181class="cmtt-8"> </span><span 10182class="cmtt-8"> </span><span 10183class="cmtt-8"> 5)</span><span 10184class="cmtt-8"> while</span><span 10185class="cmtt-8"> [partition_count]</span><span 10186class="cmtt-8"> is</span><span 10187class="cmtt-8"> less</span><span 10188class="cmtt-8"> than</span><span 10189class="cmtt-8"> [partitions_to_read]</span> 10190<br class="fancyvrb" /><a 10191 id="x1-110032r8"></a><span 10192class="cmr-6">8</span><span 10193class="cmtt-8"> </span><span 10194class="cmtt-8"> </span> 10195<br class="fancyvrb" /><a 10196 id="x1-110034r9"></a><span 10197class="cmr-6">9</span><span 10198class="cmtt-8"> </span><span 10199class="cmtt-8"> </span><span 10200class="cmtt-8"> </span><span 10201class="cmtt-8"> </span><span 10202class="cmtt-8"> </span><span 10203class="cmtt-8"> </span><span 10204class="cmtt-8"> </span><span 10205class="cmtt-8"> </span><span 10206class="cmtt-8"> </span><span 10207class="cmtt-8"> </span><span 10208class="cmtt-8"> </span><span 10209class="cmtt-8"> </span><span 10210class="cmtt-8"> </span><span 10211class="cmtt-8"> 6)</span><span 10212class="cmtt-8"> if</span><span 10213class="cmtt-8"> ([pass]</span><span 10214class="cmtt-8"> is</span><span 10215class="cmtt-8"> zero)</span><span 10216class="cmtt-8"> {</span> 10217<br class="fancyvrb" /><a 10218 id="x1-110036r10"></a><span 10219class="cmr-6">10</span><span 10220class="cmtt-8"> </span><span 10221class="cmtt-8"> </span> 10222<br class="fancyvrb" /><a 10223 id="x1-110038r11"></a><span 10224class="cmr-6">11</span><span 10225class="cmtt-8"> </span><span 10226class="cmtt-8"> </span><span 10227class="cmtt-8"> </span><span 10228class="cmtt-8"> </span><span 10229class="cmtt-8"> </span><span 10230class="cmtt-8"> </span><span 10231class="cmtt-8"> </span><span 10232class="cmtt-8"> </span><span 10233class="cmtt-8"> </span><span 10234class="cmtt-8"> </span><span 10235class="cmtt-8"> </span><span 10236class="cmtt-8"> </span><span 10237class="cmtt-8"> </span><span 10238class="cmtt-8"> </span><span 10239class="cmtt-8"> </span><span 10240class="cmtt-8"> </span><span 10241class="cmtt-8"> </span><span 10242class="cmtt-8"> </span><span 10243class="cmtt-8"> 7)</span><span 10244class="cmtt-8"> iterate</span><span 10245class="cmtt-8"> [j]</span><span 10246class="cmtt-8"> over</span><span 10247class="cmtt-8"> the</span><span 10248class="cmtt-8"> range</span><span 10249class="cmtt-8"> 0</span><span 10250class="cmtt-8"> ..</span><span 10251class="cmtt-8"> [ch]-1</span><span 10252class="cmtt-8"> {</span> 10253<br class="fancyvrb" /><a 10254 id="x1-110040r12"></a><span 10255class="cmr-6">12</span><span 10256class="cmtt-8"> </span><span 10257class="cmtt-8"> </span> 10258<br class="fancyvrb" /><a 10259 id="x1-110042r13"></a><span 10260class="cmr-6">13</span><span 10261class="cmtt-8"> </span><span 10262class="cmtt-8"> </span><span 10263class="cmtt-8"> </span><span 10264class="cmtt-8"> </span><span 10265class="cmtt-8"> </span><span 10266class="cmtt-8"> </span><span 10267class="cmtt-8"> </span><span 10268class="cmtt-8"> </span><span 10269class="cmtt-8"> </span><span 10270class="cmtt-8"> </span><span 10271class="cmtt-8"> </span><span 10272class="cmtt-8"> </span><span 10273class="cmtt-8"> </span><span 10274class="cmtt-8"> </span><span 10275class="cmtt-8"> </span><span 10276class="cmtt-8"> </span><span 10277class="cmtt-8"> </span><span 10278class="cmtt-8"> </span><span 10279class="cmtt-8"> </span><span 10280class="cmtt-8"> </span><span 10281class="cmtt-8"> </span><span 10282class="cmtt-8"> </span><span 10283class="cmtt-8"> </span><span 10284class="cmtt-8"> 8)</span><span 10285class="cmtt-8"> if</span><span 10286class="cmtt-8"> vector</span><span 10287class="cmtt-8"> [j]</span><span 10288class="cmtt-8"> is</span><span 10289class="cmtt-8"> not</span><span 10290class="cmtt-8"> marked</span><span 10291class="cmtt-8"> ’do</span><span 10292class="cmtt-8"> not</span><span 10293class="cmtt-8"> decode’</span><span 10294class="cmtt-8"> {</span> 10295<br class="fancyvrb" /><a 10296 id="x1-110044r14"></a><span 10297class="cmr-6">14</span><span 10298class="cmtt-8"> </span><span 10299class="cmtt-8"> </span> 10300<br class="fancyvrb" /><a 10301 id="x1-110046r15"></a><span 10302class="cmr-6">15</span><span 10303class="cmtt-8"> </span><span 10304class="cmtt-8"> </span><span 10305class="cmtt-8"> </span><span 10306class="cmtt-8"> </span><span 10307class="cmtt-8"> </span><span 10308class="cmtt-8"> </span><span 10309class="cmtt-8"> </span><span 10310class="cmtt-8"> </span><span 10311class="cmtt-8"> </span><span 10312class="cmtt-8"> </span><span 10313class="cmtt-8"> </span><span 10314class="cmtt-8"> </span><span 10315class="cmtt-8"> </span><span 10316class="cmtt-8"> </span><span 10317class="cmtt-8"> </span><span 10318class="cmtt-8"> </span><span 10319class="cmtt-8"> </span><span 10320class="cmtt-8"> </span><span 10321class="cmtt-8"> </span><span 10322class="cmtt-8"> </span><span 10323class="cmtt-8"> </span><span 10324class="cmtt-8"> </span><span 10325class="cmtt-8"> </span><span 10326class="cmtt-8"> </span><span 10327class="cmtt-8"> </span><span 10328class="cmtt-8"> </span><span 10329class="cmtt-8"> </span><span 10330class="cmtt-8"> </span><span 10331class="cmtt-8"> 9)</span><span 10332class="cmtt-8"> [temp]</span><span 10333class="cmtt-8"> =</span><span 10334class="cmtt-8"> read</span><span 10335class="cmtt-8"> from</span><span 10336class="cmtt-8"> packet</span><span 10337class="cmtt-8"> using</span><span 10338class="cmtt-8"> codebook</span><span 10339class="cmtt-8"> [residue_classbook]</span><span 10340class="cmtt-8"> in</span><span 10341class="cmtt-8"> scalar</span><span 10342class="cmtt-8"> context</span> 10343<br class="fancyvrb" /><a 10344 id="x1-110048r16"></a><span 10345class="cmr-6">16</span><span 10346class="cmtt-8"> </span><span 10347class="cmtt-8"> </span><span 10348class="cmtt-8"> </span><span 10349class="cmtt-8"> </span><span 10350class="cmtt-8"> </span><span 10351class="cmtt-8"> </span><span 10352class="cmtt-8"> </span><span 10353class="cmtt-8"> </span><span 10354class="cmtt-8"> </span><span 10355class="cmtt-8"> </span><span 10356class="cmtt-8"> </span><span 10357class="cmtt-8"> </span><span 10358class="cmtt-8"> </span><span 10359class="cmtt-8"> </span><span 10360class="cmtt-8"> </span><span 10361class="cmtt-8"> </span><span 10362class="cmtt-8"> </span><span 10363class="cmtt-8"> </span><span 10364class="cmtt-8"> </span><span 10365class="cmtt-8"> </span><span 10366class="cmtt-8"> </span><span 10367class="cmtt-8"> </span><span 10368class="cmtt-8"> </span><span 10369class="cmtt-8"> </span><span 10370class="cmtt-8"> </span><span 10371class="cmtt-8"> </span><span 10372class="cmtt-8"> </span><span 10373class="cmtt-8"> 10)</span><span 10374class="cmtt-8"> iterate</span><span 10375class="cmtt-8"> [i]</span><span 10376class="cmtt-8"> descending</span><span 10377class="cmtt-8"> over</span><span 10378class="cmtt-8"> the</span><span 10379class="cmtt-8"> range</span><span 10380class="cmtt-8"> [classwords_per_codeword]-1</span><span 10381class="cmtt-8"> ...</span><span 10382class="cmtt-8"> 0</span><span 10383class="cmtt-8"> {</span> 10384<br class="fancyvrb" /><a 10385 id="x1-110050r17"></a><span 10386class="cmr-6">17</span><span 10387class="cmtt-8"> </span><span 10388class="cmtt-8"> </span> 10389<br class="fancyvrb" /><a 10390 id="x1-110052r18"></a><span 10391class="cmr-6">18</span><span 10392class="cmtt-8"> </span><span 10393class="cmtt-8"> </span><span 10394class="cmtt-8"> </span><span 10395class="cmtt-8"> </span><span 10396class="cmtt-8"> </span><span 10397class="cmtt-8"> </span><span 10398class="cmtt-8"> </span><span 10399class="cmtt-8"> </span><span 10400class="cmtt-8"> </span><span 10401class="cmtt-8"> </span><span 10402class="cmtt-8"> </span><span 10403class="cmtt-8"> </span><span 10404class="cmtt-8"> </span><span 10405class="cmtt-8"> </span><span 10406class="cmtt-8"> </span><span 10407class="cmtt-8"> </span><span 10408class="cmtt-8"> </span><span 10409class="cmtt-8"> </span><span 10410class="cmtt-8"> </span><span 10411class="cmtt-8"> </span><span 10412class="cmtt-8"> </span><span 10413class="cmtt-8"> </span><span 10414class="cmtt-8"> </span><span 10415class="cmtt-8"> </span><span 10416class="cmtt-8"> </span><span 10417class="cmtt-8"> </span><span 10418class="cmtt-8"> </span><span 10419class="cmtt-8"> </span><span 10420class="cmtt-8"> </span><span 10421class="cmtt-8"> </span><span 10422class="cmtt-8"> </span><span 10423class="cmtt-8"> </span><span 10424class="cmtt-8"> 11)</span><span 10425class="cmtt-8"> array</span><span 10426class="cmtt-8"> [classifications]</span><span 10427class="cmtt-8"> element</span><span 10428class="cmtt-8"> [j],([i]+[partition_count])</span><span 10429class="cmtt-8"> =</span> 10430<br class="fancyvrb" /><a 10431 id="x1-110054r19"></a><span 10432class="cmr-6">19</span><span 10433class="cmtt-8"> </span><span 10434class="cmtt-8"> </span><span 10435class="cmtt-8"> </span><span 10436class="cmtt-8"> </span><span 10437class="cmtt-8"> </span><span 10438class="cmtt-8"> </span><span 10439class="cmtt-8"> </span><span 10440class="cmtt-8"> </span><span 10441class="cmtt-8"> </span><span 10442class="cmtt-8"> </span><span 10443class="cmtt-8"> </span><span 10444class="cmtt-8"> </span><span 10445class="cmtt-8"> </span><span 10446class="cmtt-8"> </span><span 10447class="cmtt-8"> </span><span 10448class="cmtt-8"> </span><span 10449class="cmtt-8"> </span><span 10450class="cmtt-8"> </span><span 10451class="cmtt-8"> </span><span 10452class="cmtt-8"> </span><span 10453class="cmtt-8"> </span><span 10454class="cmtt-8"> </span><span 10455class="cmtt-8"> </span><span 10456class="cmtt-8"> </span><span 10457class="cmtt-8"> </span><span 10458class="cmtt-8"> </span><span 10459class="cmtt-8"> </span><span 10460class="cmtt-8"> </span><span 10461class="cmtt-8"> </span><span 10462class="cmtt-8"> </span><span 10463class="cmtt-8"> </span><span 10464class="cmtt-8"> </span><span 10465class="cmtt-8"> </span><span 10466class="cmtt-8"> </span><span 10467class="cmtt-8"> </span><span 10468class="cmtt-8"> </span><span 10469class="cmtt-8"> [temp]</span><span 10470class="cmtt-8"> integer</span><span 10471class="cmtt-8"> modulo</span><span 10472class="cmtt-8"> [residue_classifications]</span> 10473<br class="fancyvrb" /><a 10474 id="x1-110056r20"></a><span 10475class="cmr-6">20</span><span 10476class="cmtt-8"> </span><span 10477class="cmtt-8"> </span><span 10478class="cmtt-8"> </span><span 10479class="cmtt-8"> </span><span 10480class="cmtt-8"> </span><span 10481class="cmtt-8"> </span><span 10482class="cmtt-8"> </span><span 10483class="cmtt-8"> </span><span 10484class="cmtt-8"> </span><span 10485class="cmtt-8"> </span><span 10486class="cmtt-8"> </span><span 10487class="cmtt-8"> </span><span 10488class="cmtt-8"> </span><span 10489class="cmtt-8"> </span><span 10490class="cmtt-8"> </span><span 10491class="cmtt-8"> </span><span 10492class="cmtt-8"> </span><span 10493class="cmtt-8"> </span><span 10494class="cmtt-8"> </span><span 10495class="cmtt-8"> </span><span 10496class="cmtt-8"> </span><span 10497class="cmtt-8"> </span><span 10498class="cmtt-8"> </span><span 10499class="cmtt-8"> </span><span 10500class="cmtt-8"> </span><span 10501class="cmtt-8"> </span><span 10502class="cmtt-8"> </span><span 10503class="cmtt-8"> </span><span 10504class="cmtt-8"> </span><span 10505class="cmtt-8"> </span><span 10506class="cmtt-8"> </span><span 10507class="cmtt-8"> </span><span 10508class="cmtt-8"> 12)</span><span 10509class="cmtt-8"> [temp]</span><span 10510class="cmtt-8"> =</span><span 10511class="cmtt-8"> [temp]</span><span 10512class="cmtt-8"> /</span><span 10513class="cmtt-8"> [residue_classifications]</span><span 10514class="cmtt-8"> using</span><span 10515class="cmtt-8"> integer</span><span 10516class="cmtt-8"> division</span> 10517<br class="fancyvrb" /><a 10518 id="x1-110058r21"></a><span 10519class="cmr-6">21</span><span 10520class="cmtt-8"> </span><span 10521class="cmtt-8"> </span> 10522<br class="fancyvrb" /><a 10523 id="x1-110060r22"></a><span 10524class="cmr-6">22</span><span 10525class="cmtt-8"> </span><span 10526class="cmtt-8"> </span><span 10527class="cmtt-8"> </span><span 10528class="cmtt-8"> </span><span 10529class="cmtt-8"> </span><span 10530class="cmtt-8"> </span><span 10531class="cmtt-8"> </span><span 10532class="cmtt-8"> </span><span 10533class="cmtt-8"> </span><span 10534class="cmtt-8"> </span><span 10535class="cmtt-8"> </span><span 10536class="cmtt-8"> </span><span 10537class="cmtt-8"> </span><span 10538class="cmtt-8"> </span><span 10539class="cmtt-8"> </span><span 10540class="cmtt-8"> </span><span 10541class="cmtt-8"> </span><span 10542class="cmtt-8"> </span><span 10543class="cmtt-8"> </span><span 10544class="cmtt-8"> </span><span 10545class="cmtt-8"> </span><span 10546class="cmtt-8"> </span><span 10547class="cmtt-8"> </span><span 10548class="cmtt-8"> </span><span 10549class="cmtt-8"> </span><span 10550class="cmtt-8"> </span><span 10551class="cmtt-8"> </span><span 10552class="cmtt-8"> </span><span 10553class="cmtt-8"> </span><span 10554class="cmtt-8"> </span><span 10555class="cmtt-8"> </span><span 10556class="cmtt-8"> }</span> 10557<br class="fancyvrb" /><a 10558 id="x1-110062r23"></a><span 10559class="cmr-6">23</span><span 10560class="cmtt-8"> </span><span 10561class="cmtt-8"> </span> 10562<br class="fancyvrb" /><a 10563 id="x1-110064r24"></a><span 10564class="cmr-6">24</span><span 10565class="cmtt-8"> </span><span 10566class="cmtt-8"> </span><span 10567class="cmtt-8"> </span><span 10568class="cmtt-8"> </span><span 10569class="cmtt-8"> </span><span 10570class="cmtt-8"> </span><span 10571class="cmtt-8"> </span><span 10572class="cmtt-8"> </span><span 10573class="cmtt-8"> </span><span 10574class="cmtt-8"> </span><span 10575class="cmtt-8"> </span><span 10576class="cmtt-8"> </span><span 10577class="cmtt-8"> </span><span 10578class="cmtt-8"> </span><span 10579class="cmtt-8"> </span><span 10580class="cmtt-8"> </span><span 10581class="cmtt-8"> </span><span 10582class="cmtt-8"> </span><span 10583class="cmtt-8"> </span><span 10584class="cmtt-8"> </span><span 10585class="cmtt-8"> </span><span 10586class="cmtt-8"> </span><span 10587class="cmtt-8"> </span><span 10588class="cmtt-8"> </span><span 10589class="cmtt-8"> </span><span 10590class="cmtt-8"> </span><span 10591class="cmtt-8"> }</span> 10592<br class="fancyvrb" /><a 10593 id="x1-110066r25"></a><span 10594class="cmr-6">25</span><span 10595class="cmtt-8"> </span><span 10596class="cmtt-8"> </span> 10597<br class="fancyvrb" /><a 10598 id="x1-110068r26"></a><span 10599class="cmr-6">26</span><span 10600class="cmtt-8"> </span><span 10601class="cmtt-8"> </span><span 10602class="cmtt-8"> </span><span 10603class="cmtt-8"> </span><span 10604class="cmtt-8"> </span><span 10605class="cmtt-8"> </span><span 10606class="cmtt-8"> </span><span 10607class="cmtt-8"> </span><span 10608class="cmtt-8"> </span><span 10609class="cmtt-8"> </span><span 10610class="cmtt-8"> </span><span 10611class="cmtt-8"> </span><span 10612class="cmtt-8"> </span><span 10613class="cmtt-8"> </span><span 10614class="cmtt-8"> </span><span 10615class="cmtt-8"> </span><span 10616class="cmtt-8"> </span><span 10617class="cmtt-8"> </span><span 10618class="cmtt-8"> </span><span 10619class="cmtt-8"> </span><span 10620class="cmtt-8"> </span><span 10621class="cmtt-8"> }</span> 10622<br class="fancyvrb" /><a 10623 id="x1-110070r27"></a><span 10624class="cmr-6">27</span><span 10625class="cmtt-8"> </span><span 10626class="cmtt-8"> </span> 10627<br class="fancyvrb" /><a 10628 id="x1-110072r28"></a><span 10629class="cmr-6">28</span><span 10630class="cmtt-8"> </span><span 10631class="cmtt-8"> </span><span 10632class="cmtt-8"> </span><span 10633class="cmtt-8"> </span><span 10634class="cmtt-8"> </span><span 10635class="cmtt-8"> </span><span 10636class="cmtt-8"> </span><span 10637class="cmtt-8"> </span><span 10638class="cmtt-8"> </span><span 10639class="cmtt-8"> </span><span 10640class="cmtt-8"> </span><span 10641class="cmtt-8"> </span><span 10642class="cmtt-8"> </span><span 10643class="cmtt-8"> </span><span 10644class="cmtt-8"> </span><span 10645class="cmtt-8"> </span><span 10646class="cmtt-8"> }</span> 10647<br class="fancyvrb" /><a 10648 id="x1-110074r29"></a><span 10649class="cmr-6">29</span><span 10650class="cmtt-8"> </span><span 10651class="cmtt-8"> </span> 10652<br class="fancyvrb" /><a 10653 id="x1-110076r30"></a><span 10654class="cmr-6">30</span><span 10655class="cmtt-8"> </span><span 10656class="cmtt-8"> </span><span 10657class="cmtt-8"> </span><span 10658class="cmtt-8"> </span><span 10659class="cmtt-8"> </span><span 10660class="cmtt-8"> </span><span 10661class="cmtt-8"> </span><span 10662class="cmtt-8"> </span><span 10663class="cmtt-8"> </span><span 10664class="cmtt-8"> </span><span 10665class="cmtt-8"> </span><span 10666class="cmtt-8"> </span><span 10667class="cmtt-8"> 13)</span><span 10668class="cmtt-8"> iterate</span><span 10669class="cmtt-8"> [i]</span><span 10670class="cmtt-8"> over</span><span 10671class="cmtt-8"> the</span><span 10672class="cmtt-8"> range</span><span 10673class="cmtt-8"> 0</span><span 10674class="cmtt-8"> ..</span><span 10675class="cmtt-8"> ([classwords_per_codeword]</span><span 10676class="cmtt-8"> -</span><span 10677class="cmtt-8"> 1)</span><span 10678class="cmtt-8"> while</span><span 10679class="cmtt-8"> [partition_count]</span> 10680<br class="fancyvrb" /><a 10681 id="x1-110078r31"></a><span 10682class="cmr-6">31</span><span 10683class="cmtt-8"> </span><span 10684class="cmtt-8"> </span><span 10685class="cmtt-8"> </span><span 10686class="cmtt-8"> </span><span 10687class="cmtt-8"> </span><span 10688class="cmtt-8"> </span><span 10689class="cmtt-8"> </span><span 10690class="cmtt-8"> </span><span 10691class="cmtt-8"> </span><span 10692class="cmtt-8"> </span><span 10693class="cmtt-8"> </span><span 10694class="cmtt-8"> </span><span 10695class="cmtt-8"> </span><span 10696class="cmtt-8"> </span><span 10697class="cmtt-8"> </span><span 10698class="cmtt-8"> </span><span 10699class="cmtt-8"> is</span><span 10700class="cmtt-8"> also</span><span 10701class="cmtt-8"> less</span><span 10702class="cmtt-8"> than</span><span 10703class="cmtt-8"> [partitions_to_read]</span><span 10704class="cmtt-8"> {</span> 10705<br class="fancyvrb" /><a 10706 id="x1-110080r32"></a><span 10707class="cmr-6">32</span><span 10708class="cmtt-8"> </span><span 10709class="cmtt-8"> </span> 10710<br class="fancyvrb" /><a 10711 id="x1-110082r33"></a><span 10712class="cmr-6">33</span><span 10713class="cmtt-8"> </span><span 10714class="cmtt-8"> </span><span 10715class="cmtt-8"> </span><span 10716class="cmtt-8"> </span><span 10717class="cmtt-8"> </span><span 10718class="cmtt-8"> </span><span 10719class="cmtt-8"> </span><span 10720class="cmtt-8"> </span><span 10721class="cmtt-8"> </span><span 10722class="cmtt-8"> </span><span 10723class="cmtt-8"> </span><span 10724class="cmtt-8"> </span><span 10725class="cmtt-8"> </span><span 10726class="cmtt-8"> </span><span 10727class="cmtt-8"> </span><span 10728class="cmtt-8"> </span><span 10729class="cmtt-8"> </span><span 10730class="cmtt-8"> </span><span 10731class="cmtt-8"> 14)</span><span 10732class="cmtt-8"> iterate</span><span 10733class="cmtt-8"> [j]</span><span 10734class="cmtt-8"> over</span><span 10735class="cmtt-8"> the</span><span 10736class="cmtt-8"> range</span><span 10737class="cmtt-8"> 0</span><span 10738class="cmtt-8"> ..</span><span 10739class="cmtt-8"> [ch]-1</span><span 10740class="cmtt-8"> {</span> 10741<br class="fancyvrb" /><a 10742 id="x1-110084r34"></a><span 10743class="cmr-6">34</span><span 10744class="cmtt-8"> </span><span 10745class="cmtt-8"> </span> 10746<br class="fancyvrb" /><a 10747 id="x1-110086r35"></a><span 10748class="cmr-6">35</span><span 10749class="cmtt-8"> </span><span 10750class="cmtt-8"> </span><span 10751class="cmtt-8"> </span><span 10752class="cmtt-8"> </span><span 10753class="cmtt-8"> </span><span 10754class="cmtt-8"> </span><span 10755class="cmtt-8"> </span><span 10756class="cmtt-8"> </span><span 10757class="cmtt-8"> </span><span 10758class="cmtt-8"> </span><span 10759class="cmtt-8"> </span><span 10760class="cmtt-8"> </span><span 10761class="cmtt-8"> </span><span 10762class="cmtt-8"> </span><span 10763class="cmtt-8"> </span><span 10764class="cmtt-8"> </span><span 10765class="cmtt-8"> </span><span 10766class="cmtt-8"> </span><span 10767class="cmtt-8"> </span><span 10768class="cmtt-8"> </span><span 10769class="cmtt-8"> </span><span 10770class="cmtt-8"> </span><span 10771class="cmtt-8"> </span><span 10772class="cmtt-8"> 15)</span><span 10773class="cmtt-8"> if</span><span 10774class="cmtt-8"> vector</span><span 10775class="cmtt-8"> [j]</span><span 10776class="cmtt-8"> is</span><span 10777class="cmtt-8"> not</span><span 10778class="cmtt-8"> marked</span><span 10779class="cmtt-8"> ’do</span><span 10780class="cmtt-8"> not</span><span 10781class="cmtt-8"> decode’</span><span 10782class="cmtt-8"> {</span> 10783<br class="fancyvrb" /><a 10784 id="x1-110088r36"></a><span 10785class="cmr-6">36</span><span 10786class="cmtt-8"> </span><span 10787class="cmtt-8"> </span> 10788<br class="fancyvrb" /><a 10789 id="x1-110090r37"></a><span 10790class="cmr-6">37</span><span 10791class="cmtt-8"> </span><span 10792class="cmtt-8"> </span><span 10793class="cmtt-8"> </span><span 10794class="cmtt-8"> </span><span 10795class="cmtt-8"> </span><span 10796class="cmtt-8"> </span><span 10797class="cmtt-8"> </span><span 10798class="cmtt-8"> </span><span 10799class="cmtt-8"> </span><span 10800class="cmtt-8"> </span><span 10801class="cmtt-8"> </span><span 10802class="cmtt-8"> </span><span 10803class="cmtt-8"> </span><span 10804class="cmtt-8"> </span><span 10805class="cmtt-8"> </span><span 10806class="cmtt-8"> </span><span 10807class="cmtt-8"> </span><span 10808class="cmtt-8"> </span><span 10809class="cmtt-8"> </span><span 10810class="cmtt-8"> </span><span 10811class="cmtt-8"> </span><span 10812class="cmtt-8"> </span><span 10813class="cmtt-8"> </span><span 10814class="cmtt-8"> </span><span 10815class="cmtt-8"> </span><span 10816class="cmtt-8"> </span><span 10817class="cmtt-8"> </span><span 10818class="cmtt-8"> </span><span 10819class="cmtt-8"> 16)</span><span 10820class="cmtt-8"> [vqclass]</span><span 10821class="cmtt-8"> =</span><span 10822class="cmtt-8"> array</span><span 10823class="cmtt-8"> [classifications]</span><span 10824class="cmtt-8"> element</span><span 10825class="cmtt-8"> [j],[partition_count]</span> 10826<br class="fancyvrb" /><a 10827 id="x1-110092r38"></a><span 10828class="cmr-6">38</span><span 10829class="cmtt-8"> </span><span 10830class="cmtt-8"> </span><span 10831class="cmtt-8"> </span><span 10832class="cmtt-8"> </span><span 10833class="cmtt-8"> </span><span 10834class="cmtt-8"> </span><span 10835class="cmtt-8"> </span><span 10836class="cmtt-8"> </span><span 10837class="cmtt-8"> </span><span 10838class="cmtt-8"> </span><span 10839class="cmtt-8"> </span><span 10840class="cmtt-8"> </span><span 10841class="cmtt-8"> </span><span 10842class="cmtt-8"> </span><span 10843class="cmtt-8"> </span><span 10844class="cmtt-8"> </span><span 10845class="cmtt-8"> </span><span 10846class="cmtt-8"> </span><span 10847class="cmtt-8"> </span><span 10848class="cmtt-8"> </span><span 10849class="cmtt-8"> </span><span 10850class="cmtt-8"> </span><span 10851class="cmtt-8"> </span><span 10852class="cmtt-8"> </span><span 10853class="cmtt-8"> </span><span 10854class="cmtt-8"> </span><span 10855class="cmtt-8"> </span><span 10856class="cmtt-8"> </span><span 10857class="cmtt-8"> 17)</span><span 10858class="cmtt-8"> [vqbook]</span><span 10859class="cmtt-8"> =</span><span 10860class="cmtt-8"> array</span><span 10861class="cmtt-8"> [residue_books]</span><span 10862class="cmtt-8"> element</span><span 10863class="cmtt-8"> [vqclass],[pass]</span> 10864<br class="fancyvrb" /><a 10865 id="x1-110094r39"></a><span 10866class="cmr-6">39</span><span 10867class="cmtt-8"> </span><span 10868class="cmtt-8"> </span><span 10869class="cmtt-8"> </span><span 10870class="cmtt-8"> </span><span 10871class="cmtt-8"> </span><span 10872class="cmtt-8"> </span><span 10873class="cmtt-8"> </span><span 10874class="cmtt-8"> </span><span 10875class="cmtt-8"> </span><span 10876class="cmtt-8"> </span><span 10877class="cmtt-8"> </span><span 10878class="cmtt-8"> </span><span 10879class="cmtt-8"> </span><span 10880class="cmtt-8"> </span><span 10881class="cmtt-8"> </span><span 10882class="cmtt-8"> </span><span 10883class="cmtt-8"> </span><span 10884class="cmtt-8"> </span><span 10885class="cmtt-8"> </span><span 10886class="cmtt-8"> </span><span 10887class="cmtt-8"> </span><span 10888class="cmtt-8"> </span><span 10889class="cmtt-8"> </span><span 10890class="cmtt-8"> </span><span 10891class="cmtt-8"> </span><span 10892class="cmtt-8"> </span><span 10893class="cmtt-8"> </span><span 10894class="cmtt-8"> </span><span 10895class="cmtt-8"> 18)</span><span 10896class="cmtt-8"> if</span><span 10897class="cmtt-8"> ([vqbook]</span><span 10898class="cmtt-8"> is</span><span 10899class="cmtt-8"> not</span><span 10900class="cmtt-8"> ’unused’)</span><span 10901class="cmtt-8"> {</span> 10902<br class="fancyvrb" /><a 10903 id="x1-110096r40"></a><span 10904class="cmr-6">40</span><span 10905class="cmtt-8"> </span><span 10906class="cmtt-8"> </span> 10907<br class="fancyvrb" /><a 10908 id="x1-110098r41"></a><span 10909class="cmr-6">41</span><span 10910class="cmtt-8"> </span><span 10911class="cmtt-8"> </span><span 10912class="cmtt-8"> </span><span 10913class="cmtt-8"> </span><span 10914class="cmtt-8"> </span><span 10915class="cmtt-8"> </span><span 10916class="cmtt-8"> </span><span 10917class="cmtt-8"> </span><span 10918class="cmtt-8"> </span><span 10919class="cmtt-8"> </span><span 10920class="cmtt-8"> </span><span 10921class="cmtt-8"> </span><span 10922class="cmtt-8"> </span><span 10923class="cmtt-8"> </span><span 10924class="cmtt-8"> </span><span 10925class="cmtt-8"> </span><span 10926class="cmtt-8"> </span><span 10927class="cmtt-8"> </span><span 10928class="cmtt-8"> </span><span 10929class="cmtt-8"> </span><span 10930class="cmtt-8"> </span><span 10931class="cmtt-8"> </span><span 10932class="cmtt-8"> </span><span 10933class="cmtt-8"> </span><span 10934class="cmtt-8"> </span><span 10935class="cmtt-8"> </span><span 10936class="cmtt-8"> </span><span 10937class="cmtt-8"> </span><span 10938class="cmtt-8"> </span><span 10939class="cmtt-8"> </span><span 10940class="cmtt-8"> </span><span 10941class="cmtt-8"> </span><span 10942class="cmtt-8"> </span><span 10943class="cmtt-8"> 19)</span><span 10944class="cmtt-8"> decode</span><span 10945class="cmtt-8"> partition</span><span 10946class="cmtt-8"> into</span><span 10947class="cmtt-8"> output</span><span 10948class="cmtt-8"> vector</span><span 10949class="cmtt-8"> number</span><span 10950class="cmtt-8"> [j],</span><span 10951class="cmtt-8"> starting</span><span 10952class="cmtt-8"> at</span><span 10953class="cmtt-8"> scalar</span> 10954<br class="fancyvrb" /><a 10955 id="x1-110100r42"></a><span 10956class="cmr-6">42</span><span 10957class="cmtt-8"> </span><span 10958class="cmtt-8"> </span><span 10959class="cmtt-8"> </span><span 10960class="cmtt-8"> </span><span 10961class="cmtt-8"> </span><span 10962class="cmtt-8"> </span><span 10963class="cmtt-8"> </span><span 10964class="cmtt-8"> </span><span 10965class="cmtt-8"> </span><span 10966class="cmtt-8"> </span><span 10967class="cmtt-8"> </span><span 10968class="cmtt-8"> </span><span 10969class="cmtt-8"> </span><span 10970class="cmtt-8"> </span><span 10971class="cmtt-8"> </span><span 10972class="cmtt-8"> </span><span 10973class="cmtt-8"> </span><span 10974class="cmtt-8"> </span><span 10975class="cmtt-8"> </span><span 10976class="cmtt-8"> </span><span 10977class="cmtt-8"> </span><span 10978class="cmtt-8"> </span><span 10979class="cmtt-8"> </span><span 10980class="cmtt-8"> </span><span 10981class="cmtt-8"> </span><span 10982class="cmtt-8"> </span><span 10983class="cmtt-8"> </span><span 10984class="cmtt-8"> </span><span 10985class="cmtt-8"> </span><span 10986class="cmtt-8"> </span><span 10987class="cmtt-8"> </span><span 10988class="cmtt-8"> </span><span 10989class="cmtt-8"> </span><span 10990class="cmtt-8"> </span><span 10991class="cmtt-8"> </span><span 10992class="cmtt-8"> </span><span 10993class="cmtt-8"> </span><span 10994class="cmtt-8"> offset</span><span 10995class="cmtt-8"> [limit_residue_begin]+[partition_count]*[residue_partition_size]</span><span 10996class="cmtt-8"> using</span> 10997<br class="fancyvrb" /><a 10998 id="x1-110102r43"></a><span 10999class="cmr-6">43</span><span 11000class="cmtt-8"> </span><span 11001class="cmtt-8"> </span><span 11002class="cmtt-8"> </span><span 11003class="cmtt-8"> </span><span 11004class="cmtt-8"> </span><span 11005class="cmtt-8"> </span><span 11006class="cmtt-8"> </span><span 11007class="cmtt-8"> </span><span 11008class="cmtt-8"> </span><span 11009class="cmtt-8"> </span><span 11010class="cmtt-8"> </span><span 11011class="cmtt-8"> </span><span 11012class="cmtt-8"> </span><span 11013class="cmtt-8"> </span><span 11014class="cmtt-8"> </span><span 11015class="cmtt-8"> </span><span 11016class="cmtt-8"> </span><span 11017class="cmtt-8"> </span><span 11018class="cmtt-8"> </span><span 11019class="cmtt-8"> </span><span 11020class="cmtt-8"> </span><span 11021class="cmtt-8"> </span><span 11022class="cmtt-8"> </span><span 11023class="cmtt-8"> </span><span 11024class="cmtt-8"> </span><span 11025class="cmtt-8"> </span><span 11026class="cmtt-8"> </span><span 11027class="cmtt-8"> </span><span 11028class="cmtt-8"> </span><span 11029class="cmtt-8"> </span><span 11030class="cmtt-8"> </span><span 11031class="cmtt-8"> </span><span 11032class="cmtt-8"> </span><span 11033class="cmtt-8"> </span><span 11034class="cmtt-8"> </span><span 11035class="cmtt-8"> </span><span 11036class="cmtt-8"> </span><span 11037class="cmtt-8"> codebook</span><span 11038class="cmtt-8"> number</span><span 11039class="cmtt-8"> [vqbook]</span><span 11040class="cmtt-8"> in</span><span 11041class="cmtt-8"> VQ</span><span 11042class="cmtt-8"> context</span> 11043<br class="fancyvrb" /><a 11044 id="x1-110104r44"></a><span 11045class="cmr-6">44</span><span 11046class="cmtt-8"> </span><span 11047class="cmtt-8"> </span><span 11048class="cmtt-8"> </span><span 11049class="cmtt-8"> </span><span 11050class="cmtt-8"> </span><span 11051class="cmtt-8"> </span><span 11052class="cmtt-8"> </span><span 11053class="cmtt-8"> </span><span 11054class="cmtt-8"> </span><span 11055class="cmtt-8"> </span><span 11056class="cmtt-8"> </span><span 11057class="cmtt-8"> </span><span 11058class="cmtt-8"> </span><span 11059class="cmtt-8"> </span><span 11060class="cmtt-8"> </span><span 11061class="cmtt-8"> </span><span 11062class="cmtt-8"> </span><span 11063class="cmtt-8"> </span><span 11064class="cmtt-8"> </span><span 11065class="cmtt-8"> </span><span 11066class="cmtt-8"> </span><span 11067class="cmtt-8"> </span><span 11068class="cmtt-8"> </span><span 11069class="cmtt-8"> </span><span 11070class="cmtt-8"> </span><span 11071class="cmtt-8"> </span><span 11072class="cmtt-8"> </span><span 11073class="cmtt-8"> }</span> 11074 11075 11076 11077<br class="fancyvrb" /><a 11078 id="x1-110106r45"></a><span 11079class="cmr-6">45</span><span 11080class="cmtt-8"> </span><span 11081class="cmtt-8"> </span><span 11082class="cmtt-8"> </span><span 11083class="cmtt-8"> </span><span 11084class="cmtt-8"> </span><span 11085class="cmtt-8"> </span><span 11086class="cmtt-8"> </span><span 11087class="cmtt-8"> </span><span 11088class="cmtt-8"> </span><span 11089class="cmtt-8"> </span><span 11090class="cmtt-8"> </span><span 11091class="cmtt-8"> </span><span 11092class="cmtt-8"> </span><span 11093class="cmtt-8"> </span><span 11094class="cmtt-8"> </span><span 11095class="cmtt-8"> </span><span 11096class="cmtt-8"> </span><span 11097class="cmtt-8"> </span><span 11098class="cmtt-8"> </span><span 11099class="cmtt-8"> </span><span 11100class="cmtt-8"> </span><span 11101class="cmtt-8"> </span><span 11102class="cmtt-8"> }</span> 11103<br class="fancyvrb" /><a 11104 id="x1-110108r46"></a><span 11105class="cmr-6">46</span><span 11106class="cmtt-8"> </span><span 11107class="cmtt-8"> </span> 11108<br class="fancyvrb" /><a 11109 id="x1-110110r47"></a><span 11110class="cmr-6">47</span><span 11111class="cmtt-8"> </span><span 11112class="cmtt-8"> </span><span 11113class="cmtt-8"> </span><span 11114class="cmtt-8"> </span><span 11115class="cmtt-8"> </span><span 11116class="cmtt-8"> </span><span 11117class="cmtt-8"> </span><span 11118class="cmtt-8"> </span><span 11119class="cmtt-8"> </span><span 11120class="cmtt-8"> </span><span 11121class="cmtt-8"> </span><span 11122class="cmtt-8"> </span><span 11123class="cmtt-8"> </span><span 11124class="cmtt-8"> </span><span 11125class="cmtt-8"> </span><span 11126class="cmtt-8"> </span><span 11127class="cmtt-8"> </span><span 11128class="cmtt-8"> </span><span 11129class="cmtt-8"> 20)</span><span 11130class="cmtt-8"> increment</span><span 11131class="cmtt-8"> [partition_count]</span><span 11132class="cmtt-8"> by</span><span 11133class="cmtt-8"> one</span> 11134<br class="fancyvrb" /><a 11135 id="x1-110112r48"></a><span 11136class="cmr-6">48</span><span 11137class="cmtt-8"> </span><span 11138class="cmtt-8"> </span> 11139<br class="fancyvrb" /><a 11140 id="x1-110114r49"></a><span 11141class="cmr-6">49</span><span 11142class="cmtt-8"> </span><span 11143class="cmtt-8"> </span><span 11144class="cmtt-8"> </span><span 11145class="cmtt-8"> </span><span 11146class="cmtt-8"> </span><span 11147class="cmtt-8"> </span><span 11148class="cmtt-8"> </span><span 11149class="cmtt-8"> </span><span 11150class="cmtt-8"> </span><span 11151class="cmtt-8"> </span><span 11152class="cmtt-8"> </span><span 11153class="cmtt-8"> </span><span 11154class="cmtt-8"> </span><span 11155class="cmtt-8"> </span><span 11156class="cmtt-8"> </span><span 11157class="cmtt-8"> </span><span 11158class="cmtt-8"> }</span> 11159<br class="fancyvrb" /><a 11160 id="x1-110116r50"></a><span 11161class="cmr-6">50</span><span 11162class="cmtt-8"> </span><span 11163class="cmtt-8"> </span><span 11164class="cmtt-8"> </span><span 11165class="cmtt-8"> </span><span 11166class="cmtt-8"> </span><span 11167class="cmtt-8"> </span><span 11168class="cmtt-8"> </span><span 11169class="cmtt-8"> </span><span 11170class="cmtt-8"> </span><span 11171class="cmtt-8"> </span><span 11172class="cmtt-8"> </span><span 11173class="cmtt-8"> }</span> 11174<br class="fancyvrb" /><a 11175 id="x1-110118r51"></a><span 11176class="cmr-6">51</span><span 11177class="cmtt-8"> </span><span 11178class="cmtt-8"> </span><span 11179class="cmtt-8"> </span><span 11180class="cmtt-8"> </span><span 11181class="cmtt-8"> </span><span 11182class="cmtt-8"> </span><span 11183class="cmtt-8"> }</span> 11184<br class="fancyvrb" /><a 11185 id="x1-110120r52"></a><span 11186class="cmr-6">52</span><span 11187class="cmtt-8"> </span><span 11188class="cmtt-8"> </span> 11189<br class="fancyvrb" /><a 11190 id="x1-110122r53"></a><span 11191class="cmr-6">53</span><span 11192class="cmtt-8"> </span><span 11193class="cmtt-8"> </span><span 11194class="cmtt-8"> 21)</span><span 11195class="cmtt-8"> done</span> 11196<br class="fancyvrb" /><a 11197 id="x1-110124r54"></a><span 11198class="cmr-6">54</span><span 11199class="cmtt-8"> </span><span 11200class="cmtt-8"> </span> 11201</div> 11202<!--l. 344--><p class="noindent" >An end-of-packet condition during packet decode is to be considered a nominal occurrence. 11203Decode returns the result of vector decode up to that point. 11204<!--l. 350--><p class="noindent" > 11205<h5 class="subsubsectionHead"><span class="titlemark">8.6.3 </span> <a 11206 id="x1-1110008.6.3"></a>format 0 specifics</h5> 11207<!--l. 352--><p class="noindent" >Format zero decodes partitions exactly as described earlier in the ’Residue Format: residue 0’ 11208section. The following pseudocode presents the same algorithm. Assume: 11209 <ul class="itemize1"> 11210 <li class="itemize"><span 11211class="cmtt-12">[n] </span>is the value in <span 11212class="cmtt-12">[residue_partition_size]</span> 11213 </li> 11214 <li class="itemize"><span 11215class="cmtt-12">[v] </span>is the residue vector 11216 </li> 11217 <li class="itemize"><span 11218class="cmtt-12">[offset] </span>is the beginning read offset in [v]</li></ul> 11219<!--l. 363--><p class="noindent" > 11220<div class="fancyvrb" id="fancyvrb41"> 11221<a 11222 id="x1-111002r1"></a><span 11223class="cmr-6">1</span><span 11224class="cmtt-8"> </span><span 11225class="cmtt-8"> </span><span 11226class="cmtt-8"> 1)</span><span 11227class="cmtt-8"> [step]</span><span 11228class="cmtt-8"> =</span><span 11229class="cmtt-8"> [n]</span><span 11230class="cmtt-8"> /</span><span 11231class="cmtt-8"> [codebook_dimensions]</span> 11232<br class="fancyvrb" /><a 11233 id="x1-111004r2"></a><span 11234class="cmr-6">2</span><span 11235class="cmtt-8"> </span><span 11236class="cmtt-8"> </span><span 11237class="cmtt-8"> 2)</span><span 11238class="cmtt-8"> iterate</span><span 11239class="cmtt-8"> [i]</span><span 11240class="cmtt-8"> over</span><span 11241class="cmtt-8"> the</span><span 11242class="cmtt-8"> range</span><span 11243class="cmtt-8"> 0</span><span 11244class="cmtt-8"> ...</span><span 11245class="cmtt-8"> [step]-1</span><span 11246class="cmtt-8"> {</span> 11247<br class="fancyvrb" /><a 11248 id="x1-111006r3"></a><span 11249class="cmr-6">3</span><span 11250class="cmtt-8"> </span><span 11251class="cmtt-8"> </span> 11252<br class="fancyvrb" /><a 11253 id="x1-111008r4"></a><span 11254class="cmr-6">4</span><span 11255class="cmtt-8"> </span><span 11256class="cmtt-8"> </span><span 11257class="cmtt-8"> </span><span 11258class="cmtt-8"> </span><span 11259class="cmtt-8"> </span><span 11260class="cmtt-8"> </span><span 11261class="cmtt-8"> </span><span 11262class="cmtt-8"> 3)</span><span 11263class="cmtt-8"> vector</span><span 11264class="cmtt-8"> [entry_temp]</span><span 11265class="cmtt-8"> =</span><span 11266class="cmtt-8"> read</span><span 11267class="cmtt-8"> vector</span><span 11268class="cmtt-8"> from</span><span 11269class="cmtt-8"> packet</span><span 11270class="cmtt-8"> using</span><span 11271class="cmtt-8"> current</span><span 11272class="cmtt-8"> codebook</span><span 11273class="cmtt-8"> in</span><span 11274class="cmtt-8"> VQ</span><span 11275class="cmtt-8"> context</span> 11276<br class="fancyvrb" /><a 11277 id="x1-111010r5"></a><span 11278class="cmr-6">5</span><span 11279class="cmtt-8"> </span><span 11280class="cmtt-8"> </span><span 11281class="cmtt-8"> </span><span 11282class="cmtt-8"> </span><span 11283class="cmtt-8"> </span><span 11284class="cmtt-8"> </span><span 11285class="cmtt-8"> </span><span 11286class="cmtt-8"> 4)</span><span 11287class="cmtt-8"> iterate</span><span 11288class="cmtt-8"> [j]</span><span 11289class="cmtt-8"> over</span><span 11290class="cmtt-8"> the</span><span 11291class="cmtt-8"> range</span><span 11292class="cmtt-8"> 0</span><span 11293class="cmtt-8"> ...</span><span 11294class="cmtt-8"> [codebook_dimensions]-1</span><span 11295class="cmtt-8"> {</span> 11296<br class="fancyvrb" /><a 11297 id="x1-111012r6"></a><span 11298class="cmr-6">6</span><span 11299class="cmtt-8"> </span><span 11300class="cmtt-8"> </span> 11301<br class="fancyvrb" /><a 11302 id="x1-111014r7"></a><span 11303class="cmr-6">7</span><span 11304class="cmtt-8"> </span><span 11305class="cmtt-8"> </span><span 11306class="cmtt-8"> </span><span 11307class="cmtt-8"> </span><span 11308class="cmtt-8"> </span><span 11309class="cmtt-8"> </span><span 11310class="cmtt-8"> </span><span 11311class="cmtt-8"> </span><span 11312class="cmtt-8"> </span><span 11313class="cmtt-8"> </span><span 11314class="cmtt-8"> </span><span 11315class="cmtt-8"> </span><span 11316class="cmtt-8"> 5)</span><span 11317class="cmtt-8"> vector</span><span 11318class="cmtt-8"> [v]</span><span 11319class="cmtt-8"> element</span><span 11320class="cmtt-8"> ([offset]+[i]+[j]*[step])</span><span 11321class="cmtt-8"> =</span> 11322<br class="fancyvrb" /><a 11323 id="x1-111016r8"></a><span 11324class="cmr-6">8</span><span 11325class="cmtt-8"> </span><span 11326class="cmtt-8">  </span><span 11327class="cmtt-8"> </span><span 11328class="cmtt-8"> </span><span 11329class="cmtt-8"> </span><span 11330class="cmtt-8"> </span><span 11331class="cmtt-8"> </span><span 11332class="cmtt-8"> </span><span 11333class="cmtt-8"> </span><span 11334class="cmtt-8"> vector</span><span 11335class="cmtt-8"> [v]</span><span 11336class="cmtt-8"> element</span><span 11337class="cmtt-8"> ([offset]+[i]+[j]*[step])</span><span 11338class="cmtt-8"> +</span> 11339<br class="fancyvrb" /><a 11340 id="x1-111018r9"></a><span 11341class="cmr-6">9</span><span 11342class="cmtt-8"> </span><span 11343class="cmtt-8"> </span><span 11344class="cmtt-8"> </span><span 11345class="cmtt-8"> </span><span 11346class="cmtt-8"> </span><span 11347class="cmtt-8"> </span><span 11348class="cmtt-8"> </span><span 11349class="cmtt-8"> </span><span 11350class="cmtt-8"> </span><span 11351class="cmtt-8"> </span><span 11352class="cmtt-8"> </span><span 11353class="cmtt-8"> </span><span 11354class="cmtt-8"> </span><span 11355class="cmtt-8"> </span><span 11356class="cmtt-8"> </span><span 11357class="cmtt-8"> </span><span 11358class="cmtt-8"> </span><span 11359class="cmtt-8"> vector</span><span 11360class="cmtt-8"> [entry_temp]</span><span 11361class="cmtt-8"> element</span><span 11362class="cmtt-8"> [j]</span> 11363<br class="fancyvrb" /><a 11364 id="x1-111020r10"></a><span 11365class="cmr-6">10</span><span 11366class="cmtt-8"> </span><span 11367class="cmtt-8"> </span> 11368<br class="fancyvrb" /><a 11369 id="x1-111022r11"></a><span 11370class="cmr-6">11</span><span 11371class="cmtt-8"> </span><span 11372class="cmtt-8"> </span><span 11373class="cmtt-8"> </span><span 11374class="cmtt-8"> </span><span 11375class="cmtt-8"> </span><span 11376class="cmtt-8"> </span><span 11377class="cmtt-8"> </span><span 11378class="cmtt-8"> </span><span 11379class="cmtt-8"> </span><span 11380class="cmtt-8"> </span><span 11381class="cmtt-8"> }</span> 11382<br class="fancyvrb" /><a 11383 id="x1-111024r12"></a><span 11384class="cmr-6">12</span><span 11385class="cmtt-8"> </span><span 11386class="cmtt-8"> </span> 11387<br class="fancyvrb" /><a 11388 id="x1-111026r13"></a><span 11389class="cmr-6">13</span><span 11390class="cmtt-8"> </span><span 11391class="cmtt-8"> </span><span 11392class="cmtt-8"> </span><span 11393class="cmtt-8"> </span><span 11394class="cmtt-8"> </span><span 11395class="cmtt-8"> }</span> 11396<br class="fancyvrb" /><a 11397 id="x1-111028r14"></a><span 11398class="cmr-6">14</span><span 11399class="cmtt-8"> </span><span 11400class="cmtt-8"> </span> 11401<br class="fancyvrb" /><a 11402 id="x1-111030r15"></a><span 11403class="cmr-6">15</span><span 11404class="cmtt-8"> </span><span 11405class="cmtt-8"> </span><span 11406class="cmtt-8"> </span><span 11407class="cmtt-8"> 6)</span><span 11408class="cmtt-8"> done</span> 11409<br class="fancyvrb" /><a 11410 id="x1-111032r16"></a><span 11411class="cmr-6">16</span><span 11412class="cmtt-8"> </span><span 11413class="cmtt-8"> </span> 11414 11415 11416 11417</div> 11418<!--l. 384--><p class="noindent" > 11419<h5 class="subsubsectionHead"><span class="titlemark">8.6.4 </span> <a 11420 id="x1-1120008.6.4"></a>format 1 specifics</h5> 11421<!--l. 386--><p class="noindent" >Format 1 decodes partitions exactly as described earlier in the ’Residue Format: residue 1’ 11422section. The following pseudocode presents the same algorithm. Assume: 11423 <ul class="itemize1"> 11424 <li class="itemize"><span 11425class="cmtt-12">[n] </span>is the value in <span 11426class="cmtt-12">[residue_partition_size]</span> 11427 </li> 11428 <li class="itemize"><span 11429class="cmtt-12">[v] </span>is the residue vector 11430 </li> 11431 <li class="itemize"><span 11432class="cmtt-12">[offset] </span>is the beginning read offset in [v]</li></ul> 11433<!--l. 398--><p class="noindent" > 11434<div class="fancyvrb" id="fancyvrb42"> 11435<a 11436 id="x1-112002r1"></a><span 11437class="cmr-6">1</span><span 11438class="cmtt-8"> </span><span 11439class="cmtt-8"> </span><span 11440class="cmtt-8"> 1)</span><span 11441class="cmtt-8"> [i]</span><span 11442class="cmtt-8"> =</span><span 11443class="cmtt-8"> 0</span> 11444<br class="fancyvrb" /><a 11445 id="x1-112004r2"></a><span 11446class="cmr-6">2</span><span 11447class="cmtt-8"> </span><span 11448class="cmtt-8"> </span><span 11449class="cmtt-8"> 2)</span><span 11450class="cmtt-8"> vector</span><span 11451class="cmtt-8"> [entry_temp]</span><span 11452class="cmtt-8"> =</span><span 11453class="cmtt-8"> read</span><span 11454class="cmtt-8"> vector</span><span 11455class="cmtt-8"> from</span><span 11456class="cmtt-8"> packet</span><span 11457class="cmtt-8"> using</span><span 11458class="cmtt-8"> current</span><span 11459class="cmtt-8"> codebook</span><span 11460class="cmtt-8"> in</span><span 11461class="cmtt-8"> VQ</span><span 11462class="cmtt-8"> context</span> 11463<br class="fancyvrb" /><a 11464 id="x1-112006r3"></a><span 11465class="cmr-6">3</span><span 11466class="cmtt-8"> </span><span 11467class="cmtt-8"> </span><span 11468class="cmtt-8"> 3)</span><span 11469class="cmtt-8"> iterate</span><span 11470class="cmtt-8"> [j]</span><span 11471class="cmtt-8"> over</span><span 11472class="cmtt-8"> the</span><span 11473class="cmtt-8"> range</span><span 11474class="cmtt-8"> 0</span><span 11475class="cmtt-8"> ...</span><span 11476class="cmtt-8"> [codebook_dimensions]-1</span><span 11477class="cmtt-8"> {</span> 11478<br class="fancyvrb" /><a 11479 id="x1-112008r4"></a><span 11480class="cmr-6">4</span><span 11481class="cmtt-8"> </span><span 11482class="cmtt-8"> </span> 11483<br class="fancyvrb" /><a 11484 id="x1-112010r5"></a><span 11485class="cmr-6">5</span><span 11486class="cmtt-8"> </span><span 11487class="cmtt-8"> </span><span 11488class="cmtt-8"> </span><span 11489class="cmtt-8"> </span><span 11490class="cmtt-8"> </span><span 11491class="cmtt-8"> </span><span 11492class="cmtt-8"> </span><span 11493class="cmtt-8"> 4)</span><span 11494class="cmtt-8"> vector</span><span 11495class="cmtt-8"> [v]</span><span 11496class="cmtt-8"> element</span><span 11497class="cmtt-8"> ([offset]+[i])</span><span 11498class="cmtt-8"> =</span> 11499<br class="fancyvrb" /><a 11500 id="x1-112012r6"></a><span 11501class="cmr-6">6</span><span 11502class="cmtt-8"> </span><span 11503class="cmtt-8">  </span><span 11504class="cmtt-8"> </span><span 11505class="cmtt-8"> vector</span><span 11506class="cmtt-8"> [v]</span><span 11507class="cmtt-8"> element</span><span 11508class="cmtt-8"> ([offset]+[i])</span><span 11509class="cmtt-8"> +</span> 11510<br class="fancyvrb" /><a 11511 id="x1-112014r7"></a><span 11512class="cmr-6">7</span><span 11513class="cmtt-8"> </span><span 11514class="cmtt-8"> </span><span 11515class="cmtt-8"> </span><span 11516class="cmtt-8"> </span><span 11517class="cmtt-8"> </span><span 11518class="cmtt-8"> </span><span 11519class="cmtt-8"> </span><span 11520class="cmtt-8"> </span><span 11521class="cmtt-8"> </span><span 11522class="cmtt-8"> </span><span 11523class="cmtt-8"> </span><span 11524class="cmtt-8"> vector</span><span 11525class="cmtt-8"> [entry_temp]</span><span 11526class="cmtt-8"> element</span><span 11527class="cmtt-8"> [j]</span> 11528<br class="fancyvrb" /><a 11529 id="x1-112016r8"></a><span 11530class="cmr-6">8</span><span 11531class="cmtt-8"> </span><span 11532class="cmtt-8"> </span><span 11533class="cmtt-8"> </span><span 11534class="cmtt-8"> </span><span 11535class="cmtt-8"> </span><span 11536class="cmtt-8"> </span><span 11537class="cmtt-8"> </span><span 11538class="cmtt-8"> 5)</span><span 11539class="cmtt-8"> increment</span><span 11540class="cmtt-8"> [i]</span> 11541<br class="fancyvrb" /><a 11542 id="x1-112018r9"></a><span 11543class="cmr-6">9</span><span 11544class="cmtt-8"> </span><span 11545class="cmtt-8"> </span> 11546<br class="fancyvrb" /><a 11547 id="x1-112020r10"></a><span 11548class="cmr-6">10</span><span 11549class="cmtt-8"> </span><span 11550class="cmtt-8"> </span><span 11551class="cmtt-8"> </span><span 11552class="cmtt-8"> </span><span 11553class="cmtt-8"> </span><span 11554class="cmtt-8"> }</span> 11555<br class="fancyvrb" /><a 11556 id="x1-112022r11"></a><span 11557class="cmr-6">11</span><span 11558class="cmtt-8"> </span><span 11559class="cmtt-8"> </span> 11560<br class="fancyvrb" /><a 11561 id="x1-112024r12"></a><span 11562class="cmr-6">12</span><span 11563class="cmtt-8"> </span><span 11564class="cmtt-8"> </span><span 11565class="cmtt-8"> </span><span 11566class="cmtt-8"> 6)</span><span 11567class="cmtt-8"> if</span><span 11568class="cmtt-8"> (</span><span 11569class="cmtt-8"> [i]</span><span 11570class="cmtt-8"> is</span><span 11571class="cmtt-8"> less</span><span 11572class="cmtt-8"> than</span><span 11573class="cmtt-8"> [n]</span><span 11574class="cmtt-8"> )</span><span 11575class="cmtt-8"> continue</span><span 11576class="cmtt-8"> at</span><span 11577class="cmtt-8"> step</span><span 11578class="cmtt-8"> 2</span> 11579<br class="fancyvrb" /><a 11580 id="x1-112026r13"></a><span 11581class="cmr-6">13</span><span 11582class="cmtt-8"> </span><span 11583class="cmtt-8"> </span><span 11584class="cmtt-8"> </span><span 11585class="cmtt-8"> 7)</span><span 11586class="cmtt-8"> done</span> 11587</div> 11588<!--l. 416--><p class="noindent" > 11589<h5 class="subsubsectionHead"><span class="titlemark">8.6.5 </span> <a 11590 id="x1-1130008.6.5"></a>format 2 specifics</h5> 11591<!--l. 418--><p class="noindent" >Format 2 is reducible to format 1. It may be implemented as an additional step prior to and an 11592additional post-decode step after a normal format 1 decode. 11593 11594 11595 11596<!--l. 421--><p class="noindent" >Format 2 handles ’do not decode’ vectors differently than residue 0 or 1; if all vectors are marked 11597’do not decode’, no decode occurrs. However, if at least one vector is to be decoded, all 11598the vectors are decoded. We then request normal format 1 to decode a single vector 11599representing all output channels, rather than a vector for each channel. After decode, 11600deinterleave the vector into independent vectors, one for each output channel. That 11601is: 11602<!--l. 428--><p class="noindent" > 11603 <ol class="enumerate1" > 11604 <li 11605 class="enumerate" id="x1-113002x1">If all vectors 0 through <span 11606class="cmti-12">ch</span>-1 are marked ’do not decode’, allocate and clear a single 11607 vector <span 11608class="cmtt-12">[v]</span>of length <span 11609class="cmti-12">ch*n </span>and skip step 2 below; proceed directly to the post-decode 11610 step. 11611 </li> 11612 <li 11613 class="enumerate" id="x1-113004x2">Rather than performing format 1 decode to produce <span 11614class="cmti-12">ch </span>vectors of length <span 11615class="cmti-12">n </span>each, call 11616 format 1 decode to produce a single vector <span 11617class="cmtt-12">[v] </span>of length <span 11618class="cmti-12">ch*n</span>. 11619 </li> 11620 <li 11621 class="enumerate" id="x1-113006x3">Post decode: Deinterleave the single vector <span 11622class="cmtt-12">[v] </span>returned by format 1 decode as 11623 described above into <span 11624class="cmti-12">ch </span>independent vectors, one for each outputchannel, according 11625 to: 11626 <div class="fancyvrb" id="fancyvrb43"> 11627<a 11628 id="x1-113008r1"></a><span 11629class="cmr-6">1</span><span 11630class="cmtt-8"> </span><span 11631class="cmtt-8"> </span><span 11632class="cmtt-8"> </span><span 11633class="cmtt-8"> 1)</span><span 11634class="cmtt-8"> iterate</span><span 11635class="cmtt-8"> [i]</span><span 11636class="cmtt-8"> over</span><span 11637class="cmtt-8"> the</span><span 11638class="cmtt-8"> range</span><span 11639class="cmtt-8"> 0</span><span 11640class="cmtt-8"> ...</span><span 11641class="cmtt-8"> [n]-1</span><span 11642class="cmtt-8"> {</span> 11643<br class="fancyvrb" /><a 11644 id="x1-113010r2"></a><span 11645class="cmr-6">2</span><span 11646class="cmtt-8"> </span><span 11647class="cmtt-8"> </span> 11648<br class="fancyvrb" /><a 11649 id="x1-113012r3"></a><span 11650class="cmr-6">3</span><span 11651class="cmtt-8"> </span><span 11652class="cmtt-8"> </span><span 11653class="cmtt-8"> </span><span 11654class="cmtt-8"> </span><span 11655class="cmtt-8"> </span><span 11656class="cmtt-8"> </span><span 11657class="cmtt-8"> </span><span 11658class="cmtt-8"> </span><span 11659class="cmtt-8"> 2)</span><span 11660class="cmtt-8"> iterate</span><span 11661class="cmtt-8"> [j]</span><span 11662class="cmtt-8"> over</span><span 11663class="cmtt-8"> the</span><span 11664class="cmtt-8"> range</span><span 11665class="cmtt-8"> 0</span><span 11666class="cmtt-8"> ...</span><span 11667class="cmtt-8"> [ch]-1</span><span 11668class="cmtt-8"> {</span> 11669<br class="fancyvrb" /><a 11670 id="x1-113014r4"></a><span 11671class="cmr-6">4</span><span 11672class="cmtt-8"> </span><span 11673class="cmtt-8"> </span> 11674<br class="fancyvrb" /><a 11675 id="x1-113016r5"></a><span 11676class="cmr-6">5</span><span 11677class="cmtt-8"> </span><span 11678class="cmtt-8"> </span><span 11679class="cmtt-8"> </span><span 11680class="cmtt-8"> </span><span 11681class="cmtt-8"> </span><span 11682class="cmtt-8"> </span><span 11683class="cmtt-8"> </span><span 11684class="cmtt-8"> </span><span 11685class="cmtt-8"> </span><span 11686class="cmtt-8"> </span><span 11687class="cmtt-8"> </span><span 11688class="cmtt-8"> </span><span 11689class="cmtt-8"> </span><span 11690class="cmtt-8"> 3)</span><span 11691class="cmtt-8"> output</span><span 11692class="cmtt-8"> vector</span><span 11693class="cmtt-8"> number</span><span 11694class="cmtt-8"> [j]</span><span 11695class="cmtt-8"> element</span><span 11696class="cmtt-8"> [i]</span><span 11697class="cmtt-8"> =</span><span 11698class="cmtt-8"> vector</span><span 11699class="cmtt-8"> [v]</span><span 11700class="cmtt-8"> element</span><span 11701class="cmtt-8"> ([i]</span><span 11702class="cmtt-8"> *</span><span 11703class="cmtt-8"> [ch]</span><span 11704class="cmtt-8"> +</span><span 11705class="cmtt-8"> [j])</span> 11706<br class="fancyvrb" /><a 11707 id="x1-113018r6"></a><span 11708class="cmr-6">6</span><span 11709class="cmtt-8"> </span><span 11710class="cmtt-8"> </span> 11711<br class="fancyvrb" /><a 11712 id="x1-113020r7"></a><span 11713class="cmr-6">7</span><span 11714class="cmtt-8"> </span><span 11715class="cmtt-8"> </span><span 11716class="cmtt-8"> </span><span 11717class="cmtt-8"> </span><span 11718class="cmtt-8"> </span><span 11719class="cmtt-8"> </span><span 11720class="cmtt-8"> </span><span 11721class="cmtt-8"> </span><span 11722class="cmtt-8"> </span><span 11723class="cmtt-8"> </span><span 11724class="cmtt-8"> </span><span 11725class="cmtt-8"> }</span> 11726<br class="fancyvrb" /><a 11727 id="x1-113022r8"></a><span 11728class="cmr-6">8</span><span 11729class="cmtt-8"> </span><span 11730class="cmtt-8"> </span><span 11731class="cmtt-8"> </span><span 11732class="cmtt-8"> </span><span 11733class="cmtt-8"> </span><span 11734class="cmtt-8"> </span><span 11735class="cmtt-8"> }</span> 11736<br class="fancyvrb" /><a 11737 id="x1-113024r9"></a><span 11738class="cmr-6">9</span><span 11739class="cmtt-8"> </span><span 11740class="cmtt-8"> </span> 11741<br class="fancyvrb" /><a 11742 id="x1-113026r10"></a><span 11743class="cmr-6">10</span><span 11744class="cmtt-8"> </span><span 11745class="cmtt-8"> </span><span 11746class="cmtt-8"> </span><span 11747class="cmtt-8"> 4)</span><span 11748class="cmtt-8"> done</span> 11749</div> 11750 </li></ol> 11751 11752 11753 11754 11755 11756 11757<h3 class="sectionHead"><span class="titlemark">9 </span> <a 11758 id="x1-1140009"></a>Helper equations</h3> 11759<!--l. 6--><p class="noindent" > 11760<h4 class="subsectionHead"><span class="titlemark">9.1 </span> <a 11761 id="x1-1150009.1"></a>Overview</h4> 11762<!--l. 8--><p class="noindent" >The equations below are used in multiple places by the Vorbis codec specification. Rather than 11763cluttering up the main specification documents, they are defined here and referenced where 11764appropriate. 11765<!--l. 13--><p class="noindent" > 11766<h4 class="subsectionHead"><span class="titlemark">9.2 </span> <a 11767 id="x1-1160009.2"></a>Functions</h4> 11768<!--l. 15--><p class="noindent" > 11769<h5 class="subsubsectionHead"><span class="titlemark">9.2.1 </span> <a 11770 id="x1-1170009.2.1"></a>ilog</h5> 11771<!--l. 17--><p class="noindent" >The ”ilog(x)” function returns the position number (1 through n) of the highest set bit in the 11772two’s complement integer value <span 11773class="cmtt-12">[x]</span>. Values of <span 11774class="cmtt-12">[x] </span>less than zero are defined to return 11775zero. 11776<!--l. 20--><p class="noindent" > 11777<div class="fancyvrb" id="fancyvrb44"> 11778<a 11779 id="x1-117002r1"></a><span 11780class="cmr-6">1</span><span 11781class="cmtt-8"> </span><span 11782class="cmtt-8"> </span><span 11783class="cmtt-8"> </span><span 11784class="cmtt-8"> 1)</span><span 11785class="cmtt-8"> [return_value]</span><span 11786class="cmtt-8"> =</span><span 11787class="cmtt-8"> 0;</span> 11788<br class="fancyvrb" /><a 11789 id="x1-117004r2"></a><span 11790class="cmr-6">2</span><span 11791class="cmtt-8"> </span><span 11792class="cmtt-8"> </span><span 11793class="cmtt-8"> </span><span 11794class="cmtt-8"> 2)</span><span 11795class="cmtt-8"> if</span><span 11796class="cmtt-8"> (</span><span 11797class="cmtt-8"> [x]</span><span 11798class="cmtt-8"> is</span><span 11799class="cmtt-8"> greater</span><span 11800class="cmtt-8"> than</span><span 11801class="cmtt-8"> zero</span><span 11802class="cmtt-8"> )</span><span 11803class="cmtt-8"> {</span> 11804<br class="fancyvrb" /><a 11805 id="x1-117006r3"></a><span 11806class="cmr-6">3</span><span 11807class="cmtt-8"> </span><span 11808class="cmtt-8"> </span> 11809<br class="fancyvrb" /><a 11810 id="x1-117008r4"></a><span 11811class="cmr-6">4</span><span 11812class="cmtt-8"> </span><span 11813class="cmtt-8"> </span><span 11814class="cmtt-8"> </span><span 11815class="cmtt-8"> </span><span 11816class="cmtt-8"> </span><span 11817class="cmtt-8"> </span><span 11818class="cmtt-8"> </span><span 11819class="cmtt-8"> </span><span 11820class="cmtt-8"> 3)</span><span 11821class="cmtt-8"> increment</span><span 11822class="cmtt-8"> [return_value];</span> 11823<br class="fancyvrb" /><a 11824 id="x1-117010r5"></a><span 11825class="cmr-6">5</span><span 11826class="cmtt-8"> </span><span 11827class="cmtt-8"> </span><span 11828class="cmtt-8"> </span><span 11829class="cmtt-8"> </span><span 11830class="cmtt-8"> </span><span 11831class="cmtt-8"> </span><span 11832class="cmtt-8"> </span><span 11833class="cmtt-8"> </span><span 11834class="cmtt-8"> 4)</span><span 11835class="cmtt-8"> logical</span><span 11836class="cmtt-8"> shift</span><span 11837class="cmtt-8"> [x]</span><span 11838class="cmtt-8"> one</span><span 11839class="cmtt-8"> bit</span><span 11840class="cmtt-8"> to</span><span 11841class="cmtt-8"> the</span><span 11842class="cmtt-8"> right,</span><span 11843class="cmtt-8"> padding</span><span 11844class="cmtt-8"> the</span><span 11845class="cmtt-8"> MSb</span><span 11846class="cmtt-8"> with</span><span 11847class="cmtt-8"> zero</span> 11848<br class="fancyvrb" /><a 11849 id="x1-117012r6"></a><span 11850class="cmr-6">6</span><span 11851class="cmtt-8"> </span><span 11852class="cmtt-8"> </span><span 11853class="cmtt-8"> </span><span 11854class="cmtt-8"> </span><span 11855class="cmtt-8"> </span><span 11856class="cmtt-8"> </span><span 11857class="cmtt-8"> </span><span 11858class="cmtt-8"> </span><span 11859class="cmtt-8"> 5)</span><span 11860class="cmtt-8"> repeat</span><span 11861class="cmtt-8"> at</span><span 11862class="cmtt-8"> step</span><span 11863class="cmtt-8"> 2)</span> 11864<br class="fancyvrb" /><a 11865 id="x1-117014r7"></a><span 11866class="cmr-6">7</span><span 11867class="cmtt-8"> </span><span 11868class="cmtt-8"> </span> 11869<br class="fancyvrb" /><a 11870 id="x1-117016r8"></a><span 11871class="cmr-6">8</span><span 11872class="cmtt-8"> </span><span 11873class="cmtt-8"> </span><span 11874class="cmtt-8"> </span><span 11875class="cmtt-8"> </span><span 11876class="cmtt-8"> </span><span 11877class="cmtt-8"> </span><span 11878class="cmtt-8"> }</span> 11879<br class="fancyvrb" /><a 11880 id="x1-117018r9"></a><span 11881class="cmr-6">9</span><span 11882class="cmtt-8"> </span><span 11883class="cmtt-8"> </span> 11884<br class="fancyvrb" /><a 11885 id="x1-117020r10"></a><span 11886class="cmr-6">10</span><span 11887class="cmtt-8"> </span><span 11888class="cmtt-8"> </span><span 11889class="cmtt-8"> </span><span 11890class="cmtt-8"> </span><span 11891class="cmtt-8"> 6)</span><span 11892class="cmtt-8"> done</span> 11893</div> 11894 11895 11896 11897<!--l. 33--><p class="noindent" >Examples: 11898 <ul class="itemize1"> 11899 <li class="itemize">ilog(0) = 0; 11900 </li> 11901 <li class="itemize">ilog(1) = 1; 11902 </li> 11903 <li class="itemize">ilog(2) = 2; 11904 </li> 11905 <li class="itemize">ilog(3) = 2; 11906 </li> 11907 <li class="itemize">ilog(4) = 3; 11908 </li> 11909 <li class="itemize">ilog(7) = 3; 11910 </li> 11911 <li class="itemize">ilog(negative number) = 0;</li></ul> 11912<!--l. 48--><p class="noindent" > 11913<h5 class="subsubsectionHead"><span class="titlemark">9.2.2 </span> <a 11914 id="x1-1180009.2.2"></a>float32˙unpack</h5> 11915<!--l. 50--><p class="noindent" >”float32˙unpack(x)” is intended to translate the packed binary representation of a Vorbis 11916codebook float value into the representation used by the decoder for floating point numbers. For 11917purposes of this example, we will unpack a Vorbis float32 into a host-native floating point 11918number. 11919<!--l. 56--><p class="noindent" > 11920<div class="fancyvrb" id="fancyvrb45"> 11921<a 11922 id="x1-118002r1"></a><span 11923class="cmr-6">1</span><span 11924class="cmtt-8"> </span><span 11925class="cmtt-8"> </span><span 11926class="cmtt-8"> </span><span 11927class="cmtt-8"> 1)</span><span 11928class="cmtt-8"> [mantissa]</span><span 11929class="cmtt-8"> =</span><span 11930class="cmtt-8"> [x]</span><span 11931class="cmtt-8"> bitwise</span><span 11932class="cmtt-8"> AND</span><span 11933class="cmtt-8"> 0x1fffff</span><span 11934class="cmtt-8"> (unsigned</span><span 11935class="cmtt-8"> result)</span> 11936<br class="fancyvrb" /><a 11937 id="x1-118004r2"></a><span 11938class="cmr-6">2</span><span 11939class="cmtt-8"> </span><span 11940class="cmtt-8"> </span><span 11941class="cmtt-8"> </span><span 11942class="cmtt-8"> 2)</span><span 11943class="cmtt-8"> [sign]</span><span 11944class="cmtt-8"> =</span><span 11945class="cmtt-8"> [x]</span><span 11946class="cmtt-8"> bitwise</span><span 11947class="cmtt-8"> AND</span><span 11948class="cmtt-8"> 0x80000000</span><span 11949class="cmtt-8"> (unsigned</span><span 11950class="cmtt-8"> result)</span> 11951<br class="fancyvrb" /><a 11952 id="x1-118006r3"></a><span 11953class="cmr-6">3</span><span 11954class="cmtt-8"> </span><span 11955class="cmtt-8"> </span><span 11956class="cmtt-8"> </span><span 11957class="cmtt-8"> 3)</span><span 11958class="cmtt-8"> [exponent]</span><span 11959class="cmtt-8"> =</span><span 11960class="cmtt-8"> (</span><span 11961class="cmtt-8"> [x]</span><span 11962class="cmtt-8"> bitwise</span><span 11963class="cmtt-8"> AND</span><span 11964class="cmtt-8"> 0x7fe00000)</span><span 11965class="cmtt-8"> shifted</span><span 11966class="cmtt-8"> right</span><span 11967class="cmtt-8"> 21</span><span 11968class="cmtt-8"> bits</span><span 11969class="cmtt-8"> (unsigned</span><span 11970class="cmtt-8"> result)</span> 11971<br class="fancyvrb" /><a 11972 id="x1-118008r4"></a><span 11973class="cmr-6">4</span><span 11974class="cmtt-8"> </span><span 11975class="cmtt-8"> </span><span 11976class="cmtt-8"> </span><span 11977class="cmtt-8"> 4)</span><span 11978class="cmtt-8"> if</span><span 11979class="cmtt-8"> (</span><span 11980class="cmtt-8"> [sign]</span><span 11981class="cmtt-8"> is</span><span 11982class="cmtt-8"> nonzero</span><span 11983class="cmtt-8"> )</span><span 11984class="cmtt-8"> then</span><span 11985class="cmtt-8"> negate</span><span 11986class="cmtt-8"> [mantissa]</span> 11987<br class="fancyvrb" /><a 11988 id="x1-118010r5"></a><span 11989class="cmr-6">5</span><span 11990class="cmtt-8"> </span><span 11991class="cmtt-8"> </span><span 11992class="cmtt-8"> </span><span 11993class="cmtt-8"> 5)</span><span 11994class="cmtt-8"> return</span><span 11995class="cmtt-8"> [mantissa]</span><span 11996class="cmtt-8"> *</span><span 11997class="cmtt-8"> (</span><span 11998class="cmtt-8"> 2</span><span 11999class="cmtt-8"> ^</span><span 12000class="cmtt-8"> (</span><span 12001class="cmtt-8"> [exponent]</span><span 12002class="cmtt-8"> -</span><span 12003class="cmtt-8"> 788</span><span 12004class="cmtt-8"> )</span><span 12005class="cmtt-8"> )</span> 12006</div> 12007 12008 12009 12010<!--l. 66--><p class="noindent" > 12011<h5 class="subsubsectionHead"><span class="titlemark">9.2.3 </span> <a 12012 id="x1-1190009.2.3"></a>lookup1˙values</h5> 12013<!--l. 68--><p class="noindent" >”lookup1˙values(codebook˙entries,codebook˙dimensions)” is used to compute the correct length of 12014the value index for a codebook VQ lookup table of lookup type 1. The values on this list are 12015permuted to construct the VQ vector lookup table of size <span 12016class="cmtt-12">[codebook_entries]</span>. 12017<!--l. 74--><p class="noindent" >The return value for this function is defined to be ’the greatest integer value for which 12018<span 12019class="cmtt-12">[return_value] </span>to the power of <span 12020class="cmtt-12">[codebook_dimensions] </span>is less than or equal to 12021<span 12022class="cmtt-12">[codebook_entries]</span>’. 12023<!--l. 81--><p class="noindent" > 12024<h5 class="subsubsectionHead"><span class="titlemark">9.2.4 </span> <a 12025 id="x1-1200009.2.4"></a>low˙neighbor</h5> 12026<!--l. 83--><p class="noindent" >”low˙neighbor(v,x)” finds the position <span 12027class="cmtt-12">n </span>in vector <span 12028class="cmtt-12">[v] </span>of the greatest value scalar element for 12029which <span 12030class="cmtt-12">n </span>is less than <span 12031class="cmtt-12">[x] </span>and vector <span 12032class="cmtt-12">[v] </span>element <span 12033class="cmtt-12">n </span>is less than vector <span 12034class="cmtt-12">[v] </span>element 12035<span 12036class="cmtt-12">[x]</span>. 12037<!--l. 88--><p class="noindent" > 12038<h5 class="subsubsectionHead"><span class="titlemark">9.2.5 </span> <a 12039 id="x1-1210009.2.5"></a>high˙neighbor</h5> 12040<!--l. 90--><p class="noindent" >”high˙neighbor(v,x)” finds the position <span 12041class="cmtt-12">n </span>in vector [v] of the lowest value scalar element for 12042which <span 12043class="cmtt-12">n </span>is less than <span 12044class="cmtt-12">[x] </span>and vector <span 12045class="cmtt-12">[v] </span>element <span 12046class="cmtt-12">n </span>is greater than vector <span 12047class="cmtt-12">[v] </span>element 12048<span 12049class="cmtt-12">[x]</span>. 12050<!--l. 97--><p class="noindent" > 12051<h5 class="subsubsectionHead"><span class="titlemark">9.2.6 </span> <a 12052 id="x1-1220009.2.6"></a>render˙point</h5> 12053<!--l. 99--><p class="noindent" >”render˙point(x0,y0,x1,y1,X)” is used to find the Y value at point X along the line specified by 12054x0, x1, y0 and y1. This function uses an integer algorithm to solve for the point directly without 12055calculating intervening values along the line. 12056<!--l. 104--><p class="noindent" > 12057 12058 12059 12060<div class="fancyvrb" id="fancyvrb46"> 12061<a 12062 id="x1-122002r1"></a><span 12063class="cmr-6">1</span><span 12064class="cmtt-8"> </span><span 12065class="cmtt-8"> </span><span 12066class="cmtt-8"> </span><span 12067class="cmtt-8"> 1)</span><span 12068class="cmtt-8"> </span><span 12069class="cmtt-8"> [dy]</span><span 12070class="cmtt-8"> =</span><span 12071class="cmtt-8"> [y1]</span><span 12072class="cmtt-8"> -</span><span 12073class="cmtt-8"> [y0]</span> 12074<br class="fancyvrb" /><a 12075 id="x1-122004r2"></a><span 12076class="cmr-6">2</span><span 12077class="cmtt-8"> </span><span 12078class="cmtt-8"> </span><span 12079class="cmtt-8"> </span><span 12080class="cmtt-8"> 2)</span><span 12081class="cmtt-8"> [adx]</span><span 12082class="cmtt-8"> =</span><span 12083class="cmtt-8"> [x1]</span><span 12084class="cmtt-8"> -</span><span 12085class="cmtt-8"> [x0]</span> 12086<br class="fancyvrb" /><a 12087 id="x1-122006r3"></a><span 12088class="cmr-6">3</span><span 12089class="cmtt-8"> </span><span 12090class="cmtt-8"> </span><span 12091class="cmtt-8"> </span><span 12092class="cmtt-8"> 3)</span><span 12093class="cmtt-8"> [ady]</span><span 12094class="cmtt-8"> =</span><span 12095class="cmtt-8"> absolute</span><span 12096class="cmtt-8"> value</span><span 12097class="cmtt-8"> of</span><span 12098class="cmtt-8"> [dy]</span> 12099<br class="fancyvrb" /><a 12100 id="x1-122008r4"></a><span 12101class="cmr-6">4</span><span 12102class="cmtt-8"> </span><span 12103class="cmtt-8"> </span><span 12104class="cmtt-8"> </span><span 12105class="cmtt-8"> 4)</span><span 12106class="cmtt-8"> [err]</span><span 12107class="cmtt-8"> =</span><span 12108class="cmtt-8"> [ady]</span><span 12109class="cmtt-8"> *</span><span 12110class="cmtt-8"> ([X]</span><span 12111class="cmtt-8"> -</span><span 12112class="cmtt-8"> [x0])</span> 12113<br class="fancyvrb" /><a 12114 id="x1-122010r5"></a><span 12115class="cmr-6">5</span><span 12116class="cmtt-8"> </span><span 12117class="cmtt-8"> </span><span 12118class="cmtt-8"> </span><span 12119class="cmtt-8"> 5)</span><span 12120class="cmtt-8"> [off]</span><span 12121class="cmtt-8"> =</span><span 12122class="cmtt-8"> [err]</span><span 12123class="cmtt-8"> /</span><span 12124class="cmtt-8"> [adx]</span><span 12125class="cmtt-8"> using</span><span 12126class="cmtt-8"> integer</span><span 12127class="cmtt-8"> division</span> 12128<br class="fancyvrb" /><a 12129 id="x1-122012r6"></a><span 12130class="cmr-6">6</span><span 12131class="cmtt-8"> </span><span 12132class="cmtt-8"> </span><span 12133class="cmtt-8"> </span><span 12134class="cmtt-8"> 6)</span><span 12135class="cmtt-8"> if</span><span 12136class="cmtt-8"> (</span><span 12137class="cmtt-8"> [dy]</span><span 12138class="cmtt-8"> is</span><span 12139class="cmtt-8"> less</span><span 12140class="cmtt-8"> than</span><span 12141class="cmtt-8"> zero</span><span 12142class="cmtt-8"> )</span><span 12143class="cmtt-8"> {</span> 12144<br class="fancyvrb" /><a 12145 id="x1-122014r7"></a><span 12146class="cmr-6">7</span><span 12147class="cmtt-8"> </span><span 12148class="cmtt-8"> </span> 12149<br class="fancyvrb" /><a 12150 id="x1-122016r8"></a><span 12151class="cmr-6">8</span><span 12152class="cmtt-8"> </span><span 12153class="cmtt-8"> </span><span 12154class="cmtt-8"> </span><span 12155class="cmtt-8"> </span><span 12156class="cmtt-8"> </span><span 12157class="cmtt-8"> </span><span 12158class="cmtt-8"> </span><span 12159class="cmtt-8"> </span><span 12160class="cmtt-8"> 7)</span><span 12161class="cmtt-8"> [Y]</span><span 12162class="cmtt-8"> =</span><span 12163class="cmtt-8"> [y0]</span><span 12164class="cmtt-8"> -</span><span 12165class="cmtt-8"> [off]</span> 12166<br class="fancyvrb" /><a 12167 id="x1-122018r9"></a><span 12168class="cmr-6">9</span><span 12169class="cmtt-8"> </span><span 12170class="cmtt-8"> </span> 12171<br class="fancyvrb" /><a 12172 id="x1-122020r10"></a><span 12173class="cmr-6">10</span><span 12174class="cmtt-8"> </span><span 12175class="cmtt-8"> </span><span 12176class="cmtt-8"> </span><span 12177class="cmtt-8"> </span><span 12178class="cmtt-8"> </span><span 12179class="cmtt-8"> </span><span 12180class="cmtt-8"> }</span><span 12181class="cmtt-8"> else</span><span 12182class="cmtt-8"> {</span> 12183<br class="fancyvrb" /><a 12184 id="x1-122022r11"></a><span 12185class="cmr-6">11</span><span 12186class="cmtt-8"> </span><span 12187class="cmtt-8"> </span> 12188<br class="fancyvrb" /><a 12189 id="x1-122024r12"></a><span 12190class="cmr-6">12</span><span 12191class="cmtt-8"> </span><span 12192class="cmtt-8"> </span><span 12193class="cmtt-8"> </span><span 12194class="cmtt-8"> </span><span 12195class="cmtt-8"> </span><span 12196class="cmtt-8"> </span><span 12197class="cmtt-8"> </span><span 12198class="cmtt-8"> </span><span 12199class="cmtt-8"> 8)</span><span 12200class="cmtt-8"> [Y]</span><span 12201class="cmtt-8"> =</span><span 12202class="cmtt-8"> [y0]</span><span 12203class="cmtt-8"> +</span><span 12204class="cmtt-8"> [off]</span> 12205<br class="fancyvrb" /><a 12206 id="x1-122026r13"></a><span 12207class="cmr-6">13</span><span 12208class="cmtt-8"> </span><span 12209class="cmtt-8"> </span> 12210<br class="fancyvrb" /><a 12211 id="x1-122028r14"></a><span 12212class="cmr-6">14</span><span 12213class="cmtt-8"> </span><span 12214class="cmtt-8"> </span><span 12215class="cmtt-8"> </span><span 12216class="cmtt-8"> </span><span 12217class="cmtt-8"> </span><span 12218class="cmtt-8"> </span><span 12219class="cmtt-8"> }</span> 12220<br class="fancyvrb" /><a 12221 id="x1-122030r15"></a><span 12222class="cmr-6">15</span><span 12223class="cmtt-8"> </span><span 12224class="cmtt-8"> </span> 12225<br class="fancyvrb" /><a 12226 id="x1-122032r16"></a><span 12227class="cmr-6">16</span><span 12228class="cmtt-8"> </span><span 12229class="cmtt-8"> </span><span 12230class="cmtt-8"> </span><span 12231class="cmtt-8"> 9)</span><span 12232class="cmtt-8"> done</span> 12233</div> 12234<!--l. 125--><p class="noindent" > 12235<h5 class="subsubsectionHead"><span class="titlemark">9.2.7 </span> <a 12236 id="x1-1230009.2.7"></a>render˙line</h5> 12237<!--l. 127--><p class="noindent" >Floor decode type one uses the integer line drawing algorithm of ”render˙line(x0, y0, x1, y1, v)” 12238to construct an integer floor curve for contiguous piecewise line segments. Note that it has not 12239been relevant elsewhere, but here we must define integer division as rounding division of both 12240positive and negative numbers toward zero. 12241<!--l. 134--><p class="noindent" > 12242<div class="fancyvrb" id="fancyvrb47"> 12243<a 12244 id="x1-123002r1"></a><span 12245class="cmr-6">1</span><span 12246class="cmtt-8"> </span><span 12247class="cmtt-8"> </span><span 12248class="cmtt-8"> </span><span 12249class="cmtt-8"> 1)</span><span 12250class="cmtt-8"> </span><span 12251class="cmtt-8"> </span><span 12252class="cmtt-8"> [dy]</span><span 12253class="cmtt-8"> =</span><span 12254class="cmtt-8"> [y1]</span><span 12255class="cmtt-8"> -</span><span 12256class="cmtt-8"> [y0]</span> 12257<br class="fancyvrb" /><a 12258 id="x1-123004r2"></a><span 12259class="cmr-6">2</span><span 12260class="cmtt-8"> </span><span 12261class="cmtt-8"> </span><span 12262class="cmtt-8"> </span><span 12263class="cmtt-8"> 2)</span><span 12264class="cmtt-8"> </span><span 12265class="cmtt-8"> [adx]</span><span 12266class="cmtt-8"> =</span><span 12267class="cmtt-8"> [x1]</span><span 12268class="cmtt-8"> -</span><span 12269class="cmtt-8"> [x0]</span> 12270<br class="fancyvrb" /><a 12271 id="x1-123006r3"></a><span 12272class="cmr-6">3</span><span 12273class="cmtt-8"> </span><span 12274class="cmtt-8"> </span><span 12275class="cmtt-8"> </span><span 12276class="cmtt-8"> 3)</span><span 12277class="cmtt-8"> </span><span 12278class="cmtt-8"> [ady]</span><span 12279class="cmtt-8"> =</span><span 12280class="cmtt-8"> absolute</span><span 12281class="cmtt-8"> value</span><span 12282class="cmtt-8"> of</span><span 12283class="cmtt-8"> [dy]</span> 12284<br class="fancyvrb" /><a 12285 id="x1-123008r4"></a><span 12286class="cmr-6">4</span><span 12287class="cmtt-8"> </span><span 12288class="cmtt-8"> </span><span 12289class="cmtt-8"> </span><span 12290class="cmtt-8"> 4)</span><span 12291class="cmtt-8"> [base]</span><span 12292class="cmtt-8"> =</span><span 12293class="cmtt-8"> [dy]</span><span 12294class="cmtt-8"> /</span><span 12295class="cmtt-8"> [adx]</span><span 12296class="cmtt-8"> using</span><span 12297class="cmtt-8"> integer</span><span 12298class="cmtt-8"> division</span> 12299<br class="fancyvrb" /><a 12300 id="x1-123010r5"></a><span 12301class="cmr-6">5</span><span 12302class="cmtt-8"> </span><span 12303class="cmtt-8"> </span><span 12304class="cmtt-8"> </span><span 12305class="cmtt-8"> 5)</span><span 12306class="cmtt-8"> </span><span 12307class="cmtt-8"> </span><span 12308class="cmtt-8"> </span><span 12309class="cmtt-8"> [x]</span><span 12310class="cmtt-8"> =</span><span 12311class="cmtt-8"> [x0]</span> 12312<br class="fancyvrb" /><a 12313 id="x1-123012r6"></a><span 12314class="cmr-6">6</span><span 12315class="cmtt-8"> </span><span 12316class="cmtt-8"> </span><span 12317class="cmtt-8"> </span><span 12318class="cmtt-8"> 6)</span><span 12319class="cmtt-8"> </span><span 12320class="cmtt-8"> </span><span 12321class="cmtt-8"> </span><span 12322class="cmtt-8"> [y]</span><span 12323class="cmtt-8"> =</span><span 12324class="cmtt-8"> [y0]</span> 12325<br class="fancyvrb" /><a 12326 id="x1-123014r7"></a><span 12327class="cmr-6">7</span><span 12328class="cmtt-8"> </span><span 12329class="cmtt-8"> </span><span 12330class="cmtt-8"> </span><span 12331class="cmtt-8"> 7)</span><span 12332class="cmtt-8"> </span><span 12333class="cmtt-8"> [err]</span><span 12334class="cmtt-8"> =</span><span 12335class="cmtt-8"> 0</span> 12336<br class="fancyvrb" /><a 12337 id="x1-123016r8"></a><span 12338class="cmr-6">8</span><span 12339class="cmtt-8"> </span><span 12340class="cmtt-8"> </span> 12341<br class="fancyvrb" /><a 12342 id="x1-123018r9"></a><span 12343class="cmr-6">9</span><span 12344class="cmtt-8"> </span><span 12345class="cmtt-8"> </span><span 12346class="cmtt-8"> </span><span 12347class="cmtt-8"> 8)</span><span 12348class="cmtt-8"> if</span><span 12349class="cmtt-8"> (</span><span 12350class="cmtt-8"> [dy]</span><span 12351class="cmtt-8"> is</span><span 12352class="cmtt-8"> less</span><span 12353class="cmtt-8"> than</span><span 12354class="cmtt-8"> 0</span><span 12355class="cmtt-8"> )</span><span 12356class="cmtt-8"> {</span> 12357<br class="fancyvrb" /><a 12358 id="x1-123020r10"></a><span 12359class="cmr-6">10</span><span 12360class="cmtt-8"> </span><span 12361class="cmtt-8"> </span> 12362<br class="fancyvrb" /><a 12363 id="x1-123022r11"></a><span 12364class="cmr-6">11</span><span 12365class="cmtt-8"> </span><span 12366class="cmtt-8"> </span><span 12367class="cmtt-8"> </span><span 12368class="cmtt-8"> </span><span 12369class="cmtt-8"> </span><span 12370class="cmtt-8"> </span><span 12371class="cmtt-8"> </span><span 12372class="cmtt-8"> </span><span 12373class="cmtt-8"> </span><span 12374class="cmtt-8"> 9)</span><span 12375class="cmtt-8"> [sy]</span><span 12376class="cmtt-8"> =</span><span 12377class="cmtt-8"> [base]</span><span 12378class="cmtt-8"> -</span><span 12379class="cmtt-8"> 1</span> 12380<br class="fancyvrb" /><a 12381 id="x1-123024r12"></a><span 12382class="cmr-6">12</span><span 12383class="cmtt-8"> </span><span 12384class="cmtt-8"> </span> 12385<br class="fancyvrb" /><a 12386 id="x1-123026r13"></a><span 12387class="cmr-6">13</span><span 12388class="cmtt-8"> </span><span 12389class="cmtt-8"> </span><span 12390class="cmtt-8"> </span><span 12391class="cmtt-8"> </span><span 12392class="cmtt-8"> </span><span 12393class="cmtt-8"> </span><span 12394class="cmtt-8"> }</span><span 12395class="cmtt-8"> else</span><span 12396class="cmtt-8"> {</span> 12397<br class="fancyvrb" /><a 12398 id="x1-123028r14"></a><span 12399class="cmr-6">14</span><span 12400class="cmtt-8"> </span><span 12401class="cmtt-8"> </span> 12402<br class="fancyvrb" /><a 12403 id="x1-123030r15"></a><span 12404class="cmr-6">15</span><span 12405class="cmtt-8"> </span><span 12406class="cmtt-8"> </span><span 12407class="cmtt-8"> </span><span 12408class="cmtt-8"> </span><span 12409class="cmtt-8"> </span><span 12410class="cmtt-8"> </span><span 12411class="cmtt-8"> </span><span 12412class="cmtt-8"> </span><span 12413class="cmtt-8"> 10)</span><span 12414class="cmtt-8"> [sy]</span><span 12415class="cmtt-8"> =</span><span 12416class="cmtt-8"> [base]</span><span 12417class="cmtt-8"> +</span><span 12418class="cmtt-8"> 1</span> 12419<br class="fancyvrb" /><a 12420 id="x1-123032r16"></a><span 12421class="cmr-6">16</span><span 12422class="cmtt-8"> </span><span 12423class="cmtt-8"> </span> 12424<br class="fancyvrb" /><a 12425 id="x1-123034r17"></a><span 12426class="cmr-6">17</span><span 12427class="cmtt-8"> </span><span 12428class="cmtt-8"> </span><span 12429class="cmtt-8"> </span><span 12430class="cmtt-8"> </span><span 12431class="cmtt-8"> </span><span 12432class="cmtt-8"> </span><span 12433class="cmtt-8"> }</span> 12434<br class="fancyvrb" /><a 12435 id="x1-123036r18"></a><span 12436class="cmr-6">18</span><span 12437class="cmtt-8"> </span><span 12438class="cmtt-8"> </span> 12439<br class="fancyvrb" /><a 12440 id="x1-123038r19"></a><span 12441class="cmr-6">19</span><span 12442class="cmtt-8"> </span><span 12443class="cmtt-8"> </span><span 12444class="cmtt-8"> 11)</span><span 12445class="cmtt-8"> [ady]</span><span 12446class="cmtt-8"> =</span><span 12447class="cmtt-8"> [ady]</span><span 12448class="cmtt-8"> -</span><span 12449class="cmtt-8"> (absolute</span><span 12450class="cmtt-8"> value</span><span 12451class="cmtt-8"> of</span><span 12452class="cmtt-8"> [base])</span><span 12453class="cmtt-8"> *</span><span 12454class="cmtt-8"> [adx]</span> 12455<br class="fancyvrb" /><a 12456 id="x1-123040r20"></a><span 12457class="cmr-6">20</span><span 12458class="cmtt-8"> </span><span 12459class="cmtt-8"> </span><span 12460class="cmtt-8"> 12)</span><span 12461class="cmtt-8"> vector</span><span 12462class="cmtt-8"> [v]</span><span 12463class="cmtt-8"> element</span><span 12464class="cmtt-8"> [x]</span><span 12465class="cmtt-8"> =</span><span 12466class="cmtt-8"> [y]</span> 12467<br class="fancyvrb" /><a 12468 id="x1-123042r21"></a><span 12469class="cmr-6">21</span><span 12470class="cmtt-8"> </span><span 12471class="cmtt-8"> </span> 12472<br class="fancyvrb" /><a 12473 id="x1-123044r22"></a><span 12474class="cmr-6">22</span><span 12475class="cmtt-8"> </span><span 12476class="cmtt-8"> </span><span 12477class="cmtt-8"> 13)</span><span 12478class="cmtt-8"> iterate</span><span 12479class="cmtt-8"> [x]</span><span 12480class="cmtt-8"> over</span><span 12481class="cmtt-8"> the</span><span 12482class="cmtt-8"> range</span><span 12483class="cmtt-8"> [x0]+1</span><span 12484class="cmtt-8"> ...</span><span 12485class="cmtt-8"> [x1]-1</span><span 12486class="cmtt-8"> {</span> 12487<br class="fancyvrb" /><a 12488 id="x1-123046r23"></a><span 12489class="cmr-6">23</span><span 12490class="cmtt-8"> </span><span 12491class="cmtt-8"> </span> 12492<br class="fancyvrb" /><a 12493 id="x1-123048r24"></a><span 12494class="cmr-6">24</span><span 12495class="cmtt-8"> </span><span 12496class="cmtt-8"> </span><span 12497class="cmtt-8"> </span><span 12498class="cmtt-8"> </span><span 12499class="cmtt-8"> </span><span 12500class="cmtt-8"> </span><span 12501class="cmtt-8"> </span><span 12502class="cmtt-8"> </span><span 12503class="cmtt-8"> 14)</span><span 12504class="cmtt-8"> [err]</span><span 12505class="cmtt-8"> =</span><span 12506class="cmtt-8"> [err]</span><span 12507class="cmtt-8"> +</span><span 12508class="cmtt-8"> [ady];</span> 12509 12510 12511 12512<br class="fancyvrb" /><a 12513 id="x1-123050r25"></a><span 12514class="cmr-6">25</span><span 12515class="cmtt-8"> </span><span 12516class="cmtt-8"> </span><span 12517class="cmtt-8"> </span><span 12518class="cmtt-8"> </span><span 12519class="cmtt-8"> </span><span 12520class="cmtt-8"> </span><span 12521class="cmtt-8"> </span><span 12522class="cmtt-8"> </span><span 12523class="cmtt-8"> 15)</span><span 12524class="cmtt-8"> if</span><span 12525class="cmtt-8"> (</span><span 12526class="cmtt-8"> [err]</span><span 12527class="cmtt-8"> >=</span><span 12528class="cmtt-8"> [adx]</span><span 12529class="cmtt-8"> )</span><span 12530class="cmtt-8"> {</span> 12531<br class="fancyvrb" /><a 12532 id="x1-123052r26"></a><span 12533class="cmr-6">26</span><span 12534class="cmtt-8"> </span><span 12535class="cmtt-8"> </span> 12536<br class="fancyvrb" /><a 12537 id="x1-123054r27"></a><span 12538class="cmr-6">27</span><span 12539class="cmtt-8"> </span><span 12540class="cmtt-8"> </span><span 12541class="cmtt-8"> </span><span 12542class="cmtt-8"> </span><span 12543class="cmtt-8"> </span><span 12544class="cmtt-8"> </span><span 12545class="cmtt-8"> </span><span 12546class="cmtt-8"> </span><span 12547class="cmtt-8"> </span><span 12548class="cmtt-8"> </span><span 12549class="cmtt-8"> </span><span 12550class="cmtt-8"> </span><span 12551class="cmtt-8"> </span><span 12552class="cmtt-8"> </span><span 12553class="cmtt-8"> 16)</span><span 12554class="cmtt-8"> [err]</span><span 12555class="cmtt-8"> =</span><span 12556class="cmtt-8"> [err]</span><span 12557class="cmtt-8"> -</span><span 12558class="cmtt-8"> [adx]</span> 12559<br class="fancyvrb" /><a 12560 id="x1-123056r28"></a><span 12561class="cmr-6">28</span><span 12562class="cmtt-8"> </span><span 12563class="cmtt-8"> </span><span 12564class="cmtt-8"> </span><span 12565class="cmtt-8"> </span><span 12566class="cmtt-8"> </span><span 12567class="cmtt-8"> </span><span 12568class="cmtt-8"> </span><span 12569class="cmtt-8"> </span><span 12570class="cmtt-8"> </span><span 12571class="cmtt-8"> </span><span 12572class="cmtt-8"> </span><span 12573class="cmtt-8"> </span><span 12574class="cmtt-8"> </span><span 12575class="cmtt-8"> </span><span 12576class="cmtt-8"> 17)</span><span 12577class="cmtt-8"> </span><span 12578class="cmtt-8"> </span><span 12579class="cmtt-8"> [y]</span><span 12580class="cmtt-8"> =</span><span 12581class="cmtt-8"> [y]</span><span 12582class="cmtt-8"> +</span><span 12583class="cmtt-8"> [sy]</span> 12584<br class="fancyvrb" /><a 12585 id="x1-123058r29"></a><span 12586class="cmr-6">29</span><span 12587class="cmtt-8"> </span><span 12588class="cmtt-8"> </span> 12589<br class="fancyvrb" /><a 12590 id="x1-123060r30"></a><span 12591class="cmr-6">30</span><span 12592class="cmtt-8"> </span><span 12593class="cmtt-8"> </span><span 12594class="cmtt-8"> </span><span 12595class="cmtt-8"> </span><span 12596class="cmtt-8"> </span><span 12597class="cmtt-8"> </span><span 12598class="cmtt-8"> </span><span 12599class="cmtt-8"> </span><span 12600class="cmtt-8"> </span><span 12601class="cmtt-8"> </span><span 12602class="cmtt-8"> </span><span 12603class="cmtt-8"> </span><span 12604class="cmtt-8"> }</span><span 12605class="cmtt-8"> else</span><span 12606class="cmtt-8"> {</span> 12607<br class="fancyvrb" /><a 12608 id="x1-123062r31"></a><span 12609class="cmr-6">31</span><span 12610class="cmtt-8"> </span><span 12611class="cmtt-8"> </span> 12612<br class="fancyvrb" /><a 12613 id="x1-123064r32"></a><span 12614class="cmr-6">32</span><span 12615class="cmtt-8"> </span><span 12616class="cmtt-8"> </span><span 12617class="cmtt-8"> </span><span 12618class="cmtt-8"> </span><span 12619class="cmtt-8"> </span><span 12620class="cmtt-8"> </span><span 12621class="cmtt-8"> </span><span 12622class="cmtt-8"> </span><span 12623class="cmtt-8"> </span><span 12624class="cmtt-8"> </span><span 12625class="cmtt-8"> </span><span 12626class="cmtt-8"> </span><span 12627class="cmtt-8"> </span><span 12628class="cmtt-8"> </span><span 12629class="cmtt-8"> 18)</span><span 12630class="cmtt-8"> [y]</span><span 12631class="cmtt-8"> =</span><span 12632class="cmtt-8"> [y]</span><span 12633class="cmtt-8"> +</span><span 12634class="cmtt-8"> [base]</span> 12635<br class="fancyvrb" /><a 12636 id="x1-123066r33"></a><span 12637class="cmr-6">33</span><span 12638class="cmtt-8"> </span><span 12639class="cmtt-8"> </span> 12640<br class="fancyvrb" /><a 12641 id="x1-123068r34"></a><span 12642class="cmr-6">34</span><span 12643class="cmtt-8"> </span><span 12644class="cmtt-8"> </span><span 12645class="cmtt-8"> </span><span 12646class="cmtt-8"> </span><span 12647class="cmtt-8"> </span><span 12648class="cmtt-8"> </span><span 12649class="cmtt-8"> </span><span 12650class="cmtt-8"> </span><span 12651class="cmtt-8"> </span><span 12652class="cmtt-8"> </span><span 12653class="cmtt-8"> </span><span 12654class="cmtt-8"> </span><span 12655class="cmtt-8"> }</span> 12656<br class="fancyvrb" /><a 12657 id="x1-123070r35"></a><span 12658class="cmr-6">35</span><span 12659class="cmtt-8"> </span><span 12660class="cmtt-8"> </span> 12661<br class="fancyvrb" /><a 12662 id="x1-123072r36"></a><span 12663class="cmr-6">36</span><span 12664class="cmtt-8"> </span><span 12665class="cmtt-8"> </span><span 12666class="cmtt-8"> </span><span 12667class="cmtt-8"> </span><span 12668class="cmtt-8"> </span><span 12669class="cmtt-8"> </span><span 12670class="cmtt-8"> </span><span 12671class="cmtt-8"> </span><span 12672class="cmtt-8"> 19)</span><span 12673class="cmtt-8"> vector</span><span 12674class="cmtt-8"> [v]</span><span 12675class="cmtt-8"> element</span><span 12676class="cmtt-8"> [x]</span><span 12677class="cmtt-8"> =</span><span 12678class="cmtt-8"> [y]</span> 12679<br class="fancyvrb" /><a 12680 id="x1-123074r37"></a><span 12681class="cmr-6">37</span><span 12682class="cmtt-8"> </span><span 12683class="cmtt-8"> </span> 12684<br class="fancyvrb" /><a 12685 id="x1-123076r38"></a><span 12686class="cmr-6">38</span><span 12687class="cmtt-8"> </span><span 12688class="cmtt-8"> </span><span 12689class="cmtt-8"> </span><span 12690class="cmtt-8"> </span><span 12691class="cmtt-8"> </span><span 12692class="cmtt-8"> </span><span 12693class="cmtt-8"> }</span> 12694</div> 12695 12696 12697 12698 12699 12700 12701<h3 class="sectionHead"><span class="titlemark">10 </span> <a 12702 id="x1-12400010"></a>Tables</h3> 12703<!--l. 6--><p class="noindent" > 12704<h4 class="subsectionHead"><span class="titlemark">10.1 </span> <a 12705 id="x1-12500010.1"></a>floor1_inverse_dB_table</h4> 12706<!--l. 8--><p class="noindent" >The vector <span 12707class="cmtt-12">[floor1_inverse_dB_table] </span>is a 256 element static lookup table consiting of the 12708following values (read left to right then top to bottom): 12709<!--l. 12--><p class="noindent" > 12710<div class="fancyvrb" id="fancyvrb48"> 12711<a 12712 id="x1-125002r1"></a><span 12713class="cmr-6">1</span><span 12714class="cmtt-8"> </span><span 12715class="cmtt-8"> </span><span 12716class="cmtt-8"> </span><span 12717class="cmtt-8"> 1.0649863e-07,</span><span 12718class="cmtt-8"> 1.1341951e-07,</span><span 12719class="cmtt-8"> 1.2079015e-07,</span><span 12720class="cmtt-8"> 1.2863978e-07,</span> 12721<br class="fancyvrb" /><a 12722 id="x1-125004r2"></a><span 12723class="cmr-6">2</span><span 12724class="cmtt-8"> </span><span 12725class="cmtt-8"> </span><span 12726class="cmtt-8"> </span><span 12727class="cmtt-8"> 1.3699951e-07,</span><span 12728class="cmtt-8"> 1.4590251e-07,</span><span 12729class="cmtt-8"> 1.5538408e-07,</span><span 12730class="cmtt-8"> 1.6548181e-07,</span> 12731<br class="fancyvrb" /><a 12732 id="x1-125006r3"></a><span 12733class="cmr-6">3</span><span 12734class="cmtt-8"> </span><span 12735class="cmtt-8"> </span><span 12736class="cmtt-8"> </span><span 12737class="cmtt-8"> 1.7623575e-07,</span><span 12738class="cmtt-8"> 1.8768855e-07,</span><span 12739class="cmtt-8"> 1.9988561e-07,</span><span 12740class="cmtt-8"> 2.1287530e-07,</span> 12741<br class="fancyvrb" /><a 12742 id="x1-125008r4"></a><span 12743class="cmr-6">4</span><span 12744class="cmtt-8"> </span><span 12745class="cmtt-8"> </span><span 12746class="cmtt-8"> </span><span 12747class="cmtt-8"> 2.2670913e-07,</span><span 12748class="cmtt-8"> 2.4144197e-07,</span><span 12749class="cmtt-8"> 2.5713223e-07,</span><span 12750class="cmtt-8"> 2.7384213e-07,</span> 12751<br class="fancyvrb" /><a 12752 id="x1-125010r5"></a><span 12753class="cmr-6">5</span><span 12754class="cmtt-8"> </span><span 12755class="cmtt-8"> </span><span 12756class="cmtt-8"> </span><span 12757class="cmtt-8"> 2.9163793e-07,</span><span 12758class="cmtt-8"> 3.1059021e-07,</span><span 12759class="cmtt-8"> 3.3077411e-07,</span><span 12760class="cmtt-8"> 3.5226968e-07,</span> 12761<br class="fancyvrb" /><a 12762 id="x1-125012r6"></a><span 12763class="cmr-6">6</span><span 12764class="cmtt-8"> </span><span 12765class="cmtt-8"> </span><span 12766class="cmtt-8"> </span><span 12767class="cmtt-8"> 3.7516214e-07,</span><span 12768class="cmtt-8"> 3.9954229e-07,</span><span 12769class="cmtt-8"> 4.2550680e-07,</span><span 12770class="cmtt-8"> 4.5315863e-07,</span> 12771<br class="fancyvrb" /><a 12772 id="x1-125014r7"></a><span 12773class="cmr-6">7</span><span 12774class="cmtt-8"> </span><span 12775class="cmtt-8"> </span><span 12776class="cmtt-8"> </span><span 12777class="cmtt-8"> 4.8260743e-07,</span><span 12778class="cmtt-8"> 5.1396998e-07,</span><span 12779class="cmtt-8"> 5.4737065e-07,</span><span 12780class="cmtt-8"> 5.8294187e-07,</span> 12781<br class="fancyvrb" /><a 12782 id="x1-125016r8"></a><span 12783class="cmr-6">8</span><span 12784class="cmtt-8"> </span><span 12785class="cmtt-8"> </span><span 12786class="cmtt-8"> </span><span 12787class="cmtt-8"> 6.2082472e-07,</span><span 12788class="cmtt-8"> 6.6116941e-07,</span><span 12789class="cmtt-8"> 7.0413592e-07,</span><span 12790class="cmtt-8"> 7.4989464e-07,</span> 12791<br class="fancyvrb" /><a 12792 id="x1-125018r9"></a><span 12793class="cmr-6">9</span><span 12794class="cmtt-8"> </span><span 12795class="cmtt-8"> </span><span 12796class="cmtt-8"> </span><span 12797class="cmtt-8"> 7.9862701e-07,</span><span 12798class="cmtt-8"> 8.5052630e-07,</span><span 12799class="cmtt-8"> 9.0579828e-07,</span><span 12800class="cmtt-8"> 9.6466216e-07,</span> 12801<br class="fancyvrb" /><a 12802 id="x1-125020r10"></a><span 12803class="cmr-6">10</span><span 12804class="cmtt-8"> </span><span 12805class="cmtt-8"> </span><span 12806class="cmtt-8"> </span><span 12807class="cmtt-8"> 1.0273513e-06,</span><span 12808class="cmtt-8"> 1.0941144e-06,</span><span 12809class="cmtt-8"> 1.1652161e-06,</span><span 12810class="cmtt-8"> 1.2409384e-06,</span> 12811<br class="fancyvrb" /><a 12812 id="x1-125022r11"></a><span 12813class="cmr-6">11</span><span 12814class="cmtt-8"> </span><span 12815class="cmtt-8"> </span><span 12816class="cmtt-8"> </span><span 12817class="cmtt-8"> 1.3215816e-06,</span><span 12818class="cmtt-8"> 1.4074654e-06,</span><span 12819class="cmtt-8"> 1.4989305e-06,</span><span 12820class="cmtt-8"> 1.5963394e-06,</span> 12821<br class="fancyvrb" /><a 12822 id="x1-125024r12"></a><span 12823class="cmr-6">12</span><span 12824class="cmtt-8"> </span><span 12825class="cmtt-8"> </span><span 12826class="cmtt-8"> </span><span 12827class="cmtt-8"> 1.7000785e-06,</span><span 12828class="cmtt-8"> 1.8105592e-06,</span><span 12829class="cmtt-8"> 1.9282195e-06,</span><span 12830class="cmtt-8"> 2.0535261e-06,</span> 12831<br class="fancyvrb" /><a 12832 id="x1-125026r13"></a><span 12833class="cmr-6">13</span><span 12834class="cmtt-8"> </span><span 12835class="cmtt-8"> </span><span 12836class="cmtt-8"> </span><span 12837class="cmtt-8"> 2.1869758e-06,</span><span 12838class="cmtt-8"> 2.3290978e-06,</span><span 12839class="cmtt-8"> 2.4804557e-06,</span><span 12840class="cmtt-8"> 2.6416497e-06,</span> 12841<br class="fancyvrb" /><a 12842 id="x1-125028r14"></a><span 12843class="cmr-6">14</span><span 12844class="cmtt-8"> </span><span 12845class="cmtt-8"> </span><span 12846class="cmtt-8"> </span><span 12847class="cmtt-8"> 2.8133190e-06,</span><span 12848class="cmtt-8"> 2.9961443e-06,</span><span 12849class="cmtt-8"> 3.1908506e-06,</span><span 12850class="cmtt-8"> 3.3982101e-06,</span> 12851<br class="fancyvrb" /><a 12852 id="x1-125030r15"></a><span 12853class="cmr-6">15</span><span 12854class="cmtt-8"> </span><span 12855class="cmtt-8"> </span><span 12856class="cmtt-8"> </span><span 12857class="cmtt-8"> 3.6190449e-06,</span><span 12858class="cmtt-8"> 3.8542308e-06,</span><span 12859class="cmtt-8"> 4.1047004e-06,</span><span 12860class="cmtt-8"> 4.3714470e-06,</span> 12861<br class="fancyvrb" /><a 12862 id="x1-125032r16"></a><span 12863class="cmr-6">16</span><span 12864class="cmtt-8"> </span><span 12865class="cmtt-8"> </span><span 12866class="cmtt-8"> </span><span 12867class="cmtt-8"> 4.6555282e-06,</span><span 12868class="cmtt-8"> 4.9580707e-06,</span><span 12869class="cmtt-8"> 5.2802740e-06,</span><span 12870class="cmtt-8"> 5.6234160e-06,</span> 12871<br class="fancyvrb" /><a 12872 id="x1-125034r17"></a><span 12873class="cmr-6">17</span><span 12874class="cmtt-8"> </span><span 12875class="cmtt-8"> </span><span 12876class="cmtt-8"> </span><span 12877class="cmtt-8"> 5.9888572e-06,</span><span 12878class="cmtt-8"> 6.3780469e-06,</span><span 12879class="cmtt-8"> 6.7925283e-06,</span><span 12880class="cmtt-8"> 7.2339451e-06,</span> 12881<br class="fancyvrb" /><a 12882 id="x1-125036r18"></a><span 12883class="cmr-6">18</span><span 12884class="cmtt-8"> </span><span 12885class="cmtt-8"> </span><span 12886class="cmtt-8"> </span><span 12887class="cmtt-8"> 7.7040476e-06,</span><span 12888class="cmtt-8"> 8.2047000e-06,</span><span 12889class="cmtt-8"> 8.7378876e-06,</span><span 12890class="cmtt-8"> 9.3057248e-06,</span> 12891<br class="fancyvrb" /><a 12892 id="x1-125038r19"></a><span 12893class="cmr-6">19</span><span 12894class="cmtt-8"> </span><span 12895class="cmtt-8"> </span><span 12896class="cmtt-8"> </span><span 12897class="cmtt-8"> 9.9104632e-06,</span><span 12898class="cmtt-8"> 1.0554501e-05,</span><span 12899class="cmtt-8"> 1.1240392e-05,</span><span 12900class="cmtt-8"> 1.1970856e-05,</span> 12901<br class="fancyvrb" /><a 12902 id="x1-125040r20"></a><span 12903class="cmr-6">20</span><span 12904class="cmtt-8"> </span><span 12905class="cmtt-8"> </span><span 12906class="cmtt-8"> </span><span 12907class="cmtt-8"> 1.2748789e-05,</span><span 12908class="cmtt-8"> 1.3577278e-05,</span><span 12909class="cmtt-8"> 1.4459606e-05,</span><span 12910class="cmtt-8"> 1.5399272e-05,</span> 12911<br class="fancyvrb" /><a 12912 id="x1-125042r21"></a><span 12913class="cmr-6">21</span><span 12914class="cmtt-8"> </span><span 12915class="cmtt-8"> </span><span 12916class="cmtt-8"> </span><span 12917class="cmtt-8"> 1.6400004e-05,</span><span 12918class="cmtt-8"> 1.7465768e-05,</span><span 12919class="cmtt-8"> 1.8600792e-05,</span><span 12920class="cmtt-8"> 1.9809576e-05,</span> 12921<br class="fancyvrb" /><a 12922 id="x1-125044r22"></a><span 12923class="cmr-6">22</span><span 12924class="cmtt-8"> </span><span 12925class="cmtt-8"> </span><span 12926class="cmtt-8"> </span><span 12927class="cmtt-8"> 2.1096914e-05,</span><span 12928class="cmtt-8"> 2.2467911e-05,</span><span 12929class="cmtt-8"> 2.3928002e-05,</span><span 12930class="cmtt-8"> 2.5482978e-05,</span> 12931<br class="fancyvrb" /><a 12932 id="x1-125046r23"></a><span 12933class="cmr-6">23</span><span 12934class="cmtt-8"> </span><span 12935class="cmtt-8"> </span><span 12936class="cmtt-8"> </span><span 12937class="cmtt-8"> 2.7139006e-05,</span><span 12938class="cmtt-8"> 2.8902651e-05,</span><span 12939class="cmtt-8"> 3.0780908e-05,</span><span 12940class="cmtt-8"> 3.2781225e-05,</span> 12941<br class="fancyvrb" /><a 12942 id="x1-125048r24"></a><span 12943class="cmr-6">24</span><span 12944class="cmtt-8"> </span><span 12945class="cmtt-8"> </span><span 12946class="cmtt-8"> </span><span 12947class="cmtt-8"> 3.4911534e-05,</span><span 12948class="cmtt-8"> 3.7180282e-05,</span><span 12949class="cmtt-8"> 3.9596466e-05,</span><span 12950class="cmtt-8"> 4.2169667e-05,</span> 12951<br class="fancyvrb" /><a 12952 id="x1-125050r25"></a><span 12953class="cmr-6">25</span><span 12954class="cmtt-8"> </span><span 12955class="cmtt-8"> </span><span 12956class="cmtt-8"> </span><span 12957class="cmtt-8"> 4.4910090e-05,</span><span 12958class="cmtt-8"> 4.7828601e-05,</span><span 12959class="cmtt-8"> 5.0936773e-05,</span><span 12960class="cmtt-8"> 5.4246931e-05,</span> 12961<br class="fancyvrb" /><a 12962 id="x1-125052r26"></a><span 12963class="cmr-6">26</span><span 12964class="cmtt-8"> </span><span 12965class="cmtt-8"> </span><span 12966class="cmtt-8"> </span><span 12967class="cmtt-8"> 5.7772202e-05,</span><span 12968class="cmtt-8"> 6.1526565e-05,</span><span 12969class="cmtt-8"> 6.5524908e-05,</span><span 12970class="cmtt-8"> 6.9783085e-05,</span> 12971<br class="fancyvrb" /><a 12972 id="x1-125054r27"></a><span 12973class="cmr-6">27</span><span 12974class="cmtt-8"> </span><span 12975class="cmtt-8"> </span><span 12976class="cmtt-8"> </span><span 12977class="cmtt-8"> 7.4317983e-05,</span><span 12978class="cmtt-8"> 7.9147585e-05,</span><span 12979class="cmtt-8"> 8.4291040e-05,</span><span 12980class="cmtt-8"> 8.9768747e-05,</span> 12981<br class="fancyvrb" /><a 12982 id="x1-125056r28"></a><span 12983class="cmr-6">28</span><span 12984class="cmtt-8"> </span><span 12985class="cmtt-8"> </span><span 12986class="cmtt-8"> </span><span 12987class="cmtt-8"> 9.5602426e-05,</span><span 12988class="cmtt-8"> 0.00010181521,</span><span 12989class="cmtt-8"> 0.00010843174,</span><span 12990class="cmtt-8"> 0.00011547824,</span> 12991<br class="fancyvrb" /><a 12992 id="x1-125058r29"></a><span 12993class="cmr-6">29</span><span 12994class="cmtt-8"> </span><span 12995class="cmtt-8"> </span><span 12996class="cmtt-8"> </span><span 12997class="cmtt-8"> 0.00012298267,</span><span 12998class="cmtt-8"> 0.00013097477,</span><span 12999class="cmtt-8"> 0.00013948625,</span><span 13000class="cmtt-8"> 0.00014855085,</span> 13001<br class="fancyvrb" /><a 13002 id="x1-125060r30"></a><span 13003class="cmr-6">30</span><span 13004class="cmtt-8"> </span><span 13005class="cmtt-8"> </span><span 13006class="cmtt-8"> </span><span 13007class="cmtt-8"> 0.00015820453,</span><span 13008class="cmtt-8"> 0.00016848555,</span><span 13009class="cmtt-8"> 0.00017943469,</span><span 13010class="cmtt-8"> 0.00019109536,</span> 13011<br class="fancyvrb" /><a 13012 id="x1-125062r31"></a><span 13013class="cmr-6">31</span><span 13014class="cmtt-8"> </span><span 13015class="cmtt-8"> </span><span 13016class="cmtt-8"> </span><span 13017class="cmtt-8"> 0.00020351382,</span><span 13018class="cmtt-8"> 0.00021673929,</span><span 13019class="cmtt-8"> 0.00023082423,</span><span 13020class="cmtt-8"> 0.00024582449,</span> 13021<br class="fancyvrb" /><a 13022 id="x1-125064r32"></a><span 13023class="cmr-6">32</span><span 13024class="cmtt-8"> </span><span 13025class="cmtt-8"> </span><span 13026class="cmtt-8"> </span><span 13027class="cmtt-8"> 0.00026179955,</span><span 13028class="cmtt-8"> 0.00027881276,</span><span 13029class="cmtt-8"> 0.00029693158,</span><span 13030class="cmtt-8"> 0.00031622787,</span> 13031<br class="fancyvrb" /><a 13032 id="x1-125066r33"></a><span 13033class="cmr-6">33</span><span 13034class="cmtt-8"> </span><span 13035class="cmtt-8"> </span><span 13036class="cmtt-8"> </span><span 13037class="cmtt-8"> 0.00033677814,</span><span 13038class="cmtt-8"> 0.00035866388,</span><span 13039class="cmtt-8"> 0.00038197188,</span><span 13040class="cmtt-8"> 0.00040679456,</span> 13041<br class="fancyvrb" /><a 13042 id="x1-125068r34"></a><span 13043class="cmr-6">34</span><span 13044class="cmtt-8"> </span><span 13045class="cmtt-8"> </span><span 13046class="cmtt-8"> </span><span 13047class="cmtt-8"> 0.00043323036,</span><span 13048class="cmtt-8"> 0.00046138411,</span><span 13049class="cmtt-8"> 0.00049136745,</span><span 13050class="cmtt-8"> 0.00052329927,</span> 13051<br class="fancyvrb" /><a 13052 id="x1-125070r35"></a><span 13053class="cmr-6">35</span><span 13054class="cmtt-8"> </span><span 13055class="cmtt-8"> </span><span 13056class="cmtt-8"> </span><span 13057class="cmtt-8"> 0.00055730621,</span><span 13058class="cmtt-8"> 0.00059352311,</span><span 13059class="cmtt-8"> 0.00063209358,</span><span 13060class="cmtt-8"> 0.00067317058,</span> 13061<br class="fancyvrb" /><a 13062 id="x1-125072r36"></a><span 13063class="cmr-6">36</span><span 13064class="cmtt-8"> </span><span 13065class="cmtt-8"> </span><span 13066class="cmtt-8"> </span><span 13067class="cmtt-8"> 0.00071691700,</span><span 13068class="cmtt-8"> 0.00076350630,</span><span 13069class="cmtt-8"> 0.00081312324,</span><span 13070class="cmtt-8"> 0.00086596457,</span> 13071<br class="fancyvrb" /><a 13072 id="x1-125074r37"></a><span 13073class="cmr-6">37</span><span 13074class="cmtt-8"> </span><span 13075class="cmtt-8"> </span><span 13076class="cmtt-8"> </span><span 13077class="cmtt-8"> 0.00092223983,</span><span 13078class="cmtt-8"> 0.00098217216,</span><span 13079class="cmtt-8"> 0.0010459992,</span><span 13080class="cmtt-8"> </span><span 13081class="cmtt-8"> 0.0011139742,</span> 13082<br class="fancyvrb" /><a 13083 id="x1-125076r38"></a><span 13084class="cmr-6">38</span><span 13085class="cmtt-8"> </span><span 13086class="cmtt-8"> </span><span 13087class="cmtt-8"> </span><span 13088class="cmtt-8"> 0.0011863665,</span><span 13089class="cmtt-8"> </span><span 13090class="cmtt-8"> 0.0012634633,</span><span 13091class="cmtt-8"> </span><span 13092class="cmtt-8"> 0.0013455702,</span><span 13093class="cmtt-8"> </span><span 13094class="cmtt-8"> 0.0014330129,</span> 13095<br class="fancyvrb" /><a 13096 id="x1-125078r39"></a><span 13097class="cmr-6">39</span><span 13098class="cmtt-8"> </span><span 13099class="cmtt-8"> </span><span 13100class="cmtt-8"> </span><span 13101class="cmtt-8"> 0.0015261382,</span><span 13102class="cmtt-8"> </span><span 13103class="cmtt-8"> 0.0016253153,</span><span 13104class="cmtt-8"> </span><span 13105class="cmtt-8"> 0.0017309374,</span><span 13106class="cmtt-8"> </span><span 13107class="cmtt-8"> 0.0018434235,</span> 13108<br class="fancyvrb" /><a 13109 id="x1-125080r40"></a><span 13110class="cmr-6">40</span><span 13111class="cmtt-8"> </span><span 13112class="cmtt-8"> </span><span 13113class="cmtt-8"> </span><span 13114class="cmtt-8"> 0.0019632195,</span><span 13115class="cmtt-8"> </span><span 13116class="cmtt-8"> 0.0020908006,</span><span 13117class="cmtt-8"> </span><span 13118class="cmtt-8"> 0.0022266726,</span><span 13119class="cmtt-8"> </span><span 13120class="cmtt-8"> 0.0023713743,</span> 13121<br class="fancyvrb" /><a 13122 id="x1-125082r41"></a><span 13123class="cmr-6">41</span><span 13124class="cmtt-8"> </span><span 13125class="cmtt-8"> </span><span 13126class="cmtt-8"> </span><span 13127class="cmtt-8"> 0.0025254795,</span><span 13128class="cmtt-8"> </span><span 13129class="cmtt-8"> 0.0026895994,</span><span 13130class="cmtt-8"> </span><span 13131class="cmtt-8"> 0.0028643847,</span><span 13132class="cmtt-8"> </span><span 13133class="cmtt-8"> 0.0030505286,</span> 13134<br class="fancyvrb" /><a 13135 id="x1-125084r42"></a><span 13136class="cmr-6">42</span><span 13137class="cmtt-8"> </span><span 13138class="cmtt-8"> </span><span 13139class="cmtt-8"> </span><span 13140class="cmtt-8"> 0.0032487691,</span><span 13141class="cmtt-8"> </span><span 13142class="cmtt-8"> 0.0034598925,</span><span 13143class="cmtt-8"> </span><span 13144class="cmtt-8"> 0.0036847358,</span><span 13145class="cmtt-8"> </span><span 13146class="cmtt-8"> 0.0039241906,</span> 13147 13148 13149 13150<br class="fancyvrb" /><a 13151 id="x1-125086r43"></a><span 13152class="cmr-6">43</span><span 13153class="cmtt-8"> </span><span 13154class="cmtt-8"> </span><span 13155class="cmtt-8"> </span><span 13156class="cmtt-8"> 0.0041792066,</span><span 13157class="cmtt-8"> </span><span 13158class="cmtt-8"> 0.0044507950,</span><span 13159class="cmtt-8"> </span><span 13160class="cmtt-8"> 0.0047400328,</span><span 13161class="cmtt-8"> </span><span 13162class="cmtt-8"> 0.0050480668,</span> 13163<br class="fancyvrb" /><a 13164 id="x1-125088r44"></a><span 13165class="cmr-6">44</span><span 13166class="cmtt-8"> </span><span 13167class="cmtt-8"> </span><span 13168class="cmtt-8"> </span><span 13169class="cmtt-8"> 0.0053761186,</span><span 13170class="cmtt-8"> </span><span 13171class="cmtt-8"> 0.0057254891,</span><span 13172class="cmtt-8"> </span><span 13173class="cmtt-8"> 0.0060975636,</span><span 13174class="cmtt-8"> </span><span 13175class="cmtt-8"> 0.0064938176,</span> 13176<br class="fancyvrb" /><a 13177 id="x1-125090r45"></a><span 13178class="cmr-6">45</span><span 13179class="cmtt-8"> </span><span 13180class="cmtt-8"> </span><span 13181class="cmtt-8"> </span><span 13182class="cmtt-8"> 0.0069158225,</span><span 13183class="cmtt-8"> </span><span 13184class="cmtt-8"> 0.0073652516,</span><span 13185class="cmtt-8"> </span><span 13186class="cmtt-8"> 0.0078438871,</span><span 13187class="cmtt-8"> </span><span 13188class="cmtt-8"> 0.0083536271,</span> 13189<br class="fancyvrb" /><a 13190 id="x1-125092r46"></a><span 13191class="cmr-6">46</span><span 13192class="cmtt-8"> </span><span 13193class="cmtt-8"> </span><span 13194class="cmtt-8"> </span><span 13195class="cmtt-8"> 0.0088964928,</span><span 13196class="cmtt-8"> </span><span 13197class="cmtt-8"> 0.009474637,</span><span 13198class="cmtt-8"> </span><span 13199class="cmtt-8"> </span><span 13200class="cmtt-8"> 0.010090352,</span><span 13201class="cmtt-8"> </span><span 13202class="cmtt-8"> </span><span 13203class="cmtt-8"> 0.010746080,</span> 13204<br class="fancyvrb" /><a 13205 id="x1-125094r47"></a><span 13206class="cmr-6">47</span><span 13207class="cmtt-8"> </span><span 13208class="cmtt-8"> </span><span 13209class="cmtt-8"> </span><span 13210class="cmtt-8"> 0.011444421,</span><span 13211class="cmtt-8"> </span><span 13212class="cmtt-8"> </span><span 13213class="cmtt-8"> 0.012188144,</span><span 13214class="cmtt-8"> </span><span 13215class="cmtt-8"> </span><span 13216class="cmtt-8"> 0.012980198,</span><span 13217class="cmtt-8"> </span><span 13218class="cmtt-8"> </span><span 13219class="cmtt-8"> 0.013823725,</span> 13220<br class="fancyvrb" /><a 13221 id="x1-125096r48"></a><span 13222class="cmr-6">48</span><span 13223class="cmtt-8"> </span><span 13224class="cmtt-8"> </span><span 13225class="cmtt-8"> </span><span 13226class="cmtt-8"> 0.014722068,</span><span 13227class="cmtt-8"> </span><span 13228class="cmtt-8"> </span><span 13229class="cmtt-8"> 0.015678791,</span><span 13230class="cmtt-8"> </span><span 13231class="cmtt-8"> </span><span 13232class="cmtt-8"> 0.016697687,</span><span 13233class="cmtt-8"> </span><span 13234class="cmtt-8"> </span><span 13235class="cmtt-8"> 0.017782797,</span> 13236<br class="fancyvrb" /><a 13237 id="x1-125098r49"></a><span 13238class="cmr-6">49</span><span 13239class="cmtt-8"> </span><span 13240class="cmtt-8"> </span><span 13241class="cmtt-8"> </span><span 13242class="cmtt-8"> 0.018938423,</span><span 13243class="cmtt-8"> </span><span 13244class="cmtt-8"> </span><span 13245class="cmtt-8"> 0.020169149,</span><span 13246class="cmtt-8"> </span><span 13247class="cmtt-8"> </span><span 13248class="cmtt-8"> 0.021479854,</span><span 13249class="cmtt-8"> </span><span 13250class="cmtt-8"> </span><span 13251class="cmtt-8"> 0.022875735,</span> 13252<br class="fancyvrb" /><a 13253 id="x1-125100r50"></a><span 13254class="cmr-6">50</span><span 13255class="cmtt-8"> </span><span 13256class="cmtt-8"> </span><span 13257class="cmtt-8"> </span><span 13258class="cmtt-8"> 0.024362330,</span><span 13259class="cmtt-8"> </span><span 13260class="cmtt-8"> </span><span 13261class="cmtt-8"> 0.025945531,</span><span 13262class="cmtt-8"> </span><span 13263class="cmtt-8"> </span><span 13264class="cmtt-8"> 0.027631618,</span><span 13265class="cmtt-8"> </span><span 13266class="cmtt-8"> </span><span 13267class="cmtt-8"> 0.029427276,</span> 13268<br class="fancyvrb" /><a 13269 id="x1-125102r51"></a><span 13270class="cmr-6">51</span><span 13271class="cmtt-8"> </span><span 13272class="cmtt-8"> </span><span 13273class="cmtt-8"> </span><span 13274class="cmtt-8"> 0.031339626,</span><span 13275class="cmtt-8"> </span><span 13276class="cmtt-8"> </span><span 13277class="cmtt-8"> 0.033376252,</span><span 13278class="cmtt-8"> </span><span 13279class="cmtt-8"> </span><span 13280class="cmtt-8"> 0.035545228,</span><span 13281class="cmtt-8"> </span><span 13282class="cmtt-8"> </span><span 13283class="cmtt-8"> 0.037855157,</span> 13284<br class="fancyvrb" /><a 13285 id="x1-125104r52"></a><span 13286class="cmr-6">52</span><span 13287class="cmtt-8"> </span><span 13288class="cmtt-8"> </span><span 13289class="cmtt-8"> </span><span 13290class="cmtt-8"> 0.040315199,</span><span 13291class="cmtt-8"> </span><span 13292class="cmtt-8"> </span><span 13293class="cmtt-8"> 0.042935108,</span><span 13294class="cmtt-8"> </span><span 13295class="cmtt-8"> </span><span 13296class="cmtt-8"> 0.045725273,</span><span 13297class="cmtt-8"> </span><span 13298class="cmtt-8"> </span><span 13299class="cmtt-8"> 0.048696758,</span> 13300<br class="fancyvrb" /><a 13301 id="x1-125106r53"></a><span 13302class="cmr-6">53</span><span 13303class="cmtt-8"> </span><span 13304class="cmtt-8"> </span><span 13305class="cmtt-8"> </span><span 13306class="cmtt-8"> 0.051861348,</span><span 13307class="cmtt-8"> </span><span 13308class="cmtt-8"> </span><span 13309class="cmtt-8"> 0.055231591,</span><span 13310class="cmtt-8"> </span><span 13311class="cmtt-8"> </span><span 13312class="cmtt-8"> 0.058820850,</span><span 13313class="cmtt-8"> </span><span 13314class="cmtt-8"> </span><span 13315class="cmtt-8"> 0.062643361,</span> 13316<br class="fancyvrb" /><a 13317 id="x1-125108r54"></a><span 13318class="cmr-6">54</span><span 13319class="cmtt-8"> </span><span 13320class="cmtt-8"> </span><span 13321class="cmtt-8"> </span><span 13322class="cmtt-8"> 0.066714279,</span><span 13323class="cmtt-8"> </span><span 13324class="cmtt-8"> </span><span 13325class="cmtt-8"> 0.071049749,</span><span 13326class="cmtt-8"> </span><span 13327class="cmtt-8"> </span><span 13328class="cmtt-8"> 0.075666962,</span><span 13329class="cmtt-8"> </span><span 13330class="cmtt-8"> </span><span 13331class="cmtt-8"> 0.080584227,</span> 13332<br class="fancyvrb" /><a 13333 id="x1-125110r55"></a><span 13334class="cmr-6">55</span><span 13335class="cmtt-8"> </span><span 13336class="cmtt-8"> </span><span 13337class="cmtt-8"> </span><span 13338class="cmtt-8"> 0.085821044,</span><span 13339class="cmtt-8"> </span><span 13340class="cmtt-8"> </span><span 13341class="cmtt-8"> 0.091398179,</span><span 13342class="cmtt-8"> </span><span 13343class="cmtt-8"> </span><span 13344class="cmtt-8"> 0.097337747,</span><span 13345class="cmtt-8"> </span><span 13346class="cmtt-8"> </span><span 13347class="cmtt-8"> 0.10366330,</span> 13348<br class="fancyvrb" /><a 13349 id="x1-125112r56"></a><span 13350class="cmr-6">56</span><span 13351class="cmtt-8"> </span><span 13352class="cmtt-8"> </span><span 13353class="cmtt-8"> </span><span 13354class="cmtt-8"> 0.11039993,</span><span 13355class="cmtt-8"> </span><span 13356class="cmtt-8"> </span><span 13357class="cmtt-8"> </span><span 13358class="cmtt-8"> 0.11757434,</span><span 13359class="cmtt-8"> </span><span 13360class="cmtt-8"> </span><span 13361class="cmtt-8"> </span><span 13362class="cmtt-8"> 0.12521498,</span><span 13363class="cmtt-8"> </span><span 13364class="cmtt-8"> </span><span 13365class="cmtt-8"> </span><span 13366class="cmtt-8"> 0.13335215,</span> 13367<br class="fancyvrb" /><a 13368 id="x1-125114r57"></a><span 13369class="cmr-6">57</span><span 13370class="cmtt-8"> </span><span 13371class="cmtt-8"> </span><span 13372class="cmtt-8"> </span><span 13373class="cmtt-8"> 0.14201813,</span><span 13374class="cmtt-8"> </span><span 13375class="cmtt-8"> </span><span 13376class="cmtt-8"> </span><span 13377class="cmtt-8"> 0.15124727,</span><span 13378class="cmtt-8"> </span><span 13379class="cmtt-8"> </span><span 13380class="cmtt-8"> </span><span 13381class="cmtt-8"> 0.16107617,</span><span 13382class="cmtt-8"> </span><span 13383class="cmtt-8"> </span><span 13384class="cmtt-8"> </span><span 13385class="cmtt-8"> 0.17154380,</span> 13386<br class="fancyvrb" /><a 13387 id="x1-125116r58"></a><span 13388class="cmr-6">58</span><span 13389class="cmtt-8"> </span><span 13390class="cmtt-8"> </span><span 13391class="cmtt-8"> </span><span 13392class="cmtt-8"> 0.18269168,</span><span 13393class="cmtt-8"> </span><span 13394class="cmtt-8"> </span><span 13395class="cmtt-8"> </span><span 13396class="cmtt-8"> 0.19456402,</span><span 13397class="cmtt-8"> </span><span 13398class="cmtt-8"> </span><span 13399class="cmtt-8"> </span><span 13400class="cmtt-8"> 0.20720788,</span><span 13401class="cmtt-8"> </span><span 13402class="cmtt-8"> </span><span 13403class="cmtt-8"> </span><span 13404class="cmtt-8"> 0.22067342,</span> 13405<br class="fancyvrb" /><a 13406 id="x1-125118r59"></a><span 13407class="cmr-6">59</span><span 13408class="cmtt-8"> </span><span 13409class="cmtt-8"> </span><span 13410class="cmtt-8"> </span><span 13411class="cmtt-8"> 0.23501402,</span><span 13412class="cmtt-8"> </span><span 13413class="cmtt-8"> </span><span 13414class="cmtt-8"> </span><span 13415class="cmtt-8"> 0.25028656,</span><span 13416class="cmtt-8"> </span><span 13417class="cmtt-8"> </span><span 13418class="cmtt-8"> </span><span 13419class="cmtt-8"> 0.26655159,</span><span 13420class="cmtt-8"> </span><span 13421class="cmtt-8"> </span><span 13422class="cmtt-8"> </span><span 13423class="cmtt-8"> 0.28387361,</span> 13424<br class="fancyvrb" /><a 13425 id="x1-125120r60"></a><span 13426class="cmr-6">60</span><span 13427class="cmtt-8"> </span><span 13428class="cmtt-8"> </span><span 13429class="cmtt-8"> </span><span 13430class="cmtt-8"> 0.30232132,</span><span 13431class="cmtt-8"> </span><span 13432class="cmtt-8"> </span><span 13433class="cmtt-8"> </span><span 13434class="cmtt-8"> 0.32196786,</span><span 13435class="cmtt-8"> </span><span 13436class="cmtt-8"> </span><span 13437class="cmtt-8"> </span><span 13438class="cmtt-8"> 0.34289114,</span><span 13439class="cmtt-8"> </span><span 13440class="cmtt-8"> </span><span 13441class="cmtt-8"> </span><span 13442class="cmtt-8"> 0.36517414,</span> 13443<br class="fancyvrb" /><a 13444 id="x1-125122r61"></a><span 13445class="cmr-6">61</span><span 13446class="cmtt-8"> </span><span 13447class="cmtt-8"> </span><span 13448class="cmtt-8"> </span><span 13449class="cmtt-8"> 0.38890521,</span><span 13450class="cmtt-8"> </span><span 13451class="cmtt-8"> </span><span 13452class="cmtt-8"> </span><span 13453class="cmtt-8"> 0.41417847,</span><span 13454class="cmtt-8"> </span><span 13455class="cmtt-8"> </span><span 13456class="cmtt-8"> </span><span 13457class="cmtt-8"> 0.44109412,</span><span 13458class="cmtt-8"> </span><span 13459class="cmtt-8"> </span><span 13460class="cmtt-8"> </span><span 13461class="cmtt-8"> 0.46975890,</span> 13462<br class="fancyvrb" /><a 13463 id="x1-125124r62"></a><span 13464class="cmr-6">62</span><span 13465class="cmtt-8"> </span><span 13466class="cmtt-8"> </span><span 13467class="cmtt-8"> </span><span 13468class="cmtt-8"> 0.50028648,</span><span 13469class="cmtt-8"> </span><span 13470class="cmtt-8"> </span><span 13471class="cmtt-8"> </span><span 13472class="cmtt-8"> 0.53279791,</span><span 13473class="cmtt-8"> </span><span 13474class="cmtt-8"> </span><span 13475class="cmtt-8"> </span><span 13476class="cmtt-8"> 0.56742212,</span><span 13477class="cmtt-8"> </span><span 13478class="cmtt-8"> </span><span 13479class="cmtt-8"> </span><span 13480class="cmtt-8"> 0.60429640,</span> 13481<br class="fancyvrb" /><a 13482 id="x1-125126r63"></a><span 13483class="cmr-6">63</span><span 13484class="cmtt-8"> </span><span 13485class="cmtt-8"> </span><span 13486class="cmtt-8"> </span><span 13487class="cmtt-8"> 0.64356699,</span><span 13488class="cmtt-8"> </span><span 13489class="cmtt-8"> </span><span 13490class="cmtt-8"> </span><span 13491class="cmtt-8"> 0.68538959,</span><span 13492class="cmtt-8"> </span><span 13493class="cmtt-8"> </span><span 13494class="cmtt-8"> </span><span 13495class="cmtt-8"> 0.72993007,</span><span 13496class="cmtt-8"> </span><span 13497class="cmtt-8"> </span><span 13498class="cmtt-8"> </span><span 13499class="cmtt-8"> 0.77736504,</span> 13500<br class="fancyvrb" /><a 13501 id="x1-125128r64"></a><span 13502class="cmr-6">64</span><span 13503class="cmtt-8"> </span><span 13504class="cmtt-8"> </span><span 13505class="cmtt-8"> </span><span 13506class="cmtt-8"> 0.82788260,</span><span 13507class="cmtt-8"> </span><span 13508class="cmtt-8"> </span><span 13509class="cmtt-8"> </span><span 13510class="cmtt-8"> 0.88168307,</span><span 13511class="cmtt-8"> </span><span 13512class="cmtt-8"> </span><span 13513class="cmtt-8"> </span><span 13514class="cmtt-8"> 0.9389798,</span><span 13515class="cmtt-8"> </span><span 13516class="cmtt-8"> </span><span 13517class="cmtt-8"> </span><span 13518class="cmtt-8"> </span><span 13519class="cmtt-8"> 1.</span> 13520</div> 13521 13522 13523 13524 13525 13526 13527<h3 class="sectionHead"><span class="titlemark">A </span> <a 13528 id="x1-126000A"></a>Embedding Vorbis into an Ogg stream</h3> 13529<!--l. 6--><p class="noindent" > 13530<h4 class="subsectionHead"><span class="titlemark">A.1 </span> <a 13531 id="x1-127000A.1"></a>Overview</h4> 13532<!--l. 8--><p class="noindent" >This document describes using Ogg logical and physical transport streams to encapsulate Vorbis 13533compressed audio packet data into file form. 13534<!--l. 12--><p class="noindent" >The <a 13535href="#x1-20001">Section 1</a>, “<a 13536href="#x1-20001">Introduction and Description<!--tex4ht:ref: vorbis:spec:intro --></a>” provides an overview of the construction of 13537Vorbis audio packets. 13538<!--l. 15--><p class="noindent" >The <a 13539href="oggstream.html" >Ogg bitstream overview</a> and <a 13540href="framing.html" >Ogg logical bitstream and framing spec</a> provide detailed 13541descriptions of Ogg transport streams. This specification document assumes a working 13542knowledge of the concepts covered in these named backround documents. Please read them 13543first. 13544<!--l. 22--><p class="noindent" > 13545<h5 class="subsubsectionHead"><span class="titlemark">A.1.1 </span> <a 13546 id="x1-128000A.1.1"></a>Restrictions</h5> 13547<!--l. 24--><p class="noindent" >The Ogg/Vorbis I specification currently dictates that Ogg/Vorbis streams use Ogg transport 13548streams in degenerate, unmultiplexed form only. That is: 13549 <ul class="itemize1"> 13550 <li class="itemize">A meta-headerless Ogg file encapsulates the Vorbis I packets 13551 </li> 13552 <li class="itemize">The Ogg stream may be chained, i.e., contain multiple, contigous logical streams 13553 (links). 13554 </li> 13555 <li class="itemize">The Ogg stream must be unmultiplexed (only one stream, a Vorbis audio stream, 13556 per link) 13557 </li></ul> 13558 13559 13560 13561<!--l. 41--><p class="noindent" >This is not to say that it is not currently possible to multiplex Vorbis with other media 13562types into a multi-stream Ogg file. At the time this document was written, Ogg was 13563becoming a popular container for low-bitrate movies consisting of DivX video and Vorbis 13564audio. However, a ’Vorbis I audio file’ is taken to imply Vorbis audio existing alone 13565within a degenerate Ogg stream. A compliant ’Vorbis audio player’ is not required to 13566implement Ogg support beyond the specific support of Vorbis within a degenrate Ogg 13567stream (naturally, application authors are encouraged to support full multiplexed Ogg 13568handling). 13569<!--l. 55--><p class="noindent" > 13570<h5 class="subsubsectionHead"><span class="titlemark">A.1.2 </span> <a 13571 id="x1-129000A.1.2"></a>MIME type</h5> 13572<!--l. 57--><p class="noindent" >The MIME type of Ogg files depend on the context. Specifically, complex multimedia and 13573applications should use <span 13574class="cmtt-12">application/ogg</span>, while visual media should use <span 13575class="cmtt-12">video/ogg</span>, and audio 13576<span 13577class="cmtt-12">audio/ogg</span>. Vorbis data encapsulated in Ogg may appear in any of those types. RTP 13578encapsulated Vorbis should use <span 13579class="cmtt-12">audio/vorbis </span>+ <span 13580class="cmtt-12">audio/vorbis-config</span>. 13581<!--l. 65--><p class="noindent" > 13582<h4 class="subsectionHead"><span class="titlemark">A.2 </span> <a 13583 id="x1-130000A.2"></a>Encapsulation</h4> 13584<!--l. 67--><p class="noindent" >Ogg encapsulation of a Vorbis packet stream is straightforward. 13585 <ul class="itemize1"> 13586 <li class="itemize">The first Vorbis packet (the identification header), which uniquely identifies a stream 13587 as Vorbis audio, is placed alone in the first page of the logical Ogg stream. This 13588 results in a first Ogg page of exactly 58 bytes at the very beginning of the logical 13589 stream. 13590 </li> 13591 <li class="itemize">This first page is marked ’beginning of stream’ in the page flags. 13592 </li> 13593 <li class="itemize">The second and third vorbis packets (comment and setup headers) may span one or 13594 more pages beginning on the second page of the logical stream. However many pages 13595 they span, the third header packet finishes the page on which it ends. The next (first 13596 audio) packet must begin on a fresh page. 13597 13598 13599 13600 </li> 13601 <li class="itemize">The granule position of these first pages containing only headers is zero. 13602 </li> 13603 <li class="itemize">The first audio packet of the logical stream begins a fresh Ogg page. 13604 </li> 13605 <li class="itemize">Packets are placed into ogg pages in order until the end of stream. 13606 </li> 13607 <li class="itemize">The last page is marked ’end of stream’ in the page flags. 13608 </li> 13609 <li class="itemize">Vorbis packets may span page boundaries. 13610 </li> 13611 <li class="itemize">The granule position of pages containing Vorbis audio is in units of PCM audio 13612 samples (per channel; a stereo stream’s granule position does not increment at twice 13613 the speed of a mono stream). 13614 </li> 13615 <li class="itemize">The granule position of a page represents the end PCM sample position of the last 13616 packet <span 13617class="cmti-12">completed </span>on that page. The ’last PCM sample’ is the last complete sample 13618 returned by decode, not an internal sample awaiting lapping with a subsequent block. 13619 A page that is entirely spanned by a single packet (that completes on a subsequent 13620 page) has no granule position, and the granule position is set to ’-1’. 13621 <!--l. 126--><p class="noindent" >Note that the last decoded (fully lapped) PCM sample from a packet is not 13622 necessarily the middle sample from that block. If, eg, the current Vorbis packet 13623 encodes a ”long block” and the next Vorbis packet encodes a ”short block”, the last 13624 decodable sample from the current packet be at position (3*long_block_length/4) - 13625 (short_block_length/4). 13626 </li> 13627 <li class="itemize">The granule (PCM) position of the first page need not indicate that the stream 13628 started at position zero. Although the granule position belongs to the last completed 13629 packet on the page and a valid granule position must be positive, by inference it may 13630 indicate that the PCM position of the beginning of audio is positive or negative. 13631 <ul class="itemize2"> 13632 <li class="itemize">A positive starting value simply indicates that this stream begins at some 13633 positive time offset, potentially within a larger program. This is a common case 13634 when connecting to the middle of broadcast stream. 13635 </li> 13636 <li class="itemize">A negative value indicates that output samples preceeding time zero should be 13637 13638 13639 13640 discarded during decoding; this technique is used to allow sample-granularity 13641 editing of the stream start time of already-encoded Vorbis streams. The number 13642 of samples to be discarded must not exceed the overlap-add span of the first two 13643 audio packets. 13644 </li></ul> 13645 <!--l. 161--><p class="noindent" >In both of these cases in which the initial audio PCM starting offset is nonzero, the 13646 second finished audio packet must flush the page on which it appears and the 13647 third packet begin a fresh page. This allows the decoder to always be able to 13648 perform PCM position adjustments before needing to return any PCM data from 13649 synthesis, resulting in correct positioning information without any aditional seeking 13650 logic. 13651 <!--l. 170--><p class="noindent" ><span class="likesubparagraphHead"><a 13652 id="x1-131000A.2"></a><span 13653class="cmbx-12">Note:</span></span> Failure to do so should, at worst, cause a decoder implementation to return 13654 incorrect positioning information for seeking operations at the very beginning of the 13655 stream. 13656 </li> 13657 <li class="itemize">A granule position on the final page in a stream that indicates less audio data than the 13658 final packet would normally return is used to end the stream on other than even frame 13659 boundaries. The difference between the actual available data returned and the 13660 declared amount indicates how many trailing samples to discard from the decoding 13661 process. 13662 </li></ul> 13663 13664 13665 13666<h3 class="sectionHead"><span class="titlemark">B </span> <a 13667 id="x1-132000B"></a>Vorbis encapsulation in RTP</h3> 13668<!--l. 8--><p class="noindent" >Please consult RFC 5215 <span 13669class="cmti-12">“RTP Payload Format for Vorbis Encoded Audio” </span>for description of 13670how to embed Vorbis audio in an RTP stream. 13671 13672 13673 13674 13675 13676 13677<h3 class="likesectionHead"><a 13678 id="x1-133000B"></a>Colophon</h3> 13679<!--l. 6--><p class="noindent" ><img 13680src="Vorbis_I_spec13x.png" alt="PIC" class="graphics"><!--tex4ht:graphics 13681name="Vorbis_I_spec13x.png" src="xifish.pdf" 13682--> 13683<!--l. 10--><p class="noindent" >Ogg is a <a 13684href="http://www.xiph.org/" >Xiph.org Foundation</a> effort to protect essential tenets of Internet multimedia from 13685corporate hostage-taking; Open Source is the net’s greatest tool to keep everyone honest. See 13686<a 13687href="http://www.xiph.org/about.html" >About the Xiph.org Foundation</a> for details. 13688<!--l. 17--><p class="noindent" >Ogg Vorbis is the first Ogg audio CODEC. Anyone may freely use and distribute the Ogg and 13689Vorbis specification, whether in a private, public or corporate capacity. However, the Xiph.org 13690Foundation and the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis specification 13691and certify specification compliance. 13692<!--l. 23--><p class="noindent" >Xiph.org’s Vorbis software CODEC implementation is distributed under a BSD-like license. This 13693does not restrict third parties from distributing independent implementations of Vorbis software 13694under other licenses. 13695<!--l. 28--><p class="noindent" >Ogg, Vorbis, Xiph.org Foundation and their logos are trademarks (tm) of the <a 13696href="http://www.xiph.org/" >Xiph.org 13697Foundation</a>. These pages are copyright (C) 1994-2007 Xiph.org Foundation. All rights 13698reserved. 13699<!--l. 33--><p class="noindent" >This document is set using <span class="LATEX">L<span class="A">A</span><span class="TEX">T<span 13700class="E">E</span>X</span></span>. 13701 13702 13703 13704<h3 class="likesectionHead"><a 13705 id="x1-134000B"></a>References</h3> 13706<!--l. 123--><p class="noindent" > 13707 <div class="thebibliography"> 13708 <p class="bibitem" ><span class="biblabel"> 13709 [1]<span class="bibsp">   </span></span><a 13710 id="XSporer/Brandenburg/Edler"></a>T. Sporer, K. Brandenburg and 13711 B. Edler, The use of multirate filter banks for coding of high quality digital audio, 13712 <a 13713href="http://www.iocon.com/resource/docs/ps/eusipco_corrected.ps" class="url" ><span 13714class="cmtt-12">http://www.iocon.com/resource/docs/ps/eusipco_corrected.ps</span></a>. 13715</p> 13716 </div> 13717 13718</body></html> 13719 13720 13721 13722 13723