shithub: opus

Download patch

ref: 6965388866f7046c96cddbb1fc34c573d944d19c
parent: fdd867534a8f53ddb3f2845fc1dd48d13e734125
author: Jean-Marc Valin <[email protected]>
date: Thu Apr 21 06:41:13 EDT 2011

Implements CELT_SET_LOSS_PERC

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -144,6 +144,7 @@
    int vbr;
    int signalling;
    int constrained_vbr;      /* If zero, VBR can do whatever it likes with the rate */
+   int loss_rate;
 
    /* Everything beyond this point gets cleared on a reset */
 #define ENCODER_RESET_START rng
@@ -1142,6 +1143,12 @@
          if (pitch_index > COMBFILTER_MAXPERIOD-2)
             pitch_index = COMBFILTER_MAXPERIOD-2;
          gain1 = MULT16_16_Q15(QCONST16(.7f,15),gain1);
+         if (st->loss_rate>2)
+            gain1 = HALF32(gain1);
+         if (st->loss_rate>4)
+            gain1 = HALF32(gain1);
+         if (st->loss_rate>8)
+            gain1 = 0;
          prefilter_tapset = st->tapset_decision;
       } else {
          gain1 = 0;
@@ -1785,6 +1792,14 @@
             goto bad_arg;
          st->disable_pf = value<=1;
          st->force_intra = value==0;
+      }
+      break;
+      case CELT_SET_LOSS_PERC_REQUEST:
+      {
+         int value = va_arg(ap, celt_int32);
+         if (value<0 || value>100)
+            goto bad_arg;
+         st->loss_rate = value;
       }
       break;
       case CELT_SET_VBR_CONSTRAINT_REQUEST:
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -112,6 +112,9 @@
 #define CELT_SET_CHANNELS_REQUEST    18
 #define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, _celt_check_int(x)
 
+#define CELT_SET_LOSS_PERC_REQUEST    20
+#define CELT_SET_LOSS_PERC(x) CELT_SET_LOSS_PERC_REQUEST, _celt_check_int(x)
+
 /* Internal */
 #define CELT_SET_START_BAND_REQUEST    10000
 #define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x)