adpcm_xq_sys/
lib.rs

1use std::ffi::{c_double, c_int, c_void};
2
3// Noise shaping
4/// flat noise (no shaping)
5pub const NOISE_SHAPING_OFF: c_int = 0;
6/// static 1st-order shaping (configurable, highpass default)
7pub const NOISE_SHAPING_STATIC: c_int = 0x100;
8/// dynamically tilted noise based on signal
9pub const NOISE_SHAPING_DYNAMIC: c_int = 0x200;
10
11// Lookahead
12/// depth of search
13pub const LOOKAHEAD_DEPTH: c_int = 0x0ff;
14/// full breadth of search (all branches taken)
15pub const LOOKAHEAD_EXHAUSTIVE: c_int = 0x800;
16/// no branches taken (internal use only!)
17pub const LOOKAHEAD_NO_BRANCHING: c_int = 0x400;
18
19// Bindings to the adpcm-xq encoder
20unsafe extern "C" {
21    /* adpcm-lib.c */
22
23    pub fn adpcm_sample_count_to_block_size(sample_count: c_int, num_chans: c_int, bps: c_int) -> c_int;
24    pub fn adpcm_block_size_to_sample_count(block_size: c_int, num_chans: c_int, bps: c_int) -> c_int;
25    pub fn adpcm_align_block_size(block_size: c_int, num_chans: c_int, bps: c_int, round_up: c_int) -> c_int;
26    pub fn adpcm_create_context(num_channels: c_int, sample_rate: c_int, lookahead: c_int, noise_shaping: c_int) -> *mut c_void;
27    pub fn adpcm_set_shaping_weight(p: *mut c_void, shaping_weight: c_double);
28    pub fn adpcm_encode_block_ex(p: *mut c_void, outbuf: *mut u8, outbufsize: *mut usize, inbuf: *const i16, inbufcount: c_int, bps: c_int) -> c_int;
29    pub fn adpcm_encode_block(p: *mut c_void, outbuf: *mut u8, outbufsize: *mut usize, inbuf: *const i16, inbufcount: c_int) -> c_int;
30    pub fn adpcm_decode_block_ex(outbuf: *mut i16, inbuf: *const u8, inbufsize: usize, channels: c_int, bps: c_int) -> c_int;
31    pub fn adpcm_decode_block(outbuf: *mut i16, inbuf: *const u8, inbufsize: usize, channels: c_int) -> c_int;
32    pub fn adpcm_free_context(p: *mut c_void);
33
34    /* adpcm-dns.c */
35
36    pub fn generate_dns_values(samples: *const i16, sample_count: c_int, num_chans: c_int, sample_rate: c_int,
37        values: *mut i16, min_value: i16, last_value: i16);
38}