yading@10
|
1 /*
|
yading@10
|
2 * Various utilities for command line tools
|
yading@10
|
3 * copyright (c) 2003 Fabrice Bellard
|
yading@10
|
4 *
|
yading@10
|
5 * This file is part of FFmpeg.
|
yading@10
|
6 *
|
yading@10
|
7 * FFmpeg is free software; you can redistribute it and/or
|
yading@10
|
8 * modify it under the terms of the GNU Lesser General Public
|
yading@10
|
9 * License as published by the Free Software Foundation; either
|
yading@10
|
10 * version 2.1 of the License, or (at your option) any later version.
|
yading@10
|
11 *
|
yading@10
|
12 * FFmpeg is distributed in the hope that it will be useful,
|
yading@10
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@10
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@10
|
15 * Lesser General Public License for more details.
|
yading@10
|
16 *
|
yading@10
|
17 * You should have received a copy of the GNU Lesser General Public
|
yading@10
|
18 * License along with FFmpeg; if not, write to the Free Software
|
yading@10
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@10
|
20 */
|
yading@10
|
21
|
yading@10
|
22 #ifndef FFMPEG_CMDUTILS_H
|
yading@10
|
23 #define FFMPEG_CMDUTILS_H
|
yading@10
|
24
|
yading@10
|
25 #include <stdint.h>
|
yading@10
|
26
|
yading@10
|
27 #include "libavcodec/avcodec.h"
|
yading@10
|
28 #include "libavfilter/avfilter.h"
|
yading@10
|
29 #include "libavformat/avformat.h"
|
yading@10
|
30 #include "libswscale/swscale.h"
|
yading@10
|
31
|
yading@10
|
32 #ifdef __MINGW32__
|
yading@10
|
33 #undef main /* We don't want SDL to override our main() */
|
yading@10
|
34 #endif
|
yading@10
|
35
|
yading@10
|
36 /**
|
yading@10
|
37 * program name, defined by the program for show_version().
|
yading@10
|
38 */
|
yading@10
|
39 extern const char program_name[];
|
yading@10
|
40
|
yading@10
|
41 /**
|
yading@10
|
42 * program birth year, defined by the program for show_banner()
|
yading@10
|
43 */
|
yading@10
|
44 extern const int program_birth_year;
|
yading@10
|
45
|
yading@10
|
46 /**
|
yading@10
|
47 * this year, defined by the program for show_banner()
|
yading@10
|
48 */
|
yading@10
|
49 extern const int this_year;
|
yading@10
|
50
|
yading@10
|
51 extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
yading@10
|
52 extern AVFormatContext *avformat_opts;
|
yading@10
|
53 extern struct SwsContext *sws_opts;
|
yading@10
|
54 extern AVDictionary *swr_opts;
|
yading@10
|
55 extern AVDictionary *format_opts, *codec_opts, *resample_opts;
|
yading@10
|
56
|
yading@10
|
57 /**
|
yading@10
|
58 * Initialize the cmdutils option system, in particular
|
yading@10
|
59 * allocate the *_opts contexts.
|
yading@10
|
60 */
|
yading@10
|
61 void init_opts(void);
|
yading@10
|
62 /**
|
yading@10
|
63 * Uninitialize the cmdutils option system, in particular
|
yading@10
|
64 * free the *_opts contexts and their contents.
|
yading@10
|
65 */
|
yading@10
|
66 void uninit_opts(void);
|
yading@10
|
67
|
yading@10
|
68 /**
|
yading@10
|
69 * Trivial log callback.
|
yading@10
|
70 * Only suitable for opt_help and similar since it lacks prefix handling.
|
yading@10
|
71 */
|
yading@10
|
72 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
|
yading@10
|
73
|
yading@10
|
74 /**
|
yading@10
|
75 * Fallback for options that are not explicitly handled, these will be
|
yading@10
|
76 * parsed through AVOptions.
|
yading@10
|
77 */
|
yading@10
|
78 int opt_default(void *optctx, const char *opt, const char *arg);
|
yading@10
|
79
|
yading@10
|
80 /**
|
yading@10
|
81 * Set the libav* libraries log level.
|
yading@10
|
82 */
|
yading@10
|
83 int opt_loglevel(void *optctx, const char *opt, const char *arg);
|
yading@10
|
84
|
yading@10
|
85 int opt_report(const char *opt);
|
yading@10
|
86
|
yading@10
|
87 int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
yading@10
|
88
|
yading@10
|
89 int opt_cpuflags(void *optctx, const char *opt, const char *arg);
|
yading@10
|
90
|
yading@10
|
91 int opt_codec_debug(void *optctx, const char *opt, const char *arg);
|
yading@10
|
92
|
yading@10
|
93 int opt_opencl(void *optctx, const char *opt, const char *arg);
|
yading@10
|
94
|
yading@10
|
95 /**
|
yading@10
|
96 * Limit the execution time.
|
yading@10
|
97 */
|
yading@10
|
98 int opt_timelimit(void *optctx, const char *opt, const char *arg);
|
yading@10
|
99
|
yading@10
|
100 /**
|
yading@10
|
101 * Parse a string and return its corresponding value as a double.
|
yading@10
|
102 * Exit from the application if the string cannot be correctly
|
yading@10
|
103 * parsed or the corresponding value is invalid.
|
yading@10
|
104 *
|
yading@10
|
105 * @param context the context of the value to be set (e.g. the
|
yading@10
|
106 * corresponding command line option name)
|
yading@10
|
107 * @param numstr the string to be parsed
|
yading@10
|
108 * @param type the type (OPT_INT64 or OPT_FLOAT) as which the
|
yading@10
|
109 * string should be parsed
|
yading@10
|
110 * @param min the minimum valid accepted value
|
yading@10
|
111 * @param max the maximum valid accepted value
|
yading@10
|
112 */
|
yading@10
|
113 double parse_number_or_die(const char *context, const char *numstr, int type,
|
yading@10
|
114 double min, double max);
|
yading@10
|
115
|
yading@10
|
116 /**
|
yading@10
|
117 * Parse a string specifying a time and return its corresponding
|
yading@10
|
118 * value as a number of microseconds. Exit from the application if
|
yading@10
|
119 * the string cannot be correctly parsed.
|
yading@10
|
120 *
|
yading@10
|
121 * @param context the context of the value to be set (e.g. the
|
yading@10
|
122 * corresponding command line option name)
|
yading@10
|
123 * @param timestr the string to be parsed
|
yading@10
|
124 * @param is_duration a flag which tells how to interpret timestr, if
|
yading@10
|
125 * not zero timestr is interpreted as a duration, otherwise as a
|
yading@10
|
126 * date
|
yading@10
|
127 *
|
yading@10
|
128 * @see av_parse_time()
|
yading@10
|
129 */
|
yading@10
|
130 int64_t parse_time_or_die(const char *context, const char *timestr,
|
yading@10
|
131 int is_duration);
|
yading@10
|
132
|
yading@10
|
133 typedef struct SpecifierOpt {
|
yading@10
|
134 char *specifier; /**< stream/chapter/program/... specifier */
|
yading@10
|
135 union {
|
yading@10
|
136 uint8_t *str;
|
yading@10
|
137 int i;
|
yading@10
|
138 int64_t i64;
|
yading@10
|
139 float f;
|
yading@10
|
140 double dbl;
|
yading@10
|
141 } u;
|
yading@10
|
142 } SpecifierOpt;
|
yading@10
|
143
|
yading@10
|
144 typedef struct OptionDef {
|
yading@10
|
145 const char *name;
|
yading@10
|
146 int flags;
|
yading@10
|
147 #define HAS_ARG 0x0001
|
yading@10
|
148 #define OPT_BOOL 0x0002
|
yading@10
|
149 #define OPT_EXPERT 0x0004
|
yading@10
|
150 #define OPT_STRING 0x0008
|
yading@10
|
151 #define OPT_VIDEO 0x0010
|
yading@10
|
152 #define OPT_AUDIO 0x0020
|
yading@10
|
153 #define OPT_INT 0x0080
|
yading@10
|
154 #define OPT_FLOAT 0x0100
|
yading@10
|
155 #define OPT_SUBTITLE 0x0200
|
yading@10
|
156 #define OPT_INT64 0x0400
|
yading@10
|
157 #define OPT_EXIT 0x0800
|
yading@10
|
158 #define OPT_DATA 0x1000
|
yading@10
|
159 #define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only).
|
yading@10
|
160 implied by OPT_OFFSET or OPT_SPEC */
|
yading@10
|
161 #define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */
|
yading@10
|
162 #define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt.
|
yading@10
|
163 Implies OPT_OFFSET. Next element after the offset is
|
yading@10
|
164 an int containing element count in the array. */
|
yading@10
|
165 #define OPT_TIME 0x10000
|
yading@10
|
166 #define OPT_DOUBLE 0x20000
|
yading@10
|
167 #define OPT_INPUT 0x40000
|
yading@10
|
168 #define OPT_OUTPUT 0x80000
|
yading@10
|
169 union {
|
yading@10
|
170 void *dst_ptr;
|
yading@10
|
171 int (*func_arg)(void *, const char *, const char *);
|
yading@10
|
172 size_t off;
|
yading@10
|
173 } u;
|
yading@10
|
174 const char *help;
|
yading@10
|
175 const char *argname;
|
yading@10
|
176 } OptionDef;
|
yading@10
|
177
|
yading@10
|
178 /**
|
yading@10
|
179 * Print help for all options matching specified flags.
|
yading@10
|
180 *
|
yading@10
|
181 * @param options a list of options
|
yading@10
|
182 * @param msg title of this group. Only printed if at least one option matches.
|
yading@10
|
183 * @param req_flags print only options which have all those flags set.
|
yading@10
|
184 * @param rej_flags don't print options which have any of those flags set.
|
yading@10
|
185 * @param alt_flags print only options that have at least one of those flags set
|
yading@10
|
186 */
|
yading@10
|
187 void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
yading@10
|
188 int rej_flags, int alt_flags);
|
yading@10
|
189
|
yading@10
|
190 /**
|
yading@10
|
191 * Show help for all options with given flags in class and all its
|
yading@10
|
192 * children.
|
yading@10
|
193 */
|
yading@10
|
194 void show_help_children(const AVClass *class, int flags);
|
yading@10
|
195
|
yading@10
|
196 /**
|
yading@10
|
197 * Per-fftool specific help handler. Implemented in each
|
yading@10
|
198 * fftool, called by show_help().
|
yading@10
|
199 */
|
yading@10
|
200 void show_help_default(const char *opt, const char *arg);
|
yading@10
|
201
|
yading@10
|
202 /**
|
yading@10
|
203 * Generic -h handler common to all fftools.
|
yading@10
|
204 */
|
yading@10
|
205 int show_help(void *optctx, const char *opt, const char *arg);
|
yading@10
|
206
|
yading@10
|
207 /**
|
yading@10
|
208 * Parse the command line arguments.
|
yading@10
|
209 *
|
yading@10
|
210 * @param optctx an opaque options context
|
yading@10
|
211 * @param argc number of command line arguments
|
yading@10
|
212 * @param argv values of command line arguments
|
yading@10
|
213 * @param options Array with the definitions required to interpret every
|
yading@10
|
214 * option of the form: -option_name [argument]
|
yading@10
|
215 * @param parse_arg_function Name of the function called to process every
|
yading@10
|
216 * argument without a leading option name flag. NULL if such arguments do
|
yading@10
|
217 * not have to be processed.
|
yading@10
|
218 */
|
yading@10
|
219 void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
|
yading@10
|
220 void (* parse_arg_function)(void *optctx, const char*));
|
yading@10
|
221
|
yading@10
|
222 /**
|
yading@10
|
223 * Parse one given option.
|
yading@10
|
224 *
|
yading@10
|
225 * @return on success 1 if arg was consumed, 0 otherwise; negative number on error
|
yading@10
|
226 */
|
yading@10
|
227 int parse_option(void *optctx, const char *opt, const char *arg,
|
yading@10
|
228 const OptionDef *options);
|
yading@10
|
229
|
yading@10
|
230 /**
|
yading@10
|
231 * An option extracted from the commandline.
|
yading@10
|
232 * Cannot use AVDictionary because of options like -map which can be
|
yading@10
|
233 * used multiple times.
|
yading@10
|
234 */
|
yading@10
|
235 typedef struct Option {
|
yading@10
|
236 const OptionDef *opt;
|
yading@10
|
237 const char *key;
|
yading@10
|
238 const char *val;
|
yading@10
|
239 } Option;
|
yading@10
|
240
|
yading@10
|
241 typedef struct OptionGroupDef {
|
yading@10
|
242 /**< group name */
|
yading@10
|
243 const char *name;
|
yading@10
|
244 /**
|
yading@10
|
245 * Option to be used as group separator. Can be NULL for groups which
|
yading@10
|
246 * are terminated by a non-option argument (e.g. ffmpeg output files)
|
yading@10
|
247 */
|
yading@10
|
248 const char *sep;
|
yading@10
|
249 /**
|
yading@10
|
250 * Option flags that must be set on each option that is
|
yading@10
|
251 * applied to this group
|
yading@10
|
252 */
|
yading@10
|
253 int flags;
|
yading@10
|
254 } OptionGroupDef;
|
yading@10
|
255
|
yading@10
|
256 typedef struct OptionGroup {
|
yading@10
|
257 const OptionGroupDef *group_def;
|
yading@10
|
258 const char *arg;
|
yading@10
|
259
|
yading@10
|
260 Option *opts;
|
yading@10
|
261 int nb_opts;
|
yading@10
|
262
|
yading@10
|
263 AVDictionary *codec_opts;
|
yading@10
|
264 AVDictionary *format_opts;
|
yading@10
|
265 AVDictionary *resample_opts;
|
yading@10
|
266 struct SwsContext *sws_opts;
|
yading@10
|
267 AVDictionary *swr_opts;
|
yading@10
|
268 } OptionGroup;
|
yading@10
|
269
|
yading@10
|
270 /**
|
yading@10
|
271 * A list of option groups that all have the same group type
|
yading@10
|
272 * (e.g. input files or output files)
|
yading@10
|
273 */
|
yading@10
|
274 typedef struct OptionGroupList {
|
yading@10
|
275 const OptionGroupDef *group_def;
|
yading@10
|
276
|
yading@10
|
277 OptionGroup *groups;
|
yading@10
|
278 int nb_groups;
|
yading@10
|
279 } OptionGroupList;
|
yading@10
|
280
|
yading@10
|
281 typedef struct OptionParseContext {
|
yading@10
|
282 OptionGroup global_opts;
|
yading@10
|
283
|
yading@10
|
284 OptionGroupList *groups;
|
yading@10
|
285 int nb_groups;
|
yading@10
|
286
|
yading@10
|
287 /* parsing state */
|
yading@10
|
288 OptionGroup cur_group;
|
yading@10
|
289 } OptionParseContext;
|
yading@10
|
290
|
yading@10
|
291 /**
|
yading@10
|
292 * Parse an options group and write results into optctx.
|
yading@10
|
293 *
|
yading@10
|
294 * @param optctx an app-specific options context. NULL for global options group
|
yading@10
|
295 */
|
yading@10
|
296 int parse_optgroup(void *optctx, OptionGroup *g);
|
yading@10
|
297
|
yading@10
|
298 /**
|
yading@10
|
299 * Split the commandline into an intermediate form convenient for further
|
yading@10
|
300 * processing.
|
yading@10
|
301 *
|
yading@10
|
302 * The commandline is assumed to be composed of options which either belong to a
|
yading@10
|
303 * group (those with OPT_SPEC, OPT_OFFSET or OPT_PERFILE) or are global
|
yading@10
|
304 * (everything else).
|
yading@10
|
305 *
|
yading@10
|
306 * A group (defined by an OptionGroupDef struct) is a sequence of options
|
yading@10
|
307 * terminated by either a group separator option (e.g. -i) or a parameter that
|
yading@10
|
308 * is not an option (doesn't start with -). A group without a separator option
|
yading@10
|
309 * must always be first in the supplied groups list.
|
yading@10
|
310 *
|
yading@10
|
311 * All options within the same group are stored in one OptionGroup struct in an
|
yading@10
|
312 * OptionGroupList, all groups with the same group definition are stored in one
|
yading@10
|
313 * OptionGroupList in OptionParseContext.groups. The order of group lists is the
|
yading@10
|
314 * same as the order of group definitions.
|
yading@10
|
315 */
|
yading@10
|
316 int split_commandline(OptionParseContext *octx, int argc, char *argv[],
|
yading@10
|
317 const OptionDef *options,
|
yading@10
|
318 const OptionGroupDef *groups, int nb_groups);
|
yading@10
|
319
|
yading@10
|
320 /**
|
yading@10
|
321 * Free all allocated memory in an OptionParseContext.
|
yading@10
|
322 */
|
yading@10
|
323 void uninit_parse_context(OptionParseContext *octx);
|
yading@10
|
324
|
yading@10
|
325 /**
|
yading@10
|
326 * Find the '-loglevel' option in the command line args and apply it.
|
yading@10
|
327 */
|
yading@10
|
328 void parse_loglevel(int argc, char **argv, const OptionDef *options);
|
yading@10
|
329
|
yading@10
|
330 /**
|
yading@10
|
331 * Return index of option opt in argv or 0 if not found.
|
yading@10
|
332 */
|
yading@10
|
333 int locate_option(int argc, char **argv, const OptionDef *options,
|
yading@10
|
334 const char *optname);
|
yading@10
|
335
|
yading@10
|
336 /**
|
yading@10
|
337 * Check if the given stream matches a stream specifier.
|
yading@10
|
338 *
|
yading@10
|
339 * @param s Corresponding format context.
|
yading@10
|
340 * @param st Stream from s to be checked.
|
yading@10
|
341 * @param spec A stream specifier of the [v|a|s|d]:[\<stream index\>] form.
|
yading@10
|
342 *
|
yading@10
|
343 * @return 1 if the stream matches, 0 if it doesn't, <0 on error
|
yading@10
|
344 */
|
yading@10
|
345 int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
|
yading@10
|
346
|
yading@10
|
347 /**
|
yading@10
|
348 * Filter out options for given codec.
|
yading@10
|
349 *
|
yading@10
|
350 * Create a new options dictionary containing only the options from
|
yading@10
|
351 * opts which apply to the codec with ID codec_id.
|
yading@10
|
352 *
|
yading@10
|
353 * @param opts dictionary to place options in
|
yading@10
|
354 * @param codec_id ID of the codec that should be filtered for
|
yading@10
|
355 * @param s Corresponding format context.
|
yading@10
|
356 * @param st A stream from s for which the options should be filtered.
|
yading@10
|
357 * @param codec The particular codec for which the options should be filtered.
|
yading@10
|
358 * If null, the default one is looked up according to the codec id.
|
yading@10
|
359 * @return a pointer to the created dictionary
|
yading@10
|
360 */
|
yading@10
|
361 AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
|
yading@10
|
362 AVFormatContext *s, AVStream *st, AVCodec *codec);
|
yading@10
|
363
|
yading@10
|
364 /**
|
yading@10
|
365 * Setup AVCodecContext options for avformat_find_stream_info().
|
yading@10
|
366 *
|
yading@10
|
367 * Create an array of dictionaries, one dictionary for each stream
|
yading@10
|
368 * contained in s.
|
yading@10
|
369 * Each dictionary will contain the options from codec_opts which can
|
yading@10
|
370 * be applied to the corresponding stream codec context.
|
yading@10
|
371 *
|
yading@10
|
372 * @return pointer to the created array of dictionaries, NULL if it
|
yading@10
|
373 * cannot be created
|
yading@10
|
374 */
|
yading@10
|
375 AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
|
yading@10
|
376 AVDictionary *codec_opts);
|
yading@10
|
377
|
yading@10
|
378 /**
|
yading@10
|
379 * Print an error message to stderr, indicating filename and a human
|
yading@10
|
380 * readable description of the error code err.
|
yading@10
|
381 *
|
yading@10
|
382 * If strerror_r() is not available the use of this function in a
|
yading@10
|
383 * multithreaded application may be unsafe.
|
yading@10
|
384 *
|
yading@10
|
385 * @see av_strerror()
|
yading@10
|
386 */
|
yading@10
|
387 void print_error(const char *filename, int err);
|
yading@10
|
388
|
yading@10
|
389 /**
|
yading@10
|
390 * Print the program banner to stderr. The banner contents depend on the
|
yading@10
|
391 * current version of the repository and of the libav* libraries used by
|
yading@10
|
392 * the program.
|
yading@10
|
393 */
|
yading@10
|
394 void show_banner(int argc, char **argv, const OptionDef *options);
|
yading@10
|
395
|
yading@10
|
396 /**
|
yading@10
|
397 * Print the version of the program to stdout. The version message
|
yading@10
|
398 * depends on the current versions of the repository and of the libav*
|
yading@10
|
399 * libraries.
|
yading@10
|
400 * This option processing function does not utilize the arguments.
|
yading@10
|
401 */
|
yading@10
|
402 int show_version(void *optctx, const char *opt, const char *arg);
|
yading@10
|
403
|
yading@10
|
404 /**
|
yading@10
|
405 * Print the license of the program to stdout. The license depends on
|
yading@10
|
406 * the license of the libraries compiled into the program.
|
yading@10
|
407 * This option processing function does not utilize the arguments.
|
yading@10
|
408 */
|
yading@10
|
409 int show_license(void *optctx, const char *opt, const char *arg);
|
yading@10
|
410
|
yading@10
|
411 /**
|
yading@10
|
412 * Print a listing containing all the formats supported by the
|
yading@10
|
413 * program.
|
yading@10
|
414 * This option processing function does not utilize the arguments.
|
yading@10
|
415 */
|
yading@10
|
416 int show_formats(void *optctx, const char *opt, const char *arg);
|
yading@10
|
417
|
yading@10
|
418 /**
|
yading@10
|
419 * Print a listing containing all the codecs supported by the
|
yading@10
|
420 * program.
|
yading@10
|
421 * This option processing function does not utilize the arguments.
|
yading@10
|
422 */
|
yading@10
|
423 int show_codecs(void *optctx, const char *opt, const char *arg);
|
yading@10
|
424
|
yading@10
|
425 /**
|
yading@10
|
426 * Print a listing containing all the decoders supported by the
|
yading@10
|
427 * program.
|
yading@10
|
428 */
|
yading@10
|
429 int show_decoders(void *optctx, const char *opt, const char *arg);
|
yading@10
|
430
|
yading@10
|
431 /**
|
yading@10
|
432 * Print a listing containing all the encoders supported by the
|
yading@10
|
433 * program.
|
yading@10
|
434 */
|
yading@10
|
435 int show_encoders(void *optctx, const char *opt, const char *arg);
|
yading@10
|
436
|
yading@10
|
437 /**
|
yading@10
|
438 * Print a listing containing all the filters supported by the
|
yading@10
|
439 * program.
|
yading@10
|
440 * This option processing function does not utilize the arguments.
|
yading@10
|
441 */
|
yading@10
|
442 int show_filters(void *optctx, const char *opt, const char *arg);
|
yading@10
|
443
|
yading@10
|
444 /**
|
yading@10
|
445 * Print a listing containing all the bit stream filters supported by the
|
yading@10
|
446 * program.
|
yading@10
|
447 * This option processing function does not utilize the arguments.
|
yading@10
|
448 */
|
yading@10
|
449 int show_bsfs(void *optctx, const char *opt, const char *arg);
|
yading@10
|
450
|
yading@10
|
451 /**
|
yading@10
|
452 * Print a listing containing all the protocols supported by the
|
yading@10
|
453 * program.
|
yading@10
|
454 * This option processing function does not utilize the arguments.
|
yading@10
|
455 */
|
yading@10
|
456 int show_protocols(void *optctx, const char *opt, const char *arg);
|
yading@10
|
457
|
yading@10
|
458 /**
|
yading@10
|
459 * Print a listing containing all the pixel formats supported by the
|
yading@10
|
460 * program.
|
yading@10
|
461 * This option processing function does not utilize the arguments.
|
yading@10
|
462 */
|
yading@10
|
463 int show_pix_fmts(void *optctx, const char *opt, const char *arg);
|
yading@10
|
464
|
yading@10
|
465 /**
|
yading@10
|
466 * Print a listing containing all the standard channel layouts supported by
|
yading@10
|
467 * the program.
|
yading@10
|
468 * This option processing function does not utilize the arguments.
|
yading@10
|
469 */
|
yading@10
|
470 int show_layouts(void *optctx, const char *opt, const char *arg);
|
yading@10
|
471
|
yading@10
|
472 /**
|
yading@10
|
473 * Print a listing containing all the sample formats supported by the
|
yading@10
|
474 * program.
|
yading@10
|
475 */
|
yading@10
|
476 int show_sample_fmts(void *optctx, const char *opt, const char *arg);
|
yading@10
|
477
|
yading@10
|
478 /**
|
yading@10
|
479 * Return a positive value if a line read from standard input
|
yading@10
|
480 * starts with [yY], otherwise return 0.
|
yading@10
|
481 */
|
yading@10
|
482 int read_yesno(void);
|
yading@10
|
483
|
yading@10
|
484 /**
|
yading@10
|
485 * Read the file with name filename, and put its content in a newly
|
yading@10
|
486 * allocated 0-terminated buffer.
|
yading@10
|
487 *
|
yading@10
|
488 * @param filename file to read from
|
yading@10
|
489 * @param bufptr location where pointer to buffer is returned
|
yading@10
|
490 * @param size location where size of buffer is returned
|
yading@10
|
491 * @return 0 in case of success, a negative value corresponding to an
|
yading@10
|
492 * AVERROR error code in case of failure.
|
yading@10
|
493 */
|
yading@10
|
494 int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);
|
yading@10
|
495
|
yading@10
|
496 /**
|
yading@10
|
497 * Get a file corresponding to a preset file.
|
yading@10
|
498 *
|
yading@10
|
499 * If is_path is non-zero, look for the file in the path preset_name.
|
yading@10
|
500 * Otherwise search for a file named arg.ffpreset in the directories
|
yading@10
|
501 * $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined
|
yading@10
|
502 * at configuration time or in a "ffpresets" folder along the executable
|
yading@10
|
503 * on win32, in that order. If no such file is found and
|
yading@10
|
504 * codec_name is defined, then search for a file named
|
yading@10
|
505 * codec_name-preset_name.avpreset in the above-mentioned directories.
|
yading@10
|
506 *
|
yading@10
|
507 * @param filename buffer where the name of the found filename is written
|
yading@10
|
508 * @param filename_size size in bytes of the filename buffer
|
yading@10
|
509 * @param preset_name name of the preset to search
|
yading@10
|
510 * @param is_path tell if preset_name is a filename path
|
yading@10
|
511 * @param codec_name name of the codec for which to look for the
|
yading@10
|
512 * preset, may be NULL
|
yading@10
|
513 */
|
yading@10
|
514 FILE *get_preset_file(char *filename, size_t filename_size,
|
yading@10
|
515 const char *preset_name, int is_path, const char *codec_name);
|
yading@10
|
516
|
yading@10
|
517 /**
|
yading@10
|
518 * Realloc array to hold new_size elements of elem_size.
|
yading@10
|
519 * Calls exit() on failure.
|
yading@10
|
520 *
|
yading@10
|
521 * @param array array to reallocate
|
yading@10
|
522 * @param elem_size size in bytes of each element
|
yading@10
|
523 * @param size new element count will be written here
|
yading@10
|
524 * @param new_size number of elements to place in reallocated array
|
yading@10
|
525 * @return reallocated array
|
yading@10
|
526 */
|
yading@10
|
527 void *grow_array(void *array, int elem_size, int *size, int new_size);
|
yading@10
|
528
|
yading@10
|
529 #define media_type_string av_get_media_type_string
|
yading@10
|
530
|
yading@10
|
531 #define GROW_ARRAY(array, nb_elems)\
|
yading@10
|
532 array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
yading@10
|
533
|
yading@10
|
534 #define GET_PIX_FMT_NAME(pix_fmt)\
|
yading@10
|
535 const char *name = av_get_pix_fmt_name(pix_fmt);
|
yading@10
|
536
|
yading@10
|
537 #define GET_SAMPLE_FMT_NAME(sample_fmt)\
|
yading@10
|
538 const char *name = av_get_sample_fmt_name(sample_fmt)
|
yading@10
|
539
|
yading@10
|
540 #define GET_SAMPLE_RATE_NAME(rate)\
|
yading@10
|
541 char name[16];\
|
yading@10
|
542 snprintf(name, sizeof(name), "%d", rate);
|
yading@10
|
543
|
yading@10
|
544 #define GET_CH_LAYOUT_NAME(ch_layout)\
|
yading@10
|
545 char name[16];\
|
yading@10
|
546 snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
|
yading@10
|
547
|
yading@10
|
548 #define GET_CH_LAYOUT_DESC(ch_layout)\
|
yading@10
|
549 char name[128];\
|
yading@10
|
550 av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
|
yading@10
|
551
|
yading@10
|
552 #endif /* CMDUTILS_H */
|