From 318bf57c3fb89a96008b114731e59063301ad6d1 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 24 Nov 2013 22:51:13 +0100 Subject: [PATCH 1/4] ffplay: do not wait for flushing the picture queue on flush packet It is no longer necessary. Also do frame timer and video current pos reset in the main thread because with the wait removed, the timing would not be optimal in the read thread. Signed-off-by: Marton Balint --- ffplay.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ffplay.c b/ffplay.c index bcbc30d545..104598b78c 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1376,10 +1376,14 @@ retry: if (vp->serial != is->videoq.serial) { pictq_next_picture(is); + is->video_current_pos = -1; redisplay = 0; goto retry; } + if (lastvp->serial != vp->serial && !redisplay) + is->frame_timer = av_gettime() / 1000000.0; + if (is->paused) goto display; @@ -1670,15 +1674,6 @@ static int get_video_frame(VideoState *is, AVFrame *frame, AVPacket *pkt, int *s if (pkt->data == flush_pkt.data) { avcodec_flush_buffers(is->video_st->codec); - - SDL_LockMutex(is->pictq_mutex); - // Make sure there are no long delay timers (ideally we should just flush the queue but that's harder) - while (is->pictq_size && !is->videoq.abort_request) { - SDL_CondWait(is->pictq_cond, is->pictq_mutex); - } - is->video_current_pos = -1; - is->frame_timer = (double)av_gettime() / 1000000.0; - SDL_UnlockMutex(is->pictq_mutex); return 0; } From eff4820eb20400926649edd61962b5d349489e70 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 30 Nov 2013 21:18:05 +0100 Subject: [PATCH 2/4] ffplay: remove no longer necessary codec flush It was introduced in c2e8691c07ca52de7b6b00ba8f2b30c56fd786d7, but since we no longer no longer provide a custom get_buffer callback, the original cause of the issue is gone. Signed-off-by: Marton Balint --- ffplay.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 104598b78c..2eba224f8f 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1990,7 +1990,6 @@ static int video_thread(void *arg) goto the_end; } the_end: - avcodec_flush_buffers(is->video_st->codec); #if CONFIG_AVFILTER avfilter_graph_free(&graph); #endif From 2b377fb4c0539dc50b417be98e9ca78c85697520 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 1 Dec 2013 13:25:05 +0100 Subject: [PATCH 3/4] ffplay: factor out function setting default window size Signed-off-by: Marton Balint --- ffplay.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ffplay.c b/ffplay.c index 2eba224f8f..30ee5fdf43 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1066,20 +1066,24 @@ static void sigterm_handler(int sig) exit(123); } +static void set_default_window_size(VideoPicture *vp) +{ + SDL_Rect rect; + calculate_display_rect(&rect, 0, 0, INT_MAX, vp->height, vp); + default_width = rect.w; + default_height = rect.h; +} + static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp) { int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; int w,h; - SDL_Rect rect; if (is_full_screen) flags |= SDL_FULLSCREEN; else flags |= SDL_RESIZABLE; - if (vp && vp->width) { - calculate_display_rect(&rect, 0, 0, INT_MAX, vp->height, vp); - default_width = rect.w; - default_height = rect.h; - } + if (vp && vp->width) + set_default_window_size(vp); if (is_full_screen && fs_screen_width) { w = fs_screen_width; From ad01fae86d80c8a7ac87f6203d87418b898e62ab Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 1 Dec 2013 14:21:25 +0100 Subject: [PATCH 4/4] ffplay: set default window size before starting audio Fixes ticket #2381. Signed-off-by: Marton Balint --- ffplay.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ffplay.c b/ffplay.c index 30ee5fdf43..4893ebcb2f 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2818,6 +2818,13 @@ static int read_thread(void *arg) } is->show_mode = show_mode; + if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) { + AVStream *st = ic->streams[st_index[AVMEDIA_TYPE_VIDEO]]; + AVCodecContext *avctx = st->codec; + VideoPicture vp = {.width = avctx->width, .height = avctx->height, .sar = av_guess_sample_aspect_ratio(ic, st, NULL)}; + if (vp.width) + set_default_window_size(&vp); + } /* open the streams */ if (st_index[AVMEDIA_TYPE_AUDIO] >= 0) {