[FFmpeg-soc] [soc]: r4738 - in afilters: af_vol.c dummy.c

kdub subversion at mplayerhq.hu
Tue Jul 21 14:22:20 CEST 2009


Author: kdub
Date: Tue Jul 21 14:22:19 2009
New Revision: 4738

Log:
Add volume filter

Added:
   afilters/af_vol.c
Modified:
   afilters/dummy.c

Added: afilters/af_vol.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ afilters/af_vol.c	Tue Jul 21 14:22:19 2009	(r4738)
@@ -0,0 +1,71 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file libavfilter/af_vol.c
+ * null filter. used as an example, or for development
+ */
+
+
+#include <stdio.h>
+#include "avfilter.h"
+
+static int vol_filter(AVFilterLink *link, AVFilterBufferRef *sample_ref);
+static int query_af_vol_formats(AVFilterContext *ctx);
+
+AVFilter avfilter_af_volume =
+{
+    .name      = "audio_volume",
+
+    .priv_size = 0,
+
+    .inputs    = (AVFilterPad[]) {{ .name            = "default",
+                                    .type            = CODEC_TYPE_AUDIO,
+                                    .filter_buffer    = vol_filter },
+                                  { .name = NULL}},
+
+    .outputs   = (AVFilterPad[]) {{ .name            = "default",
+                                    .type            = CODEC_TYPE_AUDIO, },
+                                  { .name = NULL}},
+    .query_formats = query_af_vol_formats
+};
+
+
+static int query_af_vol_formats(AVFilterContext *ctx)
+{
+    AVFilterFormats *formats;
+    formats = avfilter_make_format_list(2, CODEC_ID_PCM_S16LE,
+                                            CODEC_ID_PCM_S16BE);
+    avfilter_set_common_formats(ctx,formats);
+}
+
+static int vol_filter(AVFilterLink *link, AVFilterBufferRef *sample_ref)
+{
+    av_log(0,0, "Volume filter\n");
+    int i;
+    int16_t *data;
+    int num_samples = sample_ref->buffer->n_samples;
+
+    data = (int16_t*) sample_ref->buffer->data;
+    for (i=0; i < num_samples; i++)
+    {
+        data[i]  = data[i] * 2;
+    }
+
+    return 0;
+}

Modified: afilters/dummy.c
==============================================================================
--- afilters/dummy.c	Tue Jul 21 10:38:11 2009	(r4737)
+++ afilters/dummy.c	Tue Jul 21 14:22:19 2009	(r4738)
@@ -125,15 +125,6 @@ int main()
     avfilter_init_filter(avfiltcont2, NULL, NULL);
     avfilter_init_filter(src_context, NULL, NULL);
 
-    /* configure formats?  */
-
-
-
-    /* merge lists? */
-    AVFilterFormats * merge;
-
-//    merge = avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
-
 
     /* link filters */
     avfilter_link(src_context, 0, avfiltcont, 0);


More information about the FFmpeg-soc mailing list