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

j at svn.xiph.org j at svn.xiph.org
Sun Nov 5 07:44:01 PST 2006


Author: j
Date: 2006-11-05 07:43:48 -0800 (Sun, 05 Nov 2006)
New Revision: 12033

Modified:
   branches/vorbis-aotuv/aoTuV_README-1st.txt
   branches/vorbis-aotuv/aoTuV_technical.txt
   branches/vorbis-aotuv/lib/info.c
   branches/vorbis-aotuv/lib/mapping0.c
   branches/vorbis-aotuv/lib/masking.h
   branches/vorbis-aotuv/lib/modes/psych_11.h
   branches/vorbis-aotuv/lib/modes/psych_16.h
   branches/vorbis-aotuv/lib/modes/psych_44.h
   branches/vorbis-aotuv/lib/modes/psych_8.h
   branches/vorbis-aotuv/lib/modes/setup_32.h
   branches/vorbis-aotuv/lib/modes/setup_44u.h
   branches/vorbis-aotuv/lib/psy.c
   branches/vorbis-aotuv/lib/psy.h
Log:
- aoTuV Beta5 (2006/10/24)
 # The action of noise normalization has been improved.  This has an effect in the sound roughness and tremor problem etc. in the low bitrate.
 # The threshold of a stereo mode change was calculated dynamically.  Some of problems which originate in channel coupling by this will improve. 
 # Noise control of an impulse block was changed (quality 0-10 / 32-48kHz). And pre-echo decreased slightly. 
 # Tuning of each part was redone according to above-mentioned changed part and additional part.
 


Modified: branches/vorbis-aotuv/aoTuV_README-1st.txt
===================================================================
--- branches/vorbis-aotuv/aoTuV_README-1st.txt	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/aoTuV_README-1st.txt	2006-11-05 15:43:48 UTC (rev 12033)
@@ -1,4 +1,4 @@
-aoTuV Release 1
+aoTuV Beta 5
 
 "aoTuV" tunes up Xiph.Org's libvorbis uniquely. 
 A license is taken as "BSD-style license" as well as original libvorbis. 
@@ -11,9 +11,7 @@
   processing method is used.
   Thanks! Manuke.
 
-  This version is the same contents as aoTuV beta4.51. 
 
-
 aoTuV based on <Xiph.Org libvorbis>
 
 Copyright (c) 2002-2005 Xiph.Org Foundation

Modified: branches/vorbis-aotuv/aoTuV_technical.txt
===================================================================
--- branches/vorbis-aotuv/aoTuV_technical.txt	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/aoTuV_technical.txt	2006-11-05 15:43:48 UTC (rev 12033)
@@ -1,3 +1,32 @@
+aoTuV beta5 technical information
+
+
+The differences from the aoTuV beta 4.51...
+
+  1.   In order to work noise normalization correctly, the value of tone 
+  masking is compressed under certain conditions. A floor curve approaches 
+  the original audio spectrum line as a result.  [New M4] 
+
+  2.   In order to cut down the bitrate, a part of M2 code of beta4 was 
+  deleted. 
+
+@3.   The ATH curve was changed slightly. 
+
+  4.   Pre-echo decreased slightly. This is based on change of M3 code. 
+
+  5.   In order to decrease artifact by collapse of audio energy, noise 
+  normalization processing of point stereo was extended. [32/44.1/48kHz only] 
+
+  6.   The threshold of channel coupling (lossless <=> point) is changed dynamically. This is a method based on a certain idea. [M6] 
+
+...and I tune up many parameters. 
+
+
+2006/10/24
+Aoyumi
+
+----------------------------------------------------------------------------
+
 aoTuV beta4.51 technical information
 
 
@@ -3,7 +32,10 @@
 The differences from the aoTuV beta 4.5...
 
-  1.  The changed part of "scale.h" of Xiph.Org SVN was reflected in aoTuV. This will solve the problem of the compile by gcc4. 
+  1.  The changed part of "scale.h" of Xiph.Org SVN was reflected in aoTuV. 
+  This will solve the problem of the compile by gcc4. 
 
-  2.  A part of portion added by beta4.5 had caused memory access violation. Depending on environment, a problem arises in qualiy-1/-2. This problem was corrected. 
+  2.  A part of portion added by beta4.5 had caused memory access violation. 
+  Depending on environment, a problem arises in qualiy-1/-2. This problem was 
+  corrected. 
 
 
@@ -18,11 +50,17 @@
 
 The differences from the aoTuV beta 4...
 
-  1.  M4 code of beta3 was deleted. M5 is added as what is replaced with it. The advantage of this method is that the result stabilized more is obtained. Instead, the change width of the bit rate becomes large rather than before. [32/44.1/48kHz only] 
+  1.  M4 code of beta3 was deleted. M5 is added as what is replaced with it. 
+  The advantage of this method is that the result stabilized more is obtained. 
+  Instead, the change width of the bit rate becomes large rather than before. 
+  [32/44.1/48kHz only] 
 
-  2.  New M4 was added. There is this for the same purpose as M1. However, it is tuned up only in the low bit rate region according to work and individual parameters. [32/44.1/48kHz only] 
+  2.  New M4 was added. There is this for the same purpose as M1. However, 
+  it is tuned up only in the low bit rate region according to work and 
+  individual parameters. [32/44.1/48kHz only] 
 
-  3.  M2 code was extended. This decreases a specific noise problem.  [32/44.1/48kHz only] 
+  3.  M2 code was extended. This decreases a specific noise problem.  
+  [32/44.1/48kHz only] 
 
 ...and I mainly tune up tone/noise masking and noise normalization parameters. 
 

Modified: branches/vorbis-aotuv/lib/info.c
===================================================================
--- branches/vorbis-aotuv/lib/info.c	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/info.c	2006-11-05 15:43:48 UTC (rev 12033)
@@ -416,7 +416,7 @@
 }
 
 static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
-  char temp[]="AO; aoTuV r1 [20051117] (based on Xiph.Org's libVorbis)";
+  char temp[]="AO; aoTuV b5 [20061024] (based on Xiph.Org's libVorbis)";
   int bytes = strlen(temp);
 
   /* preamble */  

Modified: branches/vorbis-aotuv/lib/mapping0.c
===================================================================
--- branches/vorbis-aotuv/lib/mapping0.c	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/mapping0.c	2006-11-05 15:43:48 UTC (rev 12033)
@@ -246,6 +246,7 @@
   codec_setup_info      *ci=vi->codec_setup;
   private_state         *b=vb->vd->backend_state;
   vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal;
+  vorbis_info_floor1    *vif=ci->floor_param[vb->W];
   int                    n=vb->pcmend;
   int i,j,k;
 
@@ -487,6 +488,8 @@
 			   mdct,
 			   logmdct,
 			   lastmdct, tempmdct,
+			   *lowcomp,
+			   vif->n,
 			   blocktype, modenumber,
 			   vb->nW,
 			   b->lW_blocktype, b->lW_modenumber, b->lW_no);
@@ -534,6 +537,8 @@
 			   mdct,
 			   logmdct,
 			   lastmdct, tempmdct,
+			   *lowcomp,
+			   vif->n,
 			   blocktype, modenumber,
 			   vb->nW,
 			   b->lW_blocktype, b->lW_modenumber, b->lW_no);
@@ -561,6 +566,8 @@
 			   mdct,
 			   logmdct,
 			   lastmdct, tempmdct,
+			   *lowcomp,
+			   vif->n,
 			   blocktype, modenumber,
 			   vb->nW,
 			   b->lW_blocktype, b->lW_modenumber, b->lW_no);
@@ -727,8 +734,6 @@
 		   ilogmaskch,
 		   nonzero,
 		   ci->psy_g_param.sliding_lowpass[vb->W][k],
-		   blocktype, modenumber,
-		   b->lW_blocktype, b->lW_modenumber,
 		   gmdct, res_org);
       }
       

Modified: branches/vorbis-aotuv/lib/masking.h
===================================================================
--- branches/vorbis-aotuv/lib/masking.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/masking.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -35,7 +35,7 @@
   /*4k*/ //-107,-105,-103,-102,-101, -99, -98, -96,
   /*8k*/  //-95, -95, -96, -97, -96, -95, -93, -90,
   /*16k*/ //-80, -70, -50, -40, -30, -30, -30, -30
-/*Aoyumi's ATH (v5) */
+/*Aoyumi's ATH (v6) */
   /*15*/  -31, -33, -35, -37, -39, -41, -43, -45,
   /*31*/  -47, -49, -51, -53, -55, -57, -59, -61,
   /*63*/  -63, -65, -67, -69, -71, -73, -75, -77, 
@@ -44,8 +44,8 @@
   /*500*/ -96, -97, -97, -97, -98, -98, -98, -99, 
   /*1k*/  -98, -97, -97, -98, -99,-100,-101,-101,
   /*2k*/ -102,-103,-104,-105,-106,-106,-107,-107,
-  /*4k*/ -105,-104,-102,-101,-100, -99, -98, -97,
-  /*8k*/  -96, -95, -95, -96, -97, -97, -93, -88,
+  /*4k*/ -105,-104,-103,-102,-101, -99, -98, -97,
+  /*8k*/  -96, -95, -95, -96, -97, -97, -93, -89,
   /*16k*/ -80, -70, -50, -40, -30, -30, -30, -30
 };
 

Modified: branches/vorbis-aotuv/lib/modes/psych_11.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/psych_11.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/modes/psych_11.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -15,19 +15,19 @@
 
  ********************************************************************/
 
-static double _psy_lowpass_11[4]={4,4.5,5.5,30.,};
+static double _psy_lowpass_11[4]={4.1,4.5,5.5,30.,};
 
 static att3 _psy_tone_masteratt_11[4]={
-  {{ 30,  25,  12},  0,   0},  /* -2 */
-  {{ 30,  25,  12},  0,   0},  /* -1 */
-  {{ 30,  25,  12},  0,   0},  /*  0 */
+  {{ 31,  28,  13},  0,   0},  /* -2 */
+  {{ 30,  28,  12},  0,   0},  /* -1 */
+  {{ 30,  26,  12},  0,   0},  /*  0 */
   {{ 20,   0, -14},  0,   0},  /* 10 */
 };
 
 static vp_adjblock _vp_tonemask_adj_11[4]={
   /* adjust for mode zero */
   /* 63     125     250     500     1     2     4     8    16 */
-  {{-16,-16,-16,-16,-16,-16,-10,-8,-4, 0, 0, 0, 5, 5,99,99,99}}, /* -2 */
+  {{-16,-16,-16,-16,-16,-16,-10,-8,-4, 0, 0, 0, 3, 3,99,99,99}}, /* -2 */
   {{-16,-16,-16,-16,-16,-16,-10,-8,-4, 0, 0, 0, 0, 0,99,99,99}}, /* -1 */
   {{-20,-20,-20,-20,-20,-16,-10,-8,-4,-2, 0, 0, 0, 0,99,99,99}}, /*  0 */
   {{-20,-20,-20,-20,-20,-16,-10,-8,-4,-2, 0, 0, 0, 0,99,99,99}}, /* 10 */
@@ -36,8 +36,8 @@
 
 static noise3 _psy_noisebias_11[4]={
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
-  {{{-10,-10,-10,-10, -5, -5, -5,  0,  4, 10, 10, 12, 12, 12, 99, 99, 99},
-    {-12,-12,-12,-12,-10,-10, -3,  0,  2,  4,  4,  5,  5, 10, 99, 99, 99},
+  {{{-10,-10,-10,-10, -5, -5, -4,  2,  4, 10, 10, 12, 12, 12, 99, 99, 99},
+    {-12,-12,-12,-12, -7, -7, -2,  3,  3,  4,  4,  5,  6, 12, 99, 99, 99},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}},
 
   {{{-10,-10,-10,-10, -5, -5, -5,  0,  4, 10, 10, 12, 12, 12, 99, 99, 99},

Modified: branches/vorbis-aotuv/lib/modes/psych_16.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/psych_16.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/modes/psych_16.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -19,7 +19,7 @@
 static adj_stereo _psy_stereo_modes_16[5]={
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  */
   {{  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3},
-   {  6,  5,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4},
+   {  6,  5,  5,  5,  5,  5,  5,  5,  4,  4,  4,  4,  4,  4,  4},
    {  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  3,  4,  4},
    { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
   {{  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3},
@@ -43,9 +43,9 @@
 static double _psy_lowpass_16[5]={6.,6.5,8,30.,99.};
 
 static att3 _psy_tone_masteratt_16[5]={
-  {{ 30,  25,  12},  0,   0},  /* -2 */
-  {{ 30,  25,  12},  0,   0},  /* -1 */
-  {{ 25,  22,  12},  0,   0},  /* 0.5 */
+  {{ 30,  28,  12},  0,   0},  /* -2 */
+  {{ 30,  28,  12},  0,   0},  /* -1 */
+  {{ 25,  23,  12},  0,   0},  /* 0.5 */
   {{ 20,  12,   0},  0,   0},  /*  5 */
   {{ 15,   0, -14},  0,   0},  /* 10 */
 };
@@ -63,15 +63,15 @@
 
 static noise3 _psy_noisebias_16_short[5]={
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
-  {{{-15,-15,-15,-15,-15,-10,-10,-5,   4, 10, 10, 10, 10, 12, 12, 14, 20},
-    {-12,-12,-12,-12,-12, -7, -4, -2,  3,  3,  4,  5,  5,  6,  8,  8, 15},
+  {{{-15,-15,-15,-15,-15,-10,-10, -5,  4, 10, 10, 10, 10, 12, 12, 14, 20},
+    {-12,-12,-12,-12,-12, -7, -7, -2,  3,  3,  4,  5,  6,  7,  8,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}},
 
-  {{{-15,-15,-15,-15,-15,-10,-10,-5,   4, 10, 10, 10, 10, 12, 12, 14, 20},
+  {{{-15,-15,-15,-15,-15,-10,-10, -5,  4, 10, 10, 10, 10, 12, 12, 14, 20},
     {-15,-15,-15,-15,-15,-10,-10, -5,  0,  0,  4,  5,  5,  6,  8,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}},
 
-  {{{-15,-15,-15,-15,-15,-10,-10,-5,   4,  6,  6,  6,  6,  8, 10, 12, 20},
+  {{{-15,-15,-15,-15,-15,-10,-10, -5,  4,  6,  6,  6,  6,  8, 10, 12, 20},
     {-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5,  4,  5,  6,  8,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}},
 
@@ -86,15 +86,15 @@
 
 static noise3 _psy_noisebias_16_impulse[5]={
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
-  {{{-15,-15,-15,-15,-15,-10,-10,-5,   4, 10, 10, 10, 10, 12, 12, 14, 20},
-    {-12,-12,-12,-12,-12, -7, -4, -2,  3,  3,  4,  5,  5,  6,  8,  8, 15},
+  {{{-15,-15,-15,-15,-15,-10,-10, -5,  4, 10, 10, 10, 10, 12, 12, 14, 20},
+    {-12,-12,-12,-12,-12, -7, -7, -2,  3,  3,  4,  5,  6,  7,  8,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}},
 
-  {{{-15,-15,-15,-15,-15,-10,-10,-5,   4, 10, 10, 10, 10, 12, 12, 14, 20},
+  {{{-15,-15,-15,-15,-15,-10,-10, -5,  4, 10, 10, 10, 10, 12, 12, 14, 20},
     {-15,-15,-15,-15,-15,-10,-10, -5,  0,  0,  4,  5,  5,  6,  8,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}},
 
-  {{{-15,-15,-15,-15,-15,-10,-10,-5,   4,  4,  4,  4,  5,  5,  6,  8, 15},
+  {{{-15,-15,-15,-15,-15,-10,-10, -5,  4,  4,  4,  4,  5,  5,  6,  8, 15},
     {-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5,  0,  0,  0,  0,  4, 10},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}},
 
@@ -110,7 +110,7 @@
 static noise3 _psy_noisebias_16[5]={
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
   {{{-10,-10,-10,-10, -5, -5, -5,  0,  4,  6,  8,  8, 10, 10, 10, 14, 20},
-    {-10,-10,-10,-10,-10, -5, -2, -2,  3,  3,  3,  4,  5,  6,  8,  8, 15},
+    {-10,-10,-10,-10,-10, -5, -2, -2,  2,  2,  2,  4,  5,  6,  8,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}},
 
   {{{-10,-10,-10,-10, -5, -5, -5,  0,  4,  6,  8,  8, 10, 10, 10, 14, 20},

Modified: branches/vorbis-aotuv/lib/modes/psych_44.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/psych_44.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/modes/psych_44.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -30,13 +30,14 @@
 */
 /* q-2 */
   {8,   /* lines per eighth octave */
-   {24.f,14.f,14.f,14.f,14.f,14.f,14.f}, 
+   {24.f,16.f,16.f,16.f,16.f,16.f,14.f}, 
    {-60.f,-30.f,-40.f,-40.f,-40.f,-40.f,-40.f}, 2,-75.f,
    -6.f,
    {99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
   },
   {8,   /* lines per eighth octave */
-   {20.f,14.f,12.f,12.f,12.f,12.f,12.f}, 
+//   {20.f,14.f,12.f,12.f,12.f,12.f,12.f}, 
+   {20.f,14.f,14.f,14.f,14.f,14.f,14.f}, 
    {-60.f,-30.f,-40.f,-40.f,-40.f,-40.f,-40.f}, 2,-75.f,
    -6.f,
    {99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
@@ -55,13 +56,14 @@
   },
   {8,   /* lines per eighth octave */
 //   {10.f,8.f,8.f,8.f,8.f,8.f,8.f}, 
-   {10.f,8.f,8.f,6.f,6.f,6.f,7.f},
+   {8.f,8.f,8.f,6.f,6.f,6.f,7.f},
    {-20.f,-15.f,-12.f,-12.f,-12.f,-12.f,-12.f}, 0,-80.f,
    -6.f,
    {99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
   },
   {8,   /* lines per eighth octave */
-   {10.f,6.f,6.f,6.f,6.f,6.f,6.f}, 
+//   {10.f,6.f,6.f,6.f,6.f,6.f,6.f}, 
+   {6.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,
    {-15.f,-14.f,-10.f,-10.f,-10.f,-11.f,-12.f}, 0,-85.f,
    -6.f,
@@ -78,11 +80,11 @@
 //    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 */
-     0, 1, 2, 3, 4, 5, 6,  6,     /* 7dB */
-     6, 6, 7, 7, 7, 7, 8,  8,     /* 15dB */
-     9,10,11,12,13,14,15, 16,     /* 23dB */
-    17,17,18,19,20,21,22, 23,     /* 31dB */
-    23,24,25,26,27,28,29, 30,     /* 39dB */
+    0, 1, 2, 3, 4, 5, 6,  6,     /* 7dB */
+    7, 7, 7, 8, 9,10, 11, 11,     /* 15dB */
+    12,12,13,13,14,14,15, 15,     /* 23dB */
+    16,16,17,17,17,18,18, 19,     /* 31dB */
+    19,19,20,21,22,23,24, 25,     /* 39dB */
   }},
   /* mode_Z nominal short */
   {{
@@ -92,7 +94,7 @@
 //    15,16,17,17,17,18,18, 19,     /* 31dB */
 //    19,19,20,21,22,23,24, 25,     /* 39dB */
      0, 1, 2, 3, 4, 5, 6,  6,     /* 7dB */
-     6, 6, 7, 7, 7, 7, 7,  7,     /* 15dB */
+     7, 7, 7, 7, 7, 7, 7,  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 */
@@ -112,16 +114,11 @@
   }},
   /* 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 */
      0, 1, 2, 3, 4, 5, 6,  7,     /* 7dB */
-     8, 9,10,11,12,12,13, 13,     /* 15dB */
-    13,14,14,15,15,16,16, 16,     /* 23dB */
-    17,17,18,19,20,21,22, 23,     /* 31dB */
-    23,24,25,26,27,28,29, 30,     /* 39dB */
+     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 */
   {{
@@ -150,87 +147,86 @@
 
 static vp_adjblock _vp_tonemask_adj_longblock[13]={
    /* 63     125     250     500       1       2       4       8      16 */
-
 // {{ -3, -9,-12,-12,-10,-10,-10,-10,-10,-10,-10, -1,  0,  0,  1,  1,  1}}, /* -2(addition) */
-   {{-14,-14,-14,-14,-14,-14,-14,-14,-13,-11,-11,-11,-10, -4, -2, -2,  1}},
+   {{-16,-16,-16,-15,-15,-15,-14,-14,-13,-13,-12,-12,-11, -5,  0,  0,  5}},
 
 // {{ -3, -9,-12,-12,-11,-11,-11,-11,-11,-11,-10, -1, -1,  0,  0,  0,  0}}, /* -1 */
-   {{-15,-15,-15,-15,-15,-15,-15,-15,-14,-13,-13,-13,-13, -6, -4, -5,  0}}, 
+   {{-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-13,-13,-12, -7, -2, -2,  3}},
    
 /* {{-15,-15,-15,-15,-10, -8, -4, -2,  0,  0,  0, 10,  0,  0,  0,  0,  0}},    0 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 0 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-13, -8, -3, -3,  1}}, /* 0 */
 
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  5,  0,  0,  0,  0,  0}},    1 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 1 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-13,-10, -4, -4,  0}}, /* 1 */
 
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    2 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 2 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -5, -5,  0}}, /* 2 */
    
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    3 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 3 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -8, -7,  0}}, /* 3 */
    
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    4 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 4 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}},  /* 4 */
    
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    5 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}},/* 5 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 5 */
    
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    6 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 6 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 6 */
    
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    7 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 7 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 7 */
 
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    8 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 8 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 8 */
 
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    9 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 9 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11,-10,-10,  0}}, /* 9 */
 
 /* {{-15,-15,-15,-15,-15,-12,-10, -8,  0,  0,  0,  0,  0,  0,  0,  0,  0}},    10 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 10 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11,-10,-10,  0}}, /* 10 */
 };
 static vp_adjblock _vp_tonemask_adj_otherblock[13]={
    /* 63     125     250     500       1       2       4       8      16 */
 
 // {{ -3, -9,-12,-12,-10,-10,-10,-10,-10,-10,-10, -1,  0,  0,  1,  1,  1}}, /* -2(addition) */
-   {{-14,-14,-14,-14,-14,-14,-14,-14,-13,-11,-11,-11, -7, -3, -2, -2,  1}},
+   {{-16,-16,-16,-15,-15,-15,-14,-14,-13,-13,-12,-12,-11, -5,  0,  0,  5}},
 
 // {{ -3, -9,-12,-12,-11,-11,-11,-11,-11,-11,-10, -1, -1,  0,  0,  0,  0}}, /* -1 */
-   {{-15,-15,-15,-15,-15,-15,-15,-15,-14,-13,-13,-13,-12, -5, -3, -4,  0}},
+   {{-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-13,-13,-12, -7, -2, -2,  3}},
    
 /* {{-20,-20,-20,-20,-14,-12,-10, -8, -4,  0,  0, 10,  0,  0,  0,  0,  0}},    0 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 0 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14, -8, -3, -3,  0}}, /* 0 */
 
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  5,  0,  0,  0,  0,  0}},    1 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 1 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-10, -4, -4,  0}}, /* 1 */
 
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    2 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 2 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -6, -5,  0}}, /* 2 */
 
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    3 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -7, -5, -6,  0}}, /* 3 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -7,  0}}, /* 3 */
 
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    4 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 4 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 4 */
    
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    5 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 5 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 5 */
    
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    6 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 6 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 6 */
    
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    7 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 7 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 7 */
 
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    8 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 8 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11, -9, -9,  0}}, /* 8 */
 
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    9 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 9 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11,-10,-10,  0}}, /* 9 */
 
 /* {{-20,-20,-20,-20,-20,-18,-16,-14,-10,  0,  0,  0,  0,  0,  0,  0,  0}},    10 */
-   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-14, -9, -7, -8,  0}}, /* 10 */
+   {{-16,-16,-16,-16,-16,-16,-16,-16,-15,-15,-14,-14,-14,-11,-10,-10,  0}}, /* 10 */
 };
 
 /* noise bias (transition block) */
@@ -238,21 +234,21 @@
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
   /* -2(addition mode) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-26,-26,-26,-24,-22,-16,-12, -6, -2,  2,  2,  2,  6,  7,  8,  8, 13},
+    {-28,-28,-26,-26,-22,-18,-16, -8, -2,  2,  2,  2,  2,  5,  6,  7, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   /* -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,  6,  6, 15},
     {-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,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-30,-30,-30,-30,-26,-22,-18,-10, -4,  0,  0,  0,  1,  2,  5,  5, 13},
+    {-30,-30,-28,-28,-24,-20,-18,-10, -4,  0,  0,  0,  0,  2,  3,  4, 14},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   /* 0 */
 /*{{{-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,  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, -6, -4,  0,  2,  4,  4,  5,  5,  5,  8, 10},
-    {-30,-30,-30,-30,-26,-22,-20,-12, -6,  0,  0,  0,  0,  1,  2,  3,  6},
+    {-30,-30,-30,-30,-26,-22,-20,-14, -6,  0,  0,  0,  0,  1,  2,  3,  8},
     {-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},
@@ -266,7 +262,7 @@
     {-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, 10},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1,  1,  3},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -2, -2, -1,  1,  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},
@@ -315,7 +311,7 @@
     {-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,-34,-32,-32,-28,-20,-16,-16,-16,-16,-14,-12,-10, -7},
+    {-36,-36,-36,-36,-32,-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}}},
   /* 10 */
   {{{-30,-30,-30,-30,-30,-30,-30,-28,-20,-14,-14,-14,-14,-14,-14,-12,-10},
@@ -328,21 +324,21 @@
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
   /* -2(addition mode) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  2,  6,  6,  6,  6, 10, 10, 12, 20},
-    {-20,-20,-20,-20,-20,-20,-10, -2,  2,  2,  2,  2,  3,  5,  8,  8, 13},
+    {-20,-20,-20,-20,-20,-18,-12, -6,  0,  2,  2,  2,  2,  5,  6,  7, 15},
     {-20,-20,-20,-20,-20,-20,-20,-10, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},
   /* -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, 15},
     {-20,-20,-20,-20,-20,-20,-20,-10, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},*/
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  0,  6,  6,  6,  6, 10, 10, 12, 20},
-    {-20,-20,-20,-20,-20,-20,-12, -4,  0,  0,  0,  0,  0,  1,  4,  4, 13},
+    {-20,-20,-20,-20,-20,-18,-12, -8, -2,  0,  0,  0,  0,  2,  3,  4, 14},
     {-20,-20,-20,-20,-20,-20,-20,-10, -6, -6, -6, -6, -6, -4, -4, -4, -2}}},
   /* 0 */
 /*{{{-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,  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,-12, -6,  0,  0,  0,  0,  1,  2,  3,  6},
+    {-20,-20,-20,-20,-20,-20,-20,-14, -6,  0,  0,  0,  0,  1,  2,  3,  7},
     {-20,-20,-20,-20,-20,-20,-20,-14, -8, -6, -6, -6, -6, -4, -4, -4, -2}}},
   /* 1 */
 /*{{{-10,-10,-10,-10,-10,-10, -8, -4,  0,  2,  4,  4,  5,  5,  5,  8, 10},
@@ -356,7 +352,7 @@
     {-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, -3, -3, -3, -3, -1,  1,  3},
+    {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -2, -2, -1,  1,  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},
@@ -387,8 +383,11 @@
     {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -6, -6, -6, -6, -4, -2,  0},
     {-26,-26,-26,-26,-26,-26,-26,-18,-16,-15,-15,-15,-15,-13,-13,-12, -8}}},
   /* 7 */
+//  {{{-15,-15,-15,-15,-15,-15,-15,-10, -4,  1,  1,  1,  2,  3,  3,  4,  7},
+//    {-24,-24,-24,-24,-24,-24,-24,-18,-14,-10, -8, -8, -8, -8, -6, -4,  0},
+//    {-26,-26,-26,-26,-26,-26,-26,-22,-20,-19,-19,-19,-19,-18,-17,-16,-12}}},
   {{{-15,-15,-15,-15,-15,-15,-15,-10, -4,  1,  1,  1,  2,  3,  3,  4,  7},
-    {-24,-24,-24,-24,-24,-24,-24,-18,-14,-10, -8, -8, -8, -8, -6, -4,  0},
+    {-24,-24,-24,-24,-24,-24,-24,-18,-14,-12,-10, -8, -8, -8, -6, -4,  0},
     {-26,-26,-26,-26,-26,-26,-26,-22,-20,-19,-19,-19,-19,-18,-17,-16,-12}}},
   /* 8 */
   {{{-15,-15,-15,-15,-15,-15,-15,-10, -4,  0,  0,  0,  0,  1,  2,  3,  7},
@@ -409,47 +408,56 @@
   /*  63     125     250     500      1k      2k      4k      8k     16k*/
   /* -2(addition mode) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-26,-26,-26,-24,-22,-16,-12, -6, -2,  2,  2,  2,  6,  7,  8,  8, 13},
+    {-28,-28,-26,-26,-22,-18,-16, -8, -2,  2,  2,  2,  3,  6,  7,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   /* -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,  6,  6, 15},
     {-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,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-30,-30,-30,-30,-26,-22,-18,-10, -4,  0,  0,  0,  1,  2,  5,  5, 13},
+    {-30,-30,-28,-28,-24,-20,-18,-10, -4,  0,  0,  0,  1,  4,  5,  6, 14},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   /* 0 */
 /*{{{-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,  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,-12, -6,  0,  0,  0,  0,  1,  2,  3,  6},
+    {-30,-30,-30,-30,-26,-22,-20,-14, -6,  0,  0,  0,  0,  1,  2,  3,  7},
     {-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},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -4, -4, -2, -2, -2, -2,  2},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8,-10,-10, -8, -8, -8, -6, -4}}},*/
   {{{-12,-12,-12,-12,-12, -8, -6, -4,  0,  4,  4,  4,  4, 10, 12, 14, 20},
-    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, -2,  0,  2},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -2, -2, -2, -1,  3},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8,-10,-10, -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, -6, -6, -6, -4, -4, -4, -2,  0},
+//    {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10,-10,-10, -8, -4}}},
   {{{-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, -6, -6, -6, -4, -4, -4, -2,  0},
+    {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -3, -2,  1},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10,-10,-10, -8, -4}}},
   /* 3 */
+//  {{{-14,-14,-14,-14,-14,-10, -8, -6, -2,  2,  2,  2,  2,  6,  8,  8, 14},
+//    {-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,-10,-10,-10,-10,-10,-10, -8, -4}}},
   {{{-14,-14,-14,-14,-14,-10, -8, -6, -2,  2,  2,  2,  2,  6,  8,  8, 14},
-    {-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, -3, -2,  1},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10,-10,-10, -8, -4}}},
   /* 4 */
+//  {{{-16,-16,-16,-16,-16,-12,-10, -6, -2,  0,  0,  0,  0,  4,  6,  6, 12},
+//    {-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,-10,-10,-10,-10,-10,-10, -8, -4}}},
   {{{-16,-16,-16,-16,-16,-12,-10, -6, -2,  0,  0,  0,  0,  4,  6,  6, 12},
-    {-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, -3, -2,  1},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10,-10,-10, -8, -4}}},
   /* 5 */
 /*{{{-20,-20,-20,-20,-20,-18,-14,-10, -4,  0,  0,  0,  0,  4,  4,  6, 11},
     {-32,-32,-32,-32,-28,-24,-22,-16,-10, -6, -8, -8, -6, -6, -6, -4, -2},
     {-34,-34,-34,-34,-30,-26,-24,-18,-14,-12,-12,-12,-12,-12,-10, -9, -5}}},*/
   {{{-20,-20,-20,-20,-20,-18,-14,-10, -4,  0,  0,  0,  0,  4,  4,  6, 11},
-    {-32,-32,-32,-32,-28,-24,-22,-16,-12, -8, -8, -8, -6, -6, -6, -4, -2},
+    {-32,-32,-32,-32,-28,-24,-22,-16,-12, -8, -8, -8, -6, -6, -5, -4, -2},
     {-34,-34,-34,-34,-30,-26,-24,-18,-14,-12,-12,-12,-12,-12,-10, -9, -5}}},
   /* 6 */
 /*{{{-20,-20,-20,-20,-20,-18,-14,-10, -4,  0,  0,  0,  0,  4,  4,  6, 11},
@@ -463,15 +471,18 @@
     {-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}}},*/
   {{{-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,-16,-16,-16,-16,-14,-12,-10,-10,-10},
+    {-34,-34,-34,-34,-30,-30,-24,-20,-16,-16,-16,-16,-14,-12,-10,-10, -8},
     {-34,-34,-34,-34,-32,-32,-30,-24,-20,-19,-19,-19,-19,-19,-17,-16,-12}}},
   /* 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}}},
   /* 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}}},
   {{{-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},
+    {-36,-36,-36,-36,-32,-32,-32,-28,-24,-24,-24,-24,-24,-22,-20,-20,-18},
     {-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},
@@ -484,29 +495,32 @@
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
   /* -2(addition mode) */
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-26,-26,-26,-24,-22,-16,-12, -6, -2,  2,  2,  2,  6,  7,  8,  8, 15},
+    {-28,-28,-26,-26,-22,-18,-16, -8, -2,  2,  2,  2,  3,  6,  7,  8, 15},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
   /* -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,  6,  6, 15},
     {-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,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-30,-30,-30,-30,-26,-22,-18,-10, -4,  0,  0,  1,  2,  3,  6,  6, 15},
+    {-30,-30,-28,-28,-24,-20,-18,-10, -4,  0,  0,  0,  1,  4,  5,  6, 14},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -4, -4, -4, -4, -4, -2,  0,  2}}},
   /* 0 */
 /*{{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  8,  8,  8,  8, 10, 12, 14, 20},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2,  2,  3,  6,  6,  8, 10},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -4, -4, -2,  0,  2}}},*/
   {{{-10,-10,-10,-10,-10, -4,  0,  0,  4,  8,  8,  8,  8, 10, 12, 14, 20},
-    {-30,-30,-30,-30,-26,-22,-20,-12, -6,  0,  0,  0,  2,  4,  4,  6, 10},
+    {-30,-30,-30,-30,-26,-22,-20,-14, -6,  0,  0,  0,  0,  3,  3,  5,  8},
     {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -4, -4, -2,  0,  2}}},
   /* 1 */
   {{{-12,-12,-12,-12,-12, -8, -6, -4,  0,  4,  4,  4,  4, 10, 12, 14, 20},
     {-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, -4,  0,  0,  0,  0,  2,  4,  8},
     {-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},
@@ -536,8 +550,11 @@
     {-34,-34,-34,-34,-30,-30,-30,-24,-16,-12,-10, -8, -8, -8, -7, -5, -2},
     {-36,-36,-36,-36,-36,-34,-28,-22,-20,-20,-20,-20,-20,-20,-20,-16,-14}}},
   /* 9 */
+//  {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -2, -2, -2, -2,  0,  2,  6},
+//    {-36,-36,-36,-36,-34,-32,-32,-24,-16,-12,-12,-12,-12,-12,-10, -8, -5},
+//    {-40,-40,-40,-40,-40,-40,-40,-32,-26,-24,-24,-24,-24,-24,-24,-20,-18}}},
   {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -2, -2, -2, -2,  0,  2,  6},
-    {-36,-36,-36,-36,-34,-32,-32,-24,-16,-12,-12,-12,-12,-12,-10, -8, -5},
+    {-36,-36,-36,-36,-32,-32,-32,-26,-18,-14,-12,-12,-12,-12,-10, -8, -5},
     {-40,-40,-40,-40,-40,-40,-40,-32,-26,-24,-24,-24,-24,-24,-24,-20,-18}}},
   /* 10 */
   {{{-30,-30,-30,-30,-30,-26,-24,-24,-24,-20,-12,-12,-12,-12,-12,-10, -8},
@@ -559,7 +576,7 @@
 };
 static int _psy_tone_0dB[13]={
 /*  90,90,95,95,95,95,105,105,105,105,105,105, */
-   90,90,90,94,95,95,95,105,105,105,105,105,105,
+   90,90,90,95,95,95,95,105,105,105,105,105,105,
 };
 static int _psy_noise_suppress[13]={
 /*  -20,-20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45, */
@@ -605,7 +622,7 @@
 static adj_stereo _psy_stereo_modes_44[13]={
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14        -2(addition mode)  */
   {{  4,  4,  4,  4,  4,  4,  4,  4,  3,  2,  1,  0,  0,  0,  0},
-   {  8,  8,  8,  8,  8,  8,  7,  6,  6,  6,  6,  6,  5,  4,  3},
+   {  8,  8,  8,  8,  8,  8,  7,  7,  6,  6,  6,  6,  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  */
@@ -660,7 +677,7 @@
    {  6,  6,  8,  8,  8,  8, 10, 10, 10, 10, 10, 10, 10, 10, 10},
    { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/
   {{  2,  2,  2,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-   {  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0},
+   {  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  0,  0,  0,  0},
    {  6,  7,  8,  8,  8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12},
    { 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        6  */
@@ -704,16 +721,15 @@
 
 /* tone master attenuation by base quality mode and bitrate tweak */
 static att3 _psy_tone_masteratt_44[13]={
-  {{ 38,  24,  12},  0,    0}, /* -2 */
+  {{ 40,  32,  16},  0,    0}, /* -2 */
 //  {{ 35,  21,   9},  0,    0}, /* -1 */
-  {{ 36,  22,  10},  0,    0}, /* -1 */
+  {{ 36,  25,  10},  0,    0}, /* -1 */
 //  {{ 30,  20,   8}, -2, 1.25}, /* 0 */
-  {{ 30,  21,   8},  0,    0}, /* 0 */
-//  {{ 25,  14,   4},  0,    0}, /* 1 */
-  {{ 25,  15,   4},  0,    0}, /* 1 */
+  {{ 32,  20,   8},  0,    0}, /* 0 */
+  {{ 25,  14,   4},  0,    0}, /* 1 */
   {{ 20,  10,  -2},  0,    0}, /* 2 */
 //  {{ 20,   9,  -4},  0,    0}, /* 3 */
-  {{ 21,  10,  -3},  0,    0}, /* 3 */
+  {{ 20,  10,  -3},  0,    0}, /* 3 */
   {{ 20,   9,  -4},  0,    0}, /* 4 */
   {{ 20,   6,  -6},  0,    0}, /* 5 */
   {{ 20,   3, -10},  0,    0}, /* 6 */
@@ -727,7 +743,7 @@
 static double _psy_lowpass_44[13]={
   /*  15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999. */
 //  13.9,15.1,15.8,16.5,17.2,18.9,20.1,48.,999.,999.,999.,999.
-  13.2,14.8,15.1,15.8,16.5,17.2,18.3,20.1,48.,999.,999.,999.,999.
+  13.1,14.8,15.1,15.8,16.5,17.2,18.3,20.1,48.,999.,999.,999.,999.
 };
 
 /* noise normalization **********/
@@ -735,12 +751,12 @@
 static int _noise_start_short_44[12]={
   /*  16,16,16,16,32,32,9999,9999,9999,9999 */
 //  32,16,16,16,32,9999,9999,9999,9999,9999,9999
-  16,32,16,16,32,64,9999,9999,9999,9999,9999,9999
+  32,32,16,16,32,64,9999,9999,9999,9999,9999,9999
 };
 static int _noise_start_long_44[12]={
   /*  128,128,128,256,512,512,9999,9999,9999,9999 */
 //  256,128,128,256,512,9999,9999,9999,9999,9999,9999
-  128,256,128,128,256,512,9999,9999,9999,9999,9999,9999
+  256,256,128,128,256,512,9999,9999,9999,9999,9999,9999
 };
 
 static int _noise_part_short_44[12]={
@@ -755,7 +771,7 @@
 static double _noise_thresh_44[12]={
   /*  .2,.2,.3,.4,.5,.5,9999.,9999.,9999.,9999., */
 //   .2,.2,.2,.4,.6,9999.,9999.,9999.,9999.,9999.,9999.,
-   .1462,.1886,.1887,.1975,.355,.8,9999.,9999.,9999.,9999.,9999.,9999.,
+   .16,.19,.19,.2,.35,.8,9999.,9999.,9999.,9999.,9999.,9999.,
 };
 
 static double _noise_thresh_5only[2]={
@@ -765,9 +781,9 @@
 /* 32kHz only */
 static int _noise_start_short_32[12]={
 //  40,40,20,20,40,80,9999,9999,9999,9999,9999,9999
-  24,48,24,24,40,80,9999,9999,9999,9999,9999,9999
+  48,48,24,24,40,80,9999,9999,9999,9999,9999,9999
 };
 static int _noise_start_long_32[12]={
 //  320,320,160,160,320,640,9999,9999,9999,9999,9999,9999
-  160,320,160,160,320,640,9999,9999,9999,9999,9999,9999
+  320,320,160,160,320,640,9999,9999,9999,9999,9999,9999
 };

Modified: branches/vorbis-aotuv/lib/modes/psych_8.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/psych_8.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/modes/psych_8.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -16,26 +16,26 @@
  ********************************************************************/
 
 static att3 _psy_tone_masteratt_8[4]={
-  {{ 32,  25,  12},  0,   0},  /* -2 */
-  {{ 32,  25,  12},  0,   0},  /* -1 */
-  {{ 30,  25,  12},  0,   0},  /*  0 */
+  {{ 33,  28,  13},  0,   0},  /* -2 */
+  {{ 32,  28,  12},  0,   0},  /* -1 */
+  {{ 30,  26,  12},  0,   0},  /*  0 */
   {{ 20,   0, -14},  0,   0},  /* 10 */
 };
 
 static vp_adjblock _vp_tonemask_adj_8[4]={
   /* adjust for mode zero */
   /* 63     125     250     500     1     2     4     8    16 */
-  {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0, 0, 5, 5,99,99,99}}, /* -2 */
-  {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* -1 */
-  {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /*  0 */
-  {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 10 */
+  {{-15,-15,-15,-15,-10,-10, -6,-2, 0, 0, 0, 0, 3, 3,99,99,99}}, /* -2 */
+  {{-15,-15,-15,-15,-10,-10, -6,-2, 0, 0, 0, 0, 0, 0,99,99,99}}, /* -1 */
+  {{-15,-15,-15,-15,-10,-10, -6,-2, 0, 0, 0, 0, 0, 0,99,99,99}}, /*  0 */
+  {{-15,-15,-15,-15,-10,-10, -6,-2, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 10 */
 };
 
 
 static noise3 _psy_noisebias_8[4]={
   /*  63     125     250     500      1k       2k      4k      8k     16k*/
-  {{{-10,-10,-10,-10, -5, -5, -5,  2,  4,  8,  8,  8, 10, 10, 99, 99, 99},
-    {-10,-10,-10,-10, -5, -4, -2,  2,  3,  4,  4,  4,  7,  8, 99, 99, 99},
+  {{{-10,-10,-10,-10, -5, -5, -5,  3,  4,  8,  8,  8, 10, 10, 99, 99, 99},
+    {-10,-10,-10,-10, -5, -2, -2,  3,  3,  4,  4,  5,  6,  8, 99, 99, 99},
     {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}},
 
   {{{-10,-10,-10,-10, -5, -5, -5,  0,  4,  8,  8,  8, 10, 10, 99, 99, 99},
@@ -55,7 +55,7 @@
 static adj_stereo _psy_stereo_modes_8[4]={
   /*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  */
   {{  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3},
-   {  6,  5,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4},
+   {  6,  5,  5,  5,  5,  5,  5,  5,  4,  4,  4,  4,  4,  4,  4},
    {  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1},
    { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
   {{  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3},

Modified: branches/vorbis-aotuv/lib/modes/setup_32.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/setup_32.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/modes/setup_32.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -23,13 +23,13 @@
 
 static double rate_mapping_32_un[13]={
 //  30000.,42000.,52000.,64000.,72000.,78000.,
-  24000.,32000.,42000.,52000.,64000.,72000.,78000.,
+  26000.,32000.,42000.,52000.,64000.,72000.,78000.,
   86000.,92000.,110000.,120000.,140000.,190000.,
 };
 
 static double _psy_lowpass_32[13]={
 //  12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99.
-  12.,12.6,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99.
+  12.1,12.6,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99.
 };
 
 ve_setup_data_template ve_setup_32_stereo={

Modified: branches/vorbis-aotuv/lib/modes/setup_44u.h
===================================================================
--- branches/vorbis-aotuv/lib/modes/setup_44u.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/modes/setup_44u.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -19,7 +19,7 @@
 
 static double rate_mapping_44_un[13]={
 //  32000.,48000.,60000.,70000.,80000.,86000.,
-  26000.,32000.,48000.,60000.,70000.,80000.,86000.,
+  28000.,40000.,48000.,60000.,70000.,80000.,86000.,
   96000.,110000.,120000.,140000.,160000.,240001.
 };
 

Modified: branches/vorbis-aotuv/lib/psy.c
===================================================================
--- branches/vorbis-aotuv/lib/psy.c	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/psy.c	2006-11-05 15:43:48 UTC (rev 12033)
@@ -33,14 +33,14 @@
 
 /*
   rephase   = reverse phase limit (postpoint)
-  lowlong   = low quality long-block limit (postpoint)
-  diffmid   = diffuse mid sound limit (postpoint)
                                                 0    1    2    3    4    5    6    7    8  */
 static double stereo_threshholds[]=           {0.0, 0.5, 1.0, 1.5, 2.5, 4.5, 8.5,16.5, 9e10};
-static double stereo_threshholds_rephase[]=   {0.0, 0.5, 0.5, 1.0, 1.5, 1.5, 1.5, 2.5, 9e10};
-static double stereo_threshholds_lowlong[]=   {0.0, 0.5, 1.0, 1.5, 2.5, 3.0, 6.5,10.5, 9e10};
-static double stereo_threshholds_diffmid[]=   {0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 2.5, 5.5, 9e10};
+static double stereo_threshholds_rephase[]=   {0.0, 0.5, 0.5, 1.0, 1.5, 1.5, 2.5, 2.5, 9e10};
 
+static double stereo_threshholds_low[]=       {0.0, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0};
+static double stereo_threshholds_high[]=      {0.0, 0.5, 0.5, 0.5, 1.0, 3.0, 5.5, 8.5, 0.0};
+
+
 static int m3n32[] = {21,13,10,4};
 static int m3n44[] = {15,9,7,3};
 static int m3n48[] = {14,8,6,3};
@@ -56,7 +56,9 @@
 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
 };
 
+static float nnmid_th=0.2;
 
+
 vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){
   codec_setup_info *ci=vi->codec_setup;
   vorbis_info_psy_global *gi=&ci->psy_g_param;
@@ -309,18 +311,53 @@
   p->rate=rate;
 
   /* AoTuV HF weighting etc. */
+  p->n25p=n/4;
+  p->n33p=n/3;
+  p->n75p=n*3/4;
   if(rate < 26000){
+  	/* below 26kHz */
   	p->m_val = 0;
   	for(i=0; i<4; i++) p->m3n[i] = 0;
-  }else if(rate < 38000){   /* 32kHz */
-  	p->m_val = .94;
+  	p->tonecomp_endp=0; // dummy
+  	p->tonecomp_thres=.25;
+  	p->st_freqlimit=n;
+  	p->min_nn_lp=0;
+  }else if(rate < 38000){
+  	/* 32kHz */
+  	p->m_val = .93;
   	for(i=0; i<4; i++) p->m3n[i] = m3n32[i];
-  }else if(rate > 46000){  /* 48kHz */
+  	if(n==128)      { p->tonecomp_endp= 124; p->tonecomp_thres=.5;
+  	                 p->st_freqlimit=n; p->min_nn_lp=   0;}
+  	else if(n==256) { p->tonecomp_endp= 248; p->tonecomp_thres=.7;
+  	                 p->st_freqlimit=n; p->min_nn_lp=   0;}
+  	else if(n==1024){ p->tonecomp_endp= 992; p->tonecomp_thres=.5;
+  	                 p->st_freqlimit=n; p->min_nn_lp= 832;}
+  	else if(n==2048){ p->tonecomp_endp=1984; p->tonecomp_thres=.7;
+  	                 p->st_freqlimit=n; p->min_nn_lp=1664;}
+  }else if(rate > 46000){
+  	/* 48kHz */
   	p->m_val = 1.205;
   	for(i=0; i<4; i++) p->m3n[i] = m3n48[i];
-  }else{                   /* 44.1kHz */
+  	if(n==128)      { p->tonecomp_endp=  83; p->tonecomp_thres=.5;
+  	                 p->st_freqlimit=  89; p->min_nn_lp=   0;}
+  	else if(n==256) { p->tonecomp_endp= 166; p->tonecomp_thres=.7;
+  	                 p->st_freqlimit= 178; p->min_nn_lp=   0;}
+  	else if(n==1024){ p->tonecomp_endp= 664; p->tonecomp_thres=.5;
+  	                 p->st_freqlimit= 712; p->min_nn_lp= 576;}
+  	else if(n==2048){ p->tonecomp_endp=1328; p->tonecomp_thres=.7;
+  	                 p->st_freqlimit=1424; p->min_nn_lp=1152;}
+  }else{
+  	/* 44.1kHz */
   	p->m_val = 1.;
   	for(i=0; i<4; i++) p->m3n[i] = m3n44[i];
+  	if(n==128)      { p->tonecomp_endp=  90; p->tonecomp_thres=.5;
+  	                 p->st_freqlimit=  96; p->min_nn_lp=   0;}
+  	else if(n==256) { p->tonecomp_endp= 180; p->tonecomp_thres=.7;
+  	                 p->st_freqlimit= 192; p->min_nn_lp=   0;}
+  	else if(n==1024){ p->tonecomp_endp= 720; p->tonecomp_thres=.5;
+  	                 p->st_freqlimit= 768; p->min_nn_lp= 608;}
+  	else if(n==2048){ p->tonecomp_endp=1440; p->tonecomp_thres=.7;
+  	                 p->st_freqlimit=1536; p->min_nn_lp=1216;}
   }
 
   /* set up the lookups for a given blocksize and sample rate */
@@ -851,7 +888,7 @@
   /* aoTuV M5 extension */
   i=0;
   if((p->vi->noisecompand_high[NOISE_COMPAND_LEVELS-1] > 1) && (noise_compand_level > 0)){
-  	int thter = n/3;
+  	int thter = p->n33p;
   	for(;i<thter;i++){
     	int dB=logmask[i]+.5;
     	if(dB>=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1;
@@ -902,6 +939,8 @@
 			float *mdct,
 			float *logmdct,
 			float *lastmdct, float *tempmdct,
+			float low_compand,
+			int end_block,
 			int blocktype, int modenumber,
 			int nW_modenumber,
 			int lW_blocktype, int lW_modenumber, int lW_no){
@@ -909,29 +948,33 @@
   int i,j,n=p->n;
   int m2_sw=0,  padth; /* aoTuV for M2 */
   int it_sw, *m3n, m3_count; /* aoTuV for M3 */
-  int m4_start, fmask; /* aoTuV for M4 */
+  int m4_end, lp_pos, m4_start; /* aoTuV for M4 */
   float de, coeffi, cx; /* aoTuV for M1 */
   float toneth; /* aoTuV for M2 */
   float noise_rate, noise_rate_low, noise_center, rate_mod; /* aoTuV for M3 */
-  float m4_val; /* aoTuV for M4 */
+  float m4_thres; /* aoTuV for M4 */
   float toneatt=p->vi->tone_masteratt[offset_select];
 
   cx = p->m_val;
   m3n = p->m3n;
+  m4_start=p->vi->normal_start;
+  m4_end = p->tonecomp_endp;
+  m4_thres = p->tonecomp_thres;
+  lp_pos=9999;
   
+  end_block+=p->vi->normal_partition;
+  if(end_block>n)end_block=n;
+  
+  /* Collapse of low(mid) frequency is prevented. (for 32/44/48kHz q-2) */
+  if(low_compand<0 || toneatt<25.)low_compand=0;
+  else low_compand*=(toneatt-25.);
+  
   /** @ M2 PRE **/
-  if(p->vi->normal_thresh<.45){
-  	if(modenumber){
-  		// sample
-    	//  21@ [q-2] 0,0,-1,-7,-11 [q2] (48/44.1/32kHz quality mode)
-    	//  20@ [q-2] 0,0, 0,-6,-10 [q2] (48/44.1/32kHz quality mode)
-    	toneth=toneatt-20.45;
-    	if(toneth>0.1) toneth=0;
+  if(p->vi->normal_thresh<.48){
+  	if((cx > 0.5) && !modenumber && blocktype && (n==128)){
+    	if(p->vi->normal_thresh>.35) padth = 10+(int)(p->vi->flacint*100);
+    	else padth = 10;
     	m2_sw=1;
-    }else if((cx > 0.5) && blocktype && (n==128)){
-    	if(p->vi->normal_thresh>.25) padth = 10+(int)(p->vi->flacint*100);
-    	else padth = 10;
-    	m2_sw=2;
     }
   }
 
@@ -942,11 +985,11 @@
   	if(!lW_blocktype && !lW_modenumber){ /* last window "short" - type "impulse" */
   		if(lW_no < 8){
   			/* impulse - @impulse case1 */
-  			noise_rate = 0.8-(float)(lW_no-1)/17;
+  			noise_rate = 0.7-(float)(lW_no-1)/17;
   			noise_center = (float)(lW_no*m3_count);
   		}else{
   			/* impulse - @impulse case2 */
-  			noise_rate = 0.4;
+  			noise_rate = 0.3;
   			noise_center = 25;
   			if((lW_no*m3_count) < 24) noise_center = lW_no*m3_count;
   		}
@@ -954,14 +997,13 @@
   			for(i=0; i<128; i++) tempmdct[i] -= 5;
   		}
   	}else{ /* non_impulse - @Short(impulse) case */
-  		noise_rate = 0.9;
+  		noise_rate = 0.7;
   		noise_center = 0;
   		if(offset_select == 1){
   			for(i=0; i<128; i++) tempmdct[i] = lastmdct[i] - 5;
   		}
-  		if(p->vi->normal_thresh < .45) noise_rate = 0.8;
   	}
-  	noise_rate_low = noise_rate*0.6;
+  	noise_rate_low = 0;
   	it_sw = 1;
   }else{
   	it_sw = 0;
@@ -969,55 +1011,39 @@
   
   /** @ M3&M4 PRE **/
   if(cx < 0.5){
-  	it_sw = 0; /* M3 */
-  	m4_val=-1.; /* M4 */
-  }else if((offset_select==1) && (p->vi->normal_thresh<.45)){
-  	/* for M4 */
-  	for(i=p->vi->normal_start; i<n; i++){
-  		if(p->noiseoffset[1][i] >= -0.91){
-  			m4_start = i;
-  			break;
-  		}
-  	}
-  	if(p->vi->normal_thresh < .175){
-  		m4_val=.966; // .966  q-2
-  	}else if(p->vi->normal_thresh < .195){
-  		m4_val=.973; // .973  q-1/0
-  	}else if(p->vi->normal_thresh < .3){
-  		m4_val=.974; // .974  q1
-  	}else m4_val=.986; // .986  q2
-  }else m4_val=-1.;
+  	it_sw = 0; /* for M3 */
+  	m4_end=end_block; /* for M4 */
+  }else if(p->vi->normal_thresh>1.){
+  	m4_start = 9999;
+  }else{
+  	if(m4_end>end_block)lp_pos=m4_end;
+  	else lp_pos=end_block;
+  }
 
   for(i=0;i<n;i++){
     float val= noise[i]+p->noiseoffset[offset_select][i];
     float tval= tone[i]+toneatt;
+    if(i<=m4_start)tval-=low_compand;
     if(val>p->vi->noisemaxsupp)val=p->vi->noisemaxsupp;
     
     /* AoTuV */
     /** @ M2 MAIN **
-    floor is pulled below suitably. (long/trans./padding block)
-    by Aoyumi @ 2005/09/14
+    floor is pulled below suitably. (padding block only) (#2)
+    by Aoyumi @ 2006/06/14
     */
     if(m2_sw){
-    	if(m2_sw == 1){
-   			if(val>(tval+toneth) && ((val-tval+toneth)>20) && val>-80){
-    			if((val-tval+toneth) > 30) val -= ((val-tval+toneth-30)/10+10);
-    			else val -= ((val-tval+toneth)-20);
-    		}
-    	}else{
-			// the conspicuous low level pre-echo of the padding block origin is reduced. 
-    		if((logmdct[i]-lastmdct[i]) > 20){
-    			if(i > m3n[3]) val -= (logmdct[i]-lastmdct[i]-20)/padth;
-    			else val -= (logmdct[i]-lastmdct[i]-20)/(padth+padth);
-    		}
+    	// the conspicuous low level pre-echo of the padding block origin is reduced. 
+    	if((logmdct[i]-lastmdct[i]) > 20){
+    		if(i > m3n[3]) val -= (logmdct[i]-lastmdct[i]-20)/padth;
+    		else val -= (logmdct[i]-lastmdct[i]-20)/(padth+padth);
     	}
     }
     
     /* AoTuV */
     /** @ M3 MAIN **
-    Dynamic impulse block noise control. (#3)
+    Dynamic impulse block noise control. (#4)
     48/44.1/32kHz only.
-    by Aoyumi @ 2004/08/30
+    by Aoyumi @ 2006/02/02
     */
     if(it_sw){
     	for(j=1; j<=temp_bfn[i]; j++){
@@ -1025,49 +1051,58 @@
 			if( (tempmdct[i+j] < tempbuf) && (tempmdct[i+j] < (logmdct[i+j]-5)) )
 			 tempmdct[i+j] = logmdct[i+j] - 5;
 		}
-		
     	if(val > tval){
-    		if( logmdct[i] > (tempmdct[i]+noise_center) ){
+    		if( (val>lastmdct[i]) && (logmdct[i]>(tempmdct[i]+noise_center)) ){
+    			float valmask=0;
     			tempmdct[i] = logmdct[i];
-    			if(logmdct[i] < lastmdct[i]) rate_mod = noise_rate;
-    			else rate_mod = noise_rate_low;
-				
+    			
+    			if(logmdct[i]>lastmdct[i]){
+    				rate_mod = noise_rate;
+    			}else{
+    				rate_mod = noise_rate_low;
+				}
 				if(i > m3n[1]){
-						if((val-tval) > 30) val = val - ((val-tval-30)/10+30)*rate_mod;
-						else val = val - (val-tval)*rate_mod;
+						if((val-tval)>30) valmask=((val-tval-30)/10+30)*rate_mod;
+						else valmask=(val-tval)*rate_mod;
 				}else if(i > m3n[2]){
-						if((val-tval) > 20) val = val - ((val-tval-20)/10+20)*rate_mod;
-						else val = val - (val-tval)*rate_mod;
+						if((val-tval)>20) valmask=((val-tval-20)/10+20)*rate_mod;
+						else valmask=(val-tval)*rate_mod;
 				}else if(i > m3n[3]){
-						if((val-tval) > 10) val = val - ((val-tval-10)/10+10)*rate_mod*0.5;
-						else val = val - (val-tval)*rate_mod*0.5;
+						if((val-tval)>10) valmask=((val-tval-10)/10+10)*rate_mod*0.5;
+						else valmask=(val-tval)*rate_mod*0.5;
 				}else{
-					if((val-tval) > 10) val = val - ((val-tval-10)/10+10)*rate_mod*0.3;
-					else val = val - (val-tval)*rate_mod*0.3;
+					if((val-tval)>10) valmask=((val-tval-10)/10+10)*rate_mod*0.3;
+					else valmask=(val-tval)*rate_mod*0.3;
 				}
+				if((val-valmask)>lastmdct[i])val-=valmask;
+				else val=lastmdct[i];
 			}
    		}
    	}
    	
-   	if(val>tval){
-   		logmask[i]=val;
-   		fmask=0;
-   	}else{
-   		logmask[i]=tval;
-   		fmask=1;
-   	}
+   	/* This affects calculation of a floor curve. */
+   	if(i>=lp_pos)logmdct[i]=-160;
+   	
+     /* AoTuV */
+	/** @ M4 MAIN **
+	The purpose of this portion is working Noise Normalization more correctly. 
+	(There is this in order to prevent extreme boost of floor)
+	  m4_start = start point
+	  m4_end   = end point
+	  m4_thres = threshold
+	by Aoyumi @ 2006/03/20
+	*/
     //logmask[i]=max(val,tval);
-    
-    /* AoTuV */
-    /** @ M4 MAIN **
-    This aims at an effect similar to M1. 
-    by Aoyumi @ 2005/09/06
-    */
-    if(m4_val > 0){
-    	if(fmask && (m4_start<i)){
-    		mdct[i] *= m4_val;
-    	}
-    }
+    if(val>tval){
+		logmask[i]=val;
+	}else if((i>m4_start) && (i<m4_end) && (logmdct[i]>-140)){
+		if(logmdct[i]>val){
+			if(logmdct[i]<tval)tval-=(tval-val)*m4_thres;
+		}else{
+			if(val<tval)tval-=(tval-val)*m4_thres;
+		}
+		logmask[i]=tval;
+	}else logmask[i]=tval;
 
     /* AoTuV */
     /** @ M1 **
@@ -1445,7 +1480,7 @@
 
 void _vp_noise_normalize(vorbis_look_psy *p,
 			 float *in,float *out,int *sortedindex){
-  int flag=0,i,j=0,n=p->n;
+  int i,j=0,n=p->n,min_energy;
   vorbis_info_psy *vi=p->vi;
   int partition=vi->normal_partition;
   int start=vi->normal_start;
@@ -1459,27 +1494,64 @@
     for(;j+partition<=n;j+=partition){
       float acc=0.;
       int k;
+      int energy_loss=0;
+      int nn_num=0;
+      int freqband_mid=j+16;
+      int freqband_flag=0;
       
-      for(i=j;i<j+partition;i++)
-	acc+=in[i]*in[i]*0.9;
+      for(i=j;i<j+partition;i++){
+        if(rint(in[i])==0.f){
+        	acc+=in[i]*in[i];
+        	energy_loss++;
+        }
+      }
+      /* When an energy loss is large, NN processing is carried out in the middle of partition. */
+      /*if(energy_loss==32 && fabs(in[freqband_mid])>nnmid_th){
+      	if(in[freqband_mid]*in[freqband_mid]<.25f){
+      		i=0;
+      		if(acc>=vi->normal_thresh){
+      			out[freqband_mid]=unitnorm(in[freqband_mid]);
+      			acc-=1.;
+      			freqband_flag=1;
+      			nn_num++;
+      		}
+      	}
+      }*/
       
+      /* NN main */
       for(i=0;i<partition;i++){
-	k=sortedindex[i+j-start];
-	
-	if(in[k]*in[k]>=.25f){ // or rint(in[k])!=0.f
-	  out[k]=rint(in[k]);
-	  acc-=in[k]*in[k]*0.9;
-	  flag=1;
-	}else{
-	  if(acc<vi->normal_thresh)break;
-	  out[k]=unitnorm(in[k]);
-	  acc-=1.;
-	}
+      	k=sortedindex[i+j-start];
+      	if(in[k]*in[k]>=.25f){ // or rint(in[k])!=0.f
+      		out[k]=rint(in[k]);
+      		//acc-=in[k]*in[k];
+      	}else{
+      		if(acc<vi->normal_thresh)break;
+      		if(freqband_flag && freqband_mid==k)continue;
+      		out[k]=unitnorm(in[k]);
+      		acc-=1.;
+      		nn_num++;
+      	}
       }
       
+      /* The minimum energy complement */
+      /*min_energy=32-energy_loss+nn_num;
+      if(min_energy<2 || (j<=p->min_nn_lp && min_energy==2)){
+      	k=sortedindex[i+j-start];
+      	if(freqband_flag && freqband_mid==k){
+      		i++;
+      		k=sortedindex[i+j-start];
+	    }
+	    if(!(fabs(in[k])<0.3)){
+	    	out[k]=unitnorm(in[k]);
+	    	i++;
+	    }
+	  }*/
+	  
+	  // The last process
       for(;i<partition;i++){
-	k=sortedindex[i+j-start];
-	out[k]=0.;
+      	k=sortedindex[i+j-start];
+      	if(freqband_flag && freqband_mid==k)continue;
+      	else out[k]=0.;
       }
     }
   }
@@ -1499,8 +1571,6 @@
 		int   **ifloor,
 		int   *nonzero,
 		int  sliding_lowpass,
-		int blocktype, int modenumber,
-		int lW_blocktype, int lW_modenumber,
 		float **mdct, float **res_org){
 
   int i,j,k,n=p->n;
@@ -1535,27 +1605,60 @@
       int *floorA=ifloor[vi->coupling_ang[i]];
       float prepoint=stereo_threshholds[g->coupling_prepointamp[blobno]];
       float postpoint=stereo_threshholds[g->coupling_postpointamp[blobno]];
-      float postpoint_bu;
-      float diff_mid;
+      float sth_low=stereo_threshholds_low[g->coupling_prepointamp[blobno]];
+      float sth_high=stereo_threshholds_high[g->coupling_postpointamp[blobno]];
+      float postpoint_backup;
+      float st_thresh;
       int partition=(p->vi->normal_point_p?p->vi->normal_partition:p->n);
       int limit=g->coupling_pointlimit[p->vi->blockflag][blobno];
       int pointlimit=limit;
-
+      int freqlimit=p->st_freqlimit;
+      unsigned char Mc_treshp[2048];
+      unsigned char Ac_treshp[2048];
+      int lof_st;
+      int hif_st;
+      int hif_stcopy;
+      int old_lof_st=0;
+      int old_hif_st=0;
+      int Afreq_num=0;
+      int Mfreq_num=0;
+      int stcont_start=0; // M6 start point
+      
       nonzero[vi->coupling_mag[i]]=1; 
       nonzero[vi->coupling_ang[i]]=1; 
        
-       if(p->m_val > 0.5){
-       	/* The threshold of a stereo is changed in specific conditions. */
-       	if(modenumber) postpoint=stereo_threshholds_lowlong[g->coupling_postpointamp[blobno]];
-       }
-      postpoint_bu=postpoint;
+      postpoint_backup=postpoint;
       
-      diff_mid = stereo_threshholds_diffmid[g->coupling_postpointamp[blobno]];
-      if((p->vi->normal_thresh>.25) && (p->vi->normal_thresh<.45))
-       diff_mid = postpoint - ((postpoint-diff_mid) * (1.-p->vi->flacint));
-
-      for(j=0;j<p->n;j+=partition){
+      /** @ M6 PRE **/
+      // lossless only?
+      if(!stereo_threshholds[g->coupling_postpointamp[blobno]])stcont_start=n;
+      else{
+      	// exception handling
+      	if((postpoint-sth_high)<prepoint)sth_high=postpoint-prepoint;
+      	// start point setup
+      	for(j=0;j<n;j++){
+      		stcont_start=j;
+      		if(p->noiseoffset[1][j]>=-2)break;
+      	}
+      	// start point correction & threshold setup 
+      	st_thresh=.1;
+      	if(p->m_val<.5){
+      		// low frequency limit
+      		if(stcont_start<limit)stcont_start=limit;
+      	}else if(p->vi->normal_thresh>1.)st_thresh=.5;
+      	for(j=0;j<=freqlimit;j++){ // or j<n
+      		if(fabs(rM[j])<st_thresh)Mc_treshp[j]=1;
+      		else Mc_treshp[j]=0;
+      		if(fabs(rA[j])<st_thresh)Ac_treshp[j]=1;
+      		else Ac_treshp[j]=0;
+      	}
+      }
+      
+      for(j=0;j<n;j+=partition){
 	float acc=0.f;
+	float rpacc;
+	int energy_loss=0;
+	int nn_num=0;
 
 	for(k=0;k<partition;k++){
 	  int l=k+j;
@@ -1563,11 +1666,101 @@
 	  float b=mdctA[l];
 	  float dummypoint;
 	  float hypot_reserve;
+	  float slow=0.f;
+	  float shigh=0.f;
+	  float slowM=0.f;
+	  float slowA=0.f;
+	  float shighM=0.f;
+	  float shighA=0.f;
+	  float rMs=fabs(rMo[l]);
+      float rAs=fabs(rAo[l]);
 
-	  postpoint=postpoint_bu;
+	  postpoint=postpoint_backup;
+	  
+	  /* AoTuV */
+	  /** @ M6 MAIN **
+	    The threshold of a stereo is changed dynamically. 
+	    by Aoyumi @ 2006/06/04
+	  */
+	  if(l>=stcont_start){
+	  	int m;
+	  	int lof_num;
+	  	int hif_num;
+	  	
+	  	// (It may be better to calculate this in advance) 
+	  	lof_st=l-(l/2)*.167;
+	  	hif_st=l+l*.167;
+	  
+	  	hif_stcopy=hif_st;
+	  	
+	  	// limit setting
+	  	if(hif_st>freqlimit)hif_st=freqlimit;
+	  	
+	  	if(old_lof_st || old_hif_st){
+	  		if(hif_st>l){
+	  			// hif_st, lof_st ...absolute value
+	  			// lof_num, hif_num ...relative value
+	  			
+	  			// low freq.(lower)
+	  			lof_num=lof_st-old_lof_st;
+	  			if(lof_num==0){
+	  				Afreq_num+=Ac_treshp[l-1];
+	  				Mfreq_num+=Mc_treshp[l-1];
+	  			}else if(lof_num==1){
+	  				Afreq_num+=Ac_treshp[l-1];
+	  				Mfreq_num+=Mc_treshp[l-1];
+	  				Afreq_num-=Ac_treshp[old_lof_st];
+	  				Mfreq_num-=Mc_treshp[old_lof_st];
+	  			}//else puts("err. low");
+	  			
+	  			// high freq.(higher)
+	  			hif_num=hif_st-old_hif_st;
+	  			if(hif_num==0){
+	  				Afreq_num-=Ac_treshp[l];
+	  				Mfreq_num-=Mc_treshp[l];
+	  			}else if(hif_num==1){
+	  				Afreq_num-=Ac_treshp[l];
+	  				Mfreq_num-=Mc_treshp[l];
+	  				Afreq_num+=Ac_treshp[hif_st];
+	  				Mfreq_num+=Mc_treshp[hif_st];
+	  			}else if(hif_num==2){
+	  				Afreq_num-=Ac_treshp[l];
+	  				Mfreq_num-=Mc_treshp[l];
+	  				Afreq_num+=Ac_treshp[hif_st];
+	  				Mfreq_num+=Mc_treshp[hif_st];
+	  				Afreq_num+=Ac_treshp[hif_st-1];
+	  				Mfreq_num+=Mc_treshp[hif_st-1];
+	  			}//else puts("err. high");
+	  		}
+	  	}else{
+	  		for(m=lof_st; m<=hif_st; m++){
+	  			if(m==l)continue;
+	  			if(Ac_treshp[m]) Afreq_num++;
+	  			if(Mc_treshp[m]) Mfreq_num++;
+			}
+	  	}
+	  	if(l>=limit){
+	  		shigh=sth_high/(hif_stcopy-lof_st);
+	  		shighA=shigh*Afreq_num;
+	  		shighM=shigh*Mfreq_num;
+	  		if((shighA+rAs)>(shighM+rMs))shigh=shighA;
+	  		else shigh=shighM;
+		}else{
+			slow=sth_low/(hif_stcopy-lof_st);
+			slowA=slow*Afreq_num;
+			slowM=slow*Mfreq_num;
+			if(p->noiseoffset[1][l]<-1){
+				slowA*=(p->noiseoffset[1][l]+2);
+				slowM*=(p->noiseoffset[1][l]+2);
+			}
+		}
+		old_lof_st=lof_st;
+	  	old_hif_st=hif_st;
+	  }
 
-	  /* The following prevents an extreme reduction of residue. (2ch stereo only) */
 	  if(l>=limit){
+	    postpoint-=shigh;
+	    /* The following prevents an extreme reduction of residue. (2ch stereo only) */
 	  	if( ((a>0.) && (b<0.)) || ((b>0.) && (a<0.)) ){
 	  		hypot_reserve = fabs(fabs(a)-fabs(b));
 	  		if(hypot_reserve < 0.001){ // 0~0.000999-
@@ -1575,15 +1768,12 @@
 	  			dummypoint = dummypoint+((postpoint-dummypoint)*(hypot_reserve*1000));
 	  			if(postpoint > dummypoint) postpoint = dummypoint;
 	  		}
-      	}else if(((p->vi->normal_thresh<.45) && (a-b)<0.0001)){
-      		if((rint(rM[l])==0.f && rint(rA[l])!=0.f) || (rint(rA[l])==0.f && rint(rM[l])!=0.f))
-      		postpoint = diff_mid;
       	}
 	  }
-
+	  
 	  if(l<sliding_lowpass){
-	    if((l>=limit && fabs(rMo[l])<postpoint && fabs(rAo[l])<postpoint) ||
-	       (fabs(rMo[l])<prepoint && fabs(rAo[l])<prepoint)){
+	    if((l>=limit && rMs<postpoint && rAs<postpoint) ||
+	       (rMs<(prepoint-slowM) && rAs<(prepoint-slowA))){
 
 
 	      precomputed_couple_point(mag_memo[i][l],
@@ -1591,7 +1781,10 @@
 				       qM+l,qA+l);
 
 	      //if(rint(qM[l])==0.f)acc+=qM[l]*qM[l];
-	      if( (rint(qM[l])==0.f) && (l>=limit) )acc+=qM[l]*qM[l]*0.9;
+	      if(rint(qM[l])==0.f){
+	      	energy_loss++;
+	      	if(l>=limit)acc+=qM[l]*qM[l];
+	      }
 	    }else{
 	      couple_lossless(rM[l],rA[l],qM+l,qA+l);
 	    }
@@ -1600,21 +1793,65 @@
 	    qA[l]=0.;
 	  }
 	}
-	
+
 	if(p->vi->normal_point_p){
+	  int freqband_mid=j+16;
+	  int freqband_flag=0;
+	  int min_energy;
+	  
+	  rpacc=acc;
+	  /* When the energy loss of a partition is large, NN is performed in the middle of partition.
+	      for 48/44.1/32kHz */
+	  if(energy_loss==32 && fabs(qM[freqband_mid])>nnmid_th && acc>=p->vi->normal_thresh
+	   && freqband_mid<sliding_lowpass && freqband_mid>=pointlimit && rint(qM[freqband_mid])==0.f){
+	  	if( ((mdctM[freqband_mid]>0.) && (mdctA[freqband_mid]<0.)) ||
+	  	 ((mdctA[freqband_mid]>0.) && (mdctM[freqband_mid]<0.)) ){
+	  	 acc-=1.f;
+	  	 rpacc-=1.32;
+	  	}else{
+	  	 acc-=1.f;
+	  	 rpacc-=1.f;
+	  	}
+	  	qM[freqband_mid]=unitnorm(qM[freqband_mid]);
+	  	freqband_flag=1;
+	  	nn_num++;
+	  }
+	  /* NN main (point stereo) */
 	  for(k=0;k<partition && acc>=p->vi->normal_thresh;k++){
-	    int l=mag_sort[i][j+k];
-	    float a=mdctM[l];
-	    float b=mdctA[l];
+	    int l;
+	    l=mag_sort[i][j+k];
+	    if(freqband_mid==l && freqband_flag)continue;
 	    if(l<sliding_lowpass && l>=pointlimit && rint(qM[l])==0.f){
-	      qM[l]=unitnorm(qM[l]);
-	      if( ((a>0.) && (b<0.)) || ((b>0.) && (a<0.)) ){
-	        acc-=1.46;
+	      if( ((mdctM[l]>0.) && (mdctA[l]<0.)) || ((mdctA[l]>0.) && (mdctM[l]<0.)) ){
+	        if(rpacc<p->vi->normal_thresh)continue;
+	        acc-=1.f;
+	        rpacc-=1.32;
 	      }else{
 	        acc-=1.f;
+	        rpacc-=1.f;
 	      }
+	      qM[l]=unitnorm(qM[l]);
+	      nn_num++;
 	    }
 	  }
+	  /* The minimum energy complement.
+	      for 48/44.1/32kHz */
+	  min_energy=32-energy_loss+nn_num;
+	  if(min_energy<2 || (j<=p->min_nn_lp && min_energy==2)){
+	  	int l;
+	  	float ab;
+	    for(;k<partition;k++){
+	    	l=mag_sort[i][j+k];
+	    	ab=fabs(qM[l]);
+	    	if(ab<0.04)break;
+	    	if( ((mdctM[l]>0.) && (mdctA[l]<0.)) || ((mdctA[l]>0.) && (mdctM[l]<0.))
+	    	 && ab<0.11)break; // 0.11
+	    	if(rint(qM[l])==0.f && l>=pointlimit){
+	    		qM[l]=unitnorm(qM[l]);
+	    		break;
+	    	}
+	    }
+	  }
 	}
       }
     }
@@ -1635,7 +1872,7 @@
 		int lW_modenumber,
 		int blocktype, int modenumber){
 
-	int i, n=p->n, nq1=n/4, nq3=nq1*3;
+	int i, n=p->n, nq1=p->n25p, nq3=p->n75p;
 	double hi_th=0;
 	
 	if(p->m_val < 0.5)return(-1); /* 48/44.1/32kHz only */

Modified: branches/vorbis-aotuv/lib/psy.h
===================================================================
--- branches/vorbis-aotuv/lib/psy.h	2006-11-05 15:42:08 UTC (rev 12032)
+++ branches/vorbis-aotuv/lib/psy.h	2006-11-05 15:43:48 UTC (rev 12033)
@@ -116,7 +116,15 @@
   long  rate; /* cache it */
 
   int m3n[4]; /* number for M3 */
-  float m_val; /* Masking compensation value */
+  int tonecomp_endp; /* for M4 */
+  int min_nn_lp; /* for M6 */
+  float tonecomp_thres; /* for M4 */
+  float m_val; /* masking compensation value */
+  
+  int st_freqlimit; /* for M6 */
+  int n25p;
+  int n33p;
+  int n75p;
 
 } vorbis_look_psy;
 
@@ -153,6 +161,8 @@
 			       float *mdct,
 			       float *logmdct,
 			       float *lastmdct, float *tempmdct,
+			       float low_compand,
+			       int end_block,
 			       int blocktype, int modenumber,
 			       int nW_modenumber,
 			       int lW_blocktype, int lW_modenumber, int lW_no);
@@ -175,8 +185,6 @@
 		       int   **ifloor,
 		       int   *nonzero,
 		       int   sliding_lowpass,
-		       int blocktype, int modenumber,
-		       int lW_blocktype, int lW_modenumber,
 		       float **mdct, float **res_org);
 
 extern void _vp_noise_normalize(vorbis_look_psy *p,



More information about the commits mailing list