标签:des style http color os io for art
00001 /* 00002 * Various utilities for command line tools 00003 * copyright (c) 2003 Fabrice Bellard 00004 * 00005 * This file is part of FFmpeg. 00006 * 00007 * FFmpeg is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * FFmpeg is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with FFmpeg; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef FFMPEG_CMDUTILS_H 00023 #define FFMPEG_CMDUTILS_H 00024 00025 #include <stdint.h> 00026 00027 #include "libavcodec/avcodec.h" 00028 #include "libavfilter/avfilter.h" 00029 #include "libavformat/avformat.h" 00030 #include "libswscale/swscale.h" 00031 00032 #ifdef __MINGW32__ 00033 #undef main /* We don‘t want SDL to override our main() */ 00034 #endif 00035 00039 extern const char program_name[]; 00040 00044 extern const int program_birth_year; 00045 00049 extern const int this_year; 00050 00051 extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; 00052 extern AVFormatContext *avformat_opts; 00053 extern struct SwsContext *sws_opts; 00054 extern struct SwrContext *swr_opts; 00055 extern AVDictionary *format_opts, *codec_opts; 00056 00061 void init_opts(void); 00066 void uninit_opts(void); 00067 00072 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); 00073 00078 int opt_default(void *optctx, const char *opt, const char *arg); 00079 00083 int opt_loglevel(void *optctx, const char *opt, const char *arg); 00084 00085 int opt_report(const char *opt); 00086 00087 int opt_max_alloc(void *optctx, const char *opt, const char *arg); 00088 00089 int opt_cpuflags(void *optctx, const char *opt, const char *arg); 00090 00091 int opt_codec_debug(void *optctx, const char *opt, const char *arg); 00092 00096 int opt_timelimit(void *optctx, const char *opt, const char *arg); 00097 00111 double parse_number_or_die(const char *context, const char *numstr, int type, 00112 double min, double max); 00113 00128 int64_t parse_time_or_die(const char *context, const char *timestr, 00129 int is_duration); 00130 00131 typedef struct SpecifierOpt { 00132 char *specifier; 00133 union { 00134 uint8_t *str; 00135 int i; 00136 int64_t i64; 00137 float f; 00138 double dbl; 00139 } u; 00140 } SpecifierOpt; 00141 00142 typedef struct { 00143 const char *name; 00144 int flags; 00145 #define HAS_ARG 0x0001 00146 #define OPT_BOOL 0x0002 00147 #define OPT_EXPERT 0x0004 00148 #define OPT_STRING 0x0008 00149 #define OPT_VIDEO 0x0010 00150 #define OPT_AUDIO 0x0020 00151 #define OPT_INT 0x0080 00152 #define OPT_FLOAT 0x0100 00153 #define OPT_SUBTITLE 0x0200 00154 #define OPT_INT64 0x0400 00155 #define OPT_EXIT 0x0800 00156 #define OPT_DATA 0x1000 00157 #define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only). 00158 implied by OPT_OFFSET or OPT_SPEC */ 00159 #define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */ 00160 #define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt. 00161 Implies OPT_OFFSET. Next element after the offset is 00162 an int containing element count in the array. */ 00163 #define OPT_TIME 0x10000 00164 #define OPT_DOUBLE 0x20000 00165 union { 00166 void *dst_ptr; 00167 int (*func_arg)(void *, const char *, const char *); 00168 size_t off; 00169 } u; 00170 const char *help; 00171 const char *argname; 00172 } OptionDef; 00173 00183 void show_help_options(const OptionDef *options, const char *msg, int req_flags, 00184 int rej_flags, int alt_flags); 00185 00190 void show_help_children(const AVClass *class, int flags); 00191 00196 void show_help_default(const char *opt, const char *arg); 00197 00201 int show_help(void *optctx, const char *opt, const char *arg); 00202 00213 void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, 00214 void (* parse_arg_function)(void *optctx, const char*)); 00215 00221 int parse_option(void *optctx, const char *opt, const char *arg, 00222 const OptionDef *options); 00223 00227 void parse_loglevel(int argc, char **argv, const OptionDef *options); 00228 00232 int locate_option(int argc, char **argv, const OptionDef *options, 00233 const char *optname); 00234 00244 int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec); 00245 00258 AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, 00259 AVFormatContext *s, AVStream *st, AVCodec *codec); 00260 00272 AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, 00273 AVDictionary *codec_opts); 00274 00284 void print_error(const char *filename, int err); 00285 00291 void show_banner(int argc, char **argv, const OptionDef *options); 00292 00299 int show_version(void *optctx, const char *opt, const char *arg); 00300 00306 int show_license(void *optctx, const char *opt, const char *arg); 00307 00313 int show_formats(void *optctx,