Implemented packet loss interpolation for wideband... not optimal yet...
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 22 Aug 2002 06:33:30 +0000 (06:33 +0000)
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 22 Aug 2002 06:33:30 +0000 (06:33 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@3861 0101bb08-14d6-0310-b084-bc0e0c8e3800

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

index a66b7f0..f2ba078 100644 (file)
@@ -686,6 +686,33 @@ void sb_decoder_destroy(void *state)
    speex_free(state);
 }
 
+static void sb_decode_lost(SBDecState *st, float *out)
+{
+   int i;
+   for (i=0;i<st->frame_size;i++)
+      st->exc[i]*=0.8;
+   
+   st->first=1;
+   
+   /* Final signal synthesis from excitation */
+   syn_filt_mem(st->exc, st->interp_qlpc, st->high, st->subframeSize, st->lpcSize, st->mem_sp);
+   
+   /* Up-sample coded low-band and high-band*/
+   for (i=0;i<st->frame_size;i++)
+   {
+      st->x0[(i<<1)]=st->x0d[i];
+      st->x1[(i<<1)]=st->high[i];
+      st->x0[(i<<1)+1]=0;
+      st->x1[(i<<1)+1]=0;
+   }
+   /* Reconstruct the original */
+   fir_mem(st->x0, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem);
+   fir_mem(st->x1, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem);
+   for (i=0;i<st->full_frame_size;i++)
+      out[i]=2*(st->y0[i]-st->y1[i]);
+   
+   return;
+}
 
 void sb_decode(void *state, SpeexBits *bits, float *out, int lost)
 {
@@ -697,6 +724,12 @@ void sb_decode(void *state, SpeexBits *bits, float *out, int lost)
    /* Decode the low-band */
    nb_decode(st->st_low, bits, st->x0d, lost);
 
+   if (lost)
+   {
+      sb_decode_lost(st, out);
+      return;
+   }
+
    /*Check "wideband bit"*/
    wideband = speex_bits_peek(bits);
    if (wideband)
index e0e2fb9..dd76705 100644 (file)
@@ -74,12 +74,7 @@ int main(int argc, char **argv)
       }
       speex_bits_rewind(&bits);
       
-      if (rand()%10==0)
-      {
-         speex_decode(dec, NULL, input, 1);
-      } else {
-         speex_decode(dec, &bits, input, 0);
-      }
+      speex_decode(dec, &bits, input, 0);
       
       /* Save the bits here */
       for (i=0;i<FRAME_SIZE;i++)
index 85c4db5..83de6af 100644 (file)
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
    speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
    tmp=3;
    speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
-   tmp=4;
+   tmp=6;
    speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp);
    
    if (argc != 4 && argc != 3)