#include <string.h>
#ifdef __cplusplus
extern "c" {
#endif
#include <windows.h>
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "swscale.lib")
#include "SDL/include/SDL.h"
#include "SDL/include/SDL_thread.h"
#pragma comment(lib, "SDL/lib/SDL.lib")
#pragma comment(lib, "SDL/lib/SDLmain.lib")
//#ifdef CONFIG_WIN32 //sometimes we shoud use this ,but sometimes not.
#undef main // We don't want SDL to override our main()
#undef exit
//#endif
/*
* ffplay : Simple Media Player based on the FFmpeg libraries
* Copyright (c) 2003 Fabrice Bellard
*
* This file avState part of FFmpeg.
*
* FFmpeg avState 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 avState 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
*/
//#include "inttypes.h"
#include <math.h>
#include <limits.h>
#include "libavutil/avstring.h"
#include "libavutil/colorspace.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avassert.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavcodec/audioconvert.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "unistd.h"
#include <assert.h>
const char program_name[] = "ffplay";
const int program_birth_year = 2003;
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
#define MIN_AUDIOQ_SIZE (20 * 16 * 1024)
#define MIN_FRAMES 5
/* SDL audio buffer size, in samples. Should be small to have precise
A/V sync as SDL does not have hardware buffer fullness info. */
#define SDL_AUDIO_BUFFER_SIZE 1024
/* no AV sync correction avState done if below the AV sync threshold */
#define AV_SYNC_THRESHOLD 0.01
/* no AV correction avState done if too big error */
#define AV_NOSYNC_THRESHOLD 10.0
#define FRAME_SKIP_FACTOR 0.05
/* maximum audio speed change to get correct sync */
#define SAMPLE_CORRECTION_PERCENT_MAX 10
/* we use about AUDIO_DIFF_AVG_NB A-V differences to make the average */
#define AUDIO_DIFF_AVG_NB 20
/* NOTE: the size must be big enough to compensate the hardware audio buffersize size */
#define SAMPLE_ARRAY_SIZE (2*65536)
#define ALPHA_BLEND(a, oldp, newp, s)\
((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s))
#define RGBA_IN(r, g, b, a, s)\
{\
unsigned int v = ((const uint32_t *)(s))[0];\
a = (v >> 24) & 0xff;\
r = (v >> 16) & 0xff;\
g = (v >> 8) & 0xff;\
b = v & 0xff;\
}
#define YUVA_IN(y, u, v, a, s, pal)\
{\
unsigned int val = ((const uint32_t *)(pal))[*(const uint8_t*)(s)];\
a = (val >> 24) & 0xff;\
y = (val >> 16) & 0xff;\
u = (val >> 8) & 0xff;\
v = val & 0xff;\
}
#define YUVA_OUT(d, y, u, v, a)\
{\
((uint32_t *)(d))[0] = (a << 24) | (y << 16) | (u << 8) | v;\
}
#define BPP 1
typedef struct PacketQueue
{
AVPacketList *first_packet, *last_packet;
int nb_packets;
int size;
int abort_request;
SDL_mutex *mutex;
SDL_cond *cond;
} PacketQueue;
#define VIDEO_PICTURE_QUEUE_SIZE 2
#define SUBPICTURE_QUEUE_SIZE 4
typedef struct VideoPicture
{
double pts; ///<presentation time stamp for this picture
double target_clock; ///<av_gettime() time at which this should be displayed ideally
int64_t pos; ///<byte position in file
SDL_Overlay *bmp;
int width, height; /* source height & width */
int allocated;
enum PixelFormat pix_fmt;
} VideoPicture;
typedef struct SubPicture
{
double pts; /* presentation time stamp for this picture */
AVSubtitle sub;
} SubPicture;
enum
{
AV_SYNC_AUDIO_MASTER, /* default choice */
AV_SYNC_VIDEO_MASTER,
AV_SYNC_EXTERNAL_CLOCK, /* synchronize to an external clock */
};
static int wanted_stream[AVMEDIA_TYPE_NB] =
{
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_SUBTITLE,
};
typedef struct VideoState
{
SDL_Thread *read_tid;
SDL_Thread *video_tid;
SDL_Thread *refresh_tid;
AVInputFormat *iformat;
int no_background;
int abort_request;
int paused;
int last_paused;
int seek_req;
int seek_flags;
int64_t seek_pos;
int64_t seek_rel;
int read_pause_return;
AVFormatContext *pFormatCtx;
int audio_stream;
int av_sync_type;
double external_clock; /* external clock base */
int64_t external_clock_time;
double audio_clock;
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;
/* samples output by the codec. we reserve more space for avsync
compensation */
DECLARE_ALIGNED(16, uint8_t, audio_buf1)[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2];
DECLARE_ALIGNED(16, uint8_t, audio_buf2)[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2];
uint8_t *audio_buf;
unsigned int audio_buf_size; /* in bytes */
int audio_buf_index; /* in bytes */
AVPacket audio_packet_temp;
AVPacket audio_packet;
enum AVSampleFormat audio_src_fmt;
AVAudioConvert *reformat_ctx;
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;
SDL_Thread *subtitle_tid;
int subtitle_stream;
int subtitle_stream_changed;
AVStream *subtitle_st;
PacketQueue subtitleq;
SubPicture subpq[SUBPICTURE_QUEUE_SIZE];
int subpq_size, subpq_rindex, subpq_windex;
SDL_mutex *subpq_mutex;
SDL_cond *subpq_cond;
double frame_timer;
double frame_last_pts;
double frame_last_delay;
double video_clock; ///<pts of last decoded frame / predicted pts of next decoded frame
int video_stream;
AVStream *video_st;
PacketQueue videoq;
double video_current_pts; ///<current displayed pts (different from video_clock if frame fifos are used)
double video_current_pts_drift; ///<video_current_pts - time (av_gettime) at which we updated video_current_pts - used to have running video pts
int64_t video_current_pos; ///<current displayed file pos
VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
int pictq_size, pictq_rindex, pictq_windex;
SDL_mutex *pictq_mutex;
SDL_cond *pictq_cond;
struct SwsContext *img_convert_ctx;
char filename[1024];
int width, height, xleft, ytop ;
float skip_frames;
float skip_frames_index;
int refresh;
int screen_height; //屏幕高度
int screen_width; //屏幕宽度
int is_full_screen; //全屏幕
int64_t audio_callback_time; //回调时间
int display_disable; //是否显示
} VideoState;
/* options specified by the user */
//static AVInputFormat *file_iformat;
//static const char *input_filename;
//static const char *window_title;
//static int fs_screen_width;
//static int fs_screen_height;
//static int screen_width = 0;
//static int screen_height = 0;
//static int frame_width = 0;
//static int frame_height = 0;
//static e
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
用vs2008建立的ffmpeg的工程,并有ffplay的示例播放器。当前国内关于ffmpeg的资料并不多,次资料算作是比较重要的资料,推荐下载!-Ffmpeg built with vs2008 project, and ffplay example player. Information on current domestic ffmpeg is not much time information counted as more important information, recommended download!
资源推荐
资源详情
资源评论
收起资源包目录
win7 windows xp用vs2008建立的ffmpeg的工程 (136个子文件)
test.c 87KB
mt.dep 65B
avcodec.dll 11.9MB
avformat.dll 2.35MB
swscale.dll 357KB
SDL.dll 322KB
SDL.dll 317KB
avfilter.dll 118KB
avutil.dll 116KB
postproc.dll 113KB
avcore.dll 63KB
avdevice.dll 18KB
test.exe 572KB
SDL_opengl.h 328KB
avcodec.h 133KB
avformat.h 55KB
SDL_video.h 37KB
avfilter.h 33KB
avio.h 20KB
SDL_stdinc.h 16KB
intreadwrite.h 14KB
SDL_events.h 13KB
swscale.h 12KB
common.h 11KB
SDL_audio.h 11KB
pixfmt.h 11KB
opt.h 8KB
inttypes.h 8KB
SDL_keysym.h 7KB
stdint.h 7KB
xvmc.h 7KB
pixdesc.h 6KB
eval.h 6KB
SDL_syswm.h 6KB
dirent.h 6KB
SDL_cdrom.h 6KB
SDL_endian.h 6KB
SDL_mutex.h 6KB
SDL_joystick.h 5KB
imgutils.h 5KB
begin_code.h 5KB
log.h 5KB
SDL_rwops.h 5KB
SDL_mouse.h 5KB
mem.h 5KB
avstring.h 5KB
SDL_config_win32.h 4KB
SDL_timer.h 4KB
SDL_thread.h 4KB
SDL_config_macosx.h 4KB
audioconvert.h 4KB
SDL_keyboard.h 4KB
avfiltergraph.h 4KB
network.h 4KB
vaapi.h 4KB
rational.h 4KB
audioconvert.h 4KB
colorspace.h 4KB
SDL_config_os2.h 4KB
fifo.h 4KB
mathematics.h 4KB
postprocess.h 3KB
SDL.h 3KB
bswap.h 3KB
SDL_config_symbian.h 3KB
avutil.h 3KB
parseutils.h 3KB
SDL_config_nds.h 3KB
error.h 3KB
attributes.h 3KB
avfft.h 3KB
SDL_main.h 3KB
vdpau.h 3KB
SDL_config_dreamcast.h 3KB
SDL_config_macos.h 3KB
float_cast.h 3KB
SDL_loadso.h 3KB
SDL_platform.h 3KB
SDL_version.h 3KB
lzo.h 2KB
samplefmt.h 2KB
SDL_cpuinfo.h 2KB
cpu.h 2KB
SDL_config_amiga.h 2KB
avcore.h 2KB
avassert.h 2KB
SDL_quit.h 2KB
lfg.h 2KB
SDL_config_minimal.h 2KB
intfloat_readwrite.h 2KB
SDL_active.h 2KB
avdevice.h 2KB
SDL_error.h 2KB
base64.h 2KB
dxva2.h 2KB
sha1.h 2KB
opt.h 2KB
close_code.h 1KB
crc.h 1KB
SDL_config.h 1KB
共 136 条
- 1
- 2
gloxing
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页