tizen 2.3 release
[framework/multimedia/ffmpeg.git] / doc / print_options.c
1 /*
2  * Copyright (c) 2012 Anton Khirnov
3  *
4  * This file is part of Libav.
5  *
6  * Libav 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  * Libav 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 Libav; 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 <string.h>
27 #include <float.h>
28
29 #include "libavformat/avformat.h"
30 #include "libavcodec/avcodec.h"
31 #include "libavutil/opt.h"
32
33 static void print_usage(void)
34 {
35     fprintf(stderr, "Usage: enum_options type\n"
36             "type: format codec\n");
37     exit(1);
38 }
39
40 static void print_option(const AVOption *opts, const AVOption *o, int per_stream)
41 {
42     printf("@item -%s%s @var{", o->name, per_stream ? "[:stream_specifier]" : "");
43     switch (o->type) {
44     case AV_OPT_TYPE_BINARY:   printf("hexadecimal string"); break;
45     case AV_OPT_TYPE_STRING:   printf("string");             break;
46     case AV_OPT_TYPE_INT:
47     case AV_OPT_TYPE_INT64:    printf("integer");            break;
48     case AV_OPT_TYPE_FLOAT:
49     case AV_OPT_TYPE_DOUBLE:   printf("float");              break;
50     case AV_OPT_TYPE_RATIONAL: printf("rational number");    break;
51     case AV_OPT_TYPE_FLAGS:    printf("flags");              break;
52     default:                   printf("value");              break;
53     }
54     printf("} (@emph{");
55
56     if (o->flags & AV_OPT_FLAG_DECODING_PARAM) {
57         printf("input");
58         if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
59             printf("/");
60     }
61     if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) printf("output");
62     if (o->flags & AV_OPT_FLAG_AUDIO_PARAM)    printf(",audio");
63     if (o->flags & AV_OPT_FLAG_VIDEO_PARAM)    printf(",video");
64     if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) printf(",subtitles");
65
66     printf("})\n");
67     if (o->help)
68         printf("%s\n", o->help);
69
70     if (o->unit) {
71         const AVOption *u;
72         printf("\nPossible values:\n@table @samp\n");
73
74         for (u = opts; u->name; u++) {
75             if (u->type == AV_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit))
76                 printf("@item %s\n%s\n", u->name, u->help ? u->help : "");
77         }
78         printf("@end table\n");
79     }
80 }
81
82 static void show_opts(const AVOption *opts, int per_stream)
83 {
84     const AVOption *o;
85
86     printf("@table @option\n");
87     for (o = opts; o->name; o++) {
88         if (o->type != AV_OPT_TYPE_CONST)
89             print_option(opts, o, per_stream);
90     }
91     printf("@end table\n");
92 }
93
94 static void show_format_opts(void)
95 {
96 #include "libavformat/options_table.h"
97
98     printf("@section Format AVOptions\n");
99     show_opts(options, 0);
100 }
101
102 static void show_codec_opts(void)
103 {
104 #include "libavcodec/options_table.h"
105
106     printf("@section Codec AVOptions\n");
107     show_opts(options, 1);
108 }
109
110 int main(int argc, char **argv)
111 {
112     if (argc < 2)
113         print_usage();
114
115     printf("@c DO NOT EDIT THIS FILE!\n"
116            "@c It was generated by print_options.\n\n");
117     if (!strcmp(argv[1], "format"))
118         show_format_opts();
119     else if (!strcmp(argv[1], "codec"))
120         show_codec_opts();
121     else
122         print_usage();
123
124     return 0;
125 }