From e28f3aee8eca3cc7a10935f63899d5c4f6ba1ede Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Wed, 13 Mar 2013 01:44:24 +0900 Subject: Tizen 2.1 base --- amrnb/Makefile.alt | 119 +++++++++++++++++++++++++++ amrnb/Makefile.am | 200 +++++++++++++++++++++++++++++++++++++++++++++ amrnb/interf_dec.h | 34 ++++++++ amrnb/interf_enc.h | 50 ++++++++++++ amrnb/opencore-amrnb.pc.in | 10 +++ amrnb/wrapper.cpp | 67 +++++++++++++++ 6 files changed, 480 insertions(+) create mode 100644 amrnb/Makefile.alt create mode 100644 amrnb/Makefile.am create mode 100644 amrnb/interf_dec.h create mode 100644 amrnb/interf_enc.h create mode 100644 amrnb/opencore-amrnb.pc.in create mode 100644 amrnb/wrapper.cpp (limited to 'amrnb') diff --git a/amrnb/Makefile.alt b/amrnb/Makefile.alt new file mode 100644 index 0000000..0dbc567 --- /dev/null +++ b/amrnb/Makefile.alt @@ -0,0 +1,119 @@ +# 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_nb/dec +ENC_DIR = $(AMR_BASE)/amr_nb/enc +COMMON_DIR = $(AMR_BASE)/amr_nb/common +DEC_SRC_DIR = $(DEC_DIR)/src +ENC_SRC_DIR = $(ENC_DIR)/src +COMMON_SRC_DIR = $(COMMON_DIR)/src +OSCL = ../oscl + +CPPFLAGS = -I$(OSCL) -I$(DEC_SRC_DIR) -I$(COMMON_DIR)/include -I$(DEC_DIR)/include -I$(AMR_BASE)/common/dec/include -I$(ENC_SRC_DIR) + +# Find all the source files +DEC_SRC := $(shell cd $(DEC_SRC_DIR) && echo *.cpp) +ENC_SRC := $(shell cd $(ENC_SRC_DIR) && echo *.cpp) +COMMON_SRC := $(shell cd $(COMMON_SRC_DIR) && echo *.cpp) + +# Exclude these files +DEC_SRC := $(DEC_SRC:decoder_gsm_amr.cpp=) +DEC_SRC := $(DEC_SRC:pvgsmamrdecoder.cpp=) +ENC_SRC := $(ENC_SRC:gsmamr_encoder_wrapper.cpp=) +COMMON_SRC := $(COMMON_SRC:bits2prm.cpp=) +COMMON_SRC := $(COMMON_SRC:copy.cpp=) +COMMON_SRC := $(COMMON_SRC:div_32.cpp=) +COMMON_SRC := $(COMMON_SRC:l_abs.cpp=) +COMMON_SRC := $(COMMON_SRC:vad1.cpp=) +COMMON_SRC := $(COMMON_SRC:r_fft.cpp=) +COMMON_SRC := $(COMMON_SRC:vad2.cpp=) + +DEC_OBJS := $(DEC_SRC:.cpp=.o) +DEC_OBJS := $(patsubst %,$(DEC_SRC_DIR)/%, $(DEC_OBJS)) +ENC_OBJS := $(ENC_SRC:.cpp=.o) +ENC_OBJS := $(patsubst %,$(ENC_SRC_DIR)/%, $(ENC_OBJS)) +COMMON_OBJS := $(COMMON_SRC:.cpp=.o) +COMMON_OBJS := $(patsubst %,$(COMMON_SRC_DIR)/%, $(COMMON_OBJS)) + +OBJS = wrapper.o $(DEC_OBJS) $(ENC_OBJS) $(COMMON_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-amrnb-$(MAJOR).dll + else + SHLIB_EXT = so.$(MAJOR).$(MINOR).$(REVISION) + SHLIB_FLAGS = -shared + SONAME = libopencore-amrnb.so.$(MAJOR) + endif +endif +SHLIB = libopencore-amrnb.$(SHLIB_EXT) + +all: libopencore-amrnb.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-amrnb.a: $(OBJS) + ar rcs $@ $+ + +install: libopencore-amrnb.a $(SHLIB) + install -d $(DESTDIR)$(PREFIX)/$(LIBDIR) + install -m 644 libopencore-amrnb.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-amrnb.dll +else + ln -sf $(SHLIB) $(DESTDIR)$(PREFIX)/$(LIBDIR)/$(SONAME) + ln -sf $(SONAME) $(DESTDIR)$(PREFIX)/$(LIBDIR)/libopencore-amrnb.so +endif +endif + install -d $(DESTDIR)$(PREFIX)/include/opencore-amrnb + install -m 644 interf_dec.h $(DESTDIR)$(PREFIX)/include/opencore-amrnb + install -m 644 interf_enc.h $(DESTDIR)$(PREFIX)/include/opencore-amrnb + +clean: + rm -f $(SHLIB) libopencore-amrnb.a *.o *.lo $(OBJS) $(SOBJS) + diff --git a/amrnb/Makefile.am b/amrnb/Makefile.am new file mode 100644 index 0000000..cc4cf3c --- /dev/null +++ b/amrnb/Makefile.am @@ -0,0 +1,200 @@ +# 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_nb/dec +ENC_DIR = $(AMR_BASE)/amr_nb/enc +COMMON_DIR = $(AMR_BASE)/amr_nb/common +DEC_SRC_DIR = $(DEC_DIR)/src +ENC_SRC_DIR = $(ENC_DIR)/src +COMMON_SRC_DIR = $(COMMON_DIR)/src +OSCL = $(top_srcdir)/oscl + +AM_CFLAGS = -I$(OSCL) -I$(DEC_SRC_DIR) -I$(COMMON_DIR)/include \ + -I$(DEC_DIR)/include -I$(AMR_BASE)/common/dec/include -I$(ENC_SRC_DIR) + +if COMPILE_AS_C + AM_CFLAGS += -x c -std=c99 +endif + +AM_CXXFLAGS = $(AM_CFLAGS) + +amrnbincludedir = $(includedir)/opencore-amrnb +amrnbinclude_HEADERS = interf_dec.h interf_enc.h + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = opencore-amrnb.pc + +lib_LTLIBRARIES = libopencore-amrnb.la + +libopencore_amrnb_la_LDFLAGS = -version-info @OPENCORE_AMRNB_VERSION@ + +# Our sources to include. There are certain sources we exclude and they are +# $(DEC_SRC_DIR)/decoder_gsm_amr.cpp +# $(DEC_SRC_DIR)/pvgsmamrdecoder.cpp +# $(ENC_SRC_DIR)/gsmamr_encoder_wrapper.cpp +# $(COMMON_SRC_DIR)/bits2prm.cpp +# $(COMMON_SRC_DIR)/copy.cpp +# $(COMMON_SRC_DIR)/div_32.cpp +# $(COMMON_SRC_DIR)/l_abs.cpp +# $(COMMON_SRC_DIR)/r_fft.cpp +# $(COMMON_SRC_DIR)/vad1.cpp +# $(COMMON_SRC_DIR)/vad2.cpp +libopencore_amrnb_la_SOURCES = \ + wrapper.cpp \ + $(DEC_SRC_DIR)/agc.cpp \ + $(DEC_SRC_DIR)/amrdecode.cpp \ + $(DEC_SRC_DIR)/a_refl.cpp \ + $(DEC_SRC_DIR)/b_cn_cod.cpp \ + $(DEC_SRC_DIR)/bgnscd.cpp \ + $(DEC_SRC_DIR)/c_g_aver.cpp \ + $(DEC_SRC_DIR)/d1035pf.cpp \ + $(DEC_SRC_DIR)/d2_11pf.cpp \ + $(DEC_SRC_DIR)/d2_9pf.cpp \ + $(DEC_SRC_DIR)/d3_14pf.cpp \ + $(DEC_SRC_DIR)/d4_17pf.cpp \ + $(DEC_SRC_DIR)/d8_31pf.cpp \ + $(DEC_SRC_DIR)/dec_amr.cpp \ + $(DEC_SRC_DIR)/dec_gain.cpp \ + $(DEC_SRC_DIR)/dec_input_format_tab.cpp \ + $(DEC_SRC_DIR)/dec_lag3.cpp \ + $(DEC_SRC_DIR)/dec_lag6.cpp \ + $(DEC_SRC_DIR)/d_gain_c.cpp \ + $(DEC_SRC_DIR)/d_gain_p.cpp \ + $(DEC_SRC_DIR)/d_plsf_3.cpp \ + $(DEC_SRC_DIR)/d_plsf_5.cpp \ + $(DEC_SRC_DIR)/d_plsf.cpp \ + $(DEC_SRC_DIR)/dtx_dec.cpp \ + $(DEC_SRC_DIR)/ec_gains.cpp \ + $(DEC_SRC_DIR)/ex_ctrl.cpp \ + $(DEC_SRC_DIR)/if2_to_ets.cpp \ + $(DEC_SRC_DIR)/int_lsf.cpp \ + $(DEC_SRC_DIR)/lsp_avg.cpp \ + $(DEC_SRC_DIR)/ph_disp.cpp \ + $(DEC_SRC_DIR)/post_pro.cpp \ + $(DEC_SRC_DIR)/preemph.cpp \ + $(DEC_SRC_DIR)/pstfilt.cpp \ + $(DEC_SRC_DIR)/qgain475_tab.cpp \ + $(DEC_SRC_DIR)/sp_dec.cpp \ + $(DEC_SRC_DIR)/wmf_to_ets.cpp \ + $(ENC_SRC_DIR)/amrencode.cpp \ + $(ENC_SRC_DIR)/autocorr.cpp \ + $(ENC_SRC_DIR)/c1035pf.cpp \ + $(ENC_SRC_DIR)/c2_11pf.cpp \ + $(ENC_SRC_DIR)/c2_9pf.cpp \ + $(ENC_SRC_DIR)/c3_14pf.cpp \ + $(ENC_SRC_DIR)/c4_17pf.cpp \ + $(ENC_SRC_DIR)/c8_31pf.cpp \ + $(ENC_SRC_DIR)/calc_cor.cpp \ + $(ENC_SRC_DIR)/calc_en.cpp \ + $(ENC_SRC_DIR)/cbsearch.cpp \ + $(ENC_SRC_DIR)/cl_ltp.cpp \ + $(ENC_SRC_DIR)/cod_amr.cpp \ + $(ENC_SRC_DIR)/convolve.cpp \ + $(ENC_SRC_DIR)/cor_h.cpp \ + $(ENC_SRC_DIR)/cor_h_x2.cpp \ + $(ENC_SRC_DIR)/cor_h_x.cpp \ + $(ENC_SRC_DIR)/corrwght_tab.cpp \ + $(ENC_SRC_DIR)/div_32.cpp \ + $(ENC_SRC_DIR)/dtx_enc.cpp \ + $(ENC_SRC_DIR)/enc_lag3.cpp \ + $(ENC_SRC_DIR)/enc_lag6.cpp \ + $(ENC_SRC_DIR)/enc_output_format_tab.cpp \ + $(ENC_SRC_DIR)/ets_to_if2.cpp \ + $(ENC_SRC_DIR)/ets_to_wmf.cpp \ + $(ENC_SRC_DIR)/g_adapt.cpp \ + $(ENC_SRC_DIR)/gain_q.cpp \ + $(ENC_SRC_DIR)/g_code.cpp \ + $(ENC_SRC_DIR)/g_pitch.cpp \ + $(ENC_SRC_DIR)/hp_max.cpp \ + $(ENC_SRC_DIR)/inter_36.cpp \ + $(ENC_SRC_DIR)/inter_36_tab.cpp \ + $(ENC_SRC_DIR)/l_abs.cpp \ + $(ENC_SRC_DIR)/lag_wind.cpp \ + $(ENC_SRC_DIR)/lag_wind_tab.cpp \ + $(ENC_SRC_DIR)/l_comp.cpp \ + $(ENC_SRC_DIR)/levinson.cpp \ + $(ENC_SRC_DIR)/l_extract.cpp \ + $(ENC_SRC_DIR)/lflg_upd.cpp \ + $(ENC_SRC_DIR)/l_negate.cpp \ + $(ENC_SRC_DIR)/lpc.cpp \ + $(ENC_SRC_DIR)/ol_ltp.cpp \ + $(ENC_SRC_DIR)/pitch_fr.cpp \ + $(ENC_SRC_DIR)/pitch_ol.cpp \ + $(ENC_SRC_DIR)/p_ol_wgh.cpp \ + $(ENC_SRC_DIR)/pre_big.cpp \ + $(ENC_SRC_DIR)/pre_proc.cpp \ + $(ENC_SRC_DIR)/prm2bits.cpp \ + $(ENC_SRC_DIR)/qgain475.cpp \ + $(ENC_SRC_DIR)/qgain795.cpp \ + $(ENC_SRC_DIR)/q_gain_c.cpp \ + $(ENC_SRC_DIR)/q_gain_p.cpp \ + $(ENC_SRC_DIR)/qua_gain.cpp \ + $(ENC_SRC_DIR)/s10_8pf.cpp \ + $(ENC_SRC_DIR)/set_sign.cpp \ + $(ENC_SRC_DIR)/sid_sync.cpp \ + $(ENC_SRC_DIR)/sp_enc.cpp \ + $(ENC_SRC_DIR)/spreproc.cpp \ + $(ENC_SRC_DIR)/spstproc.cpp \ + $(ENC_SRC_DIR)/ton_stab.cpp \ + $(ENC_SRC_DIR)/vad1.cpp \ + $(COMMON_SRC_DIR)/add.cpp \ + $(COMMON_SRC_DIR)/az_lsp.cpp \ + $(COMMON_SRC_DIR)/bitno_tab.cpp \ + $(COMMON_SRC_DIR)/bitreorder_tab.cpp \ + $(COMMON_SRC_DIR)/bytesused.cpp \ + $(COMMON_SRC_DIR)/c2_9pf_tab.cpp \ + $(COMMON_SRC_DIR)/div_s.cpp \ + $(COMMON_SRC_DIR)/extract_h.cpp \ + $(COMMON_SRC_DIR)/extract_l.cpp \ + $(COMMON_SRC_DIR)/gains_tbl.cpp \ + $(COMMON_SRC_DIR)/gc_pred.cpp \ + $(COMMON_SRC_DIR)/get_const_tbls.cpp \ + $(COMMON_SRC_DIR)/gmed_n.cpp \ + $(COMMON_SRC_DIR)/gray_tbl.cpp \ + $(COMMON_SRC_DIR)/grid_tbl.cpp \ + $(COMMON_SRC_DIR)/int_lpc.cpp \ + $(COMMON_SRC_DIR)/inv_sqrt.cpp \ + $(COMMON_SRC_DIR)/inv_sqrt_tbl.cpp \ + $(COMMON_SRC_DIR)/l_deposit_h.cpp \ + $(COMMON_SRC_DIR)/l_deposit_l.cpp \ + $(COMMON_SRC_DIR)/log2.cpp \ + $(COMMON_SRC_DIR)/log2_norm.cpp \ + $(COMMON_SRC_DIR)/log2_tbl.cpp \ + $(COMMON_SRC_DIR)/lsfwt.cpp \ + $(COMMON_SRC_DIR)/l_shr_r.cpp \ + $(COMMON_SRC_DIR)/lsp_az.cpp \ + $(COMMON_SRC_DIR)/lsp.cpp \ + $(COMMON_SRC_DIR)/lsp_lsf.cpp \ + $(COMMON_SRC_DIR)/lsp_lsf_tbl.cpp \ + $(COMMON_SRC_DIR)/lsp_tab.cpp \ + $(COMMON_SRC_DIR)/mult_r.cpp \ + $(COMMON_SRC_DIR)/negate.cpp \ + $(COMMON_SRC_DIR)/norm_l.cpp \ + $(COMMON_SRC_DIR)/norm_s.cpp \ + $(COMMON_SRC_DIR)/overflow_tbl.cpp \ + $(COMMON_SRC_DIR)/ph_disp_tab.cpp \ + $(COMMON_SRC_DIR)/pow2.cpp \ + $(COMMON_SRC_DIR)/pow2_tbl.cpp \ + $(COMMON_SRC_DIR)/pred_lt.cpp \ + $(COMMON_SRC_DIR)/q_plsf_3.cpp \ + $(COMMON_SRC_DIR)/q_plsf_3_tbl.cpp \ + $(COMMON_SRC_DIR)/q_plsf_5.cpp \ + $(COMMON_SRC_DIR)/q_plsf_5_tbl.cpp \ + $(COMMON_SRC_DIR)/q_plsf.cpp \ + $(COMMON_SRC_DIR)/qua_gain_tbl.cpp \ + $(COMMON_SRC_DIR)/reorder.cpp \ + $(COMMON_SRC_DIR)/residu.cpp \ + $(COMMON_SRC_DIR)/round.cpp \ + $(COMMON_SRC_DIR)/set_zero.cpp \ + $(COMMON_SRC_DIR)/shr.cpp \ + $(COMMON_SRC_DIR)/shr_r.cpp \ + $(COMMON_SRC_DIR)/sqrt_l.cpp \ + $(COMMON_SRC_DIR)/sqrt_l_tbl.cpp \ + $(COMMON_SRC_DIR)/sub.cpp \ + $(COMMON_SRC_DIR)/syn_filt.cpp \ + $(COMMON_SRC_DIR)/weight_a.cpp \ + $(COMMON_SRC_DIR)/window_tab.cpp + +EXTRA_DIST = Makefile.alt diff --git a/amrnb/interf_dec.h b/amrnb/interf_dec.h new file mode 100644 index 0000000..98051f4 --- /dev/null +++ b/amrnb/interf_dec.h @@ -0,0 +1,34 @@ +/* ------------------------------------------------------------------ + * 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_AMRNB_INTERF_DEC_H +#define OPENCORE_AMRNB_INTERF_DEC_H + +#ifdef __cplusplus +extern "C" { +#endif + +void* Decoder_Interface_init(void); +void Decoder_Interface_exit(void* state); +void Decoder_Interface_Decode(void* state, const unsigned char* in, short* out, int bfi); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/amrnb/interf_enc.h b/amrnb/interf_enc.h new file mode 100644 index 0000000..b89b0c7 --- /dev/null +++ b/amrnb/interf_enc.h @@ -0,0 +1,50 @@ +/* ------------------------------------------------------------------ + * 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_AMRNB_INTERF_ENC_H +#define OPENCORE_AMRNB_INTERF_ENC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef AMRNB_WRAPPER_INTERNAL +/* Copied from enc/src/gsmamr_enc.h */ +enum Mode { + MR475 = 0,/* 4.75 kbps */ + MR515, /* 5.15 kbps */ + MR59, /* 5.90 kbps */ + MR67, /* 6.70 kbps */ + MR74, /* 7.40 kbps */ + MR795, /* 7.95 kbps */ + MR102, /* 10.2 kbps */ + MR122, /* 12.2 kbps */ + MRDTX, /* DTX */ + N_MODES /* Not Used */ +}; +#endif + +void* Encoder_Interface_init(int dtx); +void Encoder_Interface_exit(void* state); +int Encoder_Interface_Encode(void* state, enum Mode mode, const short* speech, unsigned char* out, int forceSpeech); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/amrnb/opencore-amrnb.pc.in b/amrnb/opencore-amrnb.pc.in new file mode 100644 index 0000000..b838c0d --- /dev/null +++ b/amrnb/opencore-amrnb.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@/opencore-amrnb + +Name: OpenCORE AMR-NB +Description: Adaptive Multi-Rate speech codec library +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -lopencore-amrnb +Cflags: -I${includedir} diff --git a/amrnb/wrapper.cpp b/amrnb/wrapper.cpp new file mode 100644 index 0000000..9af8a0e --- /dev/null +++ b/amrnb/wrapper.cpp @@ -0,0 +1,67 @@ +/* ------------------------------------------------------------------ + * 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. + * ------------------------------------------------------------------- + */ + +#define AMRNB_WRAPPER_INTERNAL +#include +#include +#include +#include "interf_dec.h" +#include "interf_enc.h" +#include + +void* Decoder_Interface_init(void) { + void* ptr = NULL; + GSMInitDecode(&ptr, (int8*)"Decoder"); + return ptr; +} + +void Decoder_Interface_exit(void* state) { + GSMDecodeFrameExit(&state); +} + +void Decoder_Interface_Decode(void* state, const unsigned char* in, short* out, int bfi) { + unsigned char type = (in[0] >> 3) & 0x0f; + in++; + AMRDecode(state, (enum Frame_Type_3GPP) type, (UWord8*) in, out, MIME_IETF); +} + +struct encoder_state { + void* encCtx; + void* pidSyncCtx; +}; + +void* Encoder_Interface_init(int dtx) { + struct encoder_state* state = (struct encoder_state*) malloc(sizeof(struct encoder_state)); + AMREncodeInit(&state->encCtx, &state->pidSyncCtx, dtx); + return state; +} + +void Encoder_Interface_exit(void* s) { + struct encoder_state* state = (struct encoder_state*) s; + AMREncodeExit(&state->encCtx, &state->pidSyncCtx); + free(state); +} + +int Encoder_Interface_Encode(void* s, enum Mode mode, const short* speech, unsigned char* out, int forceSpeech) { + struct encoder_state* state = (struct encoder_state*) s; + enum Frame_Type_3GPP frame_type = (enum Frame_Type_3GPP) mode; + int ret = AMREncode(state->encCtx, state->pidSyncCtx, mode, (Word16*) speech, out, &frame_type, AMR_TX_IETF); + out[0] |= 0x04; + return ret; +} + -- cgit v1.2.3