-
Notifications
You must be signed in to change notification settings - Fork 0
/
SKP_Silk_process_NLSFs_FIX.go
51 lines (49 loc) · 2.51 KB
/
SKP_Silk_process_NLSFs_FIX.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package silk
import (
"github.com/gotranspile/cxgo/runtime/libc"
"unsafe"
)
func SKP_Silk_process_NLSFs_FIX(psEnc *SKP_Silk_encoder_state_FIX, psEncCtrl *SKP_Silk_encoder_control_FIX, pNLSF_Q15 *int32) {
var (
doInterpolate int32
pNLSFW_Q6 [16]int32
NLSF_mu_Q15 int32
NLSF_mu_fluc_red_Q16 int32
i_sqr_Q15 int32
psNLSF_CB *SKP_Silk_NLSF_CB_struct
pNLSF0_temp_Q15 [16]int32
pNLSFW0_temp_Q6 [16]int32
i int32
)
if psEncCtrl.SCmn.Sigtype == SIG_TYPE_VOICED {
NLSF_mu_Q15 = SKP_SMLAWB(66, -8388, psEnc.Speech_activity_Q8)
NLSF_mu_fluc_red_Q16 = SKP_SMLAWB(6554, -838848, psEnc.Speech_activity_Q8)
} else {
NLSF_mu_Q15 = SKP_SMLAWB(164, -33554, psEnc.Speech_activity_Q8)
NLSF_mu_fluc_red_Q16 = SKP_SMLAWB(0x3333, -1677696, psEnc.Speech_activity_Q8+psEncCtrl.Sparseness_Q8)
}
if NLSF_mu_Q15 > 1 {
NLSF_mu_Q15 = NLSF_mu_Q15
} else {
NLSF_mu_Q15 = 1
}
SKP_Silk_NLSF_VQ_weights_laroia(&pNLSFW_Q6[0], pNLSF_Q15, psEnc.SCmn.PredictLPCOrder)
doInterpolate = libc.BoolToInt(psEnc.SCmn.UseInterpolatedNLSFs == 1 && psEncCtrl.SCmn.NLSFInterpCoef_Q2 < (1<<2))
if doInterpolate != 0 {
SKP_Silk_interpolate(pNLSF0_temp_Q15, psEnc.SPred.Prev_NLSFq_Q15, ([16]int32)(pNLSF_Q15), psEncCtrl.SCmn.NLSFInterpCoef_Q2, psEnc.SCmn.PredictLPCOrder)
SKP_Silk_NLSF_VQ_weights_laroia(&pNLSFW0_temp_Q6[0], &pNLSF0_temp_Q15[0], psEnc.SCmn.PredictLPCOrder)
i_sqr_Q15 = SKP_SMULBB(psEncCtrl.SCmn.NLSFInterpCoef_Q2, psEncCtrl.SCmn.NLSFInterpCoef_Q2) << 11
for i = 0; i < psEnc.SCmn.PredictLPCOrder; i++ {
pNLSFW_Q6[i] = SKP_SMLAWB((pNLSFW_Q6[i])>>1, pNLSFW0_temp_Q6[i], i_sqr_Q15)
}
}
psNLSF_CB = psEnc.SCmn.PsNLSF_CB[psEncCtrl.SCmn.Sigtype]
SKP_Silk_NLSF_MSVQ_encode_FIX(&psEncCtrl.SCmn.NLSFIndices[0], pNLSF_Q15, psNLSF_CB, &psEnc.SPred.Prev_NLSFq_Q15[0], &pNLSFW_Q6[0], NLSF_mu_Q15, NLSF_mu_fluc_red_Q16, psEnc.SCmn.NLSF_MSVQ_Survivors, psEnc.SCmn.PredictLPCOrder, psEnc.SCmn.First_frame_after_reset)
SKP_Silk_NLSF2A_stable(psEncCtrl.PredCoef_Q12[1], ([16]int32)(pNLSF_Q15), psEnc.SCmn.PredictLPCOrder)
if doInterpolate != 0 {
SKP_Silk_interpolate(pNLSF0_temp_Q15, psEnc.SPred.Prev_NLSFq_Q15, ([16]int32)(pNLSF_Q15), psEncCtrl.SCmn.NLSFInterpCoef_Q2, psEnc.SCmn.PredictLPCOrder)
SKP_Silk_NLSF2A_stable(psEncCtrl.PredCoef_Q12[0], pNLSF0_temp_Q15, psEnc.SCmn.PredictLPCOrder)
} else {
memcpy(unsafe.Pointer(&(psEncCtrl.PredCoef_Q12[0])[0]), unsafe.Pointer(&(psEncCtrl.PredCoef_Q12[1])[0]), size_t(uintptr(psEnc.SCmn.PredictLPCOrder)*unsafe.Sizeof(int16(0))))
}
}