[FFmpeg-soc] [soc]: r4399 - in afilters: Makefile.dummy af_null.c avfilter.c avfilter.h dummy.c
kdub
subversion at mplayerhq.hu
Tue Jun 9 07:00:29 CEST 2009
Author: kdub
Date: Tue Jun 9 07:00:29 2009
New Revision: 4399
Log:
Prototyping to run a single filter
Modified:
afilters/Makefile.dummy
afilters/af_null.c
afilters/avfilter.c
afilters/avfilter.h
afilters/dummy.c
Modified: afilters/Makefile.dummy
==============================================================================
--- afilters/Makefile.dummy Mon Jun 8 19:03:43 2009 (r4398)
+++ afilters/Makefile.dummy Tue Jun 9 07:00:29 2009 (r4399)
@@ -1,4 +1,3 @@
-
all:
- gcc dummy.c -o dummy -I./ffmpeg -lm ./ffmpeg/libav*/libav*.a
+ gcc dummy.c -o dummy -I./ffmpeg -lm ./ffmpeg/libavfilter/libavfilter.a ffmpeg/libavcodec/libavcodec.a ffmpeg/libavformat/libavformat.a ffmpeg/libavutil/libavutil.a
Modified: afilters/af_null.c
==============================================================================
--- afilters/af_null.c Mon Jun 8 19:03:43 2009 (r4398)
+++ afilters/af_null.c Tue Jun 9 07:00:29 2009 (r4399)
@@ -29,17 +29,18 @@ typedef struct
{
int history[100]; /*just an example */
-
} af_null_priv_t;
-static int start_buf(AVFilterLink *link)
+static int start_buf(AVFilterLink *link, AVFilterSamplesRef *sample_ref)
{
+ av_log(0,0, "Starting buffer\n");
return;
}
-static int end_buf(AVFilterLink *link)
+static int end_buf(AVFilterLink *link, AVFilterSamplesRef *sample_ref)
{
+ av_log(0,0, "Ending buffer\n");
return;
}
Modified: afilters/avfilter.c
==============================================================================
--- afilters/avfilter.c Mon Jun 8 19:03:43 2009 (r4398)
+++ afilters/avfilter.c Tue Jun 9 07:00:29 2009 (r4399)
@@ -231,6 +231,26 @@ void avfilter_start_frame(AVFilterLink *
start_frame(link, link->cur_pic);
}
+void avfilter_start_buffer(AVFilterLink *link, AVFilterSamplesRef *sample_ref)
+{
+ void (*start_buf) (AVFilterLink *, AVFilterSamplesRef *);
+ AVFilterPad *dst = &link_dpad(link);
+
+ if (!(start_buf = dst->start_buffer))
+ {
+ av_log(0,0,"it is %x\n", 0);
+ start_buf = NULL; /* FIXME: should have a default function pointer
+ like avfilter_default_start_buffer */
+ }
+
+
+ av_log(0,0,"it is %x\n", start_buf);
+ link->cur_buf = sample_ref;
+
+ start_buf(link, link->cur_pic);
+}
+
+
void avfilter_end_frame(AVFilterLink *link)
{
void (*end_frame)(AVFilterLink *);
@@ -246,7 +266,6 @@ void avfilter_end_frame(AVFilterLink *li
avfilter_unref_pic(link->srcpic);
link->srcpic = NULL;
}
-
}
void avfilter_draw_slice(AVFilterLink *link, int y, int h)
Modified: afilters/avfilter.h
==============================================================================
--- afilters/avfilter.h Mon Jun 8 19:03:43 2009 (r4398)
+++ afilters/avfilter.h Tue Jun 9 07:00:29 2009 (r4399)
@@ -102,17 +102,36 @@ typedef struct AVFilterPicRef
} AVFilterPicRef;
+/* two structures that contain the data to be processed for the audio buf */
+/* contains samples. audio analogue to AVFilterPic */
typedef struct AVFilterSamples
{
/* data */
void *data;
- int *n_samples;
+ int data_size; /* data size in bytes */
+ int n_samples;
void *priv;
- void (*free)(struct AVFilterSamples *samples)
+ void (*free)(struct AVFilterSamples *samples);
}AVFilterSamples;
+/**
+ * A reference to an audio buffer. contains info about the AVFilterSamples
+ * Do not use AVFilterSamples directly
+ */
+typedef struct AVFilterSamplesRef
+{
+ AVFilterSamples *samples;
+
+ int sample_type; /* contains type of sample in the buffer*/
+ int sample_rate;
+
+}AVFilterSamplesRef;
+
+
+
+
/**
@@ -365,9 +384,9 @@ struct AVFilterPad
* Process an audio buffer. This function is where the audio filter should
* recieve and process data
*/
- int (*start_buffer)(AVFilterLink *link);
+ int (*start_buffer)(AVFilterLink *link, AVFilterSamplesRef *sample_ref);
- int (*end_buffer)(AVFilterLink *link);
+ int (*end_buffer)(AVFilterLink *link, AVFilterSamplesRef *sample_ref);
};
@@ -497,6 +516,11 @@ struct AVFilterLink
AVFilterPicRef *cur_pic;
AVFilterPicRef *outpic;
+
+ /** the audio buffer reference is sent accross the link by the source. */
+ AVFilterSamplesRef *srcbuf;
+ AVFilterSamplesRef *cur_buf;
+ AVFilterSamplesRef *outbuf;
};
/**
Modified: afilters/dummy.c
==============================================================================
--- afilters/dummy.c Mon Jun 8 19:03:43 2009 (r4398)
+++ afilters/dummy.c Tue Jun 9 07:00:29 2009 (r4399)
@@ -2,47 +2,68 @@
* (c) 2009 Kevin DuBois <kdub432 at gmail.com>
*/
-#include "avfilter.h"
-#include "af_null.c"
+#include "af_null.c" /*FIXME: bad, i know. prototyping :) */
+
int main()
{
- printf("%x\n", avfilter_version());
+ printf("AVfilter version: %x\n", avfilter_version());
/* Simulates a 1024 buffer of sl16 audio data */
+ /* temporary setup, probably a cleaner way i want to do all this */
int16_t * tbuf;
- tbuf = calloc(1024, sizeof(int16_t));
- int i;
- for(i=0;i<1024;i++)
+ int i, n_samples = 1024;
+ tbuf = calloc(n_samples, sizeof(int16_t));
+ for(i=0;i<n_samples;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
+ AVFilterSamples samples;
+ samples.n_samples = n_samples;
+ samples.data = tbuf;
+ samples.data_size = sizeof(int16_t);
+
+ AVFilterSamplesRef sample_buf;
+ sample_buf.samples = &samples;
+ sample_buf.sample_type = 10;
+ sample_buf.sample_rate = 128000;
/* avfilter context */
AVFilterContext * avfiltcont;
+ AVFilter *avfilt;
- AVFilter *avfilt=NULL, *filt2=NULL;
+ /*set up avfilter */
+ avfilt = &avfilter_af_null;
+ /* this should initialize the avfiltcont */
+ printf("Opening avfilter\n");
+ avfiltcont = avfilter_open(avfilt, "kevinfilter");
+ printf("avfilter_open done\n");
- avfilt = &avfilter_af_null;
+ /* Register filters*/
+ avfilter_register(avfilt);
- AVFilterPad *pad;
- avfilter_insert_inpad(0, avfiltcont, pad );
+ /* initialize the filters */
+ printf("Starting filter chain\n");
+ avfilter_init_filter(avfiltcont, NULL, NULL);
- avfiltcont = avfilter_open(avfilt, "kevinfilter");
+ printf("Alright, we got %i inputs and %i outputs\n",
+ avfiltcont->input_count,
+ avfiltcont->output_count);
- avfilter_register(avfilt);
- filt2 = avfilter_get_by_name("kevinfilter");
+ /* run the filter */
+ printf("Running filter chain\n");
+ /* FIXME: trying to run segfaults :(. didnt set up linking right, i think*/
+ avfilter_start_buffer(avfiltcont->inputs, &sample_buf);
+ //avfilter_start_buffer(AVFilterLink *link, AVFilterPicRef *picref);
- /*run buffer now*/
+ /* uninit things */
}
More information about the FFmpeg-soc
mailing list