[FFmpeg-soc] [soc]: r438 - in libavfilter: avfilter.c avfilter.h avfiltergraph.c avfiltergraph.h filter_test.c vf_crop.c vf_slicify.c vo_sdl.c vsrc_ppm.c

koorogi subversion at mplayerhq.hu
Sun Jul 15 18:45:50 CEST 2007


Author: koorogi
Date: Sun Jul 15 18:45:50 2007
New Revision: 438

Log:
Allow code to pass data to filters it creates.


Modified:
   libavfilter/avfilter.c
   libavfilter/avfilter.h
   libavfilter/avfiltergraph.c
   libavfilter/avfiltergraph.h
   libavfilter/filter_test.c
   libavfilter/vf_crop.c
   libavfilter/vf_slicify.c
   libavfilter/vo_sdl.c
   libavfilter/vsrc_ppm.c

Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c	(original)
+++ libavfilter/avfilter.c	Sun Jul 15 18:45:50 2007
@@ -337,12 +337,12 @@ AVFilterContext *avfilter_create_by_name
     return avfilter_create(filt, inst_name);
 }
 
-int avfilter_init_filter(AVFilterContext *filter, const char *args)
+int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)
 {
     int ret, i;
 
     if(filter->filter->init)
-        if((ret = filter->filter->init(filter, args))) return ret;
+        if((ret = filter->filter->init(filter, args, opaque))) return ret;
     return 0;
 }
 

Modified: libavfilter/avfilter.h
==============================================================================
--- libavfilter/avfilter.h	(original)
+++ libavfilter/avfilter.h	Sun Jul 15 18:45:50 2007
@@ -166,8 +166,10 @@ typedef struct
     /**
      * Filter initialization function.  Args contains the user-supplied
      * parameters.  FIXME: maybe an AVOption-based system would be better?
+     * opaque is data provided by the code requesting creation of the filter,
+     * and is used to pass data to the filter.
      */
-    int (*init)(AVFilterContext *ctx, const char *args);
+    int (*init)(AVFilterContext *ctx, const char *args, const void *opaque);
     void (*uninit)(AVFilterContext *ctx);
 
     const AVFilterPad *inputs;  /// NULL terminated list of inputs. NULL if none
