doing spreading function and gain quantisation in-place
This commit is contained in:
parent
6441379e57
commit
c4a40c65c5
2 changed files with 6 additions and 14 deletions
|
@ -129,19 +129,14 @@ static void spreading_func(struct PsyDecay *d, celt_word32_t *psd, celt_mask_t *
|
||||||
void compute_masking(struct PsyDecay *decay, celt_word16_t *X, celt_mask_t *mask, int len)
|
void compute_masking(struct PsyDecay *decay, celt_word16_t *X, celt_mask_t *mask, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
VARDECL(celt_word32_t *psd);
|
|
||||||
int N;
|
int N;
|
||||||
SAVE_STACK;
|
|
||||||
N=len/2;
|
N=len/2;
|
||||||
ALLOC(psd, N, celt_word32_t);
|
mask[0] = MULT16_16(X[0], X[0]);
|
||||||
psd[0] = MULT16_16(X[0], X[0]);
|
|
||||||
for (i=1;i<N;i++)
|
for (i=1;i<N;i++)
|
||||||
psd[i] = ADD32(MULT16_16(X[i*2], X[i*2]),
|
mask[i] = ADD32(MULT16_16(X[i*2], X[i*2]), MULT16_16(X[i*2+1], X[i*2+1]));
|
||||||
MULT16_16(X[i*2+1], X[i*2+1]));
|
|
||||||
/* TODO: Do tone masking */
|
/* TODO: Do tone masking */
|
||||||
/* Noise masking */
|
/* Noise masking */
|
||||||
spreading_func(decay, psd, mask, N);
|
spreading_func(decay, mask, mask, N);
|
||||||
RESTORE_STACK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* Not needed for now, but will be useful in the future */
|
#if 0 /* Not needed for now, but will be useful in the future */
|
||||||
|
|
|
@ -86,17 +86,14 @@ static void id2gains(int id, celt_pgain_t *gains, int len)
|
||||||
int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc)
|
int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc)
|
||||||
{
|
{
|
||||||
int i, id;
|
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");*/
|
/*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++)
|
for (i=0;i<len;i++)
|
||||||
g2[i] = Q15ONE-celt_sqrt(Q1515ONE-MULT16_16(gains[i],gains[i]));
|
gains[i] = Q15ONE-celt_sqrt(Q1515ONE-MULT16_16(gains[i],gains[i]));
|
||||||
id = vq_index(g2, pgain_table, len, 128);
|
id = vq_index(gains, pgain_table, len, 128);
|
||||||
ec_enc_uint(enc, id, 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++) printf ("%f ", pgain_table[id*len+i]);printf ("\n");*/
|
||||||
id2gains(id, gains, len);
|
id2gains(id, gains, len);
|
||||||
RESTORE_STACK;
|
|
||||||
return id!=0;
|
return id!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue