From 2c0e96796eb8b3e8c547556d79b3bc9ba5023446 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jmvalin@jmvalin.ca> Date: Mon, 18 Mar 2019 21:53:28 -0400 Subject: [PATCH] Fixing dynamic libraries --- dnn/configure.ac | 6 +++--- dnn/include/lpcnet.h | 15 +++++++++++++++ dnn/lpcnet.c | 24 ++++++++++++++---------- dnn/lpcnet_demo.c | 4 ++++ dnn/lpcnet_enc.c | 12 ++++++------ 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/dnn/configure.ac b/dnn/configure.ac index ec9808b2a..262f2103b 100644 --- a/dnn/configure.ac +++ b/dnn/configure.ac @@ -38,9 +38,9 @@ dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0 dnl - interfaces added -> increment AGE dnl - interfaces removed -> AGE = 0 -OP_LT_CURRENT=4 -OP_LT_REVISION=1 -OP_LT_AGE=4 +OP_LT_CURRENT=0 +OP_LT_REVISION=0 +OP_LT_AGE=0 AC_SUBST(OP_LT_CURRENT) AC_SUBST(OP_LT_REVISION) diff --git a/dnn/include/lpcnet.h b/dnn/include/lpcnet.h index afeae5bbe..df78fb9eb 100644 --- a/dnn/include/lpcnet.h +++ b/dnn/include/lpcnet.h @@ -27,6 +27,21 @@ #ifndef _LPCNET_H_ #define _LPCNET_H_ +#ifndef LPCNET_EXPORT +# if defined(WIN32) +# if defined(LPCNET_BUILD) && defined(DLL_EXPORT) +# define LPCNET_EXPORT __declspec(dllexport) +# else +# define LPCNET_EXPORT +# endif +# elif defined(__GNUC__) && defined(LPCNET_BUILD) +# define LPCNET_EXPORT __attribute__ ((visibility ("default"))) +# else +# define LPCNET_EXPORT +# endif +#endif + + #define NB_FEATURES 38 #define NB_TOTAL_FEATURES 55 diff --git a/dnn/lpcnet.c b/dnn/lpcnet.c index 349285252..fa5d2f598 100644 --- a/dnn/lpcnet.c +++ b/dnn/lpcnet.c @@ -24,6 +24,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <math.h> #include <stdio.h> #include "nnet_data.h" @@ -89,12 +93,12 @@ void run_sample_network(NNetState *net, float *pdf, const float *condition, cons compute_mdense(&dual_fc, pdf, net->gru_b_state); } -int lpcnet_get_size() +LPCNET_EXPORT int lpcnet_get_size() { return sizeof(LPCNetState); } -int lpcnet_init(LPCNetState *lpcnet) +LPCNET_EXPORT int lpcnet_init(LPCNetState *lpcnet) { memset(lpcnet, 0, lpcnet_get_size()); lpcnet->last_exc = 128; @@ -102,7 +106,7 @@ int lpcnet_init(LPCNetState *lpcnet) } -LPCNetState *lpcnet_create() +LPCNET_EXPORT LPCNetState *lpcnet_create() { LPCNetState *lpcnet; lpcnet = (LPCNetState *)calloc(lpcnet_get_size(), 1); @@ -110,12 +114,12 @@ LPCNetState *lpcnet_create() return lpcnet; } -void lpcnet_destroy(LPCNetState *lpcnet) +LPCNET_EXPORT void lpcnet_destroy(LPCNetState *lpcnet) { free(lpcnet); } -void lpcnet_synthesize(LPCNetState *lpcnet, short *output, const float *features, int N) +LPCNET_EXPORT void lpcnet_synthesize(LPCNetState *lpcnet, short *output, const float *features, int N) { int i; float condition[FEATURE_DENSE2_OUT_SIZE]; @@ -167,19 +171,19 @@ void lpcnet_synthesize(LPCNetState *lpcnet, short *output, const float *features } -int lpcnet_decoder_get_size() +LPCNET_EXPORT int lpcnet_decoder_get_size() { return sizeof(LPCNetDecState); } -int lpcnet_decoder_init(LPCNetDecState *st) +LPCNET_EXPORT int lpcnet_decoder_init(LPCNetDecState *st) { memset(st, 0, lpcnet_decoder_get_size()); lpcnet_init(&st->lpcnet_state); return 0; } -LPCNetDecState *lpcnet_decoder_create() +LPCNET_EXPORT LPCNetDecState *lpcnet_decoder_create() { LPCNetDecState *st; st = malloc(lpcnet_decoder_get_size()); @@ -187,12 +191,12 @@ LPCNetDecState *lpcnet_decoder_create() return st; } -void lpcnet_decoder_destroy(LPCNetDecState *st) +LPCNET_EXPORT void lpcnet_decoder_destroy(LPCNetDecState *st) { free(st); } -int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, short *pcm) +LPCNET_EXPORT int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, short *pcm) { int k; float features[4][NB_TOTAL_FEATURES]; diff --git a/dnn/lpcnet_demo.c b/dnn/lpcnet_demo.c index 43dd5d558..18f065423 100644 --- a/dnn/lpcnet_demo.c +++ b/dnn/lpcnet_demo.c @@ -24,6 +24,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <math.h> #include <stdio.h> #include "arch.h" diff --git a/dnn/lpcnet_enc.c b/dnn/lpcnet_enc.c index 17852e897..123da9230 100644 --- a/dnn/lpcnet_enc.c +++ b/dnn/lpcnet_enc.c @@ -375,7 +375,7 @@ void interp_diff(float *x, float *left, float *right, float *codebook, int bits, } } -int double_interp_search(const float features[4][NB_TOTAL_FEATURES], const float *mem) { +int double_interp_search(float features[4][NB_TOTAL_FEATURES], const float *mem) { int i, j; int best_id=0; float min_dist = 1e15; @@ -462,23 +462,23 @@ void bits_pack(packer *bits, unsigned int data, int nb_bits) { } -int lpcnet_encoder_get_size() { +LPCNET_EXPORT int lpcnet_encoder_get_size() { return sizeof(LPCNetEncState); } -int lpcnet_encoder_init(LPCNetEncState *st) { +LPCNET_EXPORT int lpcnet_encoder_init(LPCNetEncState *st) { memset(st, 0, sizeof(*st)); return 0; } -LPCNetEncState *lpcnet_encoder_create() { +LPCNET_EXPORT LPCNetEncState *lpcnet_encoder_create() { LPCNetEncState *st; st = malloc(lpcnet_encoder_get_size()); lpcnet_encoder_init(st); return st; } -void lpcnet_encoder_destroy(LPCNetEncState *st) { +LPCNET_EXPORT void lpcnet_encoder_destroy(LPCNetEncState *st) { free(st); } @@ -721,7 +721,7 @@ void preemphasis(float *y, float *mem, const float *x, float coef, int N) { } } -int lpcnet_encode(LPCNetEncState *st, const short *pcm, unsigned char *buf) { +LPCNET_EXPORT int lpcnet_encode(LPCNetEncState *st, const short *pcm, unsigned char *buf) { int i, k; for (k=0;k<4;k++) { float x[FRAME_SIZE]; -- GitLab