Line data Source code
1 : /*====================================================================================
2 : EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
3 : ====================================================================================*/
4 :
5 :
6 : #include <stdint.h>
7 : #include "options.h"
8 : #include "cnst.h"
9 : #include "prot_fx.h"
10 : #include "prot_fx_enc.h" /* Function prototypes */
11 :
12 :
13 : /*
14 : * find_wsp_fx
15 : *
16 : * Parameters:
17 : * Az I: A(z) filter coefficients Q12
18 : * speech I: pointer to the denoised speech frame Q_new - preemph_bits
19 : * wsp O: pointer to the weighted speech frame Q_new - preemph_bits
20 : * mem_wsp I/O: W(z) denominator memory
21 : * preemph_fac I: pre-emphasis factor Q15
22 : * L_frame I: length of the frame
23 : * lookahead I: length of a look-ahead
24 : * L_subfr I: length of the sub-frame
25 : *
26 : * Function:
27 : * Find weighted speech (formula from AMR-WB)
28 : *
29 : * Returns:
30 : * void
31 : */
32 4150 : void find_wsp_fx(
33 : const Word16 Az[], /* i : A(z) filter coefficients Q12*/
34 : const Word16 speech[], /* i : pointer to the denoised speech frame Q_new-preemph_bits*/
35 : Word16 wsp[], /* o : poitnter to the weighted speech frame Q_new-preemph_bits*/
36 : Word16 *mem_wsp, /* i/o: W(Z) denominator memory Q_new-preemph_bits*/
37 : const Word16 preemph_fac, /* i : pre - emphasis factor Q15*/
38 : const Word16 L_frame, /* i : length of the frame Q0*/
39 : const Word16 lookahead, /* i : look-ahead Q0*/
40 : const Word16 L_subfr, /* i : length of subframe Q0*/
41 : Word16 *Aw, /* o : weighted A(z) filter coefficients Q12*/
42 : const Word16 gamma, /* i : weighting factor Q15*/
43 : const Word16 nb_subfr /* i : number of subframes Q0*/
44 : )
45 : {
46 : Word16 i_subfr, wtmp;
47 : const Word16 *p_Az;
48 : /*-----------------------------------------------------------------*
49 : * Compute weighted A(z) unquantized for subframes
50 : *-----------------------------------------------------------------*/
51 :
52 4150 : weight_a_subfr_fx( nb_subfr, Az, Aw, gamma, M );
53 :
54 :
55 : /*----------------------------------------------------------------*
56 : * Compute weighted speech for all subframes
57 : *----------------------------------------------------------------*/
58 : BASOP_SATURATE_WARNING_OFF_EVS
59 4150 : p_Az = Aw; /*move16();*/
60 21800 : FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr )
61 : {
62 17650 : Residu3_fx( p_Az, &speech[i_subfr], &wsp[i_subfr], L_subfr, 0 );
63 17650 : p_Az += ( M + 1 );
64 : }
65 4150 : p_Az -= ( M + 1 );
66 : BASOP_SATURATE_WARNING_ON_EVS
67 : /*----------------------------------------------------------------*
68 : * Weighted speech computation is extended on look-ahead
69 : *----------------------------------------------------------------*/
70 4150 : deemph_fx( wsp, preemph_fac, L_frame, mem_wsp ); /* use Deemph2 to prevent saturation */
71 :
72 4150 : IF( lookahead != 0 )
73 : {
74 4150 : Residu3_fx( p_Az, &speech[L_frame], &wsp[L_frame], lookahead, 0 );
75 4150 : wtmp = *mem_wsp;
76 4150 : move16();
77 4150 : deemph_fx( &wsp[L_frame], preemph_fac, lookahead, &wtmp );
78 : }
79 4150 : }
80 :
81 : /*-------------------------------------------------------------------*
82 : * ivas_find_wsp_fx()
83 : *
84 : * Compute weighted speech used in open-loop pitch search
85 : *-------------------------------------------------------------------*/
86 1292496 : void ivas_find_wsp_fx(
87 : const Word16 L_frame, /* i : length of the frame Q0*/
88 : const Word16 L_subfr, /* i : length of subframe Q0*/
89 : const Word16 nb_subfr, /* i : number of subframes Q0*/
90 : const Word16 *A_fx,
91 : /* i : A(z) filter coefficients */ // Q12
92 : Word16 *Aw_fx,
93 : /* o : weighted A(z) filter coefficients */ // Q12
94 : const Word16 *speech_fx,
95 : /* i : pointer to the denoised speech frame */ // Q_new
96 : const Word16 tilt_fact,
97 : /* i : tilt factor */ // Q15
98 : Word16 *wsp_fx,
99 : /* o : poitnter to the weighted speech frame */ // Q_new
100 : Word16 *mem_wsp_fx,
101 : /* i/o: W(Z) denominator memory */ // Q_new
102 : const Word16 gamma,
103 : /* i : weighting factor */ // Q15
104 : const Word16 L_look /* i : look-ahead Q0*/
105 : )
106 : {
107 : Word16 *p_Aw_fx, tmp_fx;
108 : Word16 i_subfr;
109 :
110 :
111 : /*-----------------------------------------------------------------*
112 : * Compute weighted A(z) unquantized for subframes
113 : *-----------------------------------------------------------------*/
114 1292496 : weight_a_subfr_fx( nb_subfr, A_fx, Aw_fx, gamma, M );
115 :
116 : /*-----------------------------------------------------------------*
117 : * Compute weighted speech for all subframes
118 : *-----------------------------------------------------------------*/
119 1292496 : p_Aw_fx = Aw_fx;
120 6625976 : FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr )
121 : {
122 5333480 : Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 );
123 5333480 : p_Aw_fx += ( M + 1 );
124 : }
125 1292496 : p_Aw_fx -= ( M + 1 );
126 :
127 : /*-----------------------------------------------------------------*
128 : * Weighted speech computation is extended on look-ahead
129 : *-----------------------------------------------------------------*/
130 :
131 1292496 : deemph_fx( wsp_fx, tilt_fact, L_frame, mem_wsp_fx );
132 1292496 : Residu3_fx( p_Aw_fx, &speech_fx[L_frame], &wsp_fx[L_frame], L_look, 0 );
133 1292496 : tmp_fx = *mem_wsp_fx;
134 1292496 : deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx );
135 1292496 : return;
136 : }
|