]> git.sesse.net Git - ffmpeg/blob - libavfilter/filtfmts.c
Remove pointless #undefs of previously forbidden functions.
[ffmpeg] / libavfilter / filtfmts.c
1 /*
2  * Copyright (c) 2009 Stefano Sabatini
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #include <stdio.h>
22
23 #include "libavformat/avformat.h"
24 #include "libavutil/pixdesc.h"
25 #include "libavfilter/avfilter.h"
26 #include "libavfilter/formats.h"
27
28 int main(int argc, char **argv)
29 {
30     AVFilter *filter;
31     AVFilterContext *filter_ctx;
32     const char *filter_name;
33     const char *filter_args = NULL;
34     int i, j;
35
36     av_log_set_level(AV_LOG_DEBUG);
37
38     if (!argv[1]) {
39         fprintf(stderr, "Missing filter name as argument\n");
40         return 1;
41     }
42
43     filter_name = argv[1];
44     if (argv[2])
45         filter_args = argv[2];
46
47     avfilter_register_all();
48
49     /* get a corresponding filter and open it */
50     if (!(filter = avfilter_get_by_name(filter_name))) {
51         fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
52         return 1;
53     }
54
55     if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
56         fprintf(stderr, "Impossible to open filter with name '%s'\n",
57                 filter_name);
58         return 1;
59     }
60     if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
61         fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
62                 filter_name, filter_args);
63         return 1;
64     }
65
66     /* create a link for each of the input pads */
67     for (i = 0; i < filter_ctx->input_count; i++) {
68         AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
69         link->type = filter_ctx->filter->inputs[i].type;
70         filter_ctx->inputs[i] = link;
71     }
72     for (i = 0; i < filter_ctx->output_count; i++) {
73         AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
74         link->type = filter_ctx->filter->outputs[i].type;
75         filter_ctx->outputs[i] = link;
76     }
77
78     if (filter->query_formats)
79         filter->query_formats(filter_ctx);
80     else
81         ff_default_query_formats(filter_ctx);
82
83     /* print the supported formats in input */
84     for (i = 0; i < filter_ctx->input_count; i++) {
85         AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
86         for (j = 0; j < fmts->format_count; j++)
87             printf("INPUT[%d] %s: %s\n",
88                    i, filter_ctx->filter->inputs[i].name,
89                    av_get_pix_fmt_name(fmts->formats[j]));
90     }
91
92     /* print the supported formats in output */
93     for (i = 0; i < filter_ctx->output_count; i++) {
94         AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
95         for (j = 0; j < fmts->format_count; j++)
96             printf("OUTPUT[%d] %s: %s\n",
97                    i, filter_ctx->filter->outputs[i].name,
98                    av_get_pix_fmt_name(fmts->formats[j]));
99     }
100
101     avfilter_free(filter_ctx);
102     fflush(stdout);
103     return 0;
104 }