shithub: opus

Download patch

ref: 07586892463ac5da1d501aa32b37f9eda07d4bf3
parent: 312132780efde133fa797f8ac08a8011e50f10af
author: Jean-Marc Valin <[email protected]>
date: Mon Mar 3 12:19:17 EST 2008

pre-emphasis coef now a constant

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -51,6 +51,9 @@
 
 #define MAX_PERIOD 1024
 
+static const celt_word16_t preemph = QCONST16(0.8f,15);
+
+
 /** Encoder state 
  @brief Encoder state
  */
@@ -65,7 +68,6 @@
    ec_byte_buffer buf;
    ec_enc         enc;
 
-   celt_word16_t preemph;
    celt_sig_t *preemph_memE;
    celt_sig_t *preemph_memD;
 
@@ -79,8 +81,6 @@
    celt_word16_t *oldBandE;
 };
 
-
-
 CELTEncoder *celt_encoder_create(const CELTMode *mode)
 {
    int N, B, C;
@@ -112,7 +112,6 @@
 
    st->oldBandE = (celt_word16_t*)celt_alloc(C*mode->nbEBands*sizeof(celt_word16_t));
 
-   st->preemph = QCONST16(0.8f,15);
    st->preemph_memE = (celt_sig_t*)celt_alloc(C*sizeof(celt_sig_t));;
    st->preemph_memD = (celt_sig_t*)celt_alloc(C*sizeof(celt_sig_t));;
 
@@ -268,7 +267,7 @@
       for (i=0;i<B*N;i++)
       {
          celt_sig_t tmp = SHL32(EXTEND32(pcm[C*i+c]), SIG_SHIFT);
-         in[C*(i+st->overlap)+c] = SUB32(tmp, MULT16_32_Q15(st->preemph,st->preemph_memE[c]));
+         in[C*(i+st->overlap)+c] = SUB32(tmp, MULT16_32_Q15(preemph,st->preemph_memE[c]));
          st->preemph_memE[c] = tmp;
       }
       for (i=0;i<st->overlap;i++)
@@ -385,7 +384,7 @@
          for (j=0;j<N;j++)
          {
             celt_sig_t tmp = ADD32(st->out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c],
-                                   MULT16_32_Q15(st->preemph,st->preemph_memD[c]));
+                                   MULT16_32_Q15(preemph,st->preemph_memD[c]));
             st->preemph_memD[c] = tmp;
             pcm[C*i*N+C*j+c] = SIG2INT16(tmp);
          }
@@ -450,7 +449,6 @@
    ec_byte_buffer buf;
    ec_enc         enc;
 
-   celt_word16_t preemph;
    celt_sig_t *preemph_memD;
 
    celt_sig_t *mdct_overlap;
@@ -485,7 +483,6 @@
    
    st->oldBandE = (celt_word16_t*)celt_alloc(C*mode->nbEBands*sizeof(celt_word16_t));
 
-   st->preemph = QCONST16(0.8f,15);
    st->preemph_memD = (celt_sig_t*)celt_alloc(C*sizeof(celt_sig_t));;
 
    st->last_pitch_index = 0;
@@ -544,7 +541,7 @@
          for (j=0;j<N;j++)
          {
             celt_sig_t tmp = ADD32(st->out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c],
-                                   MULT16_32_Q15(st->preemph,st->preemph_memD[c]));
+                                   MULT16_32_Q15(preemph,st->preemph_memD[c]));
             st->preemph_memD[c] = tmp;
             pcm[C*i*N+C*j+c] = SIG2INT16(tmp);
          }
@@ -652,7 +649,7 @@
          for (j=0;j<N;j++)
          {
             celt_sig_t tmp = ADD32(st->out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c],
-                                   MULT16_32_Q15(st->preemph,st->preemph_memD[c]));
+                                   MULT16_32_Q15(preemph,st->preemph_memD[c]));
             st->preemph_memD[c] = tmp;
             pcm[C*i*N+C*j+c] = SIG2INT16(tmp);
          }