[xiph-cvs] cvs commit: vorbis/lib/modes floor_44.h psych_44.h residue_44.h

Monty xiphmont at xiph.org
Mon Jun 10 21:44:52 PDT 2002



xiphmont    02/06/10 21:44:51

  Modified:    examples Tag: branch_monty_20020507 encoder_example.c
               lib      Tag: branch_monty_20020507 Makefile.am block.c
                        codec_internal.h mapping0.c psy.c psy.h synthesis.c
                        vorbisenc.c
               lib/modes Tag: branch_monty_20020507 floor_44.h psych_44.h
                        residue_44.h
  Log:
  Incremental to avoid losing work; this code is not yet functional

Revision  Changes    Path
No                   revision

<p>No                   revision

<p>1.40.2.3  +2 -2      vorbis/examples/encoder_example.c

Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/examples/encoder_example.c,v
retrieving revision 1.40.2.2
retrieving revision 1.40.2.3
diff -u -r1.40.2.2 -r1.40.2.3
--- encoder_example.c	2002/05/31 00:16:09	1.40.2.2
+++ encoder_example.c	2002/06/11 04:44:44	1.40.2.3
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.40.2.2 2002/05/31 00:16:09 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.40.2.3 2002/06/11 04:44:44 xiphmont Exp $
 
  ********************************************************************/
 
@@ -97,7 +97,7 @@
   /* (quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR) */
   vorbis_info_init(&vi);
 
-  vorbis_encode_init(&vi,2,44100,-1,80000,-1);
+  vorbis_encode_init(&vi,2,44100,-1,128000,-1);
   //vorbis_encode_init_vbr(&vi,2,44100,.4);
 
   /* add a comment */

<p><p>No                   revision

<p>No                   revision

<p>1.14.2.3  +1 -1      vorbis/lib/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/Makefile.am,v
retrieving revision 1.14.2.2
retrieving revision 1.14.2.3
diff -u -r1.14.2.2 -r1.14.2.3
--- Makefile.am	2002/05/14 07:06:40	1.14.2.2
+++ Makefile.am	2002/06/11 04:44:45	1.14.2.3
@@ -14,7 +14,7 @@
                         res0.c mapping0.c registry.c codebook.c sharedbook.c\
                         lookup.c bitrate.c\
                         envelope.h lpc.h lsp.h codebook.h misc.h psy.h\
-			masking.h os.h mdct.h smallft.h\
+			masking.h os.h mdct.h smallft.h highlevel.h\
                         registry.h scales.h window.h lookup.h lookup_data.h\
                         codec_internal.h backends.h bitrate.h 
 libvorbis_la_LDFLAGS = -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@

<p><p>1.64.2.4  +9 -7      vorbis/lib/block.c

Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/block.c,v
retrieving revision 1.64.2.3
retrieving revision 1.64.2.4
diff -u -r1.64.2.3 -r1.64.2.4
--- block.c	2002/05/18 01:39:27	1.64.2.3
+++ block.c	2002/06/11 04:44:45	1.64.2.4
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.64.2.3 2002/05/18 01:39:27 xiphmont Exp $
+ last mod: $Id: block.c,v 1.64.2.4 2002/06/11 04:44:45 xiphmont Exp $
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
@@ -496,16 +496,18 @@
   /* 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(ci->blocksizes[0]<ci->blocksizes[1]){
+
+  /* we do an envelope search even on a single blocksize; we may still
+     be throwing more bits at impulses, and envelope search handles
+     marking impulses too. */
+  {  
     long bp=_ve_envelope_search(v);
     if(bp==-1)return(0); /* not enough data currently to search for a
                             full long block */
+
     v->nW=bp;
+  }
 
