[FFmpeg-soc] [soc]: r4709 - in afilters: Makefile.dummy af_null.c af_src.c dummy.c
kdub
subversion at mplayerhq.hu
Mon Jul 13 13:29:39 CEST 2009
Author: kdub
Date: Mon Jul 13 13:29:39 2009
New Revision: 4709
Log:
Separate the filters out from the application program
Added:
afilters/af_src.c
Modified:
afilters/Makefile.dummy
afilters/af_null.c
afilters/dummy.c
Modified: afilters/Makefile.dummy
==============================================================================
--- afilters/Makefile.dummy Mon Jul 13 10:34:33 2009 (r4708)
+++ afilters/Makefile.dummy Mon Jul 13 13:29:39 2009 (r4709)
@@ -1,3 +1,2 @@
-
all:
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 Jul 13 10:34:33 2009 (r4708)
+++ afilters/af_null.c Mon Jul 13 13:29:39 2009 (r4709)
@@ -18,8 +18,51 @@
/**
* @file libavfilter/vf_null.c
- * null filter
+ * null filter. used as an example, or for development
*/
+#include <stdio.h>
+#include "avfilter.h"
+static int filter(AVFilterLink *link, AVFilterBufferRef *sample_ref);
+
+typedef struct
+{
+ int history[100]; /*just an example */
+
+} af_null_priv_t;
+
+AVFilter avfilter_af_null =
+{
+ .name = "audio_null",
+
+ .priv_size = sizeof(af_null_priv_t),
+
+ .inputs = (AVFilterPad[]) {{ .name = "default",
+ .type = CODEC_TYPE_AUDIO,
+ .filter_buffer = filter },
+ { .name = NULL}},
+
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = CODEC_TYPE_AUDIO, },
+ { .name = NULL}},
+};
+
+
+static int filter(AVFilterLink *link, AVFilterBufferRef *sample_ref)
+{
+ av_log(0,0, "Filter buffer\n");
+ int num_samples = sample_ref->buffer->n_samples;
+ int i;
+
+ int16_t *data;
+ data = (int16_t*) sample_ref->buffer->data;
+ for (i=0; i < num_samples; i++)
+ {
+ data[i] = data[i] +1;
+ }
+
+ return 0;
+}
+
Added: afilters/af_src.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ afilters/af_src.c Mon Jul 13 13:29:39 2009 (r4709)
@@ -0,0 +1,108 @@
+#include <stdio.h>
+#include "avfilter.h"
+
+typedef struct
+{
+ int first_used;
+ int last_used;
+
+ AVFilterBufferRef buf_ref;
+
+} af_src_priv_t;
+
+static int av_asrc_buffer_add_samples(AVFilterContext *ctx,
+ AVFilterBufferRef * samples)
+{
+ printf("LOAD BYTES into SRC\n");
+ af_src_priv_t *priv;
+ priv = ctx->priv;
+
+ printf("last used: %i\n", priv->last_used);
+ /* find the last point in the buffer */
+ int first = priv->first_used;
+ int last = priv->last_used;
+
+ int attempted_load = samples->buffer->n_samples;
+ if (first <= last ) /* buffer has room */
+ {
+ if (attempted_load > priv->buf_ref.buffer->n_samples)
+ {
+ /* error */
+ printf("Error! not enough room\n");
+ return attempted_load - priv->buf_ref.buffer->n_samples;
+ }
+ memcpy(&priv->buf_ref.buffer->data[last] , samples->buffer->data, attempted_load);
+ priv->last_used = priv->last_used + attempted_load;
+ }
+
+
+ printf("<<<<<<<<Buffer State>>>>>>>>\n");
+ printf("First Used:\t%i\n",priv->first_used);
+ printf("Last Used:\t%i\n", priv->last_used);
+
+}
+
+static int dump_next(AVFilterLink *lnk, AVFilterBufferRef *sample_ref)
+{
+ printf("TAKE BYTES from SRC\n");
+
+ af_src_priv_t *priv;
+ priv = (af_src_priv_t*) lnk->src->priv;
+
+
+ printf("Link size is %i\n", lnk->link_size);
+
+// memcpy(sample_ref, priv->buf_ref.buffer , lnk->link_size);
+
+ /* move samples cursor to next fresh point */
+ priv->first_used = priv->first_used + lnk->link_size;
+
+ printf("<<<<<<<<Buffer State>>>>>>>>\n");
+ printf("First Used:\t%i\n",priv->first_used);
+ printf("Last Used:\t%i\n", priv->last_used);
+
+ printf("dumping buffer\n");
+ return 0;
+
+}
+
+
+static int src_buf_init (AVFilterContext *ctx,
+ const char *args, void *opaque)
+{
+ /* allocate a fixed size for the input buffer */
+ /* arbitrary value, will be modifiable */
+
+ printf("SRC BUF INIT\n");
+ af_src_priv_t *priv;
+ priv = ctx->priv;
+
+ priv->buf_ref.buffer = (AVFilterBuffer*) malloc(sizeof(AVFilterBuffer));
+
+ priv->buf_ref.buffer->n_samples = 1024;
+ priv->buf_ref.buffer->data = (int16_t *)
+ calloc(priv->buf_ref.buffer->n_samples, sizeof(int16_t));
+
+ priv->first_used = 0;
+ priv->last_used = 0;
+
+ return 0;
+}
+
+
+
+AVFilter avfilter_af_src =
+{
+ .name = "audio_src",
+
+ .priv_size = 0,
+
+ .init = src_buf_init,
+ .inputs = (AVFilterPad[]) {{.name = NULL}},
+ .outputs = (AVFilterPad[]) { {.name = "default",
+ .type = CODEC_TYPE_AUDIO,
+ .filter_buffer = dump_next},
+ {.name = NULL}}
+
+};
+
Modified: afilters/dummy.c
==============================================================================
--- afilters/dummy.c Mon Jul 13 10:34:33 2009 (r4708)
+++ afilters/dummy.c Mon Jul 13 13:29:39 2009 (r4709)
@@ -5,152 +5,8 @@
#include <stdio.h>
#include "avfilter.h"
-
-typedef struct
-{
- int history[100]; /*just an example */
-
-} af_null_priv_t;
-
-
-static int filter(AVFilterLink *link, AVFilterBufferRef *sample_ref)
-{
- av_log(0,0, "Filter buffer\n");
- int num_samples = sample_ref->buffer->n_samples;
- int i;
-
- int16_t *data;
- data = (int16_t*) sample_ref->buffer->data;
- for (i=0; i < num_samples; i++)
- {
- data[i] = data[i] +1;
- }
-
- return 0;
-}
-
-AVFilter avfilter_af_null =
-{
- .name = "audio_null",
-
- .priv_size = sizeof(af_null_priv_t),
-
- .inputs = (AVFilterPad[]) {{ .name = "default",
- .type = CODEC_TYPE_AUDIO,
- .filter_buffer = filter },
- { .name = NULL}},
-
- .outputs = (AVFilterPad[]) {{ .name = "default",
- .type = CODEC_TYPE_AUDIO, },
- { .name = NULL}},
-};
-
-
-typedef struct
-{
- int first_used;
- int last_used;
-
- AVFilterBufferRef buf_ref;
-
-} af_src_priv_t;
-
-static int av_asrc_buffer_add_samples(AVFilterContext *ctx,
- AVFilterBufferRef * samples)
-{
- printf("LOAD BYTES into SRC\n");
- af_src_priv_t *priv;
- priv = ctx->priv;
-
- printf("last used: %i\n", priv->last_used);
- /* find the last point in the buffer */
- int first = priv->first_used;
- int last = priv->last_used;
-
- int attempted_load = samples->buffer->n_samples;
- if (first <= last ) /* buffer has room */
- {
- if (attempted_load > priv->buf_ref.buffer->n_samples)
- {
- /* error */
- printf("Error! not enough room\n");
- return attempted_load - priv->buf_ref.buffer->n_samples;
- }
- memcpy(&priv->buf_ref.buffer->data[last] , samples->buffer->data, attempted_load);
- priv->last_used = priv->last_used + attempted_load;
- }
-
-
- printf("<<<<<<<<Buffer State>>>>>>>>\n");
- printf("First Used:\t%i\n",priv->first_used);
- printf("Last Used:\t%i\n", priv->last_used);
-
-}
-
-static int dump_next(AVFilterLink *lnk, AVFilterBufferRef *sample_ref)
-{
- printf("TAKE BYTES from SRC\n");
-
- af_src_priv_t *priv;
- priv = (af_src_priv_t*) lnk->src->priv;
-
-
- printf("Link size is %i\n", lnk->link_size);
-
-// memcpy(sample_ref, priv->buf_ref.buffer , lnk->link_size);
-
- /* move samples cursor to next fresh point */
- priv->first_used = priv->first_used + lnk->link_size;
-
- printf("<<<<<<<<Buffer State>>>>>>>>\n");
- printf("First Used:\t%i\n",priv->first_used);
- printf("Last Used:\t%i\n", priv->last_used);
-
- printf("dumping buffer\n");
- return 0;
-
-}
-
-
-static int src_buf_init (AVFilterContext *ctx,
- const char *args, void *opaque)
-{
- /* allocate a fixed size for the input buffer */
- /* arbitrary value, will be modifiable */
-
- printf("SRC BUF INIT\n");
- af_src_priv_t *priv;
- priv = ctx->priv;
-
- priv->buf_ref.buffer = (AVFilterBuffer*) malloc(sizeof(AVFilterBuffer));
-
- priv->buf_ref.buffer->n_samples = 1024;
- priv->buf_ref.buffer->data = (int16_t *)
- calloc(priv->buf_ref.buffer->n_samples, sizeof(int16_t));
-
- priv->first_used = 0;
- priv->last_used = 0;
-
- return 0;
-}
-
-
-
-AVFilter avfilter_af_src =
-{
- .name = "audio_src",
-
- .priv_size = 0,
-
- .init = src_buf_init,
- .inputs = (AVFilterPad[]) {{.name = NULL}},
- .outputs = (AVFilterPad[]) { {.name = "default",
- .type = CODEC_TYPE_AUDIO,
- .filter_buffer = dump_next},
- {.name = NULL}}
-
-};
-
+#include "af_src.c"
+#include "af_null.c"
#if 0
int dump_avfiltlink(AVFilterLink *link)
@@ -214,7 +70,6 @@ int main()
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;
@@ -268,7 +123,5 @@ int main()
/* run this link */
avfilter_filter_buffer(src_context->outputs[0], &sample_buf);
-
-
}
More information about the FFmpeg-soc
mailing list