ref: 2c0e96796eb8b3e8c547556d79b3bc9ba5023446
parent: 849f3abf32c6df7a613c5bb4ca6a85693ffaddd2
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Mon Mar 18 17:53:28 EDT 2019
Fixing dynamic libraries
--- a/dnn/configure.ac
+++ b/dnn/configure.ac
@@ -38,9 +38,9 @@
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)
--- 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
--- 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 @@
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 @@
}
-LPCNetState *lpcnet_create()
+LPCNET_EXPORT LPCNetState *lpcnet_create()
{
LPCNetState *lpcnet;
lpcnet = (LPCNetState *)calloc(lpcnet_get_size(), 1);
@@ -110,12 +114,12 @@
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,12 +171,12 @@
}
-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);
@@ -179,7 +183,7 @@
return 0;
}
-LPCNetDecState *lpcnet_decoder_create()
+LPCNET_EXPORT LPCNetDecState *lpcnet_decoder_create()
{
LPCNetDecState *st;
st = malloc(lpcnet_decoder_get_size());
@@ -187,12 +191,12 @@
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];
--- 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"
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -375,7 +375,7 @@
}
}
-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,16 +462,16 @@
}
-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);
@@ -478,7 +478,7 @@
return st;
}
-void lpcnet_encoder_destroy(LPCNetEncState *st) {
+LPCNET_EXPORT void lpcnet_encoder_destroy(LPCNetEncState *st) {
free(st);
}
@@ -721,7 +721,7 @@
}
}
-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];
--
⑨