shithub: opus

Download patch

ref: 769311f98c7fd0a7fa90af01fcae6eac323da8de
parent: 862e18256a4a90338b083c655fe3b7e529f9947e
author: Jean-Marc Valin <[email protected]>
date: Tue Jul 20 09:28:00 EDT 2010

PLC support

--- a/src/hybrid_decoder.c
+++ b/src/hybrid_decoder.c
@@ -82,8 +82,11 @@
     SKP_int16 silk_frame_size;
     short pcm_celt[960];
 
-	ec_byte_readinit(&buf,(unsigned char*)data,len);
-	ec_dec_init(&dec,&buf);
+    if (data != NULL)
+    {
+        ec_byte_readinit(&buf,(unsigned char*)data,len);
+        ec_dec_init(&dec,&buf);
+    }
 
     if (st->mode != MODE_CELT_ONLY)
     {
@@ -92,7 +95,7 @@
         /* We Should eventually have to set the bandwidth here */
 
         /* Call SILK encoder for the low band */
-        silk_ret = SKP_Silk_SDK_Decode( st->silk_dec, &DecControl, 0, &dec, len, pcm, &silk_frame_size );
+        silk_ret = SKP_Silk_SDK_Decode( st->silk_dec, &DecControl, data == NULL, &dec, len, pcm, &silk_frame_size );
         if (silk_ret)
         {
             fprintf (stderr, "SILK decode error\n");
--- a/src/hybrid_encoder.c
+++ b/src/hybrid_encoder.c
@@ -98,7 +98,7 @@
 	{
 	    /* Set Encoder parameters */
 	    encControl.API_sampleRate        = st->Fs;
-	    encControl.packetLossPercentage  = 0;
+	    encControl.packetLossPercentage  = 2;
 	    encControl.useInBandFEC          = 0;
 	    encControl.useDTX                = 0;
 	    encControl.complexity            = 2;
--- a/src/test_hybrid.c
+++ b/src/test_hybrid.c
@@ -55,6 +55,7 @@
    int bytes_per_packet;
    unsigned char data[MAX_PACKET];
    int rate;
+   int loss = 0;
    int count = 0;
    int skip;
    short *in, *out;
@@ -62,7 +63,7 @@
    if (argc != 9 && argc != 8 && argc != 7)
    {
       fprintf (stderr, "Usage: test_hybrid <rate> <channels> <frame size> "
-               " <bytes per packet>  "
+               " <bytes per packet>  [<packet loss rate>] "
                "<input> <output>\n");
       return 1;
    }
@@ -72,6 +73,10 @@
    frame_size = atoi(argv[3]);
 
    bytes_per_packet = atoi(argv[4]);
+
+   if (argc >= 8)
+       loss = atoi(argv[5]);
+
    if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)
    {
       fprintf (stderr, "bytes per packet must be between 0 and %d\n",
@@ -117,7 +122,7 @@
          fprintf (stderr, "hybrid_encode() returned %d\n", len);
          return 1;
       }
-      hybrid_decode(dec, data, len, out, frame_size);
+      hybrid_decode(dec, rand()%100<loss ? NULL : data, len, out, frame_size);
       count++;
       fwrite(out+skip, sizeof(short), (frame_size-skip)*channels, fout);
       skip = 0;