[FFmpeg-cvslog] r12729 - in trunk/libavfilter: avfiltergraph.c avfiltergraph.h

vitor subversion
Fri Apr 4 22:08:35 CEST 2008


Author: vitor
Date: Fri Apr  4 22:08:34 2008
New Revision: 12729

Log:
Almost from scratch rewrite of filter parser.

Functional as is, but still work-in-progress in the
sense that some things need to be fixed before sending
it as a patch to SVN.

Commited in SoC by Vitor Sessak on 2008-03-20 21:48:30


Modified:
   trunk/libavfilter/avfiltergraph.c
   trunk/libavfilter/avfiltergraph.h

Modified: trunk/libavfilter/avfiltergraph.c
==============================================================================
--- trunk/libavfilter/avfiltergraph.c	(original)
+++ trunk/libavfilter/avfiltergraph.c	Fri Apr  4 22:08:34 2008
@@ -463,9 +463,7 @@ static void pick_formats(GraphContext *g
     for(i = 0; i < graph->filter_count; i ++) {
         AVFilterContext *filter = graph->filters[i];
 
-        if(filter->filter == &avfilter_vf_graph     ||
-           filter->filter == &avfilter_vf_graphfile ||
-           filter->filter == &avfilter_vf_graphdesc)
+        if(filter->filter == &avfilter_vf_graph)
             pick_formats(filter->priv);
 
         for(j = 0; j < filter->input_count; j ++)
@@ -498,30 +496,34 @@ static int graph_load_from_desc(AVFilter
     AVFilterContext *filt, *filtb;
 
     AVFilter *filterdef;
+    char tmp[20];
 
     /* create all filters */
     for(curfilt = desc->filters; curfilt; curfilt = curfilt->next) {
+        snprintf(tmp, 20, "%d", curfilt->index);
         if(!(filterdef = avfilter_get_by_name(curfilt->filter)) ||
-           !(filt = avfilter_open(filterdef, curfilt->name))) {
+           !(filt = avfilter_open(filterdef, tmp))) {
             av_log(ctx, AV_LOG_ERROR,
-               "error creating filter '%s'\n", curfilt->name);
+               "error creating filter '%s'\n", curfilt->filter);
             goto fail;
         }
         avfilter_graph_add_filter(ctx, filt);
         if(avfilter_init_filter(filt, curfilt->args, NULL)) {
             av_log(ctx, AV_LOG_ERROR,
-                "error initializing filter '%s'\n", curfilt->name);
+                "error initializing filter '%s'\n", curfilt->filter);
             goto fail;
         }
     }
 
     /* create all links */
     for(curlink = desc->links; curlink; curlink = curlink->next) {
-        if(!(filt = avfilter_graph_get_filter(ctx, curlink->src))) {
+        snprintf(tmp, 20, "%d", curlink->src);
+        if(!(filt = avfilter_graph_get_filter(ctx, tmp))) {
             av_log(ctx, AV_LOG_ERROR, "link source does not exist in graph\n");
             goto fail;
         }
-        if(!(filtb = avfilter_graph_get_filter(ctx, curlink->dst))) {
+        snprintf(tmp, 20, "%d", curlink->dst);
+        if(!(filtb = avfilter_graph_get_filter(ctx, tmp))) {
             av_log(ctx, AV_LOG_ERROR, "link destination does not exist in graph\n");
             goto fail;
         }
@@ -533,7 +535,8 @@ static int graph_load_from_desc(AVFilter
 
     /* export all input pads */
     for(curpad = desc->inputs; curpad; curpad = curpad->next) {
-        if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) {
+        snprintf(tmp, 20, "%d", curpad->filter);
+        if(!(filt = avfilter_graph_get_filter(ctx, tmp))) {
             av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n");
             goto fail;
         }
@@ -542,7 +545,8 @@ static int graph_load_from_desc(AVFilter
 
     /* export all output pads */
     for(curpad = desc->outputs; curpad; curpad = curpad->next) {
-        if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) {
+        snprintf(tmp, 20, "%d", curpad->filter);
+        if(!(filt = avfilter_graph_get_filter(ctx, tmp))) {
             av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n");
             goto fail;
         }
@@ -603,73 +607,3 @@ AVFilter avfilter_vf_graph =
     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
 };
 
-static int init_desc(AVFilterContext *ctx, const char *args, void *opaque)
-{
-    GraphContext *gctx = ctx->priv;
-
-    if(!opaque)
-        return -1;
-
-    if(!(gctx->link_filter_in = avfilter_open(&vf_graph_dummy, NULL)))
-        return -1;
-    if(avfilter_init_filter(gctx->link_filter_in, NULL, ctx))
-        goto fail;
-    if(!(gctx->link_filter_out = avfilter_open(&vf_graph_dummy, NULL)))
-        goto fail;
-    if(avfilter_init_filter(gctx->link_filter_out, NULL, ctx))
-        goto fail;
-
-    return graph_load_from_desc(ctx, opaque);
-
-fail:
-    avfilter_destroy(gctx->link_filter_in);
-    if(gctx->link_filter_out)
-        avfilter_destroy(gctx->link_filter_out);
-    return -1;
-}
-
-AVFilter avfilter_vf_graphdesc =
-{
-    .name      = "graph_desc",
-
-    .priv_size = sizeof(GraphContext),
-
-    .init      = init_desc,
-    .uninit    = uninit,
-
-    .query_formats = query_formats,
-
-    .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
-    .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
-};
-
-static int init_file(AVFilterContext *ctx, const char *args, void *opaque)
-{
-    AVFilterGraphDesc *desc;
-    int ret;
-
-    if(!args)
-        return -1;
-    if(!(desc = avfilter_graph_load_desc(args)))
-        return -1;
-
-    ret = init_desc(ctx, NULL, desc);
-    avfilter_graph_free_desc(desc);
-    return ret;
-}
-
-AVFilter avfilter_vf_graphfile =
-{
-    .name      = "graph_file",
-
-    .priv_size = sizeof(GraphContext),
-
-    .init      = init_file,
-    .uninit    = uninit,
-
-    .query_formats = query_formats,
-
-    .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
-    .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
-};
-

Modified: trunk/libavfilter/avfiltergraph.h
==============================================================================
--- trunk/libavfilter/avfiltergraph.h	(original)
+++ trunk/libavfilter/avfiltergraph.h	Fri Apr  4 22:08:34 2008
@@ -27,7 +27,7 @@
 /** Linked-list of filters to create for an AVFilterGraphDesc */
 typedef struct AVFilterGraphDescFilter
 {
-    char *name;             ///< filter instance name
+    int index;              ///< filter instance index
     char *filter;           ///< name of filter type
     char *args;             ///< filter parameters
     struct AVFilterGraphDescFilter *next;
@@ -37,10 +37,10 @@ typedef struct AVFilterGraphDescFilter
 typedef struct AVFilterGraphDescLink
 {
     /* TODO: allow referencing pads by name, not just by index */
-    char *src;              ///< name of the source filter
+    int src;                ///< index of the source filter
     unsigned srcpad;        ///< index of the output pad on the source filter
 
-    char *dst;              ///< name of the dest filter
+    int dst;                ///< index of the dest filter
     unsigned dstpad;        ///< index of the input pad on the dest filter
 
     struct AVFilterGraphDescLink *next;
@@ -51,7 +51,7 @@ typedef struct AVFilterGraphDescExport
 {
     /* TODO: allow referencing pads by name, not just by index */
     char *name;             ///< name of the exported pad
-    char *filter;           ///< name of the filter
+    int filter;             ///< index of the filter
     unsigned pad;           ///< index of the pad to be exported
 
     struct AVFilterGraphDescExport *next;




More information about the ffmpeg-cvslog mailing list