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,9 +53,12 @@ typedef struct CELTDecoder CELTDecoder;
typedef struct CELTMode CELTMode;
extern const CELTMode *celt_mono;
/*extern const CELTMode *celt_mono;
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 */
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 */
};
const CELTMode const *celt_mono = &mono_mode;
const CELTMode const *celt_stereo = &stereo_mode;
//const CELTMode const *celt_mono = &mono_mode;
//const CELTMode const *celt_stereo = &stereo_mode;
#define NBANDS51 17
@ -230,9 +230,9 @@ static int *compute_ebands(int Fs, int frame_size, int *nbEBands)
eBands[*nbEBands] = eBands[*nbEBands+1];
/* 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 ("\n");
printf ("\n");*/
return eBands;
}
@ -265,9 +265,9 @@ static void compute_pbands(CELTMode *mode, int res)
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 ("\n");
printf ("\n");*/
mode->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++)
printf ("%2d ", allocVectors[i*mode->nbEBands+j]);
printf ("\n");
}
}*/
mode->allocVectors = allocVectors;
}
@ -328,13 +328,13 @@ CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int overlap)
compute_allocation_table(mode, res);
printf ("%d bands\n", mode->nbEBands);
//printf ("%d bands\n", mode->nbEBands);
return mode;
}
/*int main()
void celt_mode_destroy(CELTMode *mode)
{
celt_mode_create(44100, 1, 256, 128);
return 0;
}*/
celt_free((int*)mode->eBands);
celt_free((int*)mode->pBands);
celt_free((int*)mode->allocVectors);
}

View file

@ -41,7 +41,7 @@ int main(int argc, char *argv[])
int i;
char *inFile, *outFile;
FILE *fin, *fout;
const CELTMode *mode = celt_mono;
const CELTMode *mode;
CELTEncoder *enc;
CELTDecoder *dec;
int len;
@ -61,8 +61,6 @@ int main(int argc, char *argv[])
mode = celt_mono;
else if (strcmp(argv[1], "-stereo")==0)
mode = celt_stereo;
else if (strcmp(argv[1], "-ld51")==0)
mode = celt_ld51;
else {
fprintf (stderr, "mode must be -mono or -stereo\n");
return 1;
@ -89,7 +87,7 @@ int main(int argc, char *argv[])
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 */
enc = celt_encoder_new(mode);
dec = celt_decoder_new(mode);