aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2024-03-22 17:44:13 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2024-03-22 17:44:13 -0400
commit6cbfd53eb348a8d394e0757b4025c6ded34eb2b6 (patch)
tree07142c5acd6e1af7835abcf87fec6f81dc4973e8
parentf42d86accef6f91c5746256adc3d0093d8ae81ab (diff)
downloadrnnoise-upstream-master.tar.gz
use rnn_ prefix for non-exported symbolsupstream-master
-rw-r--r--src/celt_lpc.c113
-rw-r--r--src/celt_lpc.h20
-rw-r--r--src/denoise.c6
-rw-r--r--src/pitch.c17
-rw-r--r--src/pitch.h8
5 files changed, 20 insertions, 144 deletions
diff --git a/src/celt_lpc.c b/src/celt_lpc.c
index 39dd38d..000924b 100644
--- a/src/celt_lpc.c
+++ b/src/celt_lpc.c
@@ -34,7 +34,7 @@
#include "common.h"
#include "pitch.h"
-void _rnnoise_lpc(
+void rnn_lpc(
opus_val16 *_lpc, /* out: [0...p-1] LPC coefficients */
const opus_val32 *ac, /* in: [0...p] autocorrelation values */
int p
@@ -88,114 +88,7 @@ int p
}
-void rnnoise_fir(
- const opus_val16 *x,
- const opus_val16 *num,
- opus_val16 *y,
- int N,
- int ord)
-{
- int i,j;
- opus_val16 rnum[ord];
- for(i=0;i<ord;i++)
- rnum[i] = num[ord-i-1];
- for (i=0;i<N-3;i+=4)
- {
- opus_val32 sum[4];
- sum[0] = SHL32(EXTEND32(x[i ]), SIG_SHIFT);
- sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT);
- sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
- sum[3] = SHL32(EXTEND32(x[i+3]), SIG_SHIFT);
- xcorr_kernel(rnum, x+i-ord, sum, ord);
- y[i ] = ROUND16(sum[0], SIG_SHIFT);
- y[i+1] = ROUND16(sum[1], SIG_SHIFT);
- y[i+2] = ROUND16(sum[2], SIG_SHIFT);
- y[i+3] = ROUND16(sum[3], SIG_SHIFT);
- }
- for (;i<N;i++)
- {
- opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
- for (j=0;j<ord;j++)
- sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
- y[i] = ROUND16(sum, SIG_SHIFT);
- }
-}
-
-void rnnoise_iir(const opus_val32 *_x,
- const opus_val16 *den,
- opus_val32 *_y,
- int N,
- int ord,
- opus_val16 *mem)
-{
-#ifdef SMALL_FOOTPRINT
- int i,j;
- for (i=0;i<N;i++)
- {
- opus_val32 sum = _x[i];
- for (j=0;j<ord;j++)
- {
- sum -= MULT16_16(den[j],mem[j]);
- }
- for (j=ord-1;j>=1;j--)
- {
- mem[j]=mem[j-1];
- }
- mem[0] = SROUND16(sum, SIG_SHIFT);
- _y[i] = sum;
- }
-#else
- int i,j;
- celt_assert((ord&3)==0);
- opus_val16 rden[ord];
- opus_val16 y[N+ord];
- for(i=0;i<ord;i++)
- rden[i] = den[ord-i-1];
- for(i=0;i<ord;i++)
- y[i] = -mem[ord-i-1];
- for(;i<N+ord;i++)
- y[i]=0;
- for (i=0;i<N-3;i+=4)
- {
- /* Unroll by 4 as if it were an FIR filter */
- opus_val32 sum[4];
- sum[0]=_x[i];
- sum[1]=_x[i+1];
- sum[2]=_x[i+2];
- sum[3]=_x[i+3];
- xcorr_kernel(rden, y+i, sum, ord);
-
- /* Patch up the result to compensate for the fact that this is an IIR */
- y[i+ord ] = -SROUND16(sum[0],SIG_SHIFT);
- _y[i ] = sum[0];
- sum[1] = MAC16_16(sum[1], y[i+ord ], den[0]);
- y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
- _y[i+1] = sum[1];
- sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
- sum[2] = MAC16_16(sum[2], y[i+ord ], den[1]);
- y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
- _y[i+2] = sum[2];
-
- sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
- sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
- sum[3] = MAC16_16(sum[3], y[i+ord ], den[2]);
- y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
- _y[i+3] = sum[3];
- }
- for (;i<N;i++)
- {
- opus_val32 sum = _x[i];
- for (j=0;j<ord;j++)
- sum -= MULT16_16(rden[j],y[i+j]);
- y[i+ord] = SROUND16(sum,SIG_SHIFT);
- _y[i] = sum;
- }
- for(i=0;i<ord;i++)
- mem[i] = _y[N-i-1];
-#endif
-}
-
-int _rnnoise_autocorr(
+int rnn_autocorr(
const opus_val16 *x, /* in: [0...n-1] samples x */
opus_val32 *ac, /* out: [0...lag-1] ac values */
const opus_val16 *window,
@@ -247,7 +140,7 @@ int _rnnoise_autocorr(
shift = 0;
}
#endif
- rnnoise_pitch_xcorr(xptr, xptr, ac, fastN, lag+1);
+ rnn_pitch_xcorr(xptr, xptr, ac, fastN, lag+1);
for (k=0;k<=lag;k++)
{
for (i = k+fastN, d = 0; i < n; i++)
diff --git a/src/celt_lpc.h b/src/celt_lpc.h
index 058c769..5abd61a 100644
--- a/src/celt_lpc.h
+++ b/src/celt_lpc.h
@@ -37,23 +37,9 @@
#define LPC_ORDER 24
-void _rnnoise_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p);
-
-void rnnoise_fir(
- const opus_val16 *x,
- const opus_val16 *num,
- opus_val16 *y,
- int N,
- int ord);
-
-void rnnoise_iir(const opus_val32 *x,
- const opus_val16 *den,
- opus_val32 *y,
- int N,
- int ord,
- opus_val16 *mem);
-
-int _rnnoise_autocorr(const opus_val16 *x, opus_val32 *ac,
+void rnn_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p);
+
+int rnn_autocorr(const opus_val16 *x, opus_val32 *ac,
const opus_val16 *window, int overlap, int lag, int n);
#endif /* PLC_H */
diff --git a/src/denoise.c b/src/denoise.c
index 09541e0..ec9bc41 100644
--- a/src/denoise.c
+++ b/src/denoise.c
@@ -325,12 +325,12 @@ static int compute_frame_features(DenoiseState *st, kiss_fft_cpx *X, kiss_fft_cp
RNN_MOVE(st->pitch_buf, &st->pitch_buf[FRAME_SIZE], PITCH_BUF_SIZE-FRAME_SIZE);
RNN_COPY(&st->pitch_buf[PITCH_BUF_SIZE-FRAME_SIZE], in, FRAME_SIZE);
pre[0] = &st->pitch_buf[0];
- rnnoise_pitch_downsample(pre, pitch_buf, PITCH_BUF_SIZE, 1);
- rnnoise_pitch_search(pitch_buf+(PITCH_MAX_PERIOD>>1), pitch_buf, PITCH_FRAME_SIZE,
+ rnn_pitch_downsample(pre, pitch_buf, PITCH_BUF_SIZE, 1);
+ rnn_pitch_search(pitch_buf+(PITCH_MAX_PERIOD>>1), pitch_buf, PITCH_FRAME_SIZE,
PITCH_MAX_PERIOD-3*PITCH_MIN_PERIOD, &pitch_index);
pitch_index = PITCH_MAX_PERIOD-pitch_index;
- gain = rnnoise_remove_doubling(pitch_buf, PITCH_MAX_PERIOD, PITCH_MIN_PERIOD,
+ gain = rnn_remove_doubling(pitch_buf, PITCH_MAX_PERIOD, PITCH_MIN_PERIOD,
PITCH_FRAME_SIZE, &pitch_index, st->last_period, st->last_gain);
st->last_period = pitch_index;
st->last_gain = gain;
diff --git a/src/pitch.c b/src/pitch.c
index b0fdefc..806399b 100644
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -37,9 +37,6 @@
#include "pitch.h"
#include "common.h"
-//#include "modes.h"
-//#include "stack_alloc.h"
-//#include "mathops.h"
#include "celt_lpc.h"
#include "math.h"
@@ -145,7 +142,7 @@ static void celt_fir5(const opus_val16 *x,
}
-void rnnoise_pitch_downsample(celt_sig *x[], opus_val16 *x_lp,
+void rnn_pitch_downsample(celt_sig *x[], opus_val16 *x_lp,
int len, int C)
{
int i;
@@ -180,7 +177,7 @@ void rnnoise_pitch_downsample(celt_sig *x[], opus_val16 *x_lp,
x_lp[0] += SHR32(HALF32(HALF32(x[1][1])+x[1][0]), shift);
}
- _rnnoise_autocorr(x_lp, ac, NULL, 0,
+ rnn_autocorr(x_lp, ac, NULL, 0,
4, len>>1);
/* Noise floor -40 dB */
@@ -200,7 +197,7 @@ void rnnoise_pitch_downsample(celt_sig *x[], opus_val16 *x_lp,
#endif
}
- _rnnoise_lpc(lpc, ac, 4);
+ rnn_lpc(lpc, ac, 4);
for (i=0;i<4;i++)
{
tmp = MULT16_16_Q15(QCONST16(.9f,15), tmp);
@@ -215,7 +212,7 @@ void rnnoise_pitch_downsample(celt_sig *x[], opus_val16 *x_lp,
celt_fir5(x_lp, lpc2, x_lp, len>>1, mem);
}
-void rnnoise_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y,
+void rnn_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y,
opus_val32 *xcorr, int len, int max_pitch)
{
@@ -280,7 +277,7 @@ void rnnoise_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y,
#endif
}
-void rnnoise_pitch_search(const opus_val16 *x_lp, opus_val16 *y,
+void rnn_pitch_search(const opus_val16 *x_lp, opus_val16 *y,
int len, int max_pitch, int *pitch)
{
int i, j;
@@ -329,7 +326,7 @@ void rnnoise_pitch_search(const opus_val16 *x_lp, opus_val16 *y,
#ifdef FIXED_POINT
maxcorr =
#endif
- rnnoise_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2);
+ rnn_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2);
find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch
#ifdef FIXED_POINT
@@ -420,7 +417,7 @@ static opus_val16 compute_pitch_gain(opus_val32 xy, opus_val32 xx, opus_val32 yy
#endif
static const int second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2};
-opus_val16 rnnoise_remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
+opus_val16 rnn_remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
int N, int *T0_, int prev_period, opus_val16 prev_gain)
{
int k, i, T, T0;
diff --git a/src/pitch.h b/src/pitch.h
index 09a7b4e..d87fd9d 100644
--- a/src/pitch.h
+++ b/src/pitch.h
@@ -38,13 +38,13 @@
//#include "cpu_support.h"
#include "arch.h"
-void rnnoise_pitch_downsample(celt_sig *x[], opus_val16 *x_lp,
+void rnn_pitch_downsample(celt_sig *x[], opus_val16 *x_lp,
int len, int C);
-void rnnoise_pitch_search(const opus_val16 *x_lp, opus_val16 *y,
+void rnn_pitch_search(const opus_val16 *x_lp, opus_val16 *y,
int len, int max_pitch, int *pitch);
-opus_val16 rnnoise_remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
+opus_val16 rnn_remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
int N, int *T0, int prev_period, opus_val16 prev_gain);
@@ -143,7 +143,7 @@ static OPUS_INLINE opus_val32 celt_inner_prod(const opus_val16 *x,
return xy;
}
-void rnnoise_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y,
+void rnn_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y,
opus_val32 *xcorr, int len, int max_pitch);
#endif