* Computes the scaled codebook vector Cdn From INDEX and GAIN * for all rates. * * The specification lacks some information here. * * TIA/EIA/IS-733 has an omission on the codebook index determination * formula for RATE_FULL and RATE_HALF frames at section 2.4.8.1.1. It says * you have to subtract the decoded index parameter from the given scaled * codebook vector index 'n' to get the desi
| 330 | * @param cdn_vector array for the generated scaled codebook vector |
| 331 | */ |
| 332 | static void compute_svector(QCELPContext *q, const float *gain, |
| 333 | float *cdn_vector) |
| 334 | { |
| 335 | int i, j, k; |
| 336 | uint16_t cbseed, cindex; |
| 337 | float *rnd, tmp_gain, fir_filter_value; |
| 338 | |
| 339 | switch(q->bitrate) |
| 340 | { |
| 341 | case RATE_FULL: |
| 342 | for(i=0; i<16; i++) |
| 343 | { |
| 344 | tmp_gain = gain[i] * QCELP_RATE_FULL_CODEBOOK_RATIO; |
| 345 | cindex = -q->frame.cindex[i]; |
| 346 | for(j=0; j<10; j++) |
| 347 | *cdn_vector++ = tmp_gain * qcelp_rate_full_codebook[cindex++ & 127]; |
| 348 | } |
| 349 | break; |
| 350 | case RATE_HALF: |
| 351 | for(i=0; i<4; i++) |
| 352 | { |
| 353 | tmp_gain = gain[i] * QCELP_RATE_HALF_CODEBOOK_RATIO; |
| 354 | cindex = -q->frame.cindex[i]; |
| 355 | for (j = 0; j < 40; j++) |
| 356 | *cdn_vector++ = tmp_gain * qcelp_rate_half_codebook[cindex++ & 127]; |
| 357 | } |
| 358 | break; |
| 359 | case RATE_QUARTER: |
| 360 | cbseed = (0x0003 & q->frame.lspv[4])<<14 | |
| 361 | (0x003F & q->frame.lspv[3])<< 8 | |
| 362 | (0x0060 & q->frame.lspv[2])<< 1 | |
| 363 | (0x0007 & q->frame.lspv[1])<< 3 | |
| 364 | (0x0038 & q->frame.lspv[0])>> 3 ; |
| 365 | rnd = q->rnd_fir_filter_mem + 20; |
| 366 | for(i=0; i<8; i++) |
| 367 | { |
| 368 | tmp_gain = gain[i] * (QCELP_SQRT1887 / 32768.0); |
| 369 | for(k=0; k<20; k++) |
| 370 | { |
| 371 | cbseed = 521 * cbseed + 259; |
| 372 | *rnd = (int16_t)cbseed; |
| 373 | |
| 374 | // FIR filter |
| 375 | fir_filter_value = 0.0; |
| 376 | for(j=0; j<10; j++) |
| 377 | fir_filter_value += qcelp_rnd_fir_coefs[j ] |
| 378 | * (rnd[-j ] + rnd[-20+j]); |
| 379 | |
| 380 | fir_filter_value += qcelp_rnd_fir_coefs[10] * rnd[-10]; |
| 381 | *cdn_vector++ = tmp_gain * fir_filter_value; |
| 382 | rnd++; |
| 383 | } |
| 384 | } |
| 385 | memcpy(q->rnd_fir_filter_mem, q->rnd_fir_filter_mem + 160, 20 * sizeof(float)); |
| 386 | break; |
| 387 | case RATE_OCTAVE: |
| 388 | cbseed = q->first16bits; |
| 389 | for(i=0; i<8; i++) |
no outgoing calls
no test coverage detected