From c6e9b1405e47713b2a4c4deaa088210bf9f74ed3 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Mon, 6 May 2024 10:26:39 +0100 Subject: [PATCH] Use dfa decoding for cir decode irp Signed-off-by: Sean Young --- src/bin/commands/decode.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/bin/commands/decode.rs b/src/bin/commands/decode.rs index d3fcb76..5e4e3d9 100644 --- a/src/bin/commands/decode.rs +++ b/src/bin/commands/decode.rs @@ -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); @@ -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!(