From d1426d30686faa5929ba433182b258de7e3c02e0 Mon Sep 17 00:00:00 2001 From: Aaron Viets <aaron.viets@ligo.org> Date: Mon, 21 May 2018 19:36:52 -0700 Subject: [PATCH] lal_trackfrequency: Minor bookkeeping bug fix. --- .../gst/lal/gstlal_trackfrequency.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gstlal-calibration/gst/lal/gstlal_trackfrequency.c b/gstlal-calibration/gst/lal/gstlal_trackfrequency.c index c27706c575..4425232691 100644 --- a/gstlal-calibration/gst/lal/gstlal_trackfrequency.c +++ b/gstlal-calibration/gst/lal/gstlal_trackfrequency.c @@ -101,6 +101,7 @@ static void trackfrequency_ ## DTYPE(const DTYPE *src, DTYPE *dst, gint64 size, gint64 j = 0; \ while(i < size - 1) { \ \ + gboolean shift = FALSE; \ while(*check_step) { \ if(*sign * src[i] < 0) { \ *check_step = -(*check_step) / 2; \ @@ -112,9 +113,16 @@ static void trackfrequency_ ## DTYPE(const DTYPE *src, DTYPE *dst, gint64 size, if(*check_step >= size - i) \ *check_step = (size - i) / 2; \ i += *check_step; \ + if(*check_step == -1) \ + shift = TRUE; \ + } \ + /* Make sure we are after the transition */ \ + if(shift) { \ + i ++; \ + *sign = -(*sign); \ } \ \ - /* At this point, we could be on either side of a +/- transition, and/or at the end of the buffer */ \ + /* At this point, we are either after a +/- transition or at the end of the buffer */ \ if(i == 0) { \ /* There is a transition at the beginning of a buffer */ \ *dst = (DTYPE) *current_frequency; \ @@ -182,6 +190,7 @@ static void trackfrequency_complex_ ## DTYPE(const DTYPE complex *src, DTYPE *ds gint64 j = 0; \ while(i < size - 1) { \ \ + gboolean shift = FALSE; \ while(*check_step) { \ if(*sign * creal ## F_OR_BLANK(src[i]) < 0) { \ *check_step = -(*check_step) / 2; \ @@ -193,9 +202,16 @@ static void trackfrequency_complex_ ## DTYPE(const DTYPE complex *src, DTYPE *ds if(*check_step >= size - i) \ *check_step = (size - i) / 2; \ i += *check_step; \ + if(*check_step == -1) \ + shift = TRUE; \ + } \ + /* Make sure we are after the transition */ \ + if(shift) { \ + i ++; \ + *sign = -(*sign); \ } \ \ - /* At this point, we could be on either side of a +/- transition, and/or at the end of the buffer */ \ + /* At this point, we are either after a +/- transition or at the end of the buffer */ \ if(i == 0) { \ /* There is a transition at the beginning of a buffer */ \ *dst = (DTYPE) *current_frequency; \ -- GitLab