From 94f06789223f47ed8fdd9a04d693ceae6f1d7cc4 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 18 Jul 2002 05:26:04 +0000 Subject: [PATCH] spec for floor 1 finished. residue and toplevel reference to go svn path=/trunk/vorbis/; revision=3656 --- doc/floor1_inverse_dB_table.html | 112 +++++++++++++++ doc/helper.html | 90 +++++++++++- doc/vorbis-spec-floor0.html | 22 +-- doc/vorbis-spec-floor1.html | 302 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 502 insertions(+), 24 deletions(-) create mode 100644 doc/floor1_inverse_dB_table.html diff --git a/doc/floor1_inverse_dB_table.html b/doc/floor1_inverse_dB_table.html new file mode 100644 index 0000000..f30c1bc --- /dev/null +++ b/doc/floor1_inverse_dB_table.html @@ -0,0 +1,112 @@ +xiph.org: Ogg Vorbis documentation + +

+ +

+Ogg Vorbis I format specification: floor1_inverse_dB_table +

+ +Last update to this document: July 18, 2002

+ +The vector [floor1_inverse_dB_table] is a 256 element static +lookup table consiting of the following values (read left to right +then top to bottom): + +

+  1.0649863e-07, 1.1341951e-07, 1.2079015e-07, 1.2863978e-07, 
+  1.3699951e-07, 1.4590251e-07, 1.5538408e-07, 1.6548181e-07, 
+  1.7623575e-07, 1.8768855e-07, 1.9988561e-07, 2.1287530e-07, 
+  2.2670913e-07, 2.4144197e-07, 2.5713223e-07, 2.7384213e-07, 
+  2.9163793e-07, 3.1059021e-07, 3.3077411e-07, 3.5226968e-07, 
+  3.7516214e-07, 3.9954229e-07, 4.2550680e-07, 4.5315863e-07, 
+  4.8260743e-07, 5.1396998e-07, 5.4737065e-07, 5.8294187e-07, 
+  6.2082472e-07, 6.6116941e-07, 7.0413592e-07, 7.4989464e-07, 
+  7.9862701e-07, 8.5052630e-07, 9.0579828e-07, 9.6466216e-07, 
+  1.0273513e-06, 1.0941144e-06, 1.1652161e-06, 1.2409384e-06, 
+  1.3215816e-06, 1.4074654e-06, 1.4989305e-06, 1.5963394e-06, 
+  1.7000785e-06, 1.8105592e-06, 1.9282195e-06, 2.0535261e-06, 
+  2.1869758e-06, 2.3290978e-06, 2.4804557e-06, 2.6416497e-06, 
+  2.8133190e-06, 2.9961443e-06, 3.1908506e-06, 3.3982101e-06, 
+  3.6190449e-06, 3.8542308e-06, 4.1047004e-06, 4.3714470e-06, 
+  4.6555282e-06, 4.9580707e-06, 5.2802740e-06, 5.6234160e-06, 
+  5.9888572e-06, 6.3780469e-06, 6.7925283e-06, 7.2339451e-06, 
+  7.7040476e-06, 8.2047000e-06, 8.7378876e-06, 9.3057248e-06, 
+  9.9104632e-06, 1.0554501e-05, 1.1240392e-05, 1.1970856e-05, 
+  1.2748789e-05, 1.3577278e-05, 1.4459606e-05, 1.5399272e-05, 
+  1.6400004e-05, 1.7465768e-05, 1.8600792e-05, 1.9809576e-05, 
+  2.1096914e-05, 2.2467911e-05, 2.3928002e-05, 2.5482978e-05, 
+  2.7139006e-05, 2.8902651e-05, 3.0780908e-05, 3.2781225e-05, 
+  3.4911534e-05, 3.7180282e-05, 3.9596466e-05, 4.2169667e-05, 
+  4.4910090e-05, 4.7828601e-05, 5.0936773e-05, 5.4246931e-05, 
+  5.7772202e-05, 6.1526565e-05, 6.5524908e-05, 6.9783085e-05, 
+  7.4317983e-05, 7.9147585e-05, 8.4291040e-05, 8.9768747e-05, 
+  9.5602426e-05, 0.00010181521, 0.00010843174, 0.00011547824, 
+  0.00012298267, 0.00013097477, 0.00013948625, 0.00014855085, 
+  0.00015820453, 0.00016848555, 0.00017943469, 0.00019109536, 
+  0.00020351382, 0.00021673929, 0.00023082423, 0.00024582449, 
+  0.00026179955, 0.00027881276, 0.00029693158, 0.00031622787, 
+  0.00033677814, 0.00035866388, 0.00038197188, 0.00040679456, 
+  0.00043323036, 0.00046138411, 0.00049136745, 0.00052329927, 
+  0.00055730621, 0.00059352311, 0.00063209358, 0.00067317058, 
+  0.00071691700, 0.00076350630, 0.00081312324, 0.00086596457, 
+  0.00092223983, 0.00098217216, 0.0010459992,  0.0011139742, 
+  0.0011863665,  0.0012634633,  0.0013455702,  0.0014330129, 
+  0.0015261382,  0.0016253153,  0.0017309374,  0.0018434235, 
+  0.0019632195,  0.0020908006,  0.0022266726,  0.0023713743, 
+  0.0025254795,  0.0026895994,  0.0028643847,  0.0030505286, 
+  0.0032487691,  0.0034598925,  0.0036847358,  0.0039241906, 
+  0.0041792066,  0.0044507950,  0.0047400328,  0.0050480668, 
+  0.0053761186,  0.0057254891,  0.0060975636,  0.0064938176, 
+  0.0069158225,  0.0073652516,  0.0078438871,  0.0083536271, 
+  0.0088964928,  0.009474637,   0.010090352,   0.010746080, 
+  0.011444421,   0.012188144,   0.012980198,   0.013823725, 
+  0.014722068,   0.015678791,   0.016697687,   0.017782797, 
+  0.018938423,   0.020169149,   0.021479854,   0.022875735, 
+  0.024362330,   0.025945531,   0.027631618,   0.029427276, 
+  0.031339626,   0.033376252,   0.035545228,   0.037855157, 
+  0.040315199,   0.042935108,   0.045725273,   0.048696758, 
+  0.051861348,   0.055231591,   0.058820850,   0.062643361, 
+  0.066714279,   0.071049749,   0.075666962,   0.080584227, 
+  0.085821044,   0.091398179,   0.097337747,   0.10366330, 
+  0.11039993,    0.11757434,    0.12521498,    0.13335215, 
+  0.14201813,    0.15124727,    0.16107617,    0.17154380, 
+  0.18269168,    0.19456402,    0.20720788,    0.22067342, 
+  0.23501402,    0.25028656,    0.26655159,    0.28387361, 
+  0.30232132,    0.32196786,    0.34289114,    0.36517414, 
+  0.38890521,    0.41417847,    0.44109412,    0.46975890, 
+  0.50028648,    0.53279791,    0.56742212,    0.60429640, 
+  0.64356699,    0.68538959,    0.72993007,    0.77736504, 
+  0.82788260,    0.88168307,    0.9389798,     1.
+
+
+
+ + + + + +Ogg is a Xiph.org Foundation effort +to protect essential tenets of Internet multimedia from corporate +hostage-taking; Open Source is the net's greatest tool to keep +everyone honest. See About +the Xiph.org Foundation for details. +

+ +Ogg Vorbis is the first Ogg audio CODEC. Anyone may freely use and +distribute the Ogg and Vorbis specification, whether in a private, +public or corporate capacity. However, the Xiph.org Foundation and +the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis +specification and certify specification compliance.

+ +Xiph.org's Vorbis software CODEC implementation is distributed under a +BSD-like license. This does not restrict third parties from +distributing independent implementations of Vorbis software under +other licenses.

+ +Ogg, Vorbis, Xiph.org Foundation and their logos are trademarks (tm) +of the Xiph.org Foundation. These +pages are copyright (C) 1994-2002 Xiph.org Foundation. All rights +reserved.

+ + + diff --git a/doc/helper.html b/doc/helper.html index e086356..5996485 100644 --- a/doc/helper.html +++ b/doc/helper.html @@ -6,7 +6,7 @@ Ogg Vorbis I format specification: helper equations -Last update to this document: July 15, 2002
+Last update to this document: July 18, 2002

Overview

@@ -74,6 +74,94 @@ integer value for which [return_value] to the power of [codebook_dimensions] is less than or equal to [codebook_entries]'. +

low_neighbor

+ +"low_neighbor(v,x)" finds the position n in vector [v] of +the greatest value scalar element for which n is less than +[x] and vector [v] element n is less +than vector [v] element [x]. + +

high_neighbor

+ +"high_neighbor(v,x)" finds the position n in vector [v] of +the lowest value scalar element for which n is less than +[x] and vector [v] element n is greater +than vector [v] element [x]. + +

render_point

+ +"render_point(x0,x1,y0,y1,X)" is used to find the Y value at point X +along the line specified by x0, x1, y0 and y1. This function uses an +integer algorithm to solve for the point directly without calculating +intervening values along the line.

+ +

+  1)  [dy] = [y1] - [y0]
+  2) [adx] = [x1] - [x0]
+  3) [ady] = absolute value of [dy]
+  4) [err] = [ady] * ([X] - [x0])
+  5) [off] = [err] / [adx] using integer division
+  6) if ( [dy] is less than zero ) {
+
+       7) [Y] = [y0] - [off]
+
+     } else {
+
+       8) [Y] = [y0] + [off]
+  
+     }
+
+  9) done
+
+ +

render_line

+ +Floor decode type one uses the integer line drawing algorithm of +"render_line(x0, y0, x1, y1, v)" to construct an integer floor +curve for contiguous piecewise line segments. Note that it has not +been relevant elsewhere, but here we must define integer division as +rounding division of both positive and negative numbers toward zero. + +
+  1)   [dy] = [y1] - [y0]
+  2)  [adx] = [x1] - [x0]
+  3)  [ady] = absolute value of [dy]
+  4) [base] = [dy] / [adx] using integer division
+  5)    [x] = [x0]
+  6)    [y] = [y0]
+  7)  [err] = 0
+
+  8) if ( [dy] is less than 0 ) {
+
+        9) [sy] = [base] - 1
+
+     } else {
+
+       10) [sy] = [base] + 1
+
+     }
+
+ 11) [ady] = [ady] - [base] * [adx]
+ 12) vector [v] element [x] = [y]
+
+ 13) iterate [x] over the range [x0]+1 ... [x1]-1 {
+
+       14) [err] = [err] + [ady];
+       15) if ( [err] >= [adx] ) {
+
+             15) [err] = [err] - [adx]
+             16)   [y] = [y] + [sy]
+
+           } else {
+
+             17) [y] = [y] + [base]
+   
+           }
+
+       18) vector [v] element [x] = [y]
+
+     }
+

diff --git a/doc/vorbis-spec-floor0.html b/doc/vorbis-spec-floor0.html index 187f217..e01fa54 100644 --- a/doc/vorbis-spec-floor0.html +++ b/doc/vorbis-spec-floor0.html @@ -6,13 +6,13 @@ Ogg Vorbis I format specification: floor type 0 setup and decode -Last update to this document: July 17, 2002
+Last update to this document: July 18, 2002

Overview

Vorbis floor type zero uses Line Spectral Pair [LSP, also alternately known as Line Spectral Frequency or LSF] representation to encode a -smooth spectral envelope curve as the frequency responce of the LSP +smooth spectral envelope curve as the frequency response of the LSP filter. This representation is equivalent to a traditional all-pole infinite impulse response filter as would be used in linear predictive coding; LSP representation may be converted to LPC representation and @@ -52,20 +52,20 @@ stream undecodable. Extracting a floor0 curve from an audio packet consists of first decoding the curve amplitude and [floor0_order] LSP -coefficient values from the bitstream, and then comupting the floor +coefficient values from the bitstream, and then computing the floor curve, which is defined as the frequency response of the decoded LSP filter.

