123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140 |
- #include "dec_amr.h"
- const char dec_amr_id[] = "@(#)$Id $" dec_amr_h;
- #include <stdlib.h>
- #include <stdio.h>
- #include "typedef.h"
- #include "basic_op.h"
- #include "count.h"
- #include "cnst.h"
- #include "copy.h"
- #include "set_zero.h"
- #include "syn_filt.h"
- #include "d_plsf.h"
- #include "agc.h"
- #include "int_lpc.h"
- #include "dec_gain.h"
- #include "dec_lag3.h"
- #include "dec_lag6.h"
- #include "d2_9pf.h"
- #include "d2_11pf.h"
- #include "d3_14pf.h"
- #include "d4_17pf.h"
- #include "d8_31pf.h"
- #include "d1035pf.h"
- #include "pred_lt.h"
- #include "d_gain_p.h"
- #include "d_gain_c.h"
- #include "dec_gain.h"
- #include "ec_gains.h"
- #include "ph_disp.h"
- #include "c_g_aver.h"
- #include "int_lsf.h"
- #include "lsp_lsf.h"
- #include "lsp_avg.h"
- #include "bgnscd.h"
- #include "ex_ctrl.h"
- #include "sqrt_l.h"
- #include "frame.h"
- #include "lsp.tab"
- #include "bitno.tab"
- #include "b_cn_cod.h"
- int Decoder_amr_init (Decoder_amrState **state)
- {
- Decoder_amrState* s;
- Word16 i;
-
- if (state == (Decoder_amrState **) NULL){
- wfprintf(stderr, "Decoder_amr_init: invalid parameter\n");
- return -1;
- }
- *state = NULL;
-
-
- if ((s= (Decoder_amrState *) wmalloc(sizeof(Decoder_amrState))) == NULL){
- wfprintf(stderr, "Decoder_amr_init: can not malloc state structure\n");
- return -1;
- }
-
- s->T0_lagBuff = 40;
- s->inBackgroundNoise = 0;
- s->voicedHangover = 0;
- for (i = 0; i < 9; i++)
- s->ltpGainHistory[i] = 0;
- s->lsfState = NULL;
- s->ec_gain_p_st = NULL;
- s->ec_gain_c_st = NULL;
- s->pred_state = NULL;
- s->ph_disp_st = NULL;
- s->dtxDecoderState = NULL;
-
- if (D_plsf_init(&s->lsfState) ||
- ec_gain_pitch_init(&s->ec_gain_p_st) ||
- ec_gain_code_init(&s->ec_gain_c_st) ||
- gc_pred_init(&s->pred_state) ||
- Cb_gain_average_init(&s->Cb_gain_averState) ||
- lsp_avg_init(&s->lsp_avg_st) ||
- Bgn_scd_init(&s->background_state) ||
- ph_disp_init(&s->ph_disp_st) ||
- dtx_dec_init(&s->dtxDecoderState)) {
- Decoder_amr_exit(&s);
- return -1;
- }
-
- Decoder_amr_reset(s, (enum Mode)0);
- *state = s;
-
- return 0;
- }
- int Decoder_amr_reset (Decoder_amrState *state, enum Mode mode)
- {
- Word16 i;
- if (state == (Decoder_amrState *) NULL){
- wfprintf(stderr, "Decoder_amr_reset: invalid parameter\n");
- return -1;
- }
-
-
- state->exc = state->old_exc + PIT_MAX + L_INTERPOL;
-
- Set_zero (state->old_exc, PIT_MAX + L_INTERPOL);
- if (mode != MRDTX)
- Set_zero (state->mem_syn, M);
-
- state->sharp = SHARPMIN;
- state->old_T0 = 40;
-
-
- if (mode != MRDTX) {
- Copy(lsp_init_data, &state->lsp_old[0], M);
- }
-
- state->prev_bf = 0;
- state->prev_pdf = 0;
- state->state = 0;
-
- state->T0_lagBuff = 40;
- state->inBackgroundNoise = 0;
- state->voicedHangover = 0;
- if (mode != MRDTX) {
- for (i=0;i<9;i++)
- state->excEnergyHist[i] = 0;
- }
-
- for (i = 0; i < 9; i++)
- state->ltpGainHistory[i] = 0;
- Cb_gain_average_reset(state->Cb_gain_averState);
- if (mode != MRDTX)
- lsp_avg_reset(state->lsp_avg_st);
- D_plsf_reset(state->lsfState);
- ec_gain_pitch_reset(state->ec_gain_p_st);
- ec_gain_code_reset(state->ec_gain_c_st);
- if (mode != MRDTX)
- gc_pred_reset(state->pred_state);
- Bgn_scd_reset(state->background_state);
- state->nodataSeed = 21845;
- ph_disp_reset(state->ph_disp_st);
- if (mode != MRDTX)
- dtx_dec_reset(state->dtxDecoderState);
-
- return 0;
- }
- void Decoder_amr_exit (Decoder_amrState **state)
- {
- if (state == NULL || *state == NULL)
- return;
-
- D_plsf_exit(&(*state)->lsfState);
- ec_gain_pitch_exit(&(*state)->ec_gain_p_st);
- ec_gain_code_exit(&(*state)->ec_gain_c_st);
- gc_pred_exit(&(*state)->pred_state);
- Bgn_scd_exit(&(*state)->background_state);
- ph_disp_exit(&(*state)->ph_disp_st);
- Cb_gain_average_exit(&(*state)->Cb_gain_averState);
- lsp_avg_exit(&(*state)->lsp_avg_st);
- dtx_dec_exit(&(*state)->dtxDecoderState);
-
-
- wfree(*state);
- *state = NULL;
-
- return;
- }
- int Decoder_amr (
- Decoder_amrState *st,
- enum Mode mode,
- Word16 parm[],
- enum RXFrameType frame_type,
- Word16 synth[],
- Word16 A_t[]
- )
- {
-
-
- Word16 *Az;
-
-
- Word16 lsp_new[M];
- Word16 lsp_mid[M];
-
-
- Word16 prev_lsf[M];
- Word16 lsf_i[M];
-
- Word16 code[L_SUBFR];
-
- Word16 excp[L_SUBFR];
- Word16 exc_enhanced[L_SUBFR];
-
- Word16 i, i_subfr;
- Word16 T0, T0_frac, index, index_mr475 = 0;
- Word16 gain_pit, gain_code, gain_code_mix, pit_sharp, pit_flag, pitch_fac;
- Word16 t0_min, t0_max;
- Word16 delta_frc_low, delta_frc_range;
- Word16 tmp_shift;
- Word16 temp;
- Word32 L_temp;
- Word16 flag4;
- Word16 carefulFlag;
- Word16 excEnergy;
- Word16 subfrNr;
- Word16 evenSubfr = 0;
- Word16 bfi = 0;
- Word16 pdfi = 0;
- enum DTXStateType newDTXState;
-
- newDTXState = rx_dtx_handler(st->dtxDecoderState, frame_type);
- move16 ();
-
-
- test();
- if (sub_ex(newDTXState, SPEECH) != 0 )
- {
- Decoder_amr_reset (st, MRDTX);
- dtx_dec(st->dtxDecoderState,
- st->mem_syn,
- st->lsfState,
- st->pred_state,
- st->Cb_gain_averState,
- newDTXState,
- mode,
- parm, synth, A_t);
-
-
- Lsf_lsp(st->lsfState->past_lsf_q, st->lsp_old, M);
- lsp_avg(st->lsp_avg_st, st->lsfState->past_lsf_q);
- goto the_end;
- }
-
- test (); test (); test ();
- if ((sub_ex(frame_type, RX_SPEECH_BAD) == 0) ||
- (sub_ex(frame_type, RX_NO_DATA) == 0) ||
- (sub_ex(frame_type, RX_ONSET) == 0))
- {
- bfi = 1; move16 ();
- test(); test();
- if ((sub_ex(frame_type, RX_NO_DATA) == 0) ||
- (sub_ex(frame_type, RX_ONSET) == 0))
- {
- build_CN_param(&st->nodataSeed,
- prmno[mode],
- bitno[mode],
- parm);
- }
- }
- else if (sub_ex(frame_type, RX_SPEECH_DEGRADED) == 0)
- {
- pdfi = 1; move16 ();
- }
-
-
- test();
- if (bfi != 0)
- {
- st->state = add_ex (st->state, 1);
- }
- else if (sub_ex (st->state, 6) == 0)
- {
- st->state = 5; move16 ();
- }
- else
- {
- st->state = 0; move16 ();
- }
-
- test ();
- if (sub_ex (st->state, 6) > 0)
- {
- st->state = 6; move16 ();
- }
-
-
-
-
-
-
-
-
-
- test();
- if (sub_ex(st->dtxDecoderState->dtxGlobalState, DTX) == 0)
- {
- st->state = 5; move16 ();
- st->prev_bf = 0; move16 ();
- }
- else if (test (), sub_ex(st->dtxDecoderState->dtxGlobalState, DTX_MUTE) == 0)
- {
- st->state = 5; move16 ();
- st->prev_bf = 1; move16 ();
- }
-
-
- Copy (st->lsfState->past_lsf_q, prev_lsf, M);
-
-
- test ();
- if (sub_ex (mode, MR122) != 0)
- {
- D_plsf_3(st->lsfState, mode, bfi, parm, lsp_new);
- fwc ();
-
- parm += 3; move16 ();
-
- Int_lpc_1to3(st->lsp_old, lsp_new, A_t);
- }
- else
- {
- D_plsf_5 (st->lsfState, bfi, parm, lsp_mid, lsp_new);
- fwc ();
-
- parm += 5; move16 ();
-
- Int_lpc_1and3 (st->lsp_old, lsp_mid, lsp_new, A_t);
- }
-
-
- for (i = 0; i < M; i++)
- {
- st->lsp_old[i] = lsp_new[i]; move16 ();
- }
- fwc ();
-
-
-
- Az = A_t; move16 ();
-
- evenSubfr = 0; move16();
- subfrNr = -1; move16();
- for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR)
- {
- subfrNr = add_ex(subfrNr, 1);
- evenSubfr = sub_ex(1, evenSubfr);
-
- pit_flag = i_subfr; move16 ();
- test();
- if (sub_ex (i_subfr, L_FRAME_BY2) == 0)
- {
- test(); test();
- if (sub_ex(mode, MR475) != 0 && sub_ex(mode, MR515) != 0)
- {
- pit_flag = 0; move16 ();
- }
- }
-
-
- index = *parm++; move16 ();
-
-
- test ();
- if (sub_ex(mode, MR122) != 0)
- {
-
-
-
- flag4 = 0; move16 ();
- test (); test (); test (); test ();
- if ((sub_ex (mode, MR475) == 0) ||
- (sub_ex (mode, MR515) == 0) ||
- (sub_ex (mode, MR59) == 0) ||
- (sub_ex (mode, MR67) == 0) ) {
- flag4 = 1; move16 ();
- }
-
-
- delta_frc_low = 5; move16();
- delta_frc_range = 9; move16();
- test ();
- if ( sub_ex(mode, MR795) == 0 )
- {
- delta_frc_low = 10; move16();
- delta_frc_range = 19; move16();
- }
-
- t0_min = sub_ex(st->old_T0, delta_frc_low);
- test ();
- if (sub_ex(t0_min, PIT_MIN) < 0)
- {
- t0_min = PIT_MIN; move16();
- }
- t0_max = add_ex(t0_min, delta_frc_range);
- test ();
- if (sub_ex(t0_max, PIT_MAX) > 0)
- {
- t0_max = PIT_MAX; move16();
- t0_min = sub_ex(t0_max, delta_frc_range);
- }
-
- Dec_lag3 (index, t0_min, t0_max, pit_flag, st->old_T0,
- &T0, &T0_frac, flag4);
- st->T0_lagBuff = T0; move16 ();
- test ();
- if (bfi != 0)
- {
- test ();
- if (sub_ex (st->old_T0, PIT_MAX) < 0)
- {
- st->old_T0 = add_ex(st->old_T0, 1);
- }
- T0 = st->old_T0; move16 ();
- T0_frac = 0; move16 ();
- test (); test (); test (); test (); test ();
- if ( st->inBackgroundNoise != 0 &&
- sub_ex(st->voicedHangover, 4) > 0 &&
- ((sub_ex(mode, MR475) == 0 ) ||
- (sub_ex(mode, MR515) == 0 ) ||
- (sub_ex(mode, MR59) == 0) )
- )
- {
- T0 = st->T0_lagBuff; move16 ();
- }
- }
- fwc ();
- Pred_lt_3or6 (st->exc, T0, T0_frac, L_SUBFR, 1);
- }
- else
- {
- Dec_lag6 (index, PIT_MIN_MR122,
- PIT_MAX, pit_flag, &T0, &T0_frac);
- test (); test (); test ();
- if ( bfi == 0 && (pit_flag == 0 || sub_ex (index, 61) < 0))
- {
- }
- else
- {
- st->T0_lagBuff = T0; move16 ();
- T0 = st->old_T0; move16 ();
- T0_frac = 0; move16 ();
- }
- fwc ();
- Pred_lt_3or6 (st->exc, T0, T0_frac, L_SUBFR, 0);
- }
-
- fwc ();
-
-
- test (); test ();
- if (sub_ex (mode, MR475) == 0 || sub_ex (mode, MR515) == 0)
- {
- index = *parm++; move16 ();
- i = *parm++; move16 ();
-
- fwc ();
- decode_2i40_9bits (subfrNr, i, index, code);
-
- fwc ();
- pit_sharp = shl_ex (st->sharp, 1);
- }
- else if (sub_ex (mode, MR59) == 0)
- {
- test ();
- index = *parm++; move16 ();
- i = *parm++; move16 ();
-
- fwc ();
- decode_2i40_11bits (i, index, code);
-
- fwc ();
- pit_sharp = shl_ex (st->sharp, 1);
- }
- else if (sub_ex (mode, MR67) == 0)
- {
- test (); test ();
- index = *parm++; move16 ();
- i = *parm++; move16 ();
-
- fwc ();
- decode_3i40_14bits (i, index, code);
-
- fwc ();
- pit_sharp = shl_ex (st->sharp, 1);
- }
- else if (sub_ex (mode, MR795) <= 0)
- {
- test (); test (); test ();
- index = *parm++; move16 ();
- i = *parm++; move16 ();
-
- fwc ();
- decode_4i40_17bits (i, index, code);
-
- fwc ();
- pit_sharp = shl_ex (st->sharp, 1);
- }
- else if (sub_ex (mode, MR102) == 0)
- {
- test (); test (); test ();
- fwc ();
- dec_8i40_31bits (parm, code);
- parm += 7; move16 ();
- fwc ();
- pit_sharp = shl_ex (st->sharp, 1);
- }
- else
- {
- test (); test (); test ();
- index = *parm++; move16 ();
- test();
- if (bfi != 0)
- {
- ec_gain_pitch (st->ec_gain_p_st, st->state, &gain_pit);
- }
- else
- {
- gain_pit = d_gain_pitch (mode, index); move16 ();
- }
- ec_gain_pitch_update (st->ec_gain_p_st, bfi, st->prev_bf,
- &gain_pit);
-
- fwc ();
- dec_10i40_35bits (parm, code);
- parm += 10; move16 ();
- fwc ();
-
-
-
- pit_sharp = shl_ex (gain_pit, 1);
- }
-
-
- for (i = T0; i < L_SUBFR; i++)
- {
- temp = mult_ex (code[i - T0], pit_sharp);
- code[i] = add_ex (code[i], temp);
- move16 ();
- }
-
- fwc ();
-
-
- if (test(), sub_ex (mode, MR475) == 0)
- {
-
- test();
- if (evenSubfr != 0)
- {
- index_mr475 = *parm++; move16 ();
- }
- test();
- if (bfi == 0)
- {
- Dec_gain(st->pred_state, mode, index_mr475, code,
- evenSubfr, &gain_pit, &gain_code);
- }
- else
- {
- ec_gain_pitch (st->ec_gain_p_st, st->state, &gain_pit);
- ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state,
- &gain_code);
- }
- ec_gain_pitch_update (st->ec_gain_p_st, bfi, st->prev_bf,
- &gain_pit);
- ec_gain_code_update (st->ec_gain_c_st, bfi, st->prev_bf,
- &gain_code);
-
- fwc ();
- pit_sharp = gain_pit; move16 ();
- test ();
- if (sub_ex (pit_sharp, SHARPMAX) > 0)
- {
- pit_sharp = SHARPMAX; move16 ();
- }
- }
- else if (test(), test(), (sub_ex (mode, MR74) <= 0) ||
- (sub_ex (mode, MR102) == 0))
- {
-
- index = *parm++; move16 ();
-
- test();
- if (bfi == 0)
- {
- Dec_gain(st->pred_state, mode, index, code,
- evenSubfr, &gain_pit, &gain_code);
- }
- else
- {
- ec_gain_pitch (st->ec_gain_p_st, st->state, &gain_pit);
- ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state,
- &gain_code);
- }
- ec_gain_pitch_update (st->ec_gain_p_st, bfi, st->prev_bf,
- &gain_pit);
- ec_gain_code_update (st->ec_gain_c_st, bfi, st->prev_bf,
- &gain_code);
- fwc ();
-
- pit_sharp = gain_pit; move16 ();
- test ();
- if (sub_ex (pit_sharp, SHARPMAX) > 0)
- {
- pit_sharp = SHARPMAX; move16 ();
- }
- if (sub_ex (mode, MR102) == 0)
- {
- if (sub_ex (st->old_T0, add_ex(L_SUBFR, 5)) > 0)
- {
- pit_sharp = shr_ex(pit_sharp, 2);
- }
- }
- }
- else
- {
-
- index = *parm++; move16 ();
-
- test ();
- if (sub_ex (mode, MR795) == 0)
- {
-
- test();
- if (bfi != 0)
- {
- ec_gain_pitch (st->ec_gain_p_st, st->state, &gain_pit);
- }
- else
- {
- gain_pit = d_gain_pitch (mode, index); move16 ();
- }
- ec_gain_pitch_update (st->ec_gain_p_st, bfi, st->prev_bf,
- &gain_pit);
-
-
- index = *parm++; move16 ();
- test();
- if (bfi == 0)
- {
- d_gain_code (st->pred_state, mode, index, code, &gain_code);
- }
- else
- {
- ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state,
- &gain_code);
- }
- ec_gain_code_update (st->ec_gain_c_st, bfi, st->prev_bf,
- &gain_code);
-
- fwc ();
-
- pit_sharp = gain_pit; move16 ();
- test ();
- if (sub_ex (pit_sharp, SHARPMAX) > 0)
- {
- pit_sharp = SHARPMAX; move16 ();
- }
- }
- else
- {
- test();
- if (bfi == 0)
- {
- d_gain_code (st->pred_state, mode, index, code, &gain_code);
- }
- else
- {
- ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state,
- &gain_code);
- }
- ec_gain_code_update (st->ec_gain_c_st, bfi, st->prev_bf,
- &gain_code);
-
- fwc ();
-
- pit_sharp = gain_pit; move16 ();
- }
- }
-
-
-
-
- test(); test();
- if (sub_ex(mode, MR475) != 0 || evenSubfr == 0)
- {
- st->sharp = gain_pit; move16 ();
- test ();
- if (sub_ex (st->sharp, SHARPMAX) > 0)
- {
- st->sharp = SHARPMAX; move16 ();
- }
- }
- pit_sharp = shl_ex (pit_sharp, 1);
- test ();
- if (sub_ex (pit_sharp, 16384) > 0)
- {
- for (i = 0; i < L_SUBFR; i++)
- {
- temp = mult_ex (st->exc[i], pit_sharp);
- L_temp = L_mult_ex (temp, gain_pit);
- test ();
- if (sub_ex(mode, MR122)==0)
- {
- L_temp = L_shr_ex (L_temp, 1);
- }
- excp[i] = round_ex (L_temp); move16 ();
- }
- }
-
-
- test ();
- if ( bfi == 0 )
- {
- for (i = 0; i < 8; i++)
- {
- st->ltpGainHistory[i] = st->ltpGainHistory[i+1]; move16 ();
- }
- st->ltpGainHistory[8] = gain_pit; move16 ();
- }
-
- test (); test (); test (); test (); test (); test ();
- if ( (st->prev_bf != 0 || bfi != 0) && st->inBackgroundNoise != 0 &&
- ((sub_ex(mode, MR475) == 0) ||
- (sub_ex(mode, MR515) == 0) ||
- (sub_ex(mode, MR59) == 0))
- )
- {
- test ();
- if ( sub_ex (gain_pit, 12288) > 0)
- gain_pit = add_ex( shr_ex( sub_ex(gain_pit, 12288), 1 ), 12288 );
-
- test ();
- if ( sub_ex (gain_pit, 14745) > 0)
- {
- gain_pit = 14745; move16 ();
- }
- }
-
- Int_lsf(prev_lsf, st->lsfState->past_lsf_q, i_subfr, lsf_i);
- gain_code_mix = Cb_gain_average(
- st->Cb_gain_averState, mode, gain_code,
- lsf_i, st->lsp_avg_st->lsp_meanSave, bfi,
- st->prev_bf, pdfi, st->prev_pdf,
- st->inBackgroundNoise, st->voicedHangover); move16 ();
-
-
- test();
- if ((sub_ex(mode, MR67) > 0) && (sub_ex(mode, MR102) != 0) )
-
- {
- gain_code_mix = gain_code; move16 ();
- }
-
-
- test ();
- if (sub_ex(mode, MR102) <= 0)
- {
- pitch_fac = gain_pit; move16 ();
- tmp_shift = 1; move16 ();
- }
- else
- {
- pitch_fac = shr_ex (gain_pit, 1); move16 ();
- tmp_shift = 2; move16 ();
- }
-
- for (i = 0; i < L_SUBFR; i++)
- {
- exc_enhanced[i] = st->exc[i]; move16 ();
-
- L_temp = L_mult_ex (st->exc[i], pitch_fac);
-
-
- L_temp = L_mac_ex (L_temp, code[i], gain_code);
-
-
- L_temp = L_shl_ex (L_temp, tmp_shift);
- st->exc[i] = round_ex (L_temp); move16 ();
- }
-
-
- ph_disp_release(st->ph_disp_st);
- test (); test (); test (); test (); test (); test ();
- if ( ((sub_ex(mode, MR475) == 0) ||
- (sub_ex(mode, MR515) == 0) ||
- (sub_ex(mode, MR59) == 0)) &&
- sub_ex(st->voicedHangover, 3) > 0 &&
- st->inBackgroundNoise != 0 &&
- bfi != 0 )
- {
- ph_disp_lock(st->ph_disp_st);
- }
-
- ph_disp(st->ph_disp_st, mode,
- exc_enhanced, gain_code_mix, gain_pit, code,
- pitch_fac, tmp_shift);
-
-
- L_temp = 0; move32 ();
- for (i = 0; i < L_SUBFR; i++)
- {
- L_temp = L_mac_ex (L_temp, exc_enhanced[i], exc_enhanced[i] );
- }
- L_temp = L_shr_ex (L_temp, 1);
- L_temp = sqrt_l_exp(L_temp, &temp); move32 ();
- L_temp = L_shr_ex(L_temp, add_ex( shr_ex(temp, 1), 15));
- L_temp = L_shr_ex(L_temp, 2);
- excEnergy = extract_l_ex(L_temp);
- test (); test (); test (); test (); test ();
- test (); test (); test (); test (); test ();
- if ( ((sub_ex (mode, MR475) == 0) ||
- (sub_ex (mode, MR515) == 0) ||
- (sub_ex (mode, MR59) == 0)) &&
- sub_ex(st->voicedHangover, 5) > 0 &&
- st->inBackgroundNoise != 0 &&
- sub_ex(st->state, 4) < 0 &&
- ( (pdfi != 0 && st->prev_pdf != 0) ||
- bfi != 0 ||
- st->prev_bf != 0) )
- {
- carefulFlag = 0; move32 ();
- test (); test ();
- if ( pdfi != 0 && bfi == 0 )
- {
- carefulFlag = 1; move16 ();
- }
- Ex_ctrl(exc_enhanced,
- excEnergy,
- st->excEnergyHist,
- st->voicedHangover,
- st->prev_bf,
- carefulFlag);
- }
- test (); test (); test (); test ();
- if ( st->inBackgroundNoise != 0 &&
- ( bfi != 0 || st->prev_bf != 0 ) &&
- sub_ex(st->state, 4) < 0 )
- {
- ;
- }
- else
- {
-
- for (i = 0; i < 8; i++)
- {
- st->excEnergyHist[i] = st->excEnergyHist[i+1]; move16 ();
- }
- st->excEnergyHist[8] = excEnergy; move16 ();
- }
-
-
- fwc ();
- test ();
- if (sub_ex (pit_sharp, 16384) > 0)
- {
- for (i = 0; i < L_SUBFR; i++)
- {
- excp[i] = add_ex (excp[i], exc_enhanced[i]);
- move16 ();
- }
- agc2 (exc_enhanced, excp, L_SUBFR);
- Overflow = 0; move16 ();
- Syn_filt (Az, excp, &synth[i_subfr], L_SUBFR,
- st->mem_syn, 0);
- }
- else
- {
- Overflow = 0; move16 ();
- Syn_filt (Az, exc_enhanced, &synth[i_subfr], L_SUBFR,
- st->mem_syn, 0);
- }
- test ();
- if (Overflow != 0)
- {
- for (i = 0; i < PIT_MAX + L_INTERPOL + L_SUBFR; i++)
- {
- st->old_exc[i] = shr_ex(st->old_exc[i], 2); move16 ();
- }
- for (i = 0; i < L_SUBFR; i++)
- {
- exc_enhanced[i] = shr_ex(exc_enhanced[i], 2); move16 ();
- }
- Syn_filt(Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->mem_syn, 1);
- }
- else
- {
- Copy(&synth[i_subfr+L_SUBFR-M], st->mem_syn, M);
- }
-
-
-
- Copy (&st->old_exc[L_SUBFR], &st->old_exc[0], PIT_MAX + L_INTERPOL);
- fwc ();
-
- Az += MP1; move16 ();
-
-
- st->old_T0 = T0; move16 ();
- }
-
-
- move16 ();
- st->inBackgroundNoise = Bgn_scd(st->background_state,
- &(st->ltpGainHistory[0]),
- &(synth[0]),
- &(st->voicedHangover) );
- dtx_dec_activity_update(st->dtxDecoderState,
- st->lsfState->past_lsf_q,
- synth);
-
- fwc ();
-
- st->prev_bf = bfi; move16 ();
- st->prev_pdf = pdfi; move16 ();
-
-
-
- lsp_avg(st->lsp_avg_st, st->lsfState->past_lsf_q);
- fwc ();
- the_end:
- st->dtxDecoderState->dtxGlobalState = newDTXState; move16();
-
- return 0;
- }
|