Making use of dynamically generated modes by default

This commit is contained in:
Jean-Marc Valin 2008-02-18 16:27:49 +11:00
parent 65d57e6e96
commit 2ca8fc373c
3 changed files with 22 additions and 21 deletions

View file

@ -53,10 +53,13 @@ typedef struct CELTDecoder CELTDecoder;
typedef struct CELTMode CELTMode; typedef struct CELTMode CELTMode;
extern const CELTMode *celt_mono; /*extern const CELTMode *celt_mono;
extern const CELTMode *celt_stereo; extern const CELTMode *celt_stereo;
extern const CELTMode *celt_ld51; extern const CELTMode *celt_ld51;*/
#define celt_mono celt_mode_create(44100, 1, 256, 128)
#define celt_stereo celt_mode_create(44100, 2, 256, 128)
/* Encoder stuff */ /* Encoder stuff */
CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int overlap); CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int overlap);

View file

@ -103,8 +103,8 @@ static const CELTMode stereo_mode = {
bitalloc0, /**< allocVectors */ bitalloc0, /**< allocVectors */
}; };
const CELTMode const *celt_mono = &mono_mode; //const CELTMode const *celt_mono = &mono_mode;
const CELTMode const *celt_stereo = &stereo_mode; //const CELTMode const *celt_stereo = &stereo_mode;
#define NBANDS51 17 #define NBANDS51 17
@ -230,9 +230,9 @@ static int *compute_ebands(int Fs, int frame_size, int *nbEBands)
eBands[*nbEBands] = eBands[*nbEBands+1]; eBands[*nbEBands] = eBands[*nbEBands+1];
/* FIXME: Remove last band if too small */ /* FIXME: Remove last band if too small */
for (i=0;i<*nbEBands+2;i++) /*for (i=0;i<*nbEBands+2;i++)
printf("%d ", eBands[i]); printf("%d ", eBands[i]);
printf ("\n"); printf ("\n");*/
return eBands; return eBands;
} }
@ -265,9 +265,9 @@ static void compute_pbands(CELTMode *mode, int res)
pBands[i] = mode->eBands[j+1]; pBands[i] = mode->eBands[j+1];
} }
} }
for (i=0;i<mode->nbPBands+2;i++) /*for (i=0;i<mode->nbPBands+2;i++)
printf("%d ", pBands[i]); printf("%d ", pBands[i]);
printf ("\n"); printf ("\n");*/
mode->pBands = pBands; mode->pBands = pBands;
mode->pitchEnd = pBands[PBANDS]; mode->pitchEnd = pBands[PBANDS];
} }
@ -301,12 +301,12 @@ static void compute_allocation_table(CELTMode *mode, int res)
} }
} }
} }
for (i=0;i<BITALLOC_SIZE;i++) /*for (i=0;i<BITALLOC_SIZE;i++)
{ {
for (j=0;j<mode->nbEBands;j++) for (j=0;j<mode->nbEBands;j++)
printf ("%2d ", allocVectors[i*mode->nbEBands+j]); printf ("%2d ", allocVectors[i*mode->nbEBands+j]);
printf ("\n"); printf ("\n");
} }*/
mode->allocVectors = allocVectors; mode->allocVectors = allocVectors;
} }
@ -314,7 +314,7 @@ CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int overlap)
{ {
int res; int res;
CELTMode *mode; CELTMode *mode;
res = (Fs+frame_size)/(2*frame_size); res = (Fs+frame_size)/(2*frame_size);
mode = celt_alloc(sizeof(CELTMode)); mode = celt_alloc(sizeof(CELTMode));
@ -328,13 +328,13 @@ CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int overlap)
compute_allocation_table(mode, res); compute_allocation_table(mode, res);
printf ("%d bands\n", mode->nbEBands); //printf ("%d bands\n", mode->nbEBands);
return mode; return mode;
} }
/*int main() void celt_mode_destroy(CELTMode *mode)
{ {
celt_mode_create(44100, 1, 256, 128); celt_free((int*)mode->eBands);
return 0; celt_free((int*)mode->pBands);
}*/ celt_free((int*)mode->allocVectors);
}

View file

@ -41,7 +41,7 @@ int main(int argc, char *argv[])
int i; int i;
char *inFile, *outFile; char *inFile, *outFile;
FILE *fin, *fout; FILE *fin, *fout;
const CELTMode *mode = celt_mono; const CELTMode *mode;
CELTEncoder *enc; CELTEncoder *enc;
CELTDecoder *dec; CELTDecoder *dec;
int len; int len;
@ -61,8 +61,6 @@ int main(int argc, char *argv[])
mode = celt_mono; mode = celt_mono;
else if (strcmp(argv[1], "-stereo")==0) else if (strcmp(argv[1], "-stereo")==0)
mode = celt_stereo; mode = celt_stereo;
else if (strcmp(argv[1], "-ld51")==0)
mode = celt_ld51;
else { else {
fprintf (stderr, "mode must be -mono or -stereo\n"); fprintf (stderr, "mode must be -mono or -stereo\n");
return 1; return 1;
@ -89,7 +87,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
//mode = celt_mode_create(44100, 1, 256, 128); //mode = celt_mode_create(44100, 1, 192, 64);
/* Use mode4 for stereo and don't forget to change the value of CHANNEL above */ /* Use mode4 for stereo and don't forget to change the value of CHANNEL above */
enc = celt_encoder_new(mode); enc = celt_encoder_new(mode);
dec = celt_decoder_new(mode); dec = celt_decoder_new(mode);