New LSP books, more reliable fit and lower bit usage
authorMonty <xiphmont@xiph.org>
Wed, 12 Jul 2000 09:36:18 +0000 (09:36 +0000)
committerMonty <xiphmont@xiph.org>
Wed, 12 Jul 2000 09:36:18 +0000 (09:36 +0000)
svn path=/trunk/vorbis/; revision=522

25 files changed:
include/vorbis/backends.h
include/vorbis/book/lsp12_0.vqh
include/vorbis/book/lsp30_0.vqh
include/vorbis/codec.h
include/vorbis/internal.h
include/vorbis/modes.h
lib/Makefile.in
lib/analysis.c
lib/block.c
lib/envelope.c
lib/envelope.h
lib/floor0.c
lib/iir.c [new file with mode: 0644]
lib/iir.h [new file with mode: 0644]
lib/iir.o [new file with mode: 0644]
lib/lpc.c
lib/lpc.h
lib/mapping0.c
todo.txt
vq/auxpartition.pl
vq/bookutil.c
vq/bookutil.h
vq/huffbuild.c
vq/latticebuild.c
vq/latticepare.c

index cf1068d..1a7cadd 100644 (file)
@@ -13,7 +13,7 @@
 
  function: libvorbis backend and mapping structures; needed for 
            static mode headers
- last mod: $Id: backends.h,v 1.10 2000/06/14 08:19:22 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.11 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
@@ -54,12 +54,10 @@ typedef struct{
   vorbis_info_floor     *(*unpack)(vorbis_info *,oggpack_buffer *);
   vorbis_look_floor     *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
                                   vorbis_info_floor *);
-  vorbis_echstate_floor *(*state) (vorbis_info_floor *);
   void (*free_info) (vorbis_info_floor *);
   void (*free_look) (vorbis_look_floor *);
-  void (*free_state)(vorbis_echstate_floor *);
   int  (*forward)   (struct vorbis_block *,vorbis_look_floor *,
-                    double *,double *,vorbis_echstate_floor *);
+                    double *,double *);
   int  (*inverse)   (struct vorbis_block *,vorbis_look_floor *,
                     double *);
 } vorbis_func_floor;
