FFmpeg  4.0
print_options.c
Go to the documentation of this file.
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 
42 
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 {
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 
72  printf("input");
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");
113 }
114 
115 static void show_codec_opts(void)
116 {
117  printf("@section Codec AVOptions\n");
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"))
130  else if (!strcmp(argv[1], "codec"))
131  show_codec_opts();
132  else
133  print_usage();
134 
135  return 0;
136 }
AVOption.
Definition: opt.h:246
#define AV_OPT_FLAG_SUBTITLE_PARAM
Definition: opt.h:280
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:278
static const AVOption avcodec_options[]
Definition: options_table.h:44
Macro definitions for various function/variable attributes.
const char * name
Definition: opt.h:247
const char * help
short English help text
Definition: opt.h:253
AVOptions.
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:344
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:276
static const AVOption avformat_options[]
Definition: options_table.h:36
AVDictionary * opts
Definition: movenc.c:50
const char * unit
The logical unit to which the option belongs.
Definition: opt.h:299
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:229
int flags
Definition: opt.h:275
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:279
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:277
enum AVOptionType type
Definition: opt.h:260