Changeset 222
- Timestamp:
- 07/17/08 21:54:19
(2 months ago)
- Author:
- sip
- Message:
Fixed AMR sizes (Thanks to Klaus)x
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r221 |
r222 |
|
| 159 | 159 | { { "h324m", "debug", "level" }, h324m_do_debug, |
|---|
| 160 | 160 | "Set app_h324m debug log level", debug_usage }; |
|---|
| 161 | | |
|---|
| 162 | | |
|---|
| 163 | | static short blockSize[16] = { 12, 13, 16, 18, 19, 21, 26, 31, 6, -1, -1, -1, -1, -1, -1, -1}; |
|---|
| | 161 | /* |
|---|
| | 162 | |
|---|
| | 163 | These are the different AMR modes (Table 1 from RFC 3267) |
|---|
| | 164 | |
|---|
| | 165 | Class A total speech |
|---|
| | 166 | Index Mode bits bits |
|---|
| | 167 | ---------------------------------------- |
|---|
| | 168 | 0 AMR 4.75 42 95 |
|---|
| | 169 | 1 AMR 5.15 49 103 |
|---|
| | 170 | 2 AMR 5.9 55 118 |
|---|
| | 171 | 3 AMR 6.7 58 134 |
|---|
| | 172 | 4 AMR 7.4 61 148 |
|---|
| | 173 | 5 AMR 7.95 75 159 |
|---|
| | 174 | 6 AMR 10.2 65 204 |
|---|
| | 175 | 7 AMR 12.2 81 244 |
|---|
| | 176 | 8 AMR SID 39 39 |
|---|
| | 177 | |
|---|
| | 178 | Table 1. The number of class A bits for the AMR codec. |
|---|
| | 179 | |
|---|
| | 180 | Asterisk's internal AMR format: |
|---|
| | 181 | =============================== |
|---|
| | 182 | |
|---|
| | 183 | Asterisk internally use the "octed-aligned" RTP format in ast_frame. |
|---|
| | 184 | (see section 4.4 in RFC 3267) |
|---|
| | 185 | This allows to have multiple AMR frames in one Asterisk frame. This |
|---|
| | 186 | means, the payload of an ast_frame wich contains N AMR frames consists |
|---|
| | 187 | of (se also section 4.4.5.1 of RFC 3267): |
|---|
| | 188 | |
|---|
| | 189 | 1. 1 byte CMR (codec mode request) |
|---|
| | 190 | 2. N byte TOC (the TOC contains the AMR mode of the respecitve frame |
|---|
| | 191 | and one bit which tells us if it is the last TOC or if there are |
|---|
| | 192 | some more) |
|---|
| | 193 | 3. blocksize(AMR frame 0) + ..... + blocksize(AMR frame N) |
|---|
| | 194 | |
|---|
| | 195 | We define the blocksize of an AMR frame os the number of bytes needed |
|---|
| | 196 | to contain an AMR frame in the respective mode. Thus, it is the number |
|---|
| | 197 | of total speech bits divided by 8 and rounded upwards. |
|---|
| | 198 | E.g. an AMR frame in mode 5 has 159 bits. To store this frame we need |
|---|
| | 199 | 20 bytes. Thus, the blocksize of an AMR frame in mode 5 is 20 bytes. |
|---|
| | 200 | |
|---|
| | 201 | H324M AMR format: |
|---|
| | 202 | ================= |
|---|
| | 203 | In H324M, the AMR frames received from are in if2 format from libh324m. |
|---|
| | 204 | (see Annex A in TS 26.101). This means that there are 4 bits for the AMR |
|---|
| | 205 | mode followed by the speech bits. E.g. an AMR frame in mode 5 in if format |
|---|
| | 206 | needs 159+4 => 21 bytes. |
|---|
| | 207 | There is always only one AMR frame in an if2 packet. |
|---|
| | 208 | |
|---|
| | 209 | Extended Table 1: |
|---|
| | 210 | ================== |
|---|
| | 211 | |
|---|
| | 212 | Class A total speech block if2 frame |
|---|
| | 213 | Index Mode bits bits size size |
|---|
| | 214 | ------------------------------------------------------------- |
|---|
| | 215 | 0 AMR 4.75 42 95 12 13 |
|---|
| | 216 | 1 AMR 5.15 49 103 13 14 |
|---|
| | 217 | 2 AMR 5.9 55 118 15 16 |
|---|
| | 218 | 3 AMR 6.7 58 134 17 18 |
|---|
| | 219 | 4 AMR 7.4 61 148 19 19 |
|---|
| | 220 | 5 AMR 7.95 75 159 20 21 |
|---|
| | 221 | 6 AMR 10.2 65 204 26 26 |
|---|
| | 222 | 7 AMR 12.2 81 244 31 31 |
|---|
| | 223 | 8 AMR SID 39 39 5 6 |
|---|
| | 224 | |
|---|
| | 225 | */ |
|---|
| | 226 | |
|---|
| | 227 | |
|---|
| | 228 | |
|---|
| | 229 | static short blockSize[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, -1, -1, -1, -1, -1, -1, -1}; |
|---|
| 164 | 230 | static short if2stuffing[16] = {5, 5, 6, 6, 0, 5, 0, 0, 5, 1, 6, 7, -1, -1, -1, 4}; |
|---|
| 165 | 231 | |
|---|
| … | … | |
| 259 | 325 | /*Increase size of frame*/ |
|---|
| 260 | 326 | send->datalen++; |
|---|
| | 327 | } else { |
|---|
| | 328 | /* Set last byte */ |
|---|
| | 329 | data[bs] = data[bs] >> 4 | data[bs-1] << 4; |
|---|
| 261 | 330 | } |
|---|
| 262 | 331 | |
|---|
Download in other formats:
|
|