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

lal_smoothkappas: Fixed buffer sizing bug.

parent 5a842452
No related branches found
No related tags found
No related merge requests found
...@@ -477,24 +477,25 @@ static gboolean transform_size(GstBaseTransform *trans, GstPadDirection directio ...@@ -477,24 +477,25 @@ static gboolean transform_size(GstBaseTransform *trans, GstPadDirection directio
GSTLALSmoothKappas *element = GSTLAL_SMOOTHKAPPAS(trans); GSTLALSmoothKappas *element = GSTLAL_SMOOTHKAPPAS(trans);
gsize unit_size; gsize unit_size;
if(!get_unit_size(trans, caps, &unit_size)) {
GST_DEBUG_OBJECT(element, "function 'get_unit_size' failed");
return FALSE;
}
/* buffer size in bytes should be a multiple of unit_size in bytes */
if(G_UNLIKELY(size % unit_size)) {
GST_DEBUG_OBJECT(element, "buffer size %" G_GSIZE_FORMAT " is not a multiple of %" G_GSIZE_FORMAT, size, unit_size);
return FALSE;
}
size /= unit_size;
/* How many samples do we need to throw away based on the filter latency? */ /* How many samples do we need to throw away based on the filter latency? */
int waste_samples = (int) (element->filter_latency * (element->array_size + element->avg_array_size - 2)); int waste_samples = (int) (element->filter_latency * (element->array_size + element->avg_array_size - 2));
switch(direction) { switch(direction) {
case GST_PAD_SRC: case GST_PAD_SRC:
/*We have the size of the output buffer, and we set the size of the input buffer. */ /* We have the size of the output buffer, and we set the size of the input buffer. */
if(!get_unit_size(trans, caps, &unit_size)) {
GST_DEBUG_OBJECT(element, "function 'get_unit_size' failed");
return FALSE;
}
/* buffer size in bytes should be a multiple of unit_size in bytes */
if(G_UNLIKELY(size % unit_size)) {
GST_DEBUG_OBJECT(element, "buffer size %" G_GSIZE_FORMAT " is not a multiple of %" G_GSIZE_FORMAT, size, unit_size);
return FALSE;
}
/* Check if we need to clip the output buffer */ /* Check if we need to clip the output buffer */
if(element->samples_in_filter >= waste_samples) if(element->samples_in_filter >= waste_samples)
*othersize = size; *othersize = size;
...@@ -505,21 +506,10 @@ static gboolean transform_size(GstBaseTransform *trans, GstPadDirection directio ...@@ -505,21 +506,10 @@ static gboolean transform_size(GstBaseTransform *trans, GstPadDirection directio
case GST_PAD_SINK: case GST_PAD_SINK:
/* We have the size of the input buffer, and we set the size of the output buffer. */ /* We have the size of the input buffer, and we set the size of the output buffer. */
if(!get_unit_size(trans, caps, &unit_size)) {
GST_DEBUG_OBJECT(element, "function 'get_unit_size' failed");
return FALSE;
}
/* buffer size in bytes should be a multiple of unit_size in bytes */
if(G_UNLIKELY(size % unit_size)) {
GST_DEBUG_OBJECT(element, "buffer size %" G_GSIZE_FORMAT " is not a multiple of %" G_GSIZE_FORMAT, size, unit_size);
return FALSE;
}
/* Check if we need to clip the output buffer */ /* Check if we need to clip the output buffer */
if(element->samples_in_filter >= waste_samples) if(element->samples_in_filter >= waste_samples)
*othersize = size; *othersize = size;
else if(size > (guint) (waste_samples + element->samples_in_filter)) else if(size > (guint) (waste_samples - element->samples_in_filter))
*othersize = size - waste_samples + element->samples_in_filter; *othersize = size - waste_samples + element->samples_in_filter;
else else
*othersize = 0; *othersize = 0;
...@@ -531,6 +521,8 @@ static gboolean transform_size(GstBaseTransform *trans, GstPadDirection directio ...@@ -531,6 +521,8 @@ static gboolean transform_size(GstBaseTransform *trans, GstPadDirection directio
return FALSE; return FALSE;
} }
*othersize *= unit_size;
return TRUE; return TRUE;
} }
......
...@@ -201,6 +201,7 @@ def remove_harmonics_with_witness(pipeline, signal, witness, f0, num_harmonics, ...@@ -201,6 +201,7 @@ def remove_harmonics_with_witness(pipeline, signal, witness, f0, num_harmonics,
upsample_quality = 4 upsample_quality = 4
resample_shift = 16.0 + 16.5 resample_shift = 16.0 + 16.5
zero_latency = filter_latency == 0.0 zero_latency = filter_latency == 0.0
filter_latency = min(0.5, filter_latency)
witness = pipeparts.mktee(pipeline, witness) witness = pipeparts.mktee(pipeline, witness)
signal = pipeparts.mktee(pipeline, signal) signal = pipeparts.mktee(pipeline, signal)
......
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