annotate src/libvorbis-1.3.3/doc/helper.html @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 05aa0afa9217
children
rev   line source
Chris@1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Chris@1 2 <html>
Chris@1 3 <head>
Chris@1 4
Chris@1 5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>
Chris@1 6 <title>Ogg Vorbis Documentation</title>
Chris@1 7
Chris@1 8 <style type="text/css">
Chris@1 9 body {
Chris@1 10 margin: 0 18px 0 18px;
Chris@1 11 padding-bottom: 30px;
Chris@1 12 font-family: Verdana, Arial, Helvetica, sans-serif;
Chris@1 13 color: #333333;
Chris@1 14 font-size: .8em;
Chris@1 15 }
Chris@1 16
Chris@1 17 a {
Chris@1 18 color: #3366cc;
Chris@1 19 }
Chris@1 20
Chris@1 21 img {
Chris@1 22 border: 0;
Chris@1 23 }
Chris@1 24
Chris@1 25 #xiphlogo {
Chris@1 26 margin: 30px 0 16px 0;
Chris@1 27 }
Chris@1 28
Chris@1 29 #content p {
Chris@1 30 line-height: 1.4;
Chris@1 31 }
Chris@1 32
Chris@1 33 h1, h1 a, h2, h2 a, h3, h3 a {
Chris@1 34 font-weight: bold;
Chris@1 35 color: #ff9900;
Chris@1 36 margin: 1.3em 0 8px 0;
Chris@1 37 }
Chris@1 38
Chris@1 39 h1 {
Chris@1 40 font-size: 1.3em;
Chris@1 41 }
Chris@1 42
Chris@1 43 h2 {
Chris@1 44 font-size: 1.2em;
Chris@1 45 }
Chris@1 46
Chris@1 47 h3 {
Chris@1 48 font-size: 1.1em;
Chris@1 49 }
Chris@1 50
Chris@1 51 li {
Chris@1 52 line-height: 1.4;
Chris@1 53 }
Chris@1 54
Chris@1 55 #copyright {
Chris@1 56 margin-top: 30px;
Chris@1 57 line-height: 1.5em;
Chris@1 58 text-align: center;
Chris@1 59 font-size: .8em;
Chris@1 60 color: #888888;
Chris@1 61 clear: both;
Chris@1 62 }
Chris@1 63 </style>
Chris@1 64
Chris@1 65 </head>
Chris@1 66
Chris@1 67 <body>
Chris@1 68
Chris@1 69 <div id="xiphlogo">
Chris@1 70 <a href="http://www.xiph.org/"><img src="fish_xiph_org.png" alt="Fish Logo and Xiph.Org"/></a>
Chris@1 71 </div>
Chris@1 72
Chris@1 73 <h1>Ogg Vorbis I format specification: helper equations</h1>
Chris@1 74
Chris@1 75 <h1>Overview</h1>
Chris@1 76
Chris@1 77 <p>The equations below are used in multiple places by the Vorbis codec
Chris@1 78 specification. Rather than cluttering up the main specification
Chris@1 79 documents, they are defined here and linked in the main documents
Chris@1 80 where appropriate.</p>
Chris@1 81
Chris@1 82 <h2><a name="log">ilog</a></h2>
Chris@1 83
Chris@1 84 <p>The "ilog(x)" function returns the position number (1 through n) of the
Chris@1 85 highest set bit in the two's complement integer value
Chris@1 86 <tt>[x]</tt>. Values of <tt>[x]</tt> less than zero are defined to return zero.</p>
Chris@1 87
Chris@1 88 <pre>
Chris@1 89 1) [return_value] = 0;
Chris@1 90 2) if ( [x] is greater than zero ){
Chris@1 91
Chris@1 92 3) increment [return_value];
Chris@1 93 4) logical shift [x] one bit to the right, padding the MSb with zero
Chris@1 94 5) repeat at step 2)
Chris@1 95
Chris@1 96 }
Chris@1 97
Chris@1 98 6) done
Chris@1 99 </pre>
Chris@1 100
Chris@1 101 <p>Examples:</p>
Chris@1 102
Chris@1 103 <ul>
Chris@1 104 <li>ilog(0) = 0;</li>
Chris@1 105 <li>ilog(1) = 1;</li>
Chris@1 106 <li>ilog(2) = 2;</li>
Chris@1 107 <li>ilog(3) = 2;</li>
Chris@1 108 <li>ilog(4) = 3;</li>
Chris@1 109 <li>ilog(7) = 3;</li>
Chris@1 110 <li>ilog(negative number) = 0;</li>
Chris@1 111 </ul>
Chris@1 112
Chris@1 113 <h2><a name="float32_unpack">float32_unpack</a></h2>
Chris@1 114
Chris@1 115 <p>"float32_unpack(x)" is intended to translate the packed binary
Chris@1 116 representation of a Vorbis codebook float value into the
Chris@1 117 representation used by the decoder for floating point numbers. For
Chris@1 118 purposes of this example, we will unpack a Vorbis float32 into a
Chris@1 119 host-native floating point number.</p>
Chris@1 120
Chris@1 121 <pre>
Chris@1 122 1) [mantissa] = [x] bitwise AND 0x1fffff (unsigned result)
Chris@1 123 2) [sign] = [x] bitwise AND 0x80000000 (unsigned result)
Chris@1 124 3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted right 21 bits (unsigned result)
Chris@1 125 4) if ( [sign] is nonzero ) then negate [mantissa]
Chris@1 126 5) return [mantissa] * ( 2 ^ ( [exponent] - 788 ) )
Chris@1 127 </pre>
Chris@1 128
Chris@1 129 <h2><a name="lookup1_values">lookup1_values</a></h2>
Chris@1 130
Chris@1 131 <p>"lookup1_values(codebook_entries,codebook_dimensions)" is used to
Chris@1 132 compute the correct length of the value index for a codebook VQ lookup
Chris@1 133 table of lookup type 1. The values on this list are permuted to
Chris@1 134 construct the VQ vector lookup table of size
Chris@1 135 <tt>[codebook_entries]</tt>.</p>
Chris@1 136
Chris@1 137 <p>The return value for this function is defined to be 'the greatest
Chris@1 138 integer value for which <tt>[return_value] to the power of
Chris@1 139 [codebook_dimensions] is less than or equal to
Chris@1 140 [codebook_entries]</tt>'.</p>
Chris@1 141
Chris@1 142 <h2><a name="low_neighbor">low_neighbor</a></h2>
Chris@1 143
Chris@1 144 <p>"low_neighbor(v,x)" finds the position <i>n</i> in vector [v] of
Chris@1 145 the greatest value scalar element for which <i>n</i> is less than
Chris@1 146 <tt>[x]</tt> and <tt>vector [v] element <i>n</i> is less
Chris@1 147 than vector [v] element [x]</tt>.</p>
Chris@1 148
Chris@1 149 <h2><a name="high_neighbor">high_neighbor</a></h2>
Chris@1 150
Chris@1 151 <p>"high_neighbor(v,x)" finds the position <i>n</i> in vector [v] of
Chris@1 152 the lowest value scalar element for which <i>n</i> is less than
Chris@1 153 <tt>[x]</tt> and <tt>vector [v] element <i>n</i> is greater
Chris@1 154 than vector [v] element [x]</tt>.</p>
Chris@1 155
Chris@1 156 <h2><a name="render_point">render_point</a></h2>
Chris@1 157
Chris@1 158 <p>"render_point(x0,y0,x1,y1,X)" is used to find the Y value at point X
Chris@1 159 along the line specified by x0, x1, y0 and y1. This function uses an
Chris@1 160 integer algorithm to solve for the point directly without calculating
Chris@1 161 intervening values along the line.</p>
Chris@1 162
Chris@1 163 <pre>
Chris@1 164 1) [dy] = [y1] - [y0]
Chris@1 165 2) [adx] = [x1] - [x0]
Chris@1 166 3) [ady] = absolute value of [dy]
Chris@1 167 4) [err] = [ady] * ([X] - [x0])
Chris@1 168 5) [off] = [err] / [adx] using integer division
Chris@1 169 6) if ( [dy] is less than zero ) {
Chris@1 170
Chris@1 171 7) [Y] = [y0] - [off]
Chris@1 172
Chris@1 173 } else {
Chris@1 174
Chris@1 175 8) [Y] = [y0] + [off]
Chris@1 176
Chris@1 177 }
Chris@1 178
Chris@1 179 9) done
Chris@1 180 </pre>
Chris@1 181
Chris@1 182 <h2><a name="render_line">render_line</a></h2>
Chris@1 183
Chris@1 184 <p>Floor decode type one uses the integer line drawing algorithm of
Chris@1 185 "render_line(x0, y0, x1, y1, v)" to construct an integer floor
Chris@1 186 curve for contiguous piecewise line segments. Note that it has not
Chris@1 187 been relevant elsewhere, but here we must define integer division as
Chris@1 188 rounding division of both positive and negative numbers toward zero.</p>
Chris@1 189
Chris@1 190 <pre>
Chris@1 191 1) [dy] = [y1] - [y0]
Chris@1 192 2) [adx] = [x1] - [x0]
Chris@1 193 3) [ady] = absolute value of [dy]
Chris@1 194 4) [base] = [dy] / [adx] using integer division
Chris@1 195 5) [x] = [x0]
Chris@1 196 6) [y] = [y0]
Chris@1 197 7) [err] = 0
Chris@1 198
Chris@1 199 8) if ( [dy] is less than 0 ) {
Chris@1 200
Chris@1 201 9) [sy] = [base] - 1
Chris@1 202
Chris@1 203 } else {
Chris@1 204
Chris@1 205 10) [sy] = [base] + 1
Chris@1 206
Chris@1 207 }
Chris@1 208
Chris@1 209 11) [ady] = [ady] - (absolute value of [base]) * [adx]
Chris@1 210 12) vector [v] element [x] = [y]
Chris@1 211
Chris@1 212 13) iterate [x] over the range [x0]+1 ... [x1]-1 {
Chris@1 213
Chris@1 214 14) [err] = [err] + [ady];
Chris@1 215 15) if ( [err] >= [adx] ) {
Chris@1 216
Chris@1 217 15) [err] = [err] - [adx]
Chris@1 218 16) [y] = [y] + [sy]
Chris@1 219
Chris@1 220 } else {
Chris@1 221
Chris@1 222 17) [y] = [y] + [base]
Chris@1 223
Chris@1 224 }
Chris@1 225
Chris@1 226 18) vector [v] element [x] = [y]
Chris@1 227
Chris@1 228 }
Chris@1 229 </pre>
Chris@1 230
Chris@1 231 <div id="copyright">
Chris@1 232 The Xiph Fish Logo is a
Chris@1 233 trademark (&trade;) of Xiph.Org.<br/>
Chris@1 234
Chris@1 235 These pages &copy; 1994 - 2005 Xiph.Org. All rights reserved.
Chris@1 236 </div>
Chris@1 237
Chris@1 238 </body>
Chris@1 239 </html>