ffplay: simplify display code
And get rid of frame_queue_prev. Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
0b9b3163f2
commit
37d201aad9
43
ffplay.c
43
ffplay.c
@ -769,14 +769,6 @@ static void frame_queue_next(FrameQueue *f)
|
||||
SDL_UnlockMutex(f->mutex);
|
||||
}
|
||||
|
||||
/* jump back to the previous frame if available by resetting rindex_shown */
|
||||
static int frame_queue_prev(FrameQueue *f)
|
||||
{
|
||||
int ret = f->rindex_shown;
|
||||
f->rindex_shown = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* return the number of undisplayed frames in the queue */
|
||||
static int frame_queue_nb_remaining(FrameQueue *f)
|
||||
{
|
||||
@ -947,7 +939,7 @@ static void video_image_display(VideoState *is)
|
||||
SDL_Rect rect;
|
||||
int i;
|
||||
|
||||
vp = frame_queue_peek(&is->pictq);
|
||||
vp = frame_queue_peek_last(&is->pictq);
|
||||
if (vp->bmp) {
|
||||
if (is->subtitle_st) {
|
||||
if (frame_queue_nb_remaining(&is->subpq) > 0) {
|
||||
@ -1527,9 +1519,6 @@ static void video_refresh(void *opaque, double *remaining_time)
|
||||
}
|
||||
|
||||
if (is->video_st) {
|
||||
int redisplay = 0;
|
||||
if (is->force_refresh)
|
||||
redisplay = frame_queue_prev(&is->pictq);
|
||||
retry:
|
||||
if (frame_queue_nb_remaining(&is->pictq) == 0) {
|
||||
// nothing to do, no picture to display in the queue
|
||||
@ -1543,11 +1532,10 @@ retry:
|
||||
|
||||
if (vp->serial != is->videoq.serial) {
|
||||
frame_queue_next(&is->pictq);
|
||||
redisplay = 0;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
if (lastvp->serial != vp->serial && !redisplay)
|
||||
if (lastvp->serial != vp->serial)
|
||||
is->frame_timer = av_gettime_relative() / 1000000.0;
|
||||
|
||||
if (is->paused)
|
||||
@ -1555,15 +1543,12 @@ retry:
|
||||
|
||||
/* compute nominal last_duration */
|
||||
last_duration = vp_duration(is, lastvp, vp);
|
||||
if (redisplay)
|
||||
delay = 0.0;
|
||||
else
|
||||
delay = compute_target_delay(last_duration, is);
|
||||
delay = compute_target_delay(last_duration, is);
|
||||
|
||||
time= av_gettime_relative()/1000000.0;
|
||||
if (time < is->frame_timer + delay && !redisplay) {
|
||||
if (time < is->frame_timer + delay) {
|
||||
*remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
|
||||
return;
|
||||
goto display;
|
||||
}
|
||||
|
||||
is->frame_timer += delay;
|
||||
@ -1571,18 +1556,16 @@ retry:
|
||||
is->frame_timer = time;
|
||||
|
||||
SDL_LockMutex(is->pictq.mutex);
|
||||
if (!redisplay && !isnan(vp->pts))
|
||||
if (!isnan(vp->pts))
|
||||
update_video_pts(is, vp->pts, vp->pos, vp->serial);
|
||||
SDL_UnlockMutex(is->pictq.mutex);
|
||||
|
||||
if (frame_queue_nb_remaining(&is->pictq) > 1) {
|
||||
Frame *nextvp = frame_queue_peek_next(&is->pictq);
|
||||
duration = vp_duration(is, vp, nextvp);
|
||||
if(!is->step && (redisplay || framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){
|
||||
if (!redisplay)
|
||||
is->frame_drops_late++;
|
||||
if(!is->step && (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){
|
||||
is->frame_drops_late++;
|
||||
frame_queue_next(&is->pictq);
|
||||
redisplay = 0;
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
@ -1607,16 +1590,16 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
display:
|
||||
/* display picture */
|
||||
if (!display_disable && is->show_mode == SHOW_MODE_VIDEO)
|
||||
video_display(is);
|
||||
|
||||
frame_queue_next(&is->pictq);
|
||||
is->force_refresh = 1;
|
||||
|
||||
if (is->step && !is->paused)
|
||||
stream_toggle_pause(is);
|
||||
}
|
||||
display:
|
||||
/* display picture */
|
||||
if (!display_disable && is->force_refresh && is->show_mode == SHOW_MODE_VIDEO && is->pictq.rindex_shown)
|
||||
video_display(is);
|
||||
}
|
||||
is->force_refresh = 0;
|
||||
if (show_status) {
|
||||
|
Loading…
Reference in New Issue
Block a user