/* Copyright (c) 2003 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg 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.1 of the License, or (at your option) any later version.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* simple media player based on the FFmpeg libraries
*/
#include<Windows.h>
#include "config.h"
#include "config_components.h"
#include <inttypes.h>
#include <math.h>
#include <limits.h>
#include <signal.h>
#include <stdint.h>
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/eval.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/dict.h"
#include "libavutil/fifo.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/time.h"
#include "libavutil/bprint.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "libswresample/swresample.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/buffersink.h"
#include "libavfilter/buffersrc.h"
#include <SDL.h>
#include <SDL_thread.h>
#include "cmdutils.h"
#include "opt_common.h"
#pragma comment(lib,"avcodec.lib")
#pragma comment(lib,"avdevice.lib")
#pragma comment(lib,"avfilter.lib")
#pragma comment(lib,"avformat.lib")
#pragma comment(lib,"avutil.lib")
#pragma comment(lib,"swscale.lib")
#pragma comment(lib,"swresample.lib")
#include <stdio.h>
#pragma comment(lib,"SDL2.lib")
//#define av_log(avcl, level, fmt, ...) av_log4(avcl,level,fmt)
const char program_name[] = "ffplay";
const int program_birth_year = 2003;
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
#define MIN_FRAMES 25
#define EXTERNAL_CLOCK_MIN_FRAMES 2
#define EXTERNAL_CLOCK_MAX_FRAMES 10
/* Minimum SDL audio buffer size, in samples. */
#define SDL_AUDIO_MIN_BUFFER_SIZE 512
/* Calculate actual buffer size keeping in mind not cause too frequent audio callbacks */
#define SDL_AUDIO_MAX_CALLBACKS_PER_SEC 30
/* Step size for volume control in dB */
#define SDL_VOLUME_STEP (0.75)
/* no AV sync correction is done if below the minimum AV sync threshold */
#define AV_SYNC_THRESHOLD_MIN 0.04
/* AV sync correction is done if above the maximum AV sync threshold */
#define AV_SYNC_THRESHOLD_MAX 0.1
/* If a frame duration is longer than this, it will not be duplicated to compensate AV sync */
#define AV_SYNC_FRAMEDUP_THRESHOLD 0.1
/* no AV correction is done if too big error */
#define AV_NOSYNC_THRESHOLD 10.0
/* maximum audio speed change to get correct sync */
#define SAMPLE_CORRECTION_PERCENT_MAX 10
/* external clock speed adjustment constants for realtime sources based on buffer fullness */
#define EXTERNAL_CLOCK_SPEED_MIN 0.900
#define EXTERNAL_CLOCK_SPEED_MAX 1.010
#define EXTERNAL_CLOCK_SPEED_STEP 0.001
/* we use about AUDIO_DIFF_AVG_NB A-V differences to make the average */
#define AUDIO_DIFF_AVG_NB 20
/* polls for possible required screen refresh at least this often, should be less than 1/fps */
#define REFRESH_RATE 0.01
/* NOTE: the size must be big enough to compensate the hardware audio buffersize size */
/* TODO: We assume that a decoded and resampled frame fits into this buffer */
#define SAMPLE_ARRAY_SIZE (8 * 65536)
#define CURSOR_HIDE_DELAY 1000000
#define USE_ONEPASS_SUBTITLE_RENDER 1
typedef struct MyAVPacketList {
AVPacket *pkt;
int serial;
} MyAVPacketList;
typedef struct PacketQueue {
AVFifo *pkt_list;
int nb_packets;
int size;
int64_t duration;
int abort_request;
int serial;
SDL_mutex *mutex;
SDL_cond *cond;
} PacketQueue;
#define VIDEO_PICTURE_QUEUE_SIZE 3
#define SUBPICTURE_QUEUE_SIZE 16
#define SAMPLE_QUEUE_SIZE 9
#define FRAME_QUEUE_SIZE FFMAX(SAMPLE_QUEUE_SIZE, FFMAX(VIDEO_PICTURE_QUEUE_SIZE, SUBPICTURE_QUEUE_SIZE))
typedef struct AudioParams {
int freq;
AVChannelLayout ch_layout;
enum AVSampleFormat fmt;
int frame_size;
int bytes_per_sec;
} AudioParams;
typedef struct Clock {
double pts; /* clock base */
double pts_drift; /* clock base minus time at which we updated the clock */
double last_updated;
double speed;
int serial; /* clock is based on a packet with this serial */
int paused;
int *queue_serial; /* pointer to the current packet queue serial, used for obsolete clock detection */
} Clock;
typedef struct FrameData {
int64_t pkt_pos;
} FrameData;
/* Common struct for handling all types of decoded data and allocated render buffers. */
typedef struct Frame {
AVFrame *frame;
AVSubtitle sub;
int serial;
double pts; /* presentation timestamp for the frame */
double duration; /* estimated duration of the frame */
int64_t pos; /* byte position of the frame in the input file */
int width;
int height;
int format;
AVRational sar;
int uploaded;
int flip_v;
} Frame;
typedef struct FrameQueue {
Frame queue[FRAME_QUEUE_SIZE];
int rindex;
int windex;
int size;
int max_size;
int keep_last;
int rindex_shown;
SDL_mutex *mutex;
SDL_cond *cond;
PacketQueue *pktq;
} FrameQueue;
enum {
AV_SYNC_AUDIO_MASTER, /* default choice */
AV_SYNC_VIDEO_MASTER,
AV_SYNC_EXTERNAL_CLOCK, /* synchronize to an external clock */
};
typedef struct Decoder {
AVPacket *pkt;
PacketQueue *queue;
AVCodecContext *avctx;
int pkt_serial;
int finished;
int packet_pending;
SDL_cond *empty_queue_cond;
int64_t start_pts;
AVRational start_pts_tb;
int64_t next_pts;
AVRational next_pts_tb;
SDL_Thread *decoder_tid;
} Decoder;
typedef struct VideoState {
SDL_Thread *read_tid;
const AVInputFormat *iformat;
int abort_request;
int force_refresh;
int paused;
int last_paused;
int queue_attachments_req;
int seek_req;
int seek_flags;
int64_t seek_pos;
int64_t seek_rel;
int read_pause_return;
AVFormatContext *ic;
int realtime;
Clock audclk;
Clock vidclk;
Clock extclk;
FrameQueue pictq;
FrameQueue subpq;
FrameQueue sampq;
Decoder auddec;
Decoder viddec;
Decoder subdec;
int audio_stream;
int av_sync_type;
double audio_clock;
int audio_clock_serial;
double audio_diff_cum; /* used for AV difference average computation */
double audio_diff_avg_coef;
double audio_diff_threshold;
int audio_diff_avg_count;
AVStream *audio_st;
PacketQueue audioq;
int audio_hw_buf_size;
uint8_t *audio_buf;
uint8_t *audio_buf1;
unsigned int audio_buf_size; /* in bytes */
unsigned int audio_buf1_size;
int audio_buf_index; /* in bytes */
int audio_write_buf_size;
int audio_volume;
int muted;
struct AudioParams audio_src;
struct AudioParams audio_filter_src;
struct AudioParams audio_tgt;
struct SwrContext *swr_ctx;
int frame_drops_early;
int frame_drops_late;
enum ShowMode {
SHOW_MODE_NONE = -1, SHOW_MODE_VIDEO = 0, SHOW_MODE_WAVES, SHOW_MODE_RDFT, SHOW_MODE_NB
} show_mode;
int16_t sample_array[SAMPLE_ARRAY_SIZE];
int sample_array_index;
int last_i_start;
RDFTContext *rdft;
int rdft_bits;
FFTSample *rdft_data;
int xpos;
double last_vis_time;
SDL_Texture *vis_texture;
SDL_Texture *su
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ffplay播放器移移植 mfc工程 (264个子文件)
slamtv60.264 4.8MB
mfcffplay.aps 106KB
ffplay.c 136KB
opt_common.c 47KB
cmdutils.c 31KB
mfcffplayDlg.cpp 4KB
mfcffplay.cpp 3KB
pch.cpp 158B
avcodec-60.dll 12.11MB
avfilter-9.dll 3.85MB
SDL2.dll 2.39MB
avformat-60.dll 2.3MB
avutil-58.dll 1024KB
swscale-7.dll 669KB
swresample-4.dll 213KB
avdevice-60.dll 192KB
postproc-57.dll 75KB
mfcffplay.vcxproj.filters 2KB
SDL_opengl_glext.h 844KB
SDL_opengles2_gl2ext.h 236KB
avcodec.h 115KB
SDL_hints.h 108KB
avformat.h 107KB
SDL_egl.h 106KB
SDL_opengl.h 79KB
SDL_video.h 78KB
SDL_render.h 72KB
config_components.h 69KB
SDL_audio.h 58KB
avfilter.h 55KB
SDL_events.h 46KB
SDL_haptic.h 42KB
SDL_opengles2_gl2.h 42KB
pixfmt.h 40KB
SDL_gamecontroller.h 39KB
SDL_joystick.h 38KB
opt.h 36KB
SDL_surface.h 36KB
frame.h 33KB
channel_layout.h 32KB
avio.h 31KB
SDL_stdinc.h 29KB
SDL_rwops.h 27KB
swresample.h 25KB
SDL_pixels.h 24KB
hwcontext.h 24KB
packet.h 23KB
config.h 21KB
SDL_system.h 20KB
mem.h 20KB
intreadwrite.h 18KB
codec_id.h 17KB
SDL_hidapi.h 17KB
SDL_cpuinfo.h 17KB
SDL_thread.h 17KB
common.h 17KB
SDL_mouse.h 17KB
SDL_scancode.h 17KB
swscale.h 16KB
pixdesc.h 16KB
SDL_keycode.h 15KB
fifo.h 15KB
cmdutils.h 15KB
avstring.h 15KB
SDL_atomic.h 14KB
hdr_dynamic_metadata.h 14KB
SDL_mutex.h 14KB
imgutils.h 14KB
avdevice.h 13KB
codec.h 13KB
SDL_test_fuzzer.h 13KB
SDL_rect.h 13KB
log.h 12KB
SDL_assert.h 12KB
buffer.h 12KB
SDL_log.h 11KB
bsf.h 11KB
SDL_syswm.h 11KB
SDL_opengles2_khrplatform.h 11KB
SDL_keyboard.h 11KB
opt_common.h 10KB
samplefmt.h 10KB
SDL_sensor.h 10KB
hdr_dynamic_vivid_metadata.h 10KB
avutil.h 10KB
SDL_endian.h 10KB
hwcontext_vulkan.h 9KB
dict.h 9KB
SDL_blendmode.h 9KB
wchar_filename.h 9KB
SDL_config.h 9KB
SDL_main.h 9KB
bprint.h 8KB
SDL_vulkan.h 8KB
film_grain_params.h 8KB
hash.h 8KB
SDL.h 8KB
mathematics.h 8KB
spherical.h 8KB
parseutils.h 8KB
共 264 条
- 1
- 2
- 3
资源评论
qq00769539
- 粉丝: 74
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功