Line data Source code
1 : /******************************************************************************
2 : * ETSI TS 103 634 V1.6.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 1189311 : 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, LC3PLUS_FrameDuration frame_dms, LC3_INT fs)
16 : {
17 :
18 :
19 1189311 : LC3_INT len_12k8 = 0, 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 1189311 : switch (frame_dms)
27 : {
28 : #ifdef CR9_C_ADD_1p25MS
29 0 : case LC3PLUS_FRAME_DURATION_1p25MS:
30 0 : len_12k8 = LEN_12K8 / 8;
31 0 : break;
32 : #endif
33 16 : case LC3PLUS_FRAME_DURATION_2p5MS:
34 16 : len_12k8 = LEN_12K8 / 4;
35 16 : break;
36 1139323 : case LC3PLUS_FRAME_DURATION_5MS:
37 1139323 : len_12k8 = LEN_12K8 / 2;
38 1139323 : break;
39 0 : case LC3PLUS_FRAME_DURATION_7p5MS:
40 0 : len_12k8 = (LEN_12K8 / 4) * 3;
41 0 : break;
42 49972 : case LC3PLUS_FRAME_DURATION_10MS:
43 49972 : len_12k8 = LEN_12K8;
44 49972 : break;
45 0 : case LC3PLUS_FRAME_DURATION_UNDEFINED:
46 0 : assert(0);
47 : }
48 :
49 1189311 : *y_len = len_12k8;
50 1189311 : N12k8 = x_len * 12800 / fs;
51 :
52 : /* Init Input Buffer */
53 1189311 : memmove(buf, mem_in, mem_in_len * sizeof(LC3_FLOAT));
54 1189311 : memmove(&buf[mem_in_len], x, x_len * sizeof(LC3_FLOAT));
55 1189311 : memmove(mem_in, &buf[x_len], mem_in_len * sizeof(LC3_FLOAT));
56 :
57 1189311 : filter = lp_filter[fs_idx];
58 :
59 : /* Upsampling & Low-pass Filtering & Downsampling */
60 :
61 1189311 : index_int = 1;
62 1189311 : index_frac = 0;
63 1189311 : resamp_upfac = resamp_params[fs_idx][0];
64 1189311 : resamp_delay = resamp_params[fs_idx][1];
65 1189311 : resamp_off_int = resamp_params[fs_idx][2];
66 1189311 : resamp_off_frac = resamp_params[fs_idx][3];
67 :
68 1189311 : k = 0;
69 80502911 : for (i = 0; i < N12k8; i++) {
70 :
71 79313600 : filt_input = &buf[index_int];
72 79313600 : filt_coeff = &filter[index_frac * resamp_delay * 2];
73 :
74 79313600 : mac = mac_loop(filt_input, filt_coeff, (2 * resamp_delay));
75 :
76 79313600 : bufdown[k++] = mac;
77 :
78 79313600 : index_int = index_int + resamp_off_int;
79 79313600 : index_frac = index_frac + resamp_off_frac;
80 :
81 79313600 : if ((resamp_upfac - index_frac) <= 0)
82 : {
83 59484816 : index_int = index_int + 1;
84 59484816 : index_frac = index_frac - resamp_upfac;
85 : }
86 : }
87 :
88 :
89 : /* 50Hz High-Pass */
90 1189311 : u_11 = mem_50[0];
91 1189311 : u_21 = mem_50[1];
92 :
93 80502911 : for (i = 0; i < len_12k8; i++) {
94 79313600 : LC3_FLOAT y1 = (highpass50_filt_b[0] * bufdown[i] + u_11);
95 79313600 : u_1 = (highpass50_filt_b[1] * bufdown[i] + u_21) - highpass50_filt_a[1] * y1;
96 79313600 : u_2 = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1;
97 79313600 : u_11 = u_1;
98 79313600 : u_21 = u_2;
99 79313600 : bufdown[i] = (LC3_FLOAT)y1;
100 : }
101 :
102 1189311 : mem_50[0] = (LC3_FLOAT)u_11;
103 1189311 : mem_50[1] = (LC3_FLOAT)u_21;
104 :
105 : /* Output Buffer */
106 1189311 : memmove(buf, mem_out, mem_out_len * sizeof(LC3_FLOAT));
107 :
108 1189311 : memmove(&buf[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT));
109 :
110 1189311 : memmove(y, buf, (*y_len + 1) * sizeof(LC3_FLOAT));
111 :
112 1189311 : memmove(mem_out, &buf[N12k8], mem_out_len * sizeof(LC3_FLOAT));
113 1189311 : }
|