Skip to content

Commit

Permalink
Add support for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
almoghamdani committed Jul 26, 2019
1 parent 34d6820 commit eb45832
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
13 changes: 8 additions & 5 deletions src/celt_lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void celt_fir(
int ord)
{
int i,j;
opus_val16 rnum[ord];
opus_val16 *rnum = malloc(sizeof(opus_val16) * ord);
for(i=0;i<ord;i++)
rnum[i] = num[ord-i-1];
for (i=0;i<N-3;i+=4)
Expand All @@ -119,6 +119,7 @@ void celt_fir(
sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
y[i] = ROUND16(sum, SIG_SHIFT);
}
free(rnum);
}

void celt_iir(const opus_val32 *_x,
Expand Down Expand Up @@ -147,8 +148,8 @@ void celt_iir(const opus_val32 *_x,
#else
int i,j;
celt_assert((ord&3)==0);
opus_val16 rden[ord];
opus_val16 y[N+ord];
opus_val16 *rden = malloc(sizeof(opus_val16) * ord);
opus_val16 *y = malloc(sizeof(opus_val16) * (N + ord));
for(i=0;i<ord;i++)
rden[i] = den[ord-i-1];
for(i=0;i<ord;i++)
Expand Down Expand Up @@ -192,6 +193,8 @@ void celt_iir(const opus_val32 *_x,
}
for(i=0;i<ord;i++)
mem[i] = _y[N-i-1];
free(rden);
free(y);
#endif
}

Expand All @@ -208,7 +211,7 @@ int _celt_autocorr(
int fastN=n-lag;
int shift;
const opus_val16 *xptr;
opus_val16 xx[n];
opus_val16 *xx = malloc(sizeof(opus_val16) * n);
celt_assert(n>0);
celt_assert(overlap>=0);
if (overlap == 0)
Expand Down Expand Up @@ -274,6 +277,6 @@ int _celt_autocorr(
shift += shift2;
}
#endif

free(xx);
return shift;
}
2 changes: 2 additions & 0 deletions src/denoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "config.h"
#endif

#define _USE_MATH_DEFINES

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Expand Down
14 changes: 10 additions & 4 deletions src/pitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y,
celt_assert(max_pitch>0);
lag = len+max_pitch;

opus_val16 x_lp4[len>>2];
opus_val16 y_lp4[lag>>2];
opus_val32 xcorr[max_pitch>>1];
opus_val16 *x_lp4 = malloc(sizeof(opus_val16) * (len >> 2));
opus_val16 *y_lp4 = malloc(sizeof(opus_val16) * (lag >> 2));
opus_val32 *xcorr = malloc(sizeof(opus_val32) * (max_pitch >> 1));

/* Downsample by 2 again */
for (j=0;j<len>>2;j++)
Expand Down Expand Up @@ -382,6 +382,10 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y,
offset = 0;
}
*pitch = 2*best_pitch[0]-offset;

free(x_lp4);
free(y_lp4);
free(xcorr);
}

#ifdef FIXED_POINT
Expand Down Expand Up @@ -443,7 +447,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
*T0_=maxperiod-1;

T = T0 = *T0_;
opus_val32 yy_lookup[maxperiod+1];
opus_val32 *yy_lookup = malloc(sizeof(opus_val32) * (maxperiod + 1));
dual_inner_prod(x, x, x-T0, N, &xx, &xy);
yy_lookup[0] = xx;
yy=xx;
Expand Down Expand Up @@ -522,5 +526,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,

if (*T0_<minperiod0)
*T0_=minperiod0;

free(yy_lookup);
return pg;
}

0 comments on commit eb45832

Please sign in to comment.