ref: db0141e76600b1f337a39b5345afc48474151c1a
parent: 6a0d97ebbc5d9147a1a6857df07a1a3e26b06855
author: Jean-Marc Valin <[email protected]>
date: Mon Mar 10 12:37:37 EDT 2008
Changed some of the mode data from int to celt_int16_t to save memory.
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -79,7 +79,7 @@
void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank)
{
int i, c, B, C;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
B = m->nbMdctBlocks;
C = m->nbChannels;
for (c=0;c<C;c++)
@@ -112,7 +112,7 @@
void normalise_bands(const CELTMode *m, const celt_sig_t *freq, celt_norm_t *X, const celt_ener_t *bank)
{
int i, c, B, C;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
B = m->nbMdctBlocks;
C = m->nbChannels;
for (c=0;c<C;c++)
@@ -155,7 +155,7 @@
void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank)
{
int i, c, B, C;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
B = m->nbMdctBlocks;
C = m->nbChannels;
for (c=0;c<C;c++)
@@ -177,7 +177,7 @@
void normalise_bands(const CELTMode *m, const celt_sig_t *freq, celt_norm_t *X, const celt_ener_t *bank)
{
int i, c, B, C;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
B = m->nbMdctBlocks;
C = m->nbChannels;
for (c=0;c<C;c++)
@@ -209,7 +209,7 @@
void denormalise_bands(const CELTMode *m, const celt_norm_t *X, celt_sig_t *freq, const celt_ener_t *bank)
{
int i, c, B, C;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
B = m->nbMdctBlocks;
C = m->nbChannels;
if (C>2)
@@ -233,7 +233,7 @@
void compute_pitch_gain(const CELTMode *m, const celt_norm_t *X, const celt_norm_t *P, celt_pgain_t *gains)
{
int i, B;
- const int *pBands = m->pBands;
+ const celt_int16_t *pBands = m->pBands;
B = m->nbMdctBlocks*m->nbChannels;
for (i=0;i<m->nbPBands;i++)
@@ -271,7 +271,7 @@
void pitch_quant_bands(const CELTMode *m, celt_norm_t *P, const celt_pgain_t *gains)
{
int i, B;
- const int *pBands = m->pBands;
+ const celt_int16_t *pBands = m->pBands;
B = m->nbMdctBlocks*m->nbChannels;
for (i=0;i<m->nbPBands;i++)
{
@@ -289,7 +289,7 @@
void quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_mask_t *W, int total_bits, ec_enc *enc)
{
int i, j, B, bits;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
celt_word16_t alpha;
VARDECL(celt_norm_t *norm);
VARDECL(int *pulses);
@@ -353,7 +353,7 @@
void unquant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, int total_bits, ec_dec *dec)
{
int i, j, B, bits;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
celt_word16_t alpha;
VARDECL(celt_norm_t *norm);
VARDECL(int *pulses);
@@ -410,7 +410,7 @@
void stereo_mix(const CELTMode *m, celt_norm_t *X, const celt_ener_t *bank, int dir)
{
int i, B, C;
- const int *eBands = m->eBands;
+ const celt_int16_t *eBands = m->eBands;
B = m->nbMdctBlocks;
C = m->nbChannels;
for (i=0;i<m->nbEBands;i++)
--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -63,7 +63,7 @@
CELTMode *mode = modes[i];
fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize);
- fprintf (file, "const int eBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands+2);
+ fprintf (file, "const celt_int16_t eBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands+2);
for (j=0;j<mode->nbEBands+2;j++)
fprintf (file, "%d, ", mode->eBands[j]);
fprintf (file, "};\n");
@@ -73,7 +73,7 @@
fprintf(file, "#ifndef DEF_PBANDS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf(file, "#define DEF_PBANDS%d_%d\n", mode->Fs, mode->mdctSize);
- fprintf (file, "const int pBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbPBands+2);
+ fprintf (file, "const celt_int16_t pBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbPBands+2);
for (j=0;j<mode->nbPBands+2;j++)
fprintf (file, "%d, ", mode->pBands[j]);
printf ("};\n");
@@ -102,7 +102,7 @@
fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
- fprintf (file, "const int allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
+ fprintf (file, "const celt_int16_t allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
for (j=0;j<mode->nbAllocVectors;j++)
{
int k;
@@ -121,7 +121,7 @@
int k;
if (j==0 || (mode->bits[j] != mode->bits[j-1]))
{
- fprintf (file, "const int allocCache_band%d_%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize, mode->nbChannels);
+ fprintf (file, "const celt_int16_t allocCache_band%d_%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize, mode->nbChannels);
for (k=0;k<MAX_PULSES;k++)
fprintf (file, "%2d, ", mode->bits[j][k]);
fprintf (file, "};\n");
@@ -129,7 +129,7 @@
fprintf (file, "#define allocCache_band%d_%d_%d_%d allocCache_band%d_%d_%d_%d\n", j, mode->Fs, mode->mdctSize, mode->nbChannels, j-1, mode->Fs, mode->mdctSize, mode->nbChannels);
}
}
- fprintf (file, "const int *allocCache%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands);
+ fprintf (file, "const celt_int16_t *allocCache%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands);
for (j=0;j<mode->nbEBands;j++)
{
fprintf (file, "allocCache_band%d_%d_%d_%d, ", j, mode->Fs, mode->mdctSize, mode->nbChannels);
@@ -173,7 +173,7 @@
fprintf(file, "};\n");
}
-#if 0
+#if 1
int main()
{
CELTMode *m[3];
@@ -180,7 +180,7 @@
m[0] = celt_mode_create(44100, 1, 256, 128, NULL);
m[1] = celt_mode_create(48000, 1, 256, 128, NULL);
m[2] = celt_mode_create(51200, 1, 256, 128, NULL);
- dump_modes(stdout, m, 3);
+ dump_modes(stdout, m, 1);
return 0;
}
#endif
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -103,9 +103,9 @@
};
-static int *compute_ebands(celt_int32_t Fs, int frame_size, int *nbEBands)
+static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int *nbEBands)
{
- int *eBands;
+ celt_int16_t *eBands;
int i, res, min_width, lin, low, high;
res = (Fs+frame_size)/(2*frame_size);
min_width = MIN_BINS*res;
@@ -120,7 +120,7 @@
low = ((bark_freq[lin]/res)+(MIN_BINS-1))/MIN_BINS;
high = BARK_BANDS-lin;
*nbEBands = low+high;
- eBands = celt_alloc(sizeof(int)*(*nbEBands+2));
+ eBands = celt_alloc(sizeof(celt_int16_t)*(*nbEBands+2));
/* Linear spacing (min_width) */
for (i=0;i<low;i++)
@@ -147,8 +147,8 @@
static void compute_pbands(CELTMode *mode, int res)
{
int i;
- int *pBands;
- pBands=celt_alloc(sizeof(int)*(PBANDS+2));
+ celt_int16_t *pBands;
+ pBands=celt_alloc(sizeof(celt_int16_t)*(PBANDS+2));
mode->nbPBands = PBANDS;
for (i=0;i<PBANDS+1;i++)
{
@@ -183,10 +183,10 @@
static void compute_allocation_table(CELTMode *mode, int res)
{
int i, j, eband;
- int *allocVectors;
+ celt_int16_t *allocVectors;
mode->nbAllocVectors = BITALLOC_SIZE;
- allocVectors = celt_alloc(sizeof(int)*(BITALLOC_SIZE*mode->nbEBands));
+ allocVectors = celt_alloc(sizeof(celt_int16_t)*(BITALLOC_SIZE*mode->nbEBands));
for (i=0;i<BITALLOC_SIZE;i++)
{
eband = 0;
@@ -321,7 +321,7 @@
{
#ifndef STATIC_MODES
int i;
- const int *prevPtr = NULL;
+ const celt_int16_t *prevPtr = NULL;
for (i=0;i<mode->nbEBands;i++)
{
if (mode->bits[i] != prevPtr)
--- a/libcelt/modes.h
+++ b/libcelt/modes.h
@@ -55,15 +55,15 @@
int nbPBands;
int pitchEnd;
- const int *eBands; /**< Definition for each "pseudo-critical band" */
- const int *pBands; /**< Definition of the bands used for the pitch */
+ const celt_int16_t *eBands; /**< Definition for each "pseudo-critical band" */
+ const celt_int16_t *pBands; /**< Definition of the bands used for the pitch */
celt_word16_t ePredCoef;/**< Prediction coefficient for the energy encoding */
int nbAllocVectors; /**< Number of lines in the matrix below */
- const int *allocVectors; /**< Number of bits in each band for several rates */
+ const celt_int16_t *allocVectors; /**< Number of bits in each band for several rates */
- const int * const *bits; /**< Cache for pulses->bits mapping in each band */
+ const celt_int16_t * const *bits; /**< Cache for pulses->bits mapping in each band */
/* Stuff that could go in the {en,de}coder, but we save space this way */
mdct_lookup mdct;
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -98,10 +98,10 @@
void compute_alloc_cache(CELTMode *m)
{
int i, prevN, BC;
- int **bits;
- const int *eBands = m->eBands;
+ celt_int16_t **bits;
+ const celt_int16_t *eBands = m->eBands;
- bits = celt_alloc(m->nbEBands*sizeof(int*));
+ bits = celt_alloc(m->nbEBands*sizeof(celt_int16_t*));
BC = m->nbMdctBlocks*m->nbChannels;
prevN = -1;
@@ -114,7 +114,7 @@
} else {
int j;
/* FIXME: We could save memory here */
- bits[i] = celt_alloc(MAX_PULSES*sizeof(int));
+ bits[i] = celt_alloc(MAX_PULSES*sizeof(celt_int16_t));
for (j=0;j<MAX_PULSES;j++)
{
int done = 0;
@@ -147,7 +147,7 @@
prevN = N;
}
}
- m->bits = (const int * const *)bits;
+ m->bits = (const celt_int16_t * const *)bits;
}
#endif /* !STATIC_MODES */