• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

cmdutils.h

Go to the documentation of this file.
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 AVDictionary *format_opts, *codec_opts;
00055 
00060 void init_opts(void);
00065 void uninit_opts(void);
00066 
00071 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
00072 
00077 int opt_default(const char *opt, const char *arg);
00078 
00082 int opt_loglevel(const char *opt, const char *arg);
00083 
00084 int opt_report(const char *opt);
00085 
00086 int opt_max_alloc(const char *opt, const char *arg);
00087 
00088 int opt_codec_debug(const char *opt, const char *arg);
00089 
00093 int opt_timelimit(const char *opt, const char *arg);
00094 
00108 double parse_number_or_die(const char *context, const char *numstr, int type,
00109                            double min, double max);
00110 
00125 int64_t parse_time_or_die(const char *context, const char *timestr,
00126                           int is_duration);
00127 
00128 typedef struct SpecifierOpt {
00129     char *specifier;    
00130     union {
00131         uint8_t *str;
00132         int        i;
00133         int64_t  i64;
00134         float      f;
00135         double   dbl;
00136     } u;
00137 } SpecifierOpt;
00138 
00139 typedef struct {
00140     const char *name;
00141     int flags;
00142 #define HAS_ARG    0x0001
00143 #define OPT_BOOL   0x0002
00144 #define OPT_EXPERT 0x0004
00145 #define OPT_STRING 0x0008
00146 #define OPT_VIDEO  0x0010
00147 #define OPT_AUDIO  0x0020
00148 #define OPT_GRAB   0x0040
00149 #define OPT_INT    0x0080
00150 #define OPT_FLOAT  0x0100
00151 #define OPT_SUBTITLE 0x0200
00152 #define OPT_INT64  0x0400
00153 #define OPT_EXIT   0x0800
00154 #define OPT_DATA   0x1000
00155 #define OPT_FUNC2  0x2000
00156 #define OPT_OFFSET 0x4000       /* option is specified as an offset in a passed optctx */
00157 #define OPT_SPEC   0x8000       /* option is to be stored in an array of SpecifierOpt.
00158                                    Implies OPT_OFFSET. Next element after the offset is
00159                                    an int containing element count in the array. */
00160 #define OPT_TIME  0x10000
00161 #define OPT_DOUBLE 0x20000
00162      union {
00163         void *dst_ptr;
00164         int (*func_arg)(const char *, const char *);
00165         int (*func2_arg)(void *, const char *, const char *);
00166         size_t off;
00167     } u;
00168     const char *help;
00169     const char *argname;
00170 } OptionDef;
00171 
00172 void show_help_options(const OptionDef *options, const char *msg, int mask,
00173                        int value);
00174 
00179 void show_help_children(const AVClass *class, int flags);
00180 
00191 void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
00192                    void (* parse_arg_function)(void *optctx, const char*));
00193 
00199 int parse_option(void *optctx, const char *opt, const char *arg,
00200                  const OptionDef *options);
00201 
00205 void parse_loglevel(int argc, char **argv, const OptionDef *options);
00206 
00216 int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
00217 
00228 AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec,
00229                                 AVFormatContext *s, AVStream *st);
00230 
00242 AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
00243                                            AVDictionary *codec_opts);
00244 
00254 void print_error(const char *filename, int err);
00255 
00261 void show_banner(int argc, char **argv, const OptionDef *options);
00262 
00269 int opt_version(const char *opt, const char *arg);
00270 
00276 int opt_license(const char *opt, const char *arg);
00277 
00283 int opt_formats(const char *opt, const char *arg);
00284 
00290 int opt_codecs(const char *opt, const char *arg);
00291 
00297 int opt_filters(const char *opt, const char *arg);
00298 
00304 int opt_bsfs(const char *opt, const char *arg);
00305 
00311 int opt_protocols(const char *opt, const char *arg);
00312 
00318 int opt_pix_fmts(const char *opt, const char *arg);
00319 
00324 int show_sample_fmts(const char *opt, const char *arg);
00325 
00330 int read_yesno(void);
00331 
00341 int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);
00342 
00361 FILE *get_preset_file(char *filename, size_t filename_size,
00362                       const char *preset_name, int is_path, const char *codec_name);
00363 
00368 void exit_program(int ret);
00369 
00378 void *grow_array(void *array, int elem_size, int *size, int new_size);
00379 
00380 #endif /* CMDUTILS_H */
Generated on Fri Feb 1 2013 14:34:25 for FFmpeg by doxygen 1.7.1