Skip to content
Snippets Groups Projects
Commit 1c9d5e40 authored by Aaron Viets's avatar Aaron Viets
Browse files

lal_smoothkappas: Now, the order of elements in the average array is...

lal_smoothkappas: Now, the order of elements in the average array is insensitive to the start time and the array size. This should resolve the remaining discrepancy in h(t) computed with different start times.
parent f2d8ceac
No related branches found
No related tags found
No related merge requests found
......@@ -342,6 +342,7 @@ static gboolean set_caps(GstBaseTransform *trans, GstCaps *incaps, GstCaps *outc
GSTLALSmoothKappas *element = GSTLAL_SMOOTHKAPPAS(trans);
gboolean success = TRUE;
gsize unit_size;
gint rate_in, rate_out;
/*
* parse the caps
......@@ -351,6 +352,9 @@ static gboolean set_caps(GstBaseTransform *trans, GstCaps *incaps, GstCaps *outc
GstStructure *str = gst_caps_get_structure(incaps, 0);
const gchar *name = gst_structure_get_string(str, "format");
success &= (name != NULL);
success &= gst_structure_get_int(gst_caps_get_structure(incaps, 0), "rate", &rate_in);
success &= gst_structure_get_int(gst_caps_get_structure(outcaps, 0), "rate", &rate_out);
success &= (rate_in == rate_out);
if(!success)
GST_ERROR_OBJECT(element, "unable to parse caps %" GST_PTR_FORMAT, incaps);
......@@ -376,6 +380,7 @@ static gboolean set_caps(GstBaseTransform *trans, GstCaps *incaps, GstCaps *outc
g_assert_not_reached();
element->unit_size = unit_size;
element->rate = rate_in;
}
return success;
......@@ -400,21 +405,15 @@ static gboolean start(GstBaseTransform *trans)
element->avg_array_im = g_malloc(sizeof(double) * element->avg_array_size);
int i;
for(i = 0; i < element->array_size; i++, (element->fifo_array_re)++, (element->fifo_array_im)++) {
*(element->fifo_array_re) = element->default_kappa_re;
*(element->fifo_array_im) = element->default_kappa_im;
for(i = 0; i < element->array_size; i++) {
(element->fifo_array_re)[i] = element->default_kappa_re;
(element->fifo_array_im)[i] = element->default_kappa_im;
}
for(i = 0; i < element->avg_array_size; i++, (element->avg_array_re)++, (element->avg_array_im)++) {
*(element->avg_array_re) = element->default_kappa_re;
*(element->avg_array_im) = element->default_kappa_im;
for(i = 0; i < element->avg_array_size; i++) {
(element->avg_array_re)[i] = element->default_kappa_re;
(element->avg_array_im)[i] = element->default_kappa_im;
}
(element->fifo_array_re) -= element->array_size;
(element->fifo_array_im) -= element->array_size;
(element->avg_array_re) -= element->avg_array_size;
(element->avg_array_im) -= element->avg_array_size;
return TRUE;
}
......@@ -430,6 +429,11 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
GstMapInfo inmap, outmap;
GstFlowReturn result;
if(G_UNLIKELY(GST_BUFFER_IS_DISCONT(inbuf))) {
element->avg_index_re = ((GST_BUFFER_PTS(inbuf) * element->rate) / 1000000000) % element->avg_array_size;
element->avg_index_im = ((GST_BUFFER_PTS(inbuf) * element->rate) / 1000000000) % element->avg_array_size;
}
GST_INFO_OBJECT(element, "processing %s%s buffer %p spanning %" GST_BUFFER_BOUNDARIES_FORMAT, GST_BUFFER_FLAG_IS_SET(inbuf, GST_BUFFER_FLAG_GAP) ? "gap" : "nongap", GST_BUFFER_FLAG_IS_SET(inbuf, GST_BUFFER_FLAG_DISCONT) ? "+discont" : "", inbuf, GST_BUFFER_BOUNDARIES_ARGS(inbuf));
gst_buffer_map(outbuf, &outmap, GST_MAP_WRITE);
......@@ -743,6 +747,7 @@ static void gstlal_smoothkappas_class_init(GSTLALSmoothKappasClass *klass)
static void gstlal_smoothkappas_init(GSTLALSmoothKappas *element)
{
element->unit_size = 0;
element->rate = 0;
element->array_size = 0;
element->avg_array_size = 0;
element->fifo_array_re = NULL;
......
......@@ -61,6 +61,7 @@ struct _GSTLALSmoothKappas {
GstBaseTransform element;
gint unit_size;
gint rate;
double current_median_re;
double current_median_im;
double *fifo_array_re;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment