gsmamr_enc.h revision b841f14f8e51f2365945281fbfa54ef6a1b1b5a6
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 90/*--------------------------------------------------------------------------*/ 91#ifdef __cplusplus 92extern "C" 93{ 94#endif 95 96 /*---------------------------------------------------------------------------- 97 ; MACROS 98 ----------------------------------------------------------------------------*/ 99 100 101 /*---------------------------------------------------------------------------- 102 ; DEFINES 103 ----------------------------------------------------------------------------*/ 104 /* Number of 13-bit linear PCM samples per 20 ms frame */ 105 /* L_FRAME = (8 kHz) * (20 msec) = 160 samples */ 106#define L_FRAME 160 107 108 /* Output format types */ 109#define AMR_TX_WMF 0 110#define AMR_TX_IF2 1 111#define AMR_TX_ETS 2 112 113 /*---------------------------------------------------------------------------- 114 ; EXTERNAL VARIABLES REFERENCES 115 ----------------------------------------------------------------------------*/ 116 117 118 /*---------------------------------------------------------------------------- 119 ; SIMPLE TYPEDEF'S 120 ----------------------------------------------------------------------------*/ 121 122 /*---------------------------------------------------------------------------- 123 ; ENUMERATED TYPEDEF'S 124 ----------------------------------------------------------------------------*/ 125 126 enum Mode 127 { 128 MR475 = 0,/* 4.75 kbps */ 129 MR515, /* 5.15 kbps */ 130 MR59, /* 5.90 kbps */ 131 MR67, /* 6.70 kbps */ 132 MR74, /* 7.40 kbps */ 133 MR795, /* 7.95 kbps */ 134 MR102, /* 10.2 kbps */ 135 MR122, /* 12.2 kbps */ 136 MRDTX, /* DTX */ 137 N_MODES /* Not Used */ 138 }; 139 140 enum Frame_Type_3GPP 141 { 142 AMR_475 = 0, /* 4.75 kbps */ 143 AMR_515, /* 5.15 kbps */ 144 AMR_59, /* 5.9 kbps */ 145 AMR_67, /* 6.7 kbps */ 146 AMR_74, /* 7.4 kbps */ 147 AMR_795, /* 7.95 kbps */ 148 AMR_102, /* 10.2 kbps */ 149 AMR_122, /* 12.2 kbps */ 150 AMR_SID, /* GSM AMR DTX */ 151 GSM_EFR_SID, /* GSM EFR DTX */ 152 TDMA_EFR_SID, /* TDMA EFR DTX */ 153 PDC_EFR_SID, /* PDC EFR DTX */ 154 FOR_FUTURE_USE1, /* Unused 1 */ 155 FOR_FUTURE_USE2, /* Unused 2 */ 156 FOR_FUTURE_USE3, /* Unused 3 */ 157 AMR_NO_DATA /* No data */ 158 }; 159 160 /*---------------------------------------------------------------------------- 161 ; STRUCTURES TYPEDEF'S 162 ----------------------------------------------------------------------------*/ 163 /*---------------------------------------------------------------------------- 164 ; GLOBAL FUNCTION DEFINITIONS 165 ----------------------------------------------------------------------------*/ 166 /* AMREncodeInit initializes the GSM AMR Encoder library by calling 167 * GSMInitEncode and sid_sync_init. If initialization was successful, 168 * init_status is set to zero, otherwise, it is set to -1. 169 */ 170 int AMREncodeInit( 171 void **pEncStructure, 172 void **pSidSyncStructure, 173 Flag dtx_enable); 174 175 /* AMREncodeReset resets the state memory used by the Encoder and SID sync 176 * function. If reset was successful, reset_status is set to zero, otherwise, 177 * it is set to -1. 178 */ 179 int AMREncodeReset( 180 void *pEncStructure, 181 void *pSidSyncStructure); 182 183 /* AMREncodeExit frees up the state memory used by the Encoder and SID 184 * synchronization function. 185 */ 186 void AMREncodeExit( 187 void **pEncStructure, 188 void **pSidSyncStructure); 189 190 /* 191 * AMREncode is the entry point to the ETS Encoder library that encodes the raw 192 * data speech bits and converts the encoded bitstream into either an IF2- 193 * formatted bitstream, WMF-formatted bitstream, or ETS-formatted bitstream, 194 * depending on the the value of output_format. A zero is returned on success. 195 */ 196 int AMREncode( 197 void *pEncState, 198 void *pSidSyncState, 199 enum Mode mode, 200 Word16 *pEncInput, 201 unsigned char *pEncOutput, 202 enum Frame_Type_3GPP *p3gpp_frame_type, 203 Word16 output_format 204 ); 205 206#ifdef __cplusplus 207} 208#endif 209 210 211#endif /* _GSMAMR_DEC_H_ */ 212 213