bits = (unsigned char*)malloc(nbyte*sizeof(char));
frames = bit_errors = 0;
- while(fread(bits, sizeof(char), nbyte, fin) == nbyte) {
+ while(fread(bits, sizeof(char), nbyte, fin) == (size_t)nbyte) {
frames++;
if (ber != 0.0) {
for(i=0; i<nbit; i++) {
nbit = codec2_bits_per_frame(codec2);
bits = (unsigned char*)malloc(nbit*sizeof(char));
- while(fread(buf, sizeof(short), nsam, fin) == nsam) {
+ while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) {
codec2_encode(codec2, bits, buf);
codec2_decode(codec2, buf, bits);
fwrite(buf, sizeof(short), nsam, fout);
bits = (unsigned char*)malloc(nbyte*sizeof(char));
- while(fread(buf, sizeof(short), nsam, fin) == nsam) {
+ while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) {
codec2_encode(codec2, bits, buf);
fwrite(bits, sizeof(char), nbyte, fout);
//if this is in a pipeline, we probably don't want the usual
COMP Sw_[FFT_ENC];
COMP Ew[FFT_ENC];
- int dump = 0;
-
int phase0 = 0;
float ex_phase[MAX_AMP+1];
pack(bits, &nbit, voiced1, 1);
pack(bits, &nbit, voiced2, 1);
fprintf(stderr,"v2: %d v1: %d\n", voiced2, voiced1);
- assert(nbit == codec2_bits_per_frame(c2));
+ assert(nbit == (unsigned)codec2_bits_per_frame(c2));
}
energy_index = unpack(bits, &nbit, E_BITS);
voiced1 = unpack(bits, &nbit, 1);
voiced2 = unpack(bits, &nbit, 1);
- assert(nbit == codec2_bits_per_frame(c2));
+ assert(nbit == (unsigned)codec2_bits_per_frame(c2));
/* decode integer codes to model parameters */
energy_index = unpack(bits, &nbit_tmp, E_BITS);
// fprintf(stderr,"energy_index after: %d\n", energy_index);
- assert(nbit == codec2_bits_per_frame(c2));
+ assert(nbit == (unsigned)codec2_bits_per_frame(c2));
//if (frames == 36)
//exit(0);
}
energy_index = unpack(bits, &nbit, E_BITS);
voiced3 = unpack(bits, &nbit, 1);
voiced4 = unpack(bits, &nbit, 1);
- assert(nbit == codec2_bits_per_frame(c2));
+ assert(nbit == (unsigned)codec2_bits_per_frame(c2));
/* decode integer codes to model parameters */
unsigned int nbit = 0;
unsigned int nbit_tmp;
float prev_Wo;
- static int frames;
+// static int frames;
assert(c2 != NULL);
energy_index = unpack(bits, &nbit_tmp, E_BITS);
// fprintf(stderr,"energy_index after: %d\n", energy_index);
- assert(nbit == codec2_bits_per_frame(c2));
+ assert(nbit == (unsigned)codec2_bits_per_frame(c2));
//if (frames == 8)
//exit(0);
}
energy_index = unpack(bits, &nbit, E_BITS);
voiced3 = unpack(bits, &nbit, 1);
voiced4 = unpack(bits, &nbit, 1);
- assert(nbit == codec2_bits_per_frame(c2));
+ assert(nbit == (unsigned)codec2_bits_per_frame(c2));
/* decode integer codes to model parameters */
float *lsps_interp/* interpolated lsps for this frame */
)
{
- int l,i;
+ int i;
float e;
float snr;
float Sn[], /* input speech vector */
int n, /* frames shift (no. new samples in Sn[]) */
int m, /* analysis window size */
- int pmin, /* minimum pitch value */
+ int pmin __attribute__((unused)), /* minimum pitch value */
int pmax, /* maximum pitch value */
float *pitch, /* estimated pitch period in samples */
- COMP Sw[], /* Freq domain version of Sn[] */
+ COMP Sw[] __attribute__((unused)), /* Freq domain version of Sn[] */
float *prev_Wo
)
{
\*---------------------------------------------------------------------------*/
float post_process_sub_multiples(COMP Fw[],
- int pmin, int pmax, float gmax, int gmax_bin,
+ int pmin __attribute__((unused)), int pmax, float gmax, int gmax_bin,
float *prev_Wo)
{
int min_bin, cmax_bin;
void lspvq_quantise(
float lsp[],
float lsp_[],
- int order
+ int order __attribute__((unused))
)
{
int i,k,m,ncb, nlsp;
\*---------------------------------------------------------------------------*/
-void lspjnd_quantise(float lsps[], float lsps_[], int order)
+void lspjnd_quantise(float lsps[], float lsps_[], int order __attribute__((unused)))
{
int i,k,m;
float wt[LPC_ORD], lsps_hz[LPC_ORD];
\*---------------------------------------------------------------------------*/
-void lspdt_quantise(float lsps[], float lsps_[], float lsps__prev[], int mode)
+void lspdt_quantise(float lsps[], float lsps_[], float lsps__prev[], int mode __attribute__((unused)))
{
- int i,k,m;
+ int i;
float wt[LPC_ORD];
float lsps_dt[LPC_ORD];
+#ifdef TRY_LSPDT_VQ
+ int k,m;
+ int index;
const float *cb;
float se = 0.0;
- int index;
+#endif // TRY_LSPDT_VQ
//compute_weights(lsps, wt, LPC_ORD);
for(i=0; i<LPC_ORD; i++) {
MODEL *model, /* sinusoidal model parameters for this frame */
float E, /* energy term */
float *snr, /* signal to noise ratio for this frame in dB */
- int dump /* true to dump sample to dump file */
+ int dump __attribute__((unused)) /* true to dump sample to dump file */
)
{
COMP Pw[FFT_DEC]; /* power spectrum */
void encode_lsps_diff_time_vq(int indexes[],
float lsps[],
float lsps__prev[],
- int order)
+ int order __attribute__((unused)))
{
int i,k,m;
float lsps_dt[LPC_ORD];
static float ge_coeff[2] = {0.8, 0.9};
-void compute_weights2(const float *x, const float *xp, float *w, int ndim)
+void compute_weights2(const float *x, const float *xp, float *w, int ndim __attribute__((unused)))
{
w[0] = 30;
w[1] = 1;
void encode_lsps_vq(int *indexes, float *x, float *xq, int ndim);
void decode_lsps_vq(int *indexes, float *xq, int ndim);
+long quantise(const float * cb, float vec[], float w[], int k, int m, float *se);
void lspd_quantise(float lsp[], float lsp_[], int order);
void lspvq_quantise(float lsp[], float lsp_[], int order);
void lspjnd_quantise(float lsp[], float lsp_[], int order);
void check_lsp_order(float lsp[], int lpc_order);
void bw_expand_lsps(float lsp[], int order);
void locate_lsps_jnd_steps(float lsp[], int order);
+float decode_amplitudes(MODEL *model,
+ float ak[],
+ int lsp_indexes[],
+ int energy_index,
+ float lsps[],
+ float *e);
#endif
COMP Sw_[], /* DFT of all voiced synthesised signal */
/* useful for debugging/dump file */
COMP Ew[], /* DFT of error */
- float prev_Wo)
+ float prev_Wo __attribute__((unused)))
{
int i,l,al,bl,m; /* loop variables */
COMP Am; /* amplitude sample for this band */
int k,m; /* LSP vector order and codebook size */
int index;
float wt[1]; /* weighting (not used here for scalars) */
- float *cb; /* LSP quantiser codebook */
+ const float *cb; /* LSP quantiser codebook */
int i, ret;
- float se, total_se;
+ float total_se;
if (argc < 2) {
printf("usage: %s InputFile\n", argv[0]);
assert(fout != NULL);
while(fread(buf1, sizeof(short), 2*N, fin) == 2*N) {
- codec2_encode(c2, bits, buf1);
+ codec2_encode(c2, (void*)bits, buf1);
fwrite(bits, sizeof(char), codec2_bits_per_frame(c2), fbits);
- codec2_decode(c2, buf2, bits);
+ codec2_decode(c2, buf2, (void*)bits);
fwrite(buf2, sizeof(short), codec2_bits_per_frame(c2), fout);
}
/* determine size of training set */
J = 0;
- while(fread(vec, sizeof(float), k, ftrain) == k)
+ while(fread(vec, sizeof(float), k, ftrain) == (size_t)k)
J++;
printf("J=%ld entries in training set\n", J);
\*-----------------------------------------------------------------------*/
int main(int argc, char *argv[]) {
- int k,m; /* dimension and codebook size */
+ int k; /* dimension and codebook size */
float *vec; /* current vector */
int *n; /* number of vectors in this interval */
int J; /* number of vectors in training set */
int i,j;
FILE *ftrain; /* file containing training set */
- int ret;
float *train; /* training database */
- float *pend_train; /* last entry */
+ //float *pend_train; /* last entry */
float *pt;
- int ntrain, match, vec_exists, vec_index, entry;
+ int ntrain, match, vec_exists, vec_index=0, entry;
int popular[MAX_POP], pop_thresh;
FILE *fvq;
float jnd;
/* determine size of training set */
J = 0;
- while(fread(vec, sizeof(float), k, ftrain) == k)
+ while(fread(vec, sizeof(float), k, ftrain) == (size_t)k)
J++;
printf("J=%d entries in training set\n", J);
train = (float*)malloc(sizeof(float)*k*J);
rewind(ftrain);
ntrain = 0;
entry = 0;
- while(fread(vec, sizeof(float), k, ftrain) == k) {
+ while(fread(vec, sizeof(float), k, ftrain) == (size_t)k) {
/* convert to Hz */
void locate_lsps_jnd_steps(float lsps[], float step, int k)
{
int i;
- float lsp_hz;
for(i=0; i<k; i++) {
lsps[i] = floor(lsps[i]/step + 0.5)*step;