summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2013-01-02 01:00:12 +0100
committerMarton Balint <cus@passwd.hu>2013-01-19 00:48:06 +0100
commit1427c6842d216a7071bdb46c8365f15187bc7ffe (patch)
tree21e1dbb280027ea2b4258c37c1a467df46fc8c41 /ffplay.c
parentd00df260ca3341e5cacdd53fb08c42b05fb1d442 (diff)
ffplay: use videoq.serial to detect obsolete frames
Previously VideoPicture->skip was used for that, using videoq.serial enables us to detect obsolete frames right after pushing flush_pkt to the packet queue, so we don't have to wait for the decoder thread to pop the flush packet anymore. This is good because until now a full video picture queue may have blocked the decoder thread. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/ffplay.c b/ffplay.c
index 428c78e747..a46eb8661e 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -116,7 +116,6 @@ typedef struct PacketQueue {
typedef struct VideoPicture {
double pts; // presentation timestamp for this picture
int64_t pos; // byte position in file
- int skip;
SDL_Overlay *bmp;
int width, height; /* source height & width */
AVRational sample_aspect_ratio;
@@ -1261,7 +1260,7 @@ 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) {
+ if (prevvp->allocated && prevvp->serial == is->videoq.serial) {
SDL_LockMutex(is->pictq_mutex);
if (is->pictq_size < VIDEO_PICTURE_QUEUE_SIZE - 1) {
if (--is->pictq_rindex == -1)
@@ -1316,7 +1315,7 @@ retry:
/* dequeue the picture */
vp = &is->pictq[is->pictq_rindex];
- if (vp->skip) {
+ if (vp->serial != is->videoq.serial) {
pictq_next_picture(is);
goto retry;
}
@@ -1619,7 +1618,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_
vp->pts = pts;
vp->pos = pos;
- vp->skip = 0;
vp->serial = serial;
/* now we can update the picture count */
@@ -1634,7 +1632,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_
static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt, int *serial)
{
- int got_picture, i;
+ int got_picture;
if (packet_queue_get(&is->videoq, pkt, 1, serial) < 0)
return -1;
@@ -1644,9 +1642,6 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke
SDL_LockMutex(is->pictq_mutex);
// Make sure there are no long delay timers (ideally we should just flush the queue but that's harder)
- for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) {
- is->pictq[i].skip = 1;
- }
while (is->pictq_size && !is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex);
}