1/* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18/****************************************************************************************
19Portions of this file are derived from the following 3GPP standard:
20
21    3GPP TS 26.073
22    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23    Available from http://www.3gpp.org
24
25(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26Permission to distribute, modify and use this file under the standard license
27terms listed above has been obtained from the copyright holder.
28****************************************************************************************/
29/*
30------------------------------------------------------------------------------
31
32
33
34 Filename: /audio/gsm-amr/c/include/gsmamr_enc.h
35
36     Date: 09/26/2001
37
38------------------------------------------------------------------------------
39 REVISION HISTORY
40
41 Description: Changing code as per review comments. These changes include
42              removing unnecessary tables and changing function descriptions.
43              The comments were changed to "slash-star" rather than double
44              slash, and some wordings of comments were corrected.
45
46 Description: Replaced GSMEncodeFrame function prototype with that of
47              AMREncode. Updated copyright year.
48
49 Description: Added #define for WMF and IF2, and updated function prototype
50              of AMREncode.
51
52 Description: Renamed WMF and IF2 to AMR_WMF and AMR_IF2, respectively. Added
53              AMR_ETS, and changed output_type to output_format in the
54              function prototype of AMREncode(). Removed function prototypes
55              for frame_header_move() and reverse_bits() since they are not
56              needed anymore.
57
58 Description: Moved WMFBytesUsed and IF2BytesUsed tables to
59              enc_output_format_tab.c.
60
61 Description: Added function prototypes for init, reset, and exit functions
62              in amrencode.c. Renamed output format #defines so that it it
63              unique to the encoder.
64
65 Description: Added comment to describe L_FRAME.
66
67 Description: Added Frame_Type_3GPP type definition.
68
69 Description: Moved _cplusplus #ifdef after Include section.
70
71 Description:
72
73------------------------------------------------------------------------------
74 INCLUDE DESCRIPTION
75
76 This header contains all the necessary information needed to use the
77 GSM AMR encoder library.
78
79------------------------------------------------------------------------------
80*/
81#ifndef _GSMAMR_ENC_H_
82#define _GSMAMR_ENC_H_
83
84/*----------------------------------------------------------------------------
85; INCLUDES
86----------------------------------------------------------------------------*/
87
88#include "gsm_amr_typedefs.h"
89#include "frame_type_3gpp.h"
90
91/*--------------------------------------------------------------------------*/
92#ifdef __cplusplus
93extern "C"
94{
95#endif
96
97    /*----------------------------------------------------------------------------
98    ; MACROS
99    ----------------------------------------------------------------------------*/
100
101
102    /*----------------------------------------------------------------------------
103    ; DEFINES
104    ----------------------------------------------------------------------------*/
105    /* Number of 13-bit linear PCM samples per 20 ms frame */
106    /* L_FRAME = (8 kHz) * (20 msec) = 160 samples         */
107#define L_FRAME     160
108
109    /* Output format types */
110#define AMR_TX_WMF  0
111#define AMR_TX_IF2  1
112#define AMR_TX_ETS  2
113
114    /*----------------------------------------------------------------------------
115    ; EXTERNAL VARIABLES REFERENCES
116    ----------------------------------------------------------------------------*/
117
118
119    /*----------------------------------------------------------------------------
120    ; SIMPLE TYPEDEF'S
121    ----------------------------------------------------------------------------*/
122
123    /*----------------------------------------------------------------------------
124    ; ENUMERATED TYPEDEF'S
125    ----------------------------------------------------------------------------*/
126
127    enum Mode
128    {
129        MR475 = 0,/* 4.75 kbps */
130        MR515,    /* 5.15 kbps */
131        MR59,     /* 5.90 kbps */
132        MR67,     /* 6.70 kbps */
133        MR74,     /* 7.40 kbps */
134        MR795,    /* 7.95 kbps */
135        MR102,    /* 10.2 kbps */
136        MR122,    /* 12.2 kbps */
137        MRDTX,    /* DTX       */
138        N_MODES   /* Not Used  */
139    };
140
141    /*----------------------------------------------------------------------------
142    ; STRUCTURES TYPEDEF'S
143    ----------------------------------------------------------------------------*/
144    /*----------------------------------------------------------------------------
145    ; GLOBAL FUNCTION DEFINITIONS
146    ----------------------------------------------------------------------------*/
147    /* AMREncodeInit initializes the GSM AMR Encoder library by calling
148     * GSMInitEncode and sid_sync_init. If initialization was successful,
149     * init_status is set to zero, otherwise, it is set to -1.
150    */
151    int AMREncodeInit(
152        void **pEncStructure,
153        void **pSidSyncStructure,
154        Flag dtx_enable);
155
156    /* AMREncodeReset resets the state memory used by the Encoder and SID sync
157     * function. If reset was successful, reset_status is set to zero, otherwise,
158     * it is set to -1.
159    */
160    int AMREncodeReset(
161        void *pEncStructure,
162        void *pSidSyncStructure);
163
164    /* AMREncodeExit frees up the state memory used by the Encoder and SID
165     * synchronization function.
166    */
167    void AMREncodeExit(
168        void **pEncStructure,
169        void **pSidSyncStructure);
170
171    /*
172     * AMREncode is the entry point to the ETS Encoder library that encodes the raw
173     * data speech bits and converts the encoded bitstream into either an IF2-
174     * formatted bitstream, WMF-formatted bitstream, or ETS-formatted bitstream,
175     * depending on the the value of output_format. A zero is returned on success.
176     */
177    int AMREncode(
178        void *pEncState,
179        void *pSidSyncState,
180        enum Mode mode,
181        Word16 *pEncInput,
182        unsigned char *pEncOutput,
183        enum Frame_Type_3GPP *p3gpp_frame_type,
184        Word16 output_format
185    );
186
187#ifdef __cplusplus
188}
189#endif
190
191
192#endif  /* _GSMAMR_DEC_H_ */
193
194