From 97660b8b137fd3161d669f2e894740af75608c04 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Tue, 25 Dec 2012 22:35:53 +0100 Subject: [PATCH 1/6] ffplay: move frame step pause from the video thread to video_refresh This way we pause the video right after we displayed a new frame. Partially fixes ticket #2053. Signed-off-by: Marton Balint --- ffplay.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ffplay.c b/ffplay.c index 38673b5de1..070fbd7ea6 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1396,6 +1396,9 @@ display: video_display(is); pictq_next_picture(is); + + if (is->step && !is->paused) + stream_toggle_pause(is); } } else if (is->audio_st) { /* draw the next audio frame */ @@ -1923,9 +1926,6 @@ static int video_thread(void *arg) if (ret < 0) goto the_end; - - if (is->step) - stream_toggle_pause(is); } the_end: avcodec_flush_buffers(is->video_st->codec); From 4e33d8ebb39f4c1869e078a0cc3b808a02aa16c4 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Wed, 26 Dec 2012 19:53:58 +0100 Subject: [PATCH 2/6] ffplay: only drop frames if not in frame step mode Fixes ticket #2053. Signed-off-by: Marton Balint --- ffplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 070fbd7ea6..f9ea20d9d9 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1339,7 +1339,7 @@ retry: if (is->pictq_size > 1) { VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE]; duration = nextvp->pts - vp->pts; - if((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){ is->frame_drops_late++; pictq_next_picture(is); goto retry; From 0ca4e9f014839ce26a3975e67a32c36b289d8801 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Fri, 21 Dec 2012 00:32:18 +0100 Subject: [PATCH 3/6] ffplay: reset external clock to unknown on start Fixes a delay and initial frame drops on starting realtime streams with external clock. Signed-off-by: Marton Balint --- ffplay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index f9ea20d9d9..5f4f111349 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2835,7 +2835,8 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat) is->continue_read_thread = SDL_CreateCond(); - update_external_clock_pts(is, 0.0); + //FIXME: use a cleaner way to signal obsolete external clock... + update_external_clock_pts(is, (double)AV_NOPTS_VALUE); update_external_clock_speed(is, 1.0); is->audio_current_pts_drift = -av_gettime() / 1000000.0; is->video_current_pts_drift = is->audio_current_pts_drift; From ef7f3b08703f334768f61c2c5817b6e42c05c08a Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 1 Dec 2012 02:27:29 +0100 Subject: [PATCH 4/6] ffplay: hide cursor on no mouse movement Signed-off-by: Marton Balint --- ffplay.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ffplay.c b/ffplay.c index 5f4f111349..caba6d7e9b 100644 --- a/ffplay.c +++ b/ffplay.c @@ -90,6 +90,8 @@ const int program_birth_year = 2003; /* TODO: We assume that a decoded and resampled frame fits into this buffer */ #define SAMPLE_ARRAY_SIZE (8 * 65536) +#define CURSOR_HIDE_DELAY 1000000 + static int64_t sws_flags = SWS_BICUBIC; typedef struct MyAVPacketList { @@ -303,6 +305,8 @@ static const char *audio_codec_name; static const char *subtitle_codec_name; static const char *video_codec_name; static int rdftspeed = 20; +static int64_t cursor_last_shown; +static int cursor_hidden = 0; #if CONFIG_AVFILTER static char *vfilters = NULL; #endif @@ -3038,6 +3042,11 @@ static void event_loop(VideoState *cur_stream) break; } case SDL_MOUSEMOTION: + if (cursor_hidden) { + SDL_ShowCursor(1); + cursor_hidden = 0; + } + cursor_last_shown = av_gettime(); if (event.type == SDL_MOUSEBUTTONDOWN) { x = event.button.x; } else { @@ -3084,6 +3093,10 @@ static void event_loop(VideoState *cur_stream) alloc_picture(event.user.data1); break; case FF_REFRESH_EVENT: + if (!cursor_hidden && av_gettime() - cursor_last_shown > CURSOR_HIDE_DELAY) { + SDL_ShowCursor(0); + cursor_hidden = 1; + } video_refresh(event.user.data1); cur_stream->refresh = 0; break; From ec89ea30225780fedf702d7e8740fbf92418112c Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Wed, 26 Dec 2012 00:06:19 +0100 Subject: [PATCH 5/6] ffplay: always display audio visualization if mode is set Fixes ticket #1903. Signed-off-by: Marton Balint --- ffplay.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/ffplay.c b/ffplay.c index caba6d7e9b..c8dbda58a5 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1296,6 +1296,9 @@ static void video_refresh(void *opaque) if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime) check_external_clock_speed(is); + if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) + video_display(is); + if (is->video_st) { if (is->force_refresh) pictq_prev_picture(is); @@ -1396,7 +1399,7 @@ retry: display: /* display picture */ - if (!display_disable) + if (!display_disable && is->show_mode == SHOW_MODE_VIDEO) video_display(is); pictq_next_picture(is); @@ -1404,15 +1407,6 @@ display: if (is->step && !is->paused) stream_toggle_pause(is); } - } else if (is->audio_st) { - /* draw the next audio frame */ - - /* if only audio stream, then display the audio bars (better - than nothing, just to test the implementation */ - - /* display picture */ - if (!display_disable) - video_display(is); } is->force_refresh = 0; if (show_status) { From 92b50b71a1e4e78fa2828dc2e0a4428674a8a9b0 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Wed, 26 Dec 2012 00:26:59 +0100 Subject: [PATCH 6/6] ffplay: fix type of time_diff in waveform display Fixes time diff overflow visible as showing the same few waveforms in a loop at the end of file. Signed-off-by: Marton Balint --- ffplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index c8dbda58a5..7d47bcdc2c 100644 --- a/ffplay.c +++ b/ffplay.c @@ -828,7 +828,7 @@ static void video_audio_display(VideoState *s) { int i, i_start, x, y1, y, ys, delay, n, nb_display_channels; int ch, channels, h, h2, bgcolor, fgcolor; - int16_t time_diff; + int64_t time_diff; int rdft_bits, nb_freq; for (rdft_bits = 1; (1 << rdft_bits) < 2 * s->height; rdft_bits++)