Get new docs into CVS so nothing gets lost
[platform/upstream/libvorbis.git] / doc / helper.html
1 <HTML><HEAD><TITLE>xiph.org: Ogg Vorbis documentation</TITLE>
2 <BODY bgcolor="#ffffff" text="#202020" link="#006666" vlink="#000000">
3 <nobr><img src="white-ogg.png"><img src="vorbisword2.png"></nobr><p>
4
5 <h1><font color=#000070>
6 Ogg Vorbis I format specification: helper equations
7 </font></h1>
8
9 <em>Last update to this document: July 15, 2002</em><br>
10
11 <h1>Overview</h1>
12
13 The equations below are used in multiple places by the Vorbis codec
14 specification.  Rather than cluttering up the main specification
15 documents, they are defined here and linked int he main documents
16 where appropriate.<p>
17
18 <a name=log><h2>ilog</h2></a>
19
20
21 The "ilog(x)" function returns the highest set bit in the two's complement integer value
22 <tt>[x]</tt>.  Values of <tt>[x]</tt> less than zero are defined to return zero.
23
24 <pre>
25   1) [return_value] = 0;
26   2) if ( [x] is greater than nonzero ){
27       
28        3) increment [return_value];
29        4) logical shift [x] one bit to the right, padding the MSb with zero
30        5) repeat at step 2)
31
32      }
33
34    6) done
35 </pre>
36
37 Examples:
38
39 <ul><li> ilog(0) = 0;
40     <li> ilog(1) = 1;
41     <li> ilog(2) = 2;
42     <li> ilog(3) = 2;
43     <li> ilog(4) = 3;
44     <li> ilog(7) = 3;
45     <li> ilog(negative number) = 0;
46 </uL>
47
48 <a name=float32_unpack><h2>float32_unpack</h2></a>
49
50 "float32_unpack(x)" is intended to translate the packed binary
51 representation of a Vorbis codebook float value into the
52 representation used by the decoder for floating point numbers.  For
53 purposes of this example, we will unpack a Vorbis float32 into a
54 host-native floating point number.<p>
55
56 <pre>
57   1) [mantissa] = [x] bitwise AND 0x1fffff (unsigned result)
58   2) [sign] = [x] bitwise AND 0x80000000 (unsigned result)
59   3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted left 21 bits (unsigned result)
60   4) if ( [mantissa] is nonzero ) then negate [mantissa]
61   5) return [mantissa] * ( 2 ^ ( [exponent] - 788 ) )
62 </pre>
63
64 <a name=lookup1_values><h2>lookup1_values</h2></a>
65
66 "lookup1_values(codebook_entries,codebook_dimensions)" is used to
67 compute the correct length of the value index for a codebook VQ lookup
68 table of lookup type 1.  The values on this list are permuted to
69 construct the VQ vector lookup table of size
70 <tt>[codebook_entries]</tt>.<p>
71
72 The return value for this function is defined to be 'the greatest
73 integer value for which <tt>[return_value] to the power of
74 [codebook_dimensions] is less than or equal to
75 [codebook_entries]</tt>'.
76
77
78 <hr>
79 <a href="http://www.xiph.org/">
80 <img src="white-xifish.png" align=left border=0>
81 </a>
82 <font size=-2 color=#505050>
83
84 Ogg is a <a href="http://www.xiph.org">Xiph.org Foundation</a> effort
85 to protect essential tenets of Internet multimedia from corporate
86 hostage-taking; Open Source is the net's greatest tool to keep
87 everyone honest. See <a href="http://www.xiph.org/about.html">About
88 the Xiph.org Foundation</a> for details.
89 <p>
90
91 Ogg Vorbis is the first Ogg audio CODEC.  Anyone may freely use and
92 distribute the Ogg and Vorbis specification, whether in a private,
93 public or corporate capacity.  However, the Xiph.org Foundation and
94 the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis
95 specification and certify specification compliance.<p>
96
97 Xiph.org's Vorbis software CODEC implementation is distributed under a
98 BSD-like license.  This does not restrict third parties from
99 distributing independent implementations of Vorbis software under
100 other licenses.<p>
101
102 Ogg, Vorbis, Xiph.org Foundation and their logos are trademarks (tm)
103 of the <a href="http://www.xiph.org/">Xiph.org Foundation</a>.  These
104 pages are copyright (C) 1994-2002 Xiph.org Foundation. All rights
105 reserved.<p>
106
107 </body>
108