diff --git a/libcelt/bands.c b/libcelt/bands.c index 98c79336..0a3a17e0 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -31,6 +31,7 @@ #include #include "bands.h" +#include "modes.h" #include "vq.h" #include "cwrs.h" @@ -45,31 +46,35 @@ const int qpulses[NBANDS ] = {7, 5, 4, 4, 3, 3, 3, 4, 4, 4, -2, -1, -1, -1 int pbank[] = {0, 4, 8, 12, 20, WAVEFORM_END, 128}; /* Compute the energy in each of the bands */ -void compute_bands(float *X, int B, float *bank) +void compute_band_energies(const CELTMode *m, float *X, float *bank) { - int i; + int i, B; + const int *eBands = m->eBands; + B = m->nbMdctBlocks; for (i=0;ieBands; + B = m->nbMdctBlocks; for (i=0;imdctSize; + B = mode->nbMdctBlocks; CELTState *st = celt_alloc(sizeof(CELTState)); - st->frame_size = blockSize * blocksPerFrame; - st->block_size = blockSize; - st->nb_blocks = blocksPerFrame; + st->mode = mode; + st->frame_size = B*N; + st->block_size = N; + st->nb_blocks = B; mdct_init(&st->mdct_lookup, 2*N); st->fft = spx_fft_init(MAX_PERIOD); @@ -197,11 +199,12 @@ int celt_encode(CELTState *st, short *pcm) //haar1(P, B*N); /* Band normalisation */ - compute_bands(X, B, bandE); - normalise_bands(X, B, bandE); + compute_band_energies(st->mode, X, bandE); + normalise_bands(st->mode, X, bandE); - compute_bands(P, B, bandEp); - normalise_bands(P, B, bandEp); + //for (i=0;imode, P, bandEp); + normalise_bands(st->mode, P, bandEp); /* Pitch prediction */ compute_pitch_gain(X, B, P, gains, bandE); diff --git a/libcelt/celt.h b/libcelt/celt.h index db1b9d4a..d9a75d65 100644 --- a/libcelt/celt.h +++ b/libcelt/celt.h @@ -35,9 +35,12 @@ struct CELTState_; typedef struct CELTState_ CELTState; +struct CELTMode_; +typedef struct CELTMode_ CELTMode; +extern const CELTMode const *celt_mode1; -CELTState *celt_encoder_new(int blockSize, int blocksPerFrame); +CELTState *celt_encoder_new(const CELTMode *mode); void celt_encoder_destroy(CELTState *st); diff --git a/libcelt/modes.c b/libcelt/modes.c index 942b9195..f915a2b5 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -55,3 +55,5 @@ const CELTMode mode1 = { pbank1, /**< pBands*/ qpulses1 /**< pulses */ }; + +const CELTMode const *celt_mode1 = &mode1; diff --git a/libcelt/modes.h b/libcelt/modes.h index 44cd563a..76de37f7 100644 --- a/libcelt/modes.h +++ b/libcelt/modes.h @@ -32,7 +32,9 @@ #ifndef MODES_H #define MODES_H -typedef struct { +#include "celt.h" + +struct CELTMode_ { int frameSize; int mdctSize; int nbMdctBlocks; @@ -44,6 +46,6 @@ typedef struct { const int *eBands; const int *pBands; const int *pulses; -} CELTMode; +}; #endif diff --git a/libcelt/testcelt.c b/libcelt/testcelt.c index 010db915..23403dcf 100644 --- a/libcelt/testcelt.c +++ b/libcelt/testcelt.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) outFile = argv[2]; fout = fopen(outFile, "wb+"); - st = celt_encoder_new(FRAME_SIZE/NBLOCKS, NBLOCKS); + st = celt_encoder_new(celt_mode1); while (!feof(fin)) {