implemented high-band spectral folding at the decoder
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 2 May 2002 22:28:37 +0000 (22:28 +0000)
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 2 May 2002 22:28:37 +0000 (22:28 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@3271 0101bb08-14d6-0310-b084-bc0e0c8e3800

TODO
libspeex/sb_celp.c
libspeex/testenc.c
libspeex/testenc_wb.c

diff --git a/TODO b/TODO
index 8cedaab..6b3788b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,5 @@
 - VBR
 
-- VAD & comfort noise generation
+- VAD/DTX/comfort noise generation
 
-- High-band pre-emphasis
+- Post-filter
index 6b1e85c..09d9244 100644 (file)
@@ -460,11 +460,23 @@ void sb_encode(void *state, float *in, FrameBits *bits)
          g=eh/(.01+el);
          g=sqrt(g);
 
+         /* FIXME: Should encode the gain here */
+         g *= filter_ratio;
+         {
+            int quant = (int) floor(.5 + 9.4 * log(10*(g+.0001)));
+            if (quant<0)
+               quant=0;
+            if (quant>31)
+               quant=31;
+            frame_bits_pack(bits, quant, 5);
+            g= .1*exp(quant/9.4);
+         }
+         printf ("folding gain: %f\n", g);
+         g /= filter_ratio;
+
          /* High-band excitation using the low-band excitation and a gain */
          for (i=0;i<st->subframeSize;i++)
             exc[i]=g*((EncState*)st->st_low)->exc[offset+i];
-
-         /* FIXME: Should encode the gain here */
 #endif
          /* Update the input signal using the non-coded memory */
          syn_filt_mem(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, mem);
@@ -726,9 +738,24 @@ void sb_decode(void *state, FrameBits *bits, float *out)
       
       for (i=0;i<st->subframeSize;i++)
          exc[i]=0;
-      split_cb_nogain_unquant(exc, &split_cb_high, st->subframeSize, gain, 
-                              bits, st->stack);
-
+      if (0)
+      {
+         float g;
+         int quant;
+         quant = frame_bits_unpack_unsigned(bits, 5);
+         g= .1*exp(quant/9.4);
+         
+         printf ("unquant folding gain: %f\n", g);
+         g /= filter_ratio;
+         
+         g *= .8;
+         /* High-band excitation using the low-band excitation and a gain */
+         for (i=0;i<st->subframeSize;i++)
+            exc[i]=g*((DecState*)st->st_low)->exc[offset+i];
+      } else {
+         split_cb_nogain_unquant(exc, &split_cb_high, st->subframeSize, gain, 
+                                 bits, st->stack);
+      }
       syn_filt_mem(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp);
 
    }
index 08cc992..8e6b34b 100644 (file)
@@ -61,7 +61,7 @@ int main(int argc, char **argv)
       }
       frame_bits_rewind(&bits);
       
-      /*decode(&dec, &bits, input);*/
+      decode(dec, &bits, input);
 
       /* Save the bits here */
       for (i=0;i<FRAME_SIZE;i++)
index a3e332a..f7af13d 100644 (file)
@@ -61,7 +61,7 @@ int main(int argc, char **argv)
       }
       frame_bits_rewind(&bits);
       
-      /*decode(&dec, &bits, input);*/
+      decode(dec, &bits, input);
 
       /* Save the bits here */
       for (i=0;i<FRAME_SIZE;i++)