123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548 |
- #ifndef FFTOOLS_CMDUTILS_H
- #define FFTOOLS_CMDUTILS_H
- #include <stdint.h>
- #include "config.h"
- #include "libavcodec/avcodec.h"
- #include "libavfilter/avfilter.h"
- #include "libavformat/avformat.h"
- #include "libswscale/swscale.h"
- #ifdef _WIN32
- #undef main
- #endif
- extern const char program_name[];
- extern const int program_birth_year;
- extern AVDictionary *sws_dict;
- extern AVDictionary *swr_opts;
- extern AVDictionary *format_opts, *codec_opts;
- extern int hide_banner;
- void init_dynload(void);
- void uninit_opts(void);
- void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
- int opt_default(void *optctx, const char *opt, const char *arg);
- int opt_timelimit(void *optctx, const char *opt, const char *arg);
- enum OptionType {
- OPT_TYPE_FUNC,
- OPT_TYPE_BOOL,
- OPT_TYPE_STRING,
- OPT_TYPE_INT,
- OPT_TYPE_INT64,
- OPT_TYPE_FLOAT,
- OPT_TYPE_DOUBLE,
- OPT_TYPE_TIME,
- };
- int parse_number(const char *context, const char *numstr, enum OptionType type,
- double min, double max, double *dst);
- enum StreamList {
- STREAM_LIST_ALL,
- STREAM_LIST_STREAM_ID,
- STREAM_LIST_PROGRAM,
- STREAM_LIST_GROUP_ID,
- STREAM_LIST_GROUP_IDX,
- };
- typedef struct StreamSpecifier {
-
-
- int idx;
-
- enum StreamList stream_list;
-
-
-
-
- int64_t list_id;
-
- enum AVMediaType media_type;
- uint8_t no_apic;
- uint8_t usable_only;
- int disposition;
- char *meta_key;
- char *meta_val;
- char *remainder;
- } StreamSpecifier;
- int stream_specifier_parse(StreamSpecifier *ss, const char *spec,
- int allow_remainder, void *logctx);
- unsigned stream_specifier_match(const StreamSpecifier *ss,
- const AVFormatContext *s, const AVStream *st,
- void *logctx);
- void stream_specifier_uninit(StreamSpecifier *ss);
- typedef struct SpecifierOpt {
-
- char *specifier;
-
- StreamSpecifier stream_spec;
- union {
- uint8_t *str;
- int i;
- int64_t i64;
- uint64_t ui64;
- float f;
- double dbl;
- } u;
- } SpecifierOpt;
- typedef struct SpecifierOptList {
- SpecifierOpt *opt;
- int nb_opt;
-
- const struct OptionDef *opt_canon;
-
- enum OptionType type;
- } SpecifierOptList;
- typedef struct OptionDef {
- const char *name;
- enum OptionType type;
- int flags;
- #define OPT_FUNC_ARG (1 << 0)
- #define OPT_EXIT (1 << 1)
- #define OPT_EXPERT (1 << 2)
- #define OPT_VIDEO (1 << 3)
- #define OPT_AUDIO (1 << 4)
- #define OPT_SUBTITLE (1 << 5)
- #define OPT_DATA (1 << 6)
- #define OPT_PERFILE (1 << 7)
- #define OPT_FLAG_OFFSET (1 << 8)
- #define OPT_OFFSET (OPT_FLAG_OFFSET | OPT_PERFILE)
- #define OPT_FLAG_SPEC (1 << 9)
- #define OPT_SPEC (OPT_FLAG_SPEC | OPT_OFFSET)
- #define OPT_FLAG_PERSTREAM (1 << 10)
- #define OPT_PERSTREAM (OPT_FLAG_PERSTREAM | OPT_SPEC)
- #define OPT_INPUT (1 << 11)
- #define OPT_OUTPUT (1 << 12)
- #define OPT_HAS_ALT (1 << 13)
- #define OPT_HAS_CANON (1 << 14)
- #define OPT_DECODER (1 << 15)
- union {
- void *dst_ptr;
- int (*func_arg)(void *, const char *, const char *);
- size_t off;
- } u;
- const char *help;
- const char *argname;
- union {
-
- const char *name_canon;
-
- const char * const *names_alt;
- } u1;
- } OptionDef;
- void show_help_options(const OptionDef *options, const char *msg, int req_flags,
- int rej_flags);
- void show_help_children(const AVClass *class, int flags);
- void show_help_default(const char *opt, const char *arg);
- int parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
- int (* parse_arg_function)(void *optctx, const char*));
- int parse_option(void *optctx, const char *opt, const char *arg,
- const OptionDef *options);
- typedef struct Option {
- const OptionDef *opt;
- const char *key;
- const char *val;
- } Option;
- typedef struct OptionGroupDef {
-
- const char *name;
-
- const char *sep;
-
- int flags;
- } OptionGroupDef;
- typedef struct OptionGroup {
- const OptionGroupDef *group_def;
- const char *arg;
- Option *opts;
- int nb_opts;
- AVDictionary *codec_opts;
- AVDictionary *format_opts;
- AVDictionary *sws_dict;
- AVDictionary *swr_opts;
- } OptionGroup;
- typedef struct OptionGroupList {
- const OptionGroupDef *group_def;
- OptionGroup *groups;
- int nb_groups;
- } OptionGroupList;
- typedef struct OptionParseContext {
- OptionGroup global_opts;
- OptionGroupList *groups;
- int nb_groups;
-
- OptionGroup cur_group;
- } OptionParseContext;
- int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs);
- int split_commandline(OptionParseContext *octx, int argc, char *argv[],
- const OptionDef *options,
- const OptionGroupDef *groups, int nb_groups);
- void uninit_parse_context(OptionParseContext *octx);
- void parse_loglevel(int argc, char **argv, const OptionDef *options);
- int locate_option(int argc, char **argv, const OptionDef *options,
- const char *optname);
- int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
- int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id,
- AVFormatContext *s, AVStream *st, const AVCodec *codec,
- AVDictionary **dst, AVDictionary **opts_used);
- int setup_find_stream_info_opts(AVFormatContext *s,
- AVDictionary *codec_opts,
- AVDictionary ***dst);
- static inline void print_error(const char *filename, int err)
- {
- av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, av_err2str(err));
- }
- void show_banner(int argc, char **argv, const OptionDef *options);
- int read_yesno(void);
- FILE *get_preset_file(char *filename, size_t filename_size,
- const char *preset_name, int is_path, const char *codec_name);
- int grow_array(void **array, int elem_size, int *size, int new_size);
- void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
- #define GROW_ARRAY(array, nb_elems)\
- grow_array((void**)&array, sizeof(*array), &nb_elems, nb_elems + 1)
- double get_rotation(const int32_t *displaymatrix);
- char *file_read(const char *filename);
- void remove_avoptions(AVDictionary **a, AVDictionary *b);
- int check_avoptions(AVDictionary *m);
- int cmdutils_isalnum(char c);
- #endif
|