65
65
* Fallback for options that are not explicitly handled, these will be
66
66
* parsed through AVOptions.
68
int opt_default(const char *opt, const char *arg);
68
int opt_default(void *optctx, const char *opt, const char *arg);
71
71
* Set the libav* libraries log level.
73
int opt_loglevel(const char *opt, const char *arg);
73
int opt_loglevel(void *optctx, const char *opt, const char *arg);
76
76
* Limit the execution time.
78
int opt_timelimit(const char *opt, const char *arg);
78
int opt_timelimit(void *optctx, const char *opt, const char *arg);
81
81
* Parse a string and return its corresponding value as a double.
146
146
#define OPT_DOUBLE 0x20000
149
int (*func_arg)(const char *, const char *);
150
int (*func2_arg)(void *, const char *, const char *);
149
int (*func_arg)(void *, const char *, const char *);
153
152
const char *help;
154
153
const char *argname;
157
void show_help_options(const OptionDef *options, const char *msg, int mask,
157
* Print help for all options matching specified flags.
159
* @param options a list of options
160
* @param msg title of this group. Only printed if at least one option matches.
161
* @param req_flags print only options which have all those flags set.
162
* @param rej_flags don't print options which have any of those flags set.
163
* @param alt_flags print only options that have at least one of those flags set
165
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
166
int rej_flags, int alt_flags);
161
169
* Show help for all options with given flags in class and all its
164
172
void show_help_children(const AVClass *class, int flags);
175
* Per-avtool specific help handler. Implemented in each
176
* avtool, called by show_help().
178
void show_help_default(const char *opt, const char *arg);
181
* Generic -h handler common to all avtools.
183
int show_help(void *optctx, const char *opt, const char *arg);
167
186
* Parse the command line arguments.
169
188
* @param optctx an opaque options context
189
* @param argc number of command line arguments
190
* @param argv values of command line arguments
170
191
* @param options Array with the definitions required to interpret every
171
192
* option of the form: -option_name [argument]
172
193
* @param parse_arg_function Name of the function called to process every
185
206
const OptionDef *options);
209
* An option extracted from the commandline.
210
* Cannot use AVDictionary because of options like -map which can be
211
* used multiple times.
213
typedef struct Option {
214
const OptionDef *opt;
219
typedef struct OptionGroupDef {
223
* Option to be used as group separator. Can be NULL for groups which
224
* are terminated by a non-option argument (e.g. avconv output files)
229
typedef struct OptionGroup {
230
const OptionGroupDef *group_def;
236
AVDictionary *codec_opts;
237
AVDictionary *format_opts;
238
struct SwsContext *sws_opts;
242
* A list of option groups that all have the same group type
243
* (e.g. input files or output files)
245
typedef struct OptionGroupList {
246
const OptionGroupDef *group_def;
252
typedef struct OptionParseContext {
253
OptionGroup global_opts;
255
OptionGroupList *groups;
259
OptionGroup cur_group;
260
} OptionParseContext;
263
* Parse an options group and write results into optctx.
265
* @param optctx an app-specific options context. NULL for global options group
267
int parse_optgroup(void *optctx, OptionGroup *g);
270
* Split the commandline into an intermediate form convenient for further
273
* The commandline is assumed to be composed of options which either belong to a
274
* group (those with OPT_SPEC, OPT_OFFSET or OPT_PERFILE) or are global
277
* A group (defined by an OptionGroupDef struct) is a sequence of options
278
* terminated by either a group separator option (e.g. -i) or a parameter that
279
* is not an option (doesn't start with -). A group without a separator option
280
* must always be first in the supplied groups list.
282
* All options within the same group are stored in one OptionGroup struct in an
283
* OptionGroupList, all groups with the same group definition are stored in one
284
* OptionGroupList in OptionParseContext.groups. The order of group lists is the
285
* same as the order of group definitions.
287
int split_commandline(OptionParseContext *octx, int argc, char *argv[],
288
const OptionDef *options,
289
const OptionGroupDef *groups, int nb_groups);
292
* Free all allocated memory in an OptionParseContext.
294
void uninit_parse_context(OptionParseContext *octx);
188
297
* Find the '-loglevel' option in the command line args and apply it.
190
299
void parse_loglevel(int argc, char **argv, const OptionDef *options);
302
* Return index of option opt in argv or 0 if not found.
304
int locate_option(int argc, char **argv, const OptionDef *options,
305
const char *optname);
193
308
* Check if the given stream matches a stream specifier.
195
310
* @param s Corresponding format context.
206
321
* Create a new options dictionary containing only the options from
207
322
* opts which apply to the codec with ID codec_id.
324
* @param opts dictionary to place options in
325
* @param codec_id ID of the codec that should be filtered for
209
326
* @param s Corresponding format context.
210
327
* @param st A stream from s for which the options should be filtered.
328
* @param codec The particular codec for which the options should be filtered.
329
* If null, the default one is looked up according to the codec id.
211
330
* @return a pointer to the created dictionary
213
AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id,
214
AVFormatContext *s, AVStream *st);
332
AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
333
AVFormatContext *s, AVStream *st, AVCodec *codec);
217
336
* Setup AVCodecContext options for avformat_find_stream_info().
250
369
* depends on the current versions of the repository and of the libav*
253
void show_version(void);
372
int show_version(void *optctx, const char *opt, const char *arg);
256
375
* Print the license of the program to stdout. The license depends on
257
376
* the license of the libraries compiled into the program.
259
void show_license(void);
378
int show_license(void *optctx, const char *opt, const char *arg);
262
381
* Print a listing containing all the formats supported by the
265
void show_formats(void);
384
int show_formats(void *optctx, const char *opt, const char *arg);
268
387
* Print a listing containing all the codecs supported by the
271
void show_codecs(void);
390
int show_codecs(void *optctx, const char *opt, const char *arg);
393
* Print a listing containing all the decoders supported by the
396
int show_decoders(void *optctx, const char *opt, const char *arg);
399
* Print a listing containing all the encoders supported by the
402
int show_encoders(void *optctx, const char *opt, const char *arg);
274
405
* Print a listing containing all the filters supported by the
277
void show_filters(void);
408
int show_filters(void *optctx, const char *opt, const char *arg);
280
411
* Print a listing containing all the bit stream filters supported by the
283
void show_bsfs(void);
414
int show_bsfs(void *optctx, const char *opt, const char *arg);
286
417
* Print a listing containing all the protocols supported by the
289
void show_protocols(void);
420
int show_protocols(void *optctx, const char *opt, const char *arg);
292
423
* Print a listing containing all the pixel formats supported by the
295
void show_pix_fmts(void);
426
int show_pix_fmts(void *optctx, const char *opt, const char *arg);
298
429
* Print a listing containing all the sample formats supported by the
301
int show_sample_fmts(const char *opt, const char *arg);
432
int show_sample_fmts(void *optctx, const char *opt, const char *arg);
304
435
* Return a positive value if a line read from standard input
361
494
FILE *get_preset_file(char *filename, size_t filename_size,
362
495
const char *preset_name, int is_path, const char *codec_name);
365
enum PixelFormat pix_fmt;
368
extern AVFilter avsink;
371
* Extract a frame from sink.
373
* @return a negative error in case of failure, 1 if one frame has
374
* been extracted successfully.
376
int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
377
AVFilterBufferRef **picref, AVRational *pts_tb);
380
* Do all the necessary cleanup and abort.
381
* This function is implemented in the avtools, not cmdutils.
383
void exit_program(int ret);
386
498
* Realloc array to hold new_size elements of elem_size.
387
* Calls exit_program() on failure.
499
* Calls exit() on failure.
501
* @param array array to reallocate
389
502
* @param elem_size size in bytes of each element
390
503
* @param size new element count will be written here
504
* @param new_size number of elements to place in reallocated array
391
505
* @return reallocated array
393
507
void *grow_array(void *array, int elem_size, int *size, int new_size);
509
#define GROW_ARRAY(array, nb_elems)\
510
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
512
typedef struct FrameBuffer {
518
enum AVPixelFormat pix_fmt;
521
struct FrameBuffer **pool; ///< head of the buffer pool
522
struct FrameBuffer *next;
526
* Get a frame from the pool. This is intended to be used as a callback for
527
* AVCodecContext.get_buffer.
529
* @param s codec context. s->opaque must be a pointer to the head of the
531
* @param frame frame->opaque will be set to point to the FrameBuffer
532
* containing the frame data.
534
int codec_get_buffer(AVCodecContext *s, AVFrame *frame);
537
* A callback to be used for AVCodecContext.release_buffer along with
538
* codec_get_buffer().
540
void codec_release_buffer(AVCodecContext *s, AVFrame *frame);
543
* A callback to be used for AVFilterBuffer.free.
544
* @param fb buffer to free. fb->priv must be a pointer to the FrameBuffer
545
* containing the buffer data.
547
void filter_release_buffer(AVFilterBuffer *fb);
550
* Free all the buffers in the pool. This must be called after all the
551
* buffers have been released.
553
void free_buffer_pool(FrameBuffer **pool);
555
#define GET_PIX_FMT_NAME(pix_fmt)\
556
const char *name = av_get_pix_fmt_name(pix_fmt);
558
#define GET_SAMPLE_FMT_NAME(sample_fmt)\
559
const char *name = av_get_sample_fmt_name(sample_fmt)
561
#define GET_SAMPLE_RATE_NAME(rate)\
563
snprintf(name, sizeof(name), "%d", rate);
565
#define GET_CH_LAYOUT_NAME(ch_layout)\
567
snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
569
#define GET_CH_LAYOUT_DESC(ch_layout)\
571
av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
395
573
#endif /* LIBAV_CMDUTILS_H */