Lines Matching refs:st

400    SpeexPreprocessState *st = (SpeexPreprocessState *)speex_alloc(sizeof(SpeexPreprocessState));  in speex_preprocess_state_init()  local
401 st->frame_size = frame_size; in speex_preprocess_state_init()
406 st->ps_size = st->frame_size; in speex_preprocess_state_init()
409 if (st->ps_size & ~i) in speex_preprocess_state_init()
411 st->ps_size &= ~i; in speex_preprocess_state_init()
419 if (st->ps_size < 3*st->frame_size/4) in speex_preprocess_state_init()
420 st->ps_size = st->ps_size * 3 / 2; in speex_preprocess_state_init()
422 st->ps_size = st->frame_size; in speex_preprocess_state_init()
425 N = st->ps_size; in speex_preprocess_state_init()
426 N3 = 2*N - st->frame_size; in speex_preprocess_state_init()
427 N4 = st->frame_size - N3; in speex_preprocess_state_init()
429 st->sampling_rate = sampling_rate; in speex_preprocess_state_init()
430 st->denoise_enabled = 1; in speex_preprocess_state_init()
431 st->vad_enabled = 0; in speex_preprocess_state_init()
432 st->dereverb_enabled = 0; in speex_preprocess_state_init()
433 st->reverb_decay = 0; in speex_preprocess_state_init()
434 st->reverb_level = 0; in speex_preprocess_state_init()
435 st->noise_suppress = NOISE_SUPPRESS_DEFAULT; in speex_preprocess_state_init()
436 st->echo_suppress = ECHO_SUPPRESS_DEFAULT; in speex_preprocess_state_init()
437 st->echo_suppress_active = ECHO_SUPPRESS_ACTIVE_DEFAULT; in speex_preprocess_state_init()
439 st->speech_prob_start = SPEECH_PROB_START_DEFAULT; in speex_preprocess_state_init()
440 st->speech_prob_continue = SPEECH_PROB_CONTINUE_DEFAULT; in speex_preprocess_state_init()
442 st->echo_state = NULL; in speex_preprocess_state_init()
444 st->nbands = NB_BANDS; in speex_preprocess_state_init()
445 M = st->nbands; in speex_preprocess_state_init()
446 st->bank = filterbank_new(M, sampling_rate, N, 1); in speex_preprocess_state_init()
448 st->frame = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); in speex_preprocess_state_init()
449 st->window = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); in speex_preprocess_state_init()
450 st->ft = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); in speex_preprocess_state_init()
452 st->ps = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); in speex_preprocess_state_init()
453 st->noise = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); in speex_preprocess_state_init()
454 st->echo_noise = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); in speex_preprocess_state_init()
455 st->residual_echo = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); in speex_preprocess_state_init()
456 st->reverb_estimate = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); in speex_preprocess_state_init()
457 st->old_ps = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); in speex_preprocess_state_init()
458 st->prior = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); in speex_preprocess_state_init()
459 st->post = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); in speex_preprocess_state_init()
460 st->gain = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); in speex_preprocess_state_init()
461 st->gain2 = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); in speex_preprocess_state_init()
462 st->gain_floor = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); in speex_preprocess_state_init()
463 st->zeta = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); in speex_preprocess_state_init()
465 st->S = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); in speex_preprocess_state_init()
466 st->Smin = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); in speex_preprocess_state_init()
467 st->Stmp = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); in speex_preprocess_state_init()
468 st->update_prob = (int*)speex_alloc(N*sizeof(int)); in speex_preprocess_state_init()
470 st->inbuf = (spx_word16_t*)speex_alloc(N3*sizeof(spx_word16_t)); in speex_preprocess_state_init()
471 st->outbuf = (spx_word16_t*)speex_alloc(N3*sizeof(spx_word16_t)); in speex_preprocess_state_init()
473 conj_window(st->window, 2*N3); in speex_preprocess_state_init()
474 for (i=2*N3;i<2*st->ps_size;i++) in speex_preprocess_state_init()
475 st->window[i]=Q15_ONE; in speex_preprocess_state_init()
481 st->window[i+N3+N4]=st->window[i+N3]; in speex_preprocess_state_init()
482 st->window[i+N3]=1; in speex_preprocess_state_init()
487 st->noise[i]=QCONST32(1.f,NOISE_SHIFT); in speex_preprocess_state_init()
488 st->reverb_estimate[i]=0; in speex_preprocess_state_init()
489 st->old_ps[i]=1; in speex_preprocess_state_init()
490 st->gain[i]=Q15_ONE; in speex_preprocess_state_init()
491 st->post[i]=SHL16(1, SNR_SHIFT); in speex_preprocess_state_init()
492 st->prior[i]=SHL16(1, SNR_SHIFT); in speex_preprocess_state_init()
496 st->update_prob[i] = 1; in speex_preprocess_state_init()
499 st->inbuf[i]=0; in speex_preprocess_state_init()
500 st->outbuf[i]=0; in speex_preprocess_state_init()
503 st->agc_enabled = 0; in speex_preprocess_state_init()
504 st->agc_level = 8000; in speex_preprocess_state_init()
505 st->loudness_weight = (float*)speex_alloc(N*sizeof(float)); in speex_preprocess_state_init()
510 st->loudness_weight[i] = .35f-.35f*ff/16000.f+.73f*exp(-.5f*(ff-3800)*(ff-3800)/9e5f); in speex_preprocess_state_init()
511 if (st->loudness_weight[i]<.01f) in speex_preprocess_state_init()
512 st->loudness_weight[i]=.01f; in speex_preprocess_state_init()
513 st->loudness_weight[i] *= st->loudness_weight[i]; in speex_preprocess_state_init()
516 st->loudness = 1e-15; in speex_preprocess_state_init()
517 st->agc_gain = 1; in speex_preprocess_state_init()
518 st->max_gain = 30; in speex_preprocess_state_init()
519 st->max_increase_step = exp(0.11513f * 12.*st->frame_size / st->sampling_rate); in speex_preprocess_state_init()
520 st->max_decrease_step = exp(-0.11513f * 40.*st->frame_size / st->sampling_rate); in speex_preprocess_state_init()
521 st->prev_loudness = 1; in speex_preprocess_state_init()
522 st->init_max = 1; in speex_preprocess_state_init()
524 st->was_speech = 0; in speex_preprocess_state_init()
526 st->fft_lookup = spx_fft_init(2*N); in speex_preprocess_state_init()
528 st->nb_adapt=0; in speex_preprocess_state_init()
529 st->min_count=0; in speex_preprocess_state_init()
530 return st; in speex_preprocess_state_init()
533 EXPORT void speex_preprocess_state_destroy(SpeexPreprocessState *st) in speex_preprocess_state_destroy() argument
535 speex_free(st->frame); in speex_preprocess_state_destroy()
536 speex_free(st->ft); in speex_preprocess_state_destroy()
537 speex_free(st->ps); in speex_preprocess_state_destroy()
538 speex_free(st->gain2); in speex_preprocess_state_destroy()
539 speex_free(st->gain_floor); in speex_preprocess_state_destroy()
540 speex_free(st->window); in speex_preprocess_state_destroy()
541 speex_free(st->noise); in speex_preprocess_state_destroy()
542 speex_free(st->reverb_estimate); in speex_preprocess_state_destroy()
543 speex_free(st->old_ps); in speex_preprocess_state_destroy()
544 speex_free(st->gain); in speex_preprocess_state_destroy()
545 speex_free(st->prior); in speex_preprocess_state_destroy()
546 speex_free(st->post); in speex_preprocess_state_destroy()
548 speex_free(st->loudness_weight); in speex_preprocess_state_destroy()
550 speex_free(st->echo_noise); in speex_preprocess_state_destroy()
551 speex_free(st->residual_echo); in speex_preprocess_state_destroy()
553 speex_free(st->S); in speex_preprocess_state_destroy()
554 speex_free(st->Smin); in speex_preprocess_state_destroy()
555 speex_free(st->Stmp); in speex_preprocess_state_destroy()
556 speex_free(st->update_prob); in speex_preprocess_state_destroy()
557 speex_free(st->zeta); in speex_preprocess_state_destroy()
559 speex_free(st->inbuf); in speex_preprocess_state_destroy()
560 speex_free(st->outbuf); in speex_preprocess_state_destroy()
562 spx_fft_destroy(st->fft_lookup); in speex_preprocess_state_destroy()
563 filterbank_destroy(st->bank); in speex_preprocess_state_destroy()
564 speex_free(st); in speex_preprocess_state_destroy()
569 static void speex_compute_agc(SpeexPreprocessState *st, spx_word16_t Pframe, spx_word16_t *ft) in speex_compute_agc() argument
572 int N = st->ps_size; in speex_compute_agc()
579 loudness += 2.f*N*st->ps[i]* st->loudness_weight[i]; in speex_compute_agc()
588 st->loudness = (1-rate)*st->loudness + (rate)*pow(AMP_SCALE*loudness, LOUDNESS_EXP); in speex_compute_agc()
589 st->loudness_accum = (1-rate)*st->loudness_accum + rate; in speex_compute_agc()
590 if (st->init_max < st->max_gain && st->nb_adapt > 20) in speex_compute_agc()
591 st->init_max *= 1.f + .1f*Pframe*Pframe; in speex_compute_agc()
595 …target_gain = AMP_SCALE*st->agc_level*pow(st->loudness/(1e-4+st->loudness_accum), -1.0f/LOUDNESS_E… in speex_compute_agc()
597 if ((Pframe>.5 && st->nb_adapt > 20) || target_gain < st->agc_gain) in speex_compute_agc()
599 if (target_gain > st->max_increase_step*st->agc_gain) in speex_compute_agc()
600 target_gain = st->max_increase_step*st->agc_gain; in speex_compute_agc()
601 if (target_gain < st->max_decrease_step*st->agc_gain && loudness < 10*st->prev_loudness) in speex_compute_agc()
602 target_gain = st->max_decrease_step*st->agc_gain; in speex_compute_agc()
603 if (target_gain > st->max_gain) in speex_compute_agc()
604 target_gain = st->max_gain; in speex_compute_agc()
605 if (target_gain > st->init_max) in speex_compute_agc()
606 target_gain = st->init_max; in speex_compute_agc()
608 st->agc_gain = target_gain; in speex_compute_agc()
613 ft[i] *= st->agc_gain; in speex_compute_agc()
614 st->prev_loudness = loudness; in speex_compute_agc()
618 static void preprocess_analysis(SpeexPreprocessState *st, spx_int16_t *x) in preprocess_analysis() argument
621 int N = st->ps_size; in preprocess_analysis()
622 int N3 = 2*N - st->frame_size; in preprocess_analysis()
623 int N4 = st->frame_size - N3; in preprocess_analysis()
624 spx_word32_t *ps=st->ps; in preprocess_analysis()
628 st->frame[i]=st->inbuf[i]; in preprocess_analysis()
629 for (i=0;i<st->frame_size;i++) in preprocess_analysis()
630 st->frame[N3+i]=x[i]; in preprocess_analysis()
634 st->inbuf[i]=x[N4+i]; in preprocess_analysis()
638 st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]); in preprocess_analysis()
644 max_val = MAX16(max_val, ABS16(st->frame[i])); in preprocess_analysis()
645 st->frame_shift = 14-spx_ilog2(EXTEND32(max_val)); in preprocess_analysis()
647 st->frame[i] = SHL16(st->frame[i], st->frame_shift); in preprocess_analysis()
652 spx_fft(st->fft_lookup, st->frame, st->ft); in preprocess_analysis()
655 ps[0]=MULT16_16(st->ft[0],st->ft[0]); in preprocess_analysis()
657 ps[i]=MULT16_16(st->ft[2*i-1],st->ft[2*i-1]) + MULT16_16(st->ft[2*i],st->ft[2*i]); in preprocess_analysis()
659 st->ps[i] = PSHR32(st->ps[i], 2*st->frame_shift); in preprocess_analysis()
661 filterbank_compute_bank32(st->bank, ps, ps+N); in preprocess_analysis()
664 static void update_noise_prob(SpeexPreprocessState *st) in update_noise_prob() argument
668 int N = st->ps_size; in update_noise_prob()
671st->S[i] = MULT16_32_Q15(QCONST16(.8f,15),st->S[i]) + MULT16_32_Q15(QCONST16(.05f,15),st->ps[i-1]… in update_noise_prob()
672 … + MULT16_32_Q15(QCONST16(.1f,15),st->ps[i]) + MULT16_32_Q15(QCONST16(.05f,15),st->ps[i+1]); in update_noise_prob()
673 st->S[0] = MULT16_32_Q15(QCONST16(.8f,15),st->S[0]) + MULT16_32_Q15(QCONST16(.2f,15),st->ps[0]); in update_noise_prob()
674st->S[N-1] = MULT16_32_Q15(QCONST16(.8f,15),st->S[N-1]) + MULT16_32_Q15(QCONST16(.2f,15),st->ps[N… in update_noise_prob()
676 if (st->nb_adapt==1) in update_noise_prob()
679 st->Smin[i] = st->Stmp[i] = 0; in update_noise_prob()
682 if (st->nb_adapt < 100) in update_noise_prob()
684 else if (st->nb_adapt < 1000) in update_noise_prob()
686 else if (st->nb_adapt < 10000) in update_noise_prob()
690 if (st->min_count > min_range) in update_noise_prob()
692 st->min_count = 0; in update_noise_prob()
695 st->Smin[i] = MIN32(st->Stmp[i], st->S[i]); in update_noise_prob()
696 st->Stmp[i] = st->S[i]; in update_noise_prob()
701 st->Smin[i] = MIN32(st->Smin[i], st->S[i]); in update_noise_prob()
702 st->Stmp[i] = MIN32(st->Stmp[i], st->S[i]); in update_noise_prob()
707 if (MULT16_32_Q15(QCONST16(.4f,15),st->S[i]) > st->Smin[i]) in update_noise_prob()
708 st->update_prob[i] = 1; in update_noise_prob()
710 st->update_prob[i] = 0; in update_noise_prob()
719 void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len);
721 EXPORT int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo) in speex_preprocess() argument
723 return speex_preprocess_run(st, x); in speex_preprocess()
726 EXPORT int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x) in speex_preprocess_run() argument
730 int N = st->ps_size; in speex_preprocess_run()
731 int N3 = 2*N - st->frame_size; in speex_preprocess_run()
732 int N4 = st->frame_size - N3; in speex_preprocess_run()
733 spx_word32_t *ps=st->ps; in speex_preprocess_run()
739 st->nb_adapt++; in speex_preprocess_run()
740 if (st->nb_adapt>20000) in speex_preprocess_run()
741 st->nb_adapt = 20000; in speex_preprocess_run()
742 st->min_count++; in speex_preprocess_run()
744 beta = MAX16(QCONST16(.03,15),DIV32_16(Q15_ONE,st->nb_adapt)); in speex_preprocess_run()
746 M = st->nbands; in speex_preprocess_run()
748 if (st->echo_state) in speex_preprocess_run()
750 speex_echo_get_residual(st->echo_state, st->residual_echo, N); in speex_preprocess_run()
753 if (!(st->residual_echo[0] >=0 && st->residual_echo[0]<N*1e9f)) in speex_preprocess_run()
756 st->residual_echo[i] = 0; in speex_preprocess_run()
760st->echo_noise[i] = MAX32(MULT16_32_Q15(QCONST16(.6f,15),st->echo_noise[i]), st->residual_echo[i]); in speex_preprocess_run()
761 filterbank_compute_bank32(st->bank, st->echo_noise, st->echo_noise+N); in speex_preprocess_run()
764 st->echo_noise[i] = 0; in speex_preprocess_run()
766 preprocess_analysis(st, x); in speex_preprocess_run()
768 update_noise_prob(st); in speex_preprocess_run()
781 if (!st->update_prob[i] || st->ps[i] < PSHR32(st->noise[i], NOISE_SHIFT)) in speex_preprocess_run()
782st->noise[i] = MAX32(EXTEND32(0),MULT16_32_Q15(beta_1,st->noise[i]) + MULT16_32_Q15(beta,SHL32(st-… in speex_preprocess_run()
784 filterbank_compute_bank32(st->bank, st->noise, st->noise+N); in speex_preprocess_run()
787 if (st->nb_adapt==1) in speex_preprocess_run()
789 st->old_ps[i] = ps[i]; in speex_preprocess_run()
797 …tot_noise = ADD32(ADD32(ADD32(EXTEND32(1), PSHR32(st->noise[i],NOISE_SHIFT)) , st->echo_noise[i]) … in speex_preprocess_run()
800 st->post[i] = SUB16(DIV32_16_Q8(ps[i],tot_noise), QCONST16(1.f,SNR_SHIFT)); in speex_preprocess_run()
801 st->post[i]=MIN16(st->post[i], QCONST16(100.f,SNR_SHIFT)); in speex_preprocess_run()
804 …6(.1f,15)+MULT16_16_Q15(QCONST16(.89f,15),SQR16_Q15(DIV32_16_Q15(st->old_ps[i],ADD32(st->old_ps[i]… in speex_preprocess_run()
807st->prior[i] = EXTRACT16(PSHR32(ADD32(MULT16_16(gamma,MAX16(0,st->post[i])), MULT16_16(Q15_ONE-gam… in speex_preprocess_run()
808 st->prior[i]=MIN16(st->prior[i], QCONST16(100.f,SNR_SHIFT)); in speex_preprocess_run()
814st->zeta[0] = PSHR32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[0]), MULT16_16(QCONST16(.3f,15),st-… in speex_preprocess_run()
816st->zeta[i] = PSHR32(ADD32(ADD32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[i]), MULT16_16(QCONST16… in speex_preprocess_run()
817 … MULT16_16(QCONST16(.075f,15),st->prior[i-1])), MULT16_16(QCONST16(.075f,15),st->prior[i+1])),15); in speex_preprocess_run()
819st->zeta[i] = PSHR32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[i]), MULT16_16(QCONST16(.3f,15),st-… in speex_preprocess_run()
824 Zframe = ADD32(Zframe, EXTEND32(st->zeta[i])); in speex_preprocess_run()
825 Pframe = QCONST16(.1f,15)+MULT16_16_Q15(QCONST16(.899f,15),qcurve(DIV32_16(Zframe,st->nbands))); in speex_preprocess_run()
827 …EXTRACT16(PSHR32(ADD32(MULT16_16(SUB16(Q15_ONE,Pframe), st->echo_suppress), MULT16_16(Pframe, st->… in speex_preprocess_run()
829 …compute_gain_floor(st->noise_suppress, effective_echo_suppress, st->noise+N, st->echo_noise+N, st-… in speex_preprocess_run()
850 …prior_ratio = PDIV32_16(SHL32(EXTEND32(st->prior[i]), 15), ADD16(st->prior[i], SHL32(1,SNR_SHIFT))… in speex_preprocess_run()
851 …theta = MULT16_32_P15(prior_ratio, QCONST32(1.f,EXPIN_SHIFT)+SHL32(EXTEND32(st->post[i]),EXPIN_SHI… in speex_preprocess_run()
855 st->gain[i] = EXTRACT16(MIN32(Q15_ONE, MULT16_32_Q15(prior_ratio, MM))); in speex_preprocess_run()
857st->old_ps[i] = MULT16_32_P15(QCONST16(.2f,15),st->old_ps[i]) + MULT16_32_P15(MULT16_16_P15(QCONST… in speex_preprocess_run()
859 P1 = QCONST16(.199f,15)+MULT16_16_Q15(QCONST16(.8f,15),qcurve (st->zeta[i])); in speex_preprocess_run()
863 /*Q8*/tmp = MULT16_16_Q15((SHL32(1,SNR_SHIFT)+st->prior[i]),EXTRACT16(MIN32(Q15ONE,SHR32(spx_exp(-E… in speex_preprocess_run()
866 st->gain2[i]=DIV32_16(SHL32(EXTEND32(32767),SNR_SHIFT), ADD16(256,tmp)); in speex_preprocess_run()
868 st->gain2[i]=1/(1.f + (q/(1.f-q))*(1+st->prior[i])*exp(-theta)); in speex_preprocess_run()
872 filterbank_compute_psd16(st->bank,st->gain2+N, st->gain2); in speex_preprocess_run()
873 filterbank_compute_psd16(st->bank,st->gain+N, st->gain); in speex_preprocess_run()
878 filterbank_compute_psd16(st->bank,st->gain_floor+N, st->gain_floor); in speex_preprocess_run()
891 …prior_ratio = PDIV32_16(SHL32(EXTEND32(st->prior[i]), 15), ADD16(st->prior[i], SHL32(1,SNR_SHIFT))… in speex_preprocess_run()
892 …theta = MULT16_32_P15(prior_ratio, QCONST32(1.f,EXPIN_SHIFT)+SHL32(EXTEND32(st->post[i]),EXPIN_SHI… in speex_preprocess_run()
899 p = st->gain2[i]; in speex_preprocess_run()
902 if (MULT16_16_Q15(QCONST16(.333f,15),g) > st->gain[i]) in speex_preprocess_run()
903 g = MULT16_16(3,st->gain[i]); in speex_preprocess_run()
904 st->gain[i] = g; in speex_preprocess_run()
907st->old_ps[i] = MULT16_32_P15(QCONST16(.2f,15),st->old_ps[i]) + MULT16_32_P15(MULT16_16_P15(QCONST… in speex_preprocess_run()
910 if (st->gain[i] < st->gain_floor[i]) in speex_preprocess_run()
911 st->gain[i] = st->gain_floor[i]; in speex_preprocess_run()
918 …T16_16_P15(p,spx_sqrt(SHL32(EXTEND32(st->gain[i]),15))) + MULT16_16_P15(SUB16(Q15_ONE,p),spx_sqrt(… in speex_preprocess_run()
919 st->gain2[i]=SQR16_Q15(tmp); in speex_preprocess_run()
928 spx_word16_t p = st->gain2[i]; in speex_preprocess_run()
929 st->gain[i] = MAX16(st->gain[i], st->gain_floor[i]); in speex_preprocess_run()
930 …T16_16_P15(p,spx_sqrt(SHL32(EXTEND32(st->gain[i]),15))) + MULT16_16_P15(SUB16(Q15_ONE,p),spx_sqrt(… in speex_preprocess_run()
931 st->gain2[i]=SQR16_Q15(tmp); in speex_preprocess_run()
933 filterbank_compute_psd16(st->bank,st->gain2+N, st->gain2); in speex_preprocess_run()
937 if (!st->denoise_enabled) in speex_preprocess_run()
940 st->gain2[i]=Q15_ONE; in speex_preprocess_run()
946 st->ft[2*i-1] = MULT16_16_P15(st->gain2[i],st->ft[2*i-1]); in speex_preprocess_run()
947 st->ft[2*i] = MULT16_16_P15(st->gain2[i],st->ft[2*i]); in speex_preprocess_run()
949 st->ft[0] = MULT16_16_P15(st->gain2[0],st->ft[0]); in speex_preprocess_run()
950 st->ft[2*N-1] = MULT16_16_P15(st->gain2[N-1],st->ft[2*N-1]); in speex_preprocess_run()
954 if (st->agc_enabled) in speex_preprocess_run()
955 speex_compute_agc(st, Pframe, st->ft); in speex_preprocess_run()
959 spx_ifft(st->fft_lookup, st->ft, st->frame); in speex_preprocess_run()
962 st->frame[i] = PSHR16(st->frame[i], st->frame_shift); in speex_preprocess_run()
966 if (st->agc_enabled) in speex_preprocess_run()
970 if (fabs(st->frame[i])>max_sample) in speex_preprocess_run()
971 max_sample = fabs(st->frame[i]); in speex_preprocess_run()
976 st->frame[i] *= damp; in speex_preprocess_run()
983 st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]); in speex_preprocess_run()
987 x[i] = st->outbuf[i] + st->frame[i]; in speex_preprocess_run()
989 x[N3+i] = st->frame[N3+i]; in speex_preprocess_run()
993 st->outbuf[i] = st->frame[st->frame_size+i]; in speex_preprocess_run()
996 st->speech_prob = Pframe; in speex_preprocess_run()
997 if (st->vad_enabled) in speex_preprocess_run()
999 …if (st->speech_prob > st->speech_prob_start || (st->was_speech && st->speech_prob > st->speech_pro… in speex_preprocess_run()
1001 st->was_speech=1; in speex_preprocess_run()
1005 st->was_speech=0; in speex_preprocess_run()
1013 EXPORT void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x) in speex_preprocess_estimate_update() argument
1016 int N = st->ps_size; in speex_preprocess_estimate_update()
1017 int N3 = 2*N - st->frame_size; in speex_preprocess_estimate_update()
1019 spx_word32_t *ps=st->ps; in speex_preprocess_estimate_update()
1021 M = st->nbands; in speex_preprocess_estimate_update()
1022 st->min_count++; in speex_preprocess_estimate_update()
1024 preprocess_analysis(st, x); in speex_preprocess_estimate_update()
1026 update_noise_prob(st); in speex_preprocess_estimate_update()
1030 if (!st->update_prob[i] || st->ps[i] < PSHR32(st->noise[i],NOISE_SHIFT)) in speex_preprocess_estimate_update()
1032st->noise[i] = MULT16_32_Q15(QCONST16(.95f,15),st->noise[i]) + MULT16_32_Q15(QCONST16(.05f,15),SHL… in speex_preprocess_estimate_update()
1037 st->outbuf[i] = MULT16_16_Q15(x[st->frame_size-N3+i],st->window[st->frame_size+i]); in speex_preprocess_estimate_update()
1041 st->old_ps[i] = ps[i]; in speex_preprocess_estimate_update()
1044 st->reverb_estimate[i] = MULT16_32_Q15(st->reverb_decay, st->reverb_estimate[i]); in speex_preprocess_estimate_update()
1051 SpeexPreprocessState *st; in speex_preprocess_ctl() local
1052 st=(SpeexPreprocessState*)state; in speex_preprocess_ctl()
1056 st->denoise_enabled = (*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1059 (*(spx_int32_t*)ptr) = st->denoise_enabled; in speex_preprocess_ctl()
1063 st->agc_enabled = (*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1066 (*(spx_int32_t*)ptr) = st->agc_enabled; in speex_preprocess_ctl()
1070 st->agc_level = (*(float*)ptr); in speex_preprocess_ctl()
1071 if (st->agc_level<1) in speex_preprocess_ctl()
1072 st->agc_level=1; in speex_preprocess_ctl()
1073 if (st->agc_level>32768) in speex_preprocess_ctl()
1074 st->agc_level=32768; in speex_preprocess_ctl()
1077 (*(float*)ptr) = st->agc_level; in speex_preprocess_ctl()
1081st->max_increase_step = exp(0.11513f * (*(spx_int32_t*)ptr)*st->frame_size / st->sampling_rate); in speex_preprocess_ctl()
1084 …(*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_increase_step)*st->sampling_rate/st->frame_size… in speex_preprocess_ctl()
1087st->max_decrease_step = exp(0.11513f * (*(spx_int32_t*)ptr)*st->frame_size / st->sampling_rate); in speex_preprocess_ctl()
1090 …(*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_decrease_step)*st->sampling_rate/st->frame_size… in speex_preprocess_ctl()
1093 st->max_gain = exp(0.11513f * (*(spx_int32_t*)ptr)); in speex_preprocess_ctl()
1096 (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_gain)); in speex_preprocess_ctl()
1102 st->vad_enabled = (*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1105 (*(spx_int32_t*)ptr) = st->vad_enabled; in speex_preprocess_ctl()
1109 st->dereverb_enabled = (*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1110 for (i=0;i<st->ps_size;i++) in speex_preprocess_ctl()
1111 st->reverb_estimate[i]=0; in speex_preprocess_ctl()
1114 (*(spx_int32_t*)ptr) = st->dereverb_enabled; in speex_preprocess_ctl()
1137 st->speech_prob_start = DIV32_16(MULT16_16(Q15ONE,*(spx_int32_t*)ptr), 100); in speex_preprocess_ctl()
1140 (*(spx_int32_t*)ptr) = MULT16_16_Q15(st->speech_prob_start, 100); in speex_preprocess_ctl()
1145 st->speech_prob_continue = DIV32_16(MULT16_16(Q15ONE,*(spx_int32_t*)ptr), 100); in speex_preprocess_ctl()
1148 (*(spx_int32_t*)ptr) = MULT16_16_Q15(st->speech_prob_continue, 100); in speex_preprocess_ctl()
1152 st->noise_suppress = -ABS(*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1155 (*(spx_int32_t*)ptr) = st->noise_suppress; in speex_preprocess_ctl()
1158 st->echo_suppress = -ABS(*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1161 (*(spx_int32_t*)ptr) = st->echo_suppress; in speex_preprocess_ctl()
1164 st->echo_suppress_active = -ABS(*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1167 (*(spx_int32_t*)ptr) = st->echo_suppress_active; in speex_preprocess_ctl()
1170 st->echo_state = (SpeexEchoState*)ptr; in speex_preprocess_ctl()
1173 (*(SpeexEchoState**)ptr) = (SpeexEchoState*)st->echo_state; in speex_preprocess_ctl()
1177 (*(spx_int32_t*)ptr) = pow(st->loudness, 1.0/LOUDNESS_EXP); in speex_preprocess_ctl()
1180 (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->agc_gain)); in speex_preprocess_ctl()
1185 (*(spx_int32_t*)ptr) = st->ps_size; in speex_preprocess_ctl()
1188 for(i=0;i<st->ps_size;i++) in speex_preprocess_ctl()
1189 ((spx_int32_t *)ptr)[i] = (spx_int32_t) st->ps[i]; in speex_preprocess_ctl()
1192 for(i=0;i<st->ps_size;i++) in speex_preprocess_ctl()
1193 ((spx_int32_t *)ptr)[i] = (spx_int32_t) PSHR32(st->noise[i], NOISE_SHIFT); in speex_preprocess_ctl()
1196 (*(spx_int32_t*)ptr) = MULT16_16_Q15(st->speech_prob, 100); in speex_preprocess_ctl()
1200 st->agc_level = (*(spx_int32_t*)ptr); in speex_preprocess_ctl()
1201 if (st->agc_level<1) in speex_preprocess_ctl()
1202 st->agc_level=1; in speex_preprocess_ctl()
1203 if (st->agc_level>32768) in speex_preprocess_ctl()
1204 st->agc_level=32768; in speex_preprocess_ctl()
1207 (*(spx_int32_t*)ptr) = st->agc_level; in speex_preprocess_ctl()