[PATCH] ffplay: force refresh event when the SDL window is resized
Address roundup issue #604, #1031, #1804. --- ffplay.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ffplay.c b/ffplay.c index 5032586..a6d2cd2 100644 --- a/ffplay.c +++ b/ffplay.c @@ -132,6 +132,7 @@ typedef struct VideoState { AVInputFormat *iformat; int no_background; int abort_request; + int force_refresh; int paused; int last_paused; int seek_req; @@ -1119,9 +1120,15 @@ static void video_refresh_timer(void *opaque) if (is->video_st) { retry: - if (is->pictq_size == 0) { - //nothing to do, no picture to display in the que - } else { + if (is->pictq_size == 0 && is->force_refresh) { + // display last picture in the queue + SDL_LockMutex(is->pictq_mutex); + is->pictq_size++; + is->pictq_rindex = (is->pictq_rindex + VIDEO_PICTURE_QUEUE_SIZE -1) % VIDEO_PICTURE_QUEUE_SIZE; + SDL_CondSignal(is->pictq_cond); + SDL_UnlockMutex(is->pictq_mutex); + } + if (is->pictq_size) { double time= av_gettime()/1000000.0; double next_target; /* dequeue the picture */ @@ -1140,7 +1147,7 @@ retry: }else{ next_target= vp->target_clock + is->video_clock - vp->pts; //FIXME pass durations cleanly } - if(framedrop && time > next_target){ + if (framedrop && !is->force_refresh && time > next_target) { is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR; if(is->pictq_size > 1 || time > next_target + 0.5){ /* update queue size and signal for next picture */ @@ -1211,6 +1218,7 @@ retry: is->pictq_size--; SDL_CondSignal(is->pictq_cond); SDL_UnlockMutex(is->pictq_mutex); + is->force_refresh = 0; } } else if (is->audio_st) { /* draw the next audio frame */ @@ -2759,6 +2767,8 @@ static void event_loop(void) break; case SDLK_f: toggle_full_screen(); + if (cur_stream) + cur_stream->force_refresh = 1; break; case SDLK_p: case SDLK_SPACE: @@ -2813,6 +2823,7 @@ static void event_loop(void) pos += incr; stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0); } + cur_stream->force_refresh = 1; } break; default: @@ -2864,6 +2875,7 @@ static void event_loop(void) SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); screen_width = cur_stream->width = event.resize.w; screen_height= cur_stream->height= event.resize.h; + cur_stream->force_refresh = 1; } break; case SDL_QUIT: @@ -2881,6 +2893,12 @@ static void event_loop(void) default: break; } + + if (cur_stream && cur_stream->force_refresh) { + event.type = FF_REFRESH_EVENT; + event.user.data1 = cur_stream; + SDL_PushEvent(&event); + } } } -- 1.7.2.3
On date Monday 2011-04-11 19:23:48 +0200, Stefano Sabatini encoded:
Address roundup issue #604, #1031, #1804. --- ffplay.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-)
More an RFC rather than a patch, as I have to understand how to handle seek in a sane way. That is we need to force the reading and queuing of a frame, even when the stream is paused, suggestions are welcome. -- FFmpeg = Fiendish Funny Multimedia Programmable Erratic Game
On Mon, Apr 11, 2011 at 07:26:44PM +0200, Stefano Sabatini wrote:
On date Monday 2011-04-11 19:23:48 +0200, Stefano Sabatini encoded:
Address roundup issue #604, #1031, #1804. --- ffplay.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-)
More an RFC rather than a patch, as I have to understand how to handle seek in a sane way.
That is we need to force the reading and queuing of a frame, even when the stream is paused, suggestions are welcome.
maybe marton has some comment to this old RFC/patch ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
On Mon, Aug 29, 2011 at 04:50:40AM +0200, Michael Niedermayer wrote:
On Mon, Apr 11, 2011 at 07:26:44PM +0200, Stefano Sabatini wrote:
On date Monday 2011-04-11 19:23:48 +0200, Stefano Sabatini encoded:
Address roundup issue #604, #1031, #1804. --- ffplay.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-)
More an RFC rather than a patch, as I have to understand how to handle seek in a sane way.
That is we need to force the reading and queuing of a frame, even when the stream is paused, suggestions are welcome.
maybe marton has some comment to this old RFC/patch ...
ping [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment.
On Mon, 12 Mar 2012, Michael Niedermayer wrote:
On Mon, Aug 29, 2011 at 04:50:40AM +0200, Michael Niedermayer wrote:
On Mon, Apr 11, 2011 at 07:26:44PM +0200, Stefano Sabatini wrote:
On date Monday 2011-04-11 19:23:48 +0200, Stefano Sabatini encoded:
Address roundup issue #604, #1031, #1804. --- ffplay.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-)
More an RFC rather than a patch, as I have to understand how to handle seek in a sane way.
That is we need to force the reading and queuing of a frame, even when the stream is paused, suggestions are welcome.
maybe marton has some comment to this old RFC/patch ...
Yes, sorry, I totally forgot it. Actually I have a branch which dealt with this in a different way, I will post the patch soon. Regards, Marton
--- ffplay.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ffplay.c b/ffplay.c index bf0a834..e831f83 100644 --- a/ffplay.c +++ b/ffplay.c @@ -133,6 +133,7 @@ typedef struct VideoState { AVInputFormat *iformat; int no_background; int abort_request; + int force_refresh; int paused; int last_paused; int seek_req; @@ -993,7 +994,7 @@ static int refresh_thread(void *opaque) SDL_Event event; event.type = FF_REFRESH_EVENT; event.user.data1 = opaque; - if (!is->refresh) { + if (!is->refresh && (!is->paused || is->force_refresh)) { is->refresh = 1; SDL_PushEvent(&event); } @@ -1156,6 +1157,9 @@ retry: goto retry; } + if (is->paused) + goto display; + /* compute nominal last_duration */ last_duration = vp->pts - is->frame_last_pts; if (last_duration > 0 && last_duration < 10.0) { @@ -1234,11 +1238,13 @@ retry: } } +display: /* display picture */ if (!display_disable) video_display(is); - pictq_next_picture(is); + if (!is->paused) + pictq_next_picture(is); } } else if (is->audio_st) { /* draw the next audio frame */ @@ -1250,6 +1256,7 @@ retry: if (!display_disable) video_display(is); } + is->force_refresh = 0; if (show_status) { static int64_t last_time; int64_t cur_time; @@ -2829,6 +2836,7 @@ static void event_loop(VideoState *cur_stream) break; case SDLK_f: toggle_full_screen(cur_stream); + cur_stream->force_refresh = 1; break; case SDLK_p: case SDLK_SPACE: @@ -2848,6 +2856,7 @@ static void event_loop(VideoState *cur_stream) break; case SDLK_w: toggle_audio_display(cur_stream); + cur_stream->force_refresh = 1; break; case SDLK_PAGEUP: incr = 600.0; @@ -2890,6 +2899,9 @@ static void event_loop(VideoState *cur_stream) break; } break; + case SDL_VIDEOEXPOSE: + cur_stream->force_refresh = 1; + break; case SDL_MOUSEBUTTONDOWN: if (exit_on_mousedown) { do_exit(cur_stream); @@ -2932,6 +2944,7 @@ static void event_loop(VideoState *cur_stream) SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); screen_width = cur_stream->width = event.resize.w; screen_height = cur_stream->height = event.resize.h; + cur_stream->force_refresh = 1; break; case SDL_QUIT: case FF_QUIT_EVENT: -- 1.7.3.4
Hi Michael, On Mon, 12 Mar 2012, Marton Balint wrote:
--- ffplay.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-)
[...] Please merge from ffplay stable for the patch. Thanks, Marton
On Thu, Mar 15, 2012 at 01:54:00AM +0100, Marton Balint wrote:
Hi Michael,
On Mon, 12 Mar 2012, Marton Balint wrote:
--- ffplay.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-)
[...]
Please merge from ffplay stable for the patch.
merged Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides
participants (3)
-
Marton Balint -
Michael Niedermayer -
Stefano Sabatini