Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / dec / src / gsmamr_dec.h
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 /****************************************************************************************
19 Portions 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)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
29 /*
30 ------------------------------------------------------------------------------
31
32
33
34  Filename: gsmamr_dec.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39  This header contains all the necessary information needed to allow the gsm amr
40  decoder library to be used properly upon release.
41
42 ------------------------------------------------------------------------------
43 */
44 #ifndef _GSMAMR_DEC_H_
45 #define _GSMAMR_DEC_H_
46
47 /*----------------------------------------------------------------------------
48 ; INCLUDES
49 ----------------------------------------------------------------------------*/
50
51 #include "gsm_amr_typedefs.h"
52 #include "pvamrnbdecoder_api.h"
53 /*--------------------------------------------------------------------------*/
54 #ifdef __cplusplus
55 extern "C"
56 {
57 #endif
58
59     /*----------------------------------------------------------------------------
60     ; MACROS
61     ----------------------------------------------------------------------------*/
62
63
64     /*----------------------------------------------------------------------------
65     ; DEFINES
66     ----------------------------------------------------------------------------*/
67     /* Number of 13-bit linear PCM samples per 20 ms frame */
68     /* L_FRAME = (8 kHz) * (20 msec) = 160 samples         */
69 #define L_FRAME     160
70
71     /*----------------------------------------------------------------------------
72     ; EXTERNAL VARIABLES REFERENCES
73     ----------------------------------------------------------------------------*/
74
75
76     /*----------------------------------------------------------------------------
77     ; SIMPLE TYPEDEF'S
78     ----------------------------------------------------------------------------*/
79
80     /*----------------------------------------------------------------------------
81     ; ENUMERATED TYPEDEF'S
82     ----------------------------------------------------------------------------*/
83     enum Frame_Type_3GPP
84     {
85         AMR_475 = 0,        /* 4.75 kbps    */
86         AMR_515,            /* 5.15 kbps    */
87         AMR_59,             /* 5.9 kbps     */
88         AMR_67,             /* 6.7 kbps     */
89         AMR_74,             /* 7.4 kbps     */
90         AMR_795,            /* 7.95 kbps    */
91         AMR_102,            /* 10.2 kbps    */
92         AMR_122,            /* 12.2 kbps    */
93         AMR_SID,            /* GSM AMR DTX  */
94         GSM_EFR_SID,        /* GSM EFR DTX  */
95         TDMA_EFR_SID,       /* TDMA EFR DTX */
96         PDC_EFR_SID,        /* PDC EFR DTX  */
97         FOR_FUTURE_USE1,    /* Unused 1     */
98         FOR_FUTURE_USE2,    /* Unused 2     */
99         FOR_FUTURE_USE3,    /* Unused 3     */
100         AMR_NO_DATA
101     };      /* No data      */
102
103     /*----------------------------------------------------------------------------
104     ; STRUCTURES TYPEDEF'S
105     ----------------------------------------------------------------------------*/
106
107
108     /*----------------------------------------------------------------------------
109     ; GLOBAL FUNCTION DEFINITIONS
110     ----------------------------------------------------------------------------*/
111     /*
112      * This function allocates memory for filter structure and initializes state
113      * memory used by the GSM AMR decoder. This function returns zero. It will
114      * return negative one if there is an error.
115      */
116     Word16 GSMInitDecode(void **state_data,
117                          Word8 *id);
118
119     /*
120      * AMRDecode steps into the part of the library that decodes the raw data
121      * speech bits for the decoding process. It returns the address offset of
122      * the next frame to be decoded.
123      */
124     Word16 AMRDecode(
125         void                      *state_data,
126         enum Frame_Type_3GPP      frame_type,
127         UWord8                    *speech_bits_ptr,
128         Word16                    *raw_pcm_buffer,
129         Word16                    input_format
130     );
131
132     /*
133      * This function resets the state memory used by the GSM AMR decoder. This
134      * function returns zero. It will return negative one if there is an error.
135      */
136     Word16 Speech_Decode_Frame_reset(void *state_data);
137
138     /*
139      * This function frees up the memory used for the state memory of the
140      * GSM AMR decoder.
141      */
142     void GSMDecodeFrameExit(void **state_data);
143
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif  /* _GSMAMR_DEC_H_ */
150