Commit 37d201aa authored by Marton Balint's avatar Marton Balint

ffplay: simplify display code

And get rid of frame_queue_prev.
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 0b9b3163
...@@ -769,14 +769,6 @@ static void frame_queue_next(FrameQueue *f) ...@@ -769,14 +769,6 @@ static void frame_queue_next(FrameQueue *f)
SDL_UnlockMutex(f->mutex); 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 */ /* return the number of undisplayed frames in the queue */
static int frame_queue_nb_remaining(FrameQueue *f) static int frame_queue_nb_remaining(FrameQueue *f)
{ {
...@@ -947,7 +939,7 @@ static void video_image_display(VideoState *is) ...@@ -947,7 +939,7 @@ static void video_image_display(VideoState *is)
SDL_Rect rect; SDL_Rect rect;
int i; int i;
vp = frame_queue_peek(&is->pictq); vp = frame_queue_peek_last(&is->pictq);
if (vp->bmp) { if (vp->bmp) {
if (is->subtitle_st) { if (is->subtitle_st) {
if (frame_queue_nb_remaining(&is->subpq) > 0) { if (frame_queue_nb_remaining(&is->subpq) > 0) {
...@@ -1527,9 +1519,6 @@ static void video_refresh(void *opaque, double *remaining_time) ...@@ -1527,9 +1519,6 @@ static void video_refresh(void *opaque, double *remaining_time)
} }
if (is->video_st) { if (is->video_st) {
int redisplay = 0;
if (is->force_refresh)
redisplay = frame_queue_prev(&is->pictq);
retry: retry:
if (frame_queue_nb_remaining(&is->pictq) == 0) { if (frame_queue_nb_remaining(&is->pictq) == 0) {
// nothing to do, no picture to display in the queue // nothing to do, no picture to display in the queue
...@@ -1543,11 +1532,10 @@ retry: ...@@ -1543,11 +1532,10 @@ retry:
if (vp->serial != is->videoq.serial) { if (vp->serial != is->videoq.serial) {
frame_queue_next(&is->pictq); frame_queue_next(&is->pictq);
redisplay = 0;
goto retry; goto retry;
} }
if (lastvp->serial != vp->serial && !redisplay) if (lastvp->serial != vp->serial)
is->frame_timer = av_gettime_relative() / 1000000.0; is->frame_timer = av_gettime_relative() / 1000000.0;
if (is->paused) if (is->paused)
...@@ -1555,15 +1543,12 @@ retry: ...@@ -1555,15 +1543,12 @@ retry:
/* compute nominal last_duration */ /* compute nominal last_duration */
last_duration = vp_duration(is, lastvp, vp); last_duration = vp_duration(is, lastvp, vp);
if (redisplay) delay = compute_target_delay(last_duration, is);
delay = 0.0;
else
delay = compute_target_delay(last_duration, is);
time= av_gettime_relative()/1000000.0; 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); *remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
return; goto display;
} }
is->frame_timer += delay; is->frame_timer += delay;
...@@ -1571,18 +1556,16 @@ retry: ...@@ -1571,18 +1556,16 @@ retry:
is->frame_timer = time; is->frame_timer = time;
SDL_LockMutex(is->pictq.mutex); SDL_LockMutex(is->pictq.mutex);
if (!redisplay && !isnan(vp->pts)) if (!isnan(vp->pts))
update_video_pts(is, vp->pts, vp->pos, vp->serial); update_video_pts(is, vp->pts, vp->pos, vp->serial);
SDL_UnlockMutex(is->pictq.mutex); SDL_UnlockMutex(is->pictq.mutex);
if (frame_queue_nb_remaining(&is->pictq) > 1) { if (frame_queue_nb_remaining(&is->pictq) > 1) {
Frame *nextvp = frame_queue_peek_next(&is->pictq); Frame *nextvp = frame_queue_peek_next(&is->pictq);
duration = vp_duration(is, vp, nextvp); 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(!is->step && (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){
if (!redisplay) is->frame_drops_late++;
is->frame_drops_late++;
frame_queue_next(&is->pictq); frame_queue_next(&is->pictq);
redisplay = 0;
goto retry; goto retry;
} }
} }
...@@ -1607,16 +1590,16 @@ 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); frame_queue_next(&is->pictq);
is->force_refresh = 1;
if (is->step && !is->paused) if (is->step && !is->paused)
stream_toggle_pause(is); 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; is->force_refresh = 0;
if (show_status) { if (show_status) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment