Re-ordered the parameters in the stream: [energy, pitch index, pitch gains]

Also fixed a bug that was exposed by the change (and removed some warnings)
This commit is contained in:
Jean-Marc Valin 2008-02-11 16:44:48 +11:00
parent 6c1f604944
commit cb7a2a3d52
9 changed files with 18 additions and 16 deletions

View file

@ -258,7 +258,6 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
} }
} }
find_spectral_pitch(st->fft, &st->psy, in, st->out_mem, MAX_PERIOD, (B+1)*N, C, &pitch_index); find_spectral_pitch(st->fft, &st->psy, in, st->out_mem, MAX_PERIOD, (B+1)*N, C, &pitch_index);
ec_enc_uint(&st->enc, pitch_index, MAX_PERIOD-(B+1)*N);
/* Compute MDCTs of the pitch part */ /* Compute MDCTs of the pitch part */
compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, P, N, B, C); compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, P, N, B, C);
@ -298,6 +297,9 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
/* Pitch prediction */ /* Pitch prediction */
compute_pitch_gain(st->mode, X, P, gains, bandE); compute_pitch_gain(st->mode, X, P, gains, bandE);
quant_pitch(gains, st->mode->nbPBands, &st->enc); quant_pitch(gains, st->mode->nbPBands, &st->enc);
ec_enc_uint(&st->enc, pitch_index, MAX_PERIOD-(B+1)*N);
pitch_quant_bands(st->mode, X, P, gains); pitch_quant_bands(st->mode, X, P, gains);
//for (i=0;i<B*N;i++) printf("%f ",P[i]);printf("\n"); //for (i=0;i<B*N;i++) printf("%f ",P[i]);printf("\n");
@ -509,7 +511,7 @@ static void celt_decode_lost(CELTDecoder *st, short *pcm)
} }
} }
int celt_decode(CELTDecoder *st, char *data, int len, celt_int16_t *pcm) int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm)
{ {
int i, c, N, B, C; int i, c, N, B, C;
N = st->block_size; N = st->block_size;
@ -533,18 +535,21 @@ int celt_decode(CELTDecoder *st, char *data, int len, celt_int16_t *pcm)
ec_byte_readinit(&buf,data,len); ec_byte_readinit(&buf,data,len);
ec_dec_init(&dec,&buf); ec_dec_init(&dec,&buf);
/* Get band energies */
unquant_energy(st->mode, bandE, st->oldBandE, &dec);
/* Get the pitch gains */
unquant_pitch(gains, st->mode->nbPBands, &dec);
/* Get the pitch index */ /* Get the pitch index */
pitch_index = ec_dec_uint(&dec, MAX_PERIOD-(B+1)*N); pitch_index = ec_dec_uint(&dec, MAX_PERIOD-(B+1)*N);
st->last_pitch_index = pitch_index; st->last_pitch_index = pitch_index;
/* Get band energies */
unquant_energy(st->mode, bandE, st->oldBandE, &dec);
/* Pitch MDCT */ /* Pitch MDCT */
compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, P, N, B, C); compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, P, N, B, C);
{ {
float bandEp[st->mode->nbEBands]; float bandEp[st->mode->nbEBands*C];
compute_band_energies(st->mode, P, bandEp); compute_band_energies(st->mode, P, bandEp);
normalise_bands(st->mode, P, bandEp); normalise_bands(st->mode, P, bandEp);
} }
@ -552,9 +557,6 @@ int celt_decode(CELTDecoder *st, char *data, int len, celt_int16_t *pcm)
if (C==2) if (C==2)
stereo_mix(st->mode, P, bandE, 1); stereo_mix(st->mode, P, bandE, 1);
/* Get the pitch gains */
unquant_pitch(gains, st->mode->nbPBands, &dec);
/* Apply pitch gains */ /* Apply pitch gains */
pitch_quant_bands(st->mode, X, P, gains); pitch_quant_bands(st->mode, X, P, gains);

View file

@ -70,7 +70,7 @@ CELTDecoder *celt_decoder_new(const CELTMode *mode);
void celt_decoder_destroy(CELTDecoder *st); void celt_decoder_destroy(CELTDecoder *st);
int celt_decode(CELTDecoder *st, char *data, int len, celt_int16_t *pcm); int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm);
/* Mode calls */ /* Mode calls */

View file

@ -39,7 +39,6 @@ static void kf_bfly2(
{ {
kiss_fft_cpx * Fout2; kiss_fft_cpx * Fout2;
kiss_fft_cpx * tw1; kiss_fft_cpx * tw1;
kiss_fft_cpx t;
int i,j; int i,j;
kiss_fft_cpx * Fout_beg = Fout; kiss_fft_cpx * Fout_beg = Fout;
for (i=0;i<N;i++) for (i=0;i<N;i++)

View file

@ -160,6 +160,9 @@ int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value)
case CELT_GET_NB_CHANNELS: case CELT_GET_NB_CHANNELS:
*value = mode->nbChannels; *value = mode->nbChannels;
break; break;
default:
return CELT_BAD_ARG;
} }
return CELT_OK;
} }

View file

@ -1,8 +1,8 @@
float pgain_table[1024] = { float pgain_table[1024] = {
0., 0., 0., 0., 0., 0., 0., 0.,
0.0787638, 0.0502377, 0.0370167, 0.0322025, 0.356783, 0.0669546, 0.0574281, 0.0260472, 0.0787638, 0.0502377, 0.0370167, 0.0322025, 0.356783, 0.0669546, 0.0574281, 0.0260472,
0.5126, 0.499592, 0.460184, 0.032245, 0.0312514, 0.0289121, 0.0265145, 0.0207962, 0.5126, 0.499592, 0.460184, 0.032245, 0.0312514, 0.0289121, 0.0265145, 0.0207962,
0.373555, 0.468631, 0.0241895, 0.0194926, 0.0256133, 0.0238522, 0.0211873, 0.0148774, 0.373555, 0.468631, 0.0241895, 0.0194926, 0.0256133, 0.0238522, 0.0211873, 0.0148774,
0.00139974, 0.000760276, 0.00107237, 0.00095473, 0.00115105, 0.001434, 0.00173201, 0.00274601,
0.513634, 0.467355, 0.255641, 0.091945, 0.319676, 0.0593489, 0.0488637, 0.02425, 0.513634, 0.467355, 0.255641, 0.091945, 0.319676, 0.0593489, 0.0488637, 0.02425,
0.297209, 0.0228254, 0.189478, 0.0192015, 0.0263458, 0.0241322, 0.0262124, 0.015507, 0.297209, 0.0228254, 0.189478, 0.0192015, 0.0263458, 0.0241322, 0.0262124, 0.015507,
0.0575023, 0.297549, 0.022103, 0.0219353, 0.0442874, 0.043595, 0.0413361, 0.0220558, 0.0575023, 0.297549, 0.022103, 0.0219353, 0.0442874, 0.043595, 0.0413361, 0.0220558,

View file

@ -135,7 +135,6 @@ void compute_mdct_masking(struct PsyDecay *decay, float *X, float *mask, int len
{ {
int i; int i;
float psd[len]; float psd[len];
float mem;
for (i=0;i<len;i++) for (i=0;i<len;i++)
mask[i] = X[i]*X[i]; mask[i] = X[i]*X[i];
for (i=1;i<len-1;i++) for (i=1;i<len-1;i++)

View file

@ -101,7 +101,6 @@ static void unquant_energy_mono(const CELTMode *m, float *eBands, float *oldEBan
int i; int i;
float prev = 0; float prev = 0;
float coef = m->ePredCoef; float coef = m->ePredCoef;
float error[m->nbEBands];
/* The .7 is a heuristic */ /* The .7 is a heuristic */
float beta = .7*coef; float beta = .7*coef;
for (i=0;i<m->nbEBands;i++) for (i=0;i<m->nbEBands;i++)

View file

@ -192,7 +192,6 @@ int vec_bits2pulses(const struct alloc_data *alloc, const int *bands, int *bits,
for (i=0;i<len;i++) for (i=0;i<len;i++)
{ {
int N = (bands[i+1]-bands[i])*BC;
pulses[i] = bits2pulses(alloc, i, bits[i]); pulses[i] = bits2pulses(alloc, i, bits[i]);
sum += alloc->bits[i][pulses[i]]; sum += alloc->bits[i][pulses[i]];
} }

View file

@ -34,6 +34,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <string.h>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -46,7 +47,7 @@ int main(int argc, char *argv[])
int len; int len;
celt_int32_t frame_size, channels; celt_int32_t frame_size, channels;
int bytes_per_packet; int bytes_per_packet;
char data[1024]; unsigned char data[1024];
double rmsd = 0; double rmsd = 0;
int count = 0; int count = 0;