Libav 0.7.1
|
00001 /* 00002 * Various utilities for command line tools 00003 * copyright (c) 2003 Fabrice Bellard 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav 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 * Libav 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 Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 const char **opt_names; 00043 extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; 00044 extern AVFormatContext *avformat_opts; 00045 extern struct SwsContext *sws_opts; 00046 extern AVDictionary *format_opts, *video_opts, *audio_opts, *sub_opts; 00047 00052 void init_opts(void); 00057 void uninit_opts(void); 00058 00063 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); 00064 00069 int opt_default(const char *opt, const char *arg); 00070 00074 int opt_loglevel(const char *opt, const char *arg); 00075 00079 int opt_timelimit(const char *opt, const char *arg); 00080 00094 double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max); 00095 00110 int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration); 00111 00112 typedef struct { 00113 const char *name; 00114 int flags; 00115 #define HAS_ARG 0x0001 00116 #define OPT_BOOL 0x0002 00117 #define OPT_EXPERT 0x0004 00118 #define OPT_STRING 0x0008 00119 #define OPT_VIDEO 0x0010 00120 #define OPT_AUDIO 0x0020 00121 #define OPT_GRAB 0x0040 00122 #define OPT_INT 0x0080 00123 #define OPT_FLOAT 0x0100 00124 #define OPT_SUBTITLE 0x0200 00125 #define OPT_INT64 0x0400 00126 #define OPT_EXIT 0x0800 00127 #define OPT_DATA 0x1000 00128 union { 00129 int *int_arg; 00130 char **str_arg; 00131 float *float_arg; 00132 int (*func_arg)(const char *, const char *); 00133 int64_t *int64_arg; 00134 } u; 00135 const char *help; 00136 const char *argname; 00137 } OptionDef; 00138 00139 void show_help_options(const OptionDef *options, const char *msg, int mask, int value); 00140 00149 void parse_options(int argc, char **argv, const OptionDef *options, 00150 void (* parse_arg_function)(const char*)); 00151 00152 void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec); 00153 00163 void print_error(const char *filename, int err); 00164 00170 void show_banner(void); 00171 00177 void show_version(void); 00178 00183 void show_license(void); 00184 00189 void show_formats(void); 00190 00195 void show_codecs(void); 00196 00201 void show_filters(void); 00202 00207 void show_bsfs(void); 00208 00213 void show_protocols(void); 00214 00219 void show_pix_fmts(void); 00220 00225 int read_yesno(void); 00226 00236 int read_file(const char *filename, char **bufptr, size_t *size); 00237 00238 typedef struct { 00239 int64_t num_faulty_pts; 00240 int64_t num_faulty_dts; 00241 int64_t last_pts; 00242 int64_t last_dts; 00243 } PtsCorrectionContext; 00244 00248 void init_pts_correction(PtsCorrectionContext *ctx); 00249 00260 int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t pts, int64_t dts); 00261 00279 FILE *get_preset_file(char *filename, size_t filename_size, 00280 const char *preset_name, int is_path, const char *codec_name); 00281 00282 typedef struct { 00283 enum PixelFormat pix_fmt; 00284 } FFSinkContext; 00285 00286 extern AVFilter ffsink; 00287 00294 int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame, 00295 AVFilterBufferRef **picref, AVRational *pts_tb); 00296 00297 #endif /* LIBAV_CMDUTILS_H */