shithub: opus

Download patch

ref: 896471dc3dda1f1a60b8cb176b6dc91589f40c8d
parent: a2012d8dc5af8e0db693eb42992f510d61288447
author: Jean-Marc Valin <[email protected]>
date: Thu Nov 6 16:55:41 EST 2008

Disabling the folding sign bit

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -413,11 +413,7 @@
       /* If pitch isn't available, use intra-frame prediction */
       if (eBands[i] >= m->pitchEnd || q<=0)
       {
-         q -= 1;
-         if (q<0)
-            intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], norm, P+C*eBands[i], eBands[i], B);
-         else
-            intra_prediction(m, X+C*eBands[i], W+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B, enc);
+         intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B);
       }
       
       if (q > 0)
@@ -500,11 +496,7 @@
       /* If pitch isn't available, use intra-frame prediction */
       if (eBands[i] >= m->pitchEnd || q<=0)
       {
-         q -= 1;
-         if (q<0)
-            intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], norm, P+C*eBands[i], eBands[i], B);
-         else
-            intra_unquant(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B, dec);
+         intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B);
       }
       
       if (q > 0)
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -69,16 +69,7 @@
             int pulses = j;
             /* For bands where there's no pitch, id 1 corresponds to intra prediction 
             with no pulse. id 2 means intra prediction with one pulse, and so on.*/
-            if (eBands[i] >= m->pitchEnd)
-               pulses -= 1;
-            if (pulses < 0)
-               bits[i][j] = 0;
-            else {
-               bits[i][j] = get_required_bits(N, pulses, BITRES);
-               /* Add the intra-frame prediction sign bit */
-               if (eBands[i] >= m->pitchEnd)
-                  bits[i][j] += (1<<BITRES);
-            }
+            bits[i][j] = get_required_bits(N, pulses, BITRES);
          }
          for (;j<MAX_PULSES;j++)
             bits[i][j] = BITOVERFLOW;
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -304,58 +304,18 @@
 
 #define KGAIN 6
 
-void intra_prediction(const CELTMode *m, celt_norm_t * restrict x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B, ec_enc *enc)
+void intra_fold(const CELTMode *m, celt_norm_t * restrict x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B)
 {
-   int j;
-   celt_word16_t s = 1;
-   int sign;
    celt_word16_t pred_gain;
-   celt_word32_t xy=0;
    const int C = CHANNELS(m);
 
-   pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K));
-
-   fold(m, N, Y, P, N0, B);
-
-   for (j=0;j<C*N;j++)
-      xy = MAC16_16(xy, P[j], x[j]);
-   if (xy<0)
-   {
-      s = -1;
-      sign = 1;
-   } else {
-      s = 1;
-      sign = 0;
-   }
-   ec_enc_bits(enc,sign,1);
-
-   renormalise_vector(P, s*pred_gain, C*N, 1);
-}
-
-void intra_unquant(const CELTMode *m, celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B, ec_dec *dec)
-{
-   celt_word16_t s;
-   celt_word16_t pred_gain;
-   const int C = CHANNELS(m);
-      
-   if (ec_dec_bits(dec, 1) == 0)
-      s = 1;
+   if (K==0)
+      pred_gain = Q15ONE;
    else
-      s = -1;
-   
-   pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K));
-   
-   fold(m, N, Y, P, N0, B);
-   
-   renormalise_vector(P, s*pred_gain, C*N, 1);
-}
+      pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K));
 
-void intra_fold(const CELTMode *m, celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B)
-{
-   const int C = CHANNELS(m);
-
    fold(m, N, Y, P, N0, B);
-   
-   renormalise_vector(P, Q15ONE, C*N, 1);
+
+   renormalise_vector(P, pred_gain, C*N, 1);
 }
 
--- a/libcelt/vq.h
+++ b/libcelt/vq.h
@@ -73,13 +73,7 @@
  * @param P Pitch vector (it is assumed that p+x is a unit vector)
  * @param B Stride (number of channels multiplied by the number of MDCTs per frame)
  * @param N0 Number of valid offsets
- * @param enc Entropy encoder state
  */
-void intra_prediction(const CELTMode *m, celt_norm_t * restrict x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B, ec_enc *enc);
-
-void intra_unquant(const CELTMode *m, celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t *P, int N0, int B, ec_dec *dec);
-
-/** Encode the entire band as a "fold" from other parts of the spectrum. No bits required (only use is case of an emergency!) */
-void intra_fold(const CELTMode *m, celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t *P, int N0, int B);
+void intra_fold(const CELTMode *m, celt_norm_t * restrict x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B);
 
 #endif /* VQ_H */