aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--codec/Makefile10
-rw-r--r--codec/compat_bits.h24
-rw-r--r--codec/ecc.c4
-rw-r--r--codec/frame.c2
-rw-r--r--codec/private.h4
5 files changed, 40 insertions, 4 deletions
diff --git a/codec/Makefile b/codec/Makefile
index 4393d97..3af051a 100644
--- a/codec/Makefile
+++ b/codec/Makefile
@@ -1,6 +1,12 @@
CC=gcc
-CFLAGS=`pkg-config libosmocore --cflags` -Wall -O2 -march=native
-LDLIBS=`pkg-config libosmocore --libs` -lm
+CFLAGS=-Wall -O2 -march=native
+LDLIBS=-lm
+
+CHK_LIBOSMOCORE_RV=$(shell pkg-config --exists libosmocore; echo $$?)
+ifeq ($(CHK_LIBOSMOCORE_RV),0)
+CFLAGS+=`pkg-config libosmocore --cflags` -DHAVE_LIBOSMOCORE
+LDLIBS+=`pkg-config libosmocore --libs`
+endif
OBJS=ir77_ambe_decode
diff --git a/codec/compat_bits.h b/codec/compat_bits.h
new file mode 100644
index 0000000..038b3cd
--- /dev/null
+++ b/codec/compat_bits.h
@@ -0,0 +1,24 @@
+#ifndef __OSMO_IR77_AMBE_COMPAT_BITS_H__
+#define __OSMO_IR77_AMBE_COMPAT_BITS_H__
+
+#include <stdint.h>
+
+typedef uint8_t ubit_t;
+typedef uint8_t pbit_t;
+
+static inline int
+osmo_pbit2ubit_ext(
+ ubit_t *out, unsigned int out_ofs,
+ const pbit_t *in, unsigned int in_ofs,
+ unsigned int num_bits, int lsb_mode)
+{
+ int i, ip, bn;
+ for (i=0; i<num_bits; i++) {
+ ip = in_ofs + i;
+ bn = lsb_mode ? (ip&7) : (7-(ip&7));
+ out[out_ofs+i] = !!(in[ip>>3] & (1<<bn));
+ }
+ return out_ofs + num_bits;
+}
+
+#endif /* __OSMO_IR77_AMBE_COMPAT_BITS_H__ */
diff --git a/codec/ecc.c b/codec/ecc.c
index d282a8a..7a2204d 100644
--- a/codec/ecc.c
+++ b/codec/ecc.c
@@ -25,7 +25,11 @@
* \brief Iridium AMBE vocoder ECC routines
*/
+#ifdef HAVE_LIBOSMOCORE
#include <osmocom/core/bits.h>
+#else
+#include "compat_bits.h"
+#endif
#include "ecc_tables.h"
diff --git a/codec/frame.c b/codec/frame.c
index 7a3eb3e..8ecc819 100644
--- a/codec/frame.c
+++ b/codec/frame.c
@@ -32,8 +32,6 @@
#include <math.h>
-#include <osmocom/core/bits.h>
-
#include "private.h"
diff --git a/codec/private.h b/codec/private.h
index b64252d..ed04984 100644
--- a/codec/private.h
+++ b/codec/private.h
@@ -29,7 +29,11 @@
* \brief Iridium AMBE vocoder private header
*/
+#ifdef HAVE_LIBOSMOCORE
#include <osmocom/core/bits.h>
+#else
+#include "compat_bits.h"
+#endif
#define AMBE_RATE 8000 /*!< \brief AMBE sample rate (Hz) */