| 353 | #define gain_3tap_to_1tap(g) (FFABS(g[1]) + (g[0] > 0.f ? g[0] : -.5f * g[0]) + (g[2] > 0.f ? g[2] : -.5f * g[2])) |
| 354 | |
| 355 | static void |
| 356 | pitch_unquant_3tap(float *exc, float *exc_out, int start, int end, float pitch_coef, |
| 357 | const void *par, int nsf, int *pitch_val, float *gain_val, GetBitContext *gb, |
| 358 | int count_lost, int subframe_offset, float last_pitch_gain, int cdbk_offset) |
| 359 | { |
| 360 | int pitch, gain_index, gain_cdbk_size; |
| 361 | const int8_t *gain_cdbk; |
| 362 | const LtpParam *params; |
| 363 | float gain[3]; |
| 364 | |
| 365 | params = (const LtpParam *)par; |
| 366 | gain_cdbk_size = 1 << params->gain_bits; |
| 367 | gain_cdbk = params->gain_cdbk + 4 * gain_cdbk_size * cdbk_offset; |
| 368 | |
| 369 | pitch = get_bitsz(gb, params->pitch_bits); |
| 370 | pitch += start; |
| 371 | gain_index = get_bitsz(gb, params->gain_bits); |
| 372 | gain[0] = 0.015625f * gain_cdbk[gain_index * 4] + .5f; |
| 373 | gain[1] = 0.015625f * gain_cdbk[gain_index * 4 + 1] + .5f; |
| 374 | gain[2] = 0.015625f * gain_cdbk[gain_index * 4 + 2] + .5f; |
| 375 | |
| 376 | if (count_lost && pitch > subframe_offset) { |
| 377 | float tmp = count_lost < 4 ? last_pitch_gain : 0.5f * last_pitch_gain; |
| 378 | float gain_sum; |
| 379 | |
| 380 | tmp = fminf(tmp, .95f); |
| 381 | gain_sum = gain_3tap_to_1tap(gain); |
| 382 | |
| 383 | if (gain_sum > tmp && gain_sum > 0.f) { |
| 384 | float fact = tmp / gain_sum; |
| 385 | for (int i = 0; i < 3; i++) |
| 386 | gain[i] *= fact; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | pitch_val[0] = pitch; |
| 391 | gain_val[0] = gain[0]; |
| 392 | gain_val[1] = gain[1]; |
| 393 | gain_val[2] = gain[2]; |
| 394 | SPEEX_MEMSET(exc_out, 0, nsf); |
| 395 | |
| 396 | for (int i = 0; i < 3; i++) { |
| 397 | int tmp1, tmp3; |
| 398 | int pp = pitch + 1 - i; |
| 399 | tmp1 = nsf; |
| 400 | if (tmp1 > pp) |
| 401 | tmp1 = pp; |
| 402 | for (int j = 0; j < tmp1; j++) |
| 403 | exc_out[j] += gain[2 - i] * exc[j - pp]; |
| 404 | tmp3 = nsf; |
| 405 | if (tmp3 > pp + pitch) |
| 406 | tmp3 = pp + pitch; |
| 407 | for (int j = tmp1; j < tmp3; j++) |
| 408 | exc_out[j] += gain[2 - i] * exc[j - pp - pitch]; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | static void lsp_unquant_nb(float *lsp, int order, GetBitContext *gb) |
nothing calls this directly
no test coverage detected