ref: 8143be30263bfa23276e4a7e9c5b2428b455174e
parent: b726185d5b07e36a6cf98a51097349a3d00bcd43
author: Jean-Marc Valin <[email protected]>
date: Fri Dec 7 11:40:39 EST 2007
energy decoding partially done (cheating a bit)
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -42,7 +42,6 @@
#define MAX_PERIOD 1024
/* This is only for cheating until the decoder is complete */
-float cheating_ebands[100];
float cheating_pitch_gains[100];
@@ -227,7 +226,7 @@
normalise_bands(st->mode, P, bandEp);
}
- quant_energy(st->mode, bandE, st->oldBandE);
+ quant_energy(st->mode, bandE, st->oldBandE, &st->enc);
/* Pitch prediction */
compute_pitch_gain(st->mode, X, P, gains, bandE);
@@ -234,8 +233,6 @@
//quantise_pitch(gains, PBANDS);
pitch_quant_bands(st->mode, X, P, gains);
- for (i=0;i<st->mode->nbEBands;i++)
- cheating_ebands[i] = bandE[i];
for (i=0;i<st->mode->nbPBands;i++)
cheating_pitch_gains[i] = gains[i];
@@ -401,9 +398,8 @@
ec_dec_init(&dec,&buf);
/* Get band energies */
- for (i=0;i<st->mode->nbEBands;i++)
- bandE[i] = cheating_ebands[i];
-
+ unquant_energy(st->mode, bandE, st->oldBandE, &dec);
+
/* Get the pitch index */
pitch_index = ec_dec_uint(&dec, MAX_PERIOD-(B+1)*N);;
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -33,7 +33,9 @@
#include "quant_bands.h"
#include <math.h>
-void quant_energy(CELTMode *m, float *eBands, float *oldEBands)
+int dummy_qi[100];
+
+void quant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
{
int i;
float prev = 0;
@@ -49,6 +51,7 @@
res = .25f*(i+3.f);
//res = 1;
qi = (int)floor(.5+(x-pred-prev)/res);
+ dummy_qi[i] = qi;
q = qi*res;
//printf("%f %f ", pred+prev+q, x);
@@ -64,4 +67,29 @@
//printf ("\n");
}
-
+void unquant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_dec *dec)
+{
+ int i;
+ float prev = 0;
+ for (i=0;i<m->nbEBands;i++)
+ {
+ int qi;
+ float q;
+ float res;
+ float pred = .7*oldEBands[i];
+
+ res = .25f*(i+3.f);
+ qi = dummy_qi[i];
+ q = qi*res;
+
+ //printf("%f %f ", pred+prev+q, x);
+ //printf("%d ", qi);
+ //printf("%f ", x-pred-prev);
+
+ oldEBands[i] = pred+prev+q;
+ eBands[i] = pow(10, .05*oldEBands[i])-.3;
+ if (eBands[i] < 0)
+ eBands[i] = 0;
+ prev = (prev + .5*q);
+ }
+}
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -33,8 +33,11 @@
#define QUANT_BANDS
#include "modes.h"
+#include "entenc.h"
+#include "entdec.h"
-void quant_energy(CELTMode *m, float *eBands, float *oldEBands);
+void quant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc);
+void unquant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_dec *dec);
#endif /* QUANT_BANDS */