From 5faebafff10f57faac92a6f9e0a698cf0015e48a Mon Sep 17 00:00:00 2001 From: "sgunderson@bigfoot.com" <> Date: Thu, 28 Dec 2006 20:39:02 +0100 Subject: [PATCH] More fixes. --- estimate-skew.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/estimate-skew.cpp b/estimate-skew.cpp index cc4835e..116b4fc 100644 --- a/estimate-skew.cpp +++ b/estimate-skew.cpp @@ -68,15 +68,13 @@ private: FILE *f; double p; int in_pos; - short prev_sample; + short prev_sample, sample; public: InterpolatingReader(FILE *f) : f(f), p(0.0), in_pos(-1) {} double read_sample(double speed) { - short sample; - p += speed; while ((int)(ceil(p)) > in_pos) { prev_sample = sample; @@ -134,7 +132,7 @@ int main(int argc, char **argv) // open (estimated) skew if (strcmp(argv[3], "-") == 0) { - skew = stderr; + skew = stdout; } else { skew = fopen(argv[3], "wb"); if (skew == NULL) { @@ -144,6 +142,8 @@ int main(int argc, char **argv) } FlankDetector f1, f2; + InterpolatingReader intp(in2); + double speed = 1.000; // initial sync, reference do { @@ -157,16 +157,11 @@ int main(int argc, char **argv) // initial sync, input do { - short s; - if (fread(&s, sizeof(short), 1, in2) != 1) { - exit(0); - } - + short s = (short)intp.read_sample(speed); f2.update(s); - } while (!f2.check_flag() || !f2.get_status()); - InterpolatingReader intp(in2); - double speed = 1.000; + fwrite(&speed, sizeof(double), 1, skew); + } while (!f2.check_flag() || !f2.get_status()); while (!feof(in1) && !feof(in2)) { short refs; @@ -187,6 +182,8 @@ int main(int argc, char **argv) double s = intp.read_sample(speed); f2.update((short)s); ++num_inp; + + fwrite(&speed, sizeof(double), 1, skew); } double ns = filter(speed * double(num_inp) / double(num_ref)); -- 2.39.2