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 83 : 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 83 : hPlcExt->enableGplc = 0;
35 83 : move16();
36 83 : hPlcExt->calcOnlylsf = 1;
37 83 : move16();
38 83 : hPlcExt->nBits = NBITS_GACELP;
39 83 : move16();
40 :
41 83 : hPlcExt->Q_exp = 0;
42 83 : move16();
43 83 : hPlcExt->Q_new = 0;
44 83 : move16();
45 :
46 83 : set16_fx( hPlcExt->mem_MA_14Q1, 0, M );
47 83 : set16_fx( hPlcExt->mem_AR, 0, M );
48 83 : set16_fx( hPlcExt->lsfold_14Q1, 0, M );
49 83 : set16_fx( hPlcExt->lspold_Q15, 0, M );
50 :
51 83 : set16_fx( hPlcExt->old_exc_Qold, 0, 8 );
52 :
53 83 : set16_fx( hPlcExt->lsfoldbfi0_14Q1, 0, M );
54 83 : set16_fx( hPlcExt->lsfoldbfi1_14Q1, 0, M );
55 83 : set16_fx( hPlcExt->lsf_adaptive_mean_14Q1, 0, M );
56 83 : hPlcExt->stab_fac_Q15 = 0;
57 83 : move16();
58 83 : IF( EQ_32( sampleRate, INT_FS_12k8 ) )
59 : {
60 20 : hPlcExt->T0_4th = L_SUBFR;
61 20 : move16();
62 20 : hPlcExt->T0 = L_SUBFR;
63 20 : move16();
64 340 : FOR( itr = 0; itr < M; itr++ )
65 : {
66 320 : hPlcExt->lsf_con[itr] = lsf_init_fx[itr];
67 320 : move16();
68 320 : hPlcExt->last_lsf_ref[itr] = lsf_init_fx[itr];
69 320 : move16();
70 320 : hPlcExt->last_lsf_con[itr] = lsf_init_fx[itr];
71 320 : move16();
72 : }
73 : }
74 : ELSE
75 : {
76 63 : hPlcExt->T0_4th = L_SUBFR;
77 63 : move16();
78 63 : hPlcExt->T0 = L_SUBFR;
79 63 : move16();
80 1071 : FOR( itr = 0; itr < M; itr++ )
81 : {
82 1008 : hPlcExt->lsf_con[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
83 1008 : hPlcExt->last_lsf_ref[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
84 1008 : hPlcExt->last_lsf_con[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
85 1008 : move16();
86 1008 : move16();
87 1008 : move16();
88 : }
89 : }
90 :
91 83 : return;
92 : }
93 :
94 : /*-------------------------------------------------------------------*
95 : * gPLC_encInfo_fx()
96 : *
97 : * Function to extract and write guided information
98 : *-------------------------------------------------------------------*/
99 1249 : 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 1249 : IF( hPlcExt )
109 : {
110 1249 : hPlcExt->calcOnlylsf = 1;
111 1249 : move16();
112 1249 : test();
113 1249 : IF( ( GE_16( bwidth, WB ) && EQ_32( total_brate, ACELP_24k40 ) ) )
114 : {
115 988 : hPlcExt->enableGplc = 1;
116 988 : move16();
117 988 : hPlcExt->nBits = 1;
118 988 : move16();
119 988 : test();
120 988 : test();
121 988 : test();
122 988 : 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 439 : hPlcExt->nBits = NBITS_GACELP;
126 439 : move16();
127 439 : hPlcExt->calcOnlylsf = 0;
128 439 : move16();
129 : }
130 : }
131 : ELSE
132 : {
133 261 : hPlcExt->enableGplc = 0;
134 261 : move16();
135 261 : hPlcExt->nBits = NBITS_GACELP;
136 261 : move16();
137 : }
138 : }
139 1249 : }
|