amr: replace 3GPP reference library with vo-amrwbenc
[sox.git] / src / amr-wb.c
blob7b5a66d81dc278c144b6aeae303a1f7c7794a440
1 /* File format: AMR-WB (c) 2007 robs@users.sourceforge.net
3 * This library is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2.1 of the License, or (at
6 * your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
11 * General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * In order to use the AMR format with SoX, you need to have an
20 * AMR library installed at SoX build time. The SoX build system
21 * recognizes the AMR implementations available from
22 * http://opencore-amr.sourceforge.net/
25 #include "sox_i.h"
27 /* Common definitions: */
29 static const uint8_t amrwb_block_size[] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
30 static char const amrwb_magic[] = "#!AMR-WB\n";
31 #define amr_block_size amrwb_block_size
32 #define amr_magic amrwb_magic
33 #define amr_priv_t amrwb_priv_t
34 #define amr_opencore_funcs amrwb_opencore_funcs
35 #define amr_vo_funcs amrwb_vo_funcs
37 #define AMR_CODED_MAX 61 /* NB_SERIAL_MAX */
38 #define AMR_ENCODING SOX_ENCODING_AMR_WB
39 #define AMR_FORMAT_FN lsx_amr_wb_format_fn
40 #define AMR_FRAME 320 /* L_FRAME16k */
41 #define AMR_MODE_MAX 8
42 #define AMR_NAMES "amr-wb", "awb"
43 #define AMR_RATE 16000
44 #define AMR_DESC "3GPP Adaptive Multi Rate Wide-Band (AMR-WB) lossy speech compressor"
46 #ifdef DL_AMRWB
47 #define AMR_FUNC LSX_DLENTRY_DYNAMIC
48 #else
49 #define AMR_FUNC LSX_DLENTRY_STATIC
50 #endif /* DL_AMRWB */
52 /* OpenCore definitions: */
54 #if defined(HAVE_OPENCORE_AMRWB_DEC_IF_H) || defined(DL_AMRWB)
55 #define AMR_OPENCORE 1
56 #define AMR_OPENCORE_ENABLE_ENCODE 0
57 #endif
59 #define AMR_OPENCORE_FUNC_ENTRIES(f,x) \
60 AMR_FUNC(f,x, void*, D_IF_init, (void)) \
61 AMR_FUNC(f,x, void, D_IF_decode, (void* state, const unsigned char* in, short* out, int bfi)) \
62 AMR_FUNC(f,x, void, D_IF_exit, (void* state)) \
64 #define AmrDecoderInit() \
65 D_IF_init()
66 #define AmrDecoderDecode(state, in, out, bfi) \
67 D_IF_decode(state, in, out, bfi)
68 #define AmrDecoderExit(state) \
69 D_IF_exit(state)
71 #define AMR_OPENCORE_DESC "amr-wb OpenCore library"
72 static const char* const amr_opencore_library_names[] =
74 #ifdef DL_AMRWB
75 "libopencore-amrwb",
76 "libopencore-amrwb-0",
77 #endif
78 NULL
81 /* VO definitions: */
83 #if defined(HAVE_VO_AMRWBENC_ENC_IF_H) || defined(DL_AMRWB)
84 #define AMR_VO 1
85 #endif
87 #define AMR_VO_FUNC_ENTRIES(f,x) \
88 AMR_FUNC(f,x, void*, E_IF_init, (void)) \
89 AMR_FUNC(f,x, int, E_IF_encode,(void* state, int16_t mode, int16_t* in, uint8_t* out, int16_t dtx)) \
90 AMR_FUNC(f,x, void, E_IF_exit, (void* state)) \
92 #define AmrEncoderInit() \
93 E_IF_init()
94 #define AmrEncoderEncode(state, mode, in, out, forceSpeech) \
95 E_IF_encode(state, mode, in, out, forceSpeech)
96 #define AmrEncoderExit(state) \
97 E_IF_exit(state)
99 #define AMR_VO_DESC "amr-wb VisualOn library"
100 static const char* const amr_vo_library_names[] =
102 #ifdef DL_AMRWB
103 "libvo-amrwbenc",
104 "libvo-amrwbenc-0",
105 #endif
106 NULL
109 #include "amr.h"