shithub: opus

Download patch

ref: c4a40c65c5a5bdf691da5b620c72b4fe611a34bf
parent: 6441379e5783e0a7e55978868b4b0ebc1d67ea2a
author: Jean-Marc Valin <[email protected]>
date: Wed Mar 5 18:22:00 EST 2008

doing spreading function and gain quantisation in-place

--- a/libcelt/psy.c
+++ b/libcelt/psy.c
@@ -129,19 +129,14 @@
 void compute_masking(struct PsyDecay *decay, celt_word16_t *X, celt_mask_t *mask, int len)
 {
    int i;
-   VARDECL(celt_word32_t *psd);
    int N;
-   SAVE_STACK;
    N=len/2;
-   ALLOC(psd, N, celt_word32_t);
-   psd[0] = MULT16_16(X[0], X[0]);
+   mask[0] = MULT16_16(X[0], X[0]);
    for (i=1;i<N;i++)
-      psd[i] = ADD32(MULT16_16(X[i*2], X[i*2]),
-                     MULT16_16(X[i*2+1], X[i*2+1]));
+      mask[i] = ADD32(MULT16_16(X[i*2], X[i*2]), MULT16_16(X[i*2+1], X[i*2+1]));
    /* TODO: Do tone masking */
    /* Noise masking */
-   spreading_func(decay, psd, mask, N);
-   RESTORE_STACK;  
+   spreading_func(decay, mask, mask, N);
 }
 
 #if 0 /* Not needed for now, but will be useful in the future */
--- a/libcelt/quant_pitch.c
+++ b/libcelt/quant_pitch.c
@@ -86,17 +86,14 @@
 int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc)
 {
    int i, id;
-   VARDECL(celt_pgain_t *g2);
-   SAVE_STACK;
-   ALLOC(g2, len, celt_pgain_t);
    /*for (i=0;i<len;i++) printf ("%f ", gains[i]);printf ("\n");*/
+   /* Convert to a representation where the MSE criterion should be near-optimal */
    for (i=0;i<len;i++)
-      g2[i] = Q15ONE-celt_sqrt(Q1515ONE-MULT16_16(gains[i],gains[i]));
-   id = vq_index(g2, pgain_table, len, 128);
+      gains[i] = Q15ONE-celt_sqrt(Q1515ONE-MULT16_16(gains[i],gains[i]));
+   id = vq_index(gains, pgain_table, len, 128);
    ec_enc_uint(enc, id, 128);
    /*for (i=0;i<len;i++) printf ("%f ", pgain_table[id*len+i]);printf ("\n");*/
    id2gains(id, gains, len);
-   RESTORE_STACK;
    return id!=0;
 }