-Packet decode proceeeds as follows:

+Packet decode proceeds as follows:

   1) [amplitude] = read an unsigned integer of [floor0_amplitude_bits] bits
-  2) [coefficients] is an empty, zero length vector
-  3) if ( [amplitude] is greater than zero ) {
+  2) if ( [amplitude] is greater than zero ) {
+       3) [coefficients] is an empty, zero length vector
 
        4) [booknumber] = read an unsigned integer of ilog( [floor0_number_of_books] ) bits
        5) if ( [booknumber] is greater than the highest number decode codebook ) then packet is undecodable
        6) [lastval] = zero;
-       7) vector [temp_vector] = read vector from bistream using codebook number [booknumber] in VQ context.
+       7) vector [temp_vector] = read vector from bitstream using codebook number [booknumber] in VQ context.
        8) add the scalar value [last] to each scalar in vector [temp_vector]
        9) [last] = the value of the last scalar in vector [temp_vector]
       10) concatenate [temp_vector] onto the end of the [coefficients] vector
@@ -79,6 +79,12 @@ Packet decode proceeeds as follows:

Take note of the following properties of decode:

    +
  • An [amplitude] value of zero must result in a return code that indicates this channel is unused in this frame (the output of the channel will be all-zeroes in synthesis). Several later stages of decode don't occur for an unused channel.

    +

  • An end-of-packet condition during decode should be considered a +nominal occruence; if end-of-packet is reached during any read +operation above, floor decode is to return 'unused' status as if the +[amplitude] value had read zero at the beginning of decode. +
  • The book number used for decode can, in fact, be stored in the bitstream in ilog( [floor0_number_of_books] - @@ -113,7 +119,7 @@ synthesized:

    -The above is used to synthesize the LSP curve on a Bark-scale fequency +The above is used to synthesize the LSP curve on a Bark-scale frequency axis, then map the result to a linear-scale frequency axis. Similarly, the below calculation synthesizes the output LSP curve [output] on a log (dB) amplitude scale, mapping it to linear amplitude in the last step:

    diff --git a/doc/vorbis-spec-floor1.html b/doc/vorbis-spec-floor1.html index d52f9f6..e8cb4fa 100644 --- a/doc/vorbis-spec-floor1.html +++ b/doc/vorbis-spec-floor1.html @@ -6,11 +6,11 @@ Ogg Vorbis I format specification: floor type 1 setup and decode -Last update to this document: July 17, 2002
    +Last update to this document: July 18, 2002

    Overview

    -Vorbis floor type one uses a piecewise stright-line representation to +Vorbis floor type one uses a piecewise straight-line representation to encode a spectral envelope curve. The representation plots this curve mechanically on a linear frequency axis and a logarithmic (dB) amplitude axis. The integer plotting algorithm used is similar to @@ -18,9 +18,9 @@ Bresenham's algorithm.

    Floor 1 format

    -

    model

    Floor type one represents a spectral curve as series of +

    model

    Floor type one represents a spectral curve as a series of line segments. Synthesis constructs a floor curve using iterative -refinement in a process roughly equivalent to the following simplified +prediction in a process roughly equivalent to the following simplified description:

    • the first line segment (base case) is a logical line spanning @@ -39,7 +39,7 @@ amplitude value at x_new so that later refinement is additionally bounded at x_new.

    • the induction step repeats, using a list of x values specified in -the codec setup header at floor 1 initiialization time. Computation +the codec setup header at floor 1 initialization time. Computation is completed at the end of the x value list.
    @@ -47,12 +47,13 @@ is completed at the end of the x value list. Consider the following example, with values chosen for ease of understanding rather than representing typical configuration:

    -We assume a floor setup with an [n] of 128. The list of selected X -values in increasing order are 0,16,32,48,64,80,96,112 and 128. In -list order, they're interleaved as 0, 128, 64, 32, 96, 16, 48, 80 and -112. The corresponding list-order Y values as decoded from the -bitstream are 110, 20, -5, -45, 0, -25, -10, 30 and -10. We compute -the floor in the following way, beginning with the first line:

    +For the below example, we assume a floor setup with an [n] of 128. +The list of selected X values in increasing order is +0,16,32,48,64,80,96,112 and 128. In list order, the values interleave +as 0, 128, 64, 32, 96, 16, 48, 80 and 112. The corresponding +list-order Y values as decoded from an example packet are 110, 20, -5, +-45, 0, -25, -10, 30 and -10. We compute the floor in the following +way, beginning with the first line:

    @@ -79,18 +80,289 @@ accumulation through integer roundoff/truncation.

    A list of floor X values is stored in the packet header in interleaved format (used in list order during packet decode and synthesis). This list is split into partitions, and each partition is assigned to a -partition class. The partition class defines the codebooks to be used -during synthesis to decode the Y values coresponding to the X -locations in that parition. X positions 0 and [n] are implicit and do -not belong to an explicit partition or partition class. +partition class. X positions 0 and [n] are implicit and do not belong +to an explicit partition or partition class.

    + +A partition class consists of a representation vector width (the +number of Y values which the partition class encodes at once), a +'subclass' value representing the number of alternate entropy books +the partition class may use in representing Y values, the list of +[subclass] books and a master book used to encode which alternate +books were chosen for representation in a given packet. The +master/subclass mechanism is meant to be used as a flexible +representation cascade while still using codebooks only in a scalar +context.

    + +

    +
    +  1) [floor1_partitions] = read 5 bits as unsigned integer
    +  2) [maximum_class] = 0
    +  3) iterate [i] over the range 0 ... [floor1_partitions]-1 {
    +       
    +        4) vector [floor1_partition_class_list] element [i] = read 4 bits as unsigned integer
    +
    +     }
    +
    +  5) [maximum_class] = largest integer scalar value in vector [floor1_partition_class_list]
    +  6) iterate [i] over the range 0 ... [maximum_class] {
    +
    +        7) vector [floor1_class_dimensions] element [i] = read 3 bits as unsigned integer and add 1
    +	8) vector [floor1_class_subclasses] element [i] = read 2 bits as unsigned integer
    +        9) if ( vector [floor1_class_subclasses] element [i] is nonzero ) {
    +            
    +             10) vector [floor1_class_masterbooks] element [i] = read 8 bits as unsigned integer
    +           
    +           }
    +
    +       11) iterate [j] over the range 0 ... (2 exponent [floor1_class_subclasses] element [i]) - 1  {
    +
    +             12) array [floor1_subclass_books] element [i],[j] = 
    +                 read 8 bits as unsigned integer and subtract one
    +           }
    +      }
    +
    + 13) [floor1_multiplier] = read 2 bits as unsigned integer and add one
    + 14) [rangebits] = read 4 bits as unsigned integer
    + 15) vector [floor1_X_list] element [0] = 0
    + 16) vector [floor1_X_list] element [1] = 2 exponent [rangebits];
    + 17) [floor1_values] = 1
    + 18) iterate [i] over the range 0 ... [floor1_partitions]-1 {
    +
    +       19) iterate [j] over the range 0 ... ([floor1_class_dimensions] element [i])-1 {
    +             20) vector [floor1_X_list] element ([j] + [floor1_values]) = 
    +                 read [rangebits] bits as unsigned integer
    +            }
    +
    +       21) [floor1_values] = [floor1_values] + [floor1_class_dimensions] element [i]
    +     }
    + 
    + 19) done
    +
    +An end-of-packet condition while reading any aspect of a floor 1 +configuration during setup renders a stream undecodable. In +addition, a [floor1_class_masterbooks] or +[floor1_subclass_books] scalar element greater than the +highest numbered codebook configured in this stream is an error +condition that renders the stream undecodable.

    packet decode

    +Packet decode begins by checking the [nonzero] flag:

    + +

    +  1) [nonzero] = read 1 bit as boolean
    +
    + +If [nonzero] is unset, that indicates this channel contained +no audio energy in this frame. Decode immediately returns a status +indicating this floor curve (and thus this channel) is unused this +frame. (A return status of 'unused' is different from decoding a +floor that has all points set to minimum representation amplitude, +which happens to be approximately -140dB). + +Assuming [nonzero] is set, decode proceeds as follows:

    + +

    +  1) [range] = vector { 256, 128, 86, 64 } element ([floor1_multiplier]-1)
    +  2) vector [floor1_Y] element [0] = read ilog([range]-1) bits as unsigned integer
    +  3) vector [floor1_Y] element [1] = read ilog([range]-1) bits as unsigned integer
    +  4) [offset] = 2;
    +  5) iterate [i] over the range 0 ... [floor1_partitions]-1 {
    +
    +       6) [class] = vector [floor1_partition_class]  element [i]
    +       7) [cdim]  = vector [floor1_class_dimensions] element [class]
    +       8) [cbits] = vector [floor1_class_subclasses] element [class]
    +       9) [csub]  = (2 exponent [cbits])-1
    +      10) [cval]  = 0
    +      11) if ( [cbits] is greater than zero ) {
    + 
    +             12) [cval] = read from packet using codebook number
    +                 (vector [floor1_class_masterbooks] element [class]) in scalar context
    +          }
    +      
    +      13) iterate [j] over the range 0 ... [cdim]-1 {
    +       
    +             14) [book] = array [floor1_subclass_books] element [class],([cval] bitwise AND [csub])
    +	     15) if ( [book] is not less than zero ) {
    +	     
    +	           16) vector [floor1_Y] element ([j]+[offset]) = read from packet using codebook 
    +                       [book] in scalar context
    +
    +                 } else [book] is less than zero {
    +
    +	           17) vector [floor1_Y] element ([j]+[offset]) = 0
    +
    +                 }
    +          }
    +             
    +      18) [offset] = [offset] + [cdim]
    +         
    +     }
    +  
    + 19) done
    +
    + +An end-of-packet condition during curve decode should be considered a +nominal occurrence; if end-of-packet is reached during any read +operation above, floor decode is to return 'unused' status as if the +[nonzero] flag had been unset at the beginning of decode. + +Vector [floor1_Y] contains the values from packet decode +needed for floor 1 synthesis.

    +

    curve computation

    +Curve computation is split into two logical steps; the first step +derives final Y amplitude values from the encoded, wrapped difference +values taken from the bitstream. The second step plots the curve +lines. Also, although zero-difference values are used in the +iterative prediction to find final Y values, these points are +conditionally skipped during final line computation in step two. +Skipping zero-difference values allows a smoother line fit.

    + +Although some aspects of the below algorithm look like inconsequential +optimizations, implementors are warned to follow the details closely. +Deviation from implementing a strictly equivalent algorithm can result +in serious decoding errors.

    + +

    step 1: amplitude value synthesis

    + +Unwrap the always-positive-or-zero values read from the packet into ++/- difference values, then apply to line prediction.

    + +

    +  1) [range] = vector { 256, 128, 86, 64 } element ([floor1_multiplier]-1)
    +  2) iterate [i] over the range 2 ... [floor1_values]-1 {
    +    
    +       3) [low_neighbor_offset] = low_neighbor([floor1_X_list],[i])
    +       4) [high_neighbor_offset] = high_neighbor([floor1_X_list],[i])
    +
    +       5) [predicted] = render_point( vector [floor1_X_list] element [low_neighbor_offset],
    +                                      vector [floor1_X_list] element [high_neighbor_offset],
    +				      vector [floor1_Y] element [low_neighbor_offset],
    +				      vector [floor1_Y] element [high_neighbor_offset],
    +                                      vector [floor1_X_list] element [i] )
    +
    +       6) [val] = vector [floor1_Y] element [i]
    +       7) [highroom] = [range] - [predicted]
    +       8) [lowroom]  = [predicted]
    +       9) if ( [highroom] is less than [lowroom] ) {
    +
    +            10) [room] = [highroom] * 2
    +         
    +          } else [highroom] is not less than [lowroom] {
    +		      
    +            11) [root] = [lowroom] * 2
    +        
    +          }
    +
    +      12) if ( [val] is nonzero ) {
    +
    +            13) vector [floor1_step2_flag] element [low_neighbor_offset] = set
    +            14) vector [floor1_step2_flag] element [high_neighbor_offset] = set
    +            15) vector [floor1_step2_flag] element [i] = set
    +            16) if ( [val] is greater than or equal to [room] ) {
    + 
    +                  17) if ( [hiroom] is greater than [lowroom] ) {
    +
    +                        18) vector [floor1_final_Y] element [i] = [val] - [lowroom] + [predicted]
    +		     
    +		      } else [hiroom] is not greater than [lowroom] {
    +              
    +                        19) vector [floor1_final_Y] element [i] = [predicted] - ([val] - [lowroom]) - 1
    +                   
    +                      }
    +               
    +                } else [val] is less than [room] {
    +		 
    +		  20) if ([val] is odd) {
    +                 
    +                        21) vector [floor1_final_Y] element [i] = 
    +                            [predicted] - (([val] - 1) divided by  2 using integer division)
    +
    +                      } else [val] is even {
    +
    +                        22) vector [floor1_final_Y] element [i] = 
    +                            [predicted] + ([val] / 2 using integer division)
    +                          
    +                      }
    +
    +                }      
    +
    +          } else [val] is zero {
    +
    +            23) vector [floor1_step2_flag] element [i] = unset
    +            24) vector [floor1_final_Y] element [i] = [predicted]
    +
    +          }
    +
    +     }
    +
    + 25) vector [floor1_step2_flag] element [0] = set
    + 26) vector [floor1_step2_flag] element [1] = set
    + 27) vector [floor1_final_Y] element [0] = vector [floor1_Y] element [0]
    + 28) vector [floor1_final_Y] element [1] = vector [floor1_Y] element [1]
    + 29) done
    +
     
    +

    step 2: curve synthesis

    + +Curve synthesis generates a return vector [floor] of length +[n] (where [n] is provided by the decode process +calling to floor decode). Floor 1 curve synthesis makes use of the +[floor1_X_list], [floor1_final_Y] and +[floor1_step2_flag] vectors, as well as [floor1_multiplier] +and [floor1_values] values.

    + +Decode begins by sorting the scalars from vectors +[floor1_X_list], [floor1_final_Y] and +[floor1_step2_flag] together into new vectors +[floor1_X_list]', [floor1_final_Y]' and +[floor1_step2_flag]' according to ascending sort order of the +values in [floor1_X_list]. That is, sort the values of +[floor1_X_list] and then apply the same permutation to +elements of the other two vectors so that the X, Y and step2_flag +values still match.

    + +Then compute the final curve in one pass:

    + +

    +  1) [hx] = 0
    +  2) [lx] = 0
    +  3) [ly] = vector [floor1_final_Y]' element [0] * [floor1_multiplier]
    +  4) iterate [i] over the range 1 ... [floor1_values]-1 {
    +
    +       5) if ( [floor1_step2_flag]' is set ) {
    +
    +             6) [hy] = [floor1_final_Y]' element [i] * [floor1_multiplier]
    + 	     7) [hx] = [floor1_X_list]' element [i]
    +             8) render_line( [lx], [hx], [ly], [hy], [floor] )
    +             9) [lx] = [hx]
    +	    10) [ly] = [hy]
    +          }
    + 
    +      11) if ( [hx] is less than [n] ) {
    +
    +            12) render_line( [hx], [hy], [n], [hy], [floor] )
    +
    +          }
    +
    +      13) if ( [hx] is greater than [n] ) {
    +
    +            14) truncate vector [floor] to [n] elements
    +
    +          }
    +     }
    + 
    + 15) for each scalar in vector [floor], perform a lookup substitution using 
    +     the scalar value from [floor] as an offset into the vector [floor1_inverse_dB_static_table]
    +
    + 16) done
    +
    +
    +
     
    -- 2.7.4