Skip to content

windows support #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ set(
# Build rnnoise
add_definitions(-DRNNOISE_BUILD)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# MSVC requires this to expose definitions like M_PI
add_definitions(-D_USE_MATH_DEFINES)
endif()

# Compile the library
add_library(rnnoise ${SOURCES})

Expand Down
11 changes: 11 additions & 0 deletions src/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,15 @@ static OPUS_INLINE int celt_isnan(float x)
#endif
#endif

#if __STDC_VERSION__ < 199901L || (__STDC_VERSION__ > 201000L && __STDC_NO_VLA__ == 1)
#define NO_VLA
#endif

#ifdef NO_VLA
#include <malloc.h>
#define stackalloc(type, id, len) type *id = alloca(len)
#else
#define stackalloc(type, id, len) type id[len]
#endif

#endif /* ARCH_H */
8 changes: 4 additions & 4 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];
stackalloc(opus_val16, rnum, ord);
for(i=0;i<ord;i++)
rnum[i] = num[ord-i-1];
for (i=0;i<N-3;i+=4)
Expand Down Expand Up @@ -147,8 +147,8 @@ void tn_celt_iir(const opus_val32 *_x,
#else
int i,j;
celt_assert((ord&3)==0);
opus_val16 rden[ord];
opus_val16 y[N+ord];
stackalloc(opus_val16, rden, ord);
stackalloc(opus_val16, y, N+ord);
for(i=0;i<ord;i++)
rden[i] = den[ord-i-1];
for(i=0;i<ord;i++)
Expand Down Expand Up @@ -208,7 +208,7 @@ int _tn_celt_autocorr(
int fastN=n-lag;
int shift;
const opus_val16 *xptr;
opus_val16 xx[n];
stackalloc(opus_val16, xx, n);
celt_assert(n>0);
celt_assert(overlap>=0);
if (overlap == 0)
Expand Down
8 changes: 4 additions & 4 deletions src/pitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ void tn_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];
stackalloc(opus_val16, x_lp4, len>>2);
stackalloc(opus_val16, y_lp4, lag>>2);
stackalloc(opus_val32, xcorr, max_pitch>>1);

/* Downsample by 2 again */
for (j=0;j<len>>2;j++)
Expand Down Expand Up @@ -443,7 +443,7 @@ opus_val16 tn_remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
*T0_=maxperiod-1;

T = T0 = *T0_;
opus_val32 yy_lookup[maxperiod+1];
stackalloc(opus_val32, yy_lookup, maxperiod+1);
dual_inner_prod(x, x, x-T0, N, &xx, &xy);
yy_lookup[0] = xx;
yy=xx;
Expand Down