packet loss handling...
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Wed, 18 Sep 2002 22:01:05 +0000 (22:01 +0000)
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Wed, 18 Sep 2002 22:01:05 +0000 (22:01 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@3922 0101bb08-14d6-0310-b084-bc0e0c8e3800

TODO
doc/manual.lyx
libspeex/nb_celp.c
src/speexdec.c

diff --git a/TODO b/TODO
index 902b621..eb38bfc 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,9 @@
+Codec
 - Better VBR logic for choosing mode
 - Wideband VBR
 - Improve VAD
 - Improve narrowband vocoder
+Bit-stream
+API
+- Add bit-stream request handling and encoder/decoder pairing
+- Add callbacks for user-defined inf
index 0144939..79a8589 100644 (file)
@@ -1960,7 +1960,7 @@ N/A
 
 \layout Standard
 
-reserved
+DTMF and TTY
 \end_inset 
 </cell>
 </row>
@@ -2090,7 +2090,7 @@ N/A
 
 \layout Standard
 
-Application-defined, Speex should never see it
+Application-defined, interpreted by callback or skipped
 \end_inset 
 </cell>
 </row>
@@ -2116,7 +2116,7 @@ N/A
 
 \layout Standard
 
-In-band signaling, Speex will skip it
+Speex in-band signaling
 \end_inset 
 </cell>
 </row>
index 3699a30..77a6de1 100644 (file)
@@ -799,8 +799,8 @@ static void nb_decode_lost(DecState *st, float *out)
         
       for (i=0;i<st->subframeSize;i++)
       {
-         exc[i]=.7*st->last_pitch_gain*exc[i-st->last_pitch] + 
-         .5*st->innov[i+offset];
+         exc[i]=st->last_pitch_gain*exc[i-st->last_pitch] + 
+         .8*st->innov[i+offset];
       }
 
       for (i=0;i<st->subframeSize;i++)
@@ -1012,16 +1012,14 @@ int nb_decode(void *state, SpeexBits *bits, float *out)
          SUBMODE(ltp_unquant)(exc, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params), 
                               st->subframeSize, &pitch, &pitch_gain[0], bits, st->stack, st->count_lost);
          
-         
-         /* If the frame was not lost... */
-         tmp = fabs(pitch_gain[0]+pitch_gain[1]+pitch_gain[2]);
+         tmp = (pitch_gain[0]+pitch_gain[1]+pitch_gain[2]);
          if (tmp>best_pitch_gain)
          {
             best_pitch = pitch;
-            while (best_pitch+pitch<st->max_pitch)
+            /*while (best_pitch+pitch<st->max_pitch)
             {
                best_pitch+=pitch;
-            }
+               }*/
             best_pitch_gain = tmp*.9;
             if (best_pitch_gain>.85)
                best_pitch_gain=.85;
index d9bb7e0..9bb7e73 100644 (file)
@@ -177,6 +177,7 @@ void usage()
    printf (" --no-enh              Disable perceptual enhancement (default FOR NOW)\n");
    printf (" --force-nb            Force decoding in narrowband, even for wideband\n");
    printf (" --force-wb            Force decoding in wideband, even for narrowband\n");
+   printf (" --packet-loss n       Simulate n % random packet loss\n");
    printf (" -V                    Verbose mode (show bit-rate)\n"); 
    printf (" -h, --help            This help\n");
    printf (" -v, --version         Version information\n");
@@ -274,6 +275,7 @@ int main(int argc, char **argv)
       {"no-pf", no_argument, NULL, 0},
       {"force-nb", no_argument, NULL, 0},
       {"force-wb", no_argument, NULL, 0},
+      {"packet-loss", required_argument, NULL, 0},
       {0, 0, 0, 0}
    };
    ogg_sync_state oy;
@@ -287,6 +289,8 @@ int main(int argc, char **argv)
    int eos=0;
    int forceMode=-1;
    int audio_size=0;
+   float loss_percent=-1;
+
    enh_enabled = 0;
 
    /*Process options*/
@@ -328,6 +332,9 @@ int main(int argc, char **argv)
          } else if (strcmp(long_options[option_index].name,"force-wb")==0)
          {
             forceMode=1;
+         } else if (strcmp(long_options[option_index].name,"packet-loss")==0)
+         {
+            loss_percent = atof(optarg);
          }
          break;
       case 'h':
@@ -428,6 +435,10 @@ int main(int argc, char **argv)
                fprintf (stderr, "\n");
                */
             } else {
+               
+               int lost=0;
+               if (loss_percent>0 && 100*((float)rand())/RAND_MAX<loss_percent)
+                  lost=1;
 
                /*End of stream condition*/
                if (op.e_o_s)
@@ -438,8 +449,11 @@ int main(int argc, char **argv)
                for (j=0;j<nframes;j++)
                {
                   /*Decode frame*/
-                  speex_decode(st, &bits, output);
-               
+                  if (!lost)
+                     speex_decode(st, &bits, output);
+                  else
+                     speex_decode(st, NULL, output);
+
                   if (print_bitrate) {
                      int tmp;
                      char ch=13;