首页 > 代码库 > FFmpeg之cmdutils.h源码

FFmpeg之cmdutils.h源码


cmdutils.h

Go to the documentation of this file.
00001 /*00002  * Various utilities for command line tools00003  * copyright (c) 2003 Fabrice Bellard00004  *00005  * This file is part of FFmpeg.00006  *00007  * FFmpeg is free software; you can redistribute it and/or00008  * modify it under the terms of the GNU Lesser General Public00009  * License as published by the Free Software Foundation; either00010  * 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 of00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU00015  * Lesser General Public License for more details.00016  *00017  * You should have received a copy of the GNU Lesser General Public00018  * License along with FFmpeg; if not, write to the Free Software00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA00020  */00021 00022 #ifndef FFMPEG_CMDUTILS_H00023 #define FFMPEG_CMDUTILS_H00024 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 #endif00035 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    0x000100146 #define OPT_BOOL   0x000200147 #define OPT_EXPERT 0x000400148 #define OPT_STRING 0x000800149 #define OPT_VIDEO  0x001000150 #define OPT_AUDIO  0x002000151 #define OPT_INT    0x008000152 #define OPT_FLOAT  0x010000153 #define OPT_SUBTITLE 0x020000154 #define OPT_INT64  0x040000155 #define OPT_EXIT   0x080000156 #define OPT_DATA   0x100000157 #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 is00162                                    an int containing element count in the array. */00163 #define OPT_TIME  0x1000000164 #define OPT_DOUBLE 0x2000000165      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, const char *opt, const char *arg);00314 00320 int show_codecs(void *optctx, const char *opt, const char *arg);00321 00326 int show_decoders(void *optctx, const char *opt, const char *arg);00327 00332 int show_encoders(void *optctx, const char *opt, const char *arg);00333 00339 int show_filters(void *optctx, const char *opt, const char *arg);00340 00346 int show_bsfs(void *optctx, const char *opt, const char *arg);00347 00353 int show_protocols(void *optctx, const char *opt, const char *arg);00354 00360 int show_pix_fmts(void *optctx, const char *opt, const char *arg);00361 00367 int show_layouts(void *optctx, const char *opt, const char *arg);00368 00373 int show_sample_fmts(void *optctx, const char *opt, const char *arg);00374 00379 int read_yesno(void);00380 00390 int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);00391 00410 FILE *get_preset_file(char *filename, size_t filename_size,00411                       const char *preset_name, int is_path, const char *codec_name);00412 00417 av_noreturn void exit_program(int ret);00418 00427 void *grow_array(void *array, int elem_size, int *size, int new_size);00428 00429 typedef struct FrameBuffer {00430     uint8_t *base[4];00431     uint8_t *data[4];00432     int  linesize[4];00433 00434     int h, w;00435     enum PixelFormat pix_fmt;00436 00437     int refcount;00438     struct FrameBuffer **pool;  00439     struct FrameBuffer *next;00440 } FrameBuffer;00441 00451 int codec_get_buffer(AVCodecContext *s, AVFrame *frame);00452 00457 void codec_release_buffer(AVCodecContext *s, AVFrame *frame);00458 00464 void filter_release_buffer(AVFilterBuffer *fb);00465 00470 void free_buffer_pool(FrameBuffer **pool);00471 00472 #define GET_PIX_FMT_NAME(pix_fmt)00473     const char *name = av_get_pix_fmt_name(pix_fmt);00474 00475 #define GET_SAMPLE_FMT_NAME(sample_fmt)00476     const char *name = av_get_sample_fmt_name(sample_fmt)00477 00478 #define GET_SAMPLE_RATE_NAME(rate)00479     char name[16];00480     snprintf(name, sizeof(name), "%d", rate);00481 00482 #define GET_CH_LAYOUT_NAME(ch_layout)00483     char name[16];00484     snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);00485 00486 #define GET_CH_LAYOUT_DESC(ch_layout)00487     char name[128];00488     av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);00489 00490 #endif /* CMDUTILS_H */