Debian Codegraph @

src/engine/brrUtils.h

raw
1 /* brrUtils - BRR audio codec utilities
2 * Copyright (C) 2022 tildearrow
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 #ifndef _BRR_UTILS_H
24 #define _BRR_UTILS_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31 * read len samples from buf, encode in BRR and output to out.
32 * @param buf input data.
33 * @param out output buffer. shall be at least 9*((15+len)/16) shorts in size (9 more if loopStart is not -1!)
34 * @param len input length (should be a multiple of 16. if it isn't, the output will be padded).
35 * @param loopStart beginning of loop area (may be -1 for no loop). this is used to ensure the respective block has no filter in order to loop properly.
36 * @param emphasis apply filter to compensate for Gaussian interpolation high frequency loss.
37 * @param noFilter do not use filters in any block. this is used to allow seeking to any sample position.
38 * @return number of written samples.
39 */
40 long brrEncode(short* buf, unsigned char* out, long len, long loopStart, unsigned char emphasis, unsigned char noFilter);
41
42 /**
43 * read len bytes from buf, decode BRR and output to out.
44 * @param buf input data.
45 * @param out output buffer. shall be at least 16*(len/9) shorts in size.
46 * @param len input length (shall be a multiple of 9).
47 * @param emphasis apply filter to simulate Gaussian interpolation high frequency loss.
48 * @return number of written bytes.
49 */
50 long brrDecode(unsigned char* buf, short* out, long len, unsigned char emphasis);
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif