diff options
Diffstat (limited to 'newamp1.c')
-rw-r--r-- | newamp1.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -415,23 +415,38 @@ void newamp1_model_to_indexes(C2CONST *c2const, | |||
415 | float *mean, | 415 | float *mean, |
416 | float rate_K_vec_no_mean[], | 416 | float rate_K_vec_no_mean[], |
417 | float rate_K_vec_no_mean_[], | 417 | float rate_K_vec_no_mean_[], |
418 | float *se | 418 | float *se, |
419 | float *eq, | ||
420 | int eq_en | ||
419 | ) | 421 | ) |
420 | { | 422 | { |
421 | int k; | 423 | int k; |
422 | 424 | ||
423 | /* convert variable rate L to fixed rate K */ | 425 | /* convert variable rate L to fixed rate K */ |
424 | |||
425 | resample_const_rate_f(c2const, model, rate_K_vec, rate_K_sample_freqs_kHz, K); | 426 | resample_const_rate_f(c2const, model, rate_K_vec, rate_K_sample_freqs_kHz, K); |
426 | 427 | ||
427 | /* remove mean and two stage VQ */ | 428 | /* remove mean */ |
428 | |||
429 | float sum = 0.0; | 429 | float sum = 0.0; |
430 | for(k=0; k<K; k++) | 430 | for(k=0; k<K; k++) |
431 | sum += rate_K_vec[k]; | 431 | sum += rate_K_vec[k]; |
432 | *mean = sum/K;; | 432 | *mean = sum/K; |
433 | for(k=0; k<K; k++) | 433 | for(k=0; k<K; k++) |
434 | rate_K_vec_no_mean[k] = rate_K_vec[k] - *mean; | 434 | rate_K_vec_no_mean[k] = rate_K_vec[k] - *mean; |
435 | |||
436 | /* update and optionally run "front eq" equaliser on before VQ */ | ||
437 | static float ideal[] = {8,10,12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,-20}; | ||
438 | float gain = 0.02; | ||
439 | float update; | ||
440 | |||
441 | for(k=0; k<K; k++) { | ||
442 | update = rate_K_vec_no_mean[k] - ideal[k]; | ||
443 | eq[k] = (1.0-gain)*eq[k] + gain*update; | ||
444 | if (eq[k] < 0.0) eq[k] = 0.0; | ||
445 | if (eq_en) | ||
446 | rate_K_vec_no_mean[k] -= eq[k]; | ||
447 | } | ||
448 | |||
449 | /* two stage VQ */ | ||
435 | rate_K_mbest_encode(indexes, rate_K_vec_no_mean, rate_K_vec_no_mean_, K, NEWAMP1_VQ_MBEST_DEPTH); | 450 | rate_K_mbest_encode(indexes, rate_K_vec_no_mean, rate_K_vec_no_mean_, K, NEWAMP1_VQ_MBEST_DEPTH); |
436 | 451 | ||
437 | /* running sum of squared error for variance calculation */ | 452 | /* running sum of squared error for variance calculation */ |
@@ -439,7 +454,6 @@ void newamp1_model_to_indexes(C2CONST *c2const, | |||
439 | *se += pow(rate_K_vec_no_mean[k]-rate_K_vec_no_mean_[k],2.0); | 454 | *se += pow(rate_K_vec_no_mean[k]-rate_K_vec_no_mean_[k],2.0); |
440 | 455 | ||
441 | /* scalar quantise mean (effectively the frame energy) */ | 456 | /* scalar quantise mean (effectively the frame energy) */ |
442 | |||
443 | float w[1] = {1.0}; | 457 | float w[1] = {1.0}; |
444 | float se_mean; | 458 | float se_mean; |
445 | indexes[2] = quantise(newamp1_energy_cb[0].cb, | 459 | indexes[2] = quantise(newamp1_energy_cb[0].cb, |
@@ -451,7 +465,6 @@ void newamp1_model_to_indexes(C2CONST *c2const, | |||
451 | 465 | ||
452 | /* scalar quantise Wo. We steal the smallest Wo index to signal | 466 | /* scalar quantise Wo. We steal the smallest Wo index to signal |
453 | an unvoiced frame */ | 467 | an unvoiced frame */ |
454 | |||
455 | if (model->voiced) { | 468 | if (model->voiced) { |
456 | int index = encode_log_Wo(c2const, model->Wo, 6); | 469 | int index = encode_log_Wo(c2const, model->Wo, 6); |
457 | if (index == 0) { | 470 | if (index == 0) { |