#![warn(missing_docs)]
pub mod decoder;
pub mod error;
pub mod image;
pub mod mode_pd;
pub mod modespec;
pub mod resample;
#[allow(dead_code)]
pub(crate) mod snr;
pub(crate) mod sync;
pub mod vis;
#[allow(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::cast_precision_loss
)]
#[inline]
pub(crate) fn get_bin(hz: f64, fft_len: usize, sample_rate_hz: u32) -> usize {
(hz * fft_len as f64 / f64::from(sample_rate_hz)) as usize
}
#[cfg(test)]
mod tests_common {
use super::*;
#[test]
fn get_bin_matches_slowrx_truncation() {
let cases: &[(f64, usize)] = &[
(400.0, 9),
(800.0, 18),
(1190.0, 27),
(1200.0, 27),
(1500.0, 34),
(1900.0, 44),
(2300.0, 53),
(2700.0, 62),
(3400.0, 78),
];
for &(hz, expected) in cases {
let bin_ours = get_bin(hz, 256, 11025);
let bin_slowrx = get_bin(hz, 1024, 44100);
assert_eq!(
bin_ours, expected,
"get_bin({hz}, 256, 11025) = {bin_ours}, expected {expected}"
);
assert_eq!(
bin_slowrx, expected,
"get_bin({hz}, 1024, 44100) = {bin_slowrx}, expected {expected}"
);
}
}
}
#[cfg(any(test, feature = "test-support"))]
#[doc(hidden)]
pub mod pd_test_encoder;
pub use crate::decoder::{SstvDecoder, SstvEvent};
pub use crate::error::{Error, Result};
pub use crate::image::SstvImage;
pub use crate::modespec::{
for_mode, lookup as lookup_vis, ChannelLayout, ModeSpec, SstvMode, SyncPosition,
};
pub use crate::resample::{Resampler, WORKING_SAMPLE_RATE_HZ};
#[cfg(any(test, feature = "test-support"))]
#[doc(hidden)]
pub mod __test_support {
pub mod vis {
pub use crate::vis::tests::synth_vis;
}
pub mod mode_pd {
pub use crate::mode_pd::ycbcr_to_rgb;
pub use crate::pd_test_encoder::encode_pd;
}
}