diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2005-02-10 15:06:13 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2005-02-10 15:06:13 +0000 |
commit | 909da9fb0489c3744547e6386531461c072da5fc (patch) | |
tree | f0cca5239d10580fa9d6840f3d9fa03da0ad31c9 /gst/speed/filter.func | |
parent | d7af68b7c8447e1b444e98ca1cb4a5f917a4b5b3 (diff) | |
download | gst-plugins-bad-909da9fb0489c3744547e6386531461c072da5fc.tar.gz gst-plugins-bad-909da9fb0489c3744547e6386531461c072da5fc.tar.bz2 gst-plugins-bad-909da9fb0489c3744547e6386531461c072da5fc.zip |
and make it handle more than one channel.
Original commit message from CVS:
Fix speed element and make it chain-based (fixes #156467), and make it handle more than one channel.
Diffstat (limited to 'gst/speed/filter.func')
-rw-r--r-- | gst/speed/filter.func | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/gst/speed/filter.func b/gst/speed/filter.func deleted file mode 100644 index 6802b20c..00000000 --- a/gst/speed/filter.func +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 2 -*- */ - _FORMAT *in_data, *out_data; - static gint64 offset = 0, timestamp = 0; - - /* get a buffer here so that we can have something to interpolate - * against for the first few samples if speed < 0.5 */ - in_data = (_FORMAT*) GST_BUFFER_DATA(in); - nin = GST_BUFFER_SIZE(in)/sizeof(_FORMAT); - lower = in_data[0]; - i_float = 0.5 * (speed - 1.0); - i = i_float + 1.0; /* ciel(i_float) for ints */ - - do { - speed = filter->speed; /* update this, it might have changed */ - - out = gst_buffer_new(); - GST_BUFFER_DATA(out) = (gchar*) g_new(_FORMAT,SPEED_BUFSIZE/sizeof(_FORMAT)); - GST_BUFFER_SIZE(out) = SPEED_BUFSIZE; - out_data = (_FORMAT*) GST_BUFFER_DATA(out); - nout = GST_BUFFER_SIZE(out) / sizeof(_FORMAT); - GST_BUFFER_TIMESTAMP (out) = timestamp; - offset += nout; - timestamp = offset * GST_SECOND / filter->rate; - - for (j=0; j<nout; j++) { - /* index of upper bounds of interpolation for - * new sample, got it by trial&error on the chalkboard */ - i_float += speed; - i = i_float + 1.0; /* ciel(i_float) for ints */ - - while (i >= nin) { - i = i % nin; - i_float = i_float - nin; - lower = in_data[nin-1]; - gst_buffer_unref(in); - in = GST_BUFFER (gst_pad_pull (filter->sinkpad)); - - while (GST_IS_EVENT (in)) { - gst_pad_event_default (filter->srcpad, GST_EVENT (in)); - in = GST_BUFFER (gst_pad_pull (filter->sinkpad)); - } - - in_data = (_FORMAT*) GST_BUFFER_DATA(in); - nin = GST_BUFFER_SIZE(in) / sizeof(_FORMAT); - } - - if (i>0) - lower = in_data[i-1]; - - interp = i_float - floor(i_float); - - out_data[j] = lower*(1-interp) + in_data[i]*interp; - - lower = in_data[i]; - } - - gst_pad_push(filter->srcpad, GST_DATA (out)); - - gst_element_yield (element); - } while (TRUE); |