examples/sfexamples/oggvorbiscodec/src/libvorbis/doc/helper.html

00001 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00002 <html>
00003 <head>
00004 
00005 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>
00006 <title>Ogg Vorbis Documentation</title>
00007 
00008 <style type="text/css">
00009 body {
00010   margin: 0 18px 0 18px;
00011   padding-bottom: 30px;
00012   font-family: Verdana, Arial, Helvetica, sans-serif;
00013   color: #333333;
00014   font-size: .8em;
00015 }
00016 
00017 a {
00018   color: #3366cc;
00019 }
00020 
00021 img {
00022   border: 0;
00023 }
00024 
00025 #xiphlogo {
00026   margin: 30px 0 16px 0;
00027 }
00028 
00029 #content p {
00030   line-height: 1.4;
00031 }
00032 
00033 h1, h1 a, h2, h2 a, h3, h3 a {
00034   font-weight: bold;
00035   color: #ff9900;
00036   margin: 1.3em 0 8px 0;
00037 }
00038 
00039 h1 {
00040   font-size: 1.3em;
00041 }
00042 
00043 h2 {
00044   font-size: 1.2em;
00045 }
00046 
00047 h3 {
00048   font-size: 1.1em;
00049 }
00050 
00051 li {
00052   line-height: 1.4;
00053 }
00054 
00055 #copyright {
00056   margin-top: 30px;
00057   line-height: 1.5em;
00058   text-align: center;
00059   font-size: .8em;
00060   color: #888888;
00061   clear: both;
00062 }
00063 </style>
00064 
00065 </head>
00066 
00067 <body>
00068 
00069 <div id="xiphlogo">
00070   <a href="http://www.xiph.org/"><img src="fish_xiph_org.png" alt="Fish Logo and Xiph.org"/></a>
00071 </div>
00072 
00073 <h1>Ogg Vorbis I format specification: helper equations</h1>
00074 
00075 <h1>Overview</h1>
00076 
00077 <p>The equations below are used in multiple places by the Vorbis codec
00078 specification. Rather than cluttering up the main specification
00079 documents, they are defined here and linked in the main documents
00080 where appropriate.</p>
00081 
00082 <h2><a name="log">ilog</a></h2>
00083 
00084 <p>The "ilog(x)" function returns the position number (1 through n) of the
00085 highest set bit in the two's complement integer value
00086 <tt>[x]</tt>. Values of <tt>[x]</tt> less than zero are defined to return zero.</p>
00087 
00088 <pre>
00089   1) [return_value] = 0;
00090   2) if ( [x] is greater than zero ){
00091       
00092        3) increment [return_value];
00093        4) logical shift [x] one bit to the right, padding the MSb with zero
00094        5) repeat at step 2)
00095 
00096      }
00097 
00098    6) done
00099 </pre>
00100 
00101 <p>Examples:</p>
00102 
00103 <ul>
00104 <li>ilog(0) = 0;</li>
00105 <li>ilog(1) = 1;</li>
00106 <li>ilog(2) = 2;</li>
00107 <li>ilog(3) = 2;</li>
00108 <li>ilog(4) = 3;</li>
00109 <li>ilog(7) = 3;</li>
00110 <li>ilog(negative number) = 0;</li>
00111 </ul>
00112 
00113 <h2><a name="float32_unpack">float32_unpack</a></h2>
00114 
00115 <p>"float32_unpack(x)" is intended to translate the packed binary
00116 representation of a Vorbis codebook float value into the
00117 representation used by the decoder for floating point numbers. For
00118 purposes of this example, we will unpack a Vorbis float32 into a
00119 host-native floating point number.</p>
00120 
00121 <pre>
00122   1) [mantissa] = [x] bitwise AND 0x1fffff (unsigned result)
00123   2) [sign] = [x] bitwise AND 0x80000000 (unsigned result)
00124   3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted right 21 bits (unsigned result)
00125   4) if ( [sign] is nonzero ) then negate [mantissa]
00126   5) return [mantissa] * ( 2 ^ ( [exponent] - 788 ) )
00127 </pre>
00128 
00129 <h2><a name="lookup1_values">lookup1_values</a></h2>
00130 
00131 <p>"lookup1_values(codebook_entries,codebook_dimensions)" is used to
00132 compute the correct length of the value index for a codebook VQ lookup
00133 table of lookup type 1. The values on this list are permuted to
00134 construct the VQ vector lookup table of size
00135 <tt>[codebook_entries]</tt>.</p>
00136 
00137 <p>The return value for this function is defined to be 'the greatest
00138 integer value for which <tt>[return_value] to the power of
00139 [codebook_dimensions] is less than or equal to
00140 [codebook_entries]</tt>'.</p>
00141 
00142 <h2><a name="low_neighbor">low_neighbor</a></h2>
00143 
00144 <p>"low_neighbor(v,x)" finds the position <i>n</i> in vector [v] of
00145 the greatest value scalar element for which <i>n</i> is less than
00146 <tt>[x]</tt> and <tt>vector [v] element <i>n</i> is less
00147 than vector [v] element [x]</tt>.</p>
00148 
00149 <h2><a name="high_neighbor">high_neighbor</a></h2>
00150 
00151 <p>"high_neighbor(v,x)" finds the position <i>n</i> in vector [v] of
00152 the lowest value scalar element for which <i>n</i> is less than
00153 <tt>[x]</tt> and <tt>vector [v] element <i>n</i> is greater
00154 than vector [v] element [x]</tt>.</p>
00155 
00156 <h2><a name="render_point">render_point</a></h2>
00157 
00158 <p>"render_point(x0,y0,x1,y1,X)" is used to find the Y value at point X
00159 along the line specified by x0, x1, y0 and y1. This function uses an
00160 integer algorithm to solve for the point directly without calculating
00161 intervening values along the line.</p>
00162 
00163 <pre>
00164   1)  [dy] = [y1] - [y0]
00165   2) [adx] = [x1] - [x0]
00166   3) [ady] = absolute value of [dy]
00167   4) [err] = [ady] * ([X] - [x0])
00168   5) [off] = [err] / [adx] using integer division
00169   6) if ( [dy] is less than zero ) {
00170 
00171        7) [Y] = [y0] - [off]
00172 
00173      } else {
00174 
00175        8) [Y] = [y0] + [off]
00176   
00177      }
00178 
00179   9) done
00180 </pre>
00181 
00182 <h2><a name="render_line">render_line</a></h2>
00183 
00184 <p>Floor decode type one uses the integer line drawing algorithm of
00185 "render_line(x0, y0, x1, y1, v)" to construct an integer floor
00186 curve for contiguous piecewise line segments. Note that it has not
00187 been relevant elsewhere, but here we must define integer division as
00188 rounding division of both positive and negative numbers toward zero.</p>
00189 
00190 <pre>
00191   1)   [dy] = [y1] - [y0]
00192   2)  [adx] = [x1] - [x0]
00193   3)  [ady] = absolute value of [dy]
00194   4) [base] = [dy] / [adx] using integer division
00195   5)    [x] = [x0]
00196   6)    [y] = [y0]
00197   7)  [err] = 0
00198 
00199   8) if ( [dy] is less than 0 ) {
00200 
00201         9) [sy] = [base] - 1
00202 
00203      } else {
00204 
00205        10) [sy] = [base] + 1
00206 
00207      }
00208 
00209  11) [ady] = [ady] - (absolute value of [base]) * [adx]
00210  12) vector [v] element [x] = [y]
00211 
00212  13) iterate [x] over the range [x0]+1 ... [x1]-1 {
00213 
00214        14) [err] = [err] + [ady];
00215        15) if ( [err] >= [adx] ) {
00216 
00217              15) [err] = [err] - [adx]
00218              16)   [y] = [y] + [sy]
00219 
00220            } else {
00221 
00222              17) [y] = [y] + [base]
00223    
00224            }
00225 
00226        18) vector [v] element [x] = [y]
00227 
00228      }
00229 </pre>
00230 
00231 <div id="copyright">
00232   The Xiph Fish Logo is a
00233   trademark (&trade;) of Xiph.Org.<br/>
00234 
00235   These pages &copy; 1994 - 2005 Xiph.Org. All rights reserved.
00236 </div>
00237 
00238 </body>
00239 </html>

Generated by  doxygen 1.6.2