FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/dec_amr.c @ 544:bd32bb1e8dab
doc/EFR-library-API: document malloc-alternative provision
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 03 Oct 2024 08:22:41 +0000 |
parents | 7bef001cd8b8 |
children |
rev | line source |
---|---|
426
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /************************************************************************* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * R99 Version 3.3.0 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * REL-4 Version 4.1.0 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * File : dec_amr.c |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * Purpose : Decoding of one speech frame using given codec mode |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 /* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * MODULE INCLUDE FILE AND VERSION ID |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "namespace.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "dec_amr.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "typedef.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "basic_op.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "no_count.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include "cnst.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 #include "memops.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "syn_filt.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "d_plsf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "agc.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "int_lpc.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "dec_gain.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "dec_lag3.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "dec_lag6.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include "d2_9pf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #include "d2_11pf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 #include "d3_14pf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 #include "d4_17pf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #include "d8_31pf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 #include "d1035pf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 #include "pred_lt.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 #include "d_gain_p.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 #include "d_gain_c.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 #include "dec_gain.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 #include "ec_gains.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #include "ph_disp.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 #include "c_g_aver.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #include "int_lsf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 #include "lsp_lsf.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 #include "lsp_avg.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 #include "bgnscd.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #include "ex_ctrl.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 #include "sqrt_l.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 #include "lsp_tab.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 #include "bitno.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 #include "b_cn_cod.h" |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 /* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * LOCAL VARIABLES AND TABLES |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 /*-----------------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 * Decoder constant parameters (defined in "cnst.h") * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 *-----------------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 * L_FRAME : Frame size. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 * L_FRAME_BY2 : Half the frame size. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 * L_SUBFR : Sub-frame size. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 * M : LPC order. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 * MP1 : LPC order+1 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 * PIT_MIN : Minimum pitch lag. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 * PIT_MIN_MR122 : Minimum pitch lag for the MR122 mode. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 * PIT_MAX : Maximum pitch lag. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 * L_INTERPOL : Length of filter for interpolation * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 * PRM_SIZE : size of vector containing analysis parameters * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 *-----------------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 /* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 * PUBLIC PROGRAM CODE |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 ***************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 /* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 ************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 * Function : Decoder_amr_reset |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 * Purpose : Resets state memory |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 ************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 void Decoder_amr_reset (Decoder_amrState *state, Flag dtx_partial_reset) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 Word16 i; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 /* Initialize static pointer */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 state->exc = state->old_exc + PIT_MAX + L_INTERPOL; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 /* Static vectors to zero */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 Set_zero (state->old_exc, PIT_MAX + L_INTERPOL); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 if (!dtx_partial_reset) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 Set_zero (state->mem_syn, M); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 /* initialize pitch sharpening */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 state->sharp = SHARPMIN; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 state->old_T0 = 40; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 /* Initialize state->lsp_old [] */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 if (!dtx_partial_reset) { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 Copy(lsp_init_data, &state->lsp_old[0], M); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 /* Initialize memories of bad frame handling */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 state->prev_bf = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 state->prev_pdf = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 state->state = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 state->T0_lagBuff = 40; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 state->inBackgroundNoise = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 state->voicedHangover = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 if (!dtx_partial_reset) { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 for (i=0;i<9;i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 state->excEnergyHist[i] = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 for (i = 0; i < 9; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 state->ltpGainHistory[i] = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 Cb_gain_average_reset(&state->Cb_gain_averState); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (!dtx_partial_reset) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 lsp_avg_reset(&state->lsp_avg_st); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 D_plsf_reset(&state->lsfState); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 ec_gain_pitch_reset(&state->ec_gain_p_st); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 ec_gain_code_reset(&state->ec_gain_c_st); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (!dtx_partial_reset) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 gc_pred_reset(&state->pred_state); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 Bgn_scd_reset(&state->background_state); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 state->nodataSeed = 21845; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 ph_disp_reset(&state->ph_disp_st); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 if (!dtx_partial_reset) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 dtx_dec_reset(&state->dtxDecoderState); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 /* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 ************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 * Function : Decoder_amr |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 * Purpose : Speech decoder routine. |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 ************************************************************************** |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 int Decoder_amr ( |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 Decoder_amrState *st, /* i/o : State variables */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 enum Mode mode, /* i : AMR mode */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 Word16 parm[], /* i : vector of synthesis parameters |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 (PRM_SIZE) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 enum RXFrameType frame_type, /* i : received frame type */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 Word16 synth[], /* o : synthesis speech (L_FRAME) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 Word16 A_t[] /* o : decoded LP filter in 4 subframes |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 (AZ_SIZE) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 /* LPC coefficients */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 Word16 *Az; /* Pointer on A_t */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 /* LSPs */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 Word16 lsp_new[M]; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 Word16 lsp_mid[M]; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 /* LSFs */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 Word16 prev_lsf[M]; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 Word16 lsf_i[M]; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 /* Algebraic codevector */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 Word16 code[L_SUBFR]; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 /* excitation */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 Word16 excp[L_SUBFR]; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 Word16 exc_enhanced[L_SUBFR]; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 /* Scalars */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 Word16 i, i_subfr; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 Word16 T0, T0_frac, index, index_mr475 = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 Word16 gain_pit, gain_code, gain_code_mix, pit_sharp, pit_flag, pitch_fac; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 Word16 t0_min, t0_max; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 Word16 delta_frc_low, delta_frc_range; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 Word16 tmp_shift; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 Word16 temp; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 Word32 L_temp; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 Word16 flag4; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 Word16 carefulFlag; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 Word16 excEnergy; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 Word16 subfrNr; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 Word16 evenSubfr = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 Word16 bfi = 0; /* bad frame indication flag */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 Word16 pdfi = 0; /* potential degraded bad frame flag */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 enum DTXStateType newDTXState; /* SPEECH , DTX, DTX_MUTE */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 /* find the new DTX state SPEECH OR DTX */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 newDTXState = rx_dtx_handler(&st->dtxDecoderState, frame_type); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 /* DTX actions */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 if (sub(newDTXState, SPEECH) != 0 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 Decoder_amr_reset (st, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 dtx_dec(&st->dtxDecoderState, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 st->mem_syn, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 &st->lsfState, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 &st->pred_state, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 &st->Cb_gain_averState, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 newDTXState, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 mode, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 parm, synth, A_t); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 /* update average lsp */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 Lsf_lsp(st->lsfState.past_lsf_q, st->lsp_old, M); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 lsp_avg(&st->lsp_avg_st, st->lsfState.past_lsf_q); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 goto the_end; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 /* SPEECH action state machine */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 if ((sub(frame_type, RX_SPEECH_BAD) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 (sub(frame_type, RX_NO_DATA) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 (sub(frame_type, RX_ONSET) == 0)) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 bfi = 1; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 if ((sub(frame_type, RX_NO_DATA) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 (sub(frame_type, RX_ONSET) == 0)) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 build_CN_param(&st->nodataSeed, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 prmno[mode], |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 bitno[mode], |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 parm); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 else if (sub(frame_type, RX_SPEECH_DEGRADED) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 pdfi = 1; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 if (bfi != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 st->state = add (st->state, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 else if (sub (st->state, 6) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 st->state = 5; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 st->state = 0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 if (sub (st->state, 6) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 st->state = 6; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 /* If this frame is the first speech frame after CNI period, */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 /* set the BFH state machine to an appropriate state depending */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 /* on whether there was DTX muting before start of speech or not */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 /* If there was DTX muting, the first speech frame is muted. */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 /* If there was no DTX muting, the first speech frame is not */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 /* muted. The BFH state machine starts from state 5, however, to */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 /* keep the audible noise resulting from a SID frame which is */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 /* erroneously interpreted as a good speech frame as small as */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 /* possible (the decoder output in this case is quickly muted) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 if (sub(st->dtxDecoderState.dtxGlobalState, DTX) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 st->state = 5; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 st->prev_bf = 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 else if (test (), sub(st->dtxDecoderState.dtxGlobalState, DTX_MUTE) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 st->state = 5; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 st->prev_bf = 1; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 /* save old LSFs for CB gain smoothing */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 Copy (st->lsfState.past_lsf_q, prev_lsf, M); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 /* decode LSF parameters and generate interpolated lpc coefficients |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 for the 4 subframes */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 if (sub (mode, MR122) != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 D_plsf_3(&st->lsfState, mode, bfi, parm, lsp_new); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 /* Advance synthesis parameters pointer */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 parm += 3; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 Int_lpc_1to3(st->lsp_old, lsp_new, A_t); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 D_plsf_5(&st->lsfState, bfi, parm, lsp_mid, lsp_new); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 /* Advance synthesis parameters pointer */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 parm += 5; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 Int_lpc_1and3(st->lsp_old, lsp_mid, lsp_new, A_t); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 /* update the LSPs for the next frame */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 for (i = 0; i < M; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 st->lsp_old[i] = lsp_new[i]; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 /*------------------------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 * Loop for every subframe in the analysis frame * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 *------------------------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 * The subframe size is L_SUBFR and the loop is repeated L_FRAME/L_SUBFR * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 * times * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 * - decode the pitch delay * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 * - decode algebraic code * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 * - decode pitch and codebook gains * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 * - find the excitation and compute synthesis speech * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 *------------------------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 /* pointer to interpolated LPC parameters */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 Az = A_t; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 evenSubfr = 0; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 subfrNr = -1; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 subfrNr = add(subfrNr, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 evenSubfr = sub(1, evenSubfr); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 /* flag for first and 3th subframe */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 pit_flag = i_subfr; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 if (sub (i_subfr, L_FRAME_BY2) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 test(); test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 if (sub(mode, MR475) != 0 && sub(mode, MR515) != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 pit_flag = 0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 /* pitch index */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 index = *parm++; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 * - decode pitch lag and find adaptive codebook vector. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 if (sub(mode, MR122) != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 /* flag4 indicates encoding with 4 bit resolution; */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 /* this is needed for mode MR475, MR515, MR59 and MR67 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 flag4 = 0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 test (); test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 if ((sub (mode, MR475) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 (sub (mode, MR515) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 (sub (mode, MR59) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 (sub (mode, MR67) == 0) ) { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 flag4 = 1; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 * - get ranges for the t0_min and t0_max * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 * - only needed in delta decoding * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 delta_frc_low = 5; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 delta_frc_range = 9; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 if ( sub(mode, MR795) == 0 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 delta_frc_low = 10; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 delta_frc_range = 19; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 t0_min = sub(st->old_T0, delta_frc_low); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 if (sub(t0_min, PIT_MIN) < 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 t0_min = PIT_MIN; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 t0_max = add(t0_min, delta_frc_range); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 if (sub(t0_max, PIT_MAX) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 t0_max = PIT_MAX; move16(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 t0_min = sub(t0_max, delta_frc_range); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 Dec_lag3 (index, t0_min, t0_max, pit_flag, st->old_T0, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 &T0, &T0_frac, flag4); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 st->T0_lagBuff = T0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 if (bfi != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 if (sub (st->old_T0, PIT_MAX) < 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 { /* Graceful pitch */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 st->old_T0 = add(st->old_T0, 1); /* degradation */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 T0 = st->old_T0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 T0_frac = 0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 test (); test (); test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 if ( st->inBackgroundNoise != 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 sub(st->voicedHangover, 4) > 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 ((sub(mode, MR475) == 0 ) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 (sub(mode, MR515) == 0 ) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 (sub(mode, MR59) == 0) ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 T0 = st->T0_lagBuff; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 Pred_lt_3or6 (st->exc, T0, T0_frac, L_SUBFR, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 Dec_lag6 (index, PIT_MIN_MR122, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 PIT_MAX, pit_flag, &T0, &T0_frac); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 if ( bfi == 0 && (pit_flag == 0 || sub (index, 61) < 0)) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 st->T0_lagBuff = T0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 T0 = st->old_T0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 T0_frac = 0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 Pred_lt_3or6 (st->exc, T0, T0_frac, L_SUBFR, 0); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 * - (MR122 only: Decode pitch gain.) * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 * - Decode innovative codebook. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 * - set pitch sharpening factor * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 if (sub (mode, MR475) == 0 || sub (mode, MR515) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 { /* MR475, MR515 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 index = *parm++; /* index of position */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 i = *parm++; /* signs */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 decode_2i40_9bits (subfrNr, i, index, code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 pit_sharp = shl (st->sharp, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 else if (sub (mode, MR59) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 { /* MR59 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 index = *parm++; /* index of position */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 i = *parm++; /* signs */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 decode_2i40_11bits (i, index, code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 pit_sharp = shl (st->sharp, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 else if (sub (mode, MR67) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 { /* MR67 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 index = *parm++; /* index of position */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 i = *parm++; /* signs */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 decode_3i40_14bits (i, index, code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 pit_sharp = shl (st->sharp, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 else if (sub (mode, MR795) <= 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 { /* MR74, MR795 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 index = *parm++; /* index of position */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 i = *parm++; /* signs */ move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 decode_4i40_17bits (i, index, code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 pit_sharp = shl (st->sharp, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 else if (sub (mode, MR102) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 { /* MR102 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 dec_8i40_31bits (parm, code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 parm += 7; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 pit_sharp = shl (st->sharp, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 { /* MR122 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 index = *parm++; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 if (bfi != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 ec_gain_pitch (&st->ec_gain_p_st, st->state, &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 gain_pit = d_gain_pitch (mode, index); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 ec_gain_pitch_update (&st->ec_gain_p_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 dec_10i40_35bits (parm, code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 parm += 10; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 /* pit_sharp = gain_pit; */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 /* if (pit_sharp > 1.0) pit_sharp = 1.0; */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 pit_sharp = shl (gain_pit, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 * - Add the pitch contribution to code[]. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 for (i = T0; i < L_SUBFR; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 temp = mult (code[i - T0], pit_sharp); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 code[i] = add (code[i], temp); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 /*------------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 * - Decode codebook gain (MR122) or both pitch * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 * gain and codebook gain (all others) * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 * - Update pitch sharpening "sharp" with quantized gain_pit * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 *------------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 if (test(), sub (mode, MR475) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 /* read and decode pitch and code gain */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 if (evenSubfr != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 index_mr475 = *parm++; move16 (); /* index of gain(s) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 if (bfi == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 Dec_gain(&st->pred_state, mode, index_mr475, code, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 evenSubfr, &gain_pit, &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 ec_gain_pitch (&st->ec_gain_p_st, st->state, &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 ec_gain_code (&st->ec_gain_c_st, &st->pred_state, st->state, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 ec_gain_pitch_update (&st->ec_gain_p_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 ec_gain_code_update (&st->ec_gain_c_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 pit_sharp = gain_pit; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 if (sub (pit_sharp, SHARPMAX) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 pit_sharp = SHARPMAX; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 else if (test(), test(), (sub (mode, MR74) <= 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 (sub (mode, MR102) == 0)) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 /* read and decode pitch and code gain */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 index = *parm++; move16 (); /* index of gain(s) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 if (bfi == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 Dec_gain(&st->pred_state, mode, index, code, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 evenSubfr, &gain_pit, &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 ec_gain_pitch (&st->ec_gain_p_st, st->state, &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 ec_gain_code (&st->ec_gain_c_st, &st->pred_state, st->state, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 ec_gain_pitch_update (&st->ec_gain_p_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 ec_gain_code_update (&st->ec_gain_c_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 pit_sharp = gain_pit; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 if (sub (pit_sharp, SHARPMAX) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 pit_sharp = SHARPMAX; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 if (sub (mode, MR102) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 if (sub (st->old_T0, add(L_SUBFR, 5)) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 pit_sharp = shr(pit_sharp, 2); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 /* read and decode pitch gain */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 index = *parm++; move16 (); /* index of gain(s) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 if (sub (mode, MR795) == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 /* decode pitch gain */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 if (bfi != 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 ec_gain_pitch (&st->ec_gain_p_st, st->state, &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 gain_pit = d_gain_pitch (mode, index); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 ec_gain_pitch_update (&st->ec_gain_p_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 &gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 /* read and decode code gain */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 index = *parm++; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 if (bfi == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 d_gain_code (&st->pred_state, mode, index, code, &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 ec_gain_code (&st->ec_gain_c_st, &st->pred_state, st->state, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 ec_gain_code_update (&st->ec_gain_c_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 pit_sharp = gain_pit; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
663 if (sub (pit_sharp, SHARPMAX) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
664 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
665 pit_sharp = SHARPMAX; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
666 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
667 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
668 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
669 { /* MR122 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
670 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
671 if (bfi == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
672 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
673 d_gain_code (&st->pred_state, mode, index, code, &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
674 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
675 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
676 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
677 ec_gain_code (&st->ec_gain_c_st, &st->pred_state, st->state, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
678 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
679 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
680 ec_gain_code_update (&st->ec_gain_c_st, bfi, st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
681 &gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
682 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
683 pit_sharp = gain_pit; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
684 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
685 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
686 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
687 /* store pitch sharpening for next subframe */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
688 /* (for modes which use the previous pitch gain for |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
689 pitch sharpening in the search phase) */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
690 /* do not update sharpening in even subframes for MR475 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
691 test(); test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
692 if (sub(mode, MR475) != 0 || evenSubfr == 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
693 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
694 st->sharp = gain_pit; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
695 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
696 if (sub (st->sharp, SHARPMAX) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
697 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
698 st->sharp = SHARPMAX; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
699 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
700 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
701 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
702 pit_sharp = shl (pit_sharp, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
703 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
704 if (sub (pit_sharp, 16384) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
705 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
706 for (i = 0; i < L_SUBFR; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
707 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
708 temp = mult (st->exc[i], pit_sharp); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
709 L_temp = L_mult (temp, gain_pit); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
710 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
711 if (sub(mode, MR122)==0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
712 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
713 L_temp = L_shr (L_temp, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
714 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
715 excp[i] = round (L_temp); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
716 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
717 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
718 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
719 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
720 * - Store list of LTP gains needed in the source * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
721 * characteristic detector (SCD) * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
722 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
723 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
724 if ( bfi == 0 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
725 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
726 for (i = 0; i < 8; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
727 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
728 st->ltpGainHistory[i] = st->ltpGainHistory[i+1]; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
729 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
730 st->ltpGainHistory[8] = gain_pit; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
731 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
732 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
733 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
734 * - Limit gain_pit if in background noise and BFI * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
735 * for MR475, MR515, MR59 * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
736 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
737 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
738 test (); test (); test (); test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
739 if ( (st->prev_bf != 0 || bfi != 0) && st->inBackgroundNoise != 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
740 ((sub(mode, MR475) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
741 (sub(mode, MR515) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
742 (sub(mode, MR59) == 0)) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
743 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
744 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
745 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
746 if ( sub (gain_pit, 12288) > 0) /* if (gain_pit > 0.75) in Q14*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
747 gain_pit = add( shr( sub(gain_pit, 12288), 1 ), 12288 ); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
748 /* gain_pit = (gain_pit-0.75)/2.0 + 0.75; */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
749 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
750 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
751 if ( sub (gain_pit, 14745) > 0) /* if (gain_pit > 0.90) in Q14*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
752 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
753 gain_pit = 14745; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
754 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
755 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
756 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
757 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
758 * Calculate CB mixed gain * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
759 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
760 Int_lsf(prev_lsf, st->lsfState.past_lsf_q, i_subfr, lsf_i); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
761 gain_code_mix = Cb_gain_average( |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
762 &st->Cb_gain_averState, mode, gain_code, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
763 lsf_i, st->lsp_avg_st.lsp_meanSave, bfi, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
764 st->prev_bf, pdfi, st->prev_pdf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
765 st->inBackgroundNoise, st->voicedHangover); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
766 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
767 /* make sure that MR74, MR795, MR122 have original code_gain*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
768 test(); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
769 if ((sub(mode, MR67) > 0) && (sub(mode, MR102) != 0) ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
770 /* MR74, MR795, MR122 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
771 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
772 gain_code_mix = gain_code; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
773 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
774 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
775 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
776 * - Find the total excitation. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
777 * - Find synthesis speech corresponding to st->exc[]. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
778 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
779 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
780 if (sub(mode, MR102) <= 0) /* MR475, MR515, MR59, MR67, MR74, MR795, MR102*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
781 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
782 pitch_fac = gain_pit; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
783 tmp_shift = 1; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
784 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
785 else /* MR122 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
786 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
787 pitch_fac = shr (gain_pit, 1); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
788 tmp_shift = 2; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
789 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
790 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
791 /* copy unscaled LTP excitation to exc_enhanced (used in phase |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
792 * dispersion below) and compute total excitation for LTP feedback |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
793 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
794 for (i = 0; i < L_SUBFR; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
795 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
796 exc_enhanced[i] = st->exc[i]; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
797 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
798 /* st->exc[i] = gain_pit*st->exc[i] + gain_code*code[i]; */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
799 L_temp = L_mult (st->exc[i], pitch_fac); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
800 /* 12.2: Q0 * Q13 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
801 /* 7.4: Q0 * Q14 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
802 L_temp = L_mac (L_temp, code[i], gain_code); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
803 /* 12.2: Q12 * Q1 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
804 /* 7.4: Q13 * Q1 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
805 L_temp = L_shl (L_temp, tmp_shift); /* Q16 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
806 st->exc[i] = round (L_temp); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
807 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
808 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
809 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
810 * - Adaptive phase dispersion * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
811 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
812 ph_disp_release(&st->ph_disp_st); /* free phase dispersion adaption */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
813 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
814 test (); test (); test (); test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
815 if ( ((sub(mode, MR475) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
816 (sub(mode, MR515) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
817 (sub(mode, MR59) == 0)) && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
818 sub(st->voicedHangover, 3) > 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
819 st->inBackgroundNoise != 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
820 bfi != 0 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
821 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
822 ph_disp_lock(&st->ph_disp_st); /* Always Use full Phase Disp. */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
823 } /* if error in bg noise */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
824 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
825 /* apply phase dispersion to innovation (if enabled) and |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
826 compute total excitation for synthesis part */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
827 ph_disp(&st->ph_disp_st, mode, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
828 exc_enhanced, gain_code_mix, gain_pit, code, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
829 pitch_fac, tmp_shift); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
830 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
831 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
832 * - The Excitation control module are active during BFI.* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
833 * - Conceal drops in signal energy if in bg noise. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
834 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
835 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
836 L_temp = 0; move32 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
837 for (i = 0; i < L_SUBFR; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
838 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
839 L_temp = L_mac (L_temp, exc_enhanced[i], exc_enhanced[i] ); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
840 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
841 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
842 L_temp = L_shr (L_temp, 1); /* excEnergy = sqrt(L_temp) in Q0 */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
843 L_temp = sqrt_l_exp(L_temp, &temp); move32 (); /* function result */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
844 L_temp = L_shr(L_temp, add( shr(temp, 1), 15)); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
845 L_temp = L_shr(L_temp, 2); /* To cope with 16-bit and */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
846 excEnergy = extract_l(L_temp); /* scaling in ex_ctrl() */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
847 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
848 test (); test (); test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
849 test (); test (); test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
850 if ( ((sub (mode, MR475) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
851 (sub (mode, MR515) == 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
852 (sub (mode, MR59) == 0)) && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
853 sub(st->voicedHangover, 5) > 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
854 st->inBackgroundNoise != 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
855 sub(st->state, 4) < 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
856 ( (pdfi != 0 && st->prev_pdf != 0) || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
857 bfi != 0 || |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
858 st->prev_bf != 0) ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
859 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
860 carefulFlag = 0; move32 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
861 test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
862 if ( pdfi != 0 && bfi == 0 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
863 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
864 carefulFlag = 1; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
865 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
866 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
867 Ex_ctrl(exc_enhanced, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
868 excEnergy, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
869 st->excEnergyHist, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
870 st->voicedHangover, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
871 st->prev_bf, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
872 carefulFlag); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
873 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
874 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
875 test (); test (); test (); test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
876 if ( st->inBackgroundNoise != 0 && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
877 ( bfi != 0 || st->prev_bf != 0 ) && |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
878 sub(st->state, 4) < 0 ) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
879 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
880 ; /* do nothing! */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
881 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
882 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
883 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
884 /* Update energy history for all modes */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
885 for (i = 0; i < 8; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
886 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
887 st->excEnergyHist[i] = st->excEnergyHist[i+1]; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
888 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
889 st->excEnergyHist[8] = excEnergy; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
890 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
891 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
892 * Excitation control module end. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
893 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
894 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
895 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
896 if (sub (pit_sharp, 16384) > 0) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
897 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
898 for (i = 0; i < L_SUBFR; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
899 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
900 excp[i] = add (excp[i], exc_enhanced[i]); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
901 move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
902 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
903 agc2 (exc_enhanced, excp, L_SUBFR); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
904 Overflow = 0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
905 Syn_filt (Az, excp, &synth[i_subfr], L_SUBFR, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
906 st->mem_syn, 0); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
907 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
908 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
909 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
910 Overflow = 0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
911 Syn_filt (Az, exc_enhanced, &synth[i_subfr], L_SUBFR, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
912 st->mem_syn, 0); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
913 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
914 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
915 test (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
916 if (Overflow != 0) /* Test for overflow */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
917 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
918 for (i = 0; i < PIT_MAX + L_INTERPOL + L_SUBFR; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
919 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
920 st->old_exc[i] = shr(st->old_exc[i], 2); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
921 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
922 for (i = 0; i < L_SUBFR; i++) |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
923 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
924 exc_enhanced[i] = shr(exc_enhanced[i], 2); move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
925 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
926 Syn_filt(Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->mem_syn, 1); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
927 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
928 else |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
929 { |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
930 Copy(&synth[i_subfr+L_SUBFR-M], st->mem_syn, M); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
931 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
932 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
933 /*--------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
934 * Update signal for next frame. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
935 * -> shift to the left by L_SUBFR st->exc[] * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
936 *--------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
937 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
938 Copy (&st->old_exc[L_SUBFR], &st->old_exc[0], PIT_MAX + L_INTERPOL); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
939 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
940 /* interpolated LPC parameters for next subframe */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
941 Az += MP1; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
942 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
943 /* store T0 for next subframe */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
944 st->old_T0 = T0; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
945 } |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
946 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
947 /*-------------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
948 * Call the Source Characteristic Detector which updates * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
949 * st->inBackgroundNoise and st->voicedHangover. * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
950 *-------------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
951 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
952 st->inBackgroundNoise = Bgn_scd(&st->background_state, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
953 &(st->ltpGainHistory[0]), |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
954 &(synth[0]), |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
955 &(st->voicedHangover) ); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
956 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
957 dtx_dec_activity_update(&st->dtxDecoderState, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
958 st->lsfState.past_lsf_q, |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
959 synth); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
960 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
961 /* store bfi for next subframe */ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
962 st->prev_bf = bfi; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
963 st->prev_pdf = pdfi; move16 (); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
964 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
965 /*--------------------------------------------------* |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
966 * Calculate the LSF averages on the eight * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
967 * previous frames * |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
968 *--------------------------------------------------*/ |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
969 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
970 lsp_avg(&st->lsp_avg_st, st->lsfState.past_lsf_q); |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
971 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
972 the_end: |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
973 st->dtxDecoderState.dtxGlobalState = newDTXState; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
974 |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
975 return 0; |
7bef001cd8b8
libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
976 } |