annotate src/libvorbis-1.3.3/doc/helper.html @ 86:98c1576536ae

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