00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef LIBAV_CMDUTILS_H
00023 #define LIBAV_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
00035 extern const char program_name[];
00036
00040 extern const int program_birth_year;
00041
00042 extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
00043 extern AVFormatContext *avformat_opts;
00044 extern struct SwsContext *sws_opts;
00045 extern AVDictionary *format_opts, *codec_opts;
00046
00051 void init_opts(void);
00056 void uninit_opts(void);
00057
00062 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
00063
00068 int opt_default(const char *opt, const char *arg);
00069
00073 int opt_loglevel(const char *opt, const char *arg);
00074
00078 int opt_timelimit(const char *opt, const char *arg);
00079
00093 double parse_number_or_die(const char *context, const char *numstr, int type,
00094 double min, double max);
00095
00110 int64_t parse_time_or_die(const char *context, const char *timestr,
00111 int is_duration);
00112
00113 typedef struct SpecifierOpt {
00114 char *specifier;
00115 union {
00116 uint8_t *str;
00117 int i;
00118 int64_t i64;
00119 float f;
00120 double dbl;
00121 } u;
00122 } SpecifierOpt;
00123
00124 typedef struct {
00125 const char *name;
00126 int flags;
00127 #define HAS_ARG 0x0001
00128 #define OPT_BOOL 0x0002
00129 #define OPT_EXPERT 0x0004
00130 #define OPT_STRING 0x0008
00131 #define OPT_VIDEO 0x0010
00132 #define OPT_AUDIO 0x0020
00133 #define OPT_GRAB 0x0040
00134 #define OPT_INT 0x0080
00135 #define OPT_FLOAT 0x0100
00136 #define OPT_SUBTITLE 0x0200
00137 #define OPT_INT64 0x0400
00138 #define OPT_EXIT 0x0800
00139 #define OPT_DATA 0x1000
00140 #define OPT_FUNC2 0x2000
00141 #define OPT_OFFSET 0x4000
00142 #define OPT_SPEC 0x8000
00143
00144
00145 #define OPT_TIME 0x10000
00146 #define OPT_DOUBLE 0x20000
00147 union {
00148 void *dst_ptr;
00149 int (*func_arg)(const char *, const char *);
00150 int (*func2_arg)(void *, const char *, const char *);
00151 size_t off;
00152 } u;
00153 const char *help;
00154 const char *argname;
00155 } OptionDef;
00156
00157 void show_help_options(const OptionDef *options, const char *msg, int mask,
00158 int value);
00159
00164 void show_help_children(const AVClass *class, int flags);
00165
00176 void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
00177 void (* parse_arg_function)(void *optctx, const char*));
00178
00184 int parse_option(void *optctx, const char *opt, const char *arg,
00185 const OptionDef *options);
00186
00190 void parse_loglevel(int argc, char **argv, const OptionDef *options);
00191
00201 int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
00202
00213 AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id,
00214 AVFormatContext *s, AVStream *st);
00215
00227 AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
00228 AVDictionary *codec_opts);
00229
00239 void print_error(const char *filename, int err);
00240
00246 void show_banner(void);
00247
00253 void show_version(void);
00254
00259 void show_license(void);
00260
00265 void show_formats(void);
00266
00271 void show_codecs(void);
00272
00277 void show_filters(void);
00278
00283 void show_bsfs(void);
00284
00289 void show_protocols(void);
00290
00295 void show_pix_fmts(void);
00296
00301 int show_sample_fmts(const char *opt, const char *arg);
00302
00307 int read_yesno(void);
00308
00318 int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);
00319
00320 typedef struct {
00321 int64_t num_faulty_pts;
00322 int64_t num_faulty_dts;
00323 int64_t last_pts;
00324 int64_t last_dts;
00325 } PtsCorrectionContext;
00326
00330 void init_pts_correction(PtsCorrectionContext *ctx);
00331
00342 int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t pts, int64_t dts);
00343
00361 FILE *get_preset_file(char *filename, size_t filename_size,
00362 const char *preset_name, int is_path, const char *codec_name);
00363
00364 typedef struct {
00365 enum PixelFormat pix_fmt;
00366 } AVSinkContext;
00367
00368 extern AVFilter avsink;
00369
00376 int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
00377 AVFilterBufferRef **picref, AVRational *pts_tb);
00378
00383 void exit_program(int ret);
00384
00393 void *grow_array(void *array, int elem_size, int *size, int new_size);
00394
00395 #endif