aboutsummaryrefslogtreecommitdiffstats
path: root/ffplay.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-10 13:09:13 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-10 13:26:31 +0100
commit6fb8684a24cd508f63e0246c12aae129614638ea (patch)
tree1166d5457158746ba53181016cdebbc2d4e06ab7 /ffplay.c
parent6421111b52de4442768e7ef31b4d29055f83900c (diff)
parentb36bc81ccaa2fc85dc4bae7dc546c71e8833573d (diff)
downloadffmpeg-6fb8684a24cd508f63e0246c12aae129614638ea.tar.gz
Merge commit 'b36bc81ccaa2fc85dc4bae7dc546c71e8833573d'
* commit 'b36bc81ccaa2fc85dc4bae7dc546c71e8833573d': avplay: add support for seeking to chapter marks Conflicts: doc/ffplay.texi ffplay.c ffplay uses pageup/down for seeking by +-10min thus this use of the keys conflicts. The merge thus uses them to seek to chapters when there are some or +-10min when there are not Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/ffplay.c b/ffplay.c
index b161e8c23a..ed7f180ebb 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3170,6 +3170,33 @@ static void refresh_loop_wait_event(VideoState *is, SDL_Event *event) {
}
}
+static void seek_chapter(VideoState *is, int incr)
+{
+ int64_t pos = get_master_clock(is) * AV_TIME_BASE;
+ int i;
+
+ if (!is->ic->nb_chapters)
+ return;
+
+ /* find the current chapter */
+ for (i = 0; i < is->ic->nb_chapters; i++) {
+ AVChapter *ch = is->ic->chapters[i];
+ if (av_compare_ts(pos, AV_TIME_BASE_Q, ch->start, ch->time_base) < 0) {
+ i--;
+ break;
+ }
+ }
+
+ i += incr;
+ i = FFMAX(i, 0);
+ if (i >= is->ic->nb_chapters)
+ return;
+
+ av_log(NULL, AV_LOG_VERBOSE, "Seeking to chapter %d.\n", i);
+ stream_seek(is, av_rescale_q(is->ic->chapters[i]->start, is->ic->chapters[i]->time_base,
+ AV_TIME_BASE_Q), 0, 0);
+}
+
/* handle an event sent by the GUI */
static void event_loop(VideoState *cur_stream)
{
@@ -3219,11 +3246,19 @@ static void event_loop(VideoState *cur_stream)
toggle_audio_display(cur_stream);
break;
case SDLK_PAGEUP:
- incr = 600.0;
- goto do_seek;
+ if (cur_stream->ic->nb_chapters <= 1) {
+ incr = 600.0;
+ goto do_seek;
+ }
+ seek_chapter(cur_stream, 1);
+ break;
case SDLK_PAGEDOWN:
- incr = -600.0;
- goto do_seek;
+ if (cur_stream->ic->nb_chapters <= 1) {
+ incr = -600.0;
+ goto do_seek;
+ }
+ seek_chapter(cur_stream, -1);
+ break;
case SDLK_LEFT:
incr = -10.0;
goto do_seek;