upload tizen1.0 source
[framework/multimedia/gst-plugins-good0.10.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 <gst/gst.h>
44 #include <gst/base/gstbasetransform.h>
45 #include <gst/controller/gstcontroller.h>
46
47 #include "audiopanorama.h"
48
49 #define GST_CAT_DEFAULT gst_audio_panorama_debug
50 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
51
52 /* Filter signals and args */
53 enum
54 {
55   /* FILL ME */
56   LAST_SIGNAL
57 };
58
59 enum
60 {
61   PROP_0,
62   PROP_PANORAMA,
63   PROP_METHOD
64 };
65
66 enum
67 {
68   METHOD_PSYCHOACOUSTIC = 0,
69   METHOD_SIMPLE,
70   NUM_METHODS
71 };
72
73 #define GST_TYPE_AUDIO_PANORAMA_METHOD (gst_audio_panorama_method_get_type ())
74 static GType
75 gst_audio_panorama_method_get_type (void)
76 {
77   static GType gtype = 0;
78
79   if (gtype == 0) {
80     static const GEnumValue values[] = {
81       {METHOD_PSYCHOACOUSTIC, "Psychoacoustic Panning (default)",
82           "psychoacoustic"},
83       {METHOD_SIMPLE, "Simple Panning", "simple"},
84       {0, NULL, NULL}
85     };
86
87     gtype = g_enum_register_static ("GstAudioPanoramaMethod", values);
88   }
89   return gtype;
90 }
91
92 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
93     GST_PAD_SINK,
94     GST_PAD_ALWAYS,
95     GST_STATIC_CAPS ("audio/x-raw-float, "
96         "rate = (int) [ 1, MAX ], "
97         "channels = (int) [ 1, 2 ], "
98         "endianness = (int) BYTE_ORDER, " "width = (int) 32; "
99         "audio/x-raw-int, "
100         "rate = (int) [ 1, MAX ], "
101         "channels = (int) [ 1, 2 ], "
102         "endianness = (int) BYTE_ORDER, "
103         "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
104     );
105
106 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
107     GST_PAD_SRC,
108     GST_PAD_ALWAYS,
109     GST_STATIC_CAPS ("audio/x-raw-float, "
110         "rate = (int) [ 1, MAX ], "
111         "channels = (int) 2, "
112         "endianness = (int) BYTE_ORDER, " "width = (int) 32; "
113         "audio/x-raw-int, "
114         "rate = (int) [ 1, MAX ], "
115         "channels = (int) 2, "
116         "endianness = (int) BYTE_ORDER, "
117         "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
118     );
119
120 #define DEBUG_INIT(bla) \
121   GST_DEBUG_CATEGORY_INIT (gst_audio_panorama_debug, "audiopanorama", 0, "audiopanorama element");
122
123 GST_BOILERPLATE_FULL (GstAudioPanorama, gst_audio_panorama, GstBaseTransform,
124     GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
125
126 static void gst_audio_panorama_set_property (GObject * object, guint prop_id,
127     const GValue * value, GParamSpec * pspec);
128 static void gst_audio_panorama_get_property (GObject * object, guint prop_id,
129     GValue * value, GParamSpec * pspec);
130
131 static gboolean gst_audio_panorama_get_unit_size (GstBaseTransform * base,
132     GstCaps * caps, guint * size);
133 static GstCaps *gst_audio_panorama_transform_caps (GstBaseTransform * base,
134     GstPadDirection direction, GstCaps * caps);
135 static gboolean gst_audio_panorama_set_caps (GstBaseTransform * base,
136     GstCaps * incaps, GstCaps * outcaps);
137
138 static void gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter,
139     gint16 * idata, gint16 * odata, guint num_samples);
140 static void gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter,
141     gint16 * idata, gint16 * odata, guint num_samples);
142 static void gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
143     gfloat * idata, gfloat * odata, guint num_samples);
144 static void gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
145     gfloat * idata, gfloat * odata, guint num_samples);
146
147 static void gst_audio_panorama_transform_m2s_int_simple (GstAudioPanorama *
148     filter, gint16 * idata, gint16 * odata, guint num_samples);
149 static void gst_audio_panorama_transform_s2s_int_simple (GstAudioPanorama *
150     filter, gint16 * idata, gint16 * odata, guint num_samples);
151 static void gst_audio_panorama_transform_m2s_float_simple (GstAudioPanorama *
152     filter, gfloat * idata, gfloat * odata, guint num_samples);
153 static void gst_audio_panorama_transform_s2s_float_simple (GstAudioPanorama *
154     filter, gfloat * idata, gfloat * odata, guint num_samples);
155
156 static GstFlowReturn gst_audio_panorama_transform (GstBaseTransform * base,
157     GstBuffer * inbuf, GstBuffer * outbuf);
158
159
160 /* Table with processing functions: [channels][format][method] */
161 static GstAudioPanoramaProcessFunc panorama_process_functions[2][2][2] = {
162   {
163         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_m2s_int,
164               (GstAudioPanoramaProcessFunc)
165             gst_audio_panorama_transform_m2s_int_simple},
166         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_m2s_float,
167               (GstAudioPanoramaProcessFunc)
168             gst_audio_panorama_transform_m2s_float_simple}
169       },
170   {
171         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_s2s_int,
172               (GstAudioPanoramaProcessFunc)
173             gst_audio_panorama_transform_s2s_int_simple},
174         {(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_s2s_float,
175               (GstAudioPanoramaProcessFunc)
176             gst_audio_panorama_transform_s2s_float_simple}
177       }
178 };
179
180 /* GObject vmethod implementations */
181
182 static void
183 gst_audio_panorama_base_init (gpointer klass)
184 {
185   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
186
187   gst_element_class_add_pad_template (element_class,
188       gst_static_pad_template_get (&src_template));
189   gst_element_class_add_pad_template (element_class,
190       gst_static_pad_template_get (&sink_template));
191   gst_element_class_set_details_simple (element_class, "Stereo positioning",
192       "Filter/Effect/Audio",
193       "Positions audio streams in the stereo panorama",
194       "Stefan Kost <ensonic@users.sf.net>");
195 }
196
197 static void
198 gst_audio_panorama_class_init (GstAudioPanoramaClass * klass)
199 {
200   GObjectClass *gobject_class;
201
202   gobject_class = (GObjectClass *) klass;
203   gobject_class->set_property = gst_audio_panorama_set_property;
204   gobject_class->get_property = gst_audio_panorama_get_property;
205
206   g_object_class_install_property (gobject_class, PROP_PANORAMA,
207       g_param_spec_float ("panorama", "Panorama",
208           "Position in stereo panorama (-1.0 left -> 1.0 right)", -1.0, 1.0,
209           0.0,
210           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
211   /**
212    * GstAudioPanorama:method
213    *
214    * Panning method: psychoacoustic mode keeps the same perceived loudness,
215    * while simple mode just controls the volume of one channel. It's merely
216    * a matter of taste which method should be chosen. 
217    *
218    * Since: 0.10.6
219    **/
220   g_object_class_install_property (gobject_class, PROP_METHOD,
221       g_param_spec_enum ("method", "Panning method",
222           "Psychoacoustic mode keeps same perceived loudness, "
223           "simple mode just controls volume of one channel.",
224           GST_TYPE_AUDIO_PANORAMA_METHOD, METHOD_PSYCHOACOUSTIC,
225           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
226
227   GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
228       GST_DEBUG_FUNCPTR (gst_audio_panorama_get_unit_size);
229   GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
230       GST_DEBUG_FUNCPTR (gst_audio_panorama_transform_caps);
231   GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
232       GST_DEBUG_FUNCPTR (gst_audio_panorama_set_caps);
233   GST_BASE_TRANSFORM_CLASS (klass)->transform =
234       GST_DEBUG_FUNCPTR (gst_audio_panorama_transform);
235 }
236
237 static void
238 gst_audio_panorama_init (GstAudioPanorama * filter,
239     GstAudioPanoramaClass * klass)
240 {
241
242   filter->panorama = 0;
243   filter->method = METHOD_PSYCHOACOUSTIC;
244   filter->width = 0;
245   filter->channels = 0;
246   filter->format_float = FALSE;
247   filter->process = NULL;
248
249   gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (filter), TRUE);
250 }
251
252 static gboolean
253 gst_audio_panorama_set_process_function (GstAudioPanorama * filter)
254 {
255   gint channel_index, format_index, method_index;
256
257   /* set processing function */
258   channel_index = filter->channels - 1;
259   if (channel_index > 1 || channel_index < 0) {
260     filter->process = NULL;
261     return FALSE;
262   }
263
264   format_index = (filter->format_float) ? 1 : 0;
265
266   method_index = filter->method;
267   if (method_index >= NUM_METHODS || method_index < 0)
268     method_index = METHOD_PSYCHOACOUSTIC;
269
270   filter->process =
271       panorama_process_functions[channel_index][format_index][method_index];
272   return TRUE;
273 }
274
275 static void
276 gst_audio_panorama_set_property (GObject * object, guint prop_id,
277     const GValue * value, GParamSpec * pspec)
278 {
279   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (object);
280
281   switch (prop_id) {
282     case PROP_PANORAMA:
283       filter->panorama = g_value_get_float (value);
284       break;
285     case PROP_METHOD:
286       filter->method = g_value_get_enum (value);
287       gst_audio_panorama_set_process_function (filter);
288       break;
289     default:
290       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
291       break;
292   }
293 }
294
295 static void
296 gst_audio_panorama_get_property (GObject * object, guint prop_id,
297     GValue * value, GParamSpec * pspec)
298 {
299   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (object);
300
301   switch (prop_id) {
302     case PROP_PANORAMA:
303       g_value_set_float (value, filter->panorama);
304       break;
305     case PROP_METHOD:
306       g_value_set_enum (value, filter->method);
307       break;
308     default:
309       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
310       break;
311   }
312 }
313
314 /* GstBaseTransform vmethod implementations */
315
316 static gboolean
317 gst_audio_panorama_get_unit_size (GstBaseTransform * base, GstCaps * caps,
318     guint * size)
319 {
320   gint width, channels;
321   GstStructure *structure;
322   gboolean ret;
323
324   g_assert (size);
325
326   /* this works for both float and int */
327   structure = gst_caps_get_structure (caps, 0);
328   ret = gst_structure_get_int (structure, "width", &width);
329   ret &= gst_structure_get_int (structure, "channels", &channels);
330
331   *size = width * channels / 8;
332
333   return ret;
334 }
335
336 static GstCaps *
337 gst_audio_panorama_transform_caps (GstBaseTransform * base,
338     GstPadDirection direction, GstCaps * caps)
339 {
340   GstCaps *res;
341   GstStructure *structure;
342
343   /* transform caps gives one single caps so we can just replace
344    * the channel property with our range. */
345   res = gst_caps_copy (caps);
346   structure = gst_caps_get_structure (res, 0);
347   if (direction == GST_PAD_SRC) {
348     GST_INFO ("allow 1-2 channels");
349     gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
350   } else {
351     GST_INFO ("allow 2 channels");
352     gst_structure_set (structure, "channels", G_TYPE_INT, 2, NULL);
353   }
354
355   return res;
356 }
357
358 static gboolean
359 gst_audio_panorama_set_caps (GstBaseTransform * base, GstCaps * incaps,
360     GstCaps * outcaps)
361 {
362   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
363   const GstStructure *structure;
364   gboolean ret;
365   gint width;
366   const gchar *fmt;
367
368   /*GST_INFO ("incaps are %" GST_PTR_FORMAT, incaps); */
369
370   structure = gst_caps_get_structure (incaps, 0);
371   ret = gst_structure_get_int (structure, "channels", &filter->channels);
372   if (!ret)
373     goto no_channels;
374
375   ret = gst_structure_get_int (structure, "width", &width);
376   if (!ret)
377     goto no_width;
378   filter->width = width / 8;
379
380   fmt = gst_structure_get_name (structure);
381   if (!strcmp (fmt, "audio/x-raw-int"))
382     filter->format_float = FALSE;
383   else
384     filter->format_float = TRUE;
385
386   GST_DEBUG ("try to process %s input with %d channels", fmt, filter->channels);
387
388   ret = gst_audio_panorama_set_process_function (filter);
389
390   if (!ret)
391     GST_WARNING ("can't process input with %d channels", filter->channels);
392
393   return ret;
394
395 no_channels:
396   GST_DEBUG ("no channels in caps");
397   return ret;
398 no_width:
399   GST_DEBUG ("no width in caps");
400   return ret;
401 }
402
403 /* psychoacoustic processing functions */
404 static void
405 gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter, gint16 * idata,
406     gint16 * odata, guint num_samples)
407 {
408   guint i;
409   gdouble val;
410   glong lval, rval;
411   gdouble rpan, lpan;
412
413   /* pan:  -1.0  0.0  1.0
414    * lpan:  1.0  0.5  0.0  
415    * rpan:  0.0  0.5  1.0
416    *
417    * FIXME: we should use -3db (1/sqtr(2)) for 50:50
418    */
419   rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
420   lpan = 1.0 - rpan;
421
422   for (i = 0; i < num_samples; i++) {
423     val = (gdouble) * idata++;
424
425     lval = (glong) (val * lpan);
426     rval = (glong) (val * rpan);
427
428     *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
429     *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
430   }
431 }
432
433 static void
434 gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter, gint16 * idata,
435     gint16 * odata, guint num_samples)
436 {
437   guint i;
438   glong lval, rval;
439   gdouble lival, rival;
440   gdouble lrpan, llpan, rrpan, rlpan;
441
442   /* pan:  -1.0  0.0  1.0
443    * llpan: 1.0  1.0  0.0
444    * lrpan: 1.0  0.0  0.0
445    * rrpan: 0.0  1.0  1.0
446    * rlpan: 0.0  0.0  1.0
447    */
448   if (filter->panorama > 0) {
449     rlpan = (gdouble) filter->panorama;
450     llpan = 1.0 - rlpan;
451     lrpan = 0.0;
452     rrpan = 1.0;
453   } else {
454     rrpan = (gdouble) (1.0 + filter->panorama);
455     lrpan = 1.0 - rrpan;
456     rlpan = 0.0;
457     llpan = 1.0;
458   }
459
460   for (i = 0; i < num_samples; i++) {
461     lival = (gdouble) * idata++;
462     rival = (gdouble) * idata++;
463
464     lval = lival * llpan + rival * lrpan;
465     rval = lival * rlpan + rival * rrpan;
466
467     *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
468     *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
469   }
470 }
471
472 static void
473 gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
474     gfloat * idata, gfloat * odata, guint num_samples)
475 {
476   guint i;
477   gfloat val;
478   gdouble rpan, lpan;
479
480   /* pan:  -1.0  0.0  1.0
481    * lpan:  1.0  0.5  0.0  
482    * rpan:  0.0  0.5  1.0
483    *
484    * FIXME: we should use -3db (1/sqtr(2)) for 50:50
485    */
486   rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
487   lpan = 1.0 - rpan;
488
489   for (i = 0; i < num_samples; i++) {
490     val = *idata++;
491
492     *odata++ = val * lpan;
493     *odata++ = val * rpan;
494   }
495 }
496
497 static void
498 gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
499     gfloat * idata, gfloat * odata, guint num_samples)
500 {
501   guint i;
502   gfloat lival, rival;
503   gdouble lrpan, llpan, rrpan, rlpan;
504
505   /* pan:  -1.0  0.0  1.0
506    * llpan: 1.0  1.0  0.0
507    * lrpan: 1.0  0.0  0.0
508    * rrpan: 0.0  1.0  1.0
509    * rlpan: 0.0  0.0  1.0
510    */
511   if (filter->panorama > 0) {
512     rlpan = (gdouble) filter->panorama;
513     llpan = 1.0 - rlpan;
514     lrpan = 0.0;
515     rrpan = 1.0;
516   } else {
517     rrpan = (gdouble) (1.0 + filter->panorama);
518     lrpan = 1.0 - rrpan;
519     rlpan = 0.0;
520     llpan = 1.0;
521   }
522
523   for (i = 0; i < num_samples; i++) {
524     lival = *idata++;
525     rival = *idata++;
526
527     *odata++ = lival * llpan + rival * lrpan;
528     *odata++ = lival * rlpan + rival * rrpan;
529   }
530 }
531
532 /* simple processing functions */
533 static void
534 gst_audio_panorama_transform_m2s_int_simple (GstAudioPanorama * filter,
535     gint16 * idata, gint16 * odata, guint num_samples)
536 {
537   guint i;
538   gdouble pan;
539   glong lval, rval;
540
541   if (filter->panorama > 0.0) {
542     pan = 1.0 - filter->panorama;
543     for (i = 0; i < num_samples; i++) {
544       rval = *idata++;
545       lval = (glong) ((gdouble) rval * pan);
546
547       *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
548       *odata++ = (gint16) rval;
549     }
550   } else {
551     pan = 1.0 + filter->panorama;
552     for (i = 0; i < num_samples; i++) {
553       lval = *idata++;
554       rval = (glong) ((gdouble) lval * pan);
555
556       *odata++ = (gint16) lval;
557       *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
558     }
559   }
560 }
561
562 static void
563 gst_audio_panorama_transform_s2s_int_simple (GstAudioPanorama * filter,
564     gint16 * idata, gint16 * odata, guint num_samples)
565 {
566   guint i;
567   glong lval, rval;
568   gdouble lival, rival, pan;
569
570   if (filter->panorama > 0.0) {
571     pan = 1.0 - filter->panorama;
572     for (i = 0; i < num_samples; i++) {
573       lival = (gdouble) * idata++;
574       rival = (gdouble) * idata++;
575
576       lval = (glong) (lival * pan);
577       rval = (glong) rival;
578
579       *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
580       *odata++ = (gint16) rval;
581     }
582   } else {
583     pan = 1.0 + filter->panorama;
584     for (i = 0; i < num_samples; i++) {
585       lival = (gdouble) * idata++;
586       rival = (gdouble) * idata++;
587
588       lval = (glong) lival;
589       rval = (glong) (rival * pan);
590
591       *odata++ = (gint16) lval;
592       *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
593     }
594   }
595 }
596
597 static void
598 gst_audio_panorama_transform_m2s_float_simple (GstAudioPanorama * filter,
599     gfloat * idata, gfloat * odata, guint num_samples)
600 {
601   guint i;
602   gfloat val, pan;
603
604   if (filter->panorama > 0.0) {
605     pan = 1.0 - filter->panorama;
606     for (i = 0; i < num_samples; i++) {
607       val = *idata++;
608
609       *odata++ = val * pan;
610       *odata++ = val;
611     }
612   } else {
613     pan = 1.0 + filter->panorama;
614     for (i = 0; i < num_samples; i++) {
615       val = *idata++;
616
617       *odata++ = val;
618       *odata++ = val * pan;
619     }
620   }
621 }
622
623 static void
624 gst_audio_panorama_transform_s2s_float_simple (GstAudioPanorama * filter,
625     gfloat * idata, gfloat * odata, guint num_samples)
626 {
627   guint i;
628   gfloat lival, rival, pan;
629
630   if (filter->panorama > 0.0) {
631     pan = 1.0 - filter->panorama;
632     for (i = 0; i < num_samples; i++) {
633       lival = *idata++;
634       rival = *idata++;
635
636       *odata++ = lival * pan;
637       *odata++ = rival;
638     }
639   } else {
640     pan = 1.0 + filter->panorama;
641     for (i = 0; i < num_samples; i++) {
642       lival = *idata++;
643       rival = *idata++;
644
645       *odata++ = lival;
646       *odata++ = rival * pan;
647     }
648   }
649 }
650
651 /* this function does the actual processing
652  */
653 static GstFlowReturn
654 gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
655     GstBuffer * outbuf)
656 {
657   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
658   guint num_samples = GST_BUFFER_SIZE (outbuf) / (2 * filter->width);
659   GstClockTime timestamp, stream_time;
660
661   timestamp = GST_BUFFER_TIMESTAMP (inbuf);
662   stream_time =
663       gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, timestamp);
664
665   GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT,
666       GST_TIME_ARGS (timestamp));
667
668   if (GST_CLOCK_TIME_IS_VALID (stream_time))
669     gst_object_sync_values (G_OBJECT (filter), stream_time);
670
671   if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
672     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
673     memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
674     return GST_FLOW_OK;
675   }
676
677   filter->process (filter, GST_BUFFER_DATA (inbuf),
678       GST_BUFFER_DATA (outbuf), num_samples);
679
680   return GST_FLOW_OK;
681 }