[FFmpeg-soc] [soc]: r307 - in libavfilter: avfilter.c avfilter.h filter_test.c vf_crop.c vo_sdl.c
koorogi
subversion at mplayerhq.hu
Mon Jul 2 17:17:22 CEST 2007
Author: koorogi
Date: Mon Jul 2 17:17:22 2007
New Revision: 307
Log:
Support passing parameters to filters.
Modified:
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/filter_test.c
libavfilter/vf_crop.c
libavfilter/vo_sdl.c
Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c (original)
+++ libavfilter/avfilter.c Mon Jul 2 17:17:22 2007
@@ -257,12 +257,12 @@ AVFilterContext *avfilter_create_by_name
return avfilter_create(filt);
}
-int avfilter_init_filter(AVFilterContext *filter)
+int avfilter_init_filter(AVFilterContext *filter, const char *args)
{
int ret, i;
if(filter->filter->init)
- if((ret = filter->filter->init(filter))) return ret;
+ if((ret = filter->filter->init(filter, args))) return ret;
for(i = 0; i < pad_count(filter->filter->outputs); i ++)
if(filter->outputs[i])
filter->filter->outputs[i].set_video_props(filter->outputs[i]);
Modified: libavfilter/avfilter.h
==============================================================================
--- libavfilter/avfilter.h (original)
+++ libavfilter/avfilter.h Mon Jul 2 17:17:22 2007
@@ -149,7 +149,11 @@ typedef struct
int priv_size;
- int (*init)(AVFilterContext *ctx);
+ /**
+ * Filter initialization function. Args contains the user-supplied
+ * parameters. FIXME: maybe an AVOption-based system would be better?
+ */
+ int (*init)(AVFilterContext *ctx, const char *args);
void (*uninit)(AVFilterContext *ctx);
const AVFilterPad *inputs; /// NULL terminated list of inputs. NULL if none
@@ -199,7 +203,7 @@ AVFilter *avfilter_get_by_name(char *nam
AVFilterContext *avfilter_create(AVFilter *filter);
AVFilterContext *avfilter_create_by_name(char *name);
-int avfilter_init_filter(AVFilterContext *filter);
+int avfilter_init_filter(AVFilterContext *filter, const char *args);
void avfilter_destroy(AVFilterContext *filter);
#endif /* FFMPEG_AVFILTER_H */
Modified: libavfilter/filter_test.c
==============================================================================
--- libavfilter/filter_test.c (original)
+++ libavfilter/filter_test.c Mon Jul 2 17:17:22 2007
@@ -38,9 +38,9 @@ int main()
avfilter_link(src, 0, crop, 0);
avfilter_link(crop, 0, out, 0);
- avfilter_init_filter(src);
- avfilter_init_filter(crop);
- avfilter_init_filter(out);
+ avfilter_init_filter(src, NULL);
+ avfilter_init_filter(crop, "20:40:320:240");
+ avfilter_init_filter(out, NULL);
for(i = 0; i < 10; i ++) {
sdl_display(out);
Modified: libavfilter/vf_crop.c
==============================================================================
--- libavfilter/vf_crop.c (original)
+++ libavfilter/vf_crop.c Mon Jul 2 17:17:22 2007
@@ -29,7 +29,7 @@ typedef struct
int x, y, w, h;
} CropContext;
-static int init(AVFilterContext *ctx)
+static int init(AVFilterContext *ctx, const char *args)
{
CropContext *crop = ctx->priv;
@@ -38,10 +38,14 @@ static int init(AVFilterContext *ctx)
return -1;
}
- crop->x = 20;
- crop->y = 15;
- crop->w = 467;
- crop->h = 45;
+ /* default parameters */
+ crop->x = 0;
+ crop->y = 0;
+ crop->w = 640;
+ crop->h = 480;
+
+ if(args)
+ sscanf(args, "%d:%d:%d:%d", &crop->x, &crop->y, &crop->w, &crop->h);
return 0;
}
Modified: libavfilter/vo_sdl.c
==============================================================================
--- libavfilter/vo_sdl.c (original)
+++ libavfilter/vo_sdl.c Mon Jul 2 17:17:22 2007
@@ -30,7 +30,7 @@ typedef struct
SDL_Surface *surface;
} SDLContext;
-static int init(AVFilterContext *ctx)
+static int init(AVFilterContext *ctx, const char *args)
{
SDLContext *sdl = ctx->priv;
More information about the FFmpeg-soc
mailing list