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 "stat_enc.h"
10 : //#include "prot_fx.h"
11 : #include "rom_com.h" /* Common constants */
12 : #include "prot_fx.h" /* Function prototypes */
13 : #include "prot_fx_enc.h" /* Function prototypes */
14 : #include "basop_util.h" /* Function prototypes */
15 :
16 : #define NBITS_GACELP 5
17 :
18 : // extern const Word16 lsf_init_fx[16];
19 :
20 : /*-------------------------------------------------------------------*
21 : * init_PLC_enc_fx()
22 : *
23 : *
24 : *-------------------------------------------------------------------*/
25 :
26 91 : void init_PLC_enc_fx(
27 : PLC_ENC_EVS_HANDLE hPlcExt,
28 : Word32 sampleRate /* core coder SR */
29 : )
30 : {
31 : Word16 itr;
32 :
33 :
34 91 : hPlcExt->enableGplc = 0;
35 91 : move16();
36 91 : hPlcExt->calcOnlylsf = 1;
37 91 : move16();
38 91 : hPlcExt->nBits = NBITS_GACELP;
39 91 : move16();
40 :
41 91 : hPlcExt->Q_exp = 0;
42 91 : move16();
43 91 : hPlcExt->Q_new = 0;
44 91 : move16();
45 :
46 91 : set16_fx( hPlcExt->mem_MA_14Q1, 0, M );
47 91 : set16_fx( hPlcExt->mem_AR, 0, M );
48 91 : set16_fx( hPlcExt->lsfold_14Q1, 0, M );
49 91 : set16_fx( hPlcExt->lspold_Q15, 0, M );
50 :
51 91 : set16_fx( hPlcExt->old_exc_Qold, 0, 8 );
52 :
53 91 : set16_fx( hPlcExt->lsfoldbfi0_14Q1, 0, M );
54 91 : set16_fx( hPlcExt->lsfoldbfi1_14Q1, 0, M );
55 91 : set16_fx( hPlcExt->lsf_adaptive_mean_14Q1, 0, M );
56 91 : hPlcExt->stab_fac_Q15 = 0;
57 91 : move16();
58 91 : IF( EQ_32( sampleRate, INT_FS_12k8 ) )
59 : {
60 24 : hPlcExt->T0_4th = L_SUBFR;
61 24 : move16();
62 24 : hPlcExt->T0 = L_SUBFR;
63 24 : move16();
64 408 : FOR( itr = 0; itr < M; itr++ )
65 : {
66 384 : hPlcExt->lsf_con[itr] = lsf_init_fx[itr];
67 384 : move16();
68 384 : hPlcExt->last_lsf_ref[itr] = lsf_init_fx[itr];
69 384 : move16();
70 384 : hPlcExt->last_lsf_con[itr] = lsf_init_fx[itr];
71 384 : move16();
72 : }
73 : }
74 : ELSE
75 : {
76 67 : hPlcExt->T0_4th = L_SUBFR;
77 67 : move16();
78 67 : hPlcExt->T0 = L_SUBFR;
79 67 : move16();
80 1139 : FOR( itr = 0; itr < M; itr++ )
81 : {
82 1072 : hPlcExt->lsf_con[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
83 1072 : hPlcExt->last_lsf_ref[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
84 1072 : hPlcExt->last_lsf_con[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
85 1072 : move16();
86 1072 : move16();
87 1072 : move16();
88 : }
89 : }
90 :
91 91 : return;
92 : }
93 :
94 : /*-------------------------------------------------------------------*
95 : * gPLC_encInfo_fx()
96 : *
97 : * Function to extract and write guided information
98 : *-------------------------------------------------------------------*/
99 1246 : void gPLC_encInfo_fx(
100 : PLC_ENC_EVS_HANDLE hPlcExt,
101 : const Word32 total_brate,
102 : const Word16 bwidth,
103 : const Word16 last_clas,
104 : const Word16 coder_type )
105 : {
106 :
107 :
108 1246 : IF( hPlcExt )
109 : {
110 1246 : hPlcExt->calcOnlylsf = 1;
111 1246 : move16();
112 1246 : test();
113 1246 : IF( ( GE_16( bwidth, WB ) && EQ_32( total_brate, ACELP_24k40 ) ) )
114 : {
115 984 : hPlcExt->enableGplc = 1;
116 984 : move16();
117 984 : hPlcExt->nBits = 1;
118 984 : move16();
119 984 : test();
120 984 : test();
121 984 : test();
122 984 : IF( ( EQ_16( last_clas, VOICED_CLAS ) || EQ_16( last_clas, ONSET ) ) &&
123 : ( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) ) )
124 : {
125 437 : hPlcExt->nBits = NBITS_GACELP;
126 437 : move16();
127 437 : hPlcExt->calcOnlylsf = 0;
128 437 : move16();
129 : }
130 : }
131 : ELSE
132 : {
133 262 : hPlcExt->enableGplc = 0;
134 262 : move16();
135 262 : hPlcExt->nBits = NBITS_GACELP;
136 262 : move16();
137 : }
138 : }
139 1246 : }
|