Commit b76ee706 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Allocation cache can now be pre-computed as well.

parent 5588d52e
......@@ -36,6 +36,7 @@
#include <stdio.h>
#include "modes.h"
#include "celt.h"
#include "rate.h"
#define INT16 "%d"
#define INT32 "%d"
......@@ -53,12 +54,13 @@
void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
{
int i, j;
fprintf(file, "#include \"modes.h\"\n");
fprintf(file, "#include \"rate.h\"\n");
fprintf(file, "\n");
for (i=0;i<nb_modes;i++)
{
CELTMode *mode = modes[i];
fprintf(file, "#include \"modes.h\"\n");
fprintf(file, "\n");
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);
......@@ -112,6 +114,25 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, "#endif\n");
fprintf(file, "\n");
fprintf(file, "#ifndef DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf(file, "#define DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
for (j=0;j<mode->nbEBands;j++)
{
int k;
fprintf (file, "const int 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");
}
fprintf (file, "const int *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);
}
fprintf (file, "};\n");
fprintf(file, "#endif\n");
fprintf(file, "\n");
fprintf(file, "CELTMode mode%d_%d_%d_%d = {\n", mode->Fs, mode->nbChannels, mode->mdctSize, mode->overlap);
fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
......@@ -128,7 +149,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, WORD16 ",\t/* ePredCoef */\n", mode->ePredCoef);
fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
fprintf(file, "allocVectors%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize);
fprintf(file, "0,\t/* bits */\n");
fprintf(file, "allocCache%d_%d_%d,\t/* bits */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf(file, "{%d, 0, 0},\t/* mdct */\n", 2*mode->mdctSize);
fprintf(file, "window%d,\t/* window */\n", mode->overlap);
fprintf(file, "{psy_decayR_%d},\t/* psy */\n", mode->Fs);
......@@ -144,10 +165,10 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
CELTMode *mode = modes[i];
fprintf(file, "&mode%d_%d_%d_%d,\n", mode->Fs, mode->nbChannels, mode->mdctSize, mode->overlap);
}
fprintf(file, "};\n");
fprintf(file, "};\n");
}
#if 1
#if 0
int main()
{
CELTMode *m[3];
......
......@@ -304,13 +304,14 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int lo
#endif
mode->window = window;
compute_alloc_cache(mode);
psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs);
mode->marker_start = MODEVALID;
mode->marker_end = MODEVALID;
#endif
#endif /* !STATIC_MODES */
mdct_init(&mode->mdct, 2*mode->mdctSize);
compute_alloc_cache(mode);
if (error)
*error = CELT_OK;
return mode;
......
......@@ -46,8 +46,7 @@
#define BITROUND 8
#define BITOVERFLOW 10000
#define MAX_PULSES 64
#ifndef STATIC_MODES
static int log2_frac(ec_uint32 val, int frac)
{
int i;
......@@ -151,6 +150,7 @@ void compute_alloc_cache(CELTMode *m)
m->bits = (const int * const *)bits;
}
#endif /* !STATIC_MODES */
int bits2pulses(const CELTMode *m, int band, int bits)
{
......
......@@ -32,6 +32,8 @@
#ifndef RATE_H
#define RATE_H
#define MAX_PULSES 64
/** Computes a cache of the pulses->bits mapping in each band */
void compute_alloc_cache(CELTMode *m);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment