MCPcopy Create free account
hub / github.com/FutureSDR/FutureSDR / decode_bit

Method decode_bit

examples/m17/src/decoder.rs:45–82  ·  view source on GitHub ↗
(&mut self, s0: u16, s1: u16, pos: usize)

Source from the content-addressed store, hash-verified

43 }
44
45 fn decode_bit(&mut self, s0: u16, s1: u16, pos: usize) {
46 for i in 0..Self::NUM_STATES / 2 {
47 let metric = Self::q_abs_diff(Self::COST_TABLE_0[i], s0) as u32
48 + Self::q_abs_diff(Self::COST_TABLE_1[i], s1) as u32;
49
50 let m0 = self.prev_metrics[i] + metric;
51 let m1 = self.prev_metrics[i + Self::NUM_STATES / 2] + (0x1FFFE - metric);
52 let m2 = self.prev_metrics[i] + (0x1FFFE - metric);
53 let m3 = self.prev_metrics[i + Self::NUM_STATES / 2] + metric;
54
55 let i0 = 2 * i;
56 let i1 = i0 + 1;
57
58 if m0 >= m1 {
59 self.history[pos] |= 1 << i0;
60 self.curr_metrics[i0] = m1;
61 } else {
62 self.history[pos] &= !(1 << i0);
63 self.curr_metrics[i0] = m0;
64 }
65
66 if m2 >= m3 {
67 self.history[pos] |= 1 << i1;
68 self.curr_metrics[i1] = m3;
69 } else {
70 self.history[pos] &= !(1 << i1);
71 self.curr_metrics[i1] = m2;
72 }
73 }
74
75 //swap
76 let tmp = self.curr_metrics;
77
78 for i in 0..Self::NUM_STATES {
79 self.curr_metrics[i] = self.prev_metrics[i];
80 self.prev_metrics[i] = tmp[i];
81 }
82 }
83
84 fn chainback(&mut self, out: &mut [u8], mut pos: usize, len: usize) -> usize {
85 let mut state = 0;

Callers 1

decodeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected