Debian Codegraph @

src/tns.h

raw
1 /******************************************************************************
2 *
3 * Copyright 2022 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #ifndef __LC3_TNS_H
20 #define __LC3_TNS_H
21
22 #include "common.h"
23 #include "bits.h"
24
25
26 /**
27 * Bitstream data
28 */
29
30 typedef struct lc3_tns_data {
31 int nfilters;
32 bool lpc_weighting;
33 int rc_order[2];
34 int rc[2][8];
35 } lc3_tns_data_t;
36
37
38 /* ----------------------------------------------------------------------------
39 * Encoding
40 * -------------------------------------------------------------------------- */
41
42 /**
43 * TNS analysis
44 * dt, bw Duration and bandwidth of the frame
45 * nn_flag True when high energy detected near Nyquist frequency
46 * nbytes Size in bytes of the frame
47 * data Return bitstream data
48 * x Spectral coefficients, filtered as output
49 */
50 void lc3_tns_analyze(enum lc3_dt dt, enum lc3_bandwidth bw,
51 bool nn_flag, int nbytes, lc3_tns_data_t *data, float *x);
52
53 /**
54 * Return number of bits coding the data
55 * data Bitstream data
56 * return Bit consumption
57 */
58 int lc3_tns_get_nbits(const lc3_tns_data_t *data);
59
60 /**
61 * Put bitstream data
62 * bits Bitstream context
63 * data Bitstream data
64 */
65 void lc3_tns_put_data(lc3_bits_t *bits, const lc3_tns_data_t *data);
66
67
68 /* ----------------------------------------------------------------------------
69 * Decoding
70 * -------------------------------------------------------------------------- */
71
72 /**
73 * Get bitstream data
74 * bits Bitstream context
75 * dt, bw Duration and bandwidth of the frame
76 * nbytes Size in bytes of the frame
77 * data Bitstream data
78 * return 0: Ok -1: Invalid bitstream data
79 */
80 int lc3_tns_get_data(lc3_bits_t *bits,
81 enum lc3_dt dt, enum lc3_bandwidth bw, int nbytes, lc3_tns_data_t *data);
82
83 /**
84 * TNS synthesis
85 * dt, bw Duration and bandwidth of the frame
86 * data Bitstream data
87 * x Spectral coefficients, filtered as output
88 */
89 void lc3_tns_synthesize(enum lc3_dt dt, enum lc3_bandwidth bw,
90 const lc3_tns_data_t *data, float *x);
91
92
93 #endif /* __LC3_TNS_H */