@@ -220,7 +222,7 @@ AVFilter *avfilter_get_by_name(char *nam
 
 AVFilterContext *avfilter_create(AVFilter *filter, char *inst_name);
 AVFilterContext *avfilter_create_by_name(char *name, char *inst_name);
-int avfilter_init_filter(AVFilterContext *filter, const char *args);
+int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
 void avfilter_destroy(AVFilterContext *filter);
 
 int *avfilter_make_format_list(int len, ...);

Modified: libavfilter/avfiltergraph.c
==============================================================================
--- libavfilter/avfiltergraph.c	(original)
+++ libavfilter/avfiltergraph.c	Sun Jul 15 18:45:50 2007
@@ -56,7 +56,7 @@ void avfilter_graph_add_filter(AVFilterG
     graph->filters[graph->filter_count - 1] = filter;
 }
 
-static AVFilterContext *create_filter_with_args(const char *filt)
+static AVFilterContext *create_filter_with_args(const char *filt, void *opaque)
 {
     AVFilterContext *ret;
     char *filter = av_strdup(filt); /* copy - don't mangle the input string */
@@ -75,7 +75,7 @@ static AVFilterContext *create_filter_wi
            name, args ? args : "(none)");
 
     if((ret = avfilter_create_by_name(name, NULL))) {
-        if(avfilter_init_filter(ret, args)) {
+        if(avfilter_init_filter(ret, args, opaque)) {
             av_log(NULL, AV_LOG_ERROR, "error initializing filter!\n");
             avfilter_destroy(ret);
             goto fail;
@@ -90,14 +90,19 @@ fail:
 }
 
 int avfilter_graph_load_chain(AVFilterGraph *graph,
-                              unsigned count, char **filter_list,
+                              unsigned count, char **filter_list, void **opaque,
                               AVFilterContext **first, AVFilterContext **last)
 {
     unsigned i;
     AVFilterContext *filters[2] = {NULL,NULL};
 
     for(i = 0; i < count; i ++) {
-        if(!(filters[1] = create_filter_with_args(filter_list[i])))
+        void *op;
+
+        if(opaque) op = opaque[i];
+        else       op = NULL;
+
+        if(!(filters[1] = create_filter_with_args(filter_list[i], op)))
             goto fail;
         if(i == 0) {
             if(first) *first = filters[1];

Modified: libavfilter/avfiltergraph.h
==============================================================================
--- libavfilter/avfiltergraph.h	(original)
+++ libavfilter/avfiltergraph.h	Sun Jul 15 18:45:50 2007
@@ -55,6 +55,6 @@ void avfilter_graph_add_filter(AVFilterG
  * @return 0 on success.  -1 on error.
  */
 int avfilter_graph_load_chain(AVFilterGraph *graph,
-                              unsigned count, char **filter_list,
+                              unsigned count, char **filter_list, void **opaque,
                               AVFilterContext **first, AVFilterContext **last);
 #endif  /* FFMPEG_AVFILTER_H */

Modified: libavfilter/filter_test.c
==============================================================================
--- libavfilter/filter_test.c	(original)
+++ libavfilter/filter_test.c	Sun Jul 15 18:45:50 2007
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
 
     avfilter_init();
     graph = avfilter_create_graph();
-    if(avfilter_graph_load_chain(graph, argc - 1, argv + 1, NULL, &out) < 0)
+    if(avfilter_graph_load_chain(graph, argc - 1, argv + 1, NULL, NULL, &out) < 0)
         goto done;
 
     while(pts < 5000) {

Modified: libavfilter/vf_crop.c
==============================================================================
--- libavfilter/vf_crop.c	(original)
+++ libavfilter/vf_crop.c	Sun Jul 15 18:45:50 2007
@@ -30,7 +30,7 @@ typedef struct
     int cx, cy, cw, ch;
 } CropContext;
 
-static int init(AVFilterContext *ctx, const char *args)
+static int init(AVFilterContext *ctx, const char *args, const void *opaque)
 {
     CropContext *crop = ctx->priv;
 

Modified: libavfilter/vf_slicify.c
==============================================================================
--- libavfilter/vf_slicify.c	(original)
+++ libavfilter/vf_slicify.c	Sun Jul 15 18:45:50 2007
@@ -29,7 +29,7 @@ typedef struct {
     int vshift;     ///< chroma subsampling shift
 } SliceContext;
 
-static int init(AVFilterContext *ctx, const char *args)
+static int init(AVFilterContext *ctx, const char *args, const void *opaque)
 {
     SliceContext *slice = ctx->priv;
 

Modified: libavfilter/vo_sdl.c
==============================================================================
--- libavfilter/vo_sdl.c	(original)
+++ libavfilter/vo_sdl.c	Sun Jul 15 18:45:50 2007
@@ -31,7 +31,7 @@ typedef struct
     int64_t pts;
 } SDLContext;
 
-static int init(AVFilterContext *ctx, const char *args)
+static int init(AVFilterContext *ctx, const char *args, const void *opaque)
 {
     SDLContext *sdl = ctx->priv;
 

Modified: libavfilter/vsrc_ppm.c
==============================================================================
--- libavfilter/vsrc_ppm.c	(original)
+++ libavfilter/vsrc_ppm.c	Sun Jul 15 18:45:50 2007
@@ -29,7 +29,7 @@ typedef struct {
     AVFilterPicRef *pic;
 } PPMContext;
 
-static int init(AVFilterContext *ctx, const char *args)
+static int init(AVFilterContext *ctx, const char *args, const void *opaque)
 {
     PPMContext *ppm = ctx->priv;
     FILE *in;



More information about the FFmpeg-soc mailing list