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_dec.h
35
36     Date: 09/10/2001
37
38------------------------------------------------------------------------------
39 REVISION HISTORY
40
41 Description: Adding comments and removing some tables as per review comments.
42
43 Description: Replace enum Mode with enum Frame_Type_3GPP and updated function
44              prototype of AMRDecode().
45
46 Description: Added back the enum Mode type definition, removed RXFrameType
47              type definition, and updated AMRDecode and GSMInitDecode function
48              prototypes.
49
50 Description: Added #defines for WMF and IF2. Updated AMRDecode function
51              prototype.
52
53 Description: Removed enum Mode type definition and updated AMRDecode function
54              prototype.
55
56 Description: Renamed WMF and IF2 to AMR_WMF and AMR_IF2, respectively. Added
57              #define for AMR_ETS format.
58
59 Description: Rename input format defines to make it unique to the decoder.
60
61 Description: Added comment to describe L_FRAME.
62
63 Description: Moved _cplusplus #ifdef after Include section.
64
65 Description: Included file "typedefs.h" to avoid re-declaring similar typedef
66              this for OSCL-ed compatibility
67
68 Description: Included file "gsm_amr_typedefs.h" and eliminated re-definition
69              of types UWord8, Word8, Word16
70
71 Description:
72
73------------------------------------------------------------------------------
74 INCLUDE DESCRIPTION
75
76 This header contains all the necessary information needed to allow the gsm amr
77 decoder library to be used properly upon release.
78
79------------------------------------------------------------------------------
80*/
81#ifndef _GSMAMR_DEC_H_
82#define _GSMAMR_DEC_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    /*----------------------------------------------------------------------------
110    ; EXTERNAL VARIABLES REFERENCES
111    ----------------------------------------------------------------------------*/
112
113
114    /*----------------------------------------------------------------------------
115    ; SIMPLE TYPEDEF'S
116    ----------------------------------------------------------------------------*/
117
118    /*----------------------------------------------------------------------------
119    ; ENUMERATED TYPEDEF'S
120    ----------------------------------------------------------------------------*/
121
122    /*----------------------------------------------------------------------------
123    ; STRUCTURES TYPEDEF'S
124    ----------------------------------------------------------------------------*/
125
126
127    /*----------------------------------------------------------------------------
128    ; GLOBAL FUNCTION DEFINITIONS
129    ----------------------------------------------------------------------------*/
130    /*
131     * This function allocates memory for filter structure and initializes state
132     * memory used by the GSM AMR decoder. This function returns zero. It will
133     * return negative one if there is an error.
134     */
135    Word16 GSMInitDecode(void **state_data,
136                         Word8 *id);
137
138    /*
139     * AMRDecode steps into the part of the library that decodes the raw data
140     * speech bits for the decoding process. It returns the address offset of
141     * the next frame to be decoded.
142     */
143    Word16 AMRDecode(
144        void                      *state_data,
145        enum Frame_Type_3GPP      frame_type,
146        UWord8                    *speech_bits_ptr,
147        Word16                    *raw_pcm_buffer,
148        Word16                    input_format
149    );
150
151    /*
152     * This function resets the state memory used by the GSM AMR decoder. This
153     * function returns zero. It will return negative one if there is an error.
154     */
155    Word16 Speech_Decode_Frame_reset(void *state_data);
156
157    /*
158     * This function frees up the memory used for the state memory of the
159     * GSM AMR decoder.
160     */
161    void GSMDecodeFrameExit(void **state_data);
162
163
164#ifdef __cplusplus
165}
166#endif
167
168#endif  /* _GSMAMR_DEC_H_ */
169
170