-  }else
-    v->nW=0;
-  
   centerNext=v->centerW+ci->blocksizes[v->W]/4+ci->blocksizes[v->nW]/4;
 
   {
@@ -593,7 +595,7 @@
 
   /* advance storage vectors and clean up */
   {
-    int new_centerNext=ci->blocksizes[1]/2+gi->delaycache;
+    int new_centerNext=ci->blocksizes[1]/2;
     int movementW=centerNext-new_centerNext;
 
     if(movementW>0){

<p><p>1.14.4.5  +5 -42     vorbis/lib/codec_internal.h

Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/codec_internal.h,v
retrieving revision 1.14.4.4
retrieving revision 1.14.4.5
diff -u -r1.14.4.4 -r1.14.4.5
--- codec_internal.h	2002/05/31 00:16:10	1.14.4.4
+++ codec_internal.h	2002/06/11 04:44:45	1.14.4.5
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: libvorbis codec headers
- last mod: $Id: codec_internal.h,v 1.14.4.4 2002/05/31 00:16:10 xiphmont Exp $
+ last mod: $Id: codec_internal.h,v 1.14.4.5 2002/06/11 04:44:45 xiphmont Exp $
 
  ********************************************************************/
 
@@ -28,8 +28,6 @@
 
 #define PACKETBLOBS 15
 
-static double stereo_threshholds[]={0.0, 2.5, 4.5, 8.5, 16.5};
-
 typedef struct vorbis_block_internal{
   float  **pcmdelay;  /* this is a pointer into local storage */ 
   float  ampmax;
@@ -82,50 +80,13 @@
 
 } backend_lookup_state;
 
-/* high level configuration information for setting things up
-   step-by-step with the detaile vorbis_encode_ctl interface */
-
-typedef struct highlevel_block {
-  double tone_mask_quality;
-  double tone_peaklimit_quality;
-
-  double noise_bias_quality;
-  double noise_compand_quality;
-
-  double ath_quality;
-
-} highlevel_block;
-
-typedef struct highlevel_encode_setup {
-  int    managed;
-  double base_quality;       /* these have to be tracked by the ctl */
-  double base_quality_short; /* interface so that the right books get */
-  double base_quality_long;  /* chosen... */
-
-  int short_block_p;
-  int long_block_p;
-  int impulse_block_p;
-  int stereo_couple_p;
-
-  double stereo_point_q;
-  double lowpass_kHz[2];
-
-  double ath_floating_dB;
-  double ath_absolute_dB;
-
-  double amplitude_track_dBpersec;
-  double trigger_quality;
-
-  highlevel_block blocktype[4]; /* impulse, padding, trans, long */
-  
-} highlevel_encode_setup;
-
 /* codec_setup_info contains all the setup information specific to the
    specific compression/decompression mode in progress (eg,
    psychoacoustic settings, channel setup, options, codebook
    etc).  
 *********************************************************************/
 
+#include "highlevel.h"
 typedef struct codec_setup_info {
 
   /* Vorbis supports only short and long blocks, but allows the
@@ -159,7 +120,9 @@
   vorbis_info_psy_global psy_g_param;
 
   bitrate_manager_info   bi;
-  highlevel_encode_setup hi;
+  highlevel_encode_setup hi; /* used only by vorbisenc.c.  It's a
+                                highly redundant structure, but
+                                improves clarity of program flow. */
   
 } codec_setup_info;
 

<p><p>1.49.2.5  +8 -5      vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.49.2.4
retrieving revision 1.49.2.5
diff -u -r1.49.2.4 -r1.49.2.5
--- mapping0.c	2002/05/31 00:16:10	1.49.2.4
+++ mapping0.c	2002/06/11 04:44:45	1.49.2.5
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.49.2.4 2002/05/31 00:16:10 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.49.2.5 2002/06/11 04:44:45 xiphmont Exp $
 
  ********************************************************************/
 
@@ -455,10 +455,13 @@
                                       info,
                                       mag_memo);    
 
-    for(i=0;i<vi->channels;i++){
-      float *mdct    =gmdct[i];
-      sortindex[i]=alloca(sizeof(**sortindex)*n/2);
-      _vp_noise_normalize_sort(psy_look,mdct,sortindex[i]);
+    memset(sortindex,0,sizeof(*sortindex)*vi->channels);
+    if(psy_look->vi->normal_channel_p){
+      for(i=0;i<vi->channels;i++){
+	float *mdct    =gmdct[i];
+	sortindex[i]=alloca(sizeof(**sortindex)*n/2);
+	_vp_noise_normalize_sort(psy_look,mdct,sortindex[i]);
+      }
     }
 
     for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2);

<p><p>1.67.2.6  +58 -103   vorbis/lib/psy.c

Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.67.2.5
retrieving revision 1.67.2.6
diff -u -r1.67.2.5 -r1.67.2.6
--- psy.c	2002/05/31 00:16:10	1.67.2.5
+++ psy.c	2002/06/11 04:44:46	1.67.2.6
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.67.2.5 2002/05/31 00:16:10 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.67.2.6 2002/06/11 04:44:46 xiphmont Exp $
 
  ********************************************************************/
 
@@ -30,6 +30,7 @@
 #include "misc.h"
 
 #define NEGINF -9999.f
+static double stereo_threshholds[]={0.0, 2.5, 4.5, 8.5, 16.5};
 
 vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){
   codec_setup_info *ci=vi->codec_setup;
@@ -361,57 +362,6 @@
     _analysis_output("curve_16kHz",i,p->tonecurves[16][i]+2,EHMER_MAX,0,0);
   analysis_noisy=0;
 
-  if(vi->curvelimitp){
-    /* value limit the tonal masking curves; the peakatt not only
-       optionally specifies maximum dynamic depth, but also
-       limits the masking curves to a minimum depth  */
-    for(i=0;i<P_BANDS;i++)
-      for(j=0;j<P_LEVELS;j++){
-	for(k=2;k<EHMER_OFFSET+2+vi->curvelimitp;k++)
-	  if(p->tonecurves[i][j][k]> vi->peakatt.block[i][j])
-	    p->tonecurves[i][j][k]=  vi->peakatt.block[i][j];
-	  else
-	    break;
-      }
-  }
-
-  analysis_noisy=0;
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_63Hz",i,p->tonecurves[0][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_88Hz",i,p->tonecurves[1][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_125Hz",i,p->tonecurves[2][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_170Hz",i,p->tonecurves[3][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_250Hz",i,p->tonecurves[4][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_350Hz",i,p->tonecurves[5][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_500Hz",i,p->tonecurves[6][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_700Hz",i,p->tonecurves[7][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_1kHz",i,p->tonecurves[8][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_1.4Hz",i,p->tonecurves[9][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_2kHz",i,p->tonecurves[10][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_2.4kHz",i,p->tonecurves[11][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_4kHz",i,p->tonecurves[12][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_5.6kHz",i,p->tonecurves[13][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_8kHz",i,p->tonecurves[14][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_11.5kHz",i,p->tonecurves[15][i]+2,EHMER_MAX,0,0);
-  for(i=0;i<P_LEVELS;i++)
-    _analysis_output("licurve_16kHz",i,p->tonecurves[16][i]+2,EHMER_MAX,0,0);
-  analysis_noisy=0;
-
   if(vi->peakattp) /* we limit maximum depth only optionally */
     for(i=0;i<P_BANDS;i++)
       for(j=0;j<P_LEVELS;j++)
@@ -1080,23 +1030,25 @@
                                  vorbis_look_psy *p,
                                  vorbis_info_mapping0 *vi,
                                  float **mags){
-  
-  int i,j,k,n=p->n;
-  int **ret=_vorbis_block_alloc(vb,vi->coupling_steps*sizeof(*ret));
-  int partition=p->vi->normal_partition;
-  float **work=alloca(sizeof(*work)*partition);
-  
-  for(i=0;i<vi->coupling_steps;i++){
-    ret[i]=_vorbis_block_alloc(vb,n*sizeof(**ret));
 
-    for(j=0;j<n;j+=partition){
-      for(k=0;k<partition;k++)work[k]=mags[i]+k+j;
-      qsort(work,partition,sizeof(*work),apsort);
-      for(k=0;k<partition;k++)ret[i][k+j]=work[k]-mags[i];
+  if(p->vi->normal_point_p){
+    int i,j,k,n=p->n;
+    int **ret=_vorbis_block_alloc(vb,vi->coupling_steps*sizeof(*ret));
+    int partition=p->vi->normal_partition;
+    float **work=alloca(sizeof(*work)*partition);
+    
+    for(i=0;i<vi->coupling_steps;i++){
+      ret[i]=_vorbis_block_alloc(vb,n*sizeof(**ret));
+      
+      for(j=0;j<n;j+=partition){
+	for(k=0;k<partition;k++)work[k]=mags[i]+k+j;
+	qsort(work,partition,sizeof(*work),apsort);
+	for(k=0;k<partition;k++)ret[i][k+j]=work[k]-mags[i];
+      }
     }
+    return(ret);
   }
-  
-  return(ret);
+  return(NULL);
 }
 
 void _vp_noise_normalize_sort(vorbis_look_psy *p,
@@ -1119,45 +1071,47 @@
 
 void _vp_noise_normalize(vorbis_look_psy *p,
                          float *in,float *out,int *sortedindex){
-  int i,j,n=p->n;
+  int i,j=0,n=p->n;
   vorbis_info_psy *vi=p->vi;
   int partition=vi->normal_partition;
   int start=vi->normal_start;
 
-  for(j=0;j<start;j++)
-    out[j]=rint(in[j]);
-    
-  for(;j+partition<=n;j+=partition){
-    float acc=0.,qacc=0.;
-    int flag=0;
-    for(i=0;i<partition;i++)
-      acc+=in[i+j]*in[i+j];
-    
-    for(i=0;i<partition;i++){
-      int k=sortedindex[i+j-start];
-      float qval=rint(in[k]);
+  if(vi->normal_channel_p){
+    for(;j<start;j++)
+      out[j]=rint(in[j]);
+    
+    for(;j+partition<=n;j+=partition){
+      float acc=0.,qacc=0.;
+      int flag=0;
+      for(i=0;i<partition;i++)
+	acc+=in[i+j]*in[i+j];
       
-      if(qval){
-	qacc+=in[k]*in[k];
-	flag=1;
-	out[k]=qval;
-      }else{
-	if(qacc>acc)break;
-	qacc+=1.;
-	out[k]=unitnorm(in[k]);
+      for(i=0;i<partition;i++){
+	int k=sortedindex[i+j-start];
+	float qval=rint(in[k]);
+	
+	if(qval){
+	  qacc+=in[k]*in[k];
+	  flag=1;
+	  out[k]=qval;
+	}else{
+	  if(qacc>acc)break;
+	  qacc+=1.;
+	  out[k]=unitnorm(in[k]);
+	}
       }
-    }
-
-    if(!flag && i<2)i=0;
-    for(;i<partition;i++){
-      int k=sortedindex[i+j-start];
-      out[k]=0.;
+      
+      if(!flag && i<2)i=0;
+      for(;i<partition;i++){
+	int k=sortedindex[i+j-start];
+	out[k]=0.;
+      }
     }
   }
 
   for(;j<n;j++)
     out[j]=rint(in[j]);
-
+  
 }
 
 void _vp_couple(int blobno,
@@ -1198,7 +1152,7 @@
       int *floorA=ifloor[vi->coupling_ang[i]];
       int limit=g->coupling_pointlimit[p->vi->blockflag][blobno];
       float point=stereo_threshholds[g->coupling_pointamp[blobno]];
-      int partition=p->vi->normal_partition;
+      int partition=(p->vi->normal_point_p?p->vi->normal_partition:p->n);
 
       nonzero[vi->coupling_mag[i]]=1; 
       nonzero[vi->coupling_ang[i]]=1; 
@@ -1218,14 +1172,15 @@
             couple_lossless(rM[l],rA[l],qM+l,qA+l);
           }
         }
-
-	for(k=0;k<partition && qacc<acc;k++){
-	  int l=mag_sort[i][j+k];
-	  if(l>=limit && rint(qM[l])==0.f){
-	    qM[l]=unitnorm(qM[l]);
-	    qacc+=1.f;
-	  }
-	} 
+	
+	if(p->vi->normal_point_p)
+	  for(k=0;k<partition && qacc<acc;k++){
+	    int l=mag_sort[i][j+k];
+	    if(l>=limit && rint(qM[l])==0.f){
+	      qM[l]=unitnorm(qM[l]);
+	      qacc+=1.f;
+	    }
+	  } 
       }
     }
   }

<p><p>1.28.2.4  +3 -7      vorbis/lib/psy.h

Index: psy.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.h,v
retrieving revision 1.28.2.3
retrieving revision 1.28.2.4
diff -u -r1.28.2.3 -r1.28.2.4
--- psy.h	2002/05/31 00:16:11	1.28.2.3
+++ psy.h	2002/06/11 04:44:46	1.28.2.4
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.28.2.3 2002/05/31 00:16:11 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.28.2.4 2002/06/11 04:44:46 xiphmont Exp $
 
  ********************************************************************/
 
@@ -51,7 +51,6 @@
   vp_attenblock toneatt;
 
   int peakattp;
-  int curvelimitp;
   vp_attenblock peakatt;
 
   int noisemaskp;
@@ -66,6 +65,8 @@
 
   float max_curve_dB;
 
+  int normal_channel_p;
+  int normal_point_p;
   int normal_start;
   int normal_partition;
 } vorbis_info_psy;
@@ -81,12 +82,7 @@
 
   float ampmax_att_per_sec;
 
-  /* delay caching... how many samples to keep around prior to our
-     current block to aid in analysis? */
-  int   delaycache;
-
   /* channel coupling config */
-  float monofilter_kHz[PACKETBLOBS];  
   int   coupling_pointlimit[2][PACKETBLOBS];  
   int   coupling_pointamp[PACKETBLOBS];  
 

<p><p>1.26.4.2  +4 -1      vorbis/lib/synthesis.c

Index: synthesis.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/synthesis.c,v
retrieving revision 1.26.4.1
retrieving revision 1.26.4.2
diff -u -r1.26.4.1 -r1.26.4.2
--- synthesis.c	2002/05/18 01:39:29	1.26.4.1
+++ synthesis.c	2002/06/11 04:44:46	1.26.4.2
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: single-block PCM synthesis
- last mod: $Id: synthesis.c,v 1.26.4.1 2002/05/18 01:39:29 xiphmont Exp $
+ last mod: $Id: synthesis.c,v 1.26.4.2 2002/06/11 04:44:46 xiphmont Exp $
 
  ********************************************************************/
 
@@ -48,6 +48,9 @@
   vb->mode=mode;
   vb->W=ci->mode_param[mode]->blockflag;
   if(vb->W){
+
+    /* this doesn;t get mapped through mode selection as it's used
+       only for window selection */
     vb->lW=oggpack_read(opb,1);
     vb->nW=oggpack_read(opb,1);
     if(vb->nW==-1)   return(OV_EBADPACKET);

<p><p>1.39.2.5  +500 -465  vorbis/lib/vorbisenc.c

Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.39.2.4
retrieving revision 1.39.2.5
diff -u -r1.39.2.4 -r1.39.2.5
--- vorbisenc.c	2002/05/31 00:16:11	1.39.2.4
+++ vorbisenc.c	2002/06/11 04:44:46	1.39.2.5
@@ -11,14 +11,13 @@
  ********************************************************************
 
  function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.39.2.4 2002/05/31 00:16:11 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.39.2.5 2002/06/11 04:44:46 xiphmont Exp $
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include <stdarg.h>
 
 #include "vorbis/codec.h"
 #include "vorbis/vorbisenc.h"
@@ -32,20 +31,110 @@
    all the modes a little less annoying.  If we use a residue backend
    with > 10 partition types, or a different division of iteration,
    this needs to be updated. */
+
 typedef struct {
   vorbis_info_residue0 *res[2];
   static_codebook *book_aux[2];
+  static_codebook *book_aux_managed[2];
   static_codebook *books_base[10][3];
 } vorbis_residue_template;
 
 typedef struct vp_adjblock{
   int block[P_BANDS][P_LEVELS];
 } vp_adjblock;
+
+typedef struct {
+  int data[NOISE_COMPAND_LEVELS];
+} compandblock;
+
+/* high level configuration information for setting things up
+   step-by-step with the detailed vorbis_encode_ctl interface.
+   There's a fair amount of redundancy such that interactive setup
+   does not directly deal with any vorbis_info or codec_setup_info
+   initialization; it's all stored (until full init) in this highlevel
+   setup, then flushed out to the real codec setup structs later. */
+
+typedef struct { int data[P_NOISECURVES]; } adj3; 
+typedef struct { int data[PACKETBLOBS]; } adjB; 
+typedef struct {
+  int lo;
+  int hi;
+  int fixed;
+} noiseguard;
+typedef struct {
+  int data[P_NOISECURVES][17];
+} noise3;
+typedef struct {
+  float data[27];
+} athcurve;
+
+typedef struct {
+  int      mappings;
+  double  *rate_mapping;
+  double  *quality_mapping;
+  int      coupling_restriction;
+  long     bitrate_min_restriction;
+  long     bitrate_max_restriction;
+
+
+  int     *blocksize_short;
+  int     *blocksize_long;
+
+  adj3    *psy_tone_masteratt;
+  int     *psy_tone_0dB;
+  int     *psy_tone_masterdepth;        // attempt to eliminate
+  int     *psy_tone_dBsuppress;
+
+  vp_adjblock *psy_tone_adj_impulse;
+  vp_adjblock *psy_tone_adj_long;
+  vp_adjblock *psy_tone_adj_other;
+  vp_adjblock *psy_tone_depth;        // attempt to eliminate
+
+  noiseguard  *psy_noiseguards;
+  noise3      *psy_noise_bias_impulse;
+  noise3      *psy_noise_bias_long;
+  noise3      *psy_noise_bias_other;
+  int         *psy_noise_dBsuppress;
+
+  compandblock  *psy_noise_compand;
+  double        *psy_noise_compand_short_mapping;
+  double        *psy_noise_compand_long_mapping;
+
+  int      *psy_noise_normal_start[2];
+  int      *psy_noise_normal_partition[2];
+
+  int      *psy_ath_float;
+  int      *psy_ath_abs;
+  athcurve *psy_ath;
+  double   *psy_ath_mapping;
+
+  double   *psy_lowpass;
 
-#include "modes/residue_44.h"
-#include "modes/psych_44.h"
-#include "modes/floor_44.h"
+  vorbis_info_psy_global *global_params;
+  double *global_mapping;
+  adjB   *stereo_modes;
+  adjB   *stereo_pkHz;
 
+
+  static_codebook ***floor_books;
+  vorbis_info_floor1 *floor_params;
+  int *floor_short_mapping;
+  int *floor_long_mapping;
+
+  vorbis_residue_template *residue;
+  int res_type;
+} ve_setup_data_template;
+
+#include "modes/setup_44.h"
+
+static ve_setup_data_template *setup_list[]={
+  &ve_setup_44_stereo,
+
+
+  0
+};
+
+
 /* a few static coder conventions */
 static vorbis_info_mode _mode_template[2]={
   {0,0,0,-1},
@@ -60,38 +149,27 @@
   {1, {0,0}, {1}, {-1}, 0,{0},{0}}
 };
 
-static int vorbis_encode_toplevel_setup(vorbis_info *vi,int small,
-					int large,int ch,long rate){
+static int vorbis_encode_toplevel_setup(vorbis_info *vi,int ch,long rate){
   if(vi && vi->codec_setup){
-    codec_setup_info *ci=vi->codec_setup;
 
     vi->version=0;
     vi->channels=ch;
     vi->rate=rate;
-    
-    ci->blocksizes[0]=small;
-    ci->blocksizes[1]=large;
 
     return(0);
   }
   return(OV_EINVAL);
 }
 
-static int vorbis_encode_floor_setup(vorbis_info *vi,double q,int block,
-				    static_codebook    ***books, 
-				    vorbis_info_floor1 *in, 
-				    ...){
-  int x[11],i,k,iq=rint(q*10);
+static int vorbis_encode_floor_setup(vorbis_info *vi,double s,int block,
+				     static_codebook    ***books, 
+				     vorbis_info_floor1 *in, 
+				     int *x){
+  int i,k,is=rint(s);
   vorbis_info_floor1 *f=_ogg_calloc(1,sizeof(*f));
   codec_setup_info *ci=vi->codec_setup;
-  va_list ap;
-
-  va_start(ap,in);
-  for(i=0;i<11;i++)
-    x[i]=va_arg(ap,int);
-  va_end(ap);
 
-  memcpy(f,in+x[iq],sizeof(*f));
+  memcpy(f,in+x[is],sizeof(*f));
   /* fill in the lowpass field, even if it's temporary */
   f->n=ci->blocksizes[block]>>1;
 
@@ -112,7 +190,7 @@
     }
 
     for(i=0;i<=maxbook;i++)
-      ci->book_param[ci->books++]=books[x[iq]][i];
+      ci->book_param[ci->books++]=books[x[is]][i];
   }
 
   /* for now, we're only using floor 1 */
@@ -123,41 +201,28 @@
   return(0);
 }
 
-static int vorbis_encode_global_psych_setup(vorbis_info *vi,double q,
+static int vorbis_encode_global_psych_setup(vorbis_info *vi,double s,
                                             vorbis_info_psy_global *in, 
-					    ...){
-  int i,iq=q*10;
-  double x[11],dq;
+					    double *x){
+  int i,is=s;
+  double ds=s-is;
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy_global *g=&ci->psy_g_param;
-  va_list ap;
-  
-  va_start(ap,in);
-  for(i=0;i<11;i++)
-    x[i]=va_arg(ap,double);
-  va_end(ap);
-  
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
-  }
   
-  memcpy(g,in+(int)x[iq],sizeof(*g));
+  memcpy(g,in+(int)x[is],sizeof(*g));
   
-  dq=x[iq]*(1.-dq)+x[iq+1]*dq;
-  iq=(int)dq;
-  dq-=iq;
-  if(dq==0 && iq>0){
-    iq--;
-    dq=1.;
+  ds=x[is]*(1.-ds)+x[is+1]*ds;
+  is=(int)ds;
+  ds-=is;
+  if(ds==0 && is>0){
+    is--;
+    ds=1.;
   }
   
   /* interpolate the trigger threshholds */
   for(i=0;i<4;i++){
-    g->preecho_thresh[i]=in[iq].preecho_thresh[i]*(1.-dq)+in[iq+1].preecho_thresh[i]*dq;
-    g->postecho_thresh[i]=in[iq].postecho_thresh[i]*(1.-dq)+in[iq+1].postecho_thresh[i]*dq;
+    g->preecho_thresh[i]=in[is].preecho_thresh[i]*(1.-ds)+in[is+1].preecho_thresh[i]*ds;
+    g->postecho_thresh[i]=in[is].postecho_thresh[i]*(1.-ds)+in[is+1].postecho_thresh[i]*ds;
   }
   g->ampmax_att_per_sec=ci->hi.amplitude_track_dBpersec;
   return(0);
@@ -165,38 +230,31 @@
 
 static int vorbis_encode_global_stereo(vorbis_info *vi,
                                        highlevel_encode_setup *hi,
-				       int pdB[][PACKETBLOBS],
-				       double pkHz[][PACKETBLOBS]){
-  float q=hi->stereo_point_q;
-  int i,iq=q*10;
-  double dq;
+				       adjB *pdB,
+				       adjB *pkHz){
+  float s=hi->stereo_point_setting;
+  int i,is=s;
+  double ds=s-is;
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy_global *g=&ci->psy_g_param;
 
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
-  }
-
   if(hi->managed){
-    memcpy(g->coupling_pointamp,pdB[iq],sizeof(*pdB));
+    memcpy(g->coupling_pointamp,pdB[is].data,sizeof(*pdB));
     /* interpolate the kHz threshholds */
     for(i=0;i<PACKETBLOBS;i++){
-      float kHz=pkHz[iq*2][i]*(1.-dq)+pkHz[iq*2+2][i]*dq;
+      float kHz=pkHz[is*2].data[i]*(1.-ds)+pkHz[is*2+2].data[i]*ds;
       g->coupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
-      kHz=pkHz[iq*2+1][i]*(1.-dq)+pkHz[iq*2+3][i]*dq;
+      kHz=pkHz[is*2+1].data[i]*(1.-ds)+pkHz[is*2+3].data[i]*ds;
       g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
     }
   }else{
-    int point_dB=pdB[iq][PACKETBLOBS/2];
-    float kHz=pkHz[iq*2][PACKETBLOBS/2]*(1.-dq)+pkHz[iq*2+2][PACKETBLOBS/2]*dq;
+    int point_dB=pdB[is].data[PACKETBLOBS/2];
+    float kHz=pkHz[is*2].data[PACKETBLOBS/2]*(1.-ds)+pkHz[is*2+2].data[PACKETBLOBS/2]*ds;
     for(i=0;i<PACKETBLOBS;i++)
       g->coupling_pointamp[i]=point_dB;
     for(i=0;i<PACKETBLOBS;i++)
       g->coupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
-    kHz=pkHz[iq*2+1][PACKETBLOBS/2]*(1.-dq)+pkHz[iq*2+3][PACKETBLOBS/2]*dq;
+    kHz=pkHz[is*2+1].data[PACKETBLOBS/2]*(1.-ds)+pkHz[is*2+3].data[PACKETBLOBS/2]*ds;
     for(i=0;i<PACKETBLOBS;i++)
       g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
   }
@@ -204,9 +262,14 @@
   return(0);
 }
 
-static int vorbis_encode_psyset_setup(vorbis_info *vi,int block){
+static int vorbis_encode_psyset_setup(vorbis_info *vi,double s,
+				      int *nn_start,
+				      int *nn_partition,
+				      int block){
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy *p=ci->psy_param[block];
+  highlevel_encode_setup *hi=&ci->hi;
+  int is=s;
   
   if(block>=ci->psys)
     ci->psys=block+1;
@@ -218,187 +281,123 @@
   memcpy(p,&_psy_info_template,sizeof(*p));
   p->blockflag=block>>1;
 
-  /* temporary */
-  p->normal_start=(block<2?16:128);
-  p->normal_partition=(block<2?16:32);
-  
+  if(hi->noise_normalize_p){
+    p->normal_channel_p=1;
+    p->normal_point_p=1;
+    p->normal_start=nn_start[is];
+    p->normal_partition=nn_partition[is];
+  }
+    
   return 0;
 }
 
-static int vorbis_encode_tonemask_setup(vorbis_info *vi,double q,int block,
-					double att[11][3],
-					double *max,
-					int *peaklimit_bands,
+static int vorbis_encode_tonemask_setup(vorbis_info *vi,double s,int block,
+					adj3 *att,
+					int  *max,
                                         vp_adjblock *in){
-  int i,j,iq;
-  double dq;
+  int i,j,is=s;
+  double ds=s-is;
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy *p=ci->psy_param[block];
 
-  iq=q*10;
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
-  }
-
   /* 0 and 2 are only used by bitmanagement, but there's no harm to always
      filling the values in here */
-  p->tone_masteratt[0]=att[iq][0]*(1.-dq)+att[iq+1][0]*dq;
-  p->tone_masteratt[1]=att[iq][1]*(1.-dq)+att[iq+1][1]*dq;
-  p->tone_masteratt[2]=att[iq][2]*(1.-dq)+att[iq+1][2]*dq;
-
-  p->max_curve_dB=max[iq]*(1.-dq)+max[iq+1]*dq;
-  p->curvelimitp=peaklimit_bands[iq];
-
-  iq=q*5.;
-  if(iq==5){
-    iq=5;
-    dq=1.;
-  }else{
-    dq=q*5.-iq;
-  }
-  
+  p->tone_masteratt[0]=att[is].data[0]*(1.-ds)+att[is+1].data[0]*ds;
+  p->tone_masteratt[1]=att[is].data[1]*(1.-ds)+att[is+1].data[1]*ds;
+  p->tone_masteratt[2]=att[is].data[2]*(1.-ds)+att[is+1].data[2]*ds;
+
+  p->max_curve_dB=max[is]*(1.-ds)+max[is+1]*ds;
+
   for(i=0;i<P_BANDS;i++)
     for(j=0;j<P_LEVELS;j++)
       p->toneatt.block[i][j]=(j<4?4:j)*-10.+
-	in[iq].block[i][j]*(1.-dq)+in[iq+1].block[i][j]*dq;
+	in[is].block[i][j]*(1.-ds)+in[is+1].block[i][j]*ds;
   return(0);
 }
 
 
-static int vorbis_encode_compand_setup(vorbis_info *vi,double q,int block,
-				      float in[][NOISE_COMPAND_LEVELS], ...){
-  int i,iq=q*10;
-  double x[11],dq;
+static int vorbis_encode_compand_setup(vorbis_info *vi,double s,int block,
+				       compandblock *in, double *x){
+  int i,is=s;
+  double ds=s-is;
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy *p=ci->psy_param[block];
-  va_list ap;
-  
-  va_start(ap,in);
-  for(i=0;i<11;i++)
-    x[i]=va_arg(ap,double);
-  va_end(ap);
-
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
-  }
 
-  dq=x[iq]*(1.-dq)+x[iq+1]*dq;
-  iq=(int)dq;
-  dq-=iq;
-  if(dq==0 && iq>0){
-    iq--;
-    dq=1.;
+  ds=x[is]*(1.-ds)+x[is+1]*ds;
+  is=(int)ds;
+  ds-=is;
+  if(ds==0 && is>0){
+    is--;
+    ds=1.;
   }
 
   /* interpolate the compander settings */
   for(i=0;i<NOISE_COMPAND_LEVELS;i++)
-    p->noisecompand[i]=in[iq][i]*(1.-dq)+in[iq+1][i]*dq;
+    p->noisecompand[i]=in[is].data[i]*(1.-ds)+in[is+1].data[i]*ds;
   return(0);
 }
 
-static int vorbis_encode_peak_setup(vorbis_info *vi,double q,int block,
-				    double *guard,
-				    double *suppress,
+static int vorbis_encode_peak_setup(vorbis_info *vi,double s,int block,
+				    int *guard,
+				    int *suppress,
                                     vp_adjblock *in){
-  int i,j,iq;
-  double dq;
+  int i,j,is=s;
+  double ds=s-is;
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy *p=ci->psy_param[block];
 
-  iq=q*10;
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
-  }
-
   p->peakattp=1;
-  p->tone_guard=guard[iq]*(1.-dq)+guard[iq+1]*dq;
-  p->tone_abs_limit=suppress[iq]*(1.-dq)+suppress[iq+1]*dq;
-
-  iq=q*5.;
-  if(iq==5){
-    iq=5;
-    dq=1.;
-  }else{
-    dq=q*5.-iq;
-  }
+  p->tone_guard=guard[is]*(1.-ds)+guard[is+1]*ds;
+  p->tone_abs_limit=suppress[is]*(1.-ds)+suppress[is+1]*ds;
 
   for(i=0;i<P_BANDS;i++)
     for(j=0;j<P_LEVELS;j++)
       p->peakatt.block[i][j]=(j<4?4:j)*-10.+
-	in[iq].block[i][j]*(1.-dq)+in[iq+1].block[i][j]*dq;
+	in[is].block[i][j]*(1.-ds)+in[is+1].block[i][j]*ds;
   return(0);
 }
 
-static int vorbis_encode_noisebias_setup(vorbis_info *vi,double q,int block,
-					 double *suppress,
-					 int in[][P_NOISECURVES][17],
-					 int guard[33]){
-  int i,iq=q*10,j;
-  double dq;
+static int vorbis_encode_noisebias_setup(vorbis_info *vi,double s,int block,
+					 int *suppress,
+					 noise3 *in,
+					 noiseguard *guard){
+  int i,is=s,j;
+  double ds=s-is;
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy *p=ci->psy_param[block];
-
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
-  }
 
-  p->noisemaxsupp=suppress[iq]*(1.-dq)+suppress[iq+1]*dq;
-  p->noisewindowlomin=guard[iq*3];
-  p->noisewindowhimin=guard[iq*3+1];
-  p->noisewindowfixed=guard[iq*3+2];
+  p->noisemaxsupp=suppress[is]*(1.-ds)+suppress[is+1]*ds;
+  p->noisewindowlomin=guard[is].lo;
+  p->noisewindowhimin=guard[is].hi;
+  p->noisewindowfixed=guard[is].fixed;
 
   for(j=0;j<P_NOISECURVES;j++)
     for(i=0;i<P_BANDS;i++)
-      p->noiseoff[j][i]=in[iq][j][i]*(1.-dq)+in[iq+1][j][i]*dq;
+      p->noiseoff[j][i]=in[is].data[j][i]*(1.-ds)+in[is+1].data[j][i]*ds;
 
   return(0);
 }
 
-static int vorbis_encode_ath_setup(vorbis_info *vi,double q,int block,
-				   float in[][27], ...){
-  int i,iq=q*10;
-  double x[11],dq;
+static int vorbis_encode_ath_setup(vorbis_info *vi,double s,int block,
+				   athcurve *in, double *x){
+  int i,is=s;
+  double ds;
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy *p=ci->psy_param[block];
-  va_list ap;
-  
-  va_start(ap,in);
-  for(i=0;i<11;i++)
-    x[i]=va_arg(ap,double);
-  va_end(ap);
 
   p->ath_adjatt=ci->hi.ath_floating_dB;
   p->ath_maxatt=ci->hi.ath_absolute_dB;
-
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
-  }
 
-  dq=x[iq]*(1.-dq)+x[iq+1]*dq;
-  iq=(int)dq;
-  dq-=iq;
-  if(dq==0 && iq>0){
-    iq--;
-    dq=1.;
+  ds=x[is]*(1.-ds)+x[is+1]*ds;
+  is=(int)ds;
+  ds-=is;
+  if(ds==0 && is>0){
+    is--;
+    ds=1.;
   }
 
   for(i=0;i<27;i++)
-    p->ath[i]=in[iq][i]*(1.-dq)+in[iq+1][i]*dq;
+    p->ath[i]=in[is].data[i]*(1.-ds)+in[is+1].data[i]*ds;
   return(0);
 }
 
@@ -411,12 +410,25 @@
   return(ci->books++);
 }
 
-static int vorbis_encode_residue_setup(vorbis_info *vi,double q,int block,
-				       int coupled_p,
+static void vorbis_encode_blocksize_setup(vorbis_info *vi,double s,
+					 int *shortb,int *longb){
+
+  codec_setup_info *ci=vi->codec_setup;
+  int is=s;
+  
+  int blockshort=shortb[is];
+  int blocklong=longb[is];
+  ci->blocksizes[0]=blockshort;
+  ci->blocksizes[1]=blocklong;
+
+}
+
+static int vorbis_encode_residue_setup(vorbis_info *vi,double s,int block,
+				       int type,
                                        vorbis_residue_template *in){
 
   codec_setup_info *ci=vi->codec_setup;
-  int i,iq=q*10;
+  int i,is=s;
   int n,k;
   int number=block;
 
@@ -438,37 +450,35 @@
   if(number>=ci->maps)ci->maps=number+1;
   ((vorbis_info_mapping0 *)(ci->map_param[number]))->residuesubmap[0]=number;
 
-  memcpy(r,in[iq].res[block],sizeof(*r));
+  memcpy(r,in[is].res[block],sizeof(*r));
   if(ci->residues<=number)ci->residues=number+1;
 
-  if(block){
-    r->grouping=32;
-  }else{
+  switch(ci->blocksizes[block]){
+  case 64:case 128:case 256:case 512:
     r->grouping=16;
-  }
-
-  /* for uncoupled, we use type 1, else type 2 */
-  if(coupled_p){
-    ci->residue_type[number]=2;
-  }else{
-    ci->residue_type[number]=1;
+    break;
+  default:
+    r->grouping=32;
+    break;
   }
+  ci->residue_type[number]=type;
 
   switch(ci->residue_type[number]){
   case 1:
-    n=r->end=ci->blocksizes[block?1:0]>>1; /* to be adjusted by lowpass later */
+    n=r->end=ci->blocksizes[block]>>1; /* to be adjusted by lowpass later */
     break;
   case 2:
-    n=r->end=(ci->blocksizes[block?1:0]>>1)*vi->channels; /* to be adjusted by lowpass later */
+    n=r->end=(ci->blocksizes[block]>>1)*vi->channels; /* to be adjusted by lowpass later */
     break;
   }
   
   for(i=0;i<r->partitions;i++)
     for(k=0;k<3;k++)
-      if(in[iq].books_base[i][k])
+      if(in[is].books_base[i][k])
         r->secondstages[i]|=(1<<k);
   
-  if(coupled_p){
+  if(type==2){ /* that is to say, if we're coupling, which will always mean
+		  res type 2 in this encoder for now */
     vorbis_info_mapping0 *map=ci->map_param[number];
     
     map->coupling_steps=1;
@@ -480,14 +490,14 @@
   /* fill in all the books */
   {
     int booklist=0,k;
-    r->groupbook=book_dup_or_new(ci,in[iq].book_aux[block]);
-    ci->book_param[r->groupbook]=in[iq].book_aux[block];
+    r->groupbook=book_dup_or_new(ci,in[is].book_aux[block]);
+    ci->book_param[r->groupbook]=in[is].book_aux[block];
     for(i=0;i<r->partitions;i++){
       for(k=0;k<3;k++){
-	if(in[iq].books_base[i][k]){
-	  int bookid=book_dup_or_new(ci,in[iq].books_base[i][k]);
+	if(in[is].books_base[i][k]){
+	  int bookid=book_dup_or_new(ci,in[is].books_base[i][k]);
           r->booklist[booklist++]=bookid;
-	  ci->book_param[bookid]=in[iq].books_base[i][k];
+	  ci->book_param[bookid]=in[is].books_base[i][k];
         }
       }
     }
@@ -531,274 +541,309 @@
 
 /* the final setup call */
 int vorbis_encode_setup_init(vorbis_info *vi){
-  int ret=0;
-  /*long rate=vi->rate;*/
-  long channels=vi->channels;
+  int ret=0,i0=0;
   codec_setup_info *ci=vi->codec_setup;
+  ve_setup_data_template *setup=NULL;
   highlevel_encode_setup *hi=&ci->hi;
-  
-  ret|=vorbis_encode_floor_setup(vi,hi->base_quality_short,0,
-				 _floor_44_128_books,_floor_44_128,
-				 0,1,1,2,0,2,2,2,2,2,2);
-  ret|=vorbis_encode_floor_setup(vi,hi->base_quality_long,1,
-				 _floor_44_1024_books,_floor_44_1024,
-				 0,0,0,0,0,0,0,0,0,0,0);
-  
-  ret|=vorbis_encode_global_psych_setup(vi,hi->trigger_quality,_psy_global_44,
-					0., 1., 1.5, 2., 2., 2.5, 3., 3.5, 4., 4., 4.);
+
+  if(ci==NULL)return(OV_EINVAL);
+  if(!hi->impulse_block_p)i0=1;
+
+  /* too low/high an ATH floater is nonsensical, but doesn't break anything */
+  if(hi->ath_floating_dB>-80)hi->ath_floating_dB=-80;
+  if(hi->ath_floating_dB<-200)hi->ath_floating_dB=-200;
+
+  /* again, bound this to avoid the app shooting itself int he foot
+     too badly */
+  if(hi->amplitude_track_dBpersec>0.)hi->amplitude_track_dBpersec=0.;
+  if(hi->amplitude_track_dBpersec<-99999.)hi->amplitude_track_dBpersec=-99999.;
+  
+  /* get the appropriate setup template; matches the fetch in previous
+     stages */
+  setup=(ve_setup_data_template *)hi->setup;
+  if(setup==NULL)return(OV_EINVAL);
+
+  /* choose block sizes from configured sizes as well as paying
+     attention to long_block_p and short_block_p.  If the configured
+     short and long blocks are the same length, we set long_block_p
+     and unset short_block_p */
+  vorbis_encode_blocksize_setup(vi,hi->base_setting,
+				setup->blocksize_short,
+				setup->blocksize_long);
+  
+  /* floor setup; choose proper floor params.  Allocated on the floor
+     stack in order; if we alloc only long floor, it's 0 */
+  ret|=vorbis_encode_floor_setup(vi,hi->short_setting,0,
+				 setup->floor_books,
+				 setup->floor_params,
+				 setup->floor_short_mapping);
+  ret|=vorbis_encode_floor_setup(vi,hi->long_setting,1,
+				 setup->floor_books,
+				 setup->floor_params,
+				 setup->floor_long_mapping);
+  
+  /* setup of [mostly] short block detection */
+  ret|=vorbis_encode_global_psych_setup(vi,hi->trigger_setting,
+					setup->global_params,
+					setup->global_mapping);
   
   ret|=vorbis_encode_global_stereo(vi,hi,
-				   _psy_stereo_modes_44,
-				   _psy_stereo_pkHz_44);
+				   setup->stereo_modes,
+				   setup->stereo_pkHz);
 
-  ret|=vorbis_encode_psyset_setup(vi,0);
-  ret|=vorbis_encode_psyset_setup(vi,1);
-  ret|=vorbis_encode_psyset_setup(vi,2);
-  ret|=vorbis_encode_psyset_setup(vi,3);
-  
-  ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[0].tone_mask_quality,0,
-				    _psy_tone_masteratt_44,_psy_tone_0dB,
-				    _psy_ehmer_bandlimit,
-				    _vp_tonemask_adj_otherblock);
-  ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[1].tone_mask_quality,1,
-				    _psy_tone_masteratt_44,_psy_tone_0dB,
-				    _psy_ehmer_bandlimit,
-				    _vp_tonemask_adj_otherblock);
-  ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[2].tone_mask_quality,2,
-				    _psy_tone_masteratt_44,_psy_tone_0dB,
-				    _psy_ehmer_bandlimit,
-				    _vp_tonemask_adj_otherblock);
-  ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[3].tone_mask_quality,3,
-				    _psy_tone_masteratt_44,_psy_tone_0dB,
-				    _psy_ehmer_bandlimit,
-				    _vp_tonemask_adj_longblock);
-  
-  ret|=vorbis_encode_compand_setup(vi,hi->blocktype[0].noise_compand_quality,
-				  0,_psy_compand_44_short,
-				  1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
-  ret|=vorbis_encode_compand_setup(vi,hi->blocktype[1].noise_compand_quality,
-				  1,_psy_compand_44_short,
-				  1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
-  ret|=vorbis_encode_compand_setup(vi,hi->blocktype[2].noise_compand_quality,
-				  2,_psy_compand_44,
-				  1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
-  ret|=vorbis_encode_compand_setup(vi,hi->blocktype[3].noise_compand_quality,
-				  3,_psy_compand_44,
-				  1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
-  ret|=vorbis_encode_peak_setup(vi,hi->blocktype[0].tone_peaklimit_quality,
-				0,_psy_tone_masterguard,_psy_tone_suppress,
-				_vp_peakguard);
-  ret|=vorbis_encode_peak_setup(vi,hi->blocktype[1].tone_peaklimit_quality,
-				1,_psy_tone_masterguard,_psy_tone_suppress,
-				_vp_peakguard);
-  ret|=vorbis_encode_peak_setup(vi,hi->blocktype[2].tone_peaklimit_quality,
-				2,_psy_tone_masterguard,_psy_tone_suppress,
-				_vp_peakguard);
-  ret|=vorbis_encode_peak_setup(vi,hi->blocktype[3].tone_peaklimit_quality,
-				3,_psy_tone_masterguard,_psy_tone_suppress,
-				_vp_peakguard);
-
-  if(hi->impulse_block_p){
-    ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[0].noise_bias_quality,
-				       0,_psy_noise_suppress,_psy_noisebias_impulse,
-				       _psy_noiseguards_short);
-  }else{
-    ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[0].noise_bias_quality,
-				       0,_psy_noise_suppress,_psy_noisebias_other,
-				       _psy_noiseguards_short);
-  }
-
-  ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[1].noise_bias_quality,
-				    1,_psy_noise_suppress,_psy_noisebias_other,
-				      _psy_noiseguards_short);
-  ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[2].noise_bias_quality,
-				      2,_psy_noise_suppress,_psy_noisebias_other,
-				    _psy_noiseguards_long);
-  ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[3].noise_bias_quality,
-				    3,_psy_noise_suppress,_psy_noisebias_long,
-				    _psy_noiseguards_long);
-
-  ret|=vorbis_encode_ath_setup(vi,hi->blocktype[0].ath_quality,0,ATH_Bark_dB,
-			      0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
-  ret|=vorbis_encode_ath_setup(vi,hi->blocktype[1].ath_quality,1,ATH_Bark_dB,
-			      0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
-  ret|=vorbis_encode_ath_setup(vi,hi->blocktype[2].ath_quality,2,ATH_Bark_dB,
-			      0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
-  ret|=vorbis_encode_ath_setup(vi,hi->blocktype[3].ath_quality,3,ATH_Bark_dB,
-			      0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
+  /* basic psych setup and noise normalization */
+  ret|=vorbis_encode_psyset_setup(vi,hi->short_setting,
+				  setup->psy_noise_normal_start[0],
+				  setup->psy_noise_normal_partition[0],  
+				  0);
+  ret|=vorbis_encode_psyset_setup(vi,hi->short_setting,
+				  setup->psy_noise_normal_start[0],
+				  setup->psy_noise_normal_partition[0],  
+				  1);
+  ret|=vorbis_encode_psyset_setup(vi,hi->long_setting,
+				  setup->psy_noise_normal_start[1],
+				  setup->psy_noise_normal_partition[1],  
+				  2);
+  ret|=vorbis_encode_psyset_setup(vi,hi->long_setting,
+				  setup->psy_noise_normal_start[1],
+				  setup->psy_noise_normal_partition[1],  
+				  3);
+
+  /* tone masking setup */
+  ret|=vorbis_encode_tonemask_setup(vi,hi->block[i0].tone_mask_setting,0,
+				    setup->psy_tone_masteratt,
+				    setup->psy_tone_0dB,
+				    setup->psy_tone_adj_impulse);
+  ret|=vorbis_encode_tonemask_setup(vi,hi->block[1].tone_mask_setting,1,
+				    setup->psy_tone_masteratt,
+				    setup->psy_tone_0dB,
+				    setup->psy_tone_adj_other);
+  ret|=vorbis_encode_tonemask_setup(vi,hi->block[2].tone_mask_setting,2,
+				    setup->psy_tone_masteratt,
+				    setup->psy_tone_0dB,
+				    setup->psy_tone_adj_other);
+  ret|=vorbis_encode_tonemask_setup(vi,hi->block[3].tone_mask_setting,3,
+				    setup->psy_tone_masteratt,
+				    setup->psy_tone_0dB,
+				    setup->psy_tone_adj_long);
+
+  /* noise companding setup */
+  ret|=vorbis_encode_compand_setup(vi,hi->block[i0].noise_compand_setting,0,
+				   setup->psy_noise_compand,
+				   setup->psy_noise_compand_short_mapping);
+  ret|=vorbis_encode_compand_setup(vi,hi->block[1].noise_compand_setting,1,
+				   setup->psy_noise_compand,
+				   setup->psy_noise_compand_short_mapping);
+  ret|=vorbis_encode_compand_setup(vi,hi->block[2].noise_compand_setting,2,
+				   setup->psy_noise_compand,
+				   setup->psy_noise_compand_long_mapping);
+  ret|=vorbis_encode_compand_setup(vi,hi->block[3].noise_compand_setting,3,
+				   setup->psy_noise_compand,
+				   setup->psy_noise_compand_long_mapping);
+
+  /* peak guarding setup */
+  ret|=vorbis_encode_peak_setup(vi,hi->block[i0].tone_peaklimit_setting,0,
+				setup->psy_tone_masterdepth,
+				setup->psy_tone_dBsuppress,
+				setup->psy_tone_depth);
+  ret|=vorbis_encode_peak_setup(vi,hi->block[1].tone_peaklimit_setting,1,
+				setup->psy_tone_masterdepth,
+				setup->psy_tone_dBsuppress,
+				setup->psy_tone_depth);
+  ret|=vorbis_encode_peak_setup(vi,hi->block[2].tone_peaklimit_setting,2,
+				setup->psy_tone_masterdepth,
+				setup->psy_tone_dBsuppress,
+				setup->psy_tone_depth);
+  ret|=vorbis_encode_peak_setup(vi,hi->block[3].tone_peaklimit_setting,3,
+				setup->psy_tone_masterdepth,
+				setup->psy_tone_dBsuppress,
+				setup->psy_tone_depth);
+
+  /* noise bias setup */
+  ret|=vorbis_encode_noisebias_setup(vi,hi->block[i0].noise_bias_setting,0,
+				     setup->psy_noise_dBsuppress,
+				     setup->psy_noise_bias_impulse,
+				     setup->psy_noiseguards);
+  ret|=vorbis_encode_noisebias_setup(vi,hi->block[1].noise_bias_setting,1,
+				     setup->psy_noise_dBsuppress,
+				     setup->psy_noise_bias_other,
+				     setup->psy_noiseguards);
+  ret|=vorbis_encode_noisebias_setup(vi,hi->block[2].noise_bias_setting,2,
+				     setup->psy_noise_dBsuppress,
+				     setup->psy_noise_bias_other,
+				     setup->psy_noiseguards);
+  ret|=vorbis_encode_noisebias_setup(vi,hi->block[3].noise_bias_setting,3,
+				     setup->psy_noise_dBsuppress,
+				     setup->psy_noise_bias_long,
+				     setup->psy_noiseguards);
+
+  ret|=vorbis_encode_ath_setup(vi,hi->ath_setting,0,
+			       setup->psy_ath,
+			       setup->psy_ath_mapping);
+  ret|=vorbis_encode_ath_setup(vi,hi->ath_setting,1,
+			       setup->psy_ath,
+			       setup->psy_ath_mapping);
+  ret|=vorbis_encode_ath_setup(vi,hi->ath_setting,2,
+			       setup->psy_ath,
+			       setup->psy_ath_mapping);
+  ret|=vorbis_encode_ath_setup(vi,hi->ath_setting,3,
+			       setup->psy_ath,
+				 setup->psy_ath_mapping);
 
   if(ret){
     vorbis_info_clear(vi);
     return ret; 
   }
-
-  if(channels==2 && hi->stereo_couple_p){
-    /* setup specific to stereo coupling */
-
-    if(hi->managed){
-      ret|=vorbis_encode_residue_setup(vi,hi->base_quality_short,0,
-				       1, /* coupled */
-				       _residue_template_44_stereo_m);
-      
-      ret|=vorbis_encode_residue_setup(vi,hi->base_quality_long,1,
-				       1, /* coupled */
-				       _residue_template_44_stereo_m);
-    }else{
-      ret|=vorbis_encode_residue_setup(vi,hi->base_quality_short,0,
-				       1, /* coupled */
-				       _residue_template_44_stereo);
-      
-      ret|=vorbis_encode_residue_setup(vi,hi->base_quality_long,1,
-				       1, /* coupled */
-				       _residue_template_44_stereo);
-    }
 
-  }else{
-    /* setup specific to non-stereo (mono or uncoupled polyphonic)
-       coupling */
-    ret|=vorbis_encode_residue_setup(vi,hi->base_quality_short,0,
-				     0, /* uncoupled */
-				     _residue_template_44_uncoupled);
-      
-    ret|=vorbis_encode_residue_setup(vi,hi->base_quality_long,1,
-				    0, /* uncoupled */
-				     _residue_template_44_uncoupled);
-  }
+  ret|=vorbis_encode_residue_setup(vi,hi->short_setting,0,
+				   setup->res_type,
+				   setup->residue);  
+  ret|=vorbis_encode_residue_setup(vi,hi->long_setting,1,
+				   setup->res_type,
+				   setup->residue);
     
   if(ret)
     vorbis_info_clear(vi);
-  return(ret);
 
-}
+  /* set bitrate readonlies and management */
+  vi->bitrate_nominal=setting_to_approx_bitrate(vi);
+  vi->bitrate_lower=hi->bitrate_min;
+  vi->bitrate_upper=hi->bitrate_max;
+  vi->bitrate_window=hi->bitrate_limit_window;
 
-/* this is only tuned for 44.1kHz right now.  S'ok, for other rates it
-   just doesn't guess */
-static double ratepch_un44[11]=
-    {40000.,50000.,60000.,70000.,75000.,85000.,105000.,
-     115000.,135000.,160000.,250000.};
-static double ratepch_st44[11]=
-    {32000.,40000.,48000.,56000.,64000.,
-     80000.,96000.,112000.,128000.,160000.,250000.};
-
-static double vbr_to_approx_bitrate(int ch,int coupled,
-				    double q,long srate){
-  int iq=q*10.;
-  double dq;
-  double *r=NULL;
-
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=q*10.-iq;
+  if(hi->managed){
+    ci->bi.queue_avg_time=hi->bitrate_av_window;
+    ci->bi.queue_avg_center=hi->bitrate_av_window_center;
+    ci->bi.queue_minmax_time=hi->bitrate_limit_window;
+    ci->bi.queue_hardmin=hi->bitrate_min;
+    ci->bi.queue_hardmax=hi->bitrate_max;
+    ci->bi.queue_avgmin=hi->bitrate_av_lo;
+    ci->bi.queue_avgmax=hi->bitrate_av_hi;
+    ci->bi.avgfloat_downslew_max=999999.f;
+    ci->bi.avgfloat_upslew_max=999999.f;
   }
 
-  if(srate>42000 && srate<46000){
-    if(coupled)
-      r=ratepch_st44;
-    else
-      r=ratepch_un44;
-  }
+  return(ret);
   
+}
+
+static double setting_to_approx_bitrate(vorbis_info *vi){
+  codec_setup_info *ci=vi->codec_setup;
+  highlevel_encode_setup *hi=&ci->hi;
+  ve_setup_data_template *setup=(ve_setup_data_template *)hi->setup;
+  int is=hi->base_setting;
+  double ds=hi->base_setting-is;
+  int ch=vi->channels;
+  double *r=setup->rate_mapping;
+
   if(r==NULL)
     return(-1);
   
-  return((r[iq]*(1.-dq)+r[iq+1]*dq)*ch);  
+  return((r[is]*(1.-ds)+r[is+1]*ds)*ch);  
 }
 
-static double approx_bitrate_to_vbr(int ch,int coupled,
-				    double bitrate,long srate){
-  double *r=NULL,del;
-  int i;
+static void get_setup_template(vorbis_info *vi,
+			       long ch,long srate,
+			       double req,int q_or_bitrate){
+  int i=0,j;
+  codec_setup_info *ci=vi->codec_setup;
+  highlevel_encode_setup *hi=&ci->hi;
 
-  if(srate>42000 && srate<46000){
-    if(coupled)
-      r=ratepch_st44;
-    else
-      r=ratepch_un44;
+  while(setup_list[i]){
+    if(setup_list[i]->coupling_restriction==-1 ||
+       setup_list[i]->coupling_restriction==ch){
+      if(srate>=setup_list[i]->bitrate_min_restriction &&
+	 srate<=setup_list[i]->bitrate_max_restriction){
+	int mappings=setup_list[i]->mappings;
+	double *map=(q_or_bitrate?
+		     setup_list[i]->rate_mapping:
+		     setup_list[i]->quality_mapping);
+	if(q_or_bitrate)req/=ch;
+
+	/* the template matches.  Does the requested quality mode
+	   fall within this template's modes? */
+	if(req<map[0])continue;
+	if(req>map[setup_list[i]->mappings])continue;
+	for(j=0;j<mappings;j++)
+	  if(req>=map[j] && req<map[j+1])break;
+	/* an all-points match */
+	hi->setup=setup_list[i];
+	if(j==mappings)
+	  hi->base_setting=j-.001;
+	else{
+	  float low=map[j];
+	  float high=map[j+1];
+	  float del=(req-low)/(high-low);
+	  hi->base_setting=j+del;
+	}
+	return;
+      }
+    }
   }
   
-  if(r==NULL)
-    return(-1.);
-
-  bitrate/=ch;
-
-  if(bitrate<=r[0])return(0.);
-  for(i=0;i<10;i++)
-    if(r[i]<bitrate && r[i+1]>=bitrate)break;
-  if(i==10)return(10.);
-
-  del=(bitrate-r[i])/(r[i+1]-r[i]);
-  
-  return((i+del)*.1);
+  hi->setup=NULL;
 }
 
-/* only populates the high-level settings so that we can tweak with ctl before final setup */
-int vorbis_encode_setup_vbr(vorbis_info *vi,
-			    long channels,
-			    long rate,
-			    
-			    float base_quality){
-  int ret=0,i,iq;
-  double dq;
+static int vorbis_encode_setup_setting(vorbis_info *vi,
+				       long  channels,
+				       long  rate){
+  int ret=0,i,is;
   codec_setup_info *ci=vi->codec_setup;
   highlevel_encode_setup *hi=&ci->hi;
-  
-  base_quality+=.0001;
-  if(base_quality<0.)base_quality=0.;
-  if(base_quality>.999)base_quality=.999;
-
-  iq=base_quality*10;
-  if(iq==10){
-    iq=9;
-    dq=1.;
-  }else{
-    dq=base_quality*10.-iq;
-  }
+  ve_setup_data_template *setup=hi->setup;
+  double ds;
 
-  ret|=vorbis_encode_toplevel_setup(vi,256,2048,channels,rate);
-  hi->base_quality=base_quality;
-  hi->base_quality_short=base_quality;
-  hi->base_quality_long=base_quality;
-  hi->trigger_quality=base_quality;
+  ret=vorbis_encode_toplevel_setup(vi,channels,rate);
+  if(ret)return(ret);
 
-  for(i=0;i<4;i++){
-    hi->blocktype[i].tone_mask_quality=base_quality;
-    hi->blocktype[i].tone_peaklimit_quality=base_quality;
-    hi->blocktype[i].noise_bias_quality=base_quality;
-    hi->blocktype[i].noise_compand_quality=base_quality;
-    hi->blocktype[i].ath_quality=base_quality;
-  }
+  is=hi->base_setting;
+  ds=hi->base_setting-is;
 
-  hi->short_block_p=1;
-  hi->long_block_p=1;
-  hi->impulse_block_p=1;
-  hi->amplitude_track_dBpersec=-6.;
+  hi->short_setting=hi->base_setting;
+  hi->long_setting=hi->base_setting;
 
-  hi->stereo_couple_p=1; /* only relevant if a two channel input */
+  hi->managed=0;
 
-  /* set the ATH floaters */
-  hi->ath_floating_dB=_psy_ath_floater[iq]*(1.-dq)+_psy_ath_floater[iq+1]*dq;
-  hi->ath_absolute_dB=_psy_ath_abs[iq]*(1.-dq)+_psy_ath_abs[iq+1]*dq;
+  hi->impulse_block_p=1;
+  //hi->noise_normalize_p=1;
 
-  /* set stereo dB and Hz */
-  hi->stereo_point_q=base_quality;
-  
-  /* set lowpass */
+  hi->stereo_point_setting=hi->base_setting;
   hi->lowpass_kHz[0]=
     hi->lowpass_kHz[1]=
-    _psy_lowpass_44[iq]*(1.-dq)+_psy_lowpass_44[iq+1]*dq;
+    setup->psy_lowpass[is]*(1.-ds)+setup->psy_lowpass[is+1]*ds;  
+  
+  hi->ath_floating_dB=setup->psy_ath_float[is]*(1.-ds)+
+    setup->psy_ath_float[is+1]*ds;
+  hi->ath_absolute_dB=setup->psy_ath_abs[is]*(1.-ds)+
+    setup->psy_ath_abs[is+1]*ds;
+
+  hi->amplitude_track_dBpersec=-6.;
+  hi->trigger_setting=hi->base_setting;
+  hi->ath_setting=hi->base_setting;
 
-  /* set bitrate approximation */
-  vi->bitrate_nominal=vbr_to_approx_bitrate(vi->channels,hi->stereo_couple_p,
-					    base_quality,vi->rate);
-  vi->bitrate_lower=-1;
-  vi->bitrate_upper=-1;
-  vi->bitrate_window=-1;
+  for(i=0;i<4;i++){
+    hi->block[i].tone_mask_setting=hi->base_setting;
+    hi->block[i].tone_peaklimit_setting=hi->base_setting;
+    hi->block[i].noise_bias_setting=hi->base_setting;
+    hi->block[i].noise_compand_setting=hi->base_setting;
+  }
 
   return(ret);
 }
 
+int vorbis_encode_setup_vbr(vorbis_info *vi,
+			    long  channels,
+			    long  rate,			    
+			    float quality){
+  codec_setup_info *ci=vi->codec_setup;
+  highlevel_encode_setup *hi=&ci->hi;
+
+  get_setup_template(vi,channels,rate,quality,0);
+  if(!hi->setup)return OV_EIMPL;
+  
+  return vorbis_encode_setup_setting(vi,channels,rate);
+}
+
 int vorbis_encode_init_vbr(vorbis_info *vi,
                            long channels,
                            long rate,
@@ -827,8 +872,9 @@
                                 long nominal_bitrate,
                                 long min_bitrate){
 
+  codec_setup_info *ci=vi->codec_setup;
+  highlevel_encode_setup *hi=&ci->hi;
   double tnominal=nominal_bitrate;
-  double approx_vbr;
   int ret=0;
 
   if(nominal_bitrate<=0.){
@@ -842,37 +888,26 @@
       }
     }
   }
-
-  approx_vbr=approx_bitrate_to_vbr(channels,(channels==2), 
-				   (float)nominal_bitrate,rate);
-  approx_vbr=.4;
-
-  if(approx_vbr<0)return(OV_EIMPL);
 
-
-  ret=vorbis_encode_setup_vbr(vi,channels,rate,approx_vbr);
+  get_setup_template(vi,channels,rate,nominal_bitrate,1);
+  if(!hi->setup)return OV_EIMPL;
+  
+  ret=vorbis_encode_setup_setting(vi,channels,rate);
   if(ret){
     vorbis_info_clear(vi);
     return ret; 
   }
 
-  {
-    codec_setup_info *ci=vi->codec_setup;
-    highlevel_encode_setup *hi=&ci->hi;
+  /* initialize management with sane defaults */
+  ci->hi.managed=1;
 
-    /* initialize management.  Currently hardcoded for 44, but so is above. */
-    memcpy(&ci->bi,&_bm_44_default,sizeof(ci->bi));
-    ci->bi.queue_hardmin=min_bitrate;
-    ci->bi.queue_hardmax=max_bitrate;
-    
-    ci->bi.queue_avgmin=tnominal;
-    ci->bi.queue_avgmax=tnominal;
-    
-    ci->hi.managed=1;
-  }
-  vi->bitrate_nominal = nominal_bitrate;
-  vi->bitrate_lower = min_bitrate;
-  vi->bitrate_upper = max_bitrate;
+  ci->hi.bitrate_av_window=4.;
+  ci->hi.bitrate_av_window_center=.5;
+  ci->hi.bitrate_limit_window=2.;
+  ci->hi.bitrate_min=min_bitrate;
+  ci->hi.bitrate_max=max_bitrate;
+  ci->hi.bitrate_av_lo=tnominal;
+  ci->hi.bitrate_av_hi=tnominal;
 
   return(ret);
 }

<p><p>No                   revision

<p>No                   revision

<p>1.2.8.1   +7 -12     vorbis/lib/modes/floor_44.h

Index: floor_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/floor_44.h,v
retrieving revision 1.2
retrieving revision 1.2.8.1
diff -u -r1.2 -r1.2.8.1
--- floor_44.h	2001/12/12 09:45:55	1.2
+++ floor_44.h	2002/06/11 04:44:49	1.2.8.1
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: key floor settings for 44.1/48kHz
- last mod: $Id: floor_44.h,v 1.2 2001/12/12 09:45:55 xiphmont Exp $
+ last mod: $Id: floor_44.h,v 1.2.8.1 2002/06/11 04:44:49 xiphmont Exp $
 
  ********************************************************************/
 
@@ -104,12 +104,6 @@
   &_huff_book_line_128x19_2sub3, 
 };
 
-static static_codebook **_floor_44_128_books[3]={
-  _floor_44_128x7_books,
-  _floor_44_128x9_books,
-  _floor_44_128x19_books,
-};
-
 static static_codebook *_floor_44_1024x31_books[]={
     &_huff_book_line_1024x31_class0,
     &_huff_book_line_1024x31_class1,
@@ -128,11 +122,14 @@
     &_huff_book_line_1024x31_3sub3,
 };
 
-static static_codebook **_floor_44_1024_books[1]={
+static static_codebook **_floor_44_books[4]={
+  _floor_44_128x7_books,
+  _floor_44_128x9_books,
+  _floor_44_128x19_books,
   _floor_44_1024x31_books
 };
 
-static vorbis_info_floor1 _floor_44_128[3]={
+static vorbis_info_floor1 _floor_44[4]={
   {
     3,{0,1,2},{1,3,3},{0,2,2},{-1,0,1},
     {{2},{-1,3,4,5},{-1,6,7,8}},
@@ -165,10 +162,8 @@
     999,999,1,18.,
     8,70,
     -1 /* lowpass */
-  }
-};
+  },
 
-static vorbis_info_floor1 _floor_44_1024[1]={
   {
     10,{0,1,2,2,2,2,2, 3,3,3},{3,4,3,3},{1,1,2,2},{0,1,2,3},
     {{4,5},{6,7},{-1,8,9,10},{-1,11,12,13}},

<p><p>1.15.2.5  +589 -293  vorbis/lib/modes/psych_44.h

Index: psych_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/psych_44.h,v
retrieving revision 1.15.2.4
retrieving revision 1.15.2.5
diff -u -r1.15.2.4 -r1.15.2.5
--- psych_44.h	2002/05/31 00:16:17	1.15.2.4
+++ psych_44.h	2002/06/11 04:44:49	1.15.2.5
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: key psychoacoustic settings for 44.1/48kHz
- last mod: $Id: psych_44.h,v 1.15.2.4 2002/05/31 00:16:17 xiphmont Exp $
+ last mod: $Id: psych_44.h,v 1.15.2.5 2002/06/11 04:44:49 xiphmont Exp $
 
  ********************************************************************/
 
@@ -23,93 +23,89 @@
   {8,   /* lines per eighth octave */
    {20.f,14.f,12.f,12.f,12.f,12.f,12.f}, 
    {-60.f,-30.f,-40.f,-40.f,-40.f,-40.f,-40.f}, 2,-75.f,
-   -6.f, 0,
-   {99.,99.,99.},{{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
+   -6.f,
+   {{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
   },
   {8,   /* lines per eighth octave */
    {14.f,10.f,10.f,10.f,10.f,10.f,10.f}, 
    {-40.f,-30.f,-25.f,-25.f,-25.f,-25.f,-25.f}, 2,-80.f,
-   -6.f, 0,
-   {99.,99.,99.},{{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
+   -6.f,
+   {{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
   },
   {8,   /* lines per eighth octave */
    {12.f,10.f,10.f,10.f,10.f,10.f,10.f}, 
    {-20.f,-20.f,-15.f,-15.f,-15.f,-15.f,-15.f}, 0,-80.f,
-   -6.f, 0,
-   {99.,99.,99.},{{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
+   -6.f,
+   {{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
   },
   {8,   /* lines per eighth octave */
    {10.f,8.f,8.f,8.f,8.f,8.f,8.f}, 
    {-20.f,-15.f,-12.f,-12.f,-12.f,-12.f,-12.f}, 0,-80.f,
-   -6.f, 0,
-   {99.,99.,99.},{{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
+   -6.f,
+   {{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
   },
   {8,   /* lines per eighth octave */
    {10.f,6.f,6.f,6.f,6.f,6.f,6.f}, 
    {-15.f,-15.f,-12.f,-12.f,-12.f,-12.f,-12.f}, 0,-85.f,
-   -6.f, 0,
-   {99.,99.,99.},{{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
+   -6.f,
+   {{99.,99.,99.},{99.,99.,99.}},{99.,99.,99.}
   },
 };
 
 /* noise compander lookups * low, mid, high quality ****************/
-
-static float _psy_compand_44_short[3][NOISE_COMPAND_LEVELS]={
-  /* sub-mode Z */
-  {
-    0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f,  7.f,     /* 7dB */
-    8.f, 9.f,10.f,11.f,12.f,13.f,14.f, 15.f,     /* 15dB */
-    16.f,17.f,18.f,19.f,20.f,21.f,22.f, 23.f,     /* 23dB */
-    24.f,25.f,26.f,27.f,28.f,29.f,30.f, 31.f,     /* 31dB */
-    32.f,33.f,34.f,35.f,36.f,37.f,38.f, 39.f,     /* 39dB */
-  },
-  /* mode_Z nominal */
-  {
-     0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f,  6.f,     /* 7dB */
-     7.f, 7.f, 7.f, 7.f, 6.f, 6.f, 6.f,  7.f,     /* 15dB */
-     7.f, 8.f, 9.f,10.f,11.f,12.f,13.f, 14.f,     /* 23dB */
-    15.f,16.f,17.f,17.f,17.f,18.f,18.f, 19.f,     /* 31dB */
-    19.f,19.f,20.f,21.f,22.f,23.f,24.f, 25.f,     /* 39dB */
-  },
-  /* mode A */
-  {
-    0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 5.f,  5.f,     /* 7dB */
-    6.f, 6.f, 6.f, 5.f, 4.f, 4.f, 4.f,  4.f,     /* 15dB */
-    4.f, 4.f, 5.f, 5.f, 5.f, 6.f, 6.f,  6.f,     /* 23dB */
-    7.f, 7.f, 7.f, 8.f, 8.f, 8.f, 9.f, 10.f,     /* 31dB */
-    11.f,12.f,13.f,14.f,15.f,16.f,17.f, 18.f,     /* 39dB */
-  }
-};
-
-static float _psy_compand_44[3][NOISE_COMPAND_LEVELS]={
-  /* sub-mode Z */
-  {
-     0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f,  7.f,     /* 7dB */
-     8.f, 9.f,10.f,11.f,12.f,13.f,14.f, 15.f,     /* 15dB */
-    16.f,17.f,18.f,19.f,20.f,21.f,22.f, 23.f,     /* 23dB */
-    24.f,25.f,26.f,27.f,28.f,29.f,30.f, 31.f,     /* 31dB */
-    32.f,33.f,34.f,35.f,36.f,37.f,38.f, 39.f,     /* 39dB */
-  },
-  /* mode_Z nominal */
-  {
-    0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f,  7.f,     /* 7dB */
-    8.f, 9.f,10.f,11.f,12.f,12.f,13.f, 13.f,     /* 15dB */
-    13.f,14.f,14.f,14.f,15.f,15.f,15.f, 15.f,     /* 23dB */
-    16.f,16.f,17.f,17.f,17.f,18.f,18.f, 19.f,     /* 31dB */
-    19.f,19.f,20.f,21.f,22.f,23.f,24.f, 25.f,     /* 39dB */
-  },
-  /* mode A */
-  {
-    0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f,  7.f,     /* 7dB */
-    8.f, 8.f, 7.f, 6.f, 5.f, 4.f, 4.f,  4.f,     /* 15dB */
-    4.f, 4.f, 5.f, 5.f, 5.f, 6.f, 6.f,  6.f,     /* 23dB */
-    7.f, 7.f, 7.f, 8.f, 8.f, 8.f, 9.f, 10.f,     /* 31dB */
-    11.f,12.f,13.f,14.f,15.f,16.f,17.f, 18.f,     /* 39dB */
-  }
+static compandblock _psy_compand_44[6]={
+  /* sub-mode Z short */
+  {{
+    0, 1, 2, 3, 4, 5, 6,  7,     /* 7dB */
+    8, 9,10,11,12,13,14, 15,     /* 15dB */
+    16,17,18,19,20,21,22, 23,     /* 23dB */
+    24,25,26,27,28,29,30, 31,     /* 31dB */
+    32,33,34,35,36,37,38, 39,     /* 39dB */
+  }},
+  /* mode_Z nominal short*/
+  {{
+     0, 1, 2, 3, 4, 5, 6,  6,     /* 7dB */
+     7, 7, 7, 7, 6, 6, 6,  7,     /* 15dB */
+     7, 8, 9,10,11,12,13, 14,     /* 23dB */
+    15,16,17,17,17,18,18, 19,     /* 31dB */
+    19,19,20,21,22,23,24, 25,     /* 39dB */
+  }},
+  /* mode A short */
+  {{
+    0, 1, 2, 3, 4, 5, 5,  5,     /* 7dB */
+    6, 6, 6, 5, 4, 4, 4,  4,     /* 15dB */
+    4, 4, 5, 5, 5, 6, 6,  6,     /* 23dB */
+    7, 7, 7, 8, 8, 8, 9, 10,     /* 31dB */
+    11,12,13,14,15,16,17, 18,     /* 39dB */
+  }},
+  /* sub-mode Z long */
+  {{
+     0, 1, 2, 3, 4, 5, 6,  7,     /* 7dB */
+     8, 9,10,11,12,13,14, 15,     /* 15dB */
+    16,17,18,19,20,21,22, 23,     /* 23dB */
+    24,25,26,27,28,29,30, 31,     /* 31dB */
+    32,33,34,35,36,37,38, 39,     /* 39dB */
+  }},
+  /* mode_Z nominal long */
+  {{
+    0, 1, 2, 3, 4, 5, 6,  7,     /* 7dB */
+    8, 9,10,11,12,12,13, 13,     /* 15dB */
+    13,14,14,14,15,15,15, 15,     /* 23dB */
+    16,16,17,17,17,18,18, 19,     /* 31dB */
+    19,19,20,21,22,23,24, 25,     /* 39dB */
+  }},
+  /* mode A long */
+  {{
+    0, 1, 2, 3, 4, 5, 6,  7,     /* 7dB */
+    8, 8, 7, 6, 5, 4, 4,  4,     /* 15dB */
+    4, 4, 5, 5, 5, 6, 6,  6,     /* 23dB */
+    7, 7, 7, 8, 8, 8, 9, 10,     /* 31dB */
+    11,12,13,14,15,16,17, 18,     /* 39dB */
+  }}
 };
 
 /* tonal masking curve level adjustments *************************/
-static vp_adjblock _vp_tonemask_adj_longblock[6]={
+static vp_adjblock _vp_tonemask_adj_longblock[11]={
   /* adjust for mode zero */
   {{
     { 10, 10,  5,                               }, /*63*/
@@ -132,6 +128,28 @@
     { 16, 16, 14, 12, 12, 15, 15, 15, 15, 15, 10}, /* 16000 */
   }},
 
+  /* adjust for mode one */
+  {{
+    { 10, 10,  5,                               }, /*63*/
+    { 10, 10,  5,                               }, 
+    { 10, 10,  5,                               }, /* 125 */
+    { 10, 10,  5,                               }, 
+    { 10, 10,  5,                               }, /* 250 */
+    { 10, 10,  5,                               }, 
+    { 10, 10,  5,                               }, /* 500 */
+    { 10, 10,  5,                               }, 
+    { 10, 10,  5,                               }, /* 1000 */
+    { 10, 10,  5,                               }, 
+
+    {  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5}, /* 2000 */
+    {  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5},
+    { 10,  7,  7,  5,  5,  5,  5,  5,  5,  5,  5}, /* 4000 */
+    { 10, 10,  7,  5,  5,  5,  5,  5,  5,  5,  5},
+    { 10, 10,  8,  7,  5,  5,  5,  5,  5,  5,  5}, /* 8000 */
+    { 10, 10,  9,  8,  7,  7, 10, 10, 10,  7,  5}, 
+    { 16, 16, 14, 10, 10, 11, 13, 13, 13, 10,  5}, /* 16000 */
+  }},
+
   /* adjust for mode two */
   {{
     { 10, 10,  5,                               }, /*63*/
@@ -154,6 +172,28 @@
     { 16, 16, 14,  8,  8,  8, 10, 10, 10,  5,   }, /* 16000 */
   }},
 
+  /* adjust for mode three */
+  {{
+    { 10,  5,  5,                               }, /*63*/
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 125 */
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 250 */
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 500 */
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 1000 */
+    { 10,  5,  5,                               }, 
+
+    {  0,                                       }, /* 2000 */
+    {  0,                                       },
+    {  5,  3,  3,                               }, /* 4000 */
+    { 10,  7,  5,                               },
+    { 10, 10,  7,  5,                           }, /* 8000 */
+    { 10, 10,  7,  6,  5,  5, 10, 10, 10,  5,   }, 
+    { 16, 16, 14,  8,  8,  8, 10, 10, 10,  5,   }, /* 16000 */
+  }},
+
   /* adjust for mode four */
   {{
     { 10,  5,  5,                               }, /*63*/
@@ -176,6 +216,28 @@
     { 16, 16, 14,  8,  8,  8, 10, 10, 10,  5,   }, /* 16000 */
   }},
 
+  /* adjust for mode five */
+  {{
+    { 10,  5,  5,                               }, /*63*/
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 125 */
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 250 */
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 500 */
+    { 10,  5,  5,                               }, 
+    { 10,  5,  5,                               }, /* 1000 */
+    { 10,  5,  5,                               }, 
+
+    {  0,                                       }, /* 2000 */
+    {  0,                                       },
+    {  0,                                       }, /* 4000 */
+    { 10,  5,  5,                               },
+    { 10, 10,  7,  5,                           }, /* 8000 */
+    { 10, 10,  7,  5,  5,  5, 10, 10, 10,  3,   }, 
+    { 14, 13, 12,  7,  6,  6,  8,  8,  8,  3,   }, /* 16000 */
+  }},
+
   /* adjust for mode six */
   {{
     { 10,  5,  5,                               }, /*63*/
@@ -198,6 +260,28 @@
     { 12, 10, 10,  5,  5,  5,  5,  5,  5,       }, /* 16000 */
   }},
 
+  /* adjust for mode seven */
+  {{
+    {  5,  3,  3,                               }, /*63*/
+    {  5,  3,  3,                               }, 
+    {  5,  3,  3,                               }, /* 125 */
+    {  5,  3,  3,                               }, 
+    {  5,  3,  3,                               }, /* 250 */
+    {  5,  3,  3,                               }, 
+    {  5,  3,  3,                               }, /* 500 */
+    {  5,  3,  3,                               }, 
+    {  5,  3,  3,                               }, /* 1000 */
+    {  5,  3,  3,                               }, 
+
+    {  0,                                       }, /* 2000 */
+    {  0,                                       },
+    {  0,                                       }, /* 4000 */
+    {  5,  3,  3,                               },
+    {  5,  5,  4,  3,                           }, /* 8000 */
+    {  5,  5,  4,  3,  2,  2,  2,  2,  2,       }, 
+    {  9,  7,  7,  5,  5,  5,  5,  3,  3,       }, /* 16000 */
+  }},
+
   /* adjust for mode eight */
   {{
     {  0,                                       }, /*63*/
@@ -220,6 +304,27 @@
     {  5,  5,  5,  5,  5,  5,  5,               }, /* 16000 */
   }},
 
+  /* adjust for mode nine */
+  {{
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*63*/
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, 
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*125*/
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, 
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*250*/
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7},
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*500*/
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, 
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*1000*/
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, 
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*2000*/
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, 
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*4000*/
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, 
+    {  0,  0,  0, -2, -7, -7, -7, -7, -7, -7, -7}, /*8000*/
+    {  0,  0,  0, -2, -5, -5, -5, -7, -7, -7, -7}, 
+    {  2,  2,  2,  2,  2,  0,  0, -5, -7, -7, -7}, /*16000*/
+  }},
+
   /* adjust for mode ten */
   {{
     {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*63*/
@@ -242,7 +347,7 @@
   }},
 };
 
-static vp_adjblock _vp_tonemask_adj_otherblock[6]={
+static vp_adjblock _vp_tonemask_adj_otherblock[11]={
   /* adjust for mode zero */
   {{
     {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, /*63*/
@@ -266,6 +371,30 @@
     { 16, 16, 14, 12, 12, 15, 15, 15, 15, 15, 10}, /*16000*/
   }},
 
+  /* adjust for mode one */
+  {{
+    {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, /*63*/
+    {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, 
+    {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, /*125*/
+    {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, 
+    {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, /*250*/
+    {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, 
+    {  5,  5,  5,  0, -5, -5, -5, -5, -5, -5, -5}, /*500*/
+    {  5,  5,  5,  0, -5, -5, -5, -5, -5, -5, -5},
+
+    {  5,  5,  5,                               }, /* 1000 */
+    {  5,  5,  5,                               }, 
+
+    {  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5}, /* 2000 */
+    {  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5},
+    { 10,  7,  7,  5,  5,  5,  5,  5,  5,  5,  5}, /* 4000 */
+    { 10, 10,  7,  5,  5,  5,  5,  5,  5,  5,  5},
+    { 10, 10,  8,  7,  5,  5,  5,  5,  5,  5,  5}, /* 8000 */
+    { 10, 10,  9,  8,  7,  7, 10, 10, 10,  7,  5}, 
+    { 16, 16, 14, 10, 10, 11, 13, 13, 13, 10,  5}, /* 16000 */
+
+  }},
+
   /* adjust for mode two */
   {{
     {  0,  0,  0,  0,-10,-10,-10,-10,-10,-10,-10}, /*63*/
@@ -277,8 +406,8 @@
     {  5,  5,  5,  0, -5, -5, -5, -5, -5, -5, -5}, /*500*/
     {  5,  5,  5,  0, -5, -5, -5, -5, -5, -5, -5},
 
-    { 10, 10,  5,                               }, /* 1000 */
-    { 10, 10,  5,                               }, 
+    {  5,  5,  5,                               }, /* 1000 */
+    {  5,  5,  5,                               }, 
 
     {  0,                                       }, /* 2000 */
     {  0,                                       },
@@ -289,6 +418,29 @@
     { 16, 16, 14,  8,  8,  8, 10, 10, 10,  5,   }, /* 16000 */
   }},
 
+  /* adjust for mode three */
+  {{
+    {  0,  0,  0, -3,-13,-13,-13,-13,-13,-13,-13}, /*63*/
+    {  0,  0,  0, -3,-13,-13,-13,-13,-13,-13,-13}, 
+    {  0,  0,  0, -3,-13,-13,-13,-13,-13,-13,-13}, /*125*/
+    {  0,  0,  0, -3,-13,-13,-13,-13,-13,-13,-13}, 
+    {  0,  0,  0, -3,-13,-13,-13,-13,-13,-13,-13}, /*250*/
+    {  0,  0,  0, -3,-13,-13,-13,-13,-13,-13,-13}, 
+    {  0,  0,  0, -5,-10,-10,-10,-10,-10,-10,-10}, /*500*/
+    {  0,  0,  0, -3,-10,-10,-10,-10,-10,-10,-10}, 
+
+    {  5,  5,  5,                               }, /* 1000 */
+    {  5,  5,  5,                               }, 
+
+    {  0,                                       }, /* 2000 */
+    {  0,                                       },
+    {  0,                                       }, /* 4000 */
+    { 10,  5,  5,                               },
+    { 10, 10,  7,  5,                           }, /* 8000 */
+    { 10, 10,  7,  6,  5,  5, 10, 10, 10,  5,   }, 
+    { 16, 16, 14,  8,  8,  8, 10, 10, 10,  5,   }, /* 16000 */
+  }},
+
   /* adjust for mode four */
   {{
     {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*63*/
@@ -312,6 +464,29 @@
     { 16, 16, 14,  8,  8,  8, 10, 10, 10,  5,   }, /* 16000 */
   }},
 
+  /* adjust for mode five */
+  {{
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*63*/
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, 
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*125*/
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, 
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*250*/
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, 
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*500*/
+    {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, 
+
+    {  5,  5,  5,                               }, /* 1000 */
+    {  5,  5,  5,                               }, 
+
+    {  0,                                       }, /* 2000 */
+    {  0,                                       },
+    {  0,                                       }, /* 4000 */
+    { 10,  5,  5,                               },
+    { 10, 10,  7,  5,                           }, /* 8000 */
+    { 10, 10,  7,  5,  5,  5,  7,  7,  7,  3,   }, 
+    { 14, 13, 12,  6,  6,  6,  8,  8,  8,       }, /* 16000 */
+  }},
+
   /* adjust for mode six */
   {{
     {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*63*/
@@ -335,6 +510,29 @@
     { 12, 10, 10,  5,  5,  5,  5,  5,  5,       }, /* 16000 */
   }},
 
+  /* adjust for mode seven */
+  {{
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17}, /*63*/
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17},
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17}, /*125*/
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17},
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17}, /*250*/
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17},
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17}, /*500*/
+    { -5, -5, -5,-10,-15,-15,-15,-17,-17,-17,-17},
+
+    {  2, -3, -3, -7, -7, -7, -7, -7, -7, -7, -7}, 
+    {  2, -3, -3, -7, -7, -7, -7, -7, -7, -7, -7}, 
+
+    {  0,                                       }, /* 2000 */
+    {  0,                                       },
+    {  0,                                       }, /* 4000 */
+    {  5,  2,  2,                               },
+    {  5,  5,  3,  2,                           }, /* 8000 */
+    {  5,  5,  3,  2,  2,  2,  2,  2,  2,       }, 
+    {  8,  7,  7,  5,  5,  5,  5,  2,  2,       }, /* 16000 */
+  }},
+
   /* adjust for mode eight */
   {{
     {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*63*/
@@ -358,18 +556,41 @@
     {  5,  5,  5,  5,  5,  5,  5,               }, /* 16000 */
   }},
 
+  /* adjust for mode nine */
+  {{
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*63*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*125*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*250*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*500*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+
+    {  0, -5, -5,-10,-15,-17,-17,-17,-17,-17,-17}, /*1000*/
+    {  0, -5, -5,-10,-15,-17,-17,-17,-17,-17,-17}, 
+    {  0,  0,  0, -3, -7, -7, -7, -7, -7, -7, -7}, /*2000*/
+    {  0,  0,  0, -3, -7, -7, -7, -7, -7, -7, -7},
+    {  0,  0,  0, -3, -7, -7, -7, -7, -7, -7, -7}, /*4000*/
+    {  0,  0,  0, -3, -7, -7, -7, -7, -7, -7, -7},
+    {  0,  0,  0, -3, -7, -7, -7, -7, -7, -7, -7}, /*8000*/
+    {  0,  0,  0, -5, -5, -5, -5, -7, -7, -7, -7}, 
+    {  0,  0,  0,  0,  0, -2, -3, -5, -7, -7, -7}, /*16000*/
+  }},
+
   /* adjust for mode ten */
   {{
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, /*63*/
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, 
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, /*125*/
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, 
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, /*250*/
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20},
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, /*500*/
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, 
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, /*1000*/
-    {  0,  0,  0, -5,-15,-20,-20,-20,-20,-20,-20}, 
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*63*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*125*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*250*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*500*/
+    {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, 
+
+    {  0, -5, -5,-10,-15,-17,-17,-17,-17,-17,-17}, /*1000*/
+    {  0, -5, -5,-10,-15,-17,-17,-17,-17,-17,-17}, 
     {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*2000*/
     {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, 
     {  0,  0,  0, -5,-15,-15,-15,-15,-15,-15,-15}, /*4000*/
@@ -378,9 +599,10 @@
     {  0,  0,  0, -5,-10,-10,-10,-15,-15,-15,-15}, 
     {  0,  0,  0,  0,  0, -5, -5,-10,-15,-15,-15}, /*16000*/
   }},
+
 };
 
-static vp_adjblock _vp_peakguard[6]={
+static vp_adjblock _vp_peakguard[11]={
   /* zero */
   {{
     {-14,-16,-18,-19,-24,-24,-24,-24,-24,-24,-24},/*63*/
@@ -401,6 +623,26 @@
     {-10,-10,-10,-10,-10,-14,-16,-18,-22,-24,-24},
     {-10,-10,-10,-10,-10,-12,-16,-18,-22,-24,-24},/*16000*/
   }},
+  /* one */
+  {{
+    {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},/*63*/
+    {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},
+    {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},/*125*/
+    {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},
+    {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},/*250*/
+    {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},
+    {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},/*500*/
+    {-10,-10,-10,-10,-14,-14,-14,-20,-26,-30,-30},
+    {-10,-10,-10,-10,-14,-14,-14,-20,-22,-30,-30},/*1000*/
+    {-10,-10,-10,-10,-14,-14,-16,-20,-22,-30,-30},
+    {-10,-10,-10,-10,-14,-14,-16,-20,-22,-30,-30},/*2000*/
+    {-10,-10,-10,-10,-14,-14,-16,-20,-22,-30,-30},
+    {-10,-10,-10,-10,-14,-14,-16,-20,-22,-30,-30},/*4000*/
+    {-10,-10,-10,-10,-10,-11,-12,-13,-22,-30,-30},
+    {-10,-10,-10,-10,-10,-11,-12,-13,-22,-30,-30},/*8000*/
+    {-10,-10,-10,-10,-10,-10,-10,-11,-22,-30,-30},
+    {-10,-10,-10,-10,-10,-10,-10,-10,-20,-30,-30},/*16000*/
+  }},
   /* two */
   {{
     {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},/*63*/
@@ -421,6 +663,26 @@
     {-10,-10,-10,-10,-10,-10,-10,-11,-22,-30,-30},
     {-10,-10,-10,-10,-10,-10,-10,-10,-20,-30,-30},/*16000*/
   }},
+  /* three */
+  {{
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*63*/
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*125*/
+    {-14,-20,-20,-20,-20,-20,-20,-30,-32,-32,-40},
+    {-14,-20,-20,-20,-20,-20,-20,-30,-32,-32,-40},/*250*/
+    {-14,-20,-20,-20,-20,-20,-20,-24,-32,-32,-40},
+    {-14,-20,-20,-20,-20,-20,-20,-24,-32,-32,-40},/*500*/
+    {-10,-10,-10,-10,-14,-16,-20,-24,-26,-32,-40},
+    {-10,-10,-10,-10,-14,-16,-20,-24,-22,-32,-40},/*1000*/
+    {-10,-10,-10,-10,-14,-16,-20,-24,-22,-32,-40},
+    {-10,-10,-10,-10,-14,-16,-20,-24,-22,-32,-40},/*2000*/
+    {-10,-10,-10,-10,-14,-16,-20,-24,-22,-32,-40},
+    {-10,-10,-10,-10,-14,-14,-16,-20,-22,-32,-40},/*4000*/
+    {-10,-10,-10,-10,-10,-11,-12,-13,-22,-32,-40},
+    {-10,-10,-10,-10,-10,-11,-12,-13,-22,-32,-40},/*8000*/
+    {-10,-10,-10,-10,-10,-10,-10,-11,-22,-32,-40},
+    {-10,-10,-10,-10,-10,-10,-10,-10,-20,-32,-40},/*16000*/
+  }},
   /* four */
   {{
     {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*63*/
@@ -441,6 +703,26 @@
     {-10,-10,-10,-10,-10,-10,-10,-11,-22,-32,-40},
     {-10,-10,-10,-10,-10,-10,-10,-10,-20,-32,-40},/*16000*/
   }},
+  /* five */
+  {{
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*63*/
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*125*/
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*250*/
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},
+    {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*500*/
+    {-14,-14,-14,-16,-20,-22,-24,-24,-28,-32,-40},
+    {-14,-14,-14,-16,-20,-22,-24,-24,-28,-32,-40},/*1000*/
+    {-14,-14,-14,-16,-20,-22,-24,-24,-28,-32,-40},
+    {-14,-14,-16,-20,-24,-26,-26,-28,-30,-32,-40},/*2000*/
+    {-14,-14,-16,-20,-24,-26,-26,-28,-30,-32,-40},
+    {-14,-14,-16,-20,-24,-26,-26,-28,-30,-32,-40},/*4000*/
+    {-14,-14,-14,-20,-22,-22,-24,-24,-26,-32,-40},
+    {-14,-14,-14,-18,-20,-20,-24,-24,-24,-32,-40},/*8000*/
+    {-14,-14,-14,-18,-20,-20,-24,-24,-24,-32,-40},
+    {-14,-14,-14,-18,-20,-20,-22,-24,-24,-32,-40},/*16000*/
+  }},
   /* six */
   {{
     {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*63*/
@@ -461,6 +743,26 @@
     {-14,-14,-14,-18,-20,-20,-24,-24,-24,-32,-40},
     {-14,-14,-14,-18,-20,-20,-22,-24,-24,-32,-40},/*16000*/
   }},
+  /* seven */
+  {{
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*63*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*88*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*125*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*170*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*250*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*350*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*500*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*700*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*1000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*1400*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*2000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*2800*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*4000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*5600*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*8000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*11500*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*16600*/
+  }},
   /* eight */
   {{
     {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*63*/
@@ -481,6 +783,26 @@
     {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*11500*/
     {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*16600*/
   }},
+  /* nine */
+  {{
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*63*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*88*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*125*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*170*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*250*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*350*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*500*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*700*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*1000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*1400*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*2000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*2800*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*4000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*5600*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*8000*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*11500*/
+    {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*16600*/
+  }},
   /* ten */
   {{
     {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*63*/
@@ -503,234 +825,210 @@
   }}
 };
 
-static int _psy_noisebias_long[11][P_NOISECURVES][17]={
+static noise3 _psy_noisebias_long[11]={
   /*63     125     250     500      1k       2k      4k      8k     16k*/
   /* 0 */
-  {{-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10},
-   {-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10},
-   {-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10}},
+  {{{-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10},
+    {-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10},
+    {-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10}}},
   /* 1 */
-  {{-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -2, -2,  1,  1,  2,  2,  4},
-   {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -2, -2,  1,  1,  2,  2,  4},
-   {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -2, -2,  1,  1,  2,  2,  4}},
+  {{{-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -2, -2,  1,  1,  2,  2,  4},
+    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -2, -2,  1,  1,  2,  2,  4},
+    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -2, -2,  1,  1,  2,  2,  4}}},
   /* 2 */
-  {{-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
-   {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
-   {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2}},
+  {{{-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
+    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
+    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2}}},
   /* 3 */
-  {{-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
-   {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
-   {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2}},
+  {{{-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
+    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2},
+    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -2, -3, -3, -1, -1,  0,  1,  2}}},
   /* 4 */
-  {{-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10},
-   {-20,-20,-20,-20,-20,-20,-20,-10, -6, -3, -4, -4, -2, -1,  0,  0,  2},
-   {-30,-30,-30,-30,-30,-30,-30,-30,-26,-20,-20,-20,-20,-20,-16,-14,-10}},
+  {{{-20,-20,-18,-18,-18,-16,-14, -8, -6, -2,  0,  2,  3,  3,  4,  4, 10},
+    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -3, -4, -4, -2, -1,  0,  0,  2},
+    {-30,-30,-30,-30,-30,-30,-30,-30,-26,-20,-20,-20,-20,-20,-16,-14,-10}}},
   /* 5 */
-  {{-20,-20,-20,-20,-20,-20,-20,-18,-10, -4, -6, -6, -3, -2, -2, -2,  0},
-   {-20,-20,-20,-20,-20,-20,-20,-18,-10, -4, -6, -6, -3, -2, -2, -2,  0},
-   {-20,-20,-20,-20,-20,-20,-20,-18,-10, -4, -6, -6, -3, -2, -2, -2,  0}},
+  {{{-20,-20,-20,-20,-20,-20,-20,-18,-10, -4, -6, -6, -3, -2, -2, -2,  0},
+    {-20,-20,-20,-20,-20,-20,-20,-18,-10, -4, -6, -6, -3, -2, -2, -2,  0},
+    {-20,-20,-20,-20,-20,-20,-20,-18,-10, -4, -6, -6, -3, -2, -2, -2,  0}}},
   /* 6 */
-  {{-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -8, -8, -7, -7, -6, -6, -4},
-   {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -8, -8, -7, -7, -6, -6, -4},
-   {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -8, -8, -7, -7, -6, -6, -4}},
+  {{{-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -8, -8, -7, -7, -6, -6, -4},
+    {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -8, -8, -7, -7, -6, -6, -4},
+    {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -8, -8, -7, -7, -6, -6, -4}}},
   /* 7 */
-  {{-24,-24,-24,-24,-24,-24,-24,-18,-14,-14,-16,-16,-14,-12,-10,-10, -8},
-   {-24,-24,-24,-24,-24,-24,-24,-18,-14,-14,-16,-16,-14,-12,-10,-10, -8},
-   {-24,-24,-24,-24,-24,-24,-24,-18,-14,-14,-16,-16,-14,-12,-10,-10, -8}},
+  {{{-24,-24,-24,-24,-24,-24,-24,-18,-14,-14,-16,-16,-14,-12,-10,-10, -8},
+    {-24,-24,-24,-24,-24,-24,-24,-18,-14,-14,-16,-16,-14,-12,-10,-10, -8},
+    {-24,-24,-24,-24,-24,-24,-24,-18,-14,-14,-16,-16,-14,-12,-10,-10, -8}}},
   /* 8 */
-  {{-24,-24,-24,-24,-24,-24,-24,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
-   {-24,-24,-24,-24,-24,-24,-24,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
-   {-24,-24,-24,-24,-24,-24,-24,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10}},
+  {{{-24,-24,-24,-24,-24,-24,-24,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
+    {-24,-24,-24,-24,-24,-24,-24,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
+    {-24,-24,-24,-24,-24,-24,-24,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10}}},
   /* 9 */
-  {{-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
-   {-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
-   {-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24}},
+  {{{-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
+    {-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
+    {-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24}}},
   /* 10 */
-  {{-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
-   {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
-   {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46}},
+  {{{-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
+    {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
+    {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46}}},
 };
 
-static int _psy_noisebias_impulse[11][P_NOISECURVES][17]={
+static noise3 _psy_noisebias_impulse[11]={
   /*63     125     250     500      1k       2k      4k      8k     16k*/
   /* 0 */
-  {{-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6},
-   {-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6},
-   {-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6}},
+  {{{-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6},
+    {-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6},
+    {-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6}}},
   /* 1 */
-  {{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -2, -2, -2,  2},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -2, -2, -2,  2},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -2, -2, -2,  2}},
+  {{{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -2, -2, -2,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -2, -2, -2,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -2, -2, -2,  2}}},
   /* 2 */
-  {{-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2,  0},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2,  0},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2,  0}},
+  {{{-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2,  0},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2,  0},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2,  0}}},
   /* 3 */
-  {{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, -2},
-   {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, -2},
-   {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, -2}},
+  {{{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, -2},
+    {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, -2},
+    {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, -2}}},
   /* 4 */
-  {{-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6},
-   {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2},
-   {-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16}},
+  {{{-20,-20,-20,-20,-20,-18,-14,-10,-10, -2,  2,  2,  2,  2,  2,  3,  6},
+    {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2},
+    {-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16}}},
   /* 5 */
-  {{-30,-30,-30,-30,-30,-30,-24,-20,-10,-12,-14,-14,-10, -9, -8, -6, -4},
-   {-30,-30,-30,-30,-30,-30,-24,-20,-10,-12,-14,-14,-10, -9, -8, -6, -4},
-   {-30,-30,-30,-30,-30,-30,-24,-20,-10,-12,-14,-14,-10, -9, -8, -6, -4}},
+  {{{-30,-30,-30,-30,-30,-30,-24,-20,-10,-12,-14,-14,-10, -9, -8, -6, -4},
+    {-30,-30,-30,-30,-30,-30,-24,-20,-10,-12,-14,-14,-10, -9, -8, -6, -4},
+    {-30,-30,-30,-30,-30,-30,-24,-20,-10,-12,-14,-14,-10, -9, -8, -6, -4}}},
   /* 6 */
-  {{-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
-   {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
-   {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8}},
+  {{{-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
+    {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
+    {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8}}},
   /* 7 */
-  {{-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14},
-   {-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14},
-   {-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14}},
+  {{{-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14},
+    {-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14},
+    {-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14}}},
   /* 8 */
-  {{-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16},
-   {-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16},
-   {-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16}},
+  {{{-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16},
+    {-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16},
+    {-34,-34,-34,-34,-30,-30,-30,-30,-30,-26,-26,-26,-26,-22,-20,-20,-16}}},
   /* 9 */
-  {{-40,-40,-40,-40,-40,-40,-40,-40,-40,-36,-36,-36,-36,-36,-36,-30,-30},
-   {-40,-40,-40,-40,-40,-40,-40,-40,-40,-36,-36,-36,-36,-36,-36,-30,-30},
-   {-40,-40,-40,-40,-40,-40,-40,-40,-40,-36,-36,-36,-36,-36,-36,-30,-30}},
+  {{{-40,-40,-40,-40,-40,-40,-40,-40,-40,-36,-36,-36,-36,-36,-36,-30,-30},
+    {-40,-40,-40,-40,-40,-40,-40,-40,-40,-36,-36,-36,-36,-36,-36,-30,-30},
+    {-40,-40,-40,-40,-40,-40,-40,-40,-40,-36,-36,-36,-36,-36,-36,-30,-30}}},
   /* 10 */
-  {{-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50},
-   {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50},
-   {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50}},
+  {{{-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50},
+    {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50},
+    {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50}}},
 };
 
-static int _psy_noisebias_other[11][P_NOISECURVES][17]={
+static noise3 _psy_noisebias_other[11]={
   /*63     125     250     500      1k       2k      4k      8k     16k*/
   /* 0 */
-  {{-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10},
-   {-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10},
-   {-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10}},
+  {{{-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10},
+    {-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10},
+    {-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10}}},
   /* 1 */
-  {{-26,-26,-26,-26,-26,-22,-20,-14,-10, -2, -2, -2,  1,  1,  2,  2,  4},
-   {-26,-26,-26,-26,-26,-22,-20,-14,-10, -2, -2, -2,  1,  1,  2,  2,  4},
-   {-26,-26,-26,-26,-26,-22,-20,-14,-10, -2, -2, -2,  1,  1,  2,  2,  4}},
+  {{{-26,-26,-26,-26,-26,-22,-20,-14,-10, -2, -2, -2,  1,  1,  2,  2,  4},
+    {-26,-26,-26,-26,-26,-22,-20,-14,-10, -2, -2, -2,  1,  1,  2,  2,  4},
+    {-26,-26,-26,-26,-26,-22,-20,-14,-10, -2, -2, -2,  1,  1,  2,  2,  4}}},
   /* 2 */
-  {{-30,-30,-30,-30,-26,-22,-20,-14,-10, -2, -3, -3, -1, -1,  0,  1,  2},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -2, -3, -3, -1, -1,  0,  1,  2},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -2, -3, -3, -1, -1,  0,  1,  2}},
+  {{{-30,-30,-30,-30,-26,-22,-20,-14,-10, -2, -3, -3, -1, -1,  0,  1,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -2, -3, -3, -1, -1,  0,  1,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -2, -3, -3, -1, -1,  0,  1,  2}}},
   /* 3 */
-  {{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -1, -1,  0,  1,  2},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -1, -1,  0,  1,  2},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -1, -1,  0,  1,  2}},
+  {{{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -1, -1,  0,  1,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -1, -1,  0,  1,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -1, -1,  0,  1,  2}}},
   /* 4 */
-  {{-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10},
-   {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -1,  0,  0,  2},
-   {-34,-34,-34,-34,-30,-30,-30,-30,-26,-20,-20,-20,-20,-20,-16,-14,-10}},
+  {{{-20,-20,-20,-20,-20,-18,-14,-10, -6, -2,  2,  2,  3,  3,  4,  4, 10},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -1,  0,  0,  2},
+    {-34,-34,-34,-34,-30,-30,-30,-30,-26,-20,-20,-20,-20,-20,-16,-14,-10}}},
   /* 5 */
-  {{-30,-30,-30,-30,-30,-30,-24,-20,-10, -4, -6, -6, -3, -2, -2, -2,  0},
-   {-30,-30,-30,-30,-30,-30,-24,-20,-10, -4, -6, -6, -3, -2, -2, -2,  0},
-   {-30,-30,-30,-30,-30,-30,-24,-20,-10, -4, -6, -6, -3, -2, -2, -2,  0}},
+  {{{-30,-30,-30,-30,-30,-30,-24,-20,-10, -4, -6, -6, -3, -2, -2, -2,  0},
+    {-30,-30,-30,-30,-30,-30,-24,-20,-10, -4, -6, -6, -3, -2, -2, -2,  0},
+    {-30,-30,-30,-30,-30,-30,-24,-20,-10, -4, -6, -6, -3, -2, -2, -2,  0}}},
   /* 6 */
-  {{-34,-34,-34,-34,-30,-30,-24,-20,-14, -8, -8, -8, -7, -7, -6, -6, -4},
-   {-34,-34,-34,-34,-30,-30,-24,-20,-14, -8, -8, -8, -7, -7, -6, -6, -4},
-   {-34,-34,-34,-34,-30,-30,-24,-20,-14, -8, -8, -8, -7, -7, -6, -6, -4}},
+  {{{-34,-34,-34,-34,-30,-30,-24,-20,-14, -8, -8, -8, -7, -7, -6, -6, -4},
+    {-34,-34,-34,-34,-30,-30,-24,-20,-14, -8, -8, -8, -7, -7, -6, -6, -4},
+    {-34,-34,-34,-34,-30,-30,-24,-20,-14, -8, -8, -8, -7, -7, -6, -6, -4}}},
   /* 7 */
-  {{-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
-   {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
-   {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8}},
+  {{{-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
+    {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8},
+    {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10, -8}}},
   /* 8 */
-  {{-34,-34,-34,-34,-30,-30,-30,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
-   {-34,-34,-34,-34,-30,-30,-30,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
-   {-34,-34,-34,-34,-30,-30,-30,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10}},
+  {{{-34,-34,-34,-34,-30,-30,-30,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
+    {-34,-34,-34,-34,-30,-30,-30,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10},
+    {-34,-34,-34,-34,-30,-30,-30,-20,-20,-20,-20,-20,-16,-16,-14,-14,-10}}},
   /* 9 */
-  {{-40,-40,-40,-40,-40,-40,-40,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
-   {-40,-40,-40,-40,-40,-40,-40,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
-   {-40,-40,-40,-40,-40,-40,-40,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24}},
+  {{{-40,-40,-40,-40,-40,-40,-40,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
+    {-40,-40,-40,-40,-40,-40,-40,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24},
+    {-40,-40,-40,-40,-40,-40,-40,-30,-30,-30,-30,-30,-30,-24,-24,-24,-24}}},
   /* 10 */
-  {{-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
-   {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
-   {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46}},
+  {{{-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
+    {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46},
+    {-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-46}}},
 };
 
-static int _psy_noiseguards_short[33]={
-  2,2,-1,
-  4,4,-1,
-  4,4,15,
-  4,4,15,
-  4,4,15,
-  4,4,15,
-  4,4,15,
-  4,4,15,
-  4,4,15,
-  4,4,15,
-  4,4,15,
+static noiseguard _psy_noiseguards_44[2]={
+  {4,4,15},
+  {10,10,100},
 };
-static int _psy_noiseguards_long[33]={
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-  10,10,100,
-};
-
-static double _psy_tone_masterguard[11]={
-  -18.,-24.,-24.,-24.,-26.,-40.,-40.,-40.,-45.,-45.,-45.,
-};
 
-static double _psy_tone_suppress[11]={
-  -10.,-20.,-20.,-20.,-30.,-30.,-40.,-40.,-45.,-45.,-45.,
+static int _psy_tone_masterguard[11]={
+  -18,-24,-24,-24,-26,-40,-40,-40,-45,-45,-45,
 };
 
-static double _psy_tone_0dB[11]={
-  95.,95.,95.,95.,95.,105.,105.,105.,105.,105.,105.,
+static int _psy_tone_suppress[11]={
+  -10,-20,-20,-20,-30,-30,-40,-40,-45,-45,-45,
 };
 
-static double _psy_noise_suppress[11]={
-   -0.,-24.,-24.,-24.,-24.,-30.,-40.,-40.,-45.,-45.,-45.,
+static int _psy_tone_0dB[11]={
+  95,95,95,95,95,105,105,105,105,105,105,
 };
 
-static int _psy_ehmer_bandlimit[11]={
-  0,0,0,0,4,4,30,30,30,30,30,
+static int _psy_noise_suppress[11]={
+   0,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45,
 };
 
 static vorbis_info_psy _psy_info_template={
   -1,
   {-1},-110.,-140.,
-  /* tonemask att,guard,suppr,curves  peakattp,curvelimitp,peaksettings*/
-  {0.f,0.f,0.f},  -40.f,-40.f, {{{0.}}},         1,          0,        {{{0.}}},
+  /* tonemask att,guard,suppr,curves  peakattp,peaksettings*/
+  {0.f,0.f,0.f},  -40.f,-40.f, {{{0.}}},     1,     {{{0.}}},
   
   /*noisemaskp,supp, low/high window, low/hi guard, minimum */
   1,          -0.f,         .5f, .5f,         0,0,0,
-  {{-1},{-1},{-1}},{-1},105.f
+  {{-1},{-1},{-1}},{-1},105.f,
+
+  0,0,-1,-1,
 };
 
 /* ath ****************/
 
-static double _psy_ath_floater[11]={
-  -100.,-100.,-100.,-100.,-100.,-100.,-105.,-105.,-105.,-110.,-120.,
+static int _psy_ath_floater[11]={
+  -100,-100,-100,-100,-100,-100,-105,-105,-105,-110,-120,
 };
 
-static double _psy_ath_abs[11]={
-  -110.,-110.,-120.,-140.,-140.,-140.,-140.,-140.,-140.,-140.,-150.,
+static int _psy_ath_abs[11]={
+  -110,-110,-120,-140,-140,-140,-140,-140,-140,-140,-150,
 };
 
-static float ATH_Bark_dB[][27]={
-  {
+static athcurve ATH_Bark_dB[]={
+  {{
      0.f,  15.f,  15.f,   15.f,   11.f,       10.f,   8.f,  7.f,   7.f,  7.f,
      6.f,   2.f,   0.f,    0.f,   -2.f,       -5.f,  -6.f, -6.f,  -4.f,  4.f,
     14.f,  20.f,  19.f,   17.f,   30.f,       60.f,  70.f,
-  },
-  {
+  }},
+  {{
     0.f,  15.f,  15.f,   15.f,   11.f,       10.f,   8.f,  7.f,   7.f,  7.f,
     6.f,   2.f,   0.f,    0.f,   -2.f,       -5.f,  -6.f, -6.f,  -4.f,  0.f,
     2.f,   6.f,   5.f,    5.f,   15.f,       30.f,  50.f,
-  },
-  {
+  }},
+  {{
     0.f,  15.f,  15.f,   15.f,   11.f,       10.f,   8.f,  7.f,   7.f,  7.f,
     6.f,   2.f,   0.f,    0.f,   -3.f,       -5.f,  -6.f, -6.f, -4.5f, -4.f,
     2.f,   6.f,   5.f,    5.f,   15.f,       20.f,  40.f,
-  }
+  }}
 };
 
 /* stereo setup.  These don't map directly to quality level, there's
@@ -742,98 +1040,96 @@
 /* various stereo possibilities */
 
 /* stereo mode by base quality level */
-static int _psy_stereo_modes_44[10][PACKETBLOBS]={
-
+static adjB _psy_stereo_modes_44[10]={
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, /* 0 */
+  {{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}}, /* 0 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, /* 1 */
+  {{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}}, /* 1 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  { 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, /* 2 */
+  {{ 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}}, /* 2 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  { 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1}, /* 3 */
+  {{ 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1}}, /* 3 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  { 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* 4 */
+  {{ 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1}}, /* 4 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  {0}, /* 5 */
+  {{0}}, /* 5 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  {0}, /* 6 */
+  {{0}}, /* 6 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  {0}, /* 7 */
+  {{0}}, /* 7 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  {0}, /* 8 */
+  {{0}}, /* 8 */
   /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14*/
-  {0}, /* 9 */
+  {{0}}, /* 9 */
 
 };
 
-static double _psy_stereo_pkHz_44[22][PACKETBLOBS]={
+static adjB _psy_stereo_pkHz_44[22]={
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     0 */
-  {0},
-  {0},
+  {{0}},
+  {{0}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     1 */
-  {0},
-  {0},
+  {{0}},
+  {{0}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     2 */
-  {0},
-  {0},
+  {{0}},
+  {{0}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     3 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
+  {{ 4,  4,  4,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
+  {{ 4,  5,  6,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     4 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
+  {{ 4,  4,  4,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
+  {{ 4,  5,  6,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     5 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
+  {{ 4,  4,  4,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
+  {{ 4,  5,  6,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     6 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
+  {{ 4,  4,  4,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
+  {{ 4,  5,  6,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     7 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
+  {{ 4,  4,  4,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
+  {{ 4,  5,  6,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     8 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
+  {{ 4,  4,  4,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
+  {{ 4,  5,  6,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14     9 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
+  {{ 4,  4,  4,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
+  {{ 4,  5,  6,  6,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}},
   /*0   1   2   3   4   5   6   7   8   9  10  11  12  13  14    10 */
-  { 4., 4., 4., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
-  { 4., 5., 6., 6., 8.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.},
 };
 
-static double _psy_tone_monopass_44[11][3]={
-  {0}, /* 0 */
-  {0}, /* 1 */
-  {0}, /* 2 */
-  {99.,99.,99.}, /* 3 */
-  {99.,99.,99.}, /* 4 */
-  {99.,99.,99.}, /* 5 */
-  {0}, /* 6 */
-  {0}, /* 7 */
-  {0}, /* 8 */
-  {0}, /* 9 */
-  {0}, /* 10 */
-};
-
 /* tone master attenuation by base quality mode and bitrate tweak */
 
-static double _psy_tone_masteratt_44[11][3]={
-  {0}, /* 0 */
-  {0}, /* 1 */
-  {0}, /* 2 */
-  {  0,  0, -10}, /* 3 */
-  {  0,  0, -10}, /* 4 */
-  {  0,  0, -10}, /* 5 */
-  {0}, /* 6 */
-  {0}, /* 7 */
-  {0}, /* 8 */
-  {0}, /* 9 */
-  {0}, /* 10 */
+static adj3 _psy_tone_masteratt_44[11]={
+  {{0}}, /* 0 */
+  {{0}}, /* 1 */
+  {{0}}, /* 2 */
+  {{  0,  0, -10}}, /* 3 */
+  {{  0,  0, -10}}, /* 4 */
+  {{  0,  0, -10}}, /* 5 */
+  {{0}}, /* 6 */
+  {{0}}, /* 7 */
+  {{0}}, /* 8 */
+  {{0}}, /* 9 */
+  {{0}}, /* 10 */
 };
 
 /* lowpass by mode **************/
 static double _psy_lowpass_44[11]={
   15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999.
+};
+
+/* noise normalization **********/
+
+static int _noise_start_short_44[10]={
+  16,16,16,16,16,16,16,16,16,16
+};
+static int _noise_start_long_44[10]={
+  128,128,128,128,128,128,128,128,128,128
+};
+static int _noise_part_short_44[10]={
+  16,16,16,16,16,16,16,16,16,16
+};
+static int _noise_part_long_44[10]={
+  32,32,32,32,32,32,32,32,32,32
 };

<p><p>1.11.6.5  +23 -48    vorbis/lib/modes/residue_44.h

Index: residue_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/residue_44.h,v
retrieving revision 1.11.6.4
retrieving revision 1.11.6.5
diff -u -r1.11.6.4 -r1.11.6.5
--- residue_44.h	2002/05/31 00:16:17	1.11.6.4
+++ residue_44.h	2002/06/11 04:44:49	1.11.6.5
@@ -11,22 +11,13 @@
  ********************************************************************
 
  function: toplevel residue templates for 32/44.1/48kHz
- last mod: $Id: residue_44.h,v 1.11.6.4 2002/05/31 00:16:17 xiphmont Exp $
+ last mod: $Id: residue_44.h,v 1.11.6.5 2002/06/11 04:44:49 xiphmont Exp $
 
  ********************************************************************/
 
 #include "vorbis/codec.h"
 #include "backends.h"
 
-static bitrate_manager_info _bm_44_default={
-  /* progressive coding and bitrate controls */
-  4.,.5,
-  2.,       0,           0,  
-            0,           0,
-           
-  -9999,              9999, 
-};
-
 /***** residue backends *********************************************/
 
 /* the books used depend on stereo-or-not, but the residue setup below
@@ -295,10 +286,11 @@
 /* residue backfill is entered in the template array as if stereo
    backfill is not in use.  It's up to vorbisenc to make the
    appropriate index adjustment */
-static vorbis_residue_template _residue_template_44_stereo[11]={
+static vorbis_residue_template _residue_template_44_stereo[10]={
   /* mode 0; 64-ish */
   {{&_residue_44_low, &_residue_44_low},  
    {&_huff_book__44c0_short,&_huff_book__44c0_long},
+   {&_huff_book__44c0_short,&_huff_book__44c0_long},
    { 
      {0},{0,0,&_44c0_s0_p1_0},{0,0,&_44c0_s0_p2_0},{0,0,&_44c0_s0_p3_0},
      {&_44c0_s0_p4_0,&_44c0_s0_p4_1},{0,0,&_44c0_s0_p5_0},{0,0,&_44c0_s0_p6_0},
@@ -308,6 +300,7 @@
   /* mode 1; 80-ish */
   {{&_residue_44_low, &_residue_44_low},  
    {&_huff_book__44c1_short,&_huff_book__44c1_long},
+   {&_huff_book__44c1_short,&_huff_book__44c1_long},
    { 
      {0},{0,0,&_44c1_s0_p1_0},{0,0,&_44c1_s0_p2_0},{0,0,&_44c1_s0_p3_0},
      {&_44c1_s0_p4_0,&_44c1_s0_p4_1},{0,0,&_44c1_s0_p5_0},{0,0,&_44c1_s0_p6_0},
@@ -317,6 +310,7 @@
   /* mode 2; 96-ish */
   {{&_residue_44_low, &_residue_44_low},  
    {&_huff_book__44c2_short,&_huff_book__44c2_long},
+   {&_huff_book__44c2_short,&_huff_book__44c2_long},
    { 
      {0},{0,0,&_44c2_s0_p1_0},{0,0,&_44c2_s0_p2_0},{0,0,&_44c2_s0_p3_0},
      {&_44c2_s0_p4_0,&_44c2_s0_p4_1},{0,0,&_44c2_s0_p5_0},{0,0,&_44c2_s0_p6_0},
@@ -326,6 +320,7 @@
   /* mode 3; 112-ish */
   {{&_residue_44_low, &_residue_44_low},  
    {&_huff_book__44c3_short,&_huff_book__44c3_long},
+   {&_huff_book__44c3_short,&_huff_book__44c3_long},
    { 
      {0},{0,0,&_44c3_s0_p1_0},{0,0,&_44c3_s0_p2_0},{0,0,&_44c3_s0_p3_0},
      {&_44c3_s0_p4_0,&_44c3_s0_p4_1},{0,0,&_44c3_s0_p5_0},{0,0,&_44c3_s0_p6_0},
@@ -336,6 +331,7 @@
   /* mode 4; 128-ish */
   {{&_residue_44_mid, &_residue_44_mid},  
    {&_huff_book__44c4_s_short,&_huff_book__44c4_s_long},
+   {&_huff_book__44c4_sm_short,&_huff_book__44c4_sm_long},
    {
      {0},{0,0,&_44c4_s_p1_0},{0,0,&_44c4_s_p2_0},{0,0,&_44c4_s_p3_0},
      {0,0,&_44c4_s_p4_0},{0,0,&_44c4_s_p5_0},{0,0,&_44c4_s_p6_0},
@@ -347,6 +343,7 @@
   /* mode 5; 160-ish */
   {{&_residue_44_mid, &_residue_44_mid},  
    {&_huff_book__44c5_short,&_huff_book__44c5_long},
+   {&_huff_book__44c5_short,&_huff_book__44c5_long},
    {
      {0},{0,0,&_44c5_s0_p1_0},{0,0,&_44c5_s0_p2_0},{0,0,&_44c5_s0_p3_0},
      {0,0,&_44c5_s0_p4_0},{0,0,&_44c5_s0_p5_0},{0,0,&_44c5_s0_p6_0},
@@ -358,6 +355,7 @@
   /* mode 6; 192-ish */
   {{&_residue_44_mid, &_residue_44_mid},  
    {&_huff_book__44c6_short,&_huff_book__44c6_long},
+   {&_huff_book__44c6_short,&_huff_book__44c6_long},
    { 
      {0},{0,0,&_44c6_s0_p1_0},{0,0,&_44c6_s0_p2_0},{0,0,&_44c6_s0_p3_0},
      {0,0,&_44c6_s0_p4_0},{0,0,&_44c6_s0_p5_0},{0,0,&_44c6_s0_p6_0},
@@ -369,6 +367,7 @@
   /* mode 7; 224-ish */
   {{&_residue_44_high, &_residue_44_high},  
    {&_huff_book__44c7_short,&_huff_book__44c7_long},
+   {&_huff_book__44c7_short,&_huff_book__44c7_long},
    { 
      {0},{&_44c7_s0_p1_0,&_44c7_s0_p1_1},
      {&_44c7_s0_p2_0,&_44c7_s0_p2_1},
@@ -383,6 +382,7 @@
   /* mode 8; 256-ish */
   {{&_residue_44_high, &_residue_44_high},  
    {&_huff_book__44c8_short,&_huff_book__44c8_long},
+   {&_huff_book__44c8_short,&_huff_book__44c8_long},
    { 
      {0},{&_44c8_s0_p1_0,&_44c8_s0_p1_1},
      {&_44c8_s0_p2_0,&_44c8_s0_p2_1},
@@ -396,6 +396,7 @@
   /* mode 9; 320-ish */
   {{&_residue_44_high, &_residue_44_high},  
    {&_huff_book__44c9_short,&_huff_book__44c9_long},
+   {&_huff_book__44c9_short,&_huff_book__44c9_long},
    { 
      {0},{&_44c9_s0_p1_0,&_44c9_s0_p1_1},
      {&_44c9_s0_p2_0,&_44c9_s0_p2_1},
@@ -408,42 +409,6 @@
   }
 };
 
-static vorbis_residue_template _residue_template_44_stereo_m[11]={
-  /* mode 0; 64-ish */
-  { },
-  /* mode 1; 80-ish */
-  { },
-  /* mode 2; 96-ish */
-  { },
-  /* mode 3; 112-ish */
-  { },
-
-  /* mode 4; 128-ish */
-  {{&_residue_44_mid, &_residue_44_mid},  
-   {&_huff_book__44c4_sm_short,&_huff_book__44c4_sm_long},
-   {
-     {0},{0,0,&_44c4_sm_p1_0},{0,0,&_44c4_sm_p2_0},{0,0,&_44c4_sm_p3_0},
-     {0,0,&_44c4_sm_p4_0},{0,0,&_44c4_sm_p5_0},{0,0,&_44c4_sm_p6_0},
-     {&_44c4_sm_p7_0,&_44c4_sm_p7_1},{&_44c4_sm_p8_0,&_44c4_sm_p8_1},
-     {&_44c4_sm_p9_0,&_44c4_sm_p9_1,&_44c4_sm_p9_2}
-   },
-  },
-
-  /* mode 5; 160-ish */
-  { },
-
-  /* mode 6; 192-ish */
-  { },
-
-  /* mode 7; 224-ish */
-  { },
-
-  /* mode 8; 256-ish */
-  { },
-
-  /* mode 9; 320-ish */
-  { }
-};
 
 #include "books/uncoupled/_44u0_p1_0.vqh"
 #include "books/uncoupled/_44u0_p2_0.vqh"
@@ -485,10 +450,11 @@
 #include "books/uncoupled/_44u7_p9_1.vqh"
 #include "books/uncoupled/_44u7_p9_2.vqh"
 
-static vorbis_residue_template _residue_template_44_uncoupled[11]={
+static vorbis_residue_template _residue_template_44_uncoupled[10]={
   /* mode 0; 40/c-ish */
   {{&_residue_44_low_un, &_residue_44_low_un},  
    {&_huff_book__44c0_short,&_huff_book__44c0_long},
+   {&_huff_book__44c0_short,&_huff_book__44c0_long},
    { {0},
       {0,0,&_44u0_p1_0},
       {0,0,&_44u0_p2_0},
@@ -502,6 +468,7 @@
   /* mode 1; 50-ish */
   {{&_residue_44_low_un, &_residue_44_low_un},  
    {&_huff_book__44c1_short,&_huff_book__44c1_long},
+   {&_huff_book__44c1_short,&_huff_book__44c1_long},
    { {0},
       {0,0,&_44u0_p1_0},
       {0,0,&_44u0_p2_0},
@@ -515,6 +482,7 @@
   /* mode 2; 60-ish */
   {{&_residue_44_low_un, &_residue_44_low_un},  
    {&_huff_book__44c2_short,&_huff_book__44c2_long},
+   {&_huff_book__44c2_short,&_huff_book__44c2_long},
    { {0},
       {0,0,&_44u0_p1_0},
       {0,0,&_44u0_p2_0},
@@ -528,6 +496,7 @@
   /* mode 3; 70-ish */
   {{&_residue_44_low_un, &_residue_44_low_un},  
    {&_huff_book__44c3_short,&_huff_book__44c3_long},
+   {&_huff_book__44c3_short,&_huff_book__44c3_long},
    { {0},
       {0,0,&_44u0_p1_0},
       {0,0,&_44u0_p2_0},
@@ -541,6 +510,7 @@
   /* mode 4; 80-ish */
   {{&_residue_44_mid, &_residue_44_mid},  
    {&_huff_book__44c4_s_short,&_huff_book__44c4_s_long},
+   {&_huff_book__44c4_s_short,&_huff_book__44c4_s_long},
    { {0},
       {0,0,&_44u4_p1_0},
       {0,0,&_44u4_p2_0},
@@ -556,6 +526,7 @@
   /* mode 5; 90-ish */
   {{&_residue_44_mid, &_residue_44_mid},  
    {&_huff_book__44c5_short,&_huff_book__44c5_long},
+   {&_huff_book__44c5_short,&_huff_book__44c5_long},
    { {0},
       {0,0,&_44u4_p1_0},
       {0,0,&_44u4_p2_0},
@@ -571,6 +542,7 @@
   /* mode 6; 100-ish */
   {{&_residue_44_mid, &_residue_44_mid},  
    {&_huff_book__44c6_short,&_huff_book__44c6_long},
+   {&_huff_book__44c6_short,&_huff_book__44c6_long},
    { {0},
       {0,0,&_44u4_p1_0},
       {0,0,&_44u4_p2_0},
@@ -586,6 +558,7 @@
   /* mode 7 */
   {{&_residue_44_high_un, &_residue_44_high_un},  
    {&_huff_book__44c7_short,&_huff_book__44c7_long},
+   {&_huff_book__44c7_short,&_huff_book__44c7_long},
    { {0},
       {0,0,&_44u7_p1_0},
       {&_44u7_p2_0,&_44u7_p2_1},
@@ -601,6 +574,7 @@
   /* mode 8 */
   {{&_residue_44_high_un, &_residue_44_high_un},  
    {&_huff_book__44c8_short,&_huff_book__44c8_long},
+   {&_huff_book__44c8_short,&_huff_book__44c8_long},
    { {0},
       {0,0,&_44u7_p1_0},
       {&_44u7_p2_0,&_44u7_p2_1},
@@ -615,6 +589,7 @@
   },
   /* mode 9 */
   {{&_residue_44_high_un, &_residue_44_high_un},  
+   {&_huff_book__44c9_short,&_huff_book__44c9_long},
    {&_huff_book__44c9_short,&_huff_book__44c9_long},
    { {0},
       {0,0,&_44u7_p1_0},

<p><p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list