[FFmpeg-cvslog] ffplay: simplify display code
Marton Balint
git at videolan.org
Tue May 31 00:53:54 CEST 2016
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Thu Nov 26 00:25:47 2015 +0100| [37d201aad9f7e7f233955345aee1198421a68f5e] | committer: Marton Balint
ffplay: simplify display code
And get rid of frame_queue_prev.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37d201aad9f7e7f233955345aee1198421a68f5e
---
ffplay.c | 43 +++++++++++++------------------------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index d5fcde8..11c5091 100644
--- a/ffplay.c
+++ b/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) {
More information about the ffmpeg-cvslog
mailing list