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