2 * Copyright (c) 2011 Anton Khirnov
4 * This file is part of FFmpeg.
6 * FFmpeg 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.
11 * FFmpeg 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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * enumerate avoptions and format them in texinfo format
27 #include "libavformat/avformat.h"
28 #include "libavcodec/avcodec.h"
29 #include "libavutil/log.h"
30 #include "libavutil/opt.h"
32 static void print_usage(void)
34 fprintf(stderr
, "Usage: enum_options type\n"
35 "type: format codec\n");
39 static void print_option(const AVClass
*class, const AVOption
*o
)
41 printf("@item -%s @var{", o
->name
);
43 case AV_OPT_TYPE_BINARY
: printf("hexadecimal string"); break;
44 case AV_OPT_TYPE_STRING
: printf("string"); break;
46 case AV_OPT_TYPE_INT64
: printf("integer"); break;
47 case AV_OPT_TYPE_FLOAT
:
48 case AV_OPT_TYPE_DOUBLE
: printf("float"); break;
49 case AV_OPT_TYPE_RATIONAL
: printf("rational number"); break;
50 case AV_OPT_TYPE_FLAGS
: printf("flags"); break;
51 default: printf("value"); break;
55 if (o
->flags
& AV_OPT_FLAG_ENCODING_PARAM
) {
57 if (o
->flags
& AV_OPT_FLAG_ENCODING_PARAM
)
60 if (o
->flags
& AV_OPT_FLAG_ENCODING_PARAM
)
65 printf("%s\n", o
->help
);
68 const AVOption
*u
= NULL
;
69 printf("\nPossible values:\n@table @samp\n");
71 while ((u
= av_opt_next(&class, u
)))
72 if (u
->type
== AV_OPT_TYPE_CONST
&& u
->unit
&& !strcmp(u
->unit
, o
->unit
))
73 printf("@item %s\n%s\n", u
->name
, u
->help
? u
->help
: "");
74 printf("@end table\n");
78 static void show_opts(const AVClass
*class)
80 const AVOption
*o
= NULL
;
82 printf("@table @option\n");
83 while ((o
= av_opt_next(&class, o
)))
84 if (o
->type
!= AV_OPT_TYPE_CONST
)
85 print_option(class, o
);
86 printf("@end table\n");
89 static void show_format_opts(void)
91 const AVInputFormat
*iformat
= NULL
;
92 const AVOutputFormat
*oformat
= NULL
;
93 void *iformat_opaque
= NULL
;
94 void *oformat_opaque
= NULL
;
96 printf("@section Generic format AVOptions\n");
97 show_opts(avformat_get_class());
99 printf("@section Format-specific AVOptions\n");
100 while ((iformat
= av_demuxer_iterate(&iformat_opaque
))) {
101 if (!iformat
->priv_class
)
103 printf("@subsection %s AVOptions\n", iformat
->priv_class
->class_name
);
104 show_opts(iformat
->priv_class
);
106 while ((oformat
= av_muxer_iterate(&oformat_opaque
))) {
107 if (!oformat
->priv_class
)
109 printf("@subsection %s AVOptions\n", oformat
->priv_class
->class_name
);
110 show_opts(oformat
->priv_class
);
114 static void show_codec_opts(void)
119 printf("@section Generic codec AVOptions\n");
120 show_opts(avcodec_get_class());
122 printf("@section Codec-specific AVOptions\n");
123 while ((c
= av_codec_iterate(&iter
))) {
126 printf("@subsection %s AVOptions\n", c
->priv_class
->class_name
);
127 show_opts(c
->priv_class
);
131 int main(int argc
, char **argv
)
136 if (!strcmp(argv
[1], "format"))
138 else if (!strcmp(argv
[1], "codec"))