Commit 2805a14e authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

fixed-point: celt_pgain_t now a 16-bit value (Q15)

parent 5f09ea56
......@@ -54,19 +54,19 @@ typedef celt_int32_t celt_word32_t;
typedef celt_word32_t celt_sig_t;
typedef celt_word16_t celt_norm_t;
typedef celt_word32_t celt_ener_t;
typedef float celt_pgain_t;
typedef celt_word16_t celt_pgain_t;
typedef float celt_mask_t;
#define Q15ONE 32767
#define SIG_SCALING 16384.f
#define SIG_SCALING_1 0.000061035
#define SIG_SCALING_1 (1.f/16384.f)
#define NORM_SCALING 16384.f
#define NORM_SCALING_1 0.000061035
#define NORM_SCALING_1 (1.f/16384.f)
#define ENER_SCALING 16384.f
#define ENER_SCALING_1 0.000061035
#define PGAIN_SCALING 1.f
#define PGAIN_SCALING_1 1.f
#define ENER_SCALING_1 (1.f/16384.f)
#define PGAIN_SCALING 32768.f
#define PGAIN_SCALING_1 (1.f/32768.f)
#define VERY_SMALL 0
#define VERY_LARGE32 ((celt_word32_t)2147483647)
......
......@@ -178,7 +178,7 @@ void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_
gain = 0.0f;
/* We need to be a bit conservative, otherwise residual doesn't quantise well */
gain *= .9f;
gains[i] = gain;
gains[i] = PGAIN_SCALING*gain;
/*printf ("%f ", 1-sqrt(1-gain*gain));*/
}
/*if(rand()%10==0)
......@@ -201,7 +201,7 @@ void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_p
{
int j;
for (j=B*pBands[i];j<B*pBands[i+1];j++)
P[j] *= gains[i];
P[j] *= PGAIN_SCALING_1*gains[i];
/*printf ("%f ", gain);*/
}
for (i=B*pBands[m->nbPBands];i<B*pBands[m->nbPBands+1];i++)
......
......@@ -69,12 +69,12 @@ int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc)
ALLOC(g2, len, float);
/*for (i=0;i<len;i++) printf ("%f ", gains[i]);printf ("\n");*/
for (i=0;i<len;i++)
g2[i] = 1-sqrt(1-gains[i]*gains[i]);
g2[i] = 1-sqrt(1-PGAIN_SCALING_1*PGAIN_SCALING_1*gains[i]*gains[i]);
id = vq_index(g2, 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");*/
for (i=0;i<len;i++)
gains[i] = (sqrt(1-(1-pgain_table[id*len+i])*(1-pgain_table[id*len+i])));
gains[i] = PGAIN_SCALING*(sqrt(1-(1-pgain_table[id*len+i])*(1-pgain_table[id*len+i])));
return id!=0;
}
......@@ -83,6 +83,6 @@ int unquant_pitch(celt_pgain_t *gains, int len, ec_dec *dec)
int i, id;
id = ec_dec_uint(dec, 128);
for (i=0;i<len;i++)
gains[i] = (sqrt(1-(1-pgain_table[id*len+i])*(1-pgain_table[id*len+i])));
gains[i] = PGAIN_SCALING*(sqrt(1-(1-pgain_table[id*len+i])*(1-pgain_table[id*len+i])));
return id!=0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment