diff options
author | wm4 <wm4@nowhere> | 2014-03-25 01:38:18 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-25 01:38:18 +0100 |
commit | 2c693a47328a4faa9581a792c24448407629279b (patch) | |
tree | 4f98655f55f9213ce6258c81cf6ac55b9be06463 | |
parent | 7bd3f2648152d41db9a9d3f479358d0d8f38b210 (diff) | |
download | mpv-2c693a47328a4faa9581a792c24448407629279b.tar.bz2 mpv-2c693a47328a4faa9581a792c24448407629279b.tar.xz |
stream: remove old chapter handling code
Stream-level chapters (like DVD etc.) did potentially not have
timestamps for each chapter, so STREAM_CTRL_SEEK_TO_CHAPTER and
STREAM_CTRL_GET_CURRENT_CHAPTER were needed to navigate chapters. We've
switched everything to use timestamps and that seems to work, so we can
simplify the code and remove this old mechanism.
-rw-r--r-- | demux/demux.c | 43 | ||||
-rw-r--r-- | player/playloop.c | 9 | ||||
-rw-r--r-- | stream/cache.c | 1 | ||||
-rw-r--r-- | stream/stream.h | 2 | ||||
-rw-r--r-- | stream/stream_bluray.c | 27 | ||||
-rw-r--r-- | stream/stream_dvd.c | 56 | ||||
-rw-r--r-- | stream/stream_dvdnav.c | 17 |
7 files changed, 11 insertions, 144 deletions
diff --git a/demux/demux.c b/demux/demux.c index 311a563b81..307f45a771 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -902,46 +902,23 @@ static void add_stream_chapters(struct demuxer *demuxer) int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, double *seek_pts) { - int ris = STREAM_UNSUPPORTED; - - if (demuxer->num_chapters == 0) - ris = stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_CHAPTER, - &chapter); - - if (ris != STREAM_UNSUPPORTED) { - demux_flush(demuxer); - demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); - - // exit status may be ok, but main() doesn't have to seek itself - // (because e.g. dvds depend on sectors, not on pts) - *seek_pts = -1.0; - - return chapter; - } else { - if (chapter >= demuxer->num_chapters) - return -1; - if (chapter < 0) - chapter = 0; + if (chapter >= demuxer->num_chapters) + return -1; + if (chapter < 0) + chapter = 0; - *seek_pts = demuxer->chapters[chapter].start / 1e9; + *seek_pts = demuxer->chapters[chapter].start / 1e9; - return chapter; - } + return chapter; } int demuxer_get_current_chapter(demuxer_t *demuxer, double time_now) { int chapter = -2; - if (!demuxer->num_chapters || !demuxer->chapters) { - if (stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_CHAPTER, - &chapter) == STREAM_UNSUPPORTED) - chapter = -2; - } else { - uint64_t now = time_now * 1e9 + 0.5; - for (chapter = demuxer->num_chapters - 1; chapter >= 0; --chapter) { - if (demuxer->chapters[chapter].start <= now) - break; - } + uint64_t now = time_now * 1e9 + 0.5; + for (chapter = demuxer->num_chapters - 1; chapter >= 0; --chapter) { + if (demuxer->chapters[chapter].start <= now) + break; } return chapter; } diff --git a/player/playloop.c b/player/playloop.c index e2f6a14de8..546d2e4cf8 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -570,8 +570,7 @@ int get_chapter_count(struct MPContext *mpctx) return 0; } -// Seek to a given chapter. Tries to queue the seek, but might seek immediately -// in some cases. Returns success, no matter if seek is queued or immediate. +// Seek to a given chapter. Queues the seek. bool mp_seek_chapter(struct MPContext *mpctx, int chapter) { int num = get_chapter_count(mpctx); @@ -592,12 +591,6 @@ bool mp_seek_chapter(struct MPContext *mpctx, int chapter) } else if (mpctx->master_demuxer) { int res = demuxer_seek_chapter(mpctx->master_demuxer, chapter, &pts); if (res >= 0) { - if (pts == -1) { - // for DVD/BD - seek happened via stream layer - seek_reset(mpctx, true, true); - mpctx->seek = (struct seek_params){0}; - return true; - } chapter = res; goto do_seek; } diff --git a/stream/cache.c b/stream/cache.c index 399013124f..56d9220dfd 100644 --- a/stream/cache.c +++ b/stream/cache.c @@ -407,7 +407,6 @@ static bool control_needs_flush(int stream_ctrl) { switch (stream_ctrl) { case STREAM_CTRL_SEEK_TO_TIME: - case STREAM_CTRL_SEEK_TO_CHAPTER: case STREAM_CTRL_SET_ANGLE: case STREAM_CTRL_SET_CURRENT_TITLE: return true; diff --git a/stream/stream.h b/stream/stream.h index 1c7b277db8..c23d173165 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -70,8 +70,6 @@ enum streamtype { enum stream_ctrl { STREAM_CTRL_GET_TIME_LENGTH = 1, - STREAM_CTRL_SEEK_TO_CHAPTER, - STREAM_CTRL_GET_CURRENT_CHAPTER, STREAM_CTRL_GET_NUM_CHAPTERS, STREAM_CTRL_GET_CURRENT_TIME, STREAM_CTRL_SEEK_TO_TIME, diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 6836da22d0..b0347751d6 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -161,33 +161,6 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg) return 1; } - case STREAM_CTRL_GET_CURRENT_CHAPTER: { - *((unsigned int *) arg) = bd_get_current_chapter(b->bd); - return 1; - } - - case STREAM_CTRL_SEEK_TO_CHAPTER: { - BLURAY_TITLE_INFO *ti; - int chapter = *((unsigned int *) arg); - int64_t pos; - int r; - - ti = bd_get_title_info(b->bd, b->current_title, b->current_angle); - if (!ti) - return STREAM_UNSUPPORTED; - - if (chapter < 0 || chapter > ti->chapter_count) { - bd_free_title_info(ti); - return STREAM_UNSUPPORTED; - } - - pos = bd_chapter_pos(b->bd, chapter); - r = bluray_stream_seek(s, pos); - bd_free_title_info(ti); - - return r ? 1 : STREAM_UNSUPPORTED; - } - case STREAM_CTRL_GET_TIME_LENGTH: { BLURAY_TITLE_INFO *ti; diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 93c9420086..3d6e3b3cb2 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -427,49 +427,6 @@ static int get_num_chapter(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title return vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts; } -static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no, int chapter) -{ - dvd_priv_t *d = stream->priv; - ptt_info_t ptt; - pgc_t *pgc; - int64_t pos; - - if(!vts_file || !tt_srpt) - return 0; - - if(title_no < 0 || title_no >= tt_srpt->nr_of_srpts) - return 0; - - // map global title to vts title - title_no = tt_srpt->title[title_no].vts_ttn - 1; - - if(title_no < 0 || title_no >= vts_file->vts_ptt_srpt->nr_of_srpts) - return 0; - - if(chapter < 0 || chapter > vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts-1) //no such chapter - return 0; - - ptt = vts_file->vts_ptt_srpt->title[title_no].ptt[chapter]; - pgc = vts_file->vts_pgcit->pgci_srp[ptt.pgcn-1].pgc; - - d->cur_cell = pgc->program_map[ptt.pgn - 1] - 1; - if(pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK) - d->cur_cell += dvd_angle-1; - d->cur_pack = pgc->cell_playback[d->cur_cell].first_sector; - d->cell_last_pack = pgc->cell_playback[d->cur_cell].last_sector; - - d->packs_left = -1; - d->angle_seek = 0; - - pos = (int64_t) d->cur_pack * 2048; - stream_seek(stream, pos); - - MP_VERBOSE(stream, "\r\nSTREAM_DVD, seeked to chapter: %d, cell: %u, pos: %"PRIu64"\n", - chapter, d->cur_pack, pos); - - return chapter; -} - // p: in=chapter number, out=PTS static int get_chapter_time(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no, double *p) { @@ -642,24 +599,11 @@ static int control(stream_t *stream,int cmd,void* arg) if(! r) return STREAM_UNSUPPORTED; return 1; } - case STREAM_CTRL_SEEK_TO_CHAPTER: - { - int r; - r = seek_to_chapter(stream, d->vts_file, d->tt_srpt, d->cur_title, *((unsigned int *)arg)); - if(! r) return STREAM_UNSUPPORTED; - - return 1; - } case STREAM_CTRL_GET_CURRENT_TITLE: { *((unsigned int *)arg) = d->cur_title; return 1; } - case STREAM_CTRL_GET_CURRENT_CHAPTER: - { - *((unsigned int *)arg) = dvd_chapter_from_cell(d, d->cur_title, d->cur_cell); - return 1; - } case STREAM_CTRL_GET_CURRENT_TIME: { double tm; diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 9cdc3c027b..c632e039d0 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -466,17 +466,6 @@ static int control(stream_t *stream, int cmd, void *arg) int tit, part; switch (cmd) { - case STREAM_CTRL_SEEK_TO_CHAPTER: { - int chap = *(unsigned int *)arg + 1; - - if (chap < 1) - break; - if (dvdnav_current_title_info(dvdnav, &tit, &part) != DVDNAV_STATUS_OK) - break; - if (dvdnav_part_play(dvdnav, tit, chap) != DVDNAV_STATUS_OK) - break; - return 1; - } case STREAM_CTRL_GET_NUM_CHAPTERS: { if (dvdnav_current_title_info(dvdnav, &tit, &part) != DVDNAV_STATUS_OK) break; @@ -502,12 +491,6 @@ static int control(stream_t *stream, int cmd, void *arg) free(parts); return 1; } - case STREAM_CTRL_GET_CURRENT_CHAPTER: { - if (dvdnav_current_title_info(dvdnav, &tit, &part) != DVDNAV_STATUS_OK) - break; - *(unsigned int *)arg = part - 1; - return 1; - } case STREAM_CTRL_GET_TIME_LENGTH: { if (priv->duration) { *(double *)arg = (double)priv->duration / 1000.0; |