ref: 2ca8fc373c91a4981c37cf447d2d207e4c1eacc2
parent: 65d57e6e9681053ac255faa3b88542af57bf0b8b
author: Jean-Marc Valin <[email protected]>
date: Mon Feb 18 11:27:49 EST 2008
Making use of dynamically generated modes by default
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -53,10 +53,13 @@
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);
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -103,8 +103,8 @@
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 @@
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 @@
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 @@
}
}
}
- 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;
}
@@ -314,7 +314,7 @@
{
int res;
CELTMode *mode;
-
+
res = (Fs+frame_size)/(2*frame_size);
mode = celt_alloc(sizeof(CELTMode));
@@ -328,13 +328,13 @@
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);
+}
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -41,7 +41,7 @@
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 @@
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 @@
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);