shithub: opus

Download patch

ref: 52b4cb2166d8b9730132baaae1b72163812ccf92
parent: 56522addc2d8e54a8b61740fdaa3237183e35514
parent: 2dd3d3258ab7b3acaccde06f384cd66572bd7e39
author: Jean-Marc Valin <[email protected]>
date: Fri Jun 5 13:21:17 EDT 2009

Merge commit 'greg/master'

Conflicts:
	libcelt/celt.c
	libcelt/celt.h

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -81,8 +81,10 @@
    int overlap;
    int channels;
    
-   int pitch_enabled;
-   int pitch_available;
+   int pitch_enabled;       /* Complexity level is allowed to use pitch */
+   int pitch_permitted;     /*  Use of the LTP is permitted by the user */
+   int pitch_available;     /*  Amount of pitch buffer available */
+   int force_intra;
    int delayedIntra;
    celt_word16_t tonal_average;
    int fold_decision;
@@ -139,7 +141,9 @@
 
    st->VBR_rate = 0;
    st->pitch_enabled = 1;
+   st->pitch_permitted = 1;
    st->pitch_available = 1;
+   st->force_intra  = 0;
    st->delayedIntra = 1;
    st->tonal_average = QCONST16(1.,8);
    st->fold_decision = 1;
@@ -674,8 +678,8 @@
 
    compute_band_energies(st->mode, freq, bandE);
 
-   intra_ener = st->delayedIntra;
-   if (intra_decision(bandE, st->oldBandE, st->mode->nbEBands) || shortBlocks)
+   intra_ener = (st->force_intra || st->delayedIntra);
+   if (shortBlocks || intra_decision(bandE, st->oldBandE, st->mode->nbEBands))
       st->delayedIntra = 1;
    else
       st->delayedIntra = 0;
@@ -682,7 +686,7 @@
    /* Pitch analysis: we do it early to save on the peak stack space */
    /* Don't use pitch if there isn't enough data available yet, 
       or if we're using shortBlocks */
-   has_pitch = st->pitch_enabled && (st->pitch_available >= MAX_PERIOD) && (!shortBlocks) && !intra_ener;
+   has_pitch = st->pitch_enabled && st->pitch_permitted && (st->pitch_available >= MAX_PERIOD) && (!shortBlocks) && !intra_ener;
 #ifdef EXP_PSY
    ALLOC(tonality, MAX_PERIOD/4, celt_word16_t);
    {
@@ -1021,15 +1025,22 @@
          }   
       }
       break;
-      case CELT_SET_LTP_REQUEST:
+      case CELT_SET_PREDICTION_REQUEST:
       {
          int value = va_arg(ap, celt_int32_t);
-         if (value<0 || value>1 || (value==1 && st->pitch_available==0))
+         if (value<0 || value>2)
             goto bad_arg;
          if (value==0)
-            st->pitch_enabled = 0;
-         else
-            st->pitch_enabled = 1;
+         {
+            st->force_intra   = 1;
+            st->pitch_permitted = 0;
+         } else if (value=1) {
+            st->force_intra   = 0;
+            st->pitch_permitted = 0;
+         } else {
+            st->force_intra   = 0;
+            st->pitch_permitted = 1;
+         }   
       }
       break;
       case CELT_SET_VBR_RATE_REQUEST:
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -77,10 +77,13 @@
 #define CELT_SET_COMPLEXITY_REQUEST    2
 /** Controls the complexity from 0-10 (int) */
 #define CELT_SET_COMPLEXITY(x) CELT_SET_COMPLEXITY_REQUEST, _celt_check_int(x)
-#define CELT_SET_LTP_REQUEST    4
-/** Activate or deactivate the use of the long term predictor (pitch)
-    from 0 or 1 (int) */
-#define CELT_SET_LTP(x) CELT_SET_LTP_REQUEST, _celt_check_int(x)
+#define CELT_SET_PREDICTION_REQUEST    4
+/** Controls the use of interframe prediction.
+    0=Independent frames
+    1=Short term interframe prediction allowed
+    2=Long term prediction allowed
+ */
+#define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, _celt_check_int(x)
 #define CELT_SET_VBR_RATE_REQUEST    6
 /** Set the target VBR rate in bits per second(int); 0=CBR (default) */
 #define CELT_SET_VBR_RATE(x) CELT_SET_VBR_RATE_REQUEST, _celt_check_int(x)