aarch64: Add assembly support for -fsanitize=hwaddress tagged globals.
[libav.git] / libavfilter / tests / filtfmts.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
7c29377b
MR
21#include <stdio.h>
22
072916d9 23#include "libavutil/mem.h"
e34d5db5 24#include "libavutil/pixdesc.h"
072916d9 25
e34d5db5 26#include "libavfilter/avfilter.h"
43c7a01e 27#include "libavfilter/formats.h"
e34d5db5
SS
28
29int main(int argc, char **argv)
30{
839010ac 31 const AVFilter *filter;
e34d5db5 32 AVFilterContext *filter_ctx;
6756d98c 33 AVFilterGraph *graph_ctx;
e34d5db5
SS
34 const char *filter_name;
35 const char *filter_args = NULL;
88d1fb4e 36 int i, j, ret = 0;
e34d5db5
SS
37
38 av_log_set_level(AV_LOG_DEBUG);
39
40 if (!argv[1]) {
41 fprintf(stderr, "Missing filter name as argument\n");
42 return 1;
43 }
44
45 filter_name = argv[1];
46 if (argv[2])
47 filter_args = argv[2];
48
6756d98c
VG
49 /* allocate graph */
50 graph_ctx = avfilter_graph_alloc();
51 if (!graph_ctx)
52 return 1;
53
e34d5db5
SS
54 avfilter_register_all();
55
56 /* get a corresponding filter and open it */
57 if (!(filter = avfilter_get_by_name(filter_name))) {
58 fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
59 return 1;
60 }
61
6756d98c
VG
62 /* open filter and add it to the graph */
63 if (!(filter_ctx = avfilter_graph_alloc_filter(graph_ctx, filter, filter_name))) {
ffae713a 64 fprintf(stderr, "Impossible to open filter with name '%s'\n",
4e81b5f5 65 filter_name);
e34d5db5
SS
66 return 1;
67 }
48a5adab 68 if (avfilter_init_str(filter_ctx, filter_args) < 0) {
4e81b5f5
DB
69 fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
70 filter_name, filter_args);
e34d5db5
SS
71 return 1;
72 }
73
74 /* create a link for each of the input pads */
e7399695 75 for (i = 0; i < filter_ctx->nb_inputs; i++) {
c61f84bf 76 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
88d1fb4e
HS
77 if (!link) {
78 fprintf(stderr, "Unable to allocate memory for filter input link\n");
79 ret = 1;
80 goto fail;
81 }
072916d9 82 link->type = avfilter_pad_get_type(filter_ctx->filter->inputs, i);
e34d5db5
SS
83 filter_ctx->inputs[i] = link;
84 }
e7399695 85 for (i = 0; i < filter_ctx->nb_outputs; i++) {
c61f84bf 86 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
88d1fb4e
HS
87 if (!link) {
88 fprintf(stderr, "Unable to allocate memory for filter output link\n");
89 ret = 1;
90 goto fail;
91 }
072916d9 92 link->type = avfilter_pad_get_type(filter_ctx->filter->outputs, i);
e34d5db5
SS
93 filter_ctx->outputs[i] = link;
94 }
95
96 if (filter->query_formats)
97 filter->query_formats(filter_ctx);
98 else
43c7a01e 99 ff_default_query_formats(filter_ctx);
e34d5db5
SS
100
101 /* print the supported formats in input */
e7399695 102 for (i = 0; i < filter_ctx->nb_inputs; i++) {
e34d5db5 103 AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
b01f6041 104 for (j = 0; j < fmts->nb_formats; j++)
27971664 105 printf("INPUT[%d] %s: %s\n",
072916d9 106 i, avfilter_pad_get_name(filter_ctx->filter->inputs, i),
59ee9f78 107 av_get_pix_fmt_name(fmts->formats[j]));
e34d5db5
SS
108 }
109
110 /* print the supported formats in output */
e7399695 111 for (i = 0; i < filter_ctx->nb_outputs; i++) {
e34d5db5 112 AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
b01f6041 113 for (j = 0; j < fmts->nb_formats; j++)
27971664 114 printf("OUTPUT[%d] %s: %s\n",
072916d9 115 i, avfilter_pad_get_name(filter_ctx->filter->outputs, i),
59ee9f78 116 av_get_pix_fmt_name(fmts->formats[j]));
e34d5db5
SS
117 }
118
88d1fb4e 119fail:
24de0edb 120 avfilter_free(filter_ctx);
6756d98c 121 avfilter_graph_free(&graph_ctx);
e34d5db5 122 fflush(stdout);
88d1fb4e 123 return ret;
e34d5db5 124}