1.代码框架

1.1 SDL消息处理
static void event_loop(VideoState *cur_stream)
{
SDL_Event event;
double incr, pos, frac;
for (;;) {
double x;
//SDL event队列不为空,从队列头部取一个event,处理event
refresh_loop_wait_event(cur_stream, &event);
switch (event.type) {
case SDL_KEYDOWN: //键盘按键按下事件
...
switch (event.key.keysym.sym) {
case SDLK_f: //f全屏
toggle_full_screen(cur_stream);
...
case SDLK_s: // S: Step to next frame //s逐帧播放
step_to_next_frame(cur_stream);
...
case SDL_MOUSEBUTTONDOWN: //鼠标按下事件
...
if (event.button.button == SDL_BUTTON_LEFT) { //左键
...
case SDL_MOUSEMOTION: //鼠标移动事件
...
case SDL_WINDOWEVENT:
1.2 解复用线程
/* this thread gets the stream from the disk or the network */
static int read_thread(void *arg)
{
1.3 视频解码线程
static int video_thread(void *arg)
{
1.4 视频播放
/* called to display each frame */
static void video_refresh(void *opaque, double *remaining_time)
{
2.数据结构
3.音视频同步
4.图像格式转换
本文深入探讨ffplay的内部工作原理,包括SDL消息处理、解复用线程、视频解码及播放流程,同时涉及数据结构、音视频同步机制以及图像格式转换的关键技术。
2109

被折叠的 条评论
为什么被折叠?



