Skip to content
Snippets Groups Projects
Commit e38c7c18 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Energy is now Laplace-encoded (very poorly for now)

parent 8143be30
No related branches found
No related tags found
No related merge requests found
......@@ -397,12 +397,12 @@ int celt_decode(CELTDecoder *st, char *data, int len, short *pcm)
ec_byte_readinit(&buf,data,len);
ec_dec_init(&dec,&buf);
/* Get band energies */
unquant_energy(st->mode, bandE, st->oldBandE, &dec);
/* Get the pitch index */
pitch_index = ec_dec_uint(&dec, MAX_PERIOD-(B+1)*N);;
/* Get band energies */
unquant_energy(st->mode, bandE, st->oldBandE, &dec);
/* Pitch MDCT */
compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index, P, N, B);
......
......@@ -31,10 +31,9 @@
#include "quant_bands.h"
#include "laplace.h"
#include <math.h>
int dummy_qi[100];
void quant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
{
int i;
......@@ -51,11 +50,14 @@ void quant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
res = .25f*(i+3.f);
//res = 1;
qi = (int)floor(.5+(x-pred-prev)/res);
dummy_qi[i] = qi;
/*if (qi > 40)
qi = 40;
if (qi < -40)
qi = -40;*/
ec_laplace_encode(enc, qi, 15000);
q = qi*res;
//printf("%f %f ", pred+prev+q, x);
//printf("%d ", qi);
//printf("%f ", x-pred-prev);
oldEBands[i] = pred+prev+q;
......@@ -79,9 +81,8 @@ void unquant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_dec *dec)
float pred = .7*oldEBands[i];
res = .25f*(i+3.f);
qi = dummy_qi[i];
qi = ec_laplace_decode(dec, 15000);
q = qi*res;
//printf("%f %f ", pred+prev+q, x);
//printf("%d ", qi);
//printf("%f ", x-pred-prev);
......@@ -92,4 +93,5 @@ void unquant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_dec *dec)
eBands[i] = 0;
prev = (prev + .5*q);
}
//printf ("\n");
}
......@@ -7,4 +7,4 @@ bin_PROGRAMS = ectest
ectest_SOURCES = ectest.c
ectest_LDADD = $(top_builddir)/libentcode/libentcode.la
noinst_HEADERS = bitrdec.h bitree.h bitrenc.h ecintrin.h entcode.h entdec.h \
entenc.h mfrngcod.h probdec.h probenc.h probmod.h
entenc.h laplace.h mfrngcod.h probdec.h probenc.h probmod.h
......@@ -33,7 +33,7 @@
#include "entdec.h"
#include <stdio.h>
int ec_laplace_get_total(int decay)
static int ec_laplace_get_total(int decay)
{
return (1<<30)/((1<<14) - decay) - (1<<15) + 1;
}
......@@ -52,8 +52,17 @@ void ec_laplace_encode(ec_enc *enc, int value, int decay)
fs = 1<<15;
for (i=0;i<value;i++)
{
int tmp_l, tmp_s;
tmp_l = fl;
tmp_s = fs;
fl += fs*2;
fs = (fs*decay)>>14;
if (fs == 0)
{
fs = tmp_s;
fl = tmp_l;
break;
}
}
if (fl < 0)
fl = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment