graph2dot: fix printf format specifier
[libav.git] / tools / lavfi-showfiltfmts.c
CommitLineData
e34d5db5
SS
1/*
2 * Copyright (c) 2009 Stefano Sabatini
3 *
2912e87a 4 * This file is part of Libav.
e34d5db5 5 *
2912e87a 6 * Libav is free software; you can redistribute it and/or
e34d5db5
SS
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 *
2912e87a 11 * Libav is distributed in the hope that it will be useful,
e34d5db5
SS
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
2912e87a 17 * License along with Libav; if not, write to the Free Software
e34d5db5
SS
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavformat/avformat.h"
22#include "libavutil/pixdesc.h"
23#include "libavfilter/avfilter.h"
43c7a01e 24#include "libavfilter/formats.h"
e34d5db5
SS
25
26int main(int argc, char **argv)
27{
28 AVFilter *filter;
29 AVFilterContext *filter_ctx;
30 const char *filter_name;
31 const char *filter_args = NULL;
32 int i, j;
33
34 av_log_set_level(AV_LOG_DEBUG);
35
36 if (!argv[1]) {
37 fprintf(stderr, "Missing filter name as argument\n");
38 return 1;
39 }
40
41 filter_name = argv[1];
42 if (argv[2])
43 filter_args = argv[2];
44
45 avfilter_register_all();
46
47 /* get a corresponding filter and open it */
48 if (!(filter = avfilter_get_by_name(filter_name))) {
49 fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
50 return 1;
51 }
52
84c03869 53 if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
ffae713a 54 fprintf(stderr, "Impossible to open filter with name '%s'\n",
4e81b5f5 55 filter_name);
e34d5db5
SS
56 return 1;
57 }
58 if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
4e81b5f5
DB
59 fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
60 filter_name, filter_args);
e34d5db5
SS
61 return 1;
62 }
63
64 /* create a link for each of the input pads */
65 for (i = 0; i < filter_ctx->input_count; i++) {
c61f84bf
MR
66 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
67 link->type = filter_ctx->filter->inputs[i].type;
e34d5db5
SS
68 filter_ctx->inputs[i] = link;
69 }
70 for (i = 0; i < filter_ctx->output_count; i++) {
c61f84bf 71 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
a8542e43 72 link->type = filter_ctx->filter->outputs[i].type;
e34d5db5
SS
73 filter_ctx->outputs[i] = link;
74 }
75
76 if (filter->query_formats)
77 filter->query_formats(filter_ctx);
78 else
43c7a01e 79 ff_default_query_formats(filter_ctx);
e34d5db5
SS
80
81 /* print the supported formats in input */
82 for (i = 0; i < filter_ctx->input_count; i++) {
83 AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
e34d5db5 84 for (j = 0; j < fmts->format_count; j++)
27971664
MR
85 printf("INPUT[%d] %s: %s\n",
86 i, filter_ctx->filter->inputs[i].name,
87 av_pix_fmt_descriptors[fmts->formats[j]].name);
e34d5db5
SS
88 }
89
90 /* print the supported formats in output */
91 for (i = 0; i < filter_ctx->output_count; i++) {
92 AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
e34d5db5 93 for (j = 0; j < fmts->format_count; j++)
27971664
MR
94 printf("OUTPUT[%d] %s: %s\n",
95 i, filter_ctx->filter->outputs[i].name,
96 av_pix_fmt_descriptors[fmts->formats[j]].name);
e34d5db5
SS
97 }
98
24de0edb 99 avfilter_free(filter_ctx);
e34d5db5
SS
100 fflush(stdout);
101 return 0;
102}