[FFmpeg-cvslog] ffplay: requeue last picture on forced video refresh
Marton Balint
git at videolan.org
Sat Sep 1 15:04:52 CEST 2012
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Aug 26 15:18:00 2012 +0200| [4a45e722e373c85cae7b5d57fb6bb7e295e664e0] | committer: Marton Balint
ffplay: requeue last picture on forced video refresh
Fixes ticket #1609.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4a45e722e373c85cae7b5d57fb6bb7e295e664e0
---
ffplay.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index 9efc93a..2157131 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -95,7 +95,7 @@ typedef struct PacketQueue {
SDL_cond *cond;
} PacketQueue;
-#define VIDEO_PICTURE_QUEUE_SIZE 2
+#define VIDEO_PICTURE_QUEUE_SIZE 3
#define SUBPICTURE_QUEUE_SIZE 4
typedef struct VideoPicture {
@@ -1132,6 +1132,22 @@ static void pictq_next_picture(VideoState *is) {
SDL_UnlockMutex(is->pictq_mutex);
}
+static void pictq_prev_picture(VideoState *is) {
+ VideoPicture *prevvp;
+ /* update queue size and signal for the previous picture */
+ prevvp = &is->pictq[(is->pictq_rindex + VIDEO_PICTURE_QUEUE_SIZE - 1) % VIDEO_PICTURE_QUEUE_SIZE];
+ if (prevvp->allocated && !prevvp->skip) {
+ SDL_LockMutex(is->pictq_mutex);
+ if (is->pictq_size < VIDEO_PICTURE_QUEUE_SIZE) {
+ if (--is->pictq_rindex == -1)
+ is->pictq_rindex = VIDEO_PICTURE_QUEUE_SIZE - 1;
+ is->pictq_size++;
+ }
+ SDL_CondSignal(is->pictq_cond);
+ SDL_UnlockMutex(is->pictq_mutex);
+ }
+}
+
static void update_video_pts(VideoState *is, double pts, int64_t pos) {
double time = av_gettime() / 1000000.0;
/* update current video pts */
@@ -1251,8 +1267,7 @@ display:
if (!display_disable)
video_display(is);
- if (!is->paused)
- pictq_next_picture(is);
+ pictq_next_picture(is);
}
} else if (is->audio_st) {
/* draw the next audio frame */
@@ -1368,7 +1383,8 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_
/* wait until we have space to put a new picture */
SDL_LockMutex(is->pictq_mutex);
- while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
+ /* keep the last already displayed picture in the queue */
+ while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE - 1 &&
!is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex);
}
@@ -2872,6 +2888,8 @@ static void event_loop(VideoState *cur_stream)
alloc_picture(event.user.data1);
break;
case FF_REFRESH_EVENT:
+ if (cur_stream->force_refresh)
+ pictq_prev_picture(event.user.data1);
video_refresh(event.user.data1);
cur_stream->refresh = 0;
break;
More information about the ffmpeg-cvslog
mailing list