aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Picht <julian.picht@gmail.com>2016-12-27 00:20:25 +0100
committerJulian Picht <julian.picht@gmail.com>2016-12-27 01:11:10 +0100
commit5a1236b603b6882be2ae3af11936d135bf31b7bd (patch)
tree667b11c9d91836aac5aed359e8df0bdd4c2ed83b /src
parent37e6524203b7a974bddede2f2631015d74ea31b1 (diff)
downloadlibsurvive-5a1236b603b6882be2ae3af11936d135bf31b7bd.tar.gz
libsurvive-5a1236b603b6882be2ae3af11936d135bf31b7bd.tar.bz2
disambiguator_discard: adaptive discard
Diffstat (limited to 'src')
-rw-r--r--src/disambiguator.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/disambiguator.c b/src/disambiguator.c
index 645b15e..164724e 100644
--- a/src/disambiguator.c
+++ b/src/disambiguator.c
@@ -58,15 +58,21 @@ void disambiguator_init( struct disambiguator * d ) {
d->max_confidence = 0;
}
-inline void disambiguator_discard( struct disambiguator * d, uint32_t age );
+inline void disambiguator_discard( struct disambiguator * d );
/**
* Drop all data that is outdated
* @param d
* @param age Maximum age of data we care to keep
*/
-void disambiguator_discard( struct disambiguator * d, uint32_t age )
+void disambiguator_discard( struct disambiguator * d )
{
+ long age;
+ if (d->state == D_STATE_LOCKED) {
+ age = d->last - 400000;
+ } else {
+ age = 1000000;
+ }
int confidence = 0;
for (unsigned int i = 0; i < DIS_NUM_VALUES; ++i) {
if (d->times[i] != 0 && d->times[i] < age) {
@@ -133,7 +139,7 @@ pulse_type disambiguator_step( struct disambiguator * d, uint32_t time, int leng
}
// discard all data, that is so old, we don't care about it anymore
- disambiguator_discard(d, time - 10000000);
+ disambiguator_discard(d);
// find the best match for our timestamp and presumed offset
int idx = disambiguator_find_nearest(d, time - 400000, time - 20000, 100);