Merge remote-tracking branch 'origin/master' into 0.11
[platform/upstream/gst-plugins-good.git] / gst / audiofx / audiopanorama.c
1 /*
2  * GStreamer
3  * Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
4  * Copyright (C) 2006 Sebastian Dröge <slomo@circular-chaos.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 /**
23  * SECTION:element-audiopanorama
24  *
25  * Stereo panorama effect with controllable pan position. One can choose between the default psychoacoustic panning method,
26  * which keeps the same perceived loudness, and a simple panning method that just controls the volume on one channel.
27  *
28  * <refsect2>
29  * <title>Example launch line</title>
30  * |[
31  * gst-launch audiotestsrc wave=saw ! audiopanorama panorama=-1.00 ! alsasink
32  * gst-launch filesrc location="melo1.ogg" ! oggdemux ! vorbisdec ! audioconvert ! audiopanorama panorama=-1.00 ! alsasink
33  * gst-launch audiotestsrc wave=saw ! audioconvert ! audiopanorama panorama=-1.00 ! audioconvert ! alsasink
34  * gst-launch audiotestsrc wave=saw ! audioconvert ! audiopanorama method=simple panorama=-0.50 ! audioconvert ! alsasink
35  * ]|
36  * </refsect2>
37  */
38
39 #ifdef HAVE_CONFIG_H
40 #include "config.h"
41 #endif
42
43 #include <string.h>
44
45 #include <gst/gst.h>
46 #include <gst/base/gstbasetransform.h>
47
48 #include "audiopanorama.h"
49
50 #define GST_CAT_DEFAULT gst_audio_panorama_debug
51 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
52
53 /* Filter signals and args */
54 enum
55 {
56   /* FILL ME */
57   LAST_SIGNAL
58 };
59
60 enum
61 {
62   PROP_0,
63   PROP_PANORAMA,
64   PROP_METHOD
65 };
66
67 enum
68 {
69   METHOD_PSYCHOACOUSTIC = 0,
70   METHOD_SIMPLE,
71   NUM_METHODS
72 };
73
74 #define GST_TYPE_AUDIO_PANORAMA_METHOD (gst_audio_panorama_method_get_type ())
75 static GType
76 gst_audio_panorama_method_get_type (void)
77 {
78   static GType gtype = 0;
79
80   if (gtype == 0) {
81     static const GEnumValue values[] = {
82       {METHOD_PSYCHOACOUSTIC, "Psychoacoustic Panning (default)",
83           "psychoacoustic"},
84       {METHOD_SIMPLE, "Simple Panning", "simple"},
85       {0, NULL, NULL}
86     };
87
88     gtype = g_enum_register_static ("GstAudioPanoramaMethod", values);
89   }
90   return gtype;
91 }
92
93 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
94     GST_PAD_SINK,
95     GST_PAD_ALWAYS,
96     GST_STATIC_CAPS ("audio/x-raw, "
97         "format = (string) { " GST_AUDIO_NE (S32) ", " GST_AUDIO_NE (S16) "}, "
98         "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
99     );
100
101 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
102     GST_PAD_SRC,
103     GST_PAD_ALWAYS,
104     GST_STATIC_CAPS ("audio/x-raw, "
105         "format = (string) { " GST_AUDIO_NE (S32) ", " GST_AUDIO_NE (S16) "}, "
106         "rate = (int) [ 1, MAX ], " "channels = (int) 2")
107     );
108
109 G_DEFINE_TYPE (GstAudioPanorama, gst_audio_panorama, GST_TYPE_BASE_TRANSFORM);
110
111 static void gst_audio_panorama_set_property (GObject * object, guint prop_id,
112     const GValue * value, GParamSpec * pspec);
113 static void gst_audio_panorama_get_property (GObject * object, guint prop_id,
114     GValue * value, GParamSpec * pspec);
115
116 static gboolean gst_audio_panorama_get_unit_size (GstBaseTransform * base,
117     GstCaps * caps, gsize * size);
118 static GstCaps *gst_audio_panorama_transform_caps (GstBaseTransform * base,
119     GstPadDirection direction, GstCaps * caps, GstCaps * filter);
120 static gboolean gst_audio_panorama_set_caps (GstBaseTransform * base,
121     GstCaps * incaps, GstCaps * outcaps);
122
123 static void gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter,
124     gint16 * idata, gint16 * odata, guint num_samples);
125 static void gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter,
126     gint16 * idata, gint16 * odata, guint num_samples);
127 static void gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
128     gfloat * idata, gfloat * odata, guint num_samples);
129 static void gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
130     gfloat * idata, gfloat * odata, guint num_samples);
131
132 static void gst_audio_panorama_transform_m2s_int_simple (GstAudioPanorama *
133     filter, gint16 * idata, gint16 * odata, guint num_samples);
134 static void gst_audio_panorama_transform_s2s_int_simple (GstAudioPanorama *
135     filter, gint16 * idata, gint16 * odata, guint num_samples);
136 static void gst_audio_panorama_transform_m2s_float_simple (GstAudioPanorama *
137     filter, gfloat * idata, gfloat * odata, guint num_samples);
138 static void gst_audio_panorama_transform_s2s_float_simple (GstAudioPanorama *
139     filter, gfloat * idata, gfloat * odata, guint num_samples);
140
141 static GstFlowReturn gst_audio_panorama_transform (GstBaseTransform * base,
142     GstBuffer * inbuf, GstBuffer * outbuf);
143
144
145 /* Table with processing functions: [channels][format][method] */
146 static GstAudioPanoramaProcessFunc panorama_process_functions[2][2][2] = {
147   {
148         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_m2s_int,
149               (GstAudioPanoramaProcessFunc)
150             gst_audio_panorama_transform_m2s_int_simple},
151         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_m2s_float,
152               (GstAudioPanoramaProcessFunc)
153             gst_audio_panorama_transform_m2s_float_simple}
154       },
155   {
156         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_s2s_int,
157               (GstAudioPanoramaProcessFunc)
158             gst_audio_panorama_transform_s2s_int_simple},
159         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_s2s_float,
160               (GstAudioPanoramaProcessFunc)
161             gst_audio_panorama_transform_s2s_float_simple}
162       }
163 };
164
165 /* GObject vmethod implementations */
166
167 static void
168 gst_audio_panorama_class_init (GstAudioPanoramaClass * klass)
169 {
170   GObjectClass *gobject_class;
171   GstElementClass *gstelement_class;
172
173   GST_DEBUG_CATEGORY_INIT (gst_audio_panorama_debug, "audiopanorama", 0,
174       "audiopanorama element");
175
176   gobject_class = (GObjectClass *) klass;
177   gstelement_class = (GstElementClass *) klass;
178
179   gobject_class->set_property = gst_audio_panorama_set_property;
180   gobject_class->get_property = gst_audio_panorama_get_property;
181
182   g_object_class_install_property (gobject_class, PROP_PANORAMA,
183       g_param_spec_float ("panorama", "Panorama",
184           "Position in stereo panorama (-1.0 left -> 1.0 right)", -1.0, 1.0,
185           0.0,
186           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
187   /**
188    * GstAudioPanorama:method
189    *
190    * Panning method: psychoacoustic mode keeps the same perceived loudness,
191    * while simple mode just controls the volume of one channel. It's merely
192    * a matter of taste which method should be chosen. 
193    *
194    * Since: 0.10.6
195    **/
196   g_object_class_install_property (gobject_class, PROP_METHOD,
197       g_param_spec_enum ("method", "Panning method",
198           "Psychoacoustic mode keeps same perceived loudness, "
199           "simple mode just controls volume of one channel.",
200           GST_TYPE_AUDIO_PANORAMA_METHOD, METHOD_PSYCHOACOUSTIC,
201           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
202
203   gst_element_class_set_details_simple (gstelement_class, "Stereo positioning",
204       "Filter/Effect/Audio",
205       "Positions audio streams in the stereo panorama",
206       "Stefan Kost <ensonic@users.sf.net>");
207
208   gst_element_class_add_pad_template (gstelement_class,
209       gst_static_pad_template_get (&src_template));
210   gst_element_class_add_pad_template (gstelement_class,
211       gst_static_pad_template_get (&sink_template));
212
213   GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
214       GST_DEBUG_FUNCPTR (gst_audio_panorama_get_unit_size);
215   GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
216       GST_DEBUG_FUNCPTR (gst_audio_panorama_transform_caps);
217   GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
218       GST_DEBUG_FUNCPTR (gst_audio_panorama_set_caps);
219   GST_BASE_TRANSFORM_CLASS (klass)->transform =
220       GST_DEBUG_FUNCPTR (gst_audio_panorama_transform);
221 }
222
223 static void
224 gst_audio_panorama_init (GstAudioPanorama * filter)
225 {
226
227   filter->panorama = 0;
228   filter->method = METHOD_PSYCHOACOUSTIC;
229   gst_audio_info_init (&filter->info);
230   filter->process = NULL;
231
232   gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (filter), TRUE);
233 }
234
235 static gboolean
236 gst_audio_panorama_set_process_function (GstAudioPanorama * filter,
237     GstAudioInfo * info)
238 {
239   gint channel_index, format_index, method_index;
240   const GstAudioFormatInfo *finfo = info->finfo;
241
242   /* set processing function */
243   channel_index = GST_AUDIO_INFO_CHANNELS (info) - 1;
244   if (channel_index > 1 || channel_index < 0) {
245     filter->process = NULL;
246     return FALSE;
247   }
248
249   format_index = GST_AUDIO_FORMAT_INFO_IS_FLOAT (finfo) ? 1 : 0;
250
251   method_index = filter->method;
252   if (method_index >= NUM_METHODS || method_index < 0)
253     method_index = METHOD_PSYCHOACOUSTIC;
254
255   filter->process =
256       panorama_process_functions[channel_index][format_index][method_index];
257   return TRUE;
258 }
259
260 static void
261 gst_audio_panorama_set_property (GObject * object, guint prop_id,
262     const GValue * value, GParamSpec * pspec)
263 {
264   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (object);
265
266   switch (prop_id) {
267     case PROP_PANORAMA:
268       filter->panorama = g_value_get_float (value);
269       break;
270     case PROP_METHOD:
271       filter->method = g_value_get_enum (value);
272       gst_audio_panorama_set_process_function (filter, &filter->info);
273       break;
274     default:
275       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
276       break;
277   }
278 }
279
280 static void
281 gst_audio_panorama_get_property (GObject * object, guint prop_id,
282     GValue * value, GParamSpec * pspec)
283 {
284   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (object);
285
286   switch (prop_id) {
287     case PROP_PANORAMA:
288       g_value_set_float (value, filter->panorama);
289       break;
290     case PROP_METHOD:
291       g_value_set_enum (value, filter->method);
292       break;
293     default:
294       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
295       break;
296   }
297 }
298
299 /* GstBaseTransform vmethod implementations */
300
301 static gboolean
302 gst_audio_panorama_get_unit_size (GstBaseTransform * base, GstCaps * caps,
303     gsize * size)
304 {
305   GstAudioInfo info;
306
307   g_assert (size);
308
309   if (!gst_audio_info_from_caps (&info, caps))
310     return FALSE;
311
312   *size = GST_AUDIO_INFO_BPF (&info);
313
314   return TRUE;
315 }
316
317 static GstCaps *
318 gst_audio_panorama_transform_caps (GstBaseTransform * base,
319     GstPadDirection direction, GstCaps * caps, GstCaps * filter)
320 {
321   GstCaps *res;
322   GstStructure *structure;
323
324   /* transform caps gives one single caps so we can just replace
325    * the channel property with our range. */
326   res = gst_caps_copy (caps);
327   structure = gst_caps_get_structure (res, 0);
328   if (direction == GST_PAD_SRC) {
329     GST_INFO ("allow 1-2 channels");
330     gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
331   } else {
332     GST_INFO ("allow 2 channels");
333     gst_structure_set (structure, "channels", G_TYPE_INT, 2, NULL);
334   }
335
336   return res;
337 }
338
339 static gboolean
340 gst_audio_panorama_set_caps (GstBaseTransform * base, GstCaps * incaps,
341     GstCaps * outcaps)
342 {
343   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
344   GstAudioInfo info;
345
346   /*GST_INFO ("incaps are %" GST_PTR_FORMAT, incaps); */
347   if (!gst_audio_info_from_caps (&info, incaps))
348     goto no_format;
349
350   GST_DEBUG ("try to process %d input with %d channels",
351       GST_AUDIO_INFO_FORMAT (&info), GST_AUDIO_INFO_CHANNELS (&info));
352
353   if (!gst_audio_panorama_set_process_function (filter, &info))
354     goto no_format;
355
356   filter->info = info;
357
358   return TRUE;
359
360 no_format:
361   {
362     GST_DEBUG ("invalid caps");
363     return FALSE;
364   }
365 }
366
367 /* psychoacoustic processing functions */
368 static void
369 gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter, gint16 * idata,
370     gint16 * odata, guint num_samples)
371 {
372   guint i;
373   gdouble val;
374   glong lval, rval;
375   gdouble rpan, lpan;
376
377   /* pan:  -1.0  0.0  1.0
378    * lpan:  1.0  0.5  0.0  
379    * rpan:  0.0  0.5  1.0
380    *
381    * FIXME: we should use -3db (1/sqtr(2)) for 50:50
382    */
383   rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
384   lpan = 1.0 - rpan;
385
386   for (i = 0; i < num_samples; i++) {
387     val = (gdouble) * idata++;
388
389     lval = (glong) (val * lpan);
390     rval = (glong) (val * rpan);
391
392     *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
393     *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
394   }
395 }
396
397 static void
398 gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter, gint16 * idata,
399     gint16 * odata, guint num_samples)
400 {
401   guint i;
402   glong lval, rval;
403   gdouble lival, rival;
404   gdouble lrpan, llpan, rrpan, rlpan;
405
406   /* pan:  -1.0  0.0  1.0
407    * llpan: 1.0  1.0  0.0
408    * lrpan: 1.0  0.0  0.0
409    * rrpan: 0.0  1.0  1.0
410    * rlpan: 0.0  0.0  1.0
411    */
412   if (filter->panorama > 0) {
413     rlpan = (gdouble) filter->panorama;
414     llpan = 1.0 - rlpan;
415     lrpan = 0.0;
416     rrpan = 1.0;
417   } else {
418     rrpan = (gdouble) (1.0 + filter->panorama);
419     lrpan = 1.0 - rrpan;
420     rlpan = 0.0;
421     llpan = 1.0;
422   }
423
424   for (i = 0; i < num_samples; i++) {
425     lival = (gdouble) * idata++;
426     rival = (gdouble) * idata++;
427
428     lval = lival * llpan + rival * lrpan;
429     rval = lival * rlpan + rival * rrpan;
430
431     *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
432     *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
433   }
434 }
435
436 static void
437 gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
438     gfloat * idata, gfloat * odata, guint num_samples)
439 {
440   guint i;
441   gfloat val;
442   gdouble rpan, lpan;
443
444   /* pan:  -1.0  0.0  1.0
445    * lpan:  1.0  0.5  0.0  
446    * rpan:  0.0  0.5  1.0
447    *
448    * FIXME: we should use -3db (1/sqtr(2)) for 50:50
449    */
450   rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
451   lpan = 1.0 - rpan;
452
453   for (i = 0; i < num_samples; i++) {
454     val = *idata++;
455
456     *odata++ = val * lpan;
457     *odata++ = val * rpan;
458   }
459 }
460
461 static void
462 gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
463     gfloat * idata, gfloat * odata, guint num_samples)
464 {
465   guint i;
466   gfloat lival, rival;
467   gdouble lrpan, llpan, rrpan, rlpan;
468
469   /* pan:  -1.0  0.0  1.0
470    * llpan: 1.0  1.0  0.0
471    * lrpan: 1.0  0.0  0.0
472    * rrpan: 0.0  1.0  1.0
473    * rlpan: 0.0  0.0  1.0
474    */
475   if (filter->panorama > 0) {
476     rlpan = (gdouble) filter->panorama;
477     llpan = 1.0 - rlpan;
478     lrpan = 0.0;
479     rrpan = 1.0;
480   } else {
481     rrpan = (gdouble) (1.0 + filter->panorama);
482     lrpan = 1.0 - rrpan;
483     rlpan = 0.0;
484     llpan = 1.0;
485   }
486
487   for (i = 0; i < num_samples; i++) {
488     lival = *idata++;
489     rival = *idata++;
490
491     *odata++ = lival * llpan + rival * lrpan;
492     *odata++ = lival * rlpan + rival * rrpan;
493   }
494 }
495
496 /* simple processing functions */
497 static void
498 gst_audio_panorama_transform_m2s_int_simple (GstAudioPanorama * filter,
499     gint16 * idata, gint16 * odata, guint num_samples)
500 {
501   guint i;
502   gdouble pan;
503   glong lval, rval;
504
505   if (filter->panorama > 0.0) {
506     pan = 1.0 - filter->panorama;
507     for (i = 0; i < num_samples; i++) {
508       rval = *idata++;
509       lval = (glong) ((gdouble) rval * pan);
510
511       *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
512       *odata++ = (gint16) rval;
513     }
514   } else {
515     pan = 1.0 + filter->panorama;
516     for (i = 0; i < num_samples; i++) {
517       lval = *idata++;
518       rval = (glong) ((gdouble) lval * pan);
519
520       *odata++ = (gint16) lval;
521       *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
522     }
523   }
524 }
525
526 static void
527 gst_audio_panorama_transform_s2s_int_simple (GstAudioPanorama * filter,
528     gint16 * idata, gint16 * odata, guint num_samples)
529 {
530   guint i;
531   glong lval, rval;
532   gdouble lival, rival, pan;
533
534   if (filter->panorama > 0.0) {
535     pan = 1.0 - filter->panorama;
536     for (i = 0; i < num_samples; i++) {
537       lival = (gdouble) * idata++;
538       rival = (gdouble) * idata++;
539
540       lval = (glong) (lival * pan);
541       rval = (glong) rival;
542
543       *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
544       *odata++ = (gint16) rval;
545     }
546   } else {
547     pan = 1.0 + filter->panorama;
548     for (i = 0; i < num_samples; i++) {
549       lival = (gdouble) * idata++;
550       rival = (gdouble) * idata++;
551
552       lval = (glong) lival;
553       rval = (glong) (rival * pan);
554
555       *odata++ = (gint16) lval;
556       *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
557     }
558   }
559 }
560
561 static void
562 gst_audio_panorama_transform_m2s_float_simple (GstAudioPanorama * filter,
563     gfloat * idata, gfloat * odata, guint num_samples)
564 {
565   guint i;
566   gfloat val, pan;
567
568   if (filter->panorama > 0.0) {
569     pan = 1.0 - filter->panorama;
570     for (i = 0; i < num_samples; i++) {
571       val = *idata++;
572
573       *odata++ = val * pan;
574       *odata++ = val;
575     }
576   } else {
577     pan = 1.0 + filter->panorama;
578     for (i = 0; i < num_samples; i++) {
579       val = *idata++;
580
581       *odata++ = val;
582       *odata++ = val * pan;
583     }
584   }
585 }
586
587 static void
588 gst_audio_panorama_transform_s2s_float_simple (GstAudioPanorama * filter,
589     gfloat * idata, gfloat * odata, guint num_samples)
590 {
591   guint i;
592   gfloat lival, rival, pan;
593
594   if (filter->panorama > 0.0) {
595     pan = 1.0 - filter->panorama;
596     for (i = 0; i < num_samples; i++) {
597       lival = *idata++;
598       rival = *idata++;
599
600       *odata++ = lival * pan;
601       *odata++ = rival;
602     }
603   } else {
604     pan = 1.0 + filter->panorama;
605     for (i = 0; i < num_samples; i++) {
606       lival = *idata++;
607       rival = *idata++;
608
609       *odata++ = lival;
610       *odata++ = rival * pan;
611     }
612   }
613 }
614
615 /* this function does the actual processing
616  */
617 static GstFlowReturn
618 gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
619     GstBuffer * outbuf)
620 {
621   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
622   GstClockTime timestamp, stream_time;
623   guint8 *indata, *outdata;
624   gsize insize, outsize;
625
626   timestamp = GST_BUFFER_TIMESTAMP (inbuf);
627   stream_time =
628       gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, timestamp);
629
630   GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT,
631       GST_TIME_ARGS (timestamp));
632
633   if (GST_CLOCK_TIME_IS_VALID (stream_time))
634     gst_object_sync_values (GST_OBJECT (filter), stream_time);
635
636   indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
637   outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
638
639   if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
640     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
641     memset (outdata, 0, outsize);
642   } else {
643     guint num_samples = outsize / GST_AUDIO_INFO_BPF (&filter->info);
644
645     filter->process (filter, indata, outdata, num_samples);
646   }
647
648   gst_buffer_unmap (inbuf, indata, insize);
649   gst_buffer_unmap (outbuf, outdata, outsize);
650
651   return GST_FLOW_OK;
652 }