Energy is now Laplace-encoded (very poorly for now)
This commit is contained in:
parent
8143be3026
commit
e38c7c18f7
4 changed files with 22 additions and 11 deletions
|
@ -397,12 +397,12 @@ int celt_decode(CELTDecoder *st, char *data, int len, short *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 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);;
|
||||||
|
|
||||||
|
/* 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, P, N, B);
|
compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index, P, N, B);
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,9 @@
|
||||||
|
|
||||||
|
|
||||||
#include "quant_bands.h"
|
#include "quant_bands.h"
|
||||||
|
#include "laplace.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
int dummy_qi[100];
|
|
||||||
|
|
||||||
void quant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
|
void quant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -51,11 +50,14 @@ void quant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
|
||||||
res = .25f*(i+3.f);
|
res = .25f*(i+3.f);
|
||||||
//res = 1;
|
//res = 1;
|
||||||
qi = (int)floor(.5+(x-pred-prev)/res);
|
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;
|
q = qi*res;
|
||||||
|
|
||||||
//printf("%f %f ", pred+prev+q, x);
|
//printf("%f %f ", pred+prev+q, x);
|
||||||
//printf("%d ", qi);
|
|
||||||
//printf("%f ", x-pred-prev);
|
//printf("%f ", x-pred-prev);
|
||||||
|
|
||||||
oldEBands[i] = pred+prev+q;
|
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];
|
float pred = .7*oldEBands[i];
|
||||||
|
|
||||||
res = .25f*(i+3.f);
|
res = .25f*(i+3.f);
|
||||||
qi = dummy_qi[i];
|
qi = ec_laplace_decode(dec, 15000);
|
||||||
q = qi*res;
|
q = qi*res;
|
||||||
|
|
||||||
//printf("%f %f ", pred+prev+q, x);
|
//printf("%f %f ", pred+prev+q, x);
|
||||||
//printf("%d ", qi);
|
//printf("%d ", qi);
|
||||||
//printf("%f ", x-pred-prev);
|
//printf("%f ", x-pred-prev);
|
||||||
|
@ -92,4 +93,5 @@ void unquant_energy(CELTMode *m, float *eBands, float *oldEBands, ec_dec *dec)
|
||||||
eBands[i] = 0;
|
eBands[i] = 0;
|
||||||
prev = (prev + .5*q);
|
prev = (prev + .5*q);
|
||||||
}
|
}
|
||||||
|
//printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,4 @@ bin_PROGRAMS = ectest
|
||||||
ectest_SOURCES = ectest.c
|
ectest_SOURCES = ectest.c
|
||||||
ectest_LDADD = $(top_builddir)/libentcode/libentcode.la
|
ectest_LDADD = $(top_builddir)/libentcode/libentcode.la
|
||||||
noinst_HEADERS = bitrdec.h bitree.h bitrenc.h ecintrin.h entcode.h entdec.h \
|
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 "entdec.h"
|
||||||
#include <stdio.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;
|
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;
|
fs = 1<<15;
|
||||||
for (i=0;i<value;i++)
|
for (i=0;i<value;i++)
|
||||||
{
|
{
|
||||||
|
int tmp_l, tmp_s;
|
||||||
|
tmp_l = fl;
|
||||||
|
tmp_s = fs;
|
||||||
fl += fs*2;
|
fl += fs*2;
|
||||||
fs = (fs*decay)>>14;
|
fs = (fs*decay)>>14;
|
||||||
|
if (fs == 0)
|
||||||
|
{
|
||||||
|
fs = tmp_s;
|
||||||
|
fl = tmp_l;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (fl < 0)
|
if (fl < 0)
|
||||||
fl = 0;
|
fl = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue