Skip to content

Commit

Permalink
Use dfa decoding for cir decode irp
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <[email protected]>
  • Loading branch information
seanyoung committed May 6, 2024
1 parent 84aff7c commit c6e9b14
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/bin/commands/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ pub fn decode_irp(decode: &crate::Decode, irp_str: &String) {
}
};

let nfa = match irp.build_nfa() {
Ok(nfa) => nfa,
let mut options = Options {
name: "irp",
aeps: abs_tolerance,
eps: rel_tolerance,
max_gap,
..Default::default()
};

options.nfa = decode.options.save_nfa;
options.dfa = decode.options.save_dfa;
let dfa = match irp.compile(&options) {
Ok(dfa) => dfa,
Err(s) => {
eprintln!("unable to compile irp ‘{irp_str}’: {s}");
std::process::exit(2);
Expand All @@ -45,21 +55,11 @@ pub fn decode_irp(decode: &crate::Decode, irp_str: &String) {
std::process::exit(2);
}

let mut options = Options {
aeps: abs_tolerance,
eps: rel_tolerance,
max_gap,
..Default::default()
};

options.nfa = decode.options.save_nfa;
options.dfa = decode.options.save_dfa;

let mut decoder = Decoder::new(options);

let mut feed_decoder = |raw: &[InfraredData]| {
for ir in raw {
decoder.nfa_input(*ir, &nfa, |event, var| {
decoder.dfa_input(*ir, &dfa, |event, var| {
let mut var: Vec<(String, i64)> = var.into_iter().collect();
var.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
println!(
Expand Down

0 comments on commit c6e9b14

Please sign in to comment.