summaryrefslogtreecommitdiff
path: root/amrwb
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:44:24 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:44:24 +0900
commite28f3aee8eca3cc7a10935f63899d5c4f6ba1ede (patch)
tree3e9da8eb6a913278403e100d0bbe0b9231a4b6ac /amrwb
parent54f90e8fa8d02c96e2c6d0a5bd71603dc016cf70 (diff)
downloadopencore-amr-e28f3aee8eca3cc7a10935f63899d5c4f6ba1ede.tar.gz
opencore-amr-e28f3aee8eca3cc7a10935f63899d5c4f6ba1ede.tar.bz2
opencore-amr-e28f3aee8eca3cc7a10935f63899d5c4f6ba1ede.zip
Tizen 2.1 base
Diffstat (limited to 'amrwb')
-rw-r--r--amrwb/Makefile.alt98
-rw-r--r--amrwb/Makefile.am73
-rw-r--r--amrwb/dec_if.h36
-rw-r--r--amrwb/if_rom.h33
-rw-r--r--amrwb/opencore-amrwb.pc.in10
-rw-r--r--amrwb/wrapper.cpp128
6 files changed, 378 insertions, 0 deletions
diff --git a/amrwb/Makefile.alt b/amrwb/Makefile.alt
new file mode 100644
index 0000000..a59cea9
--- /dev/null
+++ b/amrwb/Makefile.alt
@@ -0,0 +1,98 @@
+# Just set OC_BASE to the opencore root, or set AMR_BASE directly to
+# a detached gsm_amr directory
+OC_BASE = ../opencore
+AMR_BASE = $(OC_BASE)/codecs_v2/audio/gsm_amr
+LIBDIR=lib
+BINDIR=bin
+
+# To compile as C instead of C++, define BUILD_AS_C
+ifneq (, $(BUILD_AS_C))
+ CXX = $(CC)
+ CXXFLAGS += -x c -std=c99
+endif
+
+ifeq (, $(PREFIX))
+ PREFIX = /usr/local
+endif
+
+DEC_DIR = $(AMR_BASE)/amr_wb/dec
+DEC_SRC_DIR = $(DEC_DIR)/src
+OSCL = ../oscl
+
+CPPFLAGS = -I$(OSCL) -I$(DEC_SRC_DIR) -I$(DEC_DIR)/include -I$(AMR_BASE)/common/dec/include
+
+# Find all the source files
+# Exclude only decoder_amr_wb.cpp, not dtx_decoder_amr_wb.cpp
+DEC_SRC := $(shell cd $(DEC_SRC_DIR) && echo *.cpp | sed 's/ decoder_amr_wb.cpp//')
+
+DEC_OBJS := $(DEC_SRC:.cpp=.o)
+DEC_OBJS := $(patsubst %,$(DEC_SRC_DIR)/%, $(DEC_OBJS))
+
+OBJS = wrapper.o $(DEC_OBJS)
+SOBJS = $(OBJS:%.o=%.lo)
+
+#Versioning
+MAJOR = 0
+MINOR = 1
+REVISION = 1
+VERSION = $(MAJOR).$(MINOR).$(REVISION)
+
+ifeq ($(shell uname), Darwin)
+ SHLIB_EXT = dylib
+ SHLIB_FLAGS = -dynamiclib
+else
+ ifeq ($(shell uname | sed -e 's/\(MINGW32_NT\)\(.*\)/\1/'), MINGW32_NT)
+ SHLIB_EXT = $(MAJOR).$(MINOR).$(REVISION).dll
+ SHLIB_FLAGS = -shared
+ SONAME = libopencore-amrwb-$(MAJOR).dll
+ else
+ SHLIB_EXT = so.$(MAJOR).$(MINOR).$(REVISION)
+ SHLIB_FLAGS = -shared
+ SONAME = libopencore-amrwb.so.$(MAJOR)
+ endif
+endif
+SHLIB = libopencore-amrwb.$(SHLIB_EXT)
+
+all: libopencore-amrwb.a $(SHLIB)
+
+$(SHLIB): $(SOBJS)
+ifeq ($(shell uname), Darwin)
+ $(CXX) $(SHLIB_FLAGS) -o $@ $+ $(LDFLAGS)
+else
+ $(CXX) $(SHLIB_FLAGS) -o $@ $+ -Wl,-soname,$(SONAME) $(LDFLAGS)
+endif
+
+%.lo: %.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -DPIC -c $< -o $@
+
+%.lo: %.cpp
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -fPIC -DPIC -c $< -o $@
+
+libopencore-amrwb.a: $(OBJS)
+ ar rcs $@ $+
+
+install: libopencore-amrwb.a $(SHLIB)
+ install -d $(DESTDIR)$(PREFIX)/$(LIBDIR)
+ install -m 644 libopencore-amrwb.a $(DESTDIR)$(PREFIX)/$(LIBDIR)
+ifeq ($(shell uname | sed -e 's/\(MINGW32_NT\)\(.*\)/\1/'), MINGW32_NT)
+ install -d $(DESTDIR)$(PREFIX)/$(BINDIR)
+ install $(SHLIB) $(DESTDIR)$(PREFIX)/$(BINDIR)
+else
+ install $(SHLIB) $(DESTDIR)$(PREFIX)/$(LIBDIR)
+endif
+ifneq ($(shell uname), Darwin)
+ifeq ($(shell uname | sed -e 's/\(MINGW32_NT\)\(.*\)/\1/'), MINGW32_NT)
+ ln -sf $(SHLIB) $(DESTDIR)$(PREFIX)/$(BINDIR)/$(SONAME)
+ ln -sf $(DESTDIR)$(PREFIX)/$(BINDIR)/$(SONAME) $(DESTDIR)$(PREFIX)/$(BINDIR)/libopencore-amrwb.dll
+else
+ ln -sf $(SHLIB) $(DESTDIR)$(PREFIX)/$(LIBDIR)/$(SONAME)
+ ln -sf $(SONAME) $(DESTDIR)$(PREFIX)/$(LIBDIR)/libopencore-amrwb.so
+endif
+endif
+ install -d $(DESTDIR)$(PREFIX)/include/opencore-amrwb
+ install -m 644 dec_if.h $(DESTDIR)$(PREFIX)/include/opencore-amrwb
+ install -m 644 if_rom.h $(DESTDIR)$(PREFIX)/include/opencore-amrwb
+
+clean:
+ rm -f $(SHLIB) libopencore-amrwb.a *.o *.lo $(OBJS) $(SOBJS)
+
diff --git a/amrwb/Makefile.am b/amrwb/Makefile.am
new file mode 100644
index 0000000..37a917f
--- /dev/null
+++ b/amrwb/Makefile.am
@@ -0,0 +1,73 @@
+# Just set OC_BASE to the opencore root, or set AMR_BASE directly to
+# a detached gsm_amr directory
+OC_BASE = $(top_srcdir)/opencore
+AMR_BASE = $(OC_BASE)/codecs_v2/audio/gsm_amr
+
+DEC_DIR = $(AMR_BASE)/amr_wb/dec
+DEC_SRC_DIR = $(DEC_DIR)/src
+OSCL = $(top_srcdir)/oscl
+
+AM_CFLAGS = -I$(OSCL) -I$(DEC_SRC_DIR) -I$(DEC_DIR)/include \
+ -I$(AMR_BASE)/common/dec/include
+
+if COMPILE_AS_C
+ AM_CFLAGS += -x c -std=c99
+endif
+
+AM_CXXFLAGS = $(AM_CFLAGS)
+
+amrwbincludedir = $(includedir)/opencore-amrwb
+amrwbinclude_HEADERS = dec_if.h if_rom.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = opencore-amrwb.pc
+
+lib_LTLIBRARIES = libopencore-amrwb.la
+
+libopencore_amrwb_la_LDFLAGS = -version-info @OPENCORE_AMRWB_VERSION@
+
+# Our sources to include. There are certain sources we exclude and they are
+# $(DEC_SRC_DIR)/decoder_amr_wb.cpp
+libopencore_amrwb_la_SOURCES = \
+ wrapper.cpp \
+ $(DEC_SRC_DIR)/agc2_amr_wb.cpp \
+ $(DEC_SRC_DIR)/band_pass_6k_7k.cpp \
+ $(DEC_SRC_DIR)/dec_acelp_2p_in_64.cpp \
+ $(DEC_SRC_DIR)/dec_acelp_4p_in_64.cpp \
+ $(DEC_SRC_DIR)/dec_alg_codebook.cpp \
+ $(DEC_SRC_DIR)/dec_gain2_amr_wb.cpp \
+ $(DEC_SRC_DIR)/deemphasis_32.cpp \
+ $(DEC_SRC_DIR)/dtx_decoder_amr_wb.cpp \
+ $(DEC_SRC_DIR)/get_amr_wb_bits.cpp \
+ $(DEC_SRC_DIR)/highpass_400hz_at_12k8.cpp \
+ $(DEC_SRC_DIR)/highpass_50hz_at_12k8.cpp \
+ $(DEC_SRC_DIR)/homing_amr_wb_dec.cpp \
+ $(DEC_SRC_DIR)/interpolate_isp.cpp \
+ $(DEC_SRC_DIR)/isf_extrapolation.cpp \
+ $(DEC_SRC_DIR)/isp_az.cpp \
+ $(DEC_SRC_DIR)/isp_isf.cpp \
+ $(DEC_SRC_DIR)/lagconceal.cpp \
+ $(DEC_SRC_DIR)/low_pass_filt_7k.cpp \
+ $(DEC_SRC_DIR)/median5.cpp \
+ $(DEC_SRC_DIR)/mime_io.cpp \
+ $(DEC_SRC_DIR)/noise_gen_amrwb.cpp \
+ $(DEC_SRC_DIR)/normalize_amr_wb.cpp \
+ $(DEC_SRC_DIR)/oversamp_12k8_to_16k.cpp \
+ $(DEC_SRC_DIR)/phase_dispersion.cpp \
+ $(DEC_SRC_DIR)/pit_shrp.cpp \
+ $(DEC_SRC_DIR)/pred_lt4.cpp \
+ $(DEC_SRC_DIR)/preemph_amrwb_dec.cpp \
+ $(DEC_SRC_DIR)/pvamrwbdecoder.cpp \
+ $(DEC_SRC_DIR)/pvamrwb_math_op.cpp \
+ $(DEC_SRC_DIR)/q_gain2_tab.cpp \
+ $(DEC_SRC_DIR)/qisf_ns.cpp \
+ $(DEC_SRC_DIR)/qisf_ns_tab.cpp \
+ $(DEC_SRC_DIR)/qpisf_2s.cpp \
+ $(DEC_SRC_DIR)/qpisf_2s_tab.cpp \
+ $(DEC_SRC_DIR)/scale_signal.cpp \
+ $(DEC_SRC_DIR)/synthesis_amr_wb.cpp \
+ $(DEC_SRC_DIR)/voice_factor.cpp \
+ $(DEC_SRC_DIR)/wb_syn_filt.cpp \
+ $(DEC_SRC_DIR)/weight_amrwb_lpc.cpp
+
+EXTRA_DIST = Makefile.alt
diff --git a/amrwb/dec_if.h b/amrwb/dec_if.h
new file mode 100644
index 0000000..56acdaa
--- /dev/null
+++ b/amrwb/dec_if.h
@@ -0,0 +1,36 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 2009 Martin Storsjo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef OPENCORE_AMRWB_DEC_IF_H
+#define OPENCORE_AMRWB_DEC_IF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define _good_frame 0
+
+void* D_IF_init(void);
+void D_IF_decode(void* state, const unsigned char* bits, short* synth, int bfi);
+void D_IF_exit(void* state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/amrwb/if_rom.h b/amrwb/if_rom.h
new file mode 100644
index 0000000..8977e03
--- /dev/null
+++ b/amrwb/if_rom.h
@@ -0,0 +1,33 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 2009 Martin Storsjo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef OPENCORE_AMRWB_IF_ROM_H
+#define OPENCORE_AMRWB_IF_ROM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+typedef int16_t Word16;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/amrwb/opencore-amrwb.pc.in b/amrwb/opencore-amrwb.pc.in
new file mode 100644
index 0000000..8446310
--- /dev/null
+++ b/amrwb/opencore-amrwb.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@/opencore-amrwb
+
+Name: OpenCORE AMR-WB
+Description: Adaptive Multi-Rate Wideband speech codec library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lopencore-amrwb
+Cflags: -I${includedir}
diff --git a/amrwb/wrapper.cpp b/amrwb/wrapper.cpp
new file mode 100644
index 0000000..dd28281
--- /dev/null
+++ b/amrwb/wrapper.cpp
@@ -0,0 +1,128 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "dec_if.h"
+#include <stdlib.h>
+#include <string.h>
+#include <pvamrwbdecoder_api.h>
+#include <pvamrwbdecoder.h>
+#include <pvamrwbdecoder_cnst.h>
+#include <dtx.h>
+
+/* This is basically a C rewrite of decode_amr_wb.cpp */
+
+struct state {
+ void *st; /* State structure */
+ unsigned char *pt_st;
+ int16 *ScratchMem;
+
+ uint8* iInputBuf;
+ int16* iInputSampleBuf;
+ int16* iOutputBuf;
+
+ uint8 quality;
+ int16 mode;
+ int16 mode_old;
+ int16 frame_type;
+
+ int16 reset_flag;
+ int16 reset_flag_old;
+ int16 status;
+ RX_State rx_state;
+};
+
+void* D_IF_init(void) {
+ struct state* state = (struct state*) malloc(sizeof(struct state));
+ memset(state, 0, sizeof(*state));
+
+ state->iInputSampleBuf = (int16*) malloc(sizeof(int16)*KAMRWB_NB_BITS_MAX);
+ state->reset_flag = 0;
+ state->reset_flag_old = 1;
+ state->mode_old = 0;
+ state->rx_state.prev_ft = RX_SPEECH_GOOD;
+ state->rx_state.prev_mode = 0;
+ state->pt_st = (unsigned char*) malloc(pvDecoder_AmrWbMemRequirements());
+
+ pvDecoder_AmrWb_Init(&state->st, state->pt_st, &state->ScratchMem);
+ return state;
+}
+
+void D_IF_exit(void* s) {
+ struct state* state = (struct state*) s;
+ free(state->pt_st);
+ free(state->iInputSampleBuf);
+ free(state);
+}
+
+void D_IF_decode(void* s, const unsigned char* in, short* out, int bfi) {
+ struct state* state = (struct state*) s;
+
+ state->mode = (in[0] >> 3) & 0x0f;
+ in++;
+
+ state->quality = 1; /* ? */
+ mime_unsorting((uint8*) in, state->iInputSampleBuf, &state->frame_type, &state->mode, state->quality, &state->rx_state);
+
+ if ((state->frame_type == RX_NO_DATA) | (state->frame_type == RX_SPEECH_LOST)) {
+ state->mode = state->mode_old;
+ state->reset_flag = 0;
+ } else {
+ state->mode_old = state->mode;
+
+ /* if homed: check if this frame is another homing frame */
+ if (state->reset_flag_old == 1) {
+ /* only check until end of first subframe */
+ state->reset_flag = pvDecoder_AmrWb_homing_frame_test_first(state->iInputSampleBuf, state->mode);
+ }
+ }
+
+ /* produce encoder homing frame if homed & input=decoder homing frame */
+ if ((state->reset_flag != 0) && (state->reset_flag_old != 0)) {
+ /* set homing sequence ( no need to decode anything */
+
+ for (int16 i = 0; i < AMR_WB_PCM_FRAME; i++) {
+ out[i] = EHF_MASK;
+ }
+ } else {
+ int16 frameLength;
+ state->status = pvDecoder_AmrWb(state->mode,
+ state->iInputSampleBuf,
+ out,
+ &frameLength,
+ state->st,
+ state->frame_type,
+ state->ScratchMem);
+ }
+
+ for (int16 i = 0; i < AMR_WB_PCM_FRAME; i++) { /* Delete the 2 LSBs (14-bit output) */
+ out[i] &= 0xfffC;
+ }
+
+ /* if not homed: check whether current frame is a homing frame */
+ if (state->reset_flag_old == 0) {
+ /* check whole frame */
+ state->reset_flag = pvDecoder_AmrWb_homing_frame_test(state->iInputSampleBuf, state->mode);
+ }
+ /* reset decoder if current frame is a homing frame */
+ if (state->reset_flag != 0) {
+ pvDecoder_AmrWb_Reset(state->st, 1);
+ }
+ state->reset_flag_old = state->reset_flag;
+
+}
+