index 431d4ae..f4e35bb 100644 (file)
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- function: static codebook autogenerated by vq/somethingorother
+ function: static codebook autogenerated by vq/latticebuild
 
  ********************************************************************/
 
 #include "vorbis/codebook.h"
 
 static long _vq_quantlist_lsp12_0[] = {
-       74,
-       72,
-       73,
-       79,
-       73,
-       73,
-       71,
-       78,
-       79,
-       77,
-       80,
-       72,
-       80,
-       72,
-       81,
-       73,
-       66,
-       71,
-       73,
-       67,
-       80,
-       74,
-       83,
-       83,
-       81,
-       82,
-       71,
-       75,
-       79,
-       65,
-       65,
-       80,
-       73,
-       65,
-       69,
-       74,
-       52,
-       46,
-       45,
-       82,
-       84,
-       78,
-       22,
-       50,
-       254,
-       48,
-       46,
-       23,
-       91,
-       78,
-       72,
-       73,
-       73,
-       63,
-       75,
-       67,
-       86,
-       80,
-       68,
-       68,
-       67,
-       86,
-       79,
-       66,
-       70,
-       82,
-       88,
-       70,
-       76,
-       82,
-       76,
-       65,
-       82,
-       71,
-       89,
-       9,
-       101,
-       155,
-       65,
-       79,
-       64,
-       31,
-       42,
-       47,
-       92,
-       125,
-       75,
-       94,
-       95,
-       98,
-       66,
-       71,
-       63,
-       65,
-       60,
-       75,
-       67,
-       81,
-       90,
-       75,
-       71,
-       92,
-       49,
-       57,
-       56,
-       82,
-       65,
-       79,
-       19,
-       220,
-       109,
-       68,
-       72,
-       88,
-       62,
-       84,
-       84,
-       63,
-       79,
-       81,
-       67,
-       47,
-       53,
-       18,
-       116,
-       195,
-       91,
-       76,
-       86,
-       71,
-       94,
-       78,
-       65,
-       63,
-       84,
-       93,
-       83,
-       82,
-       54,
-       73,
-       71,
-       50,
-       65,
-       68,
-       21,
-       164,
-       149,
-       69,
-       87,
-       65,
-       102,
-       95,
-       73,
-       69,
-       93,
-       89,
-       48,
-       205,
-       164,
-       98,
-       82,
-       66,
-       50,
-       59,
-       174,
-       108,
-       83,
-       64,
-       75,
-       57,
-       80,
-       72,
-       61,
-       91,
-       99,
-       204,
-       74,
-       58,
-       70,
-       187,
-       62,
-       67,
-       59,
-       125,
-       93,
-       59,
-       75,
-       93,
-       59,
-       92,
-       76,
-       60,
-       96,
-       86,
-       86,
-       110,
-       88,
-       38,
-       81,
-       86,
-       94,
-       64,
-       87,
-       90,
-       56,
-       81,
-       75,
-       230,
-       67,
-       60,
-       58,
-       71,
-       88,
-       3,
-       141,
-       89,
-       71,
-       56,
-       54,
-       77,
-       56,
-       68,
-       66,
-       96,
-       68,
-       73,
-       72,
-       105,
-       58,
-       92,
-       99,
-       81,
-       112,
-       61,
-       98,
-       54,
-       59,
-       81,
-       72,
-       101,
-       75,
-       58,
-       58,
-       95,
-       126,
-       32,
-       113,
-       59,
-       57,
-       57,
-       148,
-       61,
-       71,
-       46,
-       74,
-       57,
-       149,
-       131,
-       83,
-       56,
-       82,
-       128,
-       98,
-       106,
-       81,
-       100,
-       64,
-       88,
-       56,
-       57,
-       59,
-       42,
-       123,
-       81,
-       113,
-       78,
-       38,
+       0,
        3,
-       199,
-       69,
-       111,
-       87,
-       61,
-       133,
-       111,
-       112,
-       58,
-       72,
-       96,
-       132,
-       87,
-       90,
-       63,
-       68,
-       98,
-       90,
-       135,
-       156,
-       90,
-       35,
-       93,
-       41,
-       63,
-       140,
-       251,
-       72,
-       60,
-       77,
-       92,
-       69,
-       64,
-       107,
-       33,
-       99,
-       123,
-       123,
-       65,
-       69,
-       49,
-       100,
-       64,
-       80,
-       78,
-       118,
-       87,
-       54,
-       69,
-       25,
-       234,
-       38,
-       10,
-       194,
+       6,
+       7,
+       8,
        9,
-       79,
-       91,
-       123,
-       56,
-       61,
-       98,
-       148,
-       69,
-       0,
-       101,
-       68,
-       39,
-       148,
-       37,
-       59,
-       133,
-       37,
-       58,
-       99,
-       145,
+       10,
+       11,
+       13,
+       15,
        19,
-       53,
-       78,
-       101,
-       80,
-       70,
-       55,
-       150,
-       114,
-       60,
-       69,
-       52,
-       103,
-       34,
-       139,
-       77,
-       76,
-       83,
-       49,
-       37,
-       170,
-       17,
-       76,
-       52,
-       143,
-       60,
-       91,
-       64,
-       47,
-       101,
-       50,
+       25,
+       40,
 };
 
 static long _vq_lengthlist_lsp12_0[] = {
-        3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7,
-        7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9,
-        9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,
-       10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
-       11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,
-       12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
-       12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
-       13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,
+        8,14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,15, 0, 0,
+        0, 0,16, 0, 0, 0, 0, 0,17, 0,17, 0, 0,17, 0, 0,
+       17, 0, 0,17, 0, 0, 0, 0,17,17, 0, 0, 0,17, 0, 0,
+        0, 0, 0, 0, 0,17,17, 0, 0, 0, 0, 0,17, 0, 0, 0,
+        0, 0,17, 0, 0, 0, 0, 0,17, 0, 0, 0, 0, 0,15, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0,16, 0, 0, 0,
+        0, 0,17, 0,17, 0, 0, 0, 0,16, 0, 0,17, 0, 0, 0,
+        0, 0,17, 0,17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       17, 0, 0, 0, 0, 0, 0,17, 0, 0,16,16,16,15, 0, 0,
+        0, 0, 0, 0, 0, 0,17,17,15,17,16,16,16,14,15,17,
+       16, 0, 0, 0, 0, 0, 0, 0,15,17,15,17,17, 0, 0, 0,
+        0, 0, 0,17,17, 0,17,12,17,16,16, 0,16, 0,15, 0,
+        0, 0, 0, 8, 0, 0,14,14,15,16,14,14,17, 0, 0,17,
+        0,16, 0,17,16,17, 0, 0,16,17, 0, 0, 0, 0,17,17,
+        0,15,17, 0,17, 0,17,17,17, 0, 0, 0,17,17,17, 0,
+        0,16,17,17,17, 0, 0,17,15, 0,17,15,15, 0,17,15,
+        0,17, 0, 0, 0, 0,17, 0,17,16,16,15,17,16,16, 0,
+        0,17, 0, 0, 0,17,16,15,17,17,16,16,17, 0, 0,16,
+       16, 0,16,16, 0, 0,15, 0,16, 0, 0, 0, 0, 0, 0, 0,
+       17,17,17, 0,16,17,17, 0, 0, 0,16,16, 0,17,17,17,
+        0, 0, 0, 0, 0,16,17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0,14, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0,13,
+       11,16, 0, 0, 0, 0,17,16,17,17,17, 0, 0,13,15,14,
+       14,14,13,14,14,17,15, 0, 0,16,14,15,12,12,12,13,
+       14,14,17, 0,17, 0,16,14,14,12,12,11,11,12,13,15,
+        0,17, 0, 0,16,15,13,11,10, 9,11,13,14,15, 0, 0,
+       17,15,14,13,11,10,10,10,13,16,17, 0, 0, 0,17,16,
+       13,11,10,10,11,13,15,16, 0, 0,17, 0,15,13,13,12,
+       13,13,14,16, 0, 0, 0,17,16,16,17,15,15,16, 0,15,
+       16,15,17, 0, 0,17,16, 0, 0,17, 0,16, 0,16, 0,17,
+        0, 0,15,14,17, 0, 0, 0, 0, 0, 0,17, 0, 0, 0,17,
+       17,17,16,16, 0,14, 8, 0, 0,17, 0,17,15, 0, 0, 0,
+        0, 0,17,17, 0, 0, 0, 0, 0,17,17,17, 0, 0, 0,15,
+       17,16,17, 0,17,17,16,14,12,12,12,12,14,17,16,17,
+        0, 0, 0,13,14,12,10,10,11,12,15,17, 0, 0, 0,17,
+       13,13,11, 9, 8, 8,10,13,15, 0, 0, 0, 0,13,12,10,
+        8, 7, 7, 9,12,16, 0, 0, 0, 0,14,13,10, 8, 7, 8,
+        9,12, 0, 0, 0, 0, 0,15,14,11, 9, 9, 9,10,13, 0,
+       17, 0, 0, 0, 0,14,11,12,12,12,13,16,16, 0, 0, 0,
+        0,17,15,15,17,16,16,16, 0,17, 0, 0, 0, 0, 0, 0,
+       16, 0,17, 0, 0,17, 0, 0, 0, 0, 0,15, 0,17, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0,17,17, 0,17,17, 0, 0, 0,
+        0, 0, 0, 0, 0,17, 0, 0, 0, 0, 0, 0, 0,17, 0, 0,
+        0,17, 0,15,14,16,16, 0,17, 0,16, 0,17, 0, 0,16,
+       14,12,11,11,11,12,15,17, 0, 0, 0, 0,15,13,11, 9,
+        9,10,12,15, 0,17, 0, 0, 0,13,11, 8, 7, 6, 7, 9,
+       12,14, 0, 0, 0, 0,14, 9, 5, 5, 5, 6, 8,11,16, 0,
+        0, 0, 0,17,10, 8, 7, 6, 7, 8,11,15, 0, 0, 0, 0,
+        0,13,10, 8, 7, 8, 9,12,17,17, 0, 0, 0,17,13,12,
+       11,11,12,12,17,17, 0, 0, 0,17, 0,15,14,16,15,14,
+       17,17, 0, 0, 0, 0, 0, 0, 0, 0,17,15,17, 0, 0, 0,
+        0, 0, 0, 0,17,15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0,
+        0,17, 0, 0, 0, 0, 0, 0, 0, 0, 0,16,14,16, 0,17,
+       16,15, 0, 0, 0, 0, 0, 0,15,14,13,11,11,12,13,16,
+       16, 0, 0, 0, 0,16,13,11, 9, 8,10,11,15,15, 0, 0,
+        0, 0, 0,11, 7, 5, 5, 7, 9,12,16, 0, 0, 0, 0,16,
+       10, 5, 4, 4, 5, 8,11,15, 0, 0, 0, 0,13,10, 6, 5,
+        5, 6, 8,11, 0, 0, 0, 0, 0,15,12, 9, 7, 7, 8, 9,
+       14,17, 0, 0, 0, 0, 0,13,12,10,11,12,13, 0,17, 0,
+        0, 0, 0, 0,14,15,14,15,15,16, 0, 0, 0, 0, 0, 0,
+        0,14, 0, 0, 0, 0,17, 0, 0, 0, 0, 0,17,17,17, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0,17, 0,17, 0,17, 0, 0, 0, 0, 0,
+        0, 0, 0, 0,17,17,17,17,17,16,17,16, 0, 0,17, 0,
+        0,16,14,13,12,12,13,13,16,17, 0, 0, 0, 0, 0,13,
+       11, 9, 9,10,11,14,17, 0, 0, 0, 0,17,13, 9, 7, 6,
+        8,10,13, 0, 0, 0, 0,17,15,11, 8, 5, 5, 7, 9,12,
+        0,16, 0, 0, 0,15,11, 7, 5, 6, 7, 9,12, 0, 0, 0,
+        0, 0,15,11, 8, 7, 7, 8,10,14, 0, 0, 0, 0, 0,17,
+       13,11,10,11,12,14,17,16, 0, 0, 0, 0,17,14,14,15,
+       17, 0,15, 0,17, 0, 0, 0, 0,16,15,17,17, 0, 0,17,
+        0, 0, 0, 0, 0,17,16,17, 0, 0,12, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17,16,
+       17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13, 0,
+        0, 0,17, 0, 0, 0, 0, 0, 0, 0,15,13,13,12,13,13,
+       13, 0, 0,17, 0, 0, 0,16,14,13,11,11,11,13,17, 0,
+       17, 0, 0, 0,17,13,10, 9, 9,10,12,16, 0, 0, 0, 0,
+       17,14,12, 9, 8, 8, 9,11,14, 0, 0, 0, 0, 0, 0,10,
+        9, 8, 8, 9,11,15, 0, 0, 0, 0, 0,17,10, 9, 8, 8,
+        9,11,16, 0, 0, 0, 0, 0,15,11,11,11,13,15,15, 0,
+       14, 0, 0, 0, 0,15,13,15,14,17,15,16,17, 0, 0, 0,
+        0, 0,16,16,15, 8,15,14, 0,17, 0, 0, 0, 0,17,15,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,16, 0, 0,17, 0, 0, 0,
+       17, 0,17, 0, 0,17,17,16, 0,17,16, 0,16, 0,17, 0,
+       17, 0,17,16,14,12,12,14,17,15,17,17, 0, 0, 0, 0,
+        0,15,14,13,13,14, 0,16, 0, 0, 0, 0, 0, 0,14,12,
+       12,13,14,14, 0,17, 0, 0, 0, 0,16,15,12,12,13,13,
+       15,17, 0, 0, 0, 0,17,16,13,12,12,13,14, 0, 0, 0,
+        0, 0, 0,17,15,13,13,12,13,16,17, 0,17, 0, 0, 0,
+        0,14,13,14,15,16, 0, 0,17,17, 0, 0, 0, 0,17,14,
+       15,14,14, 0,17, 0, 0, 0, 0, 0, 0,16,15,16, 0,15,
+       17, 0,15, 0, 0, 0, 0,15, 0, 0, 0, 0, 0, 0, 0,17,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0,17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17,
+       17, 0,17, 0, 0,17, 0,17, 0, 0, 0,17,17,16,17, 0,
+       17,16, 0, 0, 0, 0, 0, 0, 0,17, 0,15, 0,15, 0, 0,
+        0,17,17, 0, 0, 0,15,15,17,16,17,16, 0, 0, 0, 0,
+        0, 0, 0, 0, 0,15,17, 0,17,15, 0, 0, 0, 0, 0, 0,
+       16,15,15, 0, 0, 0,17, 0, 0, 0, 0, 0, 0,17,14,14,
+       16,16,17,16, 0, 0, 0, 0, 0, 0,15,14,14,17, 0,17,
+        0, 0, 0, 0, 0, 0, 0,16,15,17, 0,17, 0, 0,17, 0,
+        0, 0, 0, 0,16,17,17, 0, 0,17, 0, 0, 0, 0, 0, 0,
+       17,16,15, 0, 0, 0, 0, 0, 0,17, 0, 0, 0,17, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,16,16, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0,15,15, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0,15, 0, 0,17,16, 0, 0, 0, 0, 0, 0,
+        0, 0, 0,16, 0, 0,17, 0, 0, 0, 0, 0, 0, 0, 0,16,
+       15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17,17, 0,17,
+        0, 0,17, 0, 0, 0, 0, 0, 0,15,17, 0,17, 0, 0, 0,
+        0,17, 0, 0, 0,16,17, 0, 0, 0, 0, 0,16,17, 0, 0,
+        0, 0, 0,15,17, 0, 0, 0,17, 0, 0, 0, 0, 0, 0,17,
+       16,16, 0,17, 0,17, 0, 0, 0, 0, 0, 0, 0,17,17,16,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0,17, 0,16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0,17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       17,17, 0, 0, 0, 0,17,17, 0, 0, 0, 0, 0, 0,17, 0,
+        0, 0,17, 0, 0, 0, 0, 0, 0, 0,17, 0, 0, 0, 0,17,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0,17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,16,
+       17, 0, 0, 0, 0, 0,17, 0, 0, 0, 0,17, 0, 0, 0,17,
+        0, 0, 0, 0, 0, 0, 0, 0,17,16, 0,17, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0,17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17,17, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0,16,16, 0, 0, 0, 0, 0, 0,
+         0, 0, 0, 0, 0,
 };
 
 static static_codebook _vq_book_lsp12_0 = {
-       3, 128,
+       3, 2197,
        _vq_lengthlist_lsp12_0,
-       2, 1602090201, 1593036045, 8, 1,
+       1, 1605579571, 1597274849, 6, 1,
        _vq_quantlist_lsp12_0,
        NULL,
        NULL,
index 21f8033..6bed1d4 100644 (file)
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- function: static codebook autogenerated by vq/somethingorother
+ function: static codebook autogenerated by vq/latticebuild
 
  ********************************************************************/
 
 #include "vorbis/codebook.h"
 
 static long _vq_quantlist_lsp30_0[] = {
-       54,
-       53,
-       52,
-       50,
-       55,
-       54,
-       53,
-       50,
-       55,
-       55,
-       56,
-       51,
-       53,
-       57,
-       56,
-       51,
-       49,
-       52,
-       53,
-       53,
-       46,
-       55,
-       60,
-       54,
-       48,
-       51,
-       60,
-       50,
-       56,
-       60,
-       58,
-       49,
-       57,
-       59,
-       55,
-       52,
-       63,
-       55,
-       53,
-       47,
-       58,
-       48,
-       54,
-       49,
-       61,
-       60,
-       47,
-       52,
-       45,
-       53,
-       54,
-       57,
-       47,
-       49,
-       51,
-       61,
-       48,
-       55,
-       55,
-       44,
-       52,
-       47,
-       47,
-       61,
-       52,
-       48,
-       47,
-       54,
-       63,
-       45,
-       60,
-       54,
-       55,
-       64,
-       59,
-       51,
-       46,
-       59,
-       58,
-       52,
-       61,
-       45,
-       50,
-       49,
-       41,
-       59,
-       60,
-       55,
-       44,
-       59,
-       50,
-       59,
-       64,
-       63,
-       57,
-       62,
-       49,
-       66,
-       53,
-       44,
-       80,
-       53,
-       46,
-       63,
-       56,
-       33,
-       51,
-       61,
-       54,
-       64,
-       45,
-       38,
-       55,
-       54,
-       50,
-       42,
-       59,
-       65,
-       60,
-       50,
-       55,
-       50,
-       63,
-       59,
-       43,
-       57,
-       47,
-       76,
-       45,
-       44,
-       50,
-       64,
-       55,
-       58,
-       64,
-       41,
-       46,
-       55,
-       58,
-       57,
-       42,
-       43,
-       72,
-       61,
-       50,
-       29,
-       44,
-       35,
-       49,
-       52,
-       57,
-       68,
-       54,
-       42,
-       31,
-       39,
-       43,
-       47,
-       61,
-       31,
-       44,
-       53,
-       33,
-       57,
-       66,
-       49,
-       70,
-       54,
-       53,
-       59,
-       43,
-       38,
-       78,
-       69,
-       46,
-       58,
-       43,
-       59,
-       62,
-       43,
-       50,
-       40,
-       51,
-       57,
-       66,
-       46,
-       64,
-       47,
-       66,
-       42,
-       65,
-       62,
-       47,
-       37,
-       48,
-       55,
-       40,
-       46,
-       47,
-       71,
-       65,
-       58,
-       39,
-       55,
-       66,
-       62,
-       58,
-       41,
-       87,
-       57,
-       53,
-       36,
-       34,
-       59,
-       52,
-       42,
-       66,
-       49,
-       48,
-       38,
-       57,
-       68,
-       42,
-       74,
-       50,
-       59,
-       42,
-       46,
-       49,
-       44,
-       39,
-       47,
-       56,
-       68,
-       36,
-       69,
-       75,
-       65,
-       45,
-       59,
-       54,
-       56,
-       37,
-       61,
-       43,
-       61,
-       47,
-       71,
-       43,
-       61,
-       45,
-       46,
-       64,
-       67,
-       65,
-       64,
-       46,
-       45,
-       44,
-       68,
-       47,
-       50,
-       50,
-       39,
-       37,
-       59,
-       58,
-       53,
-       53,
-       37,
-       66,
-       57,
-       42,
-       32,
-       67,
-       60,
-       39,
-       83,
-       69,
-       39,
-       65,
-       60,
-       38,
-       65,
-       69,
-       65,
-       46,
-       37,
-       32,
-       62,
-       73,
-       57,
-       69,
-       63,
-       35,
-       75,
-       79,
-       44,
-       62,
-       71,
-       39,
-       65,
-       52,
-       57,
-       57,
-       73,
-       62,
-       59,
-       73,
        0,
        5,
-       8,
-       16,
-       16,
-       58,
-       65,
-       41,
-       58,
-       38,
-       65,
-       47,
-       41,
-       57,
-       39,
-       64,
-       52,
-       38,
-       47,
-       64,
-       41,
-       58,
-       29,
-       49,
-       62,
-       46,
-       38,
-       59,
-       32,
-       56,
-       43,
-       55,
-       73,
-       37,
-       72,
-       51,
-       55,
-       51,
-       71,
-       71,
-       47,
-       36,
-       79,
-       61,
-       67,
-       73,
-       53,
-       46,
-       126,
-       99,
-       73,
-       95,
-       80,
-       64,
-       33,
-       177,
-       70,
-       0,
-       87,
-       116,
-       76,
-       59,
-       46,
-       36,
-       122,
-       63,
-       6,
-       26,
-       141,
+       10,
+       11,
+       12,
+       13,
+       14,
+       15,
+       17,
+       19,
        21,
+       23,
+       27,
        31,
-       71,
-       94,
-       1,
-       254,
+       35,
 };
 
 static long _vq_lengthlist_lsp30_0[] = {
-        2, 3, 3, 3, 4, 4, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
-        7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
-        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,
-       10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,
-       11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
-       12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
-       12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,14,
-       14,14,14,14,14,15,15,15,15,15,15,16,16,16,17,17,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0,19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       20,19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0,20,19, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0,19,17,17, 0, 0, 0, 0, 0, 0, 0, 0,
+        0,20, 0,18,15,16,17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0,18,15,16,18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0,15,18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0,19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0,18,17,15,15,17,17,16,17,17, 0,
+        0, 0, 0, 0, 0, 0,17,14,14,16,17,16,17,18, 0, 0,
+        0, 0, 0, 0, 0,17,14,14,15,16,16,16,19, 0, 0, 0,
+        0, 0, 0, 0,18,15,15,17,19,17,18, 0, 0, 0, 0, 0,
+        0,16, 0,19,17,17,18, 0,17,19, 0, 0, 0, 0, 0, 0,
+        0, 0,18,16,17, 0,16,15,17,19, 0, 0, 0, 0, 0, 0,
+        0, 0,16,18,16,14,15,17,18, 0, 0, 0, 0, 0, 0, 0,
+        0,18,18,16,14,16,16,18, 0, 0, 0, 0, 0, 0,17,17,
+       17,17,19,17,17,17,17, 0, 0, 0, 0,19,19, 0,18,16,
+       18,17,18,17,19,17, 0, 0, 0,18, 0, 0,19,19, 0,15,
+       15,15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,18,19, 0,
+       19, 0,19, 0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0,19, 0, 0,16,16,17,16,16,16,18,
+        0, 0, 0, 0, 0, 0, 0,19,17,16,18,18,18,18, 0, 0,
+        0, 0, 0, 0, 0, 0,18,16,16,18,18,16,18, 0, 0, 0,
+        0, 0, 0, 0, 0, 0,18,16,16,18,16,18, 0, 0, 0, 0,
+        0, 0, 0, 0, 0,19,17,19,17,15,16, 0, 0, 0, 0, 0,
+        0, 0, 0, 0,17,18, 0,17,14,15, 0, 0, 0, 0, 0, 0,
+        0, 0,19,18,18,18,16,15,17,19, 0, 0, 0, 0, 0, 0,
+        0,18,16,18,16,18,18,17,19, 0, 0, 0, 0, 0, 0,19,
+       19,18, 0,18,18,18,17,17, 0, 0, 0,19,19, 0,17,17,
+       17,18,15,17,17,18,18, 0, 0, 0, 0, 0, 0,18, 0,16,
+       15,16,18,17, 0,19, 0,19,17,18,18, 0, 0, 0,17, 0,
+       18,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,18,16,15,18,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0, 0,
+        0, 0, 0, 0, 0, 0,18,17,17,15,14,14,15,16,16,17,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,14,15,18,19,18, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0,16,16,17, 0,17,19, 0, 0,
+        0, 0, 0, 0, 0, 0, 0,18,15,17, 0,16,18, 0, 0, 0,
+        0, 0, 0, 0, 0, 0,15,14,18,19,16,17, 0, 0, 0, 0,
+        0, 0, 0, 0,19,17,15,18,18,16,17,19, 0, 0, 0, 0,
+        0, 0, 0,19,17,18,16,16,16,17,17, 0, 0, 0, 0, 0,
+        0, 0,19,17,16,16,16,16,15,17, 0, 0, 0, 0, 0, 0,
+        0,19,17,19,17,17,16,15,18, 0, 0, 0, 0,19,17, 0,
+       19,17,16,15,15,15,16,18, 0, 0, 0, 0, 0,19,18,17,
+       15,14,15,16,16, 0, 0, 0,18,16,17,19, 0,18,17,16,
+       15,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0,18, 0,15,14,
+       17, 0,19, 0,19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0,18,19,17,
+       19, 0, 0, 0, 0, 0, 0,19,16,14,15,15,15,17,18,18,
+       19, 0, 0, 0, 0, 0, 0, 0, 0,19,17,15,17,19, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,18,15,17,19,19,19, 0,
+        0, 0, 0, 0, 0, 0, 0, 0,17,15,17, 0,18, 0, 0, 0,
+        0, 0, 0, 0, 0,19,17,15,14,18,18,18,19, 0, 0, 0,
+        0, 0, 0, 0, 0, 0,16,16,17,19,17,18, 0, 0, 0, 0,
+        0, 0, 0, 0,18,17,16,16,15,16,15,18, 0, 0, 0, 0,
+        0, 0, 0, 0,15,15,15,15,15,17,18, 0, 0, 0, 0,19,
+        0, 0,18,17,16,14,14,16,16,18, 0, 0, 0,19, 0,19,
+       19,18,18,14,13,13,15,19,18, 0, 0, 0, 0,19, 0,16,
+       15,15,15,14,11,15, 0,19, 0,19,18, 0, 0,19,17,17,
+       14,14,12,13,19, 0, 0, 0, 0, 0, 0, 0,18,17,17,14,
+       14,17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0,18,18,16,15,15,14,14,15,15,
+       17,18, 0, 0, 0, 0, 0, 0,18,16,15,14,14,16,19,17,
+       17,19, 0, 0, 0, 0, 0, 0, 0, 0, 0,18,17,17,18,17,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0,17,17,19,19, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,18,16,18,18,18,19, 0,
+        0, 0, 0, 0, 0, 0, 0, 0,18,16,17,18,19,19, 0, 0,
+        0, 0, 0, 0, 0, 0,18,16,17,19,17,17,18, 0, 0, 0,
+        0, 0, 0, 0, 0,19,16,14,15,14,15,17,18, 0, 0, 0,
+        0, 0, 0, 0, 0,15,14,14,14,14,17,17, 0, 0, 0, 0,
+        0, 0,19,19,17,14,12,12,15,17,18, 0, 0, 0, 0,18,
+        0,18,17,15,14,12,12,13,18,19, 0, 0,17, 0,17,17,
+       18,16,15,14,12,12,14, 0, 0, 0,19, 0,18, 0,19, 0,
+       16,15,13,12,14,18, 0, 0, 0, 0, 0, 0,17,19,19,16,
+       13,13,16,19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,18,16,
+       16,17,18, 0, 0, 0, 0, 0,17,15,14,14,14,14,14,15,
+       15,15,17, 0, 0, 0, 0,15,16,16,17,17,14,13,16, 0,
+        0,17, 0, 0, 0, 0,17,18,18,18, 0,18,16,18,18,17,
+       19,19, 0, 0, 0, 0, 0, 0, 0, 0,17,17,16,17,17,18,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,19,17,15,15,17,18, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,18,16,15,16,16, 0, 0,
+        0, 0,18, 0, 0, 0,19,19,15,15,16,15,15,19, 0,16,
+        0, 0, 0, 0, 0,19,17,14,12,13,12,12,17, 0, 0, 0,
+        0, 0, 0,19,18,18,13,13,12,12,13,17,19, 0, 0, 0,
+        0,18,19,19,16,13,11,11,10,12,16,19, 0, 0, 0, 0,
+       19,18,16,13,12,11,11,10,12,17, 0, 0,19,17,17,17,
+       18,17,15,13,12,10,11,14,17,19, 0,19,19,18,18,17,
+       17,15,15,11,12,14,18,17, 0, 0, 0,19,18,18,19,18,
+       14,13,13,16,18,19, 0,18, 0, 0, 0, 0, 0, 0,19, 0,
+       19,18,18,18,19, 0, 0, 0, 0,19,17,16,15,15,15,15,
+       16,16,14,17, 0, 0, 0,17,13,13,13,14,14,13,14,15,
+       16,16,17, 0, 0,16,19,16,17,16,14,16,17,16,17,17,
+       17,18, 0, 0,18, 0,18, 0,19,15,15,17,15,15,15,15,
+       17, 0, 0, 0,18,17,19,16,15,15,15,15,14,14,13,15,
+        0, 0, 0,17,17, 0,19, 0,19,16,14,14,13,13,15,19,
+        0, 0,18,17, 0, 0,18, 0,16,13,13,12,12,13,17,19,
+        0, 0,18,18, 0,18,17,14,11,10,10,10,11,16,19, 0,
+        0,17,18,19,19,14,14,10, 8, 8, 8,11,15,18, 0,19,
+       18,18,19,17,15,13,10, 8, 7, 8,11,13,17, 0,18, 0,
+       16,15,14,14,12,10, 8, 8, 9,11,13,14, 0,17,16,17,
+       16,15,15,14,11,10,10,10,13,14,14, 0, 0, 0,17,16,
+       17,17,15,12,11,12,15,15,14,16, 0, 0,17,19, 0, 0,
+       16,14,12,13,18,18,15,16,19, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0,19,18, 0, 0, 0, 0, 0, 0,18,19, 0,16,
+       16,15,16,15,16,19, 0, 0, 0,17,18,15,14,15,17,18,
+       16,16,15,17,19, 0, 0, 0,14,19,15,13,14,14,15,18,
+       15,16,18, 0, 0, 0,18,12,19,14,14,15,14,15,14,15,
+       15,16,18, 0, 0,18,13,15,17,18,17,16,14,14,13,14,
+       15,19, 0, 0, 0,15,16,17, 0,18,15,14,14,12,13,14,
+       19, 0, 0, 0, 0,19,16,15,16,14,13,11,11,11,12,17,
+        0, 0,15,14,16,17,16,14,12,10, 9, 8, 8,11,16,17,
+        0,14,13,14,13,13,14,11, 8, 6, 5, 6,10,13,14, 0,
+       15,15,15,15,14,13,10, 7, 4, 4, 6,10,12,14, 0,17,
+       16,15,14,14,13,10, 8, 6, 6, 7,10,12,14, 0,17,15,
+       15,14,14,14,12,10,10,10,10,12,13,17, 0,19,16,17,
+       17,16,17,14,13,13,14,14,14,16,19, 0,18, 0, 0,18,
+       18,16,14,12,14,16,16,15,18, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       17,17, 0,17,17,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       18,18,17,15,17, 0, 0, 0, 0, 0, 0, 0, 0,17,15,14,
+       16,18,17,17,19, 0, 0, 0, 0,19,17,19,16,13,13,16,
+       15,16,14, 0, 0, 0, 0,19,16,16,15,16,14,14,15,14,
+       14,13,18, 0, 0, 0, 0,17,15,14,14,13,12,13,12,12,
+       13,19, 0, 0,18,17,18,15,13,13,12,11,11,10,10,12,
+       18,17, 0,14,12,14,13,13,12,11, 9, 8, 7, 8,11,15,
+       17, 0,12,12,13,12,12,11,10, 7, 5, 4, 6,10,14,16,
+        0,13,13,14,12,12,11,10, 6, 4, 3, 5,10,13,16, 0,
+       13,13,13,12,12,11,10, 7, 6, 6, 7, 9,12,16, 0,15,
+       14,13,14,14,13,12,10,10,10,10,11,14,19, 0,16,16,
+        0,18,16,15,14,13,13,14,13,14,17, 0, 0,19, 0,19,
+       17,17,15,12,12,14,16,15,15,17,16, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0,19, 0, 0,18,17, 0,19, 0, 0, 0, 0, 0, 0, 0,
+        0, 0,19,17,16,14,19, 0, 0,19, 0, 0, 0, 0,19,18,
+       16,17,18,16,16,18,19, 0, 0, 0, 0, 0,19,19,16,15,
+       15,16,15,14,19,19, 0, 0, 0, 0, 0, 0,17,15,14,14,
+       14,14,13,19,19, 0,19, 0, 0, 0,17,17,14,13,13,13,
+       13,13,18,19, 0,18,18,18,17,15,14,13,12,11,11,10,
+       12,17,19, 0,14,13,14,15,13,12,11, 9, 8, 8, 8,12,
+       16,19, 0,12,12,15,13,12,12,10, 8, 6, 6, 7,11,14,
+       17, 0,11,11,13,12,12,11,10, 7, 6, 6, 7,10,13,18,
+       19,10,12,13,13,12,11, 9, 7, 7, 7, 7, 9,12,15, 0,
+       13,12,14,14,14,13,11,10,10,10,10,11,14,17, 0,16,
+       13,17,15,14,13,12,12,13,13,12,13,16,19, 0, 0,19,
+       17,16,15,12,11,11,14,15,14,14,16,17, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0,17, 0,19, 0, 0, 0, 0, 0, 0,
+       19,18,18,17,16,16,15,17, 0, 0, 0, 0, 0, 0, 0, 0,
+        0,18,17,17,18,16,18, 0, 0, 0, 0, 0,19,18,19,17,
+       16,17,18,16,15,19, 0, 0, 0, 0, 0, 0, 0, 0,17,15,
+       15,17,15,14, 0, 0, 0, 0, 0,19, 0,19,18,17,15,15,
+       15,15,14,18, 0, 0,17, 0,17,18,17,16,14,12,12,13,
+       13,14,16,18, 0,15,15,17,17,14,13,12,11,10,11,11,
+       13,15,19, 0,13,12,15,15,13,13,12,10, 9,10,11,12,
+       14,18, 0,13,11,15,14,13,13,11,10,10,10,10,12,14,
+       18, 0,13,11,14,13,12,13,12,11,10,11,11,12,14,18,
+       18,15,11,14,13,12,13,12,11,12,12,12,13,14,16, 0,
+        0,12,14,15,14,13,12,12,13,13,12,14,16,19, 0, 0,
+       14,14,15,13,12,12,14,16,15,14,15,16,16, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0,19, 0, 0,19, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0,19,19, 0, 0,18, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0,18, 0, 0, 0,17,19, 0, 0, 0, 0, 0, 0,19, 0,18,
+       18, 0, 0,18,15, 0, 0, 0,18, 0, 0, 0,19,18,16,17,
+        0,19,17,15, 0, 0, 0,19,19, 0,18,16,16,15,16,18,
+       16,15,15,18, 0, 0,17, 0,18,16,14,14,16,17,16,16,
+       15,15,17,19, 0,18,15,16,15,14,15,15,15,15,14,14,
+       14,16,19,19,16,14,15,14,15,15,14,13,14,14,13,14,
+       16, 0,19,17,13,15,13,13,15,14,14,14,14,13,13,17,
+        0, 0,17,12,15,15,15,16,14,13,14,14,14,13,17, 0,
+        0,18,12,13,15,15,15,14,14,14,13,14,13,17, 0, 0,
+        0,13,13,13,13,15,16,18,18,17,18,18, 0,17, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0,19, 0,18, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0, 0, 0, 0, 0,19,
+        0,19, 0, 0,19, 0, 0, 0,19, 0, 0, 0, 0, 0, 0, 0,
+        0, 0,18,19, 0, 0, 0,18, 0, 0, 0, 0,19,18, 0, 0,
+        0,19,18, 0, 0,18,18, 0, 0,19,19, 0,17,18,18,18,
+       17,16, 0, 0, 0, 0,17, 0, 0,18,19,18,18,18,17,16,
+       14,18, 0, 0,18,16,19, 0, 0, 0,16,15,17,15,14,13,
+       18, 0, 0, 0,13,17,17,19,19,18,17,19,16,15,13, 0,
+        0,19,19,13,14,15,17,18,18, 0,18,18,17,17, 0, 0,
+       16,17,13,13,15,16,19,18, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 };
 
 static static_codebook _vq_book_lsp30_0 = {
-       3, 128,
+       3, 3375,
        _vq_lengthlist_lsp30_0,
-       2, 1601492961, 1590858881, 8, 1,
+       1, 1602140242, 1592812110, 6, 1,
        _vq_quantlist_lsp30_0,
        NULL,
        NULL,
index 8de254f..804a1eb 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: libvorbis codec headers
- last mod: $Id: codec.h,v 1.20 2000/07/07 01:52:24 xiphmont Exp $
+ last mod: $Id: codec.h,v 1.21 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
@@ -250,10 +250,6 @@ typedef struct vorbis_dsp_state{
   int      pcm_current;
   int      pcm_returned;
 
-  double  *multipliers;
-  int      envelope_storage;
-  int      envelope_current;
-
   int  eofflag;
 
   long lW;
@@ -270,7 +266,7 @@ typedef struct vorbis_dsp_state{
   int64_t res_bits;
 
   /* local lookup storage */
-  envelope_lookup         ve; /* envelope */    
+  void                   *ve; /* envelope lookup */    
   double                **window[2][2][2]; /* block, leadin, leadout, type */
   vorbis_look_transform **transform[2];    /* block, type */
   codebook               *fullbooks;
index 02bf95b..100df51 100644 (file)
 
  function: libvorbis codec internal types.  These structures are 
            'visible', but generally uninteresting to the developer
- last mod: $Id: internal.h,v 1.6 2000/06/18 12:33:47 xiphmont Exp $
+ last mod: $Id: internal.h,v 1.7 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
 #ifndef _vorbis_internal_h_
 #define _vorbis_internal_h_
 
-/* lookup structures for various simple transforms *****************/
-
-typedef struct {
-  double *window;
-  long winlen;
-  void *fft;
-} envelope_lookup;
-
 /* structures for various internal data abstractions ********************/
 
 typedef struct {
index 9d41c8d..d1cc21f 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: predefined encoding modes
- last mod: $Id: modes.h,v 1.15 2000/06/19 10:05:57 xiphmont Exp $
+ last mod: $Id: modes.h,v 1.16 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
@@ -60,7 +60,7 @@
 /* A farily high quality setting mix */
 static vorbis_info_psy _psy_set0={
   1,/*athp*/
-  1,/*decayp*/
+  0,/*decayp*/
   1,/*smoothp*/
   0,8,0.,
 
@@ -76,12 +76,12 @@ static vorbis_info_psy _psy_set0={
   {-40.,-40.,-60.,-80.,-100.},  
 
   1,/* peakattp */
-  {-12.,-12.,-12.,-16.,-16.},
-  {-12.,-12.,-12.,-16.,-16.},
-  {-12.,-12.,-12.,-16.,-16.},
-  {-12.,-12.,-12.,-16.,-16.},
-  {-12.,-12.,-12.,-16.,-16.},
-  {-10.,-10.,-12.,-16.,-16.},
+  {-12.,-12.,-12.,-16.,-18.},
+  {-12.,-12.,-12.,-16.,-18.},
+  {-12.,-12.,-12.,-16.,-18.},
+  {-12.,-12.,-12.,-16.,-18.},
+  {-12.,-12.,-12.,-16.,-18.},
+  {-10.,-10.,-12.,-16.,-18.},
   {-6.,-8.,-10.,-12.,-12.},
 
   1,/*noisemaskp */
@@ -91,11 +91,11 @@ static vorbis_info_psy _psy_set0={
   {-65.,-65.,-65.,-85.,-85.},
   {-60.,-60.,-60.,-80.,-80.},
   {-60.,-60.,-60.,-80.,-80.},
-  {-52.,-55.,-60.,-80.,-80.},
+  {-60.,-60.,-60.,-80.,-80.},
 
   100.,
 
-  .9998, .9999  /* attack/decay control */
+  .9998, .9998  /* attack/decay control */
 };
 
 /* with GNUisms, this could be short and readable. Oh well */
@@ -113,7 +113,7 @@ static vorbis_info_residue0 _residue_set0={0,128, 64,14,2,
                                           {99,99,99,99,99,99,99,
                                            99,99,99,99,99,99,99}};
 
-static vorbis_info_residue0 _residue_set1={0,768, 64,28,3,
+static vorbis_info_residue0 _residue_set1={0,1024, 64,14,3,
                                           {0,1,1,1,1,1,1,1,1,1,1,1,1,1,
                                            0,1,1,1,1,1,1,1,1,1,1,1,1,1},
                                           {4,5,6,7,8,9,10,11,12,13,14,15,16,
@@ -132,9 +132,7 @@ static vorbis_info_residue0 _residue_set1={0,768, 64,28,3,
                                           {6,6,6,6,6,6,6,6,6,6,6,6,6,6,
                                           6,6,6,6,6,6,6,6,6,6,6,6,6},/*6==64*/
 
-                                          {2,2,2,2,2,2,2,
-                                           2,2,2,2,2,2,2,
-                                           99,99,99,99,99,99,99,
+                                          {99,99,99,99,99,99,99,
                                            99,99,99,99,99,99}};
 
 static vorbis_info_mapping0 _mapping_set0={1, {0,0}, {0}, {0}, {0}, {0}};
@@ -197,7 +195,7 @@ vorbis_info info_A={
   /* psy */
   {&_psy_set0},
   /* thresh sample period, preecho clamp trigger threshhold, range */
-  64, 15, 2 
+  256, 24, 6
 };
 
 #define PREDEF_INFO_MAX 0
index a8c9ef0..9367bc3 100644 (file)
@@ -1,5 +1,5 @@
 # vorbis makefile configured for use with gcc on any platform
-# $Id: Makefile.in,v 1.32 2000/06/26 11:25:32 omnic Exp $
+# $Id: Makefile.in,v 1.33 2000/07/12 09:36:17 xiphmont Exp $
 
 ###############################################################################
 #                                                                             #
@@ -31,14 +31,14 @@ HFILES =    ../include/vorbis/codec.h \
                ../include/vorbis/codebook.h \
                bitwise.h envelope.h lpc.h lsp.h bookinternal.h misc.h\
                psy.h smallft.h window.h scales.h os.h mdct.h registry.h\
-               masking.h sharedbook.h
+               masking.h sharedbook.h iir.h
 LFILES =       framing.o mdct.o smallft.o block.o envelope.o window.o\
                lsp.o lpc.o analysis.o synthesis.o psy.o info.o bitwise.o\
                time0.o floor0.o res0.o mapping0.o registry.o\
-               codebook.o sharedbook.o
+               codebook.o sharedbook.o iir.o
 VF_HFILES = ../include/vorbis/vorbisfile.h ../include/vorbis/codec.h \
                ../include/vorbis/internal.h ../include/vorbis/codebook.h \
-               os.h misc.h
+               os.h misc.h 
 VF_LFILES = vorbisfile.o
 
 PSY_FILES = mdct.o psy.o lpc.o smallft.o window.o psytune.o floor0.o \
index d86cf24..b7152cb 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: single-block PCM analysis mode dispatch
- last mod: $Id: analysis.c,v 1.30 2000/07/07 00:53:10 xiphmont Exp $
+ last mod: $Id: analysis.c,v 1.31 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
@@ -53,9 +53,9 @@ int vorbis_analysis(vorbis_block *vb,ogg_packet *op){
   if(vb->W){
     _oggpack_write(&vb->opb,vb->lW,1);
     _oggpack_write(&vb->opb,vb->nW,1);
-    /*fprintf(stderr,"*");
+    fprintf(stderr,"*");
   }else{
-  fprintf(stderr,".");*/
+  fprintf(stderr,".");
   }
 
   if(_mapping_P[type]->forward(vb,vd->mode[mode]))
@@ -82,6 +82,8 @@ void _analysis_output(char *base,int i,double *v,int n,int bark,int dB){
   sprintf(buffer,"%s_%d.m",base,i);
   of=fopen(buffer,"w");
 
+  if(!of)perror("failed to open data dump file");
+
   for(j=0;j<n;j++){
     if(dB && v[j]==0)
           fprintf(of,"\n\n");
index e86b577..5812f6a 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.34 2000/07/10 06:48:18 xiphmont Exp $
+ last mod: $Id: block.c,v 1.35 2000/07/12 09:36:17 xiphmont Exp $
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
@@ -234,7 +234,7 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
   v->lW=0; /* previous window size */
   v->W=0;  /* current window size */
 
-  /* all vector indexes; multiples of samples_per_envelope_step */
+  /* all vector indexes */
   v->centerW=vi->blocksizes[1]/2;
 
   v->pcm_current=v->centerW;
@@ -255,13 +255,10 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
 int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi){
   _vds_shared_init(v,vi,1);
 
-  /* Initialize the envelope multiplier storage */
+  /* Initialize the envelope state storage */
+  v->ve=calloc(1,sizeof(envelope_lookup));
+  _ve_envelope_init(v->ve,vi);
 
-  v->envelope_storage=v->pcm_storage/vi->envelopesa;
-  v->multipliers=calloc(v->envelope_storage,sizeof(double));
-  _ve_envelope_init(&v->ve,vi->envelopesa);
-
-  v->envelope_current=v->centerW/vi->envelopesa;
   return(0);
 }
 
@@ -289,9 +286,12 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
       free(v->pcm);
       if(v->pcmret)free(v->pcmret);
     }
-    if(v->multipliers)free(v->multipliers);
 
-    _ve_envelope_clear(&v->ve);
+    if(v->ve){
+      _ve_envelope_clear(v->ve);
+      free(v->ve);
+    }
+
     if(v->transform[0]){
       mdct_clear(v->transform[0][0]);
       free(v->transform[0][0]);
@@ -341,12 +341,10 @@ double **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
     
   if(v->pcm_current+vals>=v->pcm_storage){
     v->pcm_storage=v->pcm_current+vals*2;
-    v->envelope_storage=v->pcm_storage/v->vi->envelopesa;
    
     for(i=0;i<vi->channels;i++){
       v->pcm[i]=realloc(v->pcm[i],v->pcm_storage*sizeof(double));
     }
-    v->multipliers=realloc(v->multipliers,v->envelope_storage*sizeof(double));
   }
 
   for(i=0;i<vi->channels;i++)
@@ -390,69 +388,42 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
   /* check to see if we're done... */
   if(v->eofflag==-1)return(0);
 
-  /* if we have any unfilled envelope blocks for which we have PCM
-     data, fill them up in before proceeding. */
-
-  if(v->pcm_current/vi->envelopesa>v->envelope_current){
-    /* This generates the multipliers, but does not sparsify the vector.
-       That's done by block before coding */
-    _ve_envelope_deltas(v);
-  }
-
   /* By our invariant, we have lW, W and centerW set.  Search for
      the next boundary so we can determine nW (the next window size)
      which lets us compute the shape of the current block's window */
   
   if(vi->blocksizes[0]<vi->blocksizes[1]){
-    long i=v->centerW/vi->envelopesa;
+    long largebound;
+    long bp;
+
+    if(v->W)
+      /* min boundary; nW large, next small */
+      largebound=v->centerW+vi->blocksizes[1]*3/4+vi->blocksizes[0]/4;
+    else
+      /* min boundary; nW large, next small */
+      largebound=v->centerW+vi->blocksizes[1]*3/4+vi->blocksizes[0]*3/4;
+
+    bp=_ve_envelope_search(v,largebound);
+    if(bp==-1)return(0); /* not enough data currently to search for a
+                            full long block */
+    v->nW=bp;
 
-    for(;i<v->envelope_current-1;i++){
-      /* Compare last with current; do we have an abrupt energy change? */
-      if(v->multipliers[i]>vi->preecho_thresh)break;
-      if(v->multipliers[i]+v->multipliers[i+1]>vi->preecho_thresh)break;
-    }
-    
-    if(i<v->envelope_current-1){
-      /* Ooo, we hit a multiplier. Is it beyond the boundary to make the
-        upcoming block large ? */
-      long largebound;
-      if(v->W)
-       /* min boundary; nW large, next small */
-       largebound=v->centerW+vi->blocksizes[1]*3/4+vi->blocksizes[0]/4;
-      else
-       /* min boundary; nW large, next small */
-       largebound=v->centerW+vi->blocksizes[1]*3/4+vi->blocksizes[0]*3/4;
-      largebound/=vi->envelopesa;
-      
-      if(i>largebound)
-       v->nW=1;
-      else
-       v->nW=0;
-      
-    }else{
-      /* Assume maximum; if the block is incomplete given current
-        buffered data, this will be detected below */
-      v->nW=1;
-    }
   }else
     v->nW=0;
-
-  /* Do we actually have enough data *now* for the next block? The
-     reason to check is that if we had no multipliers, that could
-     simply been due to running out of data.  In that case, we don't
-     know the size of the next block for sure and we need that now to
-     figure out the window shape of this block */
   
   centerNext=v->centerW+vi->blocksizes[v->W]/4+vi->blocksizes[v->nW]/4;
 
   {
-    /* center of next block + next block maximum right side.  Note
-       that the next block needs an additional vi->envelopesa samples 
-       to actually be written (for the last multiplier), but we didn't
-       need that to determine its size */
+    /* center of next block + next block maximum right side. */
 
     long blockbound=centerNext+vi->blocksizes[v->nW]/2;
-    if(v->pcm_current<blockbound)return(0); /* not enough data yet */    
+    if(v->pcm_current<blockbound)return(0); /* not enough data yet;
+                                               although this check is
+                                               less strict that the
+                                               _ve_envelope_search,
+                                               the search is not run
+                                               if we only use one
+                                               block size */
   }
   
   /* fill in the block.  Note that for a short window, lW and nW are *short*
@@ -498,22 +469,14 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
   {
     int new_centerNext=vi->blocksizes[1]/2;
     int movementW=centerNext-new_centerNext;
-    int movementM=movementW/vi->envelopesa;
-
-
-    /* the multipliers and pcm stay synced up because the blocksize
-       must be multiples of samples_per_envelope_step (minimum
-       multiple is 2) */
 
+    _ve_envelope_shift(v->ve,movementW);
     v->pcm_current-=movementW;
-    v->envelope_current-=movementM;
 
     for(i=0;i<vi->channels;i++)
       memmove(v->pcm[i],v->pcm[i]+movementW,
              v->pcm_current*sizeof(double));
-    
-    memmove(v->multipliers,v->multipliers+movementM,
-           v->envelope_current*sizeof(double));
+
 
     v->lW=v->W;
     v->W=v->nW;
@@ -557,7 +520,7 @@ int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){
 int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
   vorbis_info *vi=v->vi;
 
-  /* Shift out any PCM/multipliers that we returned previously */
+  /* Shift out any PCM that we returned previously */
   /* centerW is currently the center of the last block added */
   if(v->pcm_returned  && v->centerW>vi->blocksizes[1]/2){
 
index 8064b72..2272c7e 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.19 2000/06/18 12:33:47 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.20 2000/07/12 09:36:17 xiphmont Exp $
 
  Preecho calculation.
 
 
 #include "os.h"
 #include "scales.h"
-#include "smallft.h"
 #include "envelope.h"
 #include "bitwise.h"
-#include "window.h"
 #include "misc.h"
 
-void _ve_envelope_init(envelope_lookup *e,int samples_per){
+/* We use a Chebyshev bandbass for the preecho trigger bandpass; it's
+   close enough for sample rates 32000-48000 Hz (corner frequencies at
+   6k/14k assuming sample rate of 44.1kHz) */
+
+/* Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher
+   Command line: /www/usr/fisher/helpers/mkfilter -Ch \
+   -6.0000000000e+00 -Bp -o 5 -a 1.3605442177e-01 3.1746031746e-01 -l */
+
+static int    cheb_bandpass_stages=10;
+static double cheb_bandpass_gain=5.589612458e+01;
+/* z^-stage, z^-stage+1... */
+static double cheb_bandpass_B[]={-1.,0.,5.,0.,-10.,0.,10.,0.,-5.,0.,1};
+static double cheb_bandpass_A[]={
+  -0.1917409386,
+  0.0078657069,
+  -0.7126903444,
+  0.0266343467,
+  -1.4047174730,
+  0.0466964232,
+  -1.9032773429,
+  0.0451493360,
+  -1.4471447397,
+  0.0303413711};
+
+static int    cheb_highpass_stages=10;
+static double cheb_highpass_gain= 5.291963434e+01;
+/* z^-stage, z^-stage+1... */
+static double cheb_highpass_B[]={1,-10,45,-120,210,-252,210,-120,45,-10,1};
+static double cheb_highpass_A[]={
+  -0.1247628029,
+  0.1334086523,
+  -0.3997715614,
+  0.3213011089,
+  -1.1131924119,
+  1.7692446626,
+  -3.6241199038,
+  4.1950871291,
+  -4.2771757867,
+  2.3920318913};
+
+void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
+  long rate=vi->rate;
+  int ch=vi->channels;
+  int window=vi->envelopesa;
   int i;
-  e->winlen=samples_per*2;
-  e->window=malloc(e->winlen*sizeof(double));
-
-  e->fft=calloc(1,sizeof(drft_lookup));
-  drft_init(e->fft,samples_per*2);
+  e->winlength=window;
+  e->iir=calloc(ch,sizeof(IIR_state));
+  e->filtered=calloc(ch,sizeof(double *));
+  e->ch=ch;
+  e->storage=128;
+  for(i=0;i<ch;i++){
+    IIR_init(e->iir+i,cheb_highpass_stages,cheb_highpass_gain,
+            cheb_highpass_A,cheb_highpass_B);
+    e->filtered[i]=calloc(e->storage,sizeof(double));
+  }
 
+  drft_init(&e->drft,window);
+  e->window=malloc(e->winlength*sizeof(double));
   /* We just use a straight sin(x) window for this */
-  for(i=0;i<e->winlen;i++)
-    e->window[i]=sin((i+.5)/e->winlen*M_PI);
+  for(i=0;i<e->winlength;i++)
+    e->window[i]=sin((i+.5)/e->winlength*M_PI);
 }
 
 void _ve_envelope_clear(envelope_lookup *e){
-  drft_clear(e->fft);
-  free(e->fft);
-  if(e->window)free(e->window);
+  int i;
+  for(i=0;i<e->ch;i++){
+    IIR_clear((e->iir+i));
+    free(e->filtered[i]);
+  }
+  drft_clear(&e->drft);
+  free(e->window);
+  free(e->filtered);
   memset(e,0,sizeof(envelope_lookup));
 }
 
+/*static int frameno=0;*/
+
 static void smooth_noise(long n,double *f,double *noise){
   long i;
   long lo=0,hi=0;
   double acc=0.;
 
   for(i=0;i<n;i++){
-    /* not exactly correct, (the center frequency should be centered
-       on a *log* scale), but not worth quibbling */
     long newhi=i*1.0442718740+5;
     long newlo=i*.8781245150-5;
     if(newhi>n)newhi=n;
-
+    
     for(;lo<newlo;lo++)
-      acc-=todB(f[lo]); /* yeah, this ain't RMS */
+      acc-=f[lo]*f[lo];
     for(;hi<newhi;hi++)
-      acc+=todB(f[hi]);
-    noise[i]=acc/(hi-lo);
+      acc+=f[hi]*f[hi];
+    noise[i]=todB(sqrt(acc/(hi-lo)));
   }
 }
 
-/* use FFT for spectral power estimation */
-static int frameno=0;
-static int frameno2=0;
+static double _ve_deltai(envelope_lookup *ve,IIR_state *iir,
+                     double *pre,double *post){
+  long no=ve->winlength/3; /* past the highpass rollon! */
+  long n2=ve->winlength*2;
+  long n=ve->winlength;
 
-static void _ve_deltas(double *deltas,double *pcm,int n,double *window,
-                      int samples_per,drft_lookup *l){
-  int i,j;
-  double *out=alloca(sizeof(double)*samples_per*2);
-  double *cache=alloca(sizeof(double)*samples_per*2);
-  
-  for(j=-1;j<n;j++){
-
-    memcpy(out,pcm+(j+1)*samples_per,samples_per*2*sizeof(double));
-    for(i=0;i<samples_per*2;i++)
-      out[i]*=window[i];
-
-    _analysis_output("Dpcm",frameno*1000+frameno2,out,samples_per*2,0,0);
-
-   
-    drft_forward(l,out);
-    for(i=1;i<samples_per;i++)
-      out[i]=hypot(out[i*2],out[i*2-1]);
-    _analysis_output("Dfft",frameno*1000+frameno2,out,samples_per,0,1);
-    smooth_noise(samples_per,out,out+samples_per);
-
-    if(j==-1){
-      for(i=samples_per/10;i<samples_per;i++)
-       cache[i]=out[i+samples_per];
-    }else{
-      double max=0;  
-      _analysis_output("Dcache",frameno*1000+frameno2,cache,samples_per,0,0);
-      for(i=samples_per/10;i<samples_per;i++){
-       double val=out[i+samples_per]-cache[i];
-       cache[i]=out[i+samples_per];
-       if(val>0)max+=val;
-      }
-      max/=samples_per;
-      if(deltas[j]<max)deltas[j]=max;
-    }
-    _analysis_output("Dnoise",frameno*1000+frameno2++,out+samples_per,samples_per,0,0);
+  double *workA=alloca(sizeof(double)*n2),A=0.;
+  double *workB=alloca(sizeof(double)*n2),B=0.;
+  long i;
+
+  /*_analysis_output("A",frameno,pre,n,0,0);
+    _analysis_output("B",frameno,post,n,0,0);*/
+
+  for(i=0;i<n;i++){
+    workA[i]=pre[i]*ve->window[i];
+    workB[i]=post[i]*ve->window[i];
   }
+
+  /*_analysis_output("Awin",frameno,workA,n,0,0);
+    _analysis_output("Bwin",frameno,workB,n,0,0);*/
+
+  drft_forward(&ve->drft,workA);
+  drft_forward(&ve->drft,workB);
+  /*_analysis_output("Afft",frameno,workA,n,0,0);
+    _analysis_output("Bfft",frameno,workB,n,0,0);*/
+
+  for(i=0;i<n;i++){
+    A+=workA[i]*workA[i];
+    B+=workB[i]*workB[i];
+  }
+
+  A=todB(A);
+  B=todB(B);
+
+  return(B-A);
 }
 
-void _ve_envelope_deltas(vorbis_dsp_state *v){
+long _ve_envelope_search(vorbis_dsp_state *v,long searchpoint){
   vorbis_info *vi=v->vi;
-  int step=vi->envelopesa;
+  envelope_lookup *ve=v->ve;
+  long i,j;
   
-  int dtotal=v->pcm_current/vi->envelopesa-1;
-  int dcurr=v->envelope_current;
-  int pch;
-  
-  if(dtotal>dcurr){
-    double *mult=v->multipliers+dcurr;
-    memset(mult,0,sizeof(double)*(dtotal-dcurr));
+  /* make sure we have enough storage to match the PCM */
+  if(v->pcm_storage>ve->storage){
+    ve->storage=v->pcm_storage;
+    for(i=0;i<ve->ch;i++)
+      ve->filtered[i]=realloc(ve->filtered[i],ve->storage*sizeof(double));
+  }
+
+  /* catch up the highpass to match the pcm */
+  for(i=0;i<ve->ch;i++){
+    double *filtered=ve->filtered[i];
+    double *pcm=v->pcm[i];
+    IIR_state *iir=ve->iir+i;
+    
+    for(j=ve->current;j<v->pcm_current;j++)
+      filtered[j]=IIR_filter(iir,pcm[j]);
+  }
+  ve->current=v->pcm_current;
+
+  /* Now search through our cached highpass data for breaking points */
+  /* starting point */
+  if(v->W)
+    j=v->centerW+vi->blocksizes[1]/4-vi->blocksizes[0]/4;
+  else
+    j=v->centerW;
+
+  while(j+ve->winlength<=v->pcm_current){
+    for(i=0;i<ve->ch;i++){
+      double *filtered=ve->filtered[i]+j;
+      IIR_state *iir=ve->iir+i;
+      double m=_ve_deltai(ve,iir,filtered-ve->winlength,filtered);
       
-    for(pch=0;pch<vi->channels;pch++){
-      double *pcm=v->pcm[pch]+(dcurr-1)*step;
-      _ve_deltas(mult,pcm,dtotal-dcurr,v->ve.window,step,v->ve.fft);
-
-      {
-       double *multexp=alloca(sizeof(double)*v->pcm_current);
-       int i,j,k;
-
-       memset(multexp,0,sizeof(double)*v->pcm_current);
-       j=0;
-       for(i=0;i<dtotal;i++)
-         for(k=0;k<step;k++)
-           multexp[j++]=v->multipliers[i];
-
-       _analysis_output("Apcm",frameno,v->pcm[pch],v->pcm_current,0,0);
-       _analysis_output("Amult",frameno++,multexp,v->pcm_current,0,0);
+      if(m>vi->preecho_thresh){
+       /*frameno++;*/
+       return(0);
       }
-
+      /*frameno++;*/
     }
-    v->envelope_current=dtotal;
+    
+    j+=vi->blocksizes[0]/2;
+    if(j>=searchpoint)return(1);
   }
+  
+  return(-1);
 }
 
-
-
-
+void _ve_envelope_shift(envelope_lookup *e,long shift){
+  int i;
+  for(i=0;i<e->ch;i++)
+    memmove(e->filtered[i],e->filtered[i]+shift,(e->current-shift)*
+           sizeof(double));
+  e->current-=shift;
+}
 
 
index 79840ea..56840fb 100644 (file)
  ********************************************************************
 
  function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.h,v 1.7 1999/12/30 07:26:37 xiphmont Exp $
+ last mod: $Id: envelope.h,v 1.8 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
 #ifndef _V_ENVELOPE_
 #define _V_ENVELOPE_
 
-extern void _ve_envelope_init(envelope_lookup *e,int samples_per);
+#include "iir.h"
+#include "smallft.h"
 
-extern void _ve_envelope_deltas(vorbis_dsp_state *v);
+#define EORDER 16
+
+typedef struct {
+  int ch;
+  int winlength;
+  int searchstep;
+
+  IIR_state *iir;
+  double    **filtered;
+  long storage;
+  long current;
+
+  drft_lookup drft;
+  double *window;
+} envelope_lookup;
+
+extern void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi);
 extern void _ve_envelope_clear(envelope_lookup *e);
+extern long _ve_envelope_search(vorbis_dsp_state *v,long searchpoint);
+extern void _ve_envelope_shift(envelope_lookup *e,long shift);
 
 
 #endif
index 83b0311..e8276bf 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.17 2000/06/19 10:05:57 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.18 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
 #include "misc.h"
 #include "os.h"
 
+#include "misc.h"
+#include <stdio.h>
+
+/* error relationship from coefficient->curve is nonlinear, so fit
+   using curve lookups, not the coefficients */
+typedef struct {
+  int usage;
+  long *entrymap;
+  double **fits;
+  int fitsize;
+  codebook *book;
+  lpc_lookup lpclook;
+} LSP_fit_lookup;
+
 typedef struct {
   long n;
   int ln;
@@ -38,14 +52,129 @@ typedef struct {
 
   vorbis_info_floor0 *vi;
   lpc_lookup lpclook;
+
+  LSP_fit_lookup *encodefit;
 } vorbis_look_floor0;
 
-typedef struct {
-  long *codewords;
-  double *curve;
-  long frameno;
-  long codes;
-} vorbis_echstate_floor0;
+/* infrastructure for setting up, finding and encoding fit */
+static void _f0_fit_init(LSP_fit_lookup *f,codebook *b){
+  int i,j,usage=0;
+  double max=0;
+  int dim=b->dim;
+  double *work;
+  double *lsp;
+
+  memset(f,0,sizeof(LSP_fit_lookup));
+
+  /* count actual codeword usage in case the book is sparse */
+  for(i=0;i<b->entries;i++)
+    if(b->c->lengthlist[i]>0){
+      if(b->valuelist[(i+1)*b->dim-1]>max)
+       max=b->valuelist[(i+1)*b->dim-1];
+      usage++;
+    }
+
+  /* allocate memory */
+  f->usage=usage;
+  f->entrymap=malloc(usage*sizeof(long));
+  f->fits=malloc(usage*sizeof(double *));
+  f->fitsize=16;
+  f->book=b;
+  lpc_init(&f->lpclook,f->fitsize,dim-1);
+
+  usage=0;
+  work=alloca(f->fitsize*2*sizeof(double));
+  lsp=alloca(dim*sizeof(double));
+  for(i=0;i<b->entries;i++)
+    if(b->c->lengthlist[i]>0){
+      double *orig=b->valuelist+i*b->dim;
+      double norm=orig[b->dim-1];
+      f->fits[usage]=malloc(f->fitsize*sizeof(double));
+
+      for(j=0;j<dim-1;j++)
+       lsp[j]=orig[j]/norm*M_PI;
+      vorbis_lsp_to_lpc(lsp,lsp,dim-1); 
+      vorbis_lpc_to_curve(work,lsp,norm*norm,&f->lpclook);
+      memcpy(f->fits[usage],work,f->fitsize*sizeof(double));
+
+      f->entrymap[usage]=i;
+
+      usage++;
+    }
+}
+
+static void _f0_fit_clear(LSP_fit_lookup *f){
+  if(f){
+    int i;
+    for(i=0;i<f->usage;i++)
+      free(f->fits[i]);
+    free(f->fits);
+    free(f->entrymap);
+    lpc_clear(&f->lpclook);
+    memset(f,0,sizeof(LSP_fit_lookup));
+  }
+}
+
+double _curve_error1(double *curve1,double *curve2,long n){
+  double acc=0.;
+  long i;
+  for(i=0;i<n;i++){
+    double val=curve1[i]-curve2[i];
+    acc+=val*val;
+  }
+  return(acc);
+}
+
+double _curve_error2(double *curve1,double *curve2,long n,double max){
+  double acc=0.;
+  long i;
+  for(i=0;i<n;i++){
+    double val=curve1[i]-curve2[i];
+    acc+=val*val;
+    if(acc>max)return(acc);
+  }
+  return(acc);
+}
+
+static long _f0_fit(LSP_fit_lookup *f, 
+                   codebook *book,
+                   double *orig,
+                   double *workfit,
+                   int cursor){
+  int dim=book->dim;
+  double norm,base=0.,err=0.;
+  int i,best=0;
+  double *lsp=alloca(dim*sizeof(double));
+  double *ref=alloca(f->fitsize*2*sizeof(double));
+
+  if(f->usage<=0)return(-1);
+
+  /* gen a curve for fitting */
+  if(cursor)base=workfit[cursor-1];
+  norm=orig[cursor+dim-1]-base;
+  for(i=0;i<dim-1;i++)
+    lsp[i]=(orig[i+cursor]-base)/norm*M_PI;
+  vorbis_lsp_to_lpc(lsp,lsp,dim-1); 
+  vorbis_lpc_to_curve(ref,lsp,norm*norm,&f->lpclook);
+
+  err=_curve_error1(f->fits[0],ref,f->fitsize);
+  for(i=1;i<f->usage;i++){
+    double this=_curve_error2(f->fits[i],ref,f->fitsize,err);
+    if(this<err){
+      err=this;
+      best=i;
+    }
+  }
+
+  /* choose the best fit from the tests and set workfit to it */
+  best=f->entrymap[best];
+  memcpy(workfit+cursor,book->valuelist+best*dim,dim*sizeof(double));
+  for(i=0;i<dim;i++)
+    workfit[i+cursor]+=base;
+  return(best);
+}
+
+/***********************************************/
 
 static void free_info(vorbis_info_floor *i){
   if(i){
@@ -57,6 +186,10 @@ static void free_info(vorbis_info_floor *i){
 static void free_look(vorbis_look_floor *i){
   vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
   if(i){
+    int j;
+    for(j=0;j<look->vi->numbooks;j++)
+      _f0_fit_clear(look->encodefit+j);
+    free(look->encodefit);
     if(look->linearmap)free(look->linearmap);
     lpc_clear(&look->lpclook);
     memset(look,0,sizeof(vorbis_look_floor0));
@@ -142,40 +275,15 @@ static vorbis_look_floor *look (vorbis_dsp_state *vd,vorbis_info_mode *mi,
     look->linearmap[j]=val;
   }
 
-  return look;
-}
-
-static vorbis_echstate_floor *state (vorbis_info_floor *i){
-  vorbis_echstate_floor0 *state=calloc(1,sizeof(vorbis_echstate_floor0));
-  vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
-
-  /* a safe size if usually too big (dim==1) */
-  state->codewords=malloc(info->order*sizeof(long)); 
-  state->curve=malloc(info->barkmap*sizeof(double));
-  state->frameno=-1;
-  return(state);
-}
-
-static void free_state (vorbis_echstate_floor *vs){
-  vorbis_echstate_floor0 *state=(vorbis_echstate_floor0 *)vs;
-  if(state){
-    free(state->codewords);
-    free(state->curve);
-    memset(state,0,sizeof(vorbis_echstate_floor0));
-    free(state);
-  }
-}
-
-#include <stdio.h>
-
-double _curve_error(double *curve1,double *curve2,long n){
-  double acc=0.;
-  long i;
-  for(i=0;i<n;i++){
-    double val=curve1[i]-curve2[i];
-    acc+=val*val;
+  if(vd->analysisp){
+    look->encodefit=calloc(info->numbooks,sizeof(LSP_fit_lookup));
+    for(j=0;j<info->numbooks;j++){
+      codebook *b=vd->fullbooks+info->books[j];
+      _f0_fit_init(look->encodefit+j,b);
+    }
   }
-  return(acc);
+    
+  return look;
 }
 
 /* less efficient than the decode side (written for clarity).  We're
@@ -276,19 +384,38 @@ void _lpc_to_curve(double *curve,double *lpc,double amp,
 
 static long seq=0;
 static int forward(vorbis_block *vb,vorbis_look_floor *i,
-                   double *in,double *out,vorbis_echstate_floor *vs){
-  long j,k,l;
+                   double *in,double *out){
+  long j;
   vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
   vorbis_info_floor0 *info=look->vi;
-  vorbis_echstate_floor0 *state=(vorbis_echstate_floor0 *)vs;
-  double *work=alloca(look->n*sizeof(double));
+  double *work=alloca((look->ln+look->n)*sizeof(double));
   double amp;
   long bits=0;
 
+#ifdef TRAIN_LSP
+  FILE *of;
+  FILE *ef;
+  char buffer[80];
+
+#if 0
+  sprintf(buffer,"lsp0coeff_%d.vqd",vb->mode);
+  of=fopen(buffer,"a");
+#endif
+
+  sprintf(buffer,"lsp0ent_%d.vqd",vb->mode);
+  ef=fopen(buffer,"a");
+#endif
+
   /* our floor comes in on a linear scale; go to a [-Inf...0] dB
      scale.  The curve has to be positive, so we offset it. */
 
-  for(j=0;j<look->n;j++)work[j]=todB(in[j])+info->ampdB;
+  for(j=0;j<look->n;j++){
+    double val=todB(in[j])+info->ampdB;
+    if(val<1.)
+      work[j]=1.;
+    else
+      work[j]=val;
+  }
 
   /* use 'out' as temp storage */
   /* Convert our floor to a set of lpc coefficients */ 
@@ -313,96 +440,78 @@ static int forward(vorbis_block *vb,vorbis_look_floor *i,
   }
 
   if(amp>0){
-    double *refcurve=alloca(sizeof(double)*max(look->ln*2,look->m*2+2));
-    double *newcurve=alloca(sizeof(double)*max(look->ln*2,look->m*2+2));
-    long *codelist=alloca(sizeof(long)*look->m);
-    int codes=0;
-
 
-    if(state->frameno == vb->sequence){
-      /* generate a reference curve for testing */
-      vorbis_lpc_to_curve(refcurve,out,1,&(look->lpclook));
-    }
+    /* the spec supports using one of a number of codebooks.  Right
+       now, encode using this lib supports only one */
+    codebook *b=vb->vd->fullbooks+info->books[0];
+    LSP_fit_lookup *f=look->encodefit;
+    _oggpack_write(&vb->opb,0,_ilog(info->numbooks));
 
     /* LSP <-> LPC is orthogonal and LSP quantizes more stably  */
     vorbis_lpc_to_lsp(out,out,look->m);
 
-#ifdef TRAIN
+#ifdef ANALYSIS
+    if(vb->W==0){fprintf(stderr,"%d ",seq);} 
+    vorbis_lsp_to_lpc(out,work,look->m); 
+    _lpc_to_curve(work,work,amp,look,"Ffloor",seq);
+    for(j=0;j<look->n;j++)work[j]-=info->ampdB;
+    _analysis_output("rawfloor",seq,work,look->n,0,0);
     {
-      int j;
-      FILE *of;
-      char buffer[80];
-      sprintf(buffer,"lsp0coeff_%d.vqd",vb->mode);
-      of=fopen(buffer,"a");
-      for(j=0;j<look->m;j++)
-       fprintf(of,"%.12g, ",out[j]);
-      fprintf(of,"\n");
-      fclose(of);
+      double last=0;
+      for(j=0;j<look->m;j++){
+       work[j]=out[j]-last;
+       last=out[j];
+      }
     }
+    _analysis_output("rawlsp",seq,work,look->m,0,0);
+       
+#endif
+
+#if 0
+#ifdef TRAIN_LSP
+    for(j=0;j<look->m;j++)
+      fprintf(of,"%.12g, ",out[j]);
+    fprintf(of,"\n");
+    fclose(of);
+#endif
 #endif
 
     /* code the spectral envelope, and keep track of the actual
        quantized values; we don't want creeping error as each block is
        nailed to the last quantized value of the previous block. */
 
-    /* A new development: the code selection is based on error against
-       the LSP coefficients and not the curve it produces.  Because
-       the coefficient error is not linearly related to the curve
-       error, the fit we select is usually nonoptimal (but
-       sufficient).  This is fine, but flailing about causes a problem
-       in generally consistent spectra... so we add hysterisis. */
-
-    /* select a new fit, but don't code it.  Just grab it for testing */
-    {
-      /* the spec supports using one of a number of codebooks.  Right
-        now, encode using this lib supports only one */
-      codebook *b=vb->vd->fullbooks+info->books[0];
-      double last=0.;
-      
-      for(j=0;j<look->m;){
-       for(k=0;k<b->dim;k++)out[j+k]-=last;
-       codelist[codes++]=vorbis_book_errorv(b,out+j);
-       for(k=0;k<b->dim;k++,j++)out[j]+=last;
-       last=out[j-1];
-      }
-    }
-    vorbis_lsp_to_lpc(out,out,look->m); 
-    vorbis_lpc_to_curve(newcurve,out,1,&(look->lpclook));
-    
-    /* if we're out of sequence, no hysterisis this frame, else check it */
-    if(state->frameno != vb->sequence ||
-       _curve_error(refcurve,newcurve,look->ln)<
-       _curve_error(refcurve,state->curve,look->ln)){
-      /* new curve is the fit to use.  replace the state */
-      memcpy(state->curve,newcurve,sizeof(double)*look->ln);
-      memcpy(state->codewords,codelist,sizeof(long)*codes);
-      state->codes=codes;
-    }else{
-      /* use state */
-      /*fprintf(stderr,"X");*/
-      codelist=state->codewords;
-      codes=state->codes;
-    }
+    for(j=0;j<look->m;j+=b->dim){
+      int entry=_f0_fit(f,b,out,work,j);
+      bits+=vorbis_book_encode(b,entry,&vb->opb);
+#ifdef ANALYSIS
+      if(entry==2921)fprintf(stderr,"\n*************found\n");
+#endif
 
-    state->frameno=vb->sequence+1;
+#ifdef TRAIN_LSP
+      fprintf(ef,"%d,\n",entry);
+#endif
 
-    /* the spec supports using one of a number of codebooks.  Right
-       now, encode using this lib supports only one */
-    _oggpack_write(&vb->opb,0,_ilog(info->numbooks));
+    }
 
+#ifdef ANALYSIS
     {
-      codebook *b=vb->vd->fullbooks+info->books[0];
-      double last=0.;
-      for(l=0,j=0;l<codes;l++){
-       bits+=vorbis_book_encodev(b,codelist[l],out+j,&vb->opb);
-       for(k=0;k<b->dim;k++,j++)out[j]+=last;
-       last=out[j-1];
+      double last=0;
+      for(j=0;j<look->m;j++){
+       out[j]=work[j]-last;
+       last=work[j];
       }
     }
+    _analysis_output("lsp",seq,out,look->m,0,0);
+       
+#endif
+
+#ifdef TRAIN_LSP
+    fclose(ef);
+#endif
 
     /* take the coefficients back to a spectral envelope curve */
-    vorbis_lsp_to_lpc(out,out,look->m); 
-    _lpc_to_curve(out,out,amp,look,"Ffloor",seq);
+    vorbis_lsp_to_lpc(work,out,look->m); 
+    _lpc_to_curve(out,out,amp,look,"Ffloor",seq++);
     for(j=0;j<look->n;j++)out[j]= fromdB(out[j]-info->ampdB);
     return(1);
   }
@@ -452,7 +561,7 @@ static int inverse(vorbis_block *vb,vorbis_look_floor *i,double *out){
 
 /* export hooks */
 vorbis_func_floor floor0_exportbundle={
-  &pack,&unpack,&look,&state,&free_info,&free_look,&free_state,&forward,&inverse
+  &pack,&unpack,&look,&free_info,&free_look,&forward,&inverse
 };
 
 
diff --git a/lib/iir.c b/lib/iir.c
new file mode 100644 (file)
index 0000000..b4a7a9e
--- /dev/null
+++ b/lib/iir.c
@@ -0,0 +1,302 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
+ * PLEASE READ THESE TERMS DISTRIBUTING.                            *
+ *                                                                  *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
+ * http://www.xiph.org/                                             *
+ *                                                                  *
+ ********************************************************************
+
+  function: Direct Form I, II IIR filters, plus some specializations
+  last mod: $Id: iir.c,v 1.1 2000/07/12 09:36:18 xiphmont Exp $
+
+ ********************************************************************/
+
+/* LPC is actually a degenerate case of form I/II filters, but we need
+   both */
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "iir.h"
+
+void IIR_init(IIR_state *s,int stages,double gain, double *A, double *B){
+  memset(s,0,sizeof(IIR_state));
+  s->stages=stages;
+  s->gain=gain;
+  s->coeff_A=malloc(stages*sizeof(double));
+  s->coeff_B=malloc((stages+1)*sizeof(double));
+  s->z_A=calloc(stages*2,sizeof(double));
+  s->z_B=calloc(stages*2,sizeof(double));
+
+  memcpy(s->coeff_A,A,stages*sizeof(double));
+  memcpy(s->coeff_B,B,(stages+1)*sizeof(double));
+}
+
+void IIR_clear(IIR_state *s){
+  if(s){
+    free(s->coeff_A);
+    free(s->coeff_B);
+    free(s->z_A);
+    free(s->z_B);
+    memset(s,0,sizeof(IIR_state));
+  }
+}
+
+double IIR_filter(IIR_state *s,double in){
+  int stages=s->stages,i;
+  double newA;
+  double newB=0;
+  double *zA=s->z_A+s->ring;
+
+  newA=in/=s->gain;
+  for(i=0;i<stages;i++){
+    newA+= s->coeff_A[i] * zA[i];
+    newB+= s->coeff_B[i] * zA[i];
+  }
+  newB+=newA*s->coeff_B[stages];
+
+  zA[0]=zA[stages]=newA;
+  if(++s->ring>=stages)s->ring=0;
+
+  return(newB);
+}
+
+/* this assumes the symmetrical structure of the feed-forward stage of
+   a Chebyshev bandpass to save multiplies */
+double IIR_filter_ChebBand(IIR_state *s,double in){
+  int stages=s->stages,i;
+  double newA;
+  double newB=0;
+  double *zA=s->z_A+s->ring;
+
+  newA=in/=s->gain;
+
+  newA+= s->coeff_A[0] * zA[0];
+  for(i=1;i<(stages>>1);i++){
+    newA+= s->coeff_A[i] * zA[i];
+    newB+= s->coeff_B[i] * (zA[i]-zA[stages-i]);
+  }
+  newB+= s->coeff_B[i] * zA[i];
+  for(;i<stages;i++)
+    newA+= s->coeff_A[i] * zA[i];
+
+  newB+= newA-zA[0];
+
+  zA[0]=zA[stages]=newA;
+  if(++s->ring>=stages)s->ring=0;
+
+  return(newB);
+}
+
+#ifdef _V_SELFTEST
+
+/* z^-stage, z^-stage+1... */
+static double cheb_bandpass_B[]={-1.,0.,5.,0.,-10.,0.,10.,0.,-5.,0.,1};
+static double cheb_bandpass_A[]={-0.6665900311,
+                                 1.0070146601,
+                                -3.1262875409,
+                                 3.5017171569,
+                                -6.2779211945,
+                                 5.2966481740,
+                                -6.7570216587,
+                                 4.0760335768,
+                                -3.9134284363,
+                                 1.3997338886};
+
+static double data[128]={  
+  0.0426331,
+  0.0384521,
+  0.0345764,
+  0.0346069,
+  0.0314636,
+  0.0310059,
+  0.0318604,
+  0.0336304,
+  0.036438,
+  0.0348511,
+  0.0354919,
+  0.0343628,
+  0.0325623,
+  0.0318909,
+  0.0263367,
+  0.0225525,
+  0.0195618,
+  0.0160828,
+  0.0168762,
+  0.0145569,
+  0.0126343,
+  0.0127258,
+  0.00820923,
+  0.00787354,
+  0.00558472,
+  0.00204468,
+  3.05176e-05,
+  -0.00357056,
+  -0.00570679,
+  -0.00991821,
+  -0.0101013,
+  -0.00881958,
+  -0.0108948,
+  -0.0110168,
+  -0.0119324,
+  -0.0161438,
+  -0.0194702,
+  -0.0229187,
+  -0.0260315,
+  -0.0282288,
+  -0.0306091,
+  -0.0330505,
+  -0.0364685,
+  -0.0385742,
+  -0.0428772,
+  -0.043457,
+  -0.0425415,
+  -0.0462341,
+  -0.0467529,
+  -0.0489807,
+  -0.0520325,
+  -0.0558167,
+  -0.0596924,
+  -0.0591431,
+  -0.0612793,
+  -0.0618591,
+  -0.0615845,
+  -0.0634155,
+  -0.0639648,
+  -0.0683594,
+  -0.0718079,
+  -0.0729675,
+  -0.0791931,
+  -0.0860901,
+  -0.0885315,
+  -0.088623,
+  -0.089386,
+  -0.0899353,
+  -0.0886841,
+  -0.0910645,
+  -0.0948181,
+  -0.0919495,
+  -0.0891418,
+  -0.0916443,
+  -0.096344,
+  -0.100464,
+  -0.105499,
+  -0.108612,
+  -0.112213,
+  -0.117676,
+  -0.120911,
+  -0.124329,
+  -0.122162,
+  -0.120605,
+  -0.12326,
+  -0.12619,
+  -0.128998,
+  -0.13205,
+  -0.134247,
+  -0.137939,
+  -0.143555,
+  -0.14389,
+  -0.14859,
+  -0.153717,
+  -0.159851,
+  -0.164551,
+  -0.162811,
+  -0.164276,
+  -0.156952,
+  -0.140564,
+  -0.123291,
+  -0.10321,
+  -0.0827637,
+  -0.0652466,
+  -0.053772,
+  -0.0509949,
+  -0.0577698,
+  -0.0818176,
+  -0.114929,
+  -0.148895,
+  -0.181122,
+  -0.200714,
+  -0.21048,
+  -0.203644,
+  -0.179413,
+  -0.145325,
+  -0.104492,
+  -0.0658264,
+  -0.0332031,
+  -0.0106201,
+  -0.00363159,
+  -0.00909424,
+  -0.0244141,
+  -0.0422058,
+  -0.0537415,
+  -0.0610046,
+  -0.0609741,
+  -0.0547791};
+
+/* comparison test code from http://www-users.cs.york.ac.uk/~fisher/mkfilter/
+   (the above page kicks ass, BTW)*/
+
+#define NZEROS 10
+#define NPOLES 10
+#define GAIN   4.599477515e+02
+
+static float xv[NZEROS+1], yv[NPOLES+1];
+
+static double filterloop(double next){ 
+  xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4]; xv[4] = xv[5]; 
+  xv[5] = xv[6]; xv[6] = xv[7]; xv[7] = xv[8]; xv[8] = xv[9]; xv[9] = xv[10]; 
+  xv[10] = next / GAIN;
+  yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4]; yv[4] = yv[5]; 
+  yv[5] = yv[6]; yv[6] = yv[7]; yv[7] = yv[8]; yv[8] = yv[9]; yv[9] = yv[10]; 
+  yv[10] =   (xv[10] - xv[0]) + 5 * (xv[2] - xv[8]) + 10 * (xv[6] - xv[4])
+    + ( -0.6665900311 * yv[0]) + (  1.0070146601 * yv[1])
+    + ( -3.1262875409 * yv[2]) + (  3.5017171569 * yv[3])
+    + ( -6.2779211945 * yv[4]) + (  5.2966481740 * yv[5])
+    + ( -6.7570216587 * yv[6]) + (  4.0760335768 * yv[7])
+    + ( -3.9134284363 * yv[8]) + (  1.3997338886 * yv[9]);
+  return(yv[10]);
+}
+
+#include <stdio.h>
+int main(){
+
+  /* run the pregenerated Chebyshev filter, then our own distillation
+     through the generic and specialized code */
+  double *work=malloc(128*sizeof(double));
+  IIR_state iir;
+  int i;
+
+  for(i=0;i<128;i++)work[i]=filterloop(data[i]);
+  {
+    FILE *out=fopen("IIR_ref.m","w");
+    for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
+    fclose(out);
+  }
+
+  IIR_init(&iir,NPOLES,GAIN,cheb_bandpass_A,cheb_bandpass_B);
+  for(i=0;i<128;i++)work[i]=IIR_filter(&iir,data[i]);
+  {
+    FILE *out=fopen("IIR_gen.m","w");
+    for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
+    fclose(out);
+  }
+  IIR_clear(&iir);  
+
+  IIR_init(&iir,NPOLES,GAIN,cheb_bandpass_A,cheb_bandpass_B);
+  for(i=0;i<128;i++)work[i]=IIR_filter_ChebBand(&iir,data[i]);
+  {
+    FILE *out=fopen("IIR_cheb.m","w");
+    for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
+    fclose(out);
+  }
+  IIR_clear(&iir);  
+
+  return(0);
+}
+
+#endif
diff --git a/lib/iir.h b/lib/iir.h
new file mode 100644 (file)
index 0000000..22e10db
--- /dev/null
+++ b/lib/iir.h
@@ -0,0 +1,37 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
+ * PLEASE READ THESE TERMS DISTRIBUTING.                            *
+ *                                                                  *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
+ * http://www.xiph.org/                                             *
+ *                                                                  *
+ ********************************************************************
+
+  function: Direct Form I, II IIR filters, plus some specializations
+  last mod: $Id: iir.h,v 1.1 2000/07/12 09:36:18 xiphmont Exp $
+
+ ********************************************************************/
+
+#ifndef _V_IIR_H_
+#define _V_IIR_H_
+
+typedef struct {
+  int stages;
+  double *coeff_A;
+  double *coeff_B;
+  double *z_A;
+  double *z_B;
+  int ring;
+  double gain;
+} IIR_state;
+
+void IIR_init(IIR_state *s,int stages,double gain, double *A, double *B);
+void IIR_clear(IIR_state *s);
+double IIR_filter(IIR_state *s,double in);
+double IIR_filter_ChebBand(IIR_state *s,double in);
+
+#endif
diff --git a/lib/iir.o b/lib/iir.o
new file mode 100644 (file)
index 0000000..5fea83c
Binary files /dev/null and b/lib/iir.o differ
index 4dc76be..b1c3634 100644 (file)
--- a/lib/lpc.c
+++ b/lib/lpc.c
@@ -12,7 +12,7 @@
  ********************************************************************
 
   function: LPC low level routines
-  last mod: $Id: lpc.c,v 1.21 2000/06/14 01:38:31 xiphmont Exp $
+  last mod: $Id: lpc.c,v 1.22 2000/07/12 09:36:18 xiphmont Exp $
 
  ********************************************************************/
 
@@ -131,7 +131,7 @@ double vorbis_lpc_from_curve(double *curve,double *lpc,lpc_lookup *l){
   
   n*=2;
   drft_backward(&l->fft,work);
-  
+
   /* The autocorrelation will not be circular.  Shift, else we lose
      most of the power in the edges. */
   
@@ -195,7 +195,36 @@ void vorbis_lpc_to_curve(double *curve,double *lpc,double amp,
   }
 }  
 
-/* subtract or add an lpc filter to data.  Vorbis doesn't actually use this. */
+/* subtract or add an lpc filter to data. */
+
+void vorbis_lpc_filter(double *coeff,double *prime,int m,
+                       double *data,long n,double amp){
+
+  /* in: coeff[0...m-1] LPC coefficients 
+         prime[0...m-1] initial values 
+         data[0...n-1] data samples 
+    out: data[0...n-1] residuals from LPC prediction */
+
+  long i,j;
+  double *work=alloca(sizeof(double)*(m+n));
+  double y;
+
+  if(!prime)
+    for(i=0;i<m;i++)
+      work[i]=0;
+  else
+    for(i=0;i<m;i++)
+      work[i]=prime[i];
+
+  for(i=0;i<n;i++){
+    y=0;
+    for(j=0;j<m;j++)
+      y-=work[i+j]*coeff[m-j-1];
+    
+    data[i]=work[i+m]=data[i]+y;
+
+  }
+}
 
 void vorbis_lpc_residue(double *coeff,double *prime,int m,
                        double *data,long n){
@@ -226,7 +255,6 @@ void vorbis_lpc_residue(double *coeff,double *prime,int m,
   }
 }
 
-
 void vorbis_lpc_predict(double *coeff,double *prime,int m,
                      double *data,long n){
 
index 677dd18..5aea0fc 100644 (file)
--- a/lib/lpc.h
+++ b/lib/lpc.h
@@ -12,7 +12,7 @@
  ********************************************************************
 
   function: LPC low level routines
-  last mod: $Id: lpc.h,v 1.10 2000/05/08 20:49:49 xiphmont Exp $
+  last mod: $Id: lpc.h,v 1.11 2000/07/12 09:36:18 xiphmont Exp $
 
  ********************************************************************/
 
@@ -41,6 +41,8 @@ extern void vorbis_lpc_to_curve(double *curve,double *lpc,double amp,
                                lpc_lookup *l);
 
 /* standard lpc stuff */
+extern void vorbis_lpc_filter(double *coeff,double *prime,int m,
+                       double *data,long n,double amp);
 extern void vorbis_lpc_residue(double *coeff,double *prime,int m,
                        double *data,long n);
 extern void vorbis_lpc_predict(double *coeff,double *prime,int m,
index fefd2a5..11014c8 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.13 2000/06/14 01:38:31 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.14 2000/07/12 09:36:18 xiphmont Exp $
 
  ********************************************************************/
 
@@ -42,7 +42,6 @@ typedef struct {
 
   vorbis_look_time **time_look;
   vorbis_look_floor **floor_look;
-  vorbis_echstate_floor **floor_state;
 
   vorbis_look_residue **residue_look;
   vorbis_look_psy *psy_look;
@@ -54,7 +53,7 @@ typedef struct {
   int ch;
   double **decay;
   long lastframe; /* if a different mode is called, we need to 
-                    invalidate decay and floor state */
+                    invalidate decay */
 } vorbis_look_mapping0;
 
 static void free_info(vorbis_info_mapping *i){
@@ -67,7 +66,6 @@ static void free_info(vorbis_info_mapping *i){
 static void free_look(vorbis_look_mapping *look){
   int i;
   vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look;
-  vorbis_info_mapping0 *info=l->map;
   if(l){
     for(i=0;i<l->map->submaps;i++){
       l->time_func[i]->free_look(l->time_look[i]);
@@ -76,12 +74,6 @@ static void free_look(vorbis_look_mapping *look){
       if(l->psy_look)_vp_psy_clear(l->psy_look+i);
     }
 
-    if(l->floor_state){
-      for(i=0;i<l->ch;i++)
-       l->floor_func[info->chmuxlist[i]]->free_state(l->floor_state[i]);
-      free(l->floor_state);
-    }
-
     if(l->decay){
       for(i=0;i<l->ch;i++){
        if(l->decay[i])free(l->decay[i]);
@@ -111,8 +103,7 @@ static vorbis_look_mapping *look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
   
   look->time_look=calloc(info->submaps,sizeof(vorbis_look_time *));
   look->floor_look=calloc(info->submaps,sizeof(vorbis_look_floor *));
-  if(vd->analysisp)
-    look->floor_state=calloc(vi->channels,sizeof(vorbis_echstate_floor *));
+
   look->residue_look=calloc(info->submaps,sizeof(vorbis_look_residue *));
   if(vi->psys)look->psy_look=calloc(info->submaps,sizeof(vorbis_look_psy));
 
@@ -149,15 +140,6 @@ static vorbis_look_mapping *look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
       look->decay[i]=calloc(vi->blocksizes[vm->blockflag]/2,sizeof(double));
   }
 
-  if(vd->analysisp)
-    for(i=0;i<vi->channels;i++){
-     int mapnumber=info->chmuxlist[i];
-     int floornum=info->floorsubmap[mapnumber];
-     
-     look->floor_state[i]=look->floor_func[mapnumber]->
-       state(vi->floor_param[floornum]);
-    }
-
   return(look);
 }
 
@@ -275,7 +257,7 @@ static int forward(vorbis_block *vb,vorbis_look_mapping *l){
 
       /* perform floor encoding */
       nonzero[i]=look->floor_func[submap]->
-       forward(vb,look->floor_look[submap],floor,floor,look->floor_state[i]);
+       forward(vb,look->floor_look[submap],floor,floor);
 
       _analysis_output("floor",seq,floor,n/2,0,1);
 
@@ -284,7 +266,7 @@ static int forward(vorbis_block *vb,vorbis_look_mapping *l){
       
       _analysis_output("res",seq++,pcm,n/2,0,0);
       
-#ifdef TRAIN
+#ifdef TRAIN_RES
       if(nonzero[i]){
        FILE *of;
        char buffer[80];
@@ -365,7 +347,7 @@ static int inverse(vorbis_block *vb,vorbis_look_mapping *l){
   /* only MDCT right now.... */
   for(i=0;i<vi->channels;i++){
     double *pcm=vb->pcm[i];
-    _analysis_output("out",seq+i,pcm,n/2,0,0);
+    _analysis_output("out",seq+i,pcm,n/2,0,1);
     mdct_backward(vd->transform[vb->W][0],pcm,pcm);
   }
 
index 152522b..d0e1665 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -4,6 +4,8 @@ libvorbis:
 
 Meaningful error code returns
 
+still some padding at EOS
+
 Option for brute-forcing vq search on maptype 2 (helps on undertrained
 sets).
 
index d02b0da..73708a1 100755 (executable)
@@ -1,29 +1,71 @@
 #!/usr/bin/perl
 
-my($auxparts,@partpoint)=@ARGV;
-
-if($#partpoint<0){
+if($#ARGV<0){
     &usage;
 }
 
-while (<STDIN>) {    
+$|=1;
+
+$bands=0;
+
+foreach $arg (@ARGV){
+    ($entries[$bands],$file[$bands])=split(/,/,$arg);
+    $bands++;
+}
+
+# no time to deal with globs right now
+if($bands>0){
+    die unless open(ONE,"<".$file[0]);
+}
+if($bands>1){
+    die unless open(TWO,"<".$file[1]);
+}
+if($bands>2){
+    die unless open(THREE,"<".$file[2]);
+}
+
+
+while (<ONE>) {    
     my@nums = ();
     @nums = split(/,/);
     my$cols=$#nums;
-    my$j,$i=0;
-    for(;$j<=$#partpoint;$j++){
-       for(;$i<$partpoint[$j] && $i<$cols;$i++){
-           print $nums[$i]+($j*$auxparts).", ";
-       }
+    for($i=0;$i<$cols;$i++){
+       print $nums[$i].", ";
     }
-    for(;$i<$cols;$i++){
-       print $nums[$i]+($j*$auxparts).", ";
+    if($bands>1){
+       $_=<TWO>;
+       @nums = ();
+       @nums = split(/,/);
+       $cols=$#nums;
+       for($i=0;$i<$cols;$i++){
+           print $nums[$i]+$entries[0].", ";
+       }
+       if($bands>2){
+           $_=<THREE>;
+           @nums = ();
+           @nums = split(/,/);
+           $cols=$#nums;
+           for($i=0;$i<$cols;$i++){
+               print $nums[$i]+$entries[0]+$entries[1].", ";
+           }
+       }
     }
     print "\n";
+
+}
+
+if($bands>0){
+    close ONE;
+}
+if($bands>1){
+    close TWO;
+}
+if($bands>2){
+    close THREE;
 }
     
 sub usage{
     print "\nOggVorbis auxbook spectral partitioner\n\n";
-    print "auxpartition.pl <entries> <partitionpoint> [<partitionpoint>...]\n\n";
+    print "auxpartition.pl <part_entries>,file [<part_entries>,file...]\n\n";
     exit(1);
 }
index b6c8bff..dc12109 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: utility functions for loading .vqh and .vqd files
- last mod: $Id: bookutil.c,v 1.13 2000/05/08 20:49:50 xiphmont Exp $
+ last mod: $Id: bookutil.c,v 1.14 2000/07/12 09:36:18 xiphmont Exp $
 
  ********************************************************************/
 
@@ -439,6 +439,37 @@ void build_tree_from_lengths(int vals, long *hist, long *lengths){
   free(membership);
 }
 
+/* wrap build_tree_from_lengths to allow zero entries in the histogram */
+void build_tree_from_lengths0(int vals, long *hist, long *lengths){
+
+  /* pack the 'sparse' hit list into a dense list, then unpack
+     the lengths after the build */
+
+  int upper=0,i;
+  long *lengthlist=calloc(vals,sizeof(long));
+  long *newhist=alloca(vals*sizeof(long));
+
+  for(i=0;i<vals;i++)
+    if(hist[i]>0)
+      newhist[upper++]=hist[i];
+
+  if(upper != vals){
+    fprintf(stderr,"\rEliminating %d unused entries; %d entries remain\n",
+           vals-upper,upper);
+  }
+    
+  build_tree_from_lengths(upper,newhist,lengthlist);
+      
+  upper=0;
+  for(i=0;i<vals;i++)
+    if(hist[i]>0)
+      lengths[i]=lengthlist[upper++];
+    else
+      lengths[i]=0;
+
+  free(lengthlist);
+}
+
 void write_codebook(FILE *out,char *name,const static_codebook *c){
   encode_aux_threshmatch *t=c->thresh_tree;
   encode_aux_nearestmatch *n=c->nearest_tree;
index 583c548..e225a85 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: utility functions for loading .vqh and .vqd files
- last mod: $Id: bookutil.h,v 1.5 2000/05/08 20:49:50 xiphmont Exp $
+ last mod: $Id: bookutil.h,v 1.6 2000/07/12 09:36:18 xiphmont Exp $
 
  ********************************************************************/
 
@@ -38,6 +38,7 @@ extern void write_codebook(FILE *out,char *name,const static_codebook *c);
 
 extern void spinnit(char *s,int n);
 extern void build_tree_from_lengths(int vals, long *hist, long *lengths);
+extern void build_tree_from_lengths0(int vals, long *hist, long *lengths);
 
 #endif
 
index ba12f6e..dc728f2 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: hufftree builder
- last mod: $Id: huffbuild.c,v 1.3 2000/05/08 20:49:42 xiphmont Exp $
+ last mod: $Id: huffbuild.c,v 1.4 2000/07/12 09:36:17 xiphmont Exp $
 
  ********************************************************************/
 
@@ -51,7 +51,7 @@ static int getval(FILE *in,int begin,int n,int group,int max){
 static void usage(){
   fprintf(stderr,
          "usage:\n" 
-         "huffbuild <input>.vqd <begin,n,group>\n"
+         "huffbuild <input>.vqd <begin,n,group> [noguard]\n"
          "   where begin,n,group is first scalar, \n"
          "                          number of scalars of each in line,\n"
          "                          number of scalars in a group\n"
@@ -63,11 +63,12 @@ static void usage(){
 int main(int argc, char *argv[]){
   char *base;
   char *infile;
-  int i,j,k,begin,n,subn;
+  int i,j,k,begin,n,subn,guard=1;
   FILE *file;
   int maxval=0;
 
   if(argc<3)usage();
+  if(argc==4)guard=0;
 
   infile=strdup(argv[1]);
   base=strdup(infile);
@@ -114,7 +115,7 @@ int main(int argc, char *argv[]){
     long *hist=malloc(vals*sizeof(long));
     long *lengths=malloc(vals*sizeof(long));
     
-    for(j=0;j<vals;j++)hist[j]=1;
+    for(j=0;j<vals;j++)hist[j]=guard;
     
     reset_next_value();
     i/=subn;
@@ -128,8 +129,8 @@ int main(int argc, char *argv[]){
  
     /* we have the probabilities, build the tree */
     fprintf(stderr,"Building tree for %ld entries\n",vals);
-    build_tree_from_lengths(vals,hist,lengths);
+    build_tree_from_lengths0(vals,hist,lengths);
+
     /* save the book */
     {
       char *buffer=alloca(strlen(base)+5);
index 9dadcbc..5cf8e8b 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: utility main for building codebooks from lattice descriptions
- last mod: $Id: latticebuild.c,v 1.2 2000/05/08 20:49:50 xiphmont Exp $
+ last mod: $Id: latticebuild.c,v 1.3 2000/07/12 09:36:18 xiphmont Exp $
 
  ********************************************************************/
 
@@ -33,7 +33,7 @@
 
    the lattice description file contains five lines:
 
-   <n> <dim> <multiplicitavep>
+   <n> <dim> <multiplicitavep> <sequentialp>
    <value_0> <value_1> <value_2> ... <value_n-1>
    <m>
    <thresh_0> <thresh_1> <thresh_2> ... <thresh_m-2>
@@ -58,7 +58,7 @@ int main(int argc,char *argv[]){
   double *quantlist;
   long *hits;
 
-  int entries=-1,dim=-1,quantvals=-1,addmul=-1,threshvals=-1;
+  int entries=-1,dim=-1,quantvals=-1,addmul=-1,threshvals=-1,sequencep=0;
   FILE *out=NULL;
   FILE *in=NULL;
   char *line,*name;
@@ -103,9 +103,11 @@ int main(int argc,char *argv[]){
   
   /* read the description */
   line=get_line(in);
-  if(sscanf(line,"%d %d %d",&quantvals,&dim,&addmul)!=3){
-    fprintf(stderr,"Syntax error reading book file (line 1)\n");
-    exit(1);
+  if(sscanf(line,"%d %d %d %d",&quantvals,&dim,&addmul,&sequencep)!=4){
+    if(sscanf(line,"%d %d %d",&quantvals,&dim,&addmul)!=3){
+      fprintf(stderr,"Syntax error reading book file (line 1)\n");
+      exit(1);
+    }
   }
   entries=pow(quantvals,dim);
   c.thresh_tree=&t;
@@ -113,7 +115,7 @@ int main(int argc,char *argv[]){
   c.entries=entries;
   c.lengthlist=malloc(entries*sizeof(long));
   c.maptype=1;
-  c.q_sequencep=0;
+  c.q_sequencep=sequencep;
   c.quantlist=calloc(quantvals,sizeof(long));
 
   quantlist=malloc(sizeof(long)*c.dim*c.entries);
@@ -160,16 +162,25 @@ int main(int argc,char *argv[]){
   /* gen a real quant list from the more easily human-grokked input */
   {
     double min=quantlist[0];
-    double mindel=1;
-    for(j=1;j<quantvals;j++){  
-      if(quantlist[j]<min)min=quantlist[j];
-      for(k=0;k<j;k++){
-       double del=quantlist[k]-min;
-       /* really underpowered :-P know that this will only factor
-           powers of two (duh) */
-       while((int)(del/mindel)+.01<del/mindel){mindel/=2;}
+    double mindel=-1;
+    int fac=1;
+    for(j=1;j<quantvals;j++)if(quantlist[j]<min)min=quantlist[j];
+    for(j=0;j<quantvals;j++)
+      if(min!=quantlist[j] && (mindel==-1 || quantlist[j]-min<mindel))
+       mindel=quantlist[j]-min;
+
+    fprintf(stderr,"min=%g mindel=%g\n",min,mindel);
+    j=0;
+    while(j<quantvals){
+      for(j=0;j<quantvals;j++){
+       double test=(quantlist[j]-min)/(mindel/fac);
+       if( fabs(rint(test)-test)>.000001) break;
       }
+      if(j<quantvals)fac++;
     }
+
+    mindel/=fac;
+
     c.q_min=_float32_pack(min);
     c.q_delta=_float32_pack(mindel);
     c.q_quant=0;
index c448be9..7b7c690 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: utility for paring low hit count cells from lattice codebook
- last mod: $Id: latticepare.c,v 1.3 2000/06/14 01:38:32 xiphmont Exp $
+ last mod: $Id: latticepare.c,v 1.4 2000/07/12 09:36:18 xiphmont Exp $
 
  ********************************************************************/
 
@@ -27,6 +27,7 @@
 #include "bookutil.h"
 #include "vqgen.h"
 #include "vqsplit.h"
+#include "../lib/os.h"
 
 /* Lattice codebooks have two strengths: important fetaures that are
    poorly modelled by global error minimization training (eg, strong