FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
print_options.c
Go to the documentation of this file.
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 {
43  return;
44 
45  printf("@item -%s%s @var{", o->name, per_stream ? "[:stream_specifier]" : "");
46  switch (o->type) {
47  case AV_OPT_TYPE_BINARY: printf("hexadecimal string"); break;
48  case AV_OPT_TYPE_STRING: printf("string"); break;
49  case AV_OPT_TYPE_INT:
50  case AV_OPT_TYPE_INT64: printf("integer"); break;
51  case AV_OPT_TYPE_FLOAT:
52  case AV_OPT_TYPE_DOUBLE: printf("float"); break;
53  case AV_OPT_TYPE_RATIONAL: printf("rational number"); break;
54  case AV_OPT_TYPE_FLAGS: printf("flags"); break;
55  default: printf("value"); break;
56  }
57  printf("} (@emph{");
58 
60  printf("input");
62  printf("/");
63  }
64  if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) printf("output");
65  if (o->flags & AV_OPT_FLAG_AUDIO_PARAM) printf(",audio");
66  if (o->flags & AV_OPT_FLAG_VIDEO_PARAM) printf(",video");
67  if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) printf(",subtitles");
68 
69  printf("})\n");
70  if (o->help)
71  printf("%s\n", o->help);
72 
73  if (o->unit) {
74  const AVOption *u;
75  printf("\nPossible values:\n@table @samp\n");
76 
77  for (u = opts; u->name; u++) {
78  if (u->type == AV_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit))
79  printf("@item %s\n%s\n", u->name, u->help ? u->help : "");
80  }
81  printf("@end table\n");
82  }
83 }
84 
85 static void show_opts(const AVOption *opts, int per_stream)
86 {
87  const AVOption *o;
88 
89  printf("@table @option\n");
90  for (o = opts; o->name; o++) {
91  if (o->type != AV_OPT_TYPE_CONST)
92  print_option(opts, o, per_stream);
93  }
94  printf("@end table\n");
95 }
96 
97 static void show_format_opts(void)
98 {
100 
101  printf("@section Format AVOptions\n");
102  show_opts(options, 0);
103 }
104 
105 static void show_codec_opts(void)
106 {
108 
109  printf("@section Codec AVOptions\n");
110  show_opts(options, 1);
111 }
112 
113 int main(int argc, char **argv)
114 {
115  if (argc < 2)
116  print_usage();
117 
118  printf("@c DO NOT EDIT THIS FILE!\n"
119  "@c It was generated by print_options.\n\n");
120  if (!strcmp(argv[1], "format"))
122  else if (!strcmp(argv[1], "codec"))
123  show_codec_opts();
124  else
125  print_usage();
126 
127  return 0;
128 }