pub struct LtcParser {
pub fps: u8,
pub default_drop_frame: bool,
}Expand description
Parses raw LTC bit streams into LtcFrame values.
§Example
use oximedia_timecode::ltc_parser::{LtcBit, LtcParser};
let parser = LtcParser::new(30, false);
// Build a minimal 80-bit all-zero LTC word (plus sync word)
let mut bits = vec![LtcBit::Zero; 64];
// Append sync word: 0011 1111 1111 1101 (LS bit first)
let sync: [u8; 16] = [0,0,1,1, 1,1,1,1, 1,1,1,1, 1,1,0,1];
bits.extend(sync.iter().map(|&b| LtcBit::from(b)));
let frames = parser.decode_bits(&bits);
assert_eq!(frames.len(), 1);Fields§
§fps: u8Nominal frames-per-second (30 for NTSC, 25 for PAL, etc.)
default_drop_frame: boolWhether drop-frame mode should be assumed when not encoded.
Implementations§
Source§impl LtcParser
impl LtcParser
Sourcepub fn new(fps: u8, default_drop_frame: bool) -> Self
pub fn new(fps: u8, default_drop_frame: bool) -> Self
Create a new parser.
fps should be 24, 25, or 30. default_drop_frame sets the drop-frame
assumption for streams that do not encode the flag.
Sourcepub fn decode_bits(&self, bits: &[LtcBit]) -> Vec<LtcFrame>
pub fn decode_bits(&self, bits: &[LtcBit]) -> Vec<LtcFrame>
Scan a slice of bits for valid LTC frames and return all decoded frames.
The function searches for the 16-bit sync word at the end of each candidate 80-bit window.
Sourcepub fn decode_frame(
&self,
bits: &[LtcBit],
offset: usize,
) -> Result<LtcFrame, TimecodeError>
pub fn decode_frame( &self, bits: &[LtcBit], offset: usize, ) -> Result<LtcFrame, TimecodeError>
Decode a single 80-bit LTC word starting at offset.
Sourcepub fn check_sync(&self, bits: &[LtcBit], offset: usize) -> bool
pub fn check_sync(&self, bits: &[LtcBit], offset: usize) -> bool
Return true if the 16 bits at offset match the LTC sync word.
Sourcepub fn encode_frame(&self, tc: &Timecode) -> Vec<LtcBit>
pub fn encode_frame(&self, tc: &Timecode) -> Vec<LtcBit>
Encode a Timecode into an 80-bit LTC word (returned as Vec<LtcBit>).
This is the inverse of decode_frame and is useful for round-trip tests.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LtcParser
impl RefUnwindSafe for LtcParser
impl Send for LtcParser
impl Sync for LtcParser
impl Unpin for LtcParser
impl UnsafeUnpin for LtcParser
impl UnwindSafe for LtcParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more