Line data Source code
1 : /******************************************************************************
2 : * ETSI TS 103 634 V1.5.1 *
3 : * Low Complexity Communication Codec Plus (LC3plus) *
4 : * *
5 : * Copyright licence is solely granted through ETSI Intellectual Property *
6 : * Rights Policy, 3rd April 2019. No patent licence is granted by implication, *
7 : * estoppel or otherwise. *
8 : ******************************************************************************/
9 :
10 : #include "options.h"
11 : #include "wmc_auto.h"
12 : #include "functions.h"
13 :
14 0 : void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[],
15 : LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs)
16 : {
17 :
18 :
19 : LC3_INT len_12k8, N12k8, i, k;
20 : LC3_FLOAT mac, bufdown[128], buf[120 + MAX_LEN];
21 : LC3_INT32 index_int, index_frac, resamp_upfac, resamp_delay, resamp_off_int, resamp_off_frac;
22 : LC3_FLOAT u_11, u_21, u_1, u_2;
23 : const LC3_FLOAT *filter;
24 : const LC3_FLOAT *filt_input, *filt_coeff;
25 :
26 0 : switch (frame_dms)
27 : {
28 0 : case 25:
29 0 : len_12k8 = LEN_12K8 / 4;
30 0 : break;
31 0 : case 50:
32 0 : len_12k8 = LEN_12K8 / 2;
33 0 : break;
34 0 : case 75:
35 0 : len_12k8 = (LEN_12K8 / 4) * 3;
36 0 : break;
37 0 : case 100:
38 0 : len_12k8 = LEN_12K8;
39 0 : break;
40 : }
41 :
42 0 : *y_len = len_12k8;
43 0 : N12k8 = x_len * 12800 / fs;
44 :
45 : /* Init Input Buffer */
46 0 : memmove(buf, mem_in, mem_in_len * sizeof(LC3_FLOAT));
47 0 : memmove(&buf[mem_in_len], x, x_len * sizeof(LC3_FLOAT));
48 0 : memmove(mem_in, &buf[x_len], mem_in_len * sizeof(LC3_FLOAT));
49 :
50 0 : filter = lp_filter[fs_idx];
51 :
52 : /* Upsampling & Low-pass Filtering & Downsampling */
53 :
54 0 : index_int = 1;
55 0 : index_frac = 0;
56 0 : resamp_upfac = resamp_params[fs_idx][0];
57 0 : resamp_delay = resamp_params[fs_idx][1];
58 0 : resamp_off_int = resamp_params[fs_idx][2];
59 0 : resamp_off_frac = resamp_params[fs_idx][3];
60 :
61 0 : k = 0;
62 0 : for (i = 0; i < N12k8; i++) {
63 :
64 0 : filt_input = &buf[index_int];
65 0 : filt_coeff = &filter[index_frac * resamp_delay * 2];
66 :
67 0 : mac = mac_loop(filt_input, filt_coeff, (2 * resamp_delay));
68 :
69 0 : bufdown[k++] = mac;
70 :
71 0 : index_int = index_int + resamp_off_int;
72 0 : index_frac = index_frac + resamp_off_frac;
73 :
74 0 : if ((resamp_upfac - index_frac) <= 0)
75 : {
76 0 : index_int = index_int + 1;
77 0 : index_frac = index_frac - resamp_upfac;
78 : }
79 : }
80 :
81 :
82 : /* 50Hz High-Pass */
83 0 : u_11 = mem_50[0];
84 0 : u_21 = mem_50[1];
85 :
86 0 : for (i = 0; i < len_12k8; i++) {
87 0 : LC3_FLOAT y1 = (highpass50_filt_b[0] * bufdown[i] + u_11);
88 0 : u_1 = (highpass50_filt_b[1] * bufdown[i] + u_21) - highpass50_filt_a[1] * y1;
89 0 : u_2 = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1;
90 0 : u_11 = u_1;
91 0 : u_21 = u_2;
92 0 : bufdown[i] = (LC3_FLOAT)y1;
93 : }
94 :
95 0 : mem_50[0] = (LC3_FLOAT)u_11;
96 0 : mem_50[1] = (LC3_FLOAT)u_21;
97 :
98 : /* Output Buffer */
99 0 : memmove(buf, mem_out, mem_out_len * sizeof(LC3_FLOAT));
100 :
101 0 : memmove(&buf[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT));
102 :
103 0 : memmove(y, buf, (*y_len + 1) * sizeof(LC3_FLOAT));
104 :
105 0 : memmove(mem_out, &buf[N12k8], mem_out_len * sizeof(LC3_FLOAT));
106 0 : }
|