From eb5907ab3b8805d4c9990cba45ac4b46f6e5cdb8 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 2 Apr 2016 07:28:03 -0500 Subject: Remove linear pressure interpolation detection code Dirk says that divinglog hasn't been doing the linear pressure interpolation for a long while, so we're doing extra dive fixups that really aren't needed any more. Also, the code is actually buggy: it only ever worked on the first cylinder anyway (because only the first cylinder pressure_delta[] would be initialized). That was probably perfectly fine in practice, since it's unlikely that many tech divers used old versions of divinglog anyway, so the bug per se isn't a reason to remove it - but it is a sign that the code was a bit hard to read, so let's get rid of it if there is no reason to maintain it or fix it. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- core/dive.c | 52 ++-------------------------------------------------- 1 file changed, 2 insertions(+), 50 deletions(-) (limited to 'core') diff --git a/core/dive.c b/core/dive.c index ce730da28..64cf48a58 100644 --- a/core/dive.c +++ b/core/dive.c @@ -1306,17 +1306,12 @@ static void fixup_dc_cylinder_index(struct dive *dive, struct divecomputer *dc) } } -/* - * Simplify dc pressure information: - * (a) Remove redundant pressure information - * (b) Remove linearly interpolated pressure data - */ +/* Remove redundant pressure information */ static void simplify_dc_pressures(struct dive *dive, struct divecomputer *dc) { - int i, j; + int i; int lastindex = -1; int lastpressure = 0, lasto2pressure = 0; - int pressure_delta[MAX_CYLINDERS] = { INT_MAX, }; for (i = 0; i < dc->samples; i++) { struct sample *sample = dc->sample + i; @@ -1325,60 +1320,17 @@ static void simplify_dc_pressures(struct dive *dive, struct divecomputer *dc) int index; index = sample->sensor; - if (index == lastindex) { /* Remove duplicate redundant pressure information */ if (pressure == lastpressure) sample->cylinderpressure.mbar = 0; if (o2_pressure == lasto2pressure) sample->o2cylinderpressure.mbar = 0; - /* check for simply linear data in the samples - +INT_MAX means uninitialized, -INT_MAX means not linear */ - if (pressure_delta[index] != -INT_MAX && lastpressure) { - if (pressure_delta[index] == INT_MAX) { - pressure_delta[index] = abs(pressure - lastpressure); - } else { - int cur_delta = abs(pressure - lastpressure); - if (cur_delta && abs(cur_delta - pressure_delta[index]) > 150) { - /* ok the samples aren't just a linearisation - * between start and end */ - pressure_delta[index] = -INT_MAX; - } - } - } } lastindex = index; lastpressure = pressure; lasto2pressure = o2_pressure; } - - /* if all the samples for a cylinder have pressure data that - * is basically equidistant throw out the sample cylinder pressure - * information but make sure we still have a valid start and end - * pressure - * this happens when DivingLog decides to linearalize the - * pressure between beginning and end and for strange reasons - * decides to put that in the sample data as if it came from - * the dive computer; we don't want that (we'll visualize with - * constant SAC rate instead) - * WARNING WARNING - I have only seen this in single tank dives - * --- maybe I should try to create a multi tank dive and see what - * --- divinglog does there - but the code right now is only tested - * --- for the single tank case */ - for (j = 0; j < MAX_CYLINDERS; j++) { - if (abs(pressure_delta[j]) != INT_MAX) { - cylinder_t *cyl = dive->cylinder + j; - for (i = 0; i < dc->samples; i++) - if (dc->sample[i].sensor == j) - dc->sample[i].cylinderpressure.mbar = 0; - if (!cyl->start.mbar) - cyl->start.mbar = cyl->sample_start.mbar; - if (!cyl->end.mbar) - cyl->end.mbar = cyl->sample_end.mbar; - cyl->sample_start.mbar = 0; - cyl->sample_end.mbar = 0; - } - } } /* FIXME! sensor -> cylinder mapping? */ -- cgit v1.2.3-70-g09d2