[xiph-commits] r12024 - in branches/vorbis-aotuv: . examples lib lib/modes

j at svn.xiph.org j at svn.xiph.org
Sun Nov 5 05:47:00 PST 2006


Author: j
Date: 2006-11-05 05:46:51 -0800 (Sun, 05 Nov 2006)
New Revision: 12024

Added:
   branches/vorbis-aotuv/examples/encoder_example_org.c
Modified:
   branches/vorbis-aotuv/aoTuV_README.txt
   branches/vorbis-aotuv/examples/encoder_example.c
   branches/vorbis-aotuv/lib/info.c
   branches/vorbis-aotuv/lib/mapping0.c
   branches/vorbis-aotuv/lib/modes/psych_44.h
   branches/vorbis-aotuv/lib/modes/setup_32.h
   branches/vorbis-aotuv/lib/psy.c
   branches/vorbis-aotuv/lib/psy.h
Log:
- aoTuV Beta2
The problem to which the sound of a specific range becomes large was reduced. 
Tuning was improved in all bit rate regions. 



Modified: branches/vorbis-aotuv/aoTuV_README.txt
===================================================================
--- branches/vorbis-aotuv/aoTuV_README.txt	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/aoTuV_README.txt	2006-11-05 13:46:51 UTC (rev 12024)
@@ -1,3 +1,5 @@
+aoTuV beta2 release note
+
 "aoTuV" tunes up libvorbis 1.0.1 uniquely. 
 A license is taken as "BSD-style license" as well as original libvorbis. 
 
@@ -4,9 +6,8 @@
 
 # NOTICE #
 
- On the frequency of 26kHz or more, q-2(nominal 40kbps/44.1-48kHz) can be used. 
- A part of Nominal bitrate has changed. 
- In the low bit rate (e.g. q-2), it is easy to clip. 
+ On the frequency of 26kHz or more, q-2(nominal 40kbps/44.1-48kHz) can be used.  A part of Nominal bitrate has changed. 
+ Use of bitrate management mode is not recommended. (In the future, psy.c and mapping0.c will need to be improved. )  Please specify this, when you compile this code and you distribute a binary. If you want to improve this portion, I welcome. iFor the moment, there is no schedule for which I improve this problem. )
 
 
 

Modified: branches/vorbis-aotuv/examples/encoder_example.c
===================================================================
--- branches/vorbis-aotuv/examples/encoder_example.c	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/examples/encoder_example.c	2006-11-05 13:46:51 UTC (rev 12024)
@@ -13,7 +13,19 @@
  function: simple example encoder
  last mod: $Id: encoder_example.c,v 1.50 2002/07/16 09:26:07 xiphmont Exp $
 
- ********************************************************************/
+ ********************************************************************
+  modified by AOYUMI
+   //-   delete
+   //+   add
+   //+~, //~+   add range
+   // /[asterisk]-~, [asterisk]/   delete range
+   
+   support only 16bit PCM .WAV file
+   
+   2004/04/26 
+    In order to enable it to compile by Linux, a patch is applied to 
+   a this code.  This patch is offer from Frederik Himpe. 
+ *********************************************************************/
 
 /* takes a stereo 16bit 44.1kHz WAV file from stdin and encodes it into
    a Vorbis bitstream */
@@ -24,6 +36,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <sys/types.h> //+
+#include <sys/stat.h> //+
 #include <math.h>
 #include <vorbis/vorbisenc.h>
 
@@ -37,9 +51,12 @@
 #endif
 
 #define READ 1024
+#define DEF_Q 0  /* Default Quality Setting */  //+
+
 signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */
 
-int main(){
+//- int main(){
+  int main(int argc, char *argv[]){ //+
   ogg_stream_state os; /* take physical pages, weld into a logical
 			  stream of packets */
   ogg_page         og; /* one Ogg bitstream page.  Vorbis packets are inside */
@@ -55,6 +72,27 @@
   int eos=0,ret;
   int i, founddata;
 
+//+~
+  float qnum = DEF_Q;
+  int qx = 1;
+  if(argc < 2){
+	puts("usage: encoder_example -q4 filename.wav");
+	exit(1);
+  }
+  if( !strncmp(argv[1], "-q", 2) ){
+	if( strlen(argv[1]) > 2 ){
+		qnum = atof(argv[1]+2);
+	}
+	if( !((qnum >= -2) && (qnum <= 10)) ) qnum = DEF_Q;
+	qx++;
+  }
+  FILE *FP;
+  if( !(FP = fopen(argv[qx], "rb")) ){
+	puts("source file not found");
+	exit(1);
+  }
+//~+
+
 #if defined(macintosh) && defined(__MWERKS__)
   int argc = 0;
   char **argv = NULL;
@@ -80,18 +118,38 @@
      verify that it matches 16bit/stereo/44.1kHz.  This is just an
      example, after all. */
 
+  unsigned long footer = 0; //+
+  unsigned long sa_rate = 44100; //+
+  unsigned long channel; //+
+  struct stat sbuf; //+
+  stat(argv[qx], &sbuf); //+
+
   readbuffer[0] = '\0';
-  for (i=0, founddata=0; i<30 && ! feof(stdin) && ! ferror(stdin); i++)
+//-  for (i=0, founddata=0; i<30 && ! feof(stdin) && ! ferror(stdin); i++)
+  for (i=0, founddata=0; i<30 && ! feof(FP) && ! ferror(FP); i++) //+
   {
-    fread(readbuffer,1,2,stdin);
-
-    if ( ! strncmp((char*)readbuffer, "da", 2) )
+//-    fread(readbuffer,1,2,stdin);
+    fread(readbuffer,1,2,FP); //+
+//+~
+    if ( ! memcmp(readbuffer, "fm", 2) ){
+       fread(readbuffer,1,8,FP); //+
+       fread(&channel,1,2,FP); //+
+       fread(&sa_rate,1,4,FP); //+
+    }
+//~+
+//-    if ( ! strncmp((char*)readbuffer, "da", 2) )
+    if ( ! memcmp(readbuffer, "da", 2) ) //+
     {
       founddata = 1;
-      fread(readbuffer,1,6,stdin);
+//-      fread(readbuffer,1,6,stdin);
+      fread(readbuffer,1,6,FP); //+
+      memcpy(&footer, readbuffer+2, 4); //+
+      footer += ftell(FP); //+
       break;
     }
   }
+  footer = sbuf.st_size - footer; //+
+  printf("\n%dHz\n", sa_rate); //+
 
   /********** Encode setup ************/
 
@@ -126,14 +184,29 @@
 
    *********************************************************************/
 
-  ret=vorbis_encode_init_vbr(&vi,2,44100,.5);
-
+//-  ret=vorbis_encode_init_vbr(&vi,2,44100,.4);
+  ret=vorbis_encode_init_vbr(&vi,channel,sa_rate, qnum/10); //+
   /* do not continue if setup failed; this can happen if we ask for a
      mode that libVorbis does not support (eg, too low a bitrate, etc,
      will return 'OV_EIMPL') */
 
-  if(ret)exit(1);
-
+//-  if(ret)exit(1);
+//+~
+  if(ret){
+	puts("encode init error");
+	exit(1);
+  }
+  char wfile[1024];
+  strcpy(wfile, argv[qx]);
+  strcat(wfile, ".ogg");
+  FILE *FP2;
+  if( !(FP2 = fopen(wfile, "wb")) ){
+	puts("file open error");
+	exit(1);
+  }
+  
+  printf("Quality %f\n Encoding...", qnum);
+//~+
   /* add a comment */
   vorbis_comment_init(&vc);
   vorbis_comment_add_tag(&vc,"ENCODER","encoder_example.c");
@@ -172,22 +245,26 @@
 	while(!eos){
 		int result=ogg_stream_flush(&os,&og);
 		if(result==0)break;
-		fwrite(og.header,1,og.header_len,stdout);
-		fwrite(og.body,1,og.body_len,stdout);
+//-		fwrite(og.header,1,og.header_len,stdout);
+		fwrite(og.header,1,og.header_len,FP2); //+
+//-		fwrite(og.body,1,og.body_len,stdout);
+		fwrite(og.body,1,og.body_len,FP2); //+
 	}
 
   }
-  
+
   while(!eos){
     long i;
-    long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */
-
+//-   long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */
+    long bytes=fread(readbuffer,1,READ*(channel*2),FP); //+
+    if(bytes < (READ*(channel*2))) bytes -= footer; //+
+    if(bytes < 0) bytes = 0; //+
     if(bytes==0){
-      /* end of file.  this can be done implicitly in the mainline,
-         but it's easier to see here in non-clever fashion.
-         Tell the library we're at end of stream so that it can handle
-         the last frame and mark end of stream in the output properly */
-      vorbis_analysis_wrote(&vd,0);
+     /* end of file.  this can be done implicitly in the mainline,
+        but it's easier to see here in non-clever fashion.
+        Tell the library we're at end of stream so that it can handle
+        the last frame and mark end of stream in the output properly */
+       vorbis_analysis_wrote(&vd,0);
 
     }else{
       /* data to encode */
@@ -196,13 +273,23 @@
       float **buffer=vorbis_analysis_buffer(&vd,READ);
       
       /* uninterleave samples */
+/*-~
       for(i=0;i<bytes/4;i++){
 	buffer[0][i]=((readbuffer[i*4+1]<<8)|
 		      (0x00ff&(int)readbuffer[i*4]))/32768.f;
 	buffer[1][i]=((readbuffer[i*4+3]<<8)|
 		      (0x00ff&(int)readbuffer[i*4+2]))/32768.f;
       }
-    
+*/
+//+~
+      for(i=0;i<bytes/(channel*2);i++){
+	buffer[0][i]=((readbuffer[i*(channel*2)+1]<<8)|
+		      (0x00ff&(int)readbuffer[i*(channel*2)]))/32768.f;
+	if(channel == 2)
+	buffer[1][i]=((readbuffer[i*(channel*2)+3]<<8)|
+		      (0x00ff&(int)readbuffer[i*(channel*2)+2]))/32768.f;
+      }
+//~+
       /* tell the library how much we actually submitted */
       vorbis_analysis_wrote(&vd,i);
     }
@@ -225,8 +312,10 @@
 	while(!eos){
 	  int result=ogg_stream_pageout(&os,&og);
 	  if(result==0)break;
-	  fwrite(og.header,1,og.header_len,stdout);
-	  fwrite(og.body,1,og.body_len,stdout);
+//-	  fwrite(og.header,1,og.header_len,stdout);
+	  fwrite(og.header,1,og.header_len,FP2); //+
+//-	  fwrite(og.body,1,og.body_len,stdout);
+	  fwrite(og.body,1,og.body_len,FP2); //+
 	  
 	  /* this could be set above, but for illustrative purposes, I do
 	     it here (to show that vorbis does know where the stream ends) */
@@ -247,7 +336,8 @@
   
   /* ogg_page and ogg_packet structs always point to storage in
      libvorbis.  They're never freed or manipulated directly */
-  
+  fclose(FP); //+
+  fclose(FP2); //+
   fprintf(stderr,"Done.\n");
   return(0);
 }

Added: branches/vorbis-aotuv/examples/encoder_example_org.c
===================================================================
--- branches/vorbis-aotuv/examples/encoder_example_org.c	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/examples/encoder_example_org.c	2006-11-05 13:46:51 UTC (rev 12024)
@@ -0,0 +1,253 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
+ * by the XIPHOPHORUS Company http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+ function: simple example encoder
+ last mod: $Id: encoder_example.c,v 1.50 2002/07/16 09:26:07 xiphmont Exp $
+
+ ********************************************************************/
+
+/* takes a stereo 16bit 44.1kHz WAV file from stdin and encodes it into
+   a Vorbis bitstream */
+
+/* Note that this is POSIX, not ANSI, code */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <math.h>
+#include <vorbis/vorbisenc.h>
+
+#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
+#include <io.h>
+#include <fcntl.h>
+#endif
+
+#if defined(__MACOS__) && defined(__MWERKS__)
+#include <console.h>      /* CodeWarrior's Mac "command-line" support */
+#endif
+
+#define READ 1024
+signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */
+
+int main(){
+  ogg_stream_state os; /* take physical pages, weld into a logical
+			  stream of packets */
+  ogg_page         og; /* one Ogg bitstream page.  Vorbis packets are inside */
+  ogg_packet       op; /* one raw packet of data for decode */
+  
+  vorbis_info      vi; /* struct that stores all the static vorbis bitstream
+			  settings */
+  vorbis_comment   vc; /* struct that stores all the user comments */
+
+  vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+  vorbis_block     vb; /* local working space for packet->PCM decode */
+
+  int eos=0,ret;
+  int i, founddata;
+
+#if defined(macintosh) && defined(__MWERKS__)
+  int argc = 0;
+  char **argv = NULL;
+  argc = ccommand(&argv); /* get a "command line" from the Mac user */
+                          /* this also lets the user set stdin and stdout */
+#endif
+
+  /* we cheat on the WAV header; we just bypass 44 bytes and never
+     verify that it matches 16bit/stereo/44.1kHz.  This is just an
+     example, after all. */
+
+#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
+  /* if we were reading/writing a file, it would also need to in
+     binary mode, eg, fopen("file.wav","wb"); */
+  /* Beware the evil ifdef. We avoid these where we can, but this one we 
+     cannot. Don't add any more, you'll probably go to hell if you do. */
+  _setmode( _fileno( stdin ), _O_BINARY );
+  _setmode( _fileno( stdout ), _O_BINARY );
+#endif
+
+
+  /* we cheat on the WAV header; we just bypass the header and never
+     verify that it matches 16bit/stereo/44.1kHz.  This is just an
+     example, after all. */
+
+  readbuffer[0] = '\0';
+  for (i=0, founddata=0; i<30 && ! feof(stdin) && ! ferror(stdin); i++)
+  {
+    fread(readbuffer,1,2,stdin);
+
+    if ( ! strncmp((char*)readbuffer, "da", 2) )
+    {
+      founddata = 1;
+      fread(readbuffer,1,6,stdin);
+      break;
+    }
+  }
+
+  /********** Encode setup ************/
+
+  vorbis_info_init(&vi);
+
+  /* choose an encoding mode.  A few possibilities commented out, one
+     actually used: */
+
+  /*********************************************************************
+   Encoding using a VBR quality mode.  The usable range is -.1
+   (lowest quality, smallest file) to 1. (highest quality, largest file).
+   Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR 
+  
+   ret = vorbis_encode_init_vbr(&vi,2,44100,.4);
+
+   ---------------------------------------------------------------------
+
+   Encoding using an average bitrate mode (ABR).
+   example: 44kHz stereo coupled, average 128kbps VBR 
+  
+   ret = vorbis_encode_init(&vi,2,44100,-1,128000,-1);
+
+   ---------------------------------------------------------------------
+
+   Encode using a qulity mode, but select that quality mode by asking for
+   an approximate bitrate.  This is not ABR, it is true VBR, but selected
+   using the bitrate interface, and then turning bitrate management off:
+
+   ret = ( vorbis_encode_setup_managed(&vi,2,44100,-1,128000,-1) ||
+           vorbis_encode_ctl(&vi,OV_ECTL_RATEMANAGE_AVG,NULL) ||
+           vorbis_encode_setup_init(&vi));
+
+   *********************************************************************/
+
+  ret=vorbis_encode_init_vbr(&vi,2,44100,.5);
+
+  /* do not continue if setup failed; this can happen if we ask for a
+     mode that libVorbis does not support (eg, too low a bitrate, etc,
+     will return 'OV_EIMPL') */
+
+  if(ret)exit(1);
+
+  /* add a comment */
+  vorbis_comment_init(&vc);
+  vorbis_comment_add_tag(&vc,"ENCODER","encoder_example.c");
+
+  /* set up the analysis state and auxiliary encoding storage */
+  vorbis_analysis_init(&vd,&vi);
+  vorbis_block_init(&vd,&vb);
+  
+  /* set up our packet->stream encoder */
+  /* pick a random serial number; that way we can more likely build
+     chained streams just by concatenation */
+  srand(time(NULL));
+  ogg_stream_init(&os,rand());
+
+  /* Vorbis streams begin with three headers; the initial header (with
+     most of the codec setup parameters) which is mandated by the Ogg
+     bitstream spec.  The second header holds any comment fields.  The
+     third header holds the bitstream codebook.  We merely need to
+     make the headers, then pass them to libvorbis one at a time;
+     libvorbis handles the additional Ogg bitstream constraints */
+
+  {
+    ogg_packet header;
+    ogg_packet header_comm;
+    ogg_packet header_code;
+
+    vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);
+    ogg_stream_packetin(&os,&header); /* automatically placed in its own
+					 page */
+    ogg_stream_packetin(&os,&header_comm);
+    ogg_stream_packetin(&os,&header_code);
+
+	/* This ensures the actual
+	 * audio data will start on a new page, as per spec
+	 */
+	while(!eos){
+		int result=ogg_stream_flush(&os,&og);
+		if(result==0)break;
+		fwrite(og.header,1,og.header_len,stdout);
+		fwrite(og.body,1,og.body_len,stdout);
+	}
+
+  }
+  
+  while(!eos){
+    long i;
+    long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */
+
+    if(bytes==0){
+      /* end of file.  this can be done implicitly in the mainline,
+         but it's easier to see here in non-clever fashion.
+         Tell the library we're at end of stream so that it can handle
+         the last frame and mark end of stream in the output properly */
+      vorbis_analysis_wrote(&vd,0);
+
+    }else{
+      /* data to encode */
+
+      /* expose the buffer to submit data */
+      float **buffer=vorbis_analysis_buffer(&vd,READ);
+      
+      /* uninterleave samples */
+      for(i=0;i<bytes/4;i++){
+	buffer[0][i]=((readbuffer[i*4+1]<<8)|
+		      (0x00ff&(int)readbuffer[i*4]))/32768.f;
+	buffer[1][i]=((readbuffer[i*4+3]<<8)|
+		      (0x00ff&(int)readbuffer[i*4+2]))/32768.f;
+      }
+    
+      /* tell the library how much we actually submitted */
+      vorbis_analysis_wrote(&vd,i);
+    }
+
+    /* vorbis does some data preanalysis, then divvies up blocks for
+       more involved (potentially parallel) processing.  Get a single
+       block for encoding now */
+    while(vorbis_analysis_blockout(&vd,&vb)==1){
+
+      /* analysis, assume we want to use bitrate management */
+      vorbis_analysis(&vb,NULL);
+      vorbis_bitrate_addblock(&vb);
+
+      while(vorbis_bitrate_flushpacket(&vd,&op)){
+	
+	/* weld the packet into the bitstream */
+	ogg_stream_packetin(&os,&op);
+	
+	/* write out pages (if any) */
+	while(!eos){
+	  int result=ogg_stream_pageout(&os,&og);
+	  if(result==0)break;
+	  fwrite(og.header,1,og.header_len,stdout);
+	  fwrite(og.body,1,og.body_len,stdout);
+	  
+	  /* this could be set above, but for illustrative purposes, I do
+	     it here (to show that vorbis does know where the stream ends) */
+	  
+	  if(ogg_page_eos(&og))eos=1;
+	}
+      }
+    }
+  }
+
+  /* clean up and exit.  vorbis_info_clear() must be called last */
+  
+  ogg_stream_clear(&os);
+  vorbis_block_clear(&vb);
+  vorbis_dsp_clear(&vd);
+  vorbis_comment_clear(&vc);
+  vorbis_info_clear(&vi);
+  
+  /* ogg_page and ogg_packet structs always point to storage in
+     libvorbis.  They're never freed or manipulated directly */
+  
+  fprintf(stderr,"Done.\n");
+  return(0);
+}

Modified: branches/vorbis-aotuv/lib/info.c
===================================================================
--- branches/vorbis-aotuv/lib/info.c	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/lib/info.c	2006-11-05 13:46:51 UTC (rev 12024)
@@ -416,7 +416,7 @@
 }
 
 static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
-  char temp[]="AO; aoTuV b1a (based on Xiph.Org's 1.0.1)";
+  char temp[]="AO; aoTuV b2 [20040420]  (based on Xiph.Org's 1.0.1)";
   int bytes = strlen(temp);
 
   /* preamble */  

Modified: branches/vorbis-aotuv/lib/mapping0.c
===================================================================
--- branches/vorbis-aotuv/lib/mapping0.c	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/lib/mapping0.c	2006-11-05 13:46:51 UTC (rev 12024)
@@ -404,7 +404,9 @@
 			 noise,
 			 tone,
 			 1,
-			 logmask);
+			 logmask,
+			 mdct,
+			 logmdct);
 
 #if 0
       if(vi->channels==2){
@@ -434,7 +436,9 @@
 			   noise,
 			   tone,
 			   2,
-			   logmask);
+			   logmask,
+			   mdct,
+			   logmdct);
 
 #if 0
 	if(vi->channels==2){
@@ -455,7 +459,9 @@
 			   noise,
 			   tone,
 			   0,
-			   logmask);
+			   logmask,
+			   mdct,
+			   logmdct);
 
 #if 0
 	if(vi->channels==2)
@@ -522,6 +528,11 @@
 					psy_look,
 					info,
 					mag_memo);    
+      
+      hf_reduction(&ci->psy_g_param,
+					psy_look,
+					info,
+					mag_memo);
     }
 
     memset(sortindex,0,sizeof(*sortindex)*vi->channels);

Modified: branches/vorbis-aotuv/lib/modes/psych_44.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/psych_44.h	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/lib/modes/psych_44.h	2006-11-05 13:46:51 UTC (rev 12024)
@@ -69,13 +69,6 @@
      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 */
-/*  alt
-     0,1,2,3,4,5,6,6,
-     6,6,6,7,7,7,7,7,
-     7,8,9,10,11,12,13,14,
-     15,16,17,17,17,18,18,19,
-     19,19,20,21,22,23,24,25,
-*/
   }},
   /* mode A short */
   {{
@@ -84,13 +77,6 @@
     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 */
-/*  alt
-    0,1,2,3,4,5,5,5,
-    5,5,5,5,6,6,6,6,
-    6,6,6,6,6,6,6,6,
-    7,7,7,8,8,8,9,10,
-    11,12,13,14,15,16,17,18
-*/    
   }},
   /* sub-mode Z long */
   {{
@@ -115,13 +101,6 @@
     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 */
-/*  alt
-    0,1,2,3,4,5,5,5,
-    6,6,6,6,6,6,6,6,
-    6,6,6,6,6,7,7,7,
-    7,7,7,8,8,8,9,10,
-    11,12,13,14,15,16,17,18,
-*/
   }}
 };
 
@@ -131,16 +110,16 @@
 static vp_adjblock _vp_tonemask_adj_longblock_low[3]={
   /* adjust for mode zero */
    /* 63     125     250     500       1       2       4       8      16 */
-   {{ -3,-10,-13,-15,-10,-10,-10,-10,-10,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 0(-2) */
-   {{ -3,-10,-13,-15,-12,-12,-11,-11,-11,-11,-11, -1, -1, -1, -1,  0,  0}}, /* 1(-1) */
-   {{ -3,-10,-13,-16,-15,-14,-13,-12,-12,-12,-11, -1, -2, -1, -1, -1,  0}}, /* 2(-0) */
+   {{ -3, -8,-13,-15,-10,-10,-10,-10,-10,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 0(-2) */
+   {{ -3, -8,-13,-15,-12,-12,-11,-11,-11,-11,-11, -1, -1, -1, -1,  0,  0}}, /* 1(-1) */
+   {{ -4,-10,-14,-16,-15,-14,-13,-12,-12,-12,-11, -1, -1, -1, -1, -1,  0}}, /* 2(-0) */
 };
 static vp_adjblock _vp_tonemask_adj_otherblock_low[3]={
   /* adjust for mode zero */
    /* 63     125     250     500       1       2       4       8      16 */
-   {{  0, -7,-12,-15,-10,-10, -9, -9, -9, -9, -9,  1,  1,  1,  1,  1,  1}}, /* 0(-2) */
-   {{  0, -7,-12,-15,-11,-11,-10,-10,-10,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 1(-1) */
-   {{  0, -7,-12,-16,-14,-13,-11,-11,-10,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 2(-0) */
+   {{ -3, -8,-13,-15,-10,-10, -9, -9, -9, -9, -9,  1,  1,  1,  1,  1,  1}}, /* 0(-2) */
+   {{ -3, -8,-13,-15,-11,-11,-10,-10,-10,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 1(-1) */
+   {{ -4,-10,-14,-16,-14,-13,-11,-11,-10,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 2(-0) */
 };
 
 static vp_adjblock _vp_tonemask_adj_longblock[11]={
@@ -148,56 +127,54 @@
   /* 63     125     250     500     1     2     4     8    16 */
    /* 63     125     250     500       1       2       4       8      16 */
 //  {{-15,-15,-15,-15,-10, -8, -4,-2, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */
-   {{ -3,-10,-14,-16,-15,-14,-13,-12,-12,-12,-11, -1, -2, -1, -1, -1,  0}}, /* 0 */
+   {{ -4,-10,-14,-16,-15,-14,-13,-12,-12,-12,-11, -1, -1, -1, -1, -1,  0}}, /* 0 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 5, 0, 0, 0, 0, 0}}, /* 1 *
-   {{ -3,-10,-14,-16,-16,-15,-14,-13,-13,-12,-11, -1, -2, -2, -1, -1,  0}}, /* 1 */
+   {{ -6,-12,-14,-16,-15,-15,-14,-13,-13,-12,-12, -2, -2, -1, -1, -1,  0}}, /* 1 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */
-   {{ -3,-10,-14,-16,-16,-16,-15,-14,-14,-13,-12, -2, -2, -2, -1, -1,  0}}, /* 2 */
+   {{-12,-13,-14,-16,-16,-16,-15,-14,-13,-12,-12, -6, -3, -1, -1, -1,  0}}, /* 2 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 3 */
-   {{ -3,-10,-14,-16,-16,-16,-16,-14,-14,-13,-13,-10, -2, -2, -1, -1,  0}}, /* 3 */
+   {{-15,-15,-15,-16,-16,-16,-16,-14,-13,-13,-13,-10, -4, -2, -1, -1,  0}}, /* 3 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 4 */
-   {{ -3,-10,-14,-16,-16,-16,-16,-14,-14,-14,-13,-11, -3, -2, -2, -1, -1}}, /* 4 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7  -3, -1, -1 , 0}}, /* 4 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 5 */
-   {{ -3,-10,-14,-16,-16,-16,-16,-15,-14,-14,-14,-12, -3, -2, -2, -1, -1}}, /* 5 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7  -3, -1, -1 , 0}}, /* 5 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 6 */
-   {{ -3,-10,-13,-16,-16,-16,-16,-15,-14,-14,-14,-14, -4, -2, -2, -2, -2}}, /* 6 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -8, -4, -2, -2,  0}}, /* 6 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 7 */
-   {{ -3,-10,-13,-16,-16,-16,-16,-15,-14,-14,-14,-14, -4, -2, -2, -2, -2}}, /* 7 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 7 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 8 */
-   {{ -3,-10,-13,-16,-16,-16,-16,-15,-14,-14,-14,-14, -4, -2, -2, -2, -2}}, /* 8 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 8 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 9 */
-   {{ -3,-10,-13,-16,-16,-16,-16,-15,-14,-14,-14,-14, -4, -2, -2, -2, -2}}, /* 9 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 9 */
 //  {{-15,-15,-15,-15,-15,-12,-10,-8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 10 */
-   {{ -3,-10,-13,-16,-16,-16,-16,-15,-14,-14,-14,-14, -4, -2, -2, -2, -2}}, /* 10 */
-//   {{-3, -10, -13,-16, -16,-16, -16,-15, -14,-14, -14,-14,-4,-2,-2,-3,-2}}, /* 6-10 alt */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 10 */
 };
 static vp_adjblock _vp_tonemask_adj_otherblock[11]={
   /* adjust for mode zero */
   /* 63     125     250     500       1     2     4     8    16 */
    /* 63     125     250     500       1       2       4       8      16 */
 //  {{-20,-20,-20,-20,-14,-12,-10, -8, -4, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */
-   {{  0, -7,-12,-16,-14,-13,-11,-11,-10,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 0 */
+   {{ -4,-10,-14,-16,-14,-13,-12,-12,-11,-11,-10,  0,  0,  0,  0,  0,  0}}, /* 0 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 5, 0, 0, 0, 0, 0}}, /* 1 */
-   {{  0, -7,-12,-16,-16,-14,-12,-12,-12,-10,-10,  0,  0,  0,  0,  0,  0}}, /* 1 */
+   {{ -6,-12,-14,-16,-15,-15,-14,-13,-13,-12,-12, -2, -2, -1,  0,  0,  0}}, /* 1 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */
-   {{  0, -7,-12,-16,-16,-15,-14,-13,-13,-11,-11,  0,  0,  0,  0,  0,  0}}, /* 2 */
+   {{-12,-13,-14,-16,-16,-16,-15,-14,-13,-12,-12, -5, -2, -1,  0,  0,  0}}, /* 2 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 3 */
-   {{  0, -7,-12,-16,-16,-16,-15,-14,-14,-12,-12, -2,  0,  0,  0,  0,  0}}, /* 3 */
+   {{-15,-15,-15,-16,-16,-16,-16,-14,-13,-13,-13,-10, -4, -2,  0,  0,  0}}, /* 3 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 4 */
-   {{  0, -7,-12,-16,-16,-16,-16,-14,-14,-13,-12, -7, -1,  1,  0,  0,  0}}, /* 4 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7  -3, -1, -1 , 0}}, /* 4 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 5 */
-   {{  0, -7,-12,-16,-16,-16,-16,-14,-14,-14,-13, -8, -1,  1,  0,  0,  0}}, /* 5 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7  -3, -1, -1 , 0}}, /* 5 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 6 */
-   {{  0, -7,-12,-16,-16,-16,-16,-15,-14,-14,-13,-10, -1,  1,  0,  0,  0}}, /* 6 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -8, -4, -2, -2,  0}}, /* 6 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 7 */
-   {{  0, -7,-12,-16,-16,-16,-16,-15,-14,-14,-13,-10, -1,  1,  0,  0,  0}}, /* 7 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 7 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 8 */
-   {{  0, -7,-12,-16,-16,-16,-16,-15,-14,-14,-13,-10, -1,  1,  0,  0,  0}}, /* 8 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 8 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 9 */
-   {{  0, -7,-12,-16,-16,-16,-16,-15,-14,-14,-13,-10, -1,  1,  0,  0,  0}}, /* 9 */
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 9 */
 //  {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 10 */
-   {{  0, -7,-12,-16,-16,-16,-16,-15,-14,-14,-13,-10, -1,  1,  0,  0,  0}}, /* 10 */
-   //   {{0, -7, -12,-16, -16,-16, -16,-15, -14,-14,-13,-10,-2, 1,0,0,0}}, /* 6-10 alt*/
+   {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2,  0}}, /* 10 */
 };
 
 // noise bias low-bitrate (impulse,padding,trans)
@@ -210,7 +187,7 @@
 //    {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
     /* 0(-2) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-30,-30,-28,-28,-26,-20,-16, -8, -6, -6, -2,  2,  2,  3,  5,  6, 12},
+    {-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2,  2,  2,  3,  6,  6, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   /* 1 */
 //  {{{-15,-15,-15,-15,-15,-10, -5,  0,  2,  2,  6,  6,  6,  8, 10, 12, 15},
@@ -218,11 +195,11 @@
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4,  -2}}},
     /* 1(-1) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2,  2,  2,  3,  5,  6, 12},
+    {-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2,  2,  2,  3,  6,  6, 12},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
     /* 2(-0) */
   {{{-15,-15,-15,-15,-15,-10, -5,  0,  2,  2,  6,  6,  6,  8, 10, 12, 15},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2,  0,  0,  0,  2,  4,  10},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2,  0,  0,  0,  2,  3,   6},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4,  -2}}},
 };
 // noise bias low-bitrate (long)
@@ -235,7 +212,7 @@
 //    {-20,-20,-20,-20,-20,-20,-20,-10, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},
     /* 0(-2) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  0,  6,  6,  6,  6, 10, 10, 12,  20},
-    {-20,-20,-20,-20,-20,-20,-10, -2,  0,  1,  1,  1,  1,  3,  6,  8,  12},
+    {-20,-20,-20,-20,-20,-20,-10, -2,  0,  0,  0,  0,  0,  2,  4,  6,  15},
     {-20,-20,-20,-20,-20,-20,-20,-10, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},
   /* 1 */
 //  {{{-10,-10,-10,-10,-10,-10, -8, -8,  0,  2,  4,  4,  5,  5,  5,  8,  10},
@@ -243,11 +220,11 @@
 //    {-20,-20,-20,-20,-20,-20,-20,-14, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},
     /* 1(-1) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  0,  6,  6,  6,  6, 10, 10, 12,  20},
-    {-20,-20,-20,-20,-20,-20,-10, -2,  0,  0,  0,  0,  0,  2,  4,  6,  10},
+    {-20,-20,-20,-20,-20,-20,-10, -2,  0,  0,  0,  0,  0,  1,  3,  5,  10},
     {-20,-20,-20,-20,-20,-20,-20,-10, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},
     /* 2(-0) */
   {{{-10,-10,-10,-10,-10,-10, -8, -8,  0,  2,  4,  4,  5,  5,  5,  8,  10},
-    {-20,-20,-20,-20,-20,-20,-20,-14, -8, -2,  0,  0,  0,  0,  2,  4,  10},
+    {-20,-20,-20,-20,-20,-20,-20,-14, -8, -2,  0,  0,  0,  0,  2,  3,  6},
     {-20,-20,-20,-20,-20,-20,-20,-14, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},
 };
 
@@ -264,35 +241,35 @@
 //    {-30,-30,-30,-30,-26,-22,-20,-14, -8, -4,  0,  0,  0,  0,  2,  4,  10},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4,  -2}}},
   {{{-15,-15,-15,-15,-15,-12,-10, -8,  0,  2,  4,  4,  5,  5,  5,  8,  10},
-    {-30,-30,-30,-30,-26,-22,-20,-14, -8, -4,  0,  0,  0,  0,  2,  3,  10},
+    {-30,-30,-30,-30,-26,-22,-20,-14, -8, -4,  0,  0,  0,  0,  2,  3,   6},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4,  -2}}},
   /* 1 */
 //  {{{-15,-15,-15,-15,-15,-12,-10, -8,  0,  2,  4,  4,  5,  5,  5,  8,  10},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2,  0,  2,  8},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}},
   {{{-15,-15,-15,-15,-15,-12,-10, -8,  0,  2,  4,  4,  5,  5,  5,  8,  10},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2,  0,  1,   3},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2,  0,  1,   4},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6,  -4}}},
   /* 2 */
 //  {{{-15,-15,-15,-15,-15,-12,-10, -8,  0,  2,  2,  2,  4,  4,  5,  6,  10},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2,  0,  2,  6},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   {{{-15,-15,-15,-15,-15,-12,-10, -8,  0,  2,  2,  2,  4,  4,  5,  6,  9},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, -1,  0,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -2, -1,  0,  3},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -7, -4}}},
   /* 3 */
 //  {{{-15,-15,-15,-15,-15,-12,-10, -8,  0,  2,  2,  2,  4,  4,  4,  5,  8},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1,  1,  6},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   {{{-15,-15,-15,-15,-15,-12,-10, -8,  0,  2,  2,  2,  4,  4,  4,  5,  8},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1,  0,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -2,  0,  2},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   /* 4 */
 //  {{{-20,-20,-20,-20,-20,-18,-14, -8, -1,  1,  1,  1,  2,  3,  3,  4,  7},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1,  1,  5},
 //    {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   {{{-20,-20,-20,-20,-20,-18,-14, -8, -1,  1,  1,  1,  2,  3,  3,  4,  7},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -2,  0,  1},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -2, -1,  1},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   /* 5 */
 //  {{{-24,-24,-24,-24,-20,-18,-14, -8, -1,  1,  1,  1,  2,  3,  3,  4,  7},
@@ -312,16 +289,16 @@
 //  {{{-24,-24,-24,-24,-20,-18,-14, -8, -1,  1,  1,  1,  2,  3,  3,  4, 7},
 //    {-32,-32,-32,-32,-28,-24,-24,-18,-14,-12,-10, -8, -8, -8, -6, -4,  0},
 //    {-34,-34,-34,-34,-30,-26,-26,-24,-22,-19,-19,-19,-19,-18,-17,-16,-12}}},
-  {{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2,  0,  0,  0,  1,  2,  3,  7},  // q8
-    {-36,-36,-36,-36,-30,-30,-30,-24,-18,-14,-12,-10,-10,-10, -8, -6, -2},
-    {-36,-36,-36,-36,-34,-30,-28,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},
+  {{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2,  0,  0,  0,  1,  2,  3,  7},
+    {-32,-32,-32,-32,-28,-24,-24,-24,-18,-14,-12,-10,-10,-10, -8, -6, -2},
+    {-34,-34,-34,-34,-30,-26,-26,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},
   /* 8 */
 //  {{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2,  0,  0,  0,  1,  2,  3,  7},
 //    {-36,-36,-36,-36,-30,-30,-30,-24,-18,-14,-12,-10,-10,-10, -8, -6, -2},
 //    {-36,-36,-36,-36,-34,-30,-28,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},
-  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  2},  // q9
-    {-36,-36,-36,-36,-34,-32,-32,-28,-20,-16,-16,-16,-16,-14,-12,-10, -7},
-    {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-24,-20}}},
+  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  2}, 
+    {-36,-36,-36,-36,-30,-30,-30,-24,-20,-16,-16,-16,-16,-14,-12,-10, -7},
+    {-36,-36,-36,-36,-34,-30,-28,-26,-24,-30,-30,-30,-30,-30,-30,-24,-20}}},
   /* 9 */
 //  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  2},
 //    {-36,-36,-36,-36,-34,-32,-32,-28,-20,-16,-16,-16,-16,-14,-12,-10, -7},
@@ -347,7 +324,7 @@
 //    {-20,-20,-20,-20,-20,-20,-20,-14, -6,  0,  0,  0,  0,  0,  2,  4,  10},
 //    {-20,-20,-20,-20,-20,-20,-20,-14, -8, -6, -6, -6, -6, -4, -4, -4, -2}}},
   {{{-10,-10,-10,-10,-10,-10, -8,  2,  2,  2,  4,  4,  5,  5,  5,  8,  10},
-    {-20,-20,-20,-20,-20,-20,-20,-14, -6,  0,  0,  0,  0,  0,  2,  3,  10},
+    {-20,-20,-20,-20,-20,-20,-20,-14, -6,  0,  0,  0,  0,  0,  2,  3,  6},
     {-20,-20,-20,-20,-20,-20,-20,-14, -8, -6, -6, -6, -6, -4, -4, -4, -2}}},
   /* 1 (1.0) */
 //  {{{-10,-10,-10,-10,-10,-10, -8, -4,  0,  2,  4,  4,  5,  5,  5,  8,  10},
@@ -358,28 +335,28 @@
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2,  0,  2,  8},
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}},
   {{{-10,-10,-10,-10,-10,-10, -8, -4,  0,  2,  4,  4,  5,  5,  5,  8,  10},
-    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2,  0,  1,  3},
+    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2,  0,  1,  4},
     {-20,-20,-20,-20,-20,-20,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}},
   /* 2 */
 //  {{{-10,-10,-10,-10,-10,-10,-10, -8,  0,  2,  2,  2,  4,  4,  5,  6,  10},
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2,  0,  2,  6},
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   {{{-10,-10,-10,-10,-10,-10,-10, -8,  0,  2,  2,  2,  4,  4,  5,  6,  10},
-    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2, -1,  0,  2},
+    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -2, -1,  0,  3},
     {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   /* 3 */
 //  {{{-10,-10,-10,-10,-10,-10,-10, -8,  0,  2,  2,  2,  4,  4,  4,  5,  8},
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -1,  1,  6},
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   {{{-10,-10,-10,-10,-10,-10,-10, -8,  0,  2,  2,  2,  3,  3,  4,  4,  7},
-    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -1,  0,  2},
+    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -2,  0,  2},
     {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -5}}},
   /* 4 */
 //  {{{-15,-15,-15,-15,-15,-15,-15,-10, -4,  1,  1,  1,  2,  3,  3,  4,  7},
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -1,  1,  5},
 //    {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
   {{{-15,-15,-15,-15,-15,-15,-15,-10, -4,  1,  1,  1,  2,  3,  3,  4,  7},
-    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -2,  0,  1},
+    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -2, -1,  1},
     {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -7}}},
   /* 5 */
 //  {{{-15,-15,-15,-15,-15,-15,-15,-10, -4,  1,  1,  1,  2,  3,  3,  4,  7},
@@ -421,7 +398,7 @@
 //    {-30,-30,-30,-30,-26,-22,-20,-14, -6, -2,  0,  0,  0,  0,  2,  4,  10},
 //    {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  4,  8,  8,  8, 10, 12, 14, 20},
-    {-30,-30,-30,-30,-26,-22,-20,-14, -6, -2,  0,  0,  0,  0,  2,  3,  10},
+    {-30,-30,-30,-30,-26,-22,-20,-14, -6, -2,  0,  0,  0,  0,  2,  3,  6},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   /* 1 */
   {{{-12,-12,-12,-12,-12, -8, -6, -4,  0,  4,  4,  4,  4, 10, 12, 14, 20},
@@ -454,23 +431,23 @@
 //  {{{-22,-22,-22,-22,-22,-20,-14,-10, -6,  0,  0,  0,  0,  4,  4,  6, 11},
 //    {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10,-10},
 //    {-34,-34,-34,-34,-32,-32,-30,-24,-20,-19,-19,-19,-19,-19,-17,-16,-12}}},
-  {{{-24,-24,-24,-24,-24,-22,-14,-10, -6, -1, -1, -1, -1,  3,  3,  5,  8}, // q8
-    {-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14},
-    {-36,-36,-36,-36,-36,-34,-28,-24,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},
+  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  0},
+    {-34,-34,-34,-34,-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-24,-22},
+    {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-30,-24}}},
   /* 8 */
 //  {{{-24,-24,-24,-24,-24,-22,-14,-10, -6, -1, -1, -1, -1,  3,  3,  5, 10},
 //    {-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14},
 //    {-36,-36,-36,-36,-36,-34,-28,-24,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},
-  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  0}, // q9+
-    {-36,-36,-36,-36,-34,-32,-32,-30,-26,-26,-26,-26,-26,-26,-26,-24,-22},
+  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  0},
+    {-34,-34,-34,-34,-34,-32,-32,-30,-26,-26,-26,-26,-26,-26,-26,-26,-24},
     {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-30,-24}}},
   /* 9 */
 //  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  2},
 //    {-36,-36,-36,-36,-34,-32,-32,-30,-26,-26,-26,-26,-26,-22,-20,-20,-18},
 //    {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-24,-20}}},
-  {{{-30,-30,-30,-30,-30,-26,-24,-24,-24,-20,-16,-16,-16,-16,-16,-14,-12}, // q10
-    {-40,-40,-40,-40,-40,-40,-40,-40,-35,-30,-30,-30,-30,-30,-30,-30,-26},
-    {-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40}}},
+  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2,  2},
+    {-36,-36,-36,-36,-34,-32,-32,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26},
+    {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-24,-20}}},
   /* 10 */
   {{{-30,-30,-30,-30,-30,-26,-24,-24,-24,-20,-16,-16,-16,-16,-16,-14,-12},
     {-40,-40,-40,-40,-40,-40,-40,-40,-35,-30,-30,-30,-30,-30,-30,-30,-26},
@@ -489,8 +466,11 @@
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4,  0,  0,  0,  2,  2,  4,  8},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -6, -4, -2,  0}}},
   /* 2 */
+//  {{{-14,-14,-14,-14,-14,-10, -8, -6, -2,  2,  2,  2,  2,  8, 10, 10, 16},
+//    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4,  0,  0,  0,  2,  2,  4,  8},
+//    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -8, -6, -4, -2}}},
   {{{-14,-14,-14,-14,-14,-10, -8, -6, -2,  2,  2,  2,  2,  8, 10, 10, 16},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4,  0,  0,  0,  2,  2,  4,  8},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -1, -1, -1,  0,  0,  2,  6},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -8, -6, -4, -2}}},
   /* 3 */
   {{{-14,-14,-14,-14,-14,-10, -8, -6, -2,  2,  2,  2,  2,  6,  8,  8, 14},
@@ -551,7 +531,7 @@
 };
 
 static int _psy_noise_suppress[11]={
- -20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45,
+  -20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45,
 };
 // low-mode added
 static int _psy_noise_suppress_low[3]={
@@ -594,38 +574,51 @@
 /* stereo mode by base quality level */
 // q-2 added
 static adj_stereo _psy_stereo_modes_44_low[3]={
-//  /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         0  */
+    /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         0  */
 //  {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
 //   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
 //   {  1,  2,  3,  4,  4,  4,  4,  4,  4,  5,  6,  7,  8,  8,  8},
 //   { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
+    /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         0(-2) OLD  */
+//  {{  4,  4,  4,  4,  4,  4,  4,  4,  3,  2,  1,  0,  0,  0,  0},
+//   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
+//   {  1,  2,  2,  2,  2,  3,  3,  4,  4,  4,  5,  6,  7,  8,  8},
+//   { 10,10.5, 11,11.5, 12,12.5, 13, 99, 99, 99, 99, 99, 99, 99, 99}},
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         0(-2)  */
-  {{  4,  4,  4,  4,  4,  4,  4,  4,  3,  2,  1,  0,  0,  0,  0},
+  {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
    {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
-   {  1,  2,  2,  2,  2,  3,  3,  4,  4,  4,  5,  6,  7,  8,  8},
-   { 10,10.5, 11,11.5, 12,12.5, 13, 99, 99, 99, 99, 99, 99, 99, 99}},
-//  /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         1  */
+   {  1,  2,  3,  4,  4,  4,  4,  4,  4,  5,  6,  7,  8,  8,  8},
+   { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
+    /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         1  */
 //  {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
 //   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
 //   {  1,  2,  3,  4,  5,  5,  6,  6,  6,  6,  6,  7,  8,  8,  8},
 //   { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         1(-1)  */
   {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
-   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
+   {  8,  8,  8,  8,  6,  6,  5,  5,  5,  5,  5,  5,  5,  4,  3},
    {  1,  2,  3,  4,  4,  4,  4,  4,  4,  5,  6,  7,  8,  8,  8},
    { 11,11.5, 12,12.5, 13,13.5, 14, 99, 99, 99, 99, 99, 99, 99, 99}},
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         2(<-1) */
-  {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
-   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
-   {  1,  2,  3,  4,  5,  5,  6,  6,  6,  6,  6,  7,  8,  8,  8},
+//  {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
+//   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
+//   {  1,  2,  3,  4,  5,  5,  6,  6,  6,  6,  6,  7,  8,  8,  8},
+//   { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
+  {{  3,  3,  3,  3,  3,  3,  3,  3,  2,  1,  0,  0,  0,  0,  0},
+   {  8,  8,  8,  8,  6,  6,  5,  5,  5,  5,  5,  5,  5,  4,  3},
+   {  1,  2,  3,  4,  4,  5,  6,  6,  6,  6,  6,  8,  8,  8,  8},
    { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
 };
 
 static adj_stereo _psy_stereo_modes_44[11]={
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         0  */
-  {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
-   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
-   {  1,  2,  3,  4,  5,  5,  6,  6,  6,  6,  6,  7,  8,  8,  8},
+//  {{  4,  4,  4,  4,  4,  4,  4,  3,  2,  2,  1,  0,  0,  0,  0},
+//   {  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  5,  4,  3},
+//   {  1,  2,  3,  4,  5,  5,  6,  6,  6,  6,  6,  7,  8,  8,  8},
+//   { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
+  {{  3,  3,  3,  3,  3,  3,  3,  3,  2,  1,  0,  0,  0,  0,  0},
+   {  8,  8,  8,  8,  6,  6,  5,  5,  5,  5,  5,  5,  5,  4,  3},
+   {  1,  2,  3,  4,  4,  5,  6,  6,  6,  6,  6,  8,  8,  8,  8},
    { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         1  */
   {{  3,  3,  3,  3,  3,  3,  3,  3,  2,  1,  0,  0,  0,  0,  0},
@@ -633,9 +626,13 @@
    {  1,  2,  3,  4,  4,  5,  6,  6,  6,  6,  6,  8,  8,  8,  8},
    { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         2  */
-  {{  3,  3,  3,  3,  3,  3,  2,  2,  2,  1,  0,  0,  0,  0,  0},
-   {  8,  8,  8,  6,  5,  5,  5,  5,  5,  5,  5,  4,  3,  2,  1},
-   {  3,  4,  4,  4,  5,  6,  6,  6,  6,  6,  6,  8,  8,  8,  8},
+//  {{  3,  3,  3,  3,  3,  3,  2,  2,  2,  1,  0,  0,  0,  0,  0},
+//   {  8,  8,  8,  6,  5,  5,  5,  5,  5,  5,  5,  4,  3,  2,  1},
+//   {  3,  4,  4,  4,  5,  6,  6,  6,  6,  6,  6,  8,  8,  8,  8},
+//   { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
+  {{  3,  3,  3,  3,  3,  3,  3,  2,  1,  1,  0,  0,  0,  0,  0},
+   {  8,  8,  6,  6,  5,  5,  4,  4,  4,  4,  4,  4,  3,  2,  1},
+   {  3,  4,  4,  5,  5,  6,  6,  6,  6,  6,  6,  8,  8,  8,  8},
    { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14         3  */
   {{  2,  2,  2,  2,  2,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0},
@@ -706,8 +703,10 @@
 };
 static att3 _psy_tone_masteratt_44[11]={
   {{ 30,  20,   8}, -2, 1.25}, /* 0 */
-  {{ 25,  14,   4},  0,    0}, /* 1 */
-  {{ 20,  10,  -2},  0,    0}, /* 2 */
+//  {{ 25,  14,   4},  0,    0}, /* 1 */
+  {{ 23,  12,   2},  0,    0}, /* 1 */
+//  {{ 20,  10,  -2},  0,    0}, /* 2 */
+  {{ 20,   9,  -3},  0,    0}, /* 2 */
   {{ 20,   9,  -4},  0,    0}, /* 3 */
   {{ 20,   9,  -4},  0,    0}, /* 4 */
   {{ 20,   6,  -6},  0,    0}, /* 5 */
@@ -722,11 +721,11 @@
 // q-2 added
 static double _psy_lowpass_44_low[3]={
 //  15.1,15.1,
-  13.1, 14.2, 15.1
+  13.9, 15.1, 15.1
 };
 static double _psy_lowpass_44[11]={
 //  15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999.
-  15.1,15.8,16.5,17.1,18.5,20.1,48.,999.,999.,999.,999.
+  15.1,15.8,16.5,17.2,18.9,20.1,48.,999.,999.,999.,999.
 };
 
 /* noise normalization **********/
@@ -749,7 +748,7 @@
 
 static double _noise_thresh_44[10]={
 //  .2,.2,.3,.4,.5,.5,9999.,9999.,9999.,9999.,
-   .2,.2,.4,.5,9999.,9999.,9999.,9999.,9999.,9999.,
+   .2,.2,.4,.6,9999.,9999.,9999.,9999.,9999.,9999.,
 };
 // 2 >> 3
 static double _noise_thresh_44_2[3]={

Modified: branches/vorbis-aotuv/lib/modes/setup_32.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/setup_32.h	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/lib/modes/setup_32.h	2006-11-05 13:46:51 UTC (rev 12024)
@@ -37,7 +37,7 @@
 
 static double _psy_lowpass_32_low[3]={
 //  13.,13.,
-  12.,12.5,13.
+  12.3,13.,13.
 };
 static double _psy_lowpass_32[11]={
   13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99.

Modified: branches/vorbis-aotuv/lib/psy.c
===================================================================
--- branches/vorbis-aotuv/lib/psy.c	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/lib/psy.c	2006-11-05 13:46:51 UTC (rev 12024)
@@ -31,6 +31,7 @@
 
 #define NEGINF -9999.f
 static double stereo_threshholds[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5, 9e10};
+static double stereo_threshholds_limited[]={0.0, .5, 1.0, 1.5, 2.0, 2.5, 4.5, 8.5, 9e10};
 
 vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){
   codec_setup_info *ci=vi->codec_setup;
@@ -283,6 +284,12 @@
   p->n=n;
   p->rate=rate;
 
+  /* This is used by @ M1&M2 */
+  p->m_val = 1.;
+  if(rate < 26000) p->m_val = 0;
+  else if(rate < 38000) p->m_val = .94;   /* 32kHz */
+  else if(rate > 46000) p->m_val = 1.275; /* 48kHz */
+
   /* set up the lookups for a given blocksize and sample rate */
 
   for(i=0,j=0;i<MAX_ATH-1;i++){
@@ -845,14 +852,48 @@
 			float *noise,
 			float *tone,
 			int offset_select,
-			float *logmask){
+			float *logmask,
+			float *mdct,
+			float *logmdct){
+
   int i,n=p->n;
+  float de, coeffi, cx=1.0, cy=1.0;
   float toneatt=p->vi->tone_masteratt[offset_select];
   
+  cx = p->m_val;
+  if(offset_select != 1) cx = 0;
+  
   for(i=0;i<n;i++){
     float val= noise[i]+p->noiseoffset[offset_select][i];
     if(val>p->vi->noisemaxsupp)val=p->vi->noisemaxsupp;
     logmask[i]=max(val,tone[i]+toneatt);
+    
+	/** @ M1 **
+	   The following codes improve a noise problem.  
+	   A fundamental idea uses the value of masking and carries out
+	    the relative compensation of the MDCT. 
+	   However, this code is not perfect and all noise problems cannot be solved. 
+	   by Aoyumi @ 2004/04/18
+	*/
+    if(logmask[i] != (tone[i]+toneatt)){
+    	// partial masking value is used here.
+    	coeffi = -17.2*cy;
+    	val = val - logmdct[i];
+		if(val > coeffi){
+			de = 1.0-((val-coeffi)*0.005*cx);
+			if(de < 0) de = 0.0001;
+		}else de = 1.0-((val-coeffi)*0.0003*cx);
+		mdct[i] *= de;
+	}else{
+		// A masking value is used here.
+		coeffi = -57*cy;
+		val = logmask[i];
+		if(val > coeffi){
+			de = 1.0-((val-coeffi)*0.005*cx);
+			if(de < 0) de = 0.0001;
+		}else de = 1.0-((val-coeffi)*0.0003*cx);
+		mdct[i] *= de;
+	}
   }
 }
 
@@ -960,7 +1001,6 @@
     for(;j<n;j++)
       ret[i][j]=round_hypot(mdctM[j],mdctA[j]);
   }
-
   return(ret);
 }
 
@@ -1107,6 +1147,10 @@
       nonzero[vi->coupling_mag[i]]=1; 
       nonzero[vi->coupling_ang[i]]=1; 
 
+      /* The threshold of a stereo is changed with the size of n */
+      if(n > 1000)
+        postpoint=stereo_threshholds_limited[g->coupling_postpointamp[blobno]];
+
       for(j=0;j<p->n;j+=partition){
 	float acc=0.f;
 
@@ -1117,7 +1161,6 @@
 	    if((l>=limit && fabs(rM[l])<postpoint && fabs(rA[l])<postpoint) ||
 	       (fabs(rM[l])<prepoint && fabs(rA[l])<prepoint)){
 
-
 	      precomputed_couple_point(mag_memo[i][l],
 				       floorM[l],floorA[l],
 				       qM+l,qA+l);
@@ -1146,3 +1189,22 @@
   }
 }
 
+/** @ M2 **
+   The boost problem by the combination of noise normalization and point stereo is eased. 
+   However, this is a temporary patch. 
+   by Aoyumi @ 2004/04/18
+*/
+void hf_reduction(vorbis_info_psy_global *g,
+			vorbis_look_psy *p, 
+			vorbis_info_mapping0 *vi,
+			float **mdct){
+
+	int i,j,n=p->n, de=0.3*p->m_val;
+	int limit=g->coupling_pointlimit[p->vi->blockflag][PACKETBLOBS/2];
+	int start=p->vi->normal_start;
+	
+	for(i=0; i<vi->coupling_steps; i++){
+		for(j=start; j<limit; j++){}
+		for(; j<n; j++) mdct[i][j] *= (1.0 - de*((float)(j-limit) / (float)(n-limit)));
+	}
+}

Modified: branches/vorbis-aotuv/lib/psy.h
===================================================================
--- branches/vorbis-aotuv/lib/psy.h	2006-11-05 13:45:29 UTC (rev 12023)
+++ branches/vorbis-aotuv/lib/psy.h	2006-11-05 13:46:51 UTC (rev 12024)
@@ -109,6 +109,8 @@
   int   eighth_octave_lines; /* power of two, please */
   int   total_octave_lines;  
   long  rate; /* cache it */
+
+  float m_val; /* Masking compensation value */
 } vorbis_look_psy;
 
 extern void   _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
@@ -139,7 +141,9 @@
 			       float *noise,
 			       float *tone,
 			       int offset_select,
-			       float *logmask);
+			       float *logmask,
+			       float *mdct,
+			       float *logmdct);
 
 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
 
@@ -171,5 +175,10 @@
 				      vorbis_info_mapping0 *vi,
 				      float **mags);
 
+extern void hf_reduction(vorbis_info_psy_global *g,
+				vorbis_look_psy *p,
+				vorbis_info_mapping0 *vi,
+				float **mdct);
+
 #endif
 



More information about the commits mailing list