blob: 4a184976b261dbddea45ea916a53fbddc2a50187 [file] [log] [blame]
Sebastian Dröge54b10eb2007-01-24 12:41:03 +00001/*
2 * GStreamer
3 * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
4 * Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
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-audioamplify
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000024 *
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000025 * Amplifies an audio stream by a given factor and allows the selection of different clipping modes.
26 * The difference between the clipping modes is best evaluated by testing.
27 * <title>Example launch line</title>
Stefan Kosta99d3f82009-01-28 12:29:42 +020028 * <refsect2>
29 * |[
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000030 * gst-launch audiotestsrc wave=saw ! audioamplify amplification=1.5 ! alsasink
31 * gst-launch filesrc location="melo1.ogg" ! oggdemux ! vorbisdec ! audioconvert ! audioamplify amplification=1.5 method=wrap-negative ! alsasink
32 * gst-launch audiotestsrc wave=saw ! audioconvert ! audioamplify amplification=1.5 method=wrap-positive ! audioconvert ! alsasink
Stefan Kosta99d3f82009-01-28 12:29:42 +020033 * ]|
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000034 * </refsect2>
35 */
36
37#ifdef HAVE_CONFIG_H
38#include "config.h"
39#endif
40
41#include <gst/gst.h>
42#include <gst/base/gstbasetransform.h>
Sebastian Drögecdba2c42007-02-06 11:16:49 +000043#include <gst/audio/audio.h>
44#include <gst/audio/gstaudiofilter.h>
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000045#include <gst/controller/gstcontroller.h>
46
47#include "audioamplify.h"
48
49#define GST_CAT_DEFAULT gst_audio_amplify_debug
50GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
51
52static const GstElementDetails element_details =
Sebastian Drögef13c8b62008-02-10 10:46:13 +000053GST_ELEMENT_DETAILS ("Audio amplifier",
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000054 "Filter/Effect/Audio",
55 "Amplifies an audio stream by a given factor",
56 "Sebastian Dröge <slomo@circular-chaos.org>");
57
58/* Filter signals and args */
59enum
60{
61 /* FILL ME */
62 LAST_SIGNAL
63};
64
65enum
66{
67 PROP_0,
68 PROP_AMPLIFICATION,
69 PROP_CLIPPING_METHOD
70};
71
72enum
73{
74 METHOD_CLIP = 0,
75 METHOD_WRAP_NEGATIVE,
76 METHOD_WRAP_POSITIVE,
Kipp Cannonafccf532009-06-19 22:20:45 +020077 METHOD_NOCLIP,
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000078 NUM_METHODS
79};
80
81#define GST_TYPE_AUDIO_AMPLIFY_CLIPPING_METHOD (gst_audio_amplify_clipping_method_get_type ())
82static GType
83gst_audio_amplify_clipping_method_get_type (void)
84{
85 static GType gtype = 0;
86
87 if (gtype == 0) {
88 static const GEnumValue values[] = {
Kipp Cannonafccf532009-06-19 22:20:45 +020089 {METHOD_CLIP, "Normal clipping (default)", "clip"},
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000090 {METHOD_WRAP_NEGATIVE,
91 "Push overdriven values back from the opposite side",
92 "wrap-negative"},
93 {METHOD_WRAP_POSITIVE, "Push overdriven values back from the same side",
94 "wrap-positive"},
Kipp Cannonafccf532009-06-19 22:20:45 +020095 {METHOD_NOCLIP, "No clipping", "none"},
Sebastian Dröge54b10eb2007-01-24 12:41:03 +000096 {0, NULL, NULL}
97 };
98
Sebastian Drögeb76819b2008-01-08 14:58:18 +000099 /* FIXME 0.11: rename to GstAudioAmplifyClippingMethod */
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000100 gtype = g_enum_register_static ("GstAudioPanoramaClippingMethod", values);
101 }
102 return gtype;
103}
104
Kipp Cannonafccf532009-06-19 22:20:45 +0200105#define ALLOWED_CAPS \
106 "audio/x-raw-int," \
107 " depth=(int)8," \
108 " width=(int)8," \
109 " endianness=(int)BYTE_ORDER," \
110 " signed=(bool)TRUE," \
111 " rate=(int)[1,MAX]," \
112 " channels=(int)[1,MAX]; " \
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000113 "audio/x-raw-int," \
114 " depth=(int)16," \
115 " width=(int)16," \
116 " endianness=(int)BYTE_ORDER," \
117 " signed=(bool)TRUE," \
118 " rate=(int)[1,MAX]," \
119 " channels=(int)[1,MAX]; " \
Kipp Cannonafccf532009-06-19 22:20:45 +0200120 "audio/x-raw-int," \
121 " depth=(int)32," \
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000122 " width=(int)32," \
123 " endianness=(int)BYTE_ORDER," \
Kipp Cannonafccf532009-06-19 22:20:45 +0200124 " signed=(bool)TRUE," \
125 " rate=(int)[1,MAX]," \
126 " channels=(int)[1,MAX]; " \
127 "audio/x-raw-float," \
128 " width=(int){32,64}," \
129 " endianness=(int)BYTE_ORDER," \
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000130 " rate=(int)[1,MAX]," \
131 " channels=(int)[1,MAX]"
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000132
133#define DEBUG_INIT(bla) \
134 GST_DEBUG_CATEGORY_INIT (gst_audio_amplify_debug, "audioamplify", 0, "audioamplify element");
135
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000136GST_BOILERPLATE_FULL (GstAudioAmplify, gst_audio_amplify, GstAudioFilter,
137 GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000138
Kipp Cannonafccf532009-06-19 22:20:45 +0200139static gboolean gst_audio_amplify_set_process_function (GstAudioAmplify *
140 filter, gint clipping, gint format, gint width);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000141static void gst_audio_amplify_set_property (GObject * object, guint prop_id,
142 const GValue * value, GParamSpec * pspec);
143static void gst_audio_amplify_get_property (GObject * object, guint prop_id,
144 GValue * value, GParamSpec * pspec);
145
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000146static gboolean gst_audio_amplify_setup (GstAudioFilter * filter,
147 GstRingBufferSpec * format);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000148static GstFlowReturn gst_audio_amplify_transform_ip (GstBaseTransform * base,
149 GstBuffer * buf);
150
Kipp Cannonafccf532009-06-19 22:20:45 +0200151#define MIN_gint8 G_MININT8
152#define MAX_gint8 G_MAXINT8
153#define MIN_gint16 G_MININT16
154#define MAX_gint16 G_MAXINT16
155#define MIN_gint32 G_MININT32
156#define MAX_gint32 G_MAXINT32
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000157
Sebastian Drögea3cb8f02009-06-21 17:13:43 +0200158#define MAKE_INT_FUNCS(type,largetype) \
Kipp Cannonafccf532009-06-19 22:20:45 +0200159static void \
160gst_audio_amplify_transform_##type##_clip (GstAudioAmplify * filter, \
161 void * data, guint num_samples) \
162{ \
163 type *d = data; \
164 \
165 while (num_samples--) { \
Sebastian Drögea3cb8f02009-06-21 17:13:43 +0200166 largetype val = *d * filter->amplification; \
Kipp Cannonafccf532009-06-19 22:20:45 +0200167 *d++ = CLAMP (val, MIN_##type, MAX_##type); \
168 } \
169} \
170static void \
171gst_audio_amplify_transform_##type##_wrap_negative (GstAudioAmplify * filter, \
172 void * data, guint num_samples) \
173{ \
174 type *d = data; \
175 \
176 while (num_samples--) { \
Sebastian Drögea3cb8f02009-06-21 17:13:43 +0200177 largetype val = *d * filter->amplification; \
Kipp Cannonafccf532009-06-19 22:20:45 +0200178 if (val > MAX_##type) \
Sebastian Drögea3cb8f02009-06-21 17:13:43 +0200179 val = MIN_##type + (val - MIN_##type) % ((largetype) MAX_##type + 1 - \
Kipp Cannonafccf532009-06-19 22:20:45 +0200180 MIN_##type); \
181 else if (val < MIN_##type) \
Sebastian Drögea3cb8f02009-06-21 17:13:43 +0200182 val = MAX_##type - (MAX_##type - val) % ((largetype) MAX_##type + 1 - \
Kipp Cannonafccf532009-06-19 22:20:45 +0200183 MIN_##type); \
184 *d++ = val; \
185 } \
186} \
187static void \
188gst_audio_amplify_transform_##type##_wrap_positive (GstAudioAmplify * filter, \
189 void * data, guint num_samples) \
190{ \
191 type *d = data; \
192 \
193 while (num_samples--) { \
Sebastian Drögea3cb8f02009-06-21 17:13:43 +0200194 largetype val = *d * filter->amplification; \
Kipp Cannonafccf532009-06-19 22:20:45 +0200195 do { \
196 if (val > MAX_##type) \
197 val = MAX_##type - (val - MAX_##type); \
198 else if (val < MIN_##type) \
199 val = MIN_##type + (MIN_##type - val); \
200 else \
201 break; \
202 } while (1); \
203 *d++ = val; \
204 } \
205} \
206static void \
207gst_audio_amplify_transform_##type##_noclip (GstAudioAmplify * filter, \
208 void * data, guint num_samples) \
209{ \
210 type *d = data; \
211 \
212 while (num_samples--) \
213 *d++ *= filter->amplification; \
214}
215
216#define MAKE_FLOAT_FUNCS(type) \
217static void \
218gst_audio_amplify_transform_##type##_clip (GstAudioAmplify * filter, \
219 void * data, guint num_samples) \
220{ \
221 type *d = data; \
222 \
223 while (num_samples--) { \
224 type val = *d* filter->amplification; \
225 *d++ = CLAMP (val, -1.0, +1.0); \
226 } \
227} \
228static void \
229gst_audio_amplify_transform_##type##_wrap_negative (GstAudioAmplify * \
230 filter, void * data, guint num_samples) \
231{ \
232 type *d = data; \
233 \
234 while (num_samples--) { \
235 type val = *d * filter->amplification; \
236 do { \
237 if (val > 1.0) \
238 val = -1.0 + (val - 1.0); \
239 else if (val < -1.0) \
240 val = 1.0 - (1.0 - val); \
241 else \
242 break; \
243 } while (1); \
244 *d++ = val; \
245 } \
246} \
247static void \
248gst_audio_amplify_transform_##type##_wrap_positive (GstAudioAmplify * filter, \
249 void * data, guint num_samples) \
250{ \
251 type *d = data; \
252 \
253 while (num_samples--) { \
254 type val = *d* filter->amplification; \
255 do { \
256 if (val > 1.0) \
257 val = 1.0 - (val - 1.0); \
258 else if (val < -1.0) \
259 val = -1.0 + (-1.0 - val); \
260 else \
261 break; \
262 } while (1); \
263 *d++ = val; \
264 } \
265} \
266static void \
267gst_audio_amplify_transform_##type##_noclip (GstAudioAmplify * filter, \
268 void * data, guint num_samples) \
269{ \
270 type *d = data; \
271 \
272 while (num_samples--) \
273 *d++ *= filter->amplification; \
274}
275
276/* *INDENT-OFF* */
Sebastian Drögea3cb8f02009-06-21 17:13:43 +0200277MAKE_INT_FUNCS (gint8,gint)
278MAKE_INT_FUNCS (gint16,gint)
279MAKE_INT_FUNCS (gint32,gint64)
Kipp Cannonafccf532009-06-19 22:20:45 +0200280MAKE_FLOAT_FUNCS (gfloat)
281MAKE_FLOAT_FUNCS (gdouble)
Kipp Cannonf80b62c2009-06-21 09:50:54 +0200282/* *INDENT-ON* */
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000283
284/* GObject vmethod implementations */
285
286static void
287gst_audio_amplify_base_init (gpointer klass)
288{
289 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000290 GstCaps *caps;
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000291
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000292 gst_element_class_set_details (element_class, &element_details);
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000293
294 caps = gst_caps_from_string (ALLOWED_CAPS);
295 gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
296 caps);
297 gst_caps_unref (caps);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000298}
299
300static void
301gst_audio_amplify_class_init (GstAudioAmplifyClass * klass)
302{
303 GObjectClass *gobject_class;
304
305 gobject_class = (GObjectClass *) klass;
306 gobject_class->set_property = gst_audio_amplify_set_property;
307 gobject_class->get_property = gst_audio_amplify_get_property;
308
309 g_object_class_install_property (gobject_class, PROP_AMPLIFICATION,
310 g_param_spec_float ("amplification", "Amplification",
311 "Factor of amplification", 0.0, G_MAXFLOAT,
312 1.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
313
314 /**
315 * GstAudioAmplify:clipping-method
316 *
317 * Clipping method: clip mode set values higher than the maximum to the
318 * maximum. The wrap-negative mode pushes those values back from the
319 * opposite side, wrap-positive pushes them back from the same side.
320 *
321 **/
322 g_object_class_install_property (gobject_class, PROP_CLIPPING_METHOD,
323 g_param_spec_enum ("clipping-method", "Clipping method",
324 "Selects how to handle values higher than the maximum",
325 GST_TYPE_AUDIO_AMPLIFY_CLIPPING_METHOD, METHOD_CLIP,
326 G_PARAM_READWRITE));
327
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000328 GST_AUDIO_FILTER_CLASS (klass)->setup =
329 GST_DEBUG_FUNCPTR (gst_audio_amplify_setup);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000330 GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
331 GST_DEBUG_FUNCPTR (gst_audio_amplify_transform_ip);
332}
333
334static void
335gst_audio_amplify_init (GstAudioAmplify * filter, GstAudioAmplifyClass * klass)
336{
337 filter->amplification = 1.0;
Kipp Cannonafccf532009-06-19 22:20:45 +0200338 gst_audio_amplify_set_process_function (filter, METHOD_CLIP,
339 GST_BUFTYPE_LINEAR, 16);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000340 gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
Sebastian Drögeb76819b2008-01-08 14:58:18 +0000341 gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (filter), TRUE);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000342}
343
Kipp Cannonafccf532009-06-19 22:20:45 +0200344static GstAudioAmplifyProcessFunc
345gst_audio_amplify_process_function (gint clipping, gint format, gint width)
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000346{
Kipp Cannonf80b62c2009-06-21 09:50:54 +0200347 static const struct process
348 {
Kipp Cannonafccf532009-06-19 22:20:45 +0200349 gint format;
350 gint width;
351 gint clipping;
352 GstAudioAmplifyProcessFunc func;
Kipp Cannonf80b62c2009-06-21 09:50:54 +0200353 } process[] = {
354 {
355 GST_BUFTYPE_FLOAT, 32, METHOD_CLIP,
356 gst_audio_amplify_transform_gfloat_clip}, {
357 GST_BUFTYPE_FLOAT, 32, METHOD_WRAP_NEGATIVE,
358 gst_audio_amplify_transform_gfloat_wrap_negative}, {
359 GST_BUFTYPE_FLOAT, 32, METHOD_WRAP_POSITIVE,
360 gst_audio_amplify_transform_gfloat_wrap_positive}, {
361 GST_BUFTYPE_FLOAT, 32, METHOD_NOCLIP,
362 gst_audio_amplify_transform_gfloat_noclip}, {
363 GST_BUFTYPE_FLOAT, 64, METHOD_CLIP,
364 gst_audio_amplify_transform_gdouble_clip}, {
365 GST_BUFTYPE_FLOAT, 64, METHOD_WRAP_NEGATIVE,
366 gst_audio_amplify_transform_gdouble_wrap_negative}, {
367 GST_BUFTYPE_FLOAT, 64, METHOD_WRAP_POSITIVE,
368 gst_audio_amplify_transform_gdouble_wrap_positive}, {
369 GST_BUFTYPE_FLOAT, 64, METHOD_NOCLIP,
370 gst_audio_amplify_transform_gdouble_noclip}, {
371 GST_BUFTYPE_LINEAR, 8, METHOD_CLIP, gst_audio_amplify_transform_gint8_clip}, {
372 GST_BUFTYPE_LINEAR, 8, METHOD_WRAP_NEGATIVE,
373 gst_audio_amplify_transform_gint8_wrap_negative}, {
374 GST_BUFTYPE_LINEAR, 8, METHOD_WRAP_POSITIVE,
375 gst_audio_amplify_transform_gint8_wrap_positive}, {
376 GST_BUFTYPE_LINEAR, 8, METHOD_NOCLIP,
377 gst_audio_amplify_transform_gint8_noclip}, {
378 GST_BUFTYPE_LINEAR, 16, METHOD_CLIP,
379 gst_audio_amplify_transform_gint16_clip}, {
380 GST_BUFTYPE_LINEAR, 16, METHOD_WRAP_NEGATIVE,
381 gst_audio_amplify_transform_gint16_wrap_negative}, {
382 GST_BUFTYPE_LINEAR, 16, METHOD_WRAP_POSITIVE,
383 gst_audio_amplify_transform_gint16_wrap_positive}, {
384 GST_BUFTYPE_LINEAR, 16, METHOD_NOCLIP,
385 gst_audio_amplify_transform_gint16_noclip}, {
386 GST_BUFTYPE_LINEAR, 32, METHOD_CLIP,
387 gst_audio_amplify_transform_gint32_clip}, {
388 GST_BUFTYPE_LINEAR, 32, METHOD_WRAP_NEGATIVE,
389 gst_audio_amplify_transform_gint32_wrap_negative}, {
390 GST_BUFTYPE_LINEAR, 32, METHOD_WRAP_POSITIVE,
391 gst_audio_amplify_transform_gint32_wrap_positive}, {
392 GST_BUFTYPE_LINEAR, 32, METHOD_NOCLIP,
393 gst_audio_amplify_transform_gint32_noclip}, {
394 0, 0, 0, NULL}
Kipp Cannonafccf532009-06-19 22:20:45 +0200395 };
Kipp Cannonf80b62c2009-06-21 09:50:54 +0200396 const struct process *p;
Kipp Cannonafccf532009-06-19 22:20:45 +0200397
398 for (p = process; p->func; p++)
399 if (p->format == format && p->width == width && p->clipping == clipping)
400 return p->func;
401 return NULL;
402}
403
404static gboolean
405gst_audio_amplify_set_process_function (GstAudioAmplify * filter, gint
406 clipping_method, gint format, gint width)
407{
408 GstAudioAmplifyProcessFunc process;
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000409
410 /* set processing function */
411
Kipp Cannonf80b62c2009-06-21 09:50:54 +0200412 process = gst_audio_amplify_process_function (clipping_method, format, width);
Kipp Cannonafccf532009-06-19 22:20:45 +0200413 if (!process) {
414 GST_DEBUG ("wrong format");
415 return FALSE;
416 }
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000417
Kipp Cannonafccf532009-06-19 22:20:45 +0200418 filter->process = process;
419 filter->clipping_method = clipping_method;
420 filter->format = format;
421 filter->width = width;
422
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000423 return TRUE;
424}
425
426static void
427gst_audio_amplify_set_property (GObject * object, guint prop_id,
428 const GValue * value, GParamSpec * pspec)
429{
430 GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (object);
431
432 switch (prop_id) {
433 case PROP_AMPLIFICATION:
434 filter->amplification = g_value_get_float (value);
435 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter),
436 filter->amplification == 1.0);
437 break;
438 case PROP_CLIPPING_METHOD:
Kipp Cannonafccf532009-06-19 22:20:45 +0200439 gst_audio_amplify_set_process_function (filter, g_value_get_enum (value),
440 filter->format, filter->width);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000441 break;
442 default:
443 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
444 break;
445 }
446}
447
448static void
449gst_audio_amplify_get_property (GObject * object, guint prop_id,
450 GValue * value, GParamSpec * pspec)
451{
452 GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (object);
453
454 switch (prop_id) {
455 case PROP_AMPLIFICATION:
456 g_value_set_float (value, filter->amplification);
457 break;
458 case PROP_CLIPPING_METHOD:
459 g_value_set_enum (value, filter->clipping_method);
460 break;
461 default:
462 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
463 break;
464 }
465}
466
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000467/* GstAudioFilter vmethod implementations */
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000468static gboolean
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000469gst_audio_amplify_setup (GstAudioFilter * base, GstRingBufferSpec * format)
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000470{
471 GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000472
Kipp Cannonafccf532009-06-19 22:20:45 +0200473 return gst_audio_amplify_set_process_function (filter,
474 filter->clipping_method, format->type, format->width);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000475}
476
Sebastian Drögecdba2c42007-02-06 11:16:49 +0000477/* GstBaseTransform vmethod implementations */
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000478static GstFlowReturn
479gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
480{
481 GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
Sebastian Dröge5f350142007-07-26 19:41:07 +0000482 guint num_samples =
483 GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (filter)->format.width / 8);
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000484
Sebastian Dröge3d7b6f12007-05-06 21:32:40 +0000485 if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buf)))
486 gst_object_sync_values (G_OBJECT (filter), GST_BUFFER_TIMESTAMP (buf));
487
Sebastian Drögeb76819b2008-01-08 14:58:18 +0000488 if (gst_base_transform_is_passthrough (base) ||
489 G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
490 return GST_FLOW_OK;
491
Sebastian Dröge54b10eb2007-01-24 12:41:03 +0000492 filter->process (filter, GST_BUFFER_DATA (buf), num_samples);
493
494 return GST_FLOW_OK;
495}