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 // // 20 // File: pvgsmamrdecoderinterface.h // 21 // // 22 ////////////////////////////////////////////////////////////////////////////////// 23 24 #ifndef _PVGSMAMR_DECODER_INTERFACE_H 25 #define _PVGSMAMR_DECODER_INTERFACE_H 26 27 #include "oscl_base.h" 28 29 /*---------------------------------------------------------------------------- 30 ; ENUMERATED TYPEDEF'S 31 ----------------------------------------------------------------------------*/ 32 33 typedef enum 34 { 35 /* 36 * One word (2-byte) to indicate type of frame type. 37 * One word (2-byte) to indicate frame type. 38 * One word (2-byte) to indicate mode. 39 * N words (2-byte) containing N bits (bit 0 = 0xff81, bit 1 = 0x007f). 40 */ 41 ETS = 0, /* Both AMR-Narrowband and AMR-Wideband */ 42 43 /* 44 * One word (2-byte) for sync word (good frames: 0x6b21, bad frames: 0x6b20) 45 * One word (2-byte) for frame length N. 46 * N words (2-byte) containing N bits (bit 0 = 0x007f, bit 1 = 0x0081). 47 */ 48 ITU, /* AMR-Wideband */ 49 50 /* 51 * AMR-WB MIME/storage format, see RFC 3267 (sections 5.1 and 5.3) for details 52 */ 53 MIME_IETF, 54 55 WMF, /* AMR-Narrowband */ 56 57 IF2 /* AMR-Narrowband */ 58 59 } bitstream_format; 60 61 62 63 /*---------------------------------------------------------------------------- 64 ; STRUCTURES TYPEDEF'S 65 ----------------------------------------------------------------------------*/ 66 typedef struct 67 { 68 int16 prev_ft; 69 int16 prev_mode; 70 } RX_State; 71 72 73 typedef struct tPVAmrDecoderExternal 74 { 75 /* 76 * INPUT: 77 * Pointer to the input buffer that contains the encoded bistream data. 78 * The data is filled in such that the first bit transmitted is 79 * the most-significant bit (MSB) of the first array element. 80 * The buffer is accessed in a linear fashion for speed, and the number of 81 * bytes consumed varies frame to frame. This is use for mime/ietf data 82 */ 83 uint8 *pInputBuffer; 84 85 /* 86 * INPUT: 87 * Pointer to the input buffer that contains the encoded stream data. 88 * The data is filled such that the first bit transmitted is 89 * in the first int16 element. 90 * The buffer is accessed in a linear fashion for speed, and the number of 91 * bytes consumed varies frame to frame. 92 */ 93 int16 *pInputSampleBuffer; 94 95 /* 96 * INPUT: (but what is pointed to is an output) 97 * Pointer to the output buffer to hold the 16-bit PCM audio samples. 98 */ 99 int16 *pOutputBuffer; 100 101 /* 102 * INPUT: 103 * Number of requested output audio channels. This relieves the calling 104 * environment from having to perform stereo-to-mono or mono-to-stereo 105 * conversions. 106 */ 107 int32 desiredChannels; 108 109 /* 110 * INPUT: 111 * Format type of the encoded bitstream. 112 */ 113 bitstream_format input_format; 114 115 /* 116 * OUTPUT: 117 * The sampling rate decoded from the bitstream, in units of 118 * samples/second. For this release of the library this value does 119 * not change from frame to frame, but future versions will. 120 */ 121 int32 samplingRate; 122 123 /* 124 * OUTPUT: 125 * This value is the bitrate in units of bits/second. IT 126 * is calculated using the number of bits consumed for the current frame, 127 * and then multiplying by the sampling_rate, divided by points in a frame. 128 * This value can changes frame to frame. 129 */ 130 int32 bitRate; 131 132 /* 133 * OUTPUT: 134 * The number of channels decoded from the bitstream. The output data 135 * will have be the amount specified in the variable desiredChannels, 136 * this output is informative only, and can be ignored. 137 */ 138 int32 encodedChannels; 139 140 /* 141 * OUTPUT: 142 * This value is the number of output PCM samples per channel. 143 * It is 320. 144 */ 145 int16 frameLength; 146 147 /* 148 * OUTPUT: 149 * This value is the quality indicator. 1 (good) 0 (bad) 150 */ 151 uint8 quality; 152 153 154 /* 155 * OUTPUT: 156 * GSM AMR NB and WB mode (i.e. bit-rate ) 157 */ 158 int16 mode; 159 int16 mode_old; 160 161 /* 162 * OUTPUT: 163 * GSM AMR NB and WB frame type ( speech_good, speech_bad, sid, etc.) 164 */ 165 int16 frame_type; 166 167 int16 reset_flag; 168 int16 reset_flag_old; 169 170 /* 171 * OUTPUT: 172 * Decoder status 173 */ 174 int32 status; 175 176 /* 177 * OUTPUT: 178 * Rx status state 179 */ 180 RX_State rx_state; 181 182 } tPVAmrDecoderExternal; 183 184 // CDecoder_AMRInterface 185 class CDecoder_AMRInterface 186 { 187 public: 188 OSCL_IMPORT_REF virtual int32 StartL(tPVAmrDecoderExternal * pExt, 189 bool aAllocateInputBuffer = false, 190 bool aAllocateOutputBuffer = false) = 0; 191 192 OSCL_IMPORT_REF virtual int32 ExecuteL(tPVAmrDecoderExternal * pExt) = 0; 193 194 OSCL_IMPORT_REF virtual int32 ResetDecoderL() = 0; 195 OSCL_IMPORT_REF virtual void StopL() = 0; 196 OSCL_IMPORT_REF virtual void TerminateDecoderL() = 0; 197 }; 198 199 200 201 #endif 202 203