[FFmpeg-soc] [soc]: r4390 - in afilters: Makefile.dummy af_null.c avfilter.c avfilter.h dummy.c

kdub subversion at mplayerhq.hu
Mon Jun 8 06:02:13 CEST 2009


Author: kdub
Date: Mon Jun  8 06:02:12 2009
New Revision: 4390

Log:
Constructs for afilters, null filter example, standalone testing program w/ makefile

Added:
   afilters/Makefile.dummy
   afilters/af_null.c
   afilters/dummy.c
Modified:
   afilters/avfilter.c
   afilters/avfilter.h

Added: afilters/Makefile.dummy
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ afilters/Makefile.dummy	Mon Jun  8 06:02:12 2009	(r4390)
@@ -0,0 +1,4 @@
+
+
+all:
+	gcc dummy.c -o dummy -I./ffmpeg -lm ./ffmpeg/libav*/libav*.a

Added: afilters/af_null.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ afilters/af_null.c	Mon Jun  8 06:02:12 2009	(r4390)
@@ -0,0 +1,61 @@
+/*
+ * 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/vf_null.c
+ * null filter
+ */
+
+#include <stdio.h>
+#include "avfilter.h"
+
+
+typedef struct
+{
+    int history[100]; /*just an example */
+
+
+} af_null_priv_t;
+
+
+static int start_buf(AVFilterLink *link)
+{
+    return;
+}
+
+static int end_buf(AVFilterLink *link)
+{
+    return;
+}
+
+AVFilter avfilter_af_null =
+{
+    .name      = "audio_null",
+
+    .priv_size = sizeof(af_null_priv_t),
+
+    .inputs    = (AVFilterPad[]) {{ .name            = "default",
+                                    .type            = CODEC_TYPE_AUDIO,
+                                    .start_buffer    = start_buf,
+                                    .end_buffer      = end_buf },
+                                  { .name = NULL}},
+
+    .outputs   = (AVFilterPad[]) {{ .name            = "default",
+                                    .type            = CODEC_TYPE_AUDIO, },
+                                  { .name = NULL}},
+};

Modified: afilters/avfilter.c
==============================================================================
--- afilters/avfilter.c	Sun Jun  7 20:19:38 2009	(r4389)
+++ afilters/avfilter.c	Mon Jun  8 06:02:12 2009	(r4390)
@@ -69,6 +69,8 @@ void avfilter_insert_pad(unsigned idx, u
     (*links)[idx] = NULL;
 
     (*count) ++;
+
+    av_log(0,0,"%x %x\n", idx, *count);
     for(i = idx+1; i < *count; i ++)
         if(*links[i])
             (*(unsigned *)((uint8_t *) *links[i] + padidx_off)) ++;
@@ -297,6 +299,7 @@ AVFilter *avfilter_get_by_name(const cha
     return NULL;
 }
 
+/* does not work, nonrobust logic? */
 void avfilter_register(AVFilter *filter)
 {
     struct FilterList *newfilt = av_malloc(sizeof(struct FilterList));
@@ -318,9 +321,12 @@ void avfilter_uninit(void)
 
 static int pad_count(const AVFilterPad *pads)
 {
-    int count;
+    if (!pads)
+        return 0;
 
+    int count;
     for(count = 0; pads->name; count ++) pads ++;
+    av_log(0,0,"count is: %i\n", count);
     return count;
 }
 

Modified: afilters/avfilter.h
==============================================================================
--- afilters/avfilter.h	Sun Jun  7 20:19:38 2009	(r4389)
+++ afilters/avfilter.h	Mon Jun  8 06:02:12 2009	(r4390)
@@ -101,6 +101,20 @@ typedef struct AVFilterPicRef
 #define AV_PERM_REUSE2   0x10   ///< can output the buffer multiple times, modified each time
 } AVFilterPicRef;
 
+
+typedef struct AVFilterSamples
+{
+    /* data */
+    void *data;
+    int *n_samples;
+
+    void *priv;
+    void (*free)(struct AVFilterSamples *samples)
+
+}AVFilterSamples;
+
+
+
 /**
  * Adds a new reference to a picture.
  * @param ref   an existing reference to the picture
@@ -345,6 +359,17 @@ struct AVFilterPad
      * and another value on error.
      */
     int (*config_props)(AVFilterLink *link);
+
+
+    /**
+     * Process an audio buffer. This function is where the audio filter should
+     * recieve and process data
+     */
+    int (*start_buffer)(AVFilterLink *link);
+
+    int (*end_buffer)(AVFilterLink *link);
+
+
 };
 
 /** default handler for start_frame() for video inputs */

Added: afilters/dummy.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ afilters/dummy.c	Mon Jun  8 06:02:12 2009	(r4390)
@@ -0,0 +1,48 @@
+/* temporary development file for avfilters
+* (c) 2009 Kevin DuBois <kdub432 at gmail.com>
+*/
+
+#include "avfilter.h"
+#include "af_null.c"
+
+int main()
+{
+
+    printf("%x\n", avfilter_version());
+
+
+    /* Simulates a 1024 buffer of sl16 audio data */
+    int16_t * tbuf;
+    tbuf = calloc(1024, sizeof(int16_t));
+    int i;
+    for(i=0;i<1024;i++)
+    {
+        tbuf[i] = (int16_t) 100 * sin(2*3.141/100 * i);
+        printf("%i\n", tbuf[i]);
+
+    }   // sine wave, period 1024/100, range, 100 -> -100
+
+
+    /* avfilter context */
+    AVFilterContext * avfiltcont;
+
+    AVFilter *avfilt=NULL, *filt2=NULL;
+
+
+    avfilt = &avfilter_af_null;
+
+
+    AVFilterPad *pad;
+    avfilter_insert_inpad(0, avfiltcont, pad );
+
+    avfiltcont = avfilter_open(avfilt, "kevinfilter");
+
+    avfilter_register(avfilt);
+    filt2 = avfilter_get_by_name("kevinfilter");
+
+    /*run buffer now*/
+
+
+
+}
+


More information about the FFmpeg-soc mailing list