decode_cea608/
decode_cea608.rs1use broadcast_common::parity::set_odd_parity;
6use cc_data::decode::{Cea608Channel, Cea608Decoder};
7
8fn main() {
9 let mut dec = Cea608Decoder::new();
10
11 let pairs: &[(u8, u8)] = &[
17 (0x14, 0x20),
18 (0x14, 0x70),
19 (b'H', b'E'),
20 (b'L', b'L'),
21 (b'O', 0x00),
22 (0x14, 0x2F),
23 ];
24 for &(b1, b2) in pairs {
25 dec.push_pair(false, set_odd_parity(b1), set_odd_parity(b2));
26 }
27
28 println!("CC1 mode : {}", dec.mode(Cea608Channel::Cc1));
29 println!("CC1 text : {:?}", dec.channel_text(Cea608Channel::Cc1));
30
31 let mut dec2 = Cea608Decoder::new();
33 let roll: &[(u8, u8)] = &[
34 (0x14, 0x25), (b'O', b'N'),
36 (b'E', 0x00),
37 (0x14, 0x2D), (b'T', b'W'),
39 (b'O', 0x00),
40 ];
41 for &(b1, b2) in roll {
42 dec2.push_pair(false, set_odd_parity(b1), set_odd_parity(b2));
43 }
44 println!("\nRoll-up mode : {}", dec2.mode(Cea608Channel::Cc1));
45 println!("Roll-up text :\n{}", dec2.channel_text(Cea608Channel::Cc1));
46}