Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2023-06-23 07:02:12 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-06-23 07:02:12 +0300
commit9f4fc8bbfa4f8ddd518f85a7aa0a87ab8369c6a9 (patch)
treed78f543aca68cbf6155190fd9d9719d7b617a680
parent5af9e9524abda564a3ee6e9df04dfa75b9b68bab (diff)
Replacing RNN_ macros with existing OPUS_ ones
-rw-r--r--dnn/common.h46
-rw-r--r--dnn/dred_rdovae_dec.c8
-rw-r--r--dnn/dred_rdovae_enc.c7
-rw-r--r--dnn/dump_data.c3
-rw-r--r--dnn/freq.c11
-rw-r--r--dnn/lpcnet.c33
-rw-r--r--dnn/lpcnet_demo.c3
-rw-r--r--dnn/lpcnet_enc.c19
-rw-r--r--dnn/lpcnet_plc.c41
-rw-r--r--dnn/nnet.c11
-rw-r--r--dnn/write_lpcnet_weights.c3
-rw-r--r--silk/dred_encoder.c2
12 files changed, 79 insertions, 108 deletions
diff --git a/dnn/common.h b/dnn/common.h
index e9c8dd17..df3dcca1 100644
--- a/dnn/common.h
+++ b/dnn/common.h
@@ -6,16 +6,12 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
-
-#define RNN_INLINE inline
-#ifndef OPUS_INLINE
-#define OPUS_INLINE inline
-#endif
+#include "opus_defines.h"
float lpc_from_cepstrum(float *lpc, const float *cepstrum);
#define LOG256 5.5451774445f
-static RNN_INLINE float log2_approx(float x)
+static OPUS_INLINE float log2_approx(float x)
{
int integer;
float frac;
@@ -34,7 +30,7 @@ static RNN_INLINE float log2_approx(float x)
#define log_approx(x) (0.69315f*log2_approx(x))
-static RNN_INLINE float ulaw2lin(float u)
+static OPUS_INLINE float ulaw2lin(float u)
{
float s;
float scale_1 = 32768.f/255.f;
@@ -44,7 +40,7 @@ static RNN_INLINE float ulaw2lin(float u)
return s*scale_1*(exp(u/128.*LOG256)-1);
}
-static RNN_INLINE int lin2ulaw(float x)
+static OPUS_INLINE int lin2ulaw(float x)
{
float u;
float scale = 255.f/32768.f;
@@ -58,39 +54,5 @@ static RNN_INLINE int lin2ulaw(float x)
}
-/** RNNoise wrapper for malloc(). To do your own dynamic allocation, all you need t
-o do is replace this function and rnnoise_free */
-#ifndef OVERRIDE_RNNOISE_ALLOC
-static RNN_INLINE void *rnnoise_alloc (size_t size)
-{
- return malloc(size);
-}
-#endif
-
-/** RNNoise wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and rnnoise_alloc */
-#ifndef OVERRIDE_RNNOISE_FREE
-static RNN_INLINE void rnnoise_free (void *ptr)
-{
- free(ptr);
-}
-#endif
-
-/** Copy n elements from src to dst. The 0* term provides compile-time type checking */
-#ifndef OVERRIDE_RNN_COPY
-#define RNN_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
-#endif
-
-/** Copy n elements from src to dst, allowing overlapping regions. The 0* term
- provides compile-time type checking */
-#ifndef OVERRIDE_RNN_MOVE
-#define RNN_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
-#endif
-
-/** Set n elements of dst to zero */
-#ifndef OVERRIDE_RNN_CLEAR
-#define RNN_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
-#endif
-
-
#endif
diff --git a/dnn/dred_rdovae_dec.c b/dnn/dred_rdovae_dec.c
index 3cf2d69a..5f712524 100644
--- a/dnn/dred_rdovae_dec.c
+++ b/dnn/dred_rdovae_dec.c
@@ -32,7 +32,7 @@
#include "common.h"
#include "dred_rdovae_dec.h"
#include "dred_rdovae_constants.h"
-
+#include "os_support.h"
void dred_rdovae_dec_init_states(
RDOVAEDecState *h, /* io: state buffer handle */
@@ -65,7 +65,7 @@ void dred_rdovae_decode_qframe(
output_index += DEC_DENSE1_OUT_SIZE;
compute_gruB(&model->dec_dense2, zero_vector, dec_state->dense2_state, &buffer[input_index]);
- RNN_COPY(&buffer[output_index], dec_state->dense2_state, DEC_DENSE2_OUT_SIZE);
+ OPUS_COPY(&buffer[output_index], dec_state->dense2_state, DEC_DENSE2_OUT_SIZE);
input_index = output_index;
output_index += DEC_DENSE2_OUT_SIZE;
@@ -74,7 +74,7 @@ void dred_rdovae_decode_qframe(
output_index += DEC_DENSE3_OUT_SIZE;
compute_gruB(&model->dec_dense4, zero_vector, dec_state->dense4_state, &buffer[input_index]);
- RNN_COPY(&buffer[output_index], dec_state->dense4_state, DEC_DENSE4_OUT_SIZE);
+ OPUS_COPY(&buffer[output_index], dec_state->dense4_state, DEC_DENSE4_OUT_SIZE);
input_index = output_index;
output_index += DEC_DENSE4_OUT_SIZE;
@@ -83,7 +83,7 @@ void dred_rdovae_decode_qframe(
output_index += DEC_DENSE5_OUT_SIZE;
compute_gruB(&model->dec_dense6, zero_vector, dec_state->dense6_state, &buffer[input_index]);
- RNN_COPY(&buffer[output_index], dec_state->dense6_state, DEC_DENSE6_OUT_SIZE);
+ OPUS_COPY(&buffer[output_index], dec_state->dense6_state, DEC_DENSE6_OUT_SIZE);
input_index = output_index;
output_index += DEC_DENSE6_OUT_SIZE;
diff --git a/dnn/dred_rdovae_enc.c b/dnn/dred_rdovae_enc.c
index 9fb93cd8..2f21d9fb 100644
--- a/dnn/dred_rdovae_enc.c
+++ b/dnn/dred_rdovae_enc.c
@@ -34,6 +34,7 @@
#include "dred_rdovae_enc.h"
#include "common.h"
+#include "os_support.h"
void dred_rdovae_encode_dframe(
RDOVAEEncState *enc_state, /* io: encoder state */
@@ -54,7 +55,7 @@ void dred_rdovae_encode_dframe(
output_index += ENC_DENSE1_OUT_SIZE;
compute_gruB(&model->enc_dense2, zero_vector, enc_state->dense2_state, &buffer[input_index]);
- RNN_COPY(&buffer[output_index], enc_state->dense2_state, ENC_DENSE2_OUT_SIZE);
+ OPUS_COPY(&buffer[output_index], enc_state->dense2_state, ENC_DENSE2_OUT_SIZE);
input_index = output_index;
output_index += ENC_DENSE2_OUT_SIZE;
@@ -63,7 +64,7 @@ void dred_rdovae_encode_dframe(
output_index += ENC_DENSE3_OUT_SIZE;
compute_gruB(&model->enc_dense4, zero_vector, enc_state->dense4_state, &buffer[input_index]);
- RNN_COPY(&buffer[output_index], enc_state->dense4_state, ENC_DENSE4_OUT_SIZE);
+ OPUS_COPY(&buffer[output_index], enc_state->dense4_state, ENC_DENSE4_OUT_SIZE);
input_index = output_index;
output_index += ENC_DENSE4_OUT_SIZE;
@@ -72,7 +73,7 @@ void dred_rdovae_encode_dframe(
output_index += ENC_DENSE5_OUT_SIZE;
compute_gruB(&model->enc_dense6, zero_vector, enc_state->dense6_state, &buffer[input_index]);
- RNN_COPY(&buffer[output_index], enc_state->dense6_state, ENC_DENSE6_OUT_SIZE);
+ OPUS_COPY(&buffer[output_index], enc_state->dense6_state, ENC_DENSE6_OUT_SIZE);
input_index = output_index;
output_index += ENC_DENSE6_OUT_SIZE;
diff --git a/dnn/dump_data.c b/dnn/dump_data.c
index 2c1b783a..2beec071 100644
--- a/dnn/dump_data.c
+++ b/dnn/dump_data.c
@@ -41,6 +41,7 @@
#include <assert.h>
#include "lpcnet.h"
#include "lpcnet_private.h"
+#include "os_support.h"
static void biquad(float *y, float mem[2], const float *x, const float *b, const float *a, int N) {
@@ -98,7 +99,7 @@ void write_audio(LPCNetEncState *st, const opus_int16 *pcm, const int *noise, FI
e += noise[i];
e = IMIN(255, IMAX(0, e));
- RNN_MOVE(&st->sig_mem[1], &st->sig_mem[0], LPC_ORDER-1);
+ OPUS_MOVE(&st->sig_mem[1], &st->sig_mem[0], LPC_ORDER-1);
st->sig_mem[0] = p + ulaw2lin(e);
st->exc_mem = e;
}
diff --git a/dnn/freq.c b/dnn/freq.c
index 8ef1efe6..261acd2b 100644
--- a/dnn/freq.c
+++ b/dnn/freq.c
@@ -39,6 +39,7 @@
#include "arch.h"
#include "burg.h"
#include <assert.h>
+#include "os_support.h"
#define SQUARE(x) ((x)*(x))
@@ -94,8 +95,8 @@ int p
opus_val32 r;
opus_val32 error = ac[0];
- RNN_CLEAR(lpc, p);
- RNN_CLEAR(rc, p);
+ OPUS_CLEAR(lpc, p);
+ OPUS_CLEAR(rc, p);
if (ac[0] != 0)
{
for (i = 0; i < p; i++) {
@@ -169,7 +170,7 @@ static void compute_burg_cepstrum(const float *pcm, float *burg_cepstrum, int le
for (i=0;i<len-1;i++) burg_in[i] = pcm[i+1] - PREEMPHASIS*pcm[i];
g = silk_burg_analysis(burg_lpc, burg_in, 1e-3, len-1, 1, order);
g /= len - 2*(order-1);
- RNN_CLEAR(x, WINDOW_SIZE);
+ OPUS_CLEAR(x, WINDOW_SIZE);
x[0] = 1;
for (i=0;i<order;i++) x[i+1] = -burg_lpc[i]*pow(.995, i+1);
forward_transform(LPC, x);
@@ -283,7 +284,7 @@ static float lpc_from_bands(float *lpc, const float *Ex)
float x_auto[WINDOW_SIZE];
interp_band_gain(Xr, Ex);
Xr[FREQ_SIZE-1] = 0;
- RNN_CLEAR(X_auto, FREQ_SIZE);
+ OPUS_CLEAR(X_auto, FREQ_SIZE);
for (i=0;i<FREQ_SIZE;i++) X_auto[i].r = Xr[i];
inverse_transform(x_auto, X_auto);
for (i=0;i<LPC_ORDER+1;i++) ac[i] = x_auto[i];
@@ -312,7 +313,7 @@ float lpc_from_cepstrum(float *lpc, const float *cepstrum)
int i;
float Ex[NB_BANDS];
float tmp[NB_BANDS];
- RNN_COPY(tmp, cepstrum, NB_BANDS);
+ OPUS_COPY(tmp, cepstrum, NB_BANDS);
tmp[0] += 4;
idct(Ex, tmp);
for (i=0;i<NB_BANDS;i++) Ex[i] = pow(10.f, Ex[i])*compensation[i];
diff --git a/dnn/lpcnet.c b/dnn/lpcnet.c
index 99a58644..ff43e301 100644
--- a/dnn/lpcnet.c
+++ b/dnn/lpcnet.c
@@ -36,6 +36,7 @@
#include "arch.h"
#include "lpcnet.h"
#include "lpcnet_private.h"
+#include "os_support.h"
#define PREEMPH 0.85f
@@ -59,7 +60,7 @@ void rc2lpc(float *lpc, const float *rc)
int i, j, k;
float tmp[LPC_ORDER];
float ntmp[LPC_ORDER] = {0.0};
- RNN_COPY(tmp, rc, LPC_ORDER);
+ OPUS_COPY(tmp, rc, LPC_ORDER);
for(i = 0; i < LPC_ORDER ; i++)
{
for(j = 0; j <= i-1; j++)
@@ -93,15 +94,15 @@ void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b
pitch = (int)floor(.1 + 50*features[NB_BANDS]+100);
pitch = IMIN(255, IMAX(33, pitch));
net = &lpcnet->nnet;
- RNN_COPY(in, features, NB_FEATURES);
+ OPUS_COPY(in, features, NB_FEATURES);
compute_embedding(&lpcnet->model.embed_pitch, &in[NB_FEATURES], pitch);
compute_conv1d(&lpcnet->model.feature_conv1, conv1_out, net->feature_conv1_state, in);
- if (lpcnet->frame_count < FEATURE_CONV1_DELAY) RNN_CLEAR(conv1_out, FEATURE_CONV1_OUT_SIZE);
+ if (lpcnet->frame_count < FEATURE_CONV1_DELAY) OPUS_CLEAR(conv1_out, FEATURE_CONV1_OUT_SIZE);
compute_conv1d(&lpcnet->model.feature_conv2, conv2_out, net->feature_conv2_state, conv1_out);
- if (lpcnet->frame_count < FEATURES_DELAY) RNN_CLEAR(conv2_out, FEATURE_CONV2_OUT_SIZE);
+ if (lpcnet->frame_count < FEATURES_DELAY) OPUS_CLEAR(conv2_out, FEATURE_CONV2_OUT_SIZE);
_lpcnet_compute_dense(&lpcnet->model.feature_dense1, dense1_out, conv2_out);
_lpcnet_compute_dense(&lpcnet->model.feature_dense2, condition, dense1_out);
- RNN_COPY(rc, condition, LPC_ORDER);
+ OPUS_COPY(rc, condition, LPC_ORDER);
_lpcnet_compute_dense(&lpcnet->model.gru_a_dense_feature, gru_a_condition, condition);
_lpcnet_compute_dense(&lpcnet->model.gru_b_dense_feature, gru_b_condition, condition);
#ifdef END2END
@@ -124,11 +125,11 @@ void run_frame_network_deferred(LPCNetState *lpcnet, const float *features)
int max_buffer_size = lpcnet->model.feature_conv1.kernel_size + lpcnet->model.feature_conv2.kernel_size - 2;
celt_assert(max_buffer_size <= MAX_FEATURE_BUFFER_SIZE);
if (lpcnet->feature_buffer_fill == max_buffer_size) {
- RNN_MOVE(lpcnet->feature_buffer, &lpcnet->feature_buffer[NB_FEATURES], (max_buffer_size-1)*NB_FEATURES);
+ OPUS_MOVE(lpcnet->feature_buffer, &lpcnet->feature_buffer[NB_FEATURES], (max_buffer_size-1)*NB_FEATURES);
} else {
lpcnet->feature_buffer_fill++;
}
- RNN_COPY(&lpcnet->feature_buffer[(lpcnet->feature_buffer_fill-1)*NB_FEATURES], features, NB_FEATURES);
+ OPUS_COPY(&lpcnet->feature_buffer[(lpcnet->feature_buffer_fill-1)*NB_FEATURES], features, NB_FEATURES);
}
void run_frame_network_flush(LPCNetState *lpcnet)
@@ -153,15 +154,15 @@ int run_sample_network(LPCNetState *lpcnet, const float *gru_a_condition, const
#if 1
compute_gru_a_input(gru_a_input, gru_a_condition, GRU_A_STATE_SIZE, &lpcnet->model.gru_a_embed_sig, last_sig, &lpcnet->model.gru_a_embed_pred, pred, &lpcnet->model.gru_a_embed_exc, last_exc);
#else
- RNN_COPY(gru_a_input, gru_a_condition, 3*GRU_A_STATE_SIZE);
+ OPUS_COPY(gru_a_input, gru_a_condition, 3*GRU_A_STATE_SIZE);
accum_embedding(&lpcnet->model.gru_a_embed_sig, gru_a_input, last_sig);
accum_embedding(&lpcnet->model.gru_a_embed_pred, gru_a_input, pred);
accum_embedding(&lpcnet->model.gru_a_embed_exc, gru_a_input, last_exc);
#endif
/*compute_gru3(&gru_a, net->gru_a_state, gru_a_input);*/
compute_sparse_gru(&lpcnet->model.sparse_gru_a, net->gru_a_state, gru_a_input);
- RNN_COPY(in_b, net->gru_a_state, GRU_A_STATE_SIZE);
- RNN_COPY(gru_b_input, gru_b_condition, 3*GRU_B_STATE_SIZE);
+ OPUS_COPY(in_b, net->gru_a_state, GRU_A_STATE_SIZE);
+ OPUS_COPY(gru_b_input, gru_b_condition, 3*GRU_B_STATE_SIZE);
compute_gruB(&lpcnet->model.gru_b, gru_b_input, net->gru_b_state, in_b);
return sample_mdense(&lpcnet->model.dual_fc, net->gru_b_state, sampling_logit_table, rng);
}
@@ -174,7 +175,7 @@ int lpcnet_get_size()
void lpcnet_reset(LPCNetState *lpcnet)
{
const char* rng_string="LPCNet";
- RNN_CLEAR((char*)&lpcnet->LPCNET_RESET_START,
+ OPUS_CLEAR((char*)&lpcnet->LPCNET_RESET_START,
sizeof(LPCNetState)-
((char*)&lpcnet->LPCNET_RESET_START - (char*)lpcnet));
lpcnet->last_exc = lin2ulaw(0.f);
@@ -227,9 +228,9 @@ void lpcnet_reset_signal(LPCNetState *lpcnet)
{
lpcnet->deemph_mem = 0;
lpcnet->last_exc = lin2ulaw(0.f);
- RNN_CLEAR(lpcnet->last_sig, LPC_ORDER);
- RNN_CLEAR(lpcnet->nnet.gru_a_state, GRU_A_STATE_SIZE);
- RNN_CLEAR(lpcnet->nnet.gru_b_state, GRU_B_STATE_SIZE);
+ OPUS_CLEAR(lpcnet->last_sig, LPC_ORDER);
+ OPUS_CLEAR(lpcnet->nnet.gru_a_state, GRU_A_STATE_SIZE);
+ OPUS_CLEAR(lpcnet->nnet.gru_b_state, GRU_B_STATE_SIZE);
}
void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N, int preload)
@@ -238,7 +239,7 @@ void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N,
if (lpcnet->frame_count <= FEATURES_DELAY)
{
- RNN_CLEAR(output, N);
+ OPUS_CLEAR(output, N);
return;
}
for (i=0;i<N;i++)
@@ -259,7 +260,7 @@ void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N,
} else {
pcm = pred + ulaw2lin(exc);
}
- RNN_MOVE(&lpcnet->last_sig[1], &lpcnet->last_sig[0], LPC_ORDER-1);
+ OPUS_MOVE(&lpcnet->last_sig[1], &lpcnet->last_sig[0], LPC_ORDER-1);
lpcnet->last_sig[0] = pcm;
lpcnet->last_exc = exc;
pcm += PREEMPH*lpcnet->deemph_mem;
diff --git a/dnn/lpcnet_demo.c b/dnn/lpcnet_demo.c
index a41f5120..0b5956b4 100644
--- a/dnn/lpcnet_demo.c
+++ b/dnn/lpcnet_demo.c
@@ -36,6 +36,7 @@
#include "arch.h"
#include "lpcnet.h"
#include "freq.h"
+#include "os_support.h"
#ifdef USE_WEIGHTS_FILE
# if __unix__
@@ -179,7 +180,7 @@ int main(int argc, char **argv) {
size_t ret;
ret = fread(in_features, sizeof(features[0]), NB_TOTAL_FEATURES, fin);
if (feof(fin) || ret != NB_TOTAL_FEATURES) break;
- RNN_COPY(features, in_features, NB_FEATURES);
+ OPUS_COPY(features, in_features, NB_FEATURES);
lpcnet_synthesize(net, features, pcm, LPCNET_FRAME_SIZE);
fwrite(pcm, sizeof(pcm[0]), LPCNET_FRAME_SIZE, fout);
}
diff --git a/dnn/lpcnet_enc.c b/dnn/lpcnet_enc.c
index 7d1208fa..70d8debe 100644
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -40,6 +40,7 @@
#include <assert.h>
#include "lpcnet_private.h"
#include "lpcnet.h"
+#include "os_support.h"
int lpcnet_encoder_get_size() {
@@ -65,9 +66,9 @@ void lpcnet_encoder_destroy(LPCNetEncState *st) {
static void frame_analysis(LPCNetEncState *st, kiss_fft_cpx *X, float *Ex, const float *in) {
float x[WINDOW_SIZE];
- RNN_COPY(x, st->analysis_mem, OVERLAP_SIZE);
- RNN_COPY(&x[OVERLAP_SIZE], in, FRAME_SIZE);
- RNN_COPY(st->analysis_mem, &in[FRAME_SIZE-OVERLAP_SIZE], OVERLAP_SIZE);
+ OPUS_COPY(x, st->analysis_mem, OVERLAP_SIZE);
+ OPUS_COPY(&x[OVERLAP_SIZE], in, FRAME_SIZE);
+ OPUS_COPY(st->analysis_mem, &in[FRAME_SIZE-OVERLAP_SIZE], OVERLAP_SIZE);
apply_window(x);
forward_transform(X, x);
lpcn_compute_band_energy(Ex, X);
@@ -85,7 +86,7 @@ void compute_frame_features(LPCNetEncState *st, const float *in) {
float ener0;
int sub;
float ener;
- RNN_COPY(aligned_in, &st->analysis_mem[OVERLAP_SIZE-TRAINING_OFFSET], TRAINING_OFFSET);
+ OPUS_COPY(aligned_in, &st->analysis_mem[OVERLAP_SIZE-TRAINING_OFFSET], TRAINING_OFFSET);
frame_analysis(st, X, Ex, in);
logMax = -2;
follow = -2;
@@ -100,14 +101,14 @@ void compute_frame_features(LPCNetEncState *st, const float *in) {
st->features[0] -= 4;
lpc_from_cepstrum(st->lpc, st->features);
for (i=0;i<LPC_ORDER;i++) st->features[NB_BANDS+2+i] = st->lpc[i];
- RNN_MOVE(st->exc_buf, &st->exc_buf[FRAME_SIZE], PITCH_MAX_PERIOD);
- RNN_COPY(&aligned_in[TRAINING_OFFSET], in, FRAME_SIZE-TRAINING_OFFSET);
+ OPUS_MOVE(st->exc_buf, &st->exc_buf[FRAME_SIZE], PITCH_MAX_PERIOD);
+ OPUS_COPY(&aligned_in[TRAINING_OFFSET], in, FRAME_SIZE-TRAINING_OFFSET);
for (i=0;i<FRAME_SIZE;i++) {
int j;
float sum = aligned_in[i];
for (j=0;j<LPC_ORDER;j++)
sum += st->lpc[j]*st->pitch_mem[j];
- RNN_MOVE(st->pitch_mem+1, st->pitch_mem, LPC_ORDER-1);
+ OPUS_MOVE(st->pitch_mem+1, st->pitch_mem, LPC_ORDER-1);
st->pitch_mem[0] = aligned_in[i];
st->exc_buf[PITCH_MAX_PERIOD+i] = sum + .7f*st->pitch_filt;
st->pitch_filt = sum;
@@ -192,7 +193,7 @@ void process_single_frame(LPCNetEncState *st, FILE *ffeat) {
for (i=0;i<PITCH_MAX_PERIOD-PITCH_MIN_PERIOD;i++) st->pitch_max_path[1][i] -= max_path_all;
/*for (i=0;i<PITCH_MAX_PERIOD-PITCH_MIN_PERIOD;i++) printf("%f ", st->pitch_max_path[1][i]);
printf("\n");*/
- RNN_COPY(&st->pitch_max_path[0][0], &st->pitch_max_path[1][0], PITCH_MAX_PERIOD);
+ OPUS_COPY(&st->pitch_max_path[0][0], &st->pitch_max_path[1][0], PITCH_MAX_PERIOD);
st->pitch_max_path_all = max_path_all;
st->best_i = best_i;
}
@@ -226,7 +227,7 @@ static int lpcnet_compute_single_frame_features_impl(LPCNetEncState *st, float *
preemphasis(x, &st->mem_preemph, x, PREEMPHASIS, FRAME_SIZE);
compute_frame_features(st, x);
process_single_frame(st, NULL);
- RNN_COPY(features, &st->features[0], NB_TOTAL_FEATURES);
+ OPUS_COPY(features, &st->features[0], NB_TOTAL_FEATURES);
return 0;
}
diff --git a/dnn/lpcnet_plc.c b/dnn/lpcnet_plc.c
index 6f61b9c7..6cba005b 100644
--- a/dnn/lpcnet_plc.c
+++ b/dnn/lpcnet_plc.c
@@ -31,6 +31,7 @@
#include "lpcnet_private.h"
#include "lpcnet.h"
#include "plc_data.h"
+#include "os_support.h"
#ifndef M_PI
#define M_PI 3.141592653
@@ -44,12 +45,12 @@ int lpcnet_plc_get_size() {
}
void lpcnet_plc_reset(LPCNetPLCState *st) {
- RNN_CLEAR((char*)&st->LPCNET_PLC_RESET_START,
+ OPUS_CLEAR((char*)&st->LPCNET_PLC_RESET_START,
sizeof(LPCNetPLCState)-
((char*)&st->LPCNET_PLC_RESET_START - (char*)st));
lpcnet_reset(&st->lpcnet);
lpcnet_encoder_init(&st->enc);
- RNN_CLEAR(st->pcm, PLC_BUF_SIZE);
+ OPUS_CLEAR(st->pcm, PLC_BUF_SIZE);
st->pcm_fill = PLC_BUF_SIZE;
st->skip_analysis = 0;
st->blend = 0;
@@ -110,12 +111,12 @@ void lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features) {
fprintf(stderr, "FEC buffer full\n");
return;
}
- RNN_MOVE(&st->fec[0][0], &st->fec[st->fec_keep_pos][0], (st->fec_fill_pos-st->fec_keep_pos)*NB_FEATURES);
+ OPUS_MOVE(&st->fec[0][0], &st->fec[st->fec_keep_pos][0], (st->fec_fill_pos-st->fec_keep_pos)*NB_FEATURES);
st->fec_fill_pos = st->fec_fill_pos-st->fec_keep_pos;
st->fec_read_pos -= st->fec_keep_pos;
st->fec_keep_pos = 0;
}
- RNN_COPY(&st->fec[st->fec_fill_pos][0], features, NB_FEATURES);
+ OPUS_COPY(&st->fec[st->fec_fill_pos][0], features, NB_FEATURES);
st->fec_fill_pos++;
}
@@ -140,12 +141,12 @@ static int get_fec_or_pred(LPCNetPLCState *st, float *out) {
if (st->fec_read_pos != st->fec_fill_pos && st->fec_skip==0) {
float plc_features[2*NB_BANDS+NB_FEATURES+1] = {0};
float discard[NB_FEATURES];
- RNN_COPY(out, &st->fec[st->fec_read_pos][0], NB_FEATURES);
+ OPUS_COPY(out, &st->fec[st->fec_read_pos][0], NB_FEATURES);
st->fec_read_pos++;
/* Make sure we can rewind a few frames back at resync time. */
st->fec_keep_pos = IMAX(0, IMAX(st->fec_keep_pos, st->fec_read_pos-FEATURES_DELAY-1));
/* Update PLC state using FEC, so without Burg features. */
- RNN_COPY(&plc_features[2*NB_BANDS], out, NB_FEATURES);
+ OPUS_COPY(&plc_features[2*NB_BANDS], out, NB_FEATURES);
plc_features[2*NB_BANDS+NB_FEATURES] = -1;
compute_plc_pred(st, discard, plc_features);
return 1;
@@ -165,11 +166,11 @@ static void fec_rewind(LPCNetPLCState *st, int offset) {
}
void clear_state(LPCNetPLCState *st) {
- RNN_CLEAR(st->lpcnet.last_sig, LPC_ORDER);
+ OPUS_CLEAR(st->lpcnet.last_sig, LPC_ORDER);
st->lpcnet.last_exc = lin2ulaw(0.f);
st->lpcnet.deemph_mem = 0;
- RNN_CLEAR(st->lpcnet.nnet.gru_a_state, GRU_A_STATE_SIZE);
- RNN_CLEAR(st->lpcnet.nnet.gru_b_state, GRU_B_STATE_SIZE);
+ OPUS_CLEAR(st->lpcnet.nnet.gru_a_state, GRU_A_STATE_SIZE);
+ OPUS_CLEAR(st->lpcnet.nnet.gru_b_state, GRU_B_STATE_SIZE);
}
/* In this causal version of the code, the DNN model implemented by compute_plc_pred()
@@ -188,7 +189,7 @@ int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
if (st->blend) {
opus_int16 tmp[FRAME_SIZE-TRAINING_OFFSET];
float zeros[2*NB_BANDS+NB_FEATURES+1] = {0};
- RNN_COPY(zeros, plc_features, 2*NB_BANDS);
+ OPUS_COPY(zeros, plc_features, 2*NB_BANDS);
zeros[2*NB_BANDS+NB_FEATURES] = 1;
if (st->enable_blending) {
LPCNetState copy;
@@ -213,14 +214,14 @@ int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
#ifdef PLC_SKIP_UPDATES
lpcnet_reset_signal(&st->lpcnet);
#else
- RNN_COPY(tmp, pcm, FRAME_SIZE-TRAINING_OFFSET);
+ OPUS_COPY(tmp, pcm, FRAME_SIZE-TRAINING_OFFSET);
lpcnet_synthesize_tail_impl(&st->lpcnet, tmp, FRAME_SIZE-TRAINING_OFFSET, FRAME_SIZE-TRAINING_OFFSET);
#endif
}
- RNN_COPY(st->pcm, &pcm[FRAME_SIZE-TRAINING_OFFSET], TRAINING_OFFSET);
+ OPUS_COPY(st->pcm, &pcm[FRAME_SIZE-TRAINING_OFFSET], TRAINING_OFFSET);
st->pcm_fill = TRAINING_OFFSET;
} else {
- RNN_COPY(&st->pcm[st->pcm_fill], pcm, FRAME_SIZE);
+ OPUS_COPY(&st->pcm[st->pcm_fill], pcm, FRAME_SIZE);
st->pcm_fill += FRAME_SIZE;
}
}
@@ -231,7 +232,7 @@ int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
compute_frame_features(&st->enc, x);
process_single_frame(&st->enc, NULL);
if (!st->blend) {
- RNN_COPY(&plc_features[2*NB_BANDS], st->enc.features, NB_FEATURES);
+ OPUS_COPY(&plc_features[2*NB_BANDS], st->enc.features, NB_FEATURES);
plc_features[2*NB_BANDS+NB_FEATURES] = 1;
compute_plc_pred(st, st->features, plc_features);
/* Discard an FEC frame that we know we will no longer need. */
@@ -247,7 +248,7 @@ int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
st->skip_analysis--;
} else {
for (i=0;i<FRAME_SIZE;i++) st->pcm[PLC_BUF_SIZE+i] = pcm[i];
- RNN_COPY(output, &st->pcm[0], FRAME_SIZE);
+ OPUS_COPY(output, &st->pcm[0], FRAME_SIZE);
#ifdef PLC_SKIP_UPDATES
{
run_frame_network_deferred(&st->lpcnet, st->enc.features);
@@ -255,7 +256,7 @@ int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
#else
lpcnet_synthesize_impl(&st->lpcnet, st->enc.features, output, FRAME_SIZE, FRAME_SIZE);
#endif
- RNN_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE);
+ OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE);
}
st->loss_count = 0;
st->blend = 0;
@@ -273,16 +274,16 @@ int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) {
/*fprintf(stderr, "update state for PLC %d\n", st->pcm_fill);*/
int update_count;
update_count = IMIN(st->pcm_fill, FRAME_SIZE);
- RNN_COPY(output, &st->pcm[0], update_count);
- RNN_MOVE(&st->plc_copy[1], &st->plc_copy[0], FEATURES_DELAY);
+ OPUS_COPY(output, &st->pcm[0], update_count);
+ OPUS_MOVE(&st->plc_copy[1], &st->plc_copy[0], FEATURES_DELAY);
st->plc_copy[0] = st->plc_net;
get_fec_or_pred(st, st->features);
lpcnet_synthesize_impl(&st->lpcnet, &st->features[0], output, update_count, update_count);
- RNN_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE);
+ OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE);
st->pcm_fill -= update_count;
st->skip_analysis++;
}
- RNN_MOVE(&st->plc_copy[1], &st->plc_copy[0], FEATURES_DELAY);
+ OPUS_MOVE(&st->plc_copy[1], &st->plc_copy[0], FEATURES_DELAY);
st->plc_copy[0] = st->plc_net;
lpcnet_synthesize_tail_impl(&st->lpcnet, pcm, FRAME_SIZE-TRAINING_OFFSET, 0);
if (get_fec_or_pred(st, st->features)) st->loss_count = 0;
diff --git a/dnn/nnet.c b/dnn/nnet.c
index e5e12c20..b4fe8457 100644
--- a/dnn/nnet.c
+++ b/dnn/nnet.c
@@ -40,6 +40,7 @@
#include "nnet_data.h"
#include "dred_rdovae_constants.h"
#include "plc_data.h"
+#include "os_support.h"
#ifdef NO_OPTIMIZATIONS
#if defined(_MSC_VER)
@@ -99,7 +100,7 @@ void compute_activation(float *output, const float *input, int N, int activation
output[i] = relu(input[i]);
} else if (activation == ACTIVATION_SOFTMAX) {
#ifdef SOFTMAX_HACK
- RNN_COPY(output, input, N);
+ OPUS_COPY(output, input, N);
/*for (i=0;i<N;i++)
output[i] = input[i];*/
#else
@@ -390,7 +391,7 @@ void compute_gru3(const GRULayer *gru, float *state, const float *input)
celt_assert(input != state);
celt_assert(gru->reset_after);
stride = 3*N;
- RNN_COPY(zrh, input, 3*N);
+ OPUS_COPY(zrh, input, 3*N);
for (i=0;i<3*N;i++)
recur[i] = gru->bias[3*N + i];
sgemv_accum8x4(recur, gru->recurrent_weights, 3*N, N, stride, state);
@@ -457,8 +458,8 @@ void compute_conv1d(const Conv1DLayer *layer, float *output, float *mem, const f
float tmp[MAX_CONV_INPUTS_ALL];
celt_assert(input != output);
celt_assert(layer->nb_inputs*layer->kernel_size <= MAX_CONV_INPUTS_ALL);
- RNN_COPY(tmp, mem, layer->nb_inputs*(layer->kernel_size-1));
- RNN_COPY(&tmp[layer->nb_inputs*(layer->kernel_size-1)], input, layer->nb_inputs);
+ OPUS_COPY(tmp, mem, layer->nb_inputs*(layer->kernel_size-1));
+ OPUS_COPY(&tmp[layer->nb_inputs*(layer->kernel_size-1)], input, layer->nb_inputs);
M = layer->nb_inputs*layer->kernel_size;
N = layer->nb_neurons;
stride = N;
@@ -466,7 +467,7 @@ void compute_conv1d(const Conv1DLayer *layer, float *output, float *mem, const f
output[i] = layer->bias[i];
sgemv_accum(output, layer->input_weights, N, M, stride, tmp);
compute_activation(output, output, N, layer->activation);
- RNN_COPY(mem, &tmp[layer->nb_inputs], layer->nb_inputs*(layer->kernel_size-1));
+ OPUS_COPY(mem, &tmp[layer->nb_inputs], layer->nb_inputs*(layer->kernel_size-1));
}
void compute_embedding(const EmbeddingLayer *layer, float *output, int input)
diff --git a/dnn/write_lpcnet_weights.c b/dnn/write_lpcnet_weights.c
index b072a5ff..2742f30a 100644
--- a/dnn/write_lpcnet_weights.c
+++ b/dnn/write_lpcnet_weights.c
@@ -33,6 +33,7 @@
#include <stddef.h>
#include "nnet.h"
#include "common.h"
+#include "os_support.h"
/* This is a bit of a hack because we need to build nnet_data.c and plc_data.c without USE_WEIGHTS_FILE,
but USE_WEIGHTS_FILE is defined in config.h. */
@@ -56,7 +57,7 @@ void write_weights(const WeightArray *list, FILE *fout)
h.type = list[i].type;
h.size = list[i].size;
h.block_size = (h.size+WEIGHT_BLOCK_SIZE-1)/WEIGHT_BLOCK_SIZE*WEIGHT_BLOCK_SIZE;
- RNN_CLEAR(h.name, sizeof(h.name));
+ OPUS_CLEAR(h.name, sizeof(h.name));
strncpy(h.name, list[i].name, sizeof(h.name));
h.name[sizeof(h.name)-1] = 0;
celt_assert(sizeof(h) == WEIGHT_BLOCK_SIZE);
diff --git a/silk/dred_encoder.c b/silk/dred_encoder.c
index c2628c7f..0f77e96a 100644
--- a/silk/dred_encoder.c
+++ b/silk/dred_encoder.c
@@ -56,7 +56,7 @@ int dred_encoder_load_model(DREDEnc* enc, const unsigned char *data, int len)
void dred_encoder_reset(DREDEnc* enc)
{
- RNN_CLEAR((char*)&enc->DREDENC_RESET_START,
+ OPUS_CLEAR((char*)&enc->DREDENC_RESET_START,
sizeof(DREDEnc)-
((char*)&enc->DREDENC_RESET_START - (char*)enc));
enc->input_buffer_fill = DRED_SILK_ENCODER_DELAY;