]> git.sesse.net Git - ffmpeg/blob - libavfilter/filtfmts.c
x86: h264dsp: Fix linking with yasm and optimizations disabled
[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 #undef fprintf
29 #undef printf
30
31 int main(int argc, char **argv)
32 {
33     AVFilter *filter;
34     AVFilterContext *filter_ctx;
35     const char *filter_name;
36     const char *filter_args = NULL;
37     int i, j;
38
39     av_log_set_level(AV_LOG_DEBUG);
40
41     if (!argv[1]) {
42         fprintf(stderr, "Missing filter name as argument\n");
43         return 1;
44     }
45
46     filter_name = argv[1];
47     if (argv[2])
48         filter_args = argv[2];
49
50     avfilter_register_all();
51
52     /* get a corresponding filter and open it */
53     if (!(filter = avfilter_get_by_name(filter_name))) {
54         fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
55         return 1;
56     }
57
58     if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
59         fprintf(stderr, "Impossible to open filter with name '%s'\n",
60                 filter_name);
61         return 1;
62     }
63     if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
64         fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
65                 filter_name, filter_args);
66         return 1;
67     }
68
69     /* create a link for each of the input pads */
70     for (i = 0; i < filter_ctx->input_count; i++) {
71         AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
72         link->type = filter_ctx->filter->inputs[i].type;
73         filter_ctx->inputs[i] = link;
74     }
75     for (i = 0; i < filter_ctx->output_count; i++) {
76         AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
77         link->type = filter_ctx->filter->outputs[i].type;
78         filter_ctx->outputs[i] = link;
79     }
80
81     if (filter->query_formats)
82         filter->query_formats(filter_ctx);
83     else
84         ff_default_query_formats(filter_ctx);
85
86     /* print the supported formats in input */
87     for (i = 0; i < filter_ctx->input_count; i++) {
88         AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
89         for (j = 0; j < fmts->format_count; j++)
90             printf("INPUT[%d] %s: %s\n",
91                    i, filter_ctx->filter->inputs[i].name,
92                    av_get_pix_fmt_name(fmts->formats[j]));
93     }
94
95     /* print the supported formats in output */
96     for (i = 0; i < filter_ctx->output_count; i++) {
97         AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
98         for (j = 0; j < fmts->format_count; j++)
99             printf("OUTPUT[%d] %s: %s\n",
100                    i, filter_ctx->filter->outputs[i].name,
101                    av_get_pix_fmt_name(fmts->formats[j]));
102     }
103
104     avfilter_free(filter_ctx);
105     fflush(stdout);
106     return 0;
107 }