⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ffmpeg.c

📁 ffmpeg源码分析
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * FFmpeg main * Copyright (c) 2000-2003 Fabrice Bellard * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */#define HAVE_AV_CONFIG_H#include <limits.h>#include "avformat.h"#include "framehook.h"#include "dsputil.h"#include "opt.h"#ifndef CONFIG_WIN32#include <unistd.h>#include <fcntl.h>#include <sys/ioctl.h>#include <sys/time.h>#include <termios.h>#include <sys/resource.h>#include <signal.h>#endif#ifdef CONFIG_OS2#include <sys/types.h>#include <sys/select.h>#include <stdlib.h>#endif#undef time //needed because HAVE_AV_CONFIG_H is defined on top#include <time.h>#include "cmdutils.h"#undef NDEBUG#include <assert.h>#if !defined(INFINITY) && defined(HUGE_VAL)#define INFINITY HUGE_VAL#endif/* select an input stream for an output stream */typedef struct AVStreamMap {    int file_index;    int stream_index;    int sync_file_index;    int sync_stream_index;} AVStreamMap;/** select an input file for an output file */typedef struct AVMetaDataMap {    int out_file;    int in_file;} AVMetaDataMap;extern const OptionDef options[];static void show_help(void);static void show_license(void);static int opt_default(const char *opt, const char *arg);#define MAX_FILES 20static AVFormatContext *input_files[MAX_FILES];static int64_t input_files_ts_offset[MAX_FILES];static int nb_input_files = 0;static AVFormatContext *output_files[MAX_FILES];static int nb_output_files = 0;static AVStreamMap stream_maps[MAX_FILES];static int nb_stream_maps;static AVMetaDataMap meta_data_maps[MAX_FILES];static int nb_meta_data_maps;static AVInputFormat *file_iformat;static AVOutputFormat *file_oformat;static AVImageFormat *image_format;static int frame_width  = 0;static int frame_height = 0;static float frame_aspect_ratio = 0;static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;static int frame_padtop  = 0;static int frame_padbottom = 0;static int frame_padleft  = 0;static int frame_padright = 0;static int padcolor[3] = {16,128,128}; /* default to black */static int frame_topBand  = 0;static int frame_bottomBand = 0;static int frame_leftBand  = 0;static int frame_rightBand = 0;static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};static int frame_rate = 25;static int frame_rate_base = 1;static int video_bit_rate = 200*1000;static int video_bit_rate_tolerance = 4000*1000;static float video_qscale = 0;static int video_qmin = 2;static int video_qmax = 31;static int video_lmin = 2*FF_QP2LAMBDA;static int video_lmax = 31*FF_QP2LAMBDA;static int video_mb_lmin = 2*FF_QP2LAMBDA;static int video_mb_lmax = 31*FF_QP2LAMBDA;static int video_qdiff = 3;static float video_qblur = 0.5;static float video_qsquish = 0.0;static float video_qcomp = 0.5;static uint16_t *intra_matrix = NULL;static uint16_t *inter_matrix = NULL;#if 0 //experimental, (can be removed)static float video_rc_qsquish=1.0;static float video_rc_qmod_amp=0;static int video_rc_qmod_freq=0;#endifstatic char *video_rc_override_string=NULL;static char *video_rc_eq="tex^qComp";static int video_rc_buffer_size=0;static float video_rc_buffer_aggressivity=1.0;static int video_rc_max_rate=0;static int video_rc_min_rate=0;static float video_rc_initial_cplx=0;static float video_b_qfactor = 1.25;static float video_b_qoffset = 1.25;static float video_i_qfactor = -0.8;static float video_i_qoffset = 0.0;static int video_intra_quant_bias= FF_DEFAULT_QUANT_BIAS;static int video_inter_quant_bias= FF_DEFAULT_QUANT_BIAS;static int me_method = ME_EPZS;static int video_disable = 0;static int video_discard = 0;static int video_codec_id = CODEC_ID_NONE;static int video_codec_tag = 0;static int same_quality = 0;static int b_frames = 0;static int pre_me = 0;static int do_deinterlace = 0;static int workaround_bugs = FF_BUG_AUTODETECT;static int packet_size = 0;static int error_rate = 0;static int strict = 0;static int top_field_first = -1;static int sc_threshold = 0;static int me_threshold = 0;static int mb_threshold = 0;static int intra_dc_precision = 8;static int me_penalty_compensation= 256;static int frame_skip_threshold= 0;static int frame_skip_factor= 0;static int frame_skip_exp= 0;extern int loop_input; /* currently a hack */static int loop_output = AVFMT_NOOUTPUTLOOP;static int genpts = 0;static int qp_hist = 0;static int gop_size = 12;static int intra_only = 0;static int audio_sample_rate = 44100;static int audio_bit_rate = 64000;#define QSCALE_NONE -99999static float audio_qscale = QSCALE_NONE;static int audio_disable = 0;static int audio_channels = 1;static int audio_codec_id = CODEC_ID_NONE;static int audio_codec_tag = 0;static char *audio_language = NULL;static int subtitle_codec_id = CODEC_ID_NONE;static char *subtitle_language = NULL;static int mux_rate= 0;static int mux_packet_size= 0;static float mux_preload= 0.5;static float mux_max_delay= 0.7;static int64_t recording_time = 0;static int64_t start_time = 0;static int64_t rec_timestamp = 0;static int64_t input_ts_offset = 0;static int file_overwrite = 0;static char *str_title = NULL;static char *str_author = NULL;static char *str_copyright = NULL;static char *str_comment = NULL;static int do_benchmark = 0;static int do_hex_dump = 0;static int do_pkt_dump = 0;static int do_psnr = 0;static int do_vstats = 0;static int do_pass = 0;static char *pass_logfilename = NULL;static int audio_stream_copy = 0;static int video_stream_copy = 0;static int subtitle_stream_copy = 0;static int video_sync_method= 1;static int audio_sync_method= 0;static int copy_ts= 0;static int opt_shortest = 0; //static int video_global_header = 0;static int rate_emu = 0;#ifdef CONFIG_BKTRstatic char *video_grab_format = "bktr";#else#ifdef CONFIG_VIDEO4LINUX2static char *video_grab_format = "video4linux2";#elsestatic char *video_grab_format = "video4linux";#endif#endifstatic char *video_device = NULL;static char *grab_device = NULL;static int  video_channel = 0;static char *video_standard = "ntsc";static char *audio_grab_format = "audio_device";static char *audio_device = NULL;static int audio_volume = 256;static int using_stdin = 0;static int using_vhook = 0;static int verbose = 1;static int thread_count= 1;static int q_pressed = 0;static int me_range = 0;static int64_t video_size = 0;static int64_t audio_size = 0;static int64_t extra_size = 0;static int nb_frames_dup = 0;static int nb_frames_drop = 0;static int input_sync;static int limit_filesize = 0; //static int pgmyuv_compatibility_hack=0;static int dts_delta_threshold = 10;const char **opt_names=NULL;int opt_name_count=0;AVCodecContext *avctx_opts;#define DEFAULT_PASS_LOGFILENAME "ffmpeg2pass"struct AVInputStream;typedef struct AVOutputStream {    int file_index;          /* file index */    int index;               /* stream index in the output file */    int source_index;        /* AVInputStream index */    AVStream *st;            /* stream in the output file */    int encoding_needed;     /* true if encoding needed for this stream */    int frame_number;    /* input pts and corresponding output pts       for A/V sync */    //double sync_ipts;        /* dts from the AVPacket of the demuxer in second units */    struct AVInputStream *sync_ist; /* input stream to sync against */    int64_t sync_opts;       /* output frame counter, could be changed to some true timestamp */ //FIXME look at frame_number    /* video only */    int video_resample;      /* video_resample and video_crop are mutually exclusive */    AVFrame pict_tmp;      /* temporary image for resampling */    ImgReSampleContext *img_resample_ctx; /* for image resampling */    int video_crop;          /* video_resample and video_crop are mutually exclusive */    int topBand;             /* cropping area sizes */    int leftBand;    int video_pad;           /* video_resample and video_pad are mutually exclusive */    int padtop;              /* padding area sizes */    int padbottom;    int padleft;    int padright;    /* audio only */    int audio_resample;    ReSampleContext *resample; /* for audio resampling */    FifoBuffer fifo;     /* for compression: one audio fifo per codec */    FILE *logfile;} AVOutputStream;typedef struct AVInputStream {    int file_index;    int index;    AVStream *st;    int discard;             /* true if stream data should be discarded */    int decoding_needed;     /* true if the packets must be decoded in 'raw_fifo' */    int64_t sample_index;      /* current sample */    int64_t       start;     /* time when read started */    unsigned long frame;     /* current frame */    int64_t       next_pts;  /* synthetic pts for cases where pkt.pts                                is not defined */    int64_t       pts;       /* current pts */    int is_start;            /* is 1 at the start and after a discontinuity */} AVInputStream;typedef struct AVInputFile {    int eof_reached;      /* true if eof reached */    int ist_index;        /* index of first stream in ist_table */    int buffer_size;      /* current total buffer size */    int buffer_size_max;  /* buffer size at which we consider we can stop                             buffering */    int nb_streams;       /* nb streams we are aware of */} AVInputFile;#ifndef CONFIG_WIN32/* init terminal so that we can grab keys */static struct termios oldtty;static void term_exit(void){    tcsetattr (0, TCSANOW, &oldtty);}static volatile sig_atomic_t received_sigterm = 0;static voidsigterm_handler(int sig){    received_sigterm = sig;    term_exit();}static void term_init(void){    struct termios tty;    tcgetattr (0, &tty);    oldtty = tty;    tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP                          |INLCR|IGNCR|ICRNL|IXON);    tty.c_oflag |= OPOST;    tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);    tty.c_cflag &= ~(CSIZE|PARENB);    tty.c_cflag |= CS8;    tty.c_cc[VMIN] = 1;    tty.c_cc[VTIME] = 0;    tcsetattr (0, TCSANOW, &tty);    signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */    signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */    signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */    /*    register a function to be called at normal program termination    */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -