Revision 037be76e

View differences:

doc/APIchanges
12 12

  
13 13

  
14 14
API changes, most recent first:
15
2010-12-02 - r25862 - lavfi 1.67.0 - avfilter_graph_create_filter()
16
  Add function avfilter_graph_create_filter() in avfiltergraph.h.
17

  
15 18
2010-11-25 - r25826 - lavfi 1.65.0 - avfilter_get_video_buffer_ref_from_arrays()
16 19
  Add function avfilter_get_video_buffer_ref_from_arrays() in
17 20
  avfilter.h.
ffmpeg.c
356 356

  
357 357
    graph = avfilter_graph_alloc();
358 358

  
359
    if ((ret = avfilter_open(&ist->input_video_filter, avfilter_get_by_name("buffer"), "src")) < 0)
360
        return ret;
361
    if ((ret = avfilter_open(&ist->output_video_filter, &ffsink, "out")) < 0)
362
        return ret;
363

  
364 359
    snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width,
365 360
             ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE);
366
    if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0)
361
    ret = avfilter_graph_create_filter(&ist->input_video_filter, avfilter_get_by_name("buffer"),
362
                                       "src", args, NULL, graph);
363
    if (ret < 0)
367 364
        return ret;
368
    if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &ffsink_ctx)) < 0)
365
    ret = avfilter_graph_create_filter(&ist->output_video_filter, &ffsink,
366
                                       "out", NULL, &ffsink_ctx, graph);
367
    if (ret < 0)
369 368
        return ret;
370

  
371
    /* add input and output filters to the overall graph */
372
    avfilter_graph_add_filter(graph, ist->input_video_filter);
373
    avfilter_graph_add_filter(graph, ist->output_video_filter);
374

  
375 369
    last_filter = ist->input_video_filter;
376 370

  
377 371
    if (codec->width  != icodec->width || codec->height != icodec->height) {
......
379 373
                 codec->width,
380 374
                 codec->height,
381 375
                 (int)av_get_int(sws_opts, "sws_flags", NULL));
382
        if ((ret = avfilter_open(&filter, avfilter_get_by_name("scale"), NULL)) < 0)
383
            return ret;
384
        if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
376
        if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
377
                                                NULL, args, NULL, graph)) < 0)
385 378
            return ret;
386 379
        if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
387 380
            return ret;
388 381
        last_filter = filter;
389
        avfilter_graph_add_filter(graph, last_filter);
390 382
    }
391 383

  
392 384
    snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL));
ffplay.c
1798 1798
    snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
1799 1799
    graph->scale_sws_opts = av_strdup(sws_flags_str);
1800 1800

  
1801
    if (avfilter_open(&filt_src, &input_filter,  "src") < 0) goto the_end;
1802
    if (avfilter_open(&filt_out, &ffsink      ,  "out") < 0) goto the_end;
1803

  
1804
    if(avfilter_init_filter(filt_src, NULL, is))             goto the_end;
1805
    if(avfilter_init_filter(filt_out, NULL, &ffsink_ctx))    goto the_end;
1806

  
1801
    if (avfilter_graph_create_filter(&filt_src, &input_filter, "src",
1802
                                     NULL, is, graph) < 0)
1803
        goto the_end;
1804
    if (avfilter_graph_create_filter(&filt_out, &ffsink, "out",
1805
                                     NULL, &ffsink_ctx, graph) < 0)
1806
        goto the_end;
1807 1807

  
1808 1808
    if(vfilters) {
1809 1809
        AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
......
1825 1825
    } else {
1826 1826
        if(avfilter_link(filt_src, 0, filt_out, 0) < 0)          goto the_end;
1827 1827
    }
1828
    avfilter_graph_add_filter(graph, filt_src);
1829
    avfilter_graph_add_filter(graph, filt_out);
1830 1828

  
1831 1829
    if (avfilter_graph_config(graph, NULL) < 0)
1832 1830
        goto the_end;
libavfilter/avfilter.h
25 25
#include "libavutil/avutil.h"
26 26

  
27 27
#define LIBAVFILTER_VERSION_MAJOR  1
28
#define LIBAVFILTER_VERSION_MINOR 66
28
#define LIBAVFILTER_VERSION_MINOR 67
29 29
#define LIBAVFILTER_VERSION_MICRO  0
30 30

  
31 31
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
libavfilter/avfiltergraph.c
53 53
    return 0;
54 54
}
55 55

  
56
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
57
                                 const char *name, const char *args, void *opaque,
58
                                 AVFilterGraph *graph_ctx)
59
{
60
    int ret;
61

  
62
    if ((ret = avfilter_open(filt_ctx, filt, name)) < 0)
63
        goto fail;
64
    if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0)
65
        goto fail;
66
    if ((ret = avfilter_graph_add_filter(graph_ctx, *filt_ctx)) < 0)
67
        goto fail;
68
    return 0;
69

  
70
fail:
71
    if (*filt_ctx)
72
        avfilter_free(*filt_ctx);
73
    *filt_ctx = NULL;
74
    return ret;
75
}
76

  
56 77
int ff_avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
57 78
{
58 79
    AVFilterContext *filt;
......
113 134

  
114 135
static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
115 136
{
116
    int i, j;
137
    int i, j, ret;
117 138
    int scaler_count = 0;
118 139
    char inst_name[30];
119 140

  
......
139 160
                    /* couldn't merge format lists. auto-insert scale filter */
140 161
                    snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d",
141 162
                             scaler_count++);
142
                    avfilter_open(&scale, avfilter_get_by_name("scale"), inst_name);
143

  
144 163
                    snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts);
145
                    if(!scale || scale->filter->init(scale, scale_args, NULL) ||
146
                                 avfilter_insert_filter(link, scale, 0, 0)) {
147
                        avfilter_free(scale);
148
                        return -1;
149
                    }
150

  
151
                    if (avfilter_graph_add_filter(graph, scale) < 0)
152
                        return -1;
164
                    if ((ret = avfilter_graph_create_filter(&scale, avfilter_get_by_name("scale"),
165
                                                            inst_name, scale_args, NULL, graph)) < 0)
166
                        return ret;
167
                    if ((ret = avfilter_insert_filter(link, scale, 0, 0)) < 0)
168
                        return ret;
153 169

  
154 170
                    scale->filter->query_formats(scale);
155 171
                    if (((link = scale-> inputs[0]) &&
libavfilter/avfiltergraph.h
53 53
int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
54 54

  
55 55
/**
56
 * Create and add a filter instance into an existing graph.
57
 * The filter instance is created from the filter filt and inited
58
 * with the parameters args and opaque.
59
 *
60
 * In case of success put in *filt_ctx the pointer to the created
61
 * filter instance, otherwise set *filt_ctx to NULL.
62
 *
63
 * @param name the instance name to give to the created filter instance
64
 * @param graph_ctx the filter graph
65
 * @return a negative AVERROR error code in case of failure, a non
66
 * negative value otherwise
67
 */
68
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
69
                                 const char *name, const char *args, void *opaque,
70
                                 AVFilterGraph *graph_ctx);
71

  
72
/**
56 73
 * Check validity and configure all the links and formats in the graph.
57 74
 *
58 75
 * @param graphctx the filter graph

Also available in: Unified diff