blob: fd1cf10dc193a1c917a3276ada9261bd233e85e1
1 | /* |
2 | * Copyright (c) 2012 Anton Khirnov |
3 | * |
4 | * This file is part of FFmpeg. |
5 | * |
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. |
10 | * |
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. |
15 | * |
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 |
19 | */ |
20 | |
21 | /* |
22 | * generate texinfo manpages for avoptions |
23 | */ |
24 | |
25 | #include <stddef.h> |
26 | #include <stdio.h> |
27 | #include <string.h> |
28 | #include <float.h> |
29 | |
30 | // print_options is build for the host, os_support.h isn't needed and is setup |
31 | // for the target. without this build breaks on mingw |
32 | #define AVFORMAT_OS_SUPPORT_H |
33 | |
34 | #include "libavutil/attributes.h" |
35 | #include "libavutil/opt.h" |
36 | |
37 | /* Forcibly turn off deprecation warnings, which just add noise here. */ |
38 | #undef attribute_deprecated |
39 | #define attribute_deprecated |
40 | |
41 | #include "libavcodec/options_table.h" |
42 | |
43 | #include "libavformat/options_table.h" |
44 | |
45 | static void print_usage(void) |
46 | { |
47 | fprintf(stderr, "Usage: enum_options type\n" |
48 | "type: format codec\n"); |
49 | exit(1); |
50 | } |
51 | |
52 | static void print_option(const AVOption *opts, const AVOption *o, int per_stream) |
53 | { |
54 | if (!(o->flags & (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM))) |
55 | return; |
56 | |
57 | printf("@item -%s%s @var{", o->name, per_stream ? "[:stream_specifier]" : ""); |
58 | switch (o->type) { |
59 | case AV_OPT_TYPE_BINARY: printf("hexadecimal string"); break; |
60 | case AV_OPT_TYPE_STRING: printf("string"); break; |
61 | case AV_OPT_TYPE_INT: |
62 | case AV_OPT_TYPE_INT64: printf("integer"); break; |
63 | case AV_OPT_TYPE_FLOAT: |
64 | case AV_OPT_TYPE_DOUBLE: printf("float"); break; |
65 | case AV_OPT_TYPE_RATIONAL: printf("rational number"); break; |
66 | case AV_OPT_TYPE_FLAGS: printf("flags"); break; |
67 | default: printf("value"); break; |
68 | } |
69 | printf("} (@emph{"); |
70 | |
71 | if (o->flags & AV_OPT_FLAG_DECODING_PARAM) { |
72 | printf("input"); |
73 | if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) |
74 | printf("/"); |
75 | } |
76 | if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) printf("output"); |
77 | if (o->flags & AV_OPT_FLAG_AUDIO_PARAM) printf(",audio"); |
78 | if (o->flags & AV_OPT_FLAG_VIDEO_PARAM) printf(",video"); |
79 | if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) printf(",subtitles"); |
80 | |
81 | printf("})\n"); |
82 | if (o->help) |
83 | printf("%s\n", o->help); |
84 | |
85 | if (o->unit) { |
86 | const AVOption *u; |
87 | printf("\nPossible values:\n@table @samp\n"); |
88 | |
89 | for (u = opts; u->name; u++) { |
90 | if (u->type == AV_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit)) |
91 | printf("@item %s\n%s\n", u->name, u->help ? u->help : ""); |
92 | } |
93 | printf("@end table\n"); |
94 | } |
95 | } |
96 | |
97 | static void show_opts(const AVOption *opts, int per_stream) |
98 | { |
99 | const AVOption *o; |
100 | |
101 | printf("@table @option\n"); |
102 | for (o = opts; o->name; o++) { |
103 | if (o->type != AV_OPT_TYPE_CONST) |
104 | print_option(opts, o, per_stream); |
105 | } |
106 | printf("@end table\n"); |
107 | } |
108 | |
109 | static void show_format_opts(void) |
110 | { |
111 | printf("@section Format AVOptions\n"); |
112 | show_opts(avformat_options, 0); |
113 | } |
114 | |
115 | static void show_codec_opts(void) |
116 | { |
117 | printf("@section Codec AVOptions\n"); |
118 | show_opts(avcodec_options, 1); |
119 | } |
120 | |
121 | int main(int argc, char **argv) |
122 | { |
123 | if (argc < 2) |
124 | print_usage(); |
125 | |
126 | printf("@c DO NOT EDIT THIS FILE!\n" |
127 | "@c It was generated by print_options.\n\n"); |
128 | if (!strcmp(argv[1], "format")) |
129 | show_format_opts(); |
130 | else if (!strcmp(argv[1], "codec")) |
131 | show_codec_opts(); |
132 | else |
133 | print_usage(); |
134 | |
135 | return 0; |
136 | } |
137 |