yading@11
|
1 /*
|
yading@11
|
2 * Copyright (c) 2011 Anton Khirnov
|
yading@11
|
3 *
|
yading@11
|
4 * This file is part of Libav.
|
yading@11
|
5 *
|
yading@11
|
6 * Libav is free software; you can redistribute it and/or
|
yading@11
|
7 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
8 * License as published by the Free Software Foundation; either
|
yading@11
|
9 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
10 *
|
yading@11
|
11 * Libav is distributed in the hope that it will be useful,
|
yading@11
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
14 * Lesser General Public License for more details.
|
yading@11
|
15 *
|
yading@11
|
16 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
17 * License along with Libav; if not, write to the Free Software
|
yading@11
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
19 */
|
yading@11
|
20
|
yading@11
|
21 /*
|
yading@11
|
22 * enumerate avoptions and format them in texinfo format
|
yading@11
|
23 */
|
yading@11
|
24
|
yading@11
|
25 #include <string.h>
|
yading@11
|
26
|
yading@11
|
27 #include "libavformat/avformat.h"
|
yading@11
|
28 #include "libavcodec/avcodec.h"
|
yading@11
|
29 #include "libavutil/log.h"
|
yading@11
|
30 #include "libavutil/opt.h"
|
yading@11
|
31
|
yading@11
|
32 static void print_usage(void)
|
yading@11
|
33 {
|
yading@11
|
34 fprintf(stderr, "Usage: enum_options type\n"
|
yading@11
|
35 "type: format codec\n");
|
yading@11
|
36 exit(1);
|
yading@11
|
37 }
|
yading@11
|
38
|
yading@11
|
39 static void print_option(const AVClass *class, const AVOption *o)
|
yading@11
|
40 {
|
yading@11
|
41 printf("@item -%s @var{", o->name);
|
yading@11
|
42 switch (o->type) {
|
yading@11
|
43 case FF_OPT_TYPE_BINARY: printf("hexadecimal string"); break;
|
yading@11
|
44 case FF_OPT_TYPE_STRING: printf("string"); break;
|
yading@11
|
45 case FF_OPT_TYPE_INT:
|
yading@11
|
46 case FF_OPT_TYPE_INT64: printf("integer"); break;
|
yading@11
|
47 case FF_OPT_TYPE_FLOAT:
|
yading@11
|
48 case FF_OPT_TYPE_DOUBLE: printf("float"); break;
|
yading@11
|
49 case FF_OPT_TYPE_RATIONAL: printf("rational number"); break;
|
yading@11
|
50 case FF_OPT_TYPE_FLAGS: printf("flags"); break;
|
yading@11
|
51 default: printf("value"); break;
|
yading@11
|
52 }
|
yading@11
|
53 printf("} (@emph{");
|
yading@11
|
54
|
yading@11
|
55 if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) {
|
yading@11
|
56 printf("input");
|
yading@11
|
57 if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
|
yading@11
|
58 printf("/");
|
yading@11
|
59 }
|
yading@11
|
60 if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
|
yading@11
|
61 printf("output");
|
yading@11
|
62
|
yading@11
|
63 printf("})\n");
|
yading@11
|
64 if (o->help)
|
yading@11
|
65 printf("%s\n", o->help);
|
yading@11
|
66
|
yading@11
|
67 if (o->unit) {
|
yading@11
|
68 const AVOption *u = NULL;
|
yading@11
|
69 printf("\nPossible values:\n@table @samp\n");
|
yading@11
|
70
|
yading@11
|
71 while ((u = av_next_option(&class, u)))
|
yading@11
|
72 if (u->type == FF_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit))
|
yading@11
|
73 printf("@item %s\n%s\n", u->name, u->help ? u->help : "");
|
yading@11
|
74 printf("@end table\n");
|
yading@11
|
75 }
|
yading@11
|
76 }
|
yading@11
|
77
|
yading@11
|
78 static void show_opts(const AVClass *class)
|
yading@11
|
79 {
|
yading@11
|
80 const AVOption *o = NULL;
|
yading@11
|
81
|
yading@11
|
82 printf("@table @option\n");
|
yading@11
|
83 while ((o = av_next_option(&class, o)))
|
yading@11
|
84 if (o->type != FF_OPT_TYPE_CONST)
|
yading@11
|
85 print_option(class, o);
|
yading@11
|
86 printf("@end table\n");
|
yading@11
|
87 }
|
yading@11
|
88
|
yading@11
|
89 static void show_format_opts(void)
|
yading@11
|
90 {
|
yading@11
|
91 AVInputFormat *iformat = NULL;
|
yading@11
|
92 AVOutputFormat *oformat = NULL;
|
yading@11
|
93
|
yading@11
|
94 printf("@section Generic format AVOptions\n");
|
yading@11
|
95 show_opts(avformat_get_class());
|
yading@11
|
96
|
yading@11
|
97 printf("@section Format-specific AVOptions\n");
|
yading@11
|
98 while ((iformat = av_iformat_next(iformat))) {
|
yading@11
|
99 if (!iformat->priv_class)
|
yading@11
|
100 continue;
|
yading@11
|
101 printf("@subsection %s AVOptions\n", iformat->priv_class->class_name);
|
yading@11
|
102 show_opts(iformat->priv_class);
|
yading@11
|
103 }
|
yading@11
|
104 while ((oformat = av_oformat_next(oformat))) {
|
yading@11
|
105 if (!oformat->priv_class)
|
yading@11
|
106 continue;
|
yading@11
|
107 printf("@subsection %s AVOptions\n", oformat->priv_class->class_name);
|
yading@11
|
108 show_opts(oformat->priv_class);
|
yading@11
|
109 }
|
yading@11
|
110 }
|
yading@11
|
111
|
yading@11
|
112 static void show_codec_opts(void)
|
yading@11
|
113 {
|
yading@11
|
114 AVCodec *c = NULL;
|
yading@11
|
115
|
yading@11
|
116 printf("@section Generic codec AVOptions\n");
|
yading@11
|
117 show_opts(avcodec_get_class());
|
yading@11
|
118
|
yading@11
|
119 printf("@section Codec-specific AVOptions\n");
|
yading@11
|
120 while ((c = av_codec_next(c))) {
|
yading@11
|
121 if (!c->priv_class)
|
yading@11
|
122 continue;
|
yading@11
|
123 printf("@subsection %s AVOptions\n", c->priv_class->class_name);
|
yading@11
|
124 show_opts(c->priv_class);
|
yading@11
|
125 }
|
yading@11
|
126 }
|
yading@11
|
127
|
yading@11
|
128 int main(int argc, char **argv)
|
yading@11
|
129 {
|
yading@11
|
130 if (argc < 2)
|
yading@11
|
131 print_usage();
|
yading@11
|
132
|
yading@11
|
133 av_register_all();
|
yading@11
|
134
|
yading@11
|
135 if (!strcmp(argv[1], "format"))
|
yading@11
|
136 show_format_opts();
|
yading@11
|
137 else if (!strcmp(argv[1], "codec"))
|
yading@11
|
138 show_codec_opts();
|
yading@11
|
139 else
|
yading@11
|
140 print_usage();
|
yading@11
|
141
|
yading@11
|
142 return 0;
|
yading@11
|
143 }
|