From f785eba8a1af1345bd757e00ab419c8b0120f5ea Mon Sep 17 00:00:00 2001 From: nicodvb Date: Mon, 11 Feb 2008 22:03:34 +0000 Subject: -chapter is now handled uniformly calling demuxer_seek_chapter() instead of letting individual demuxers and stream readers do their nasty job git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25987 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_mkv.c | 11 ----------- mencoder.c | 10 ++++++++++ mplayer.c | 12 ++++++++++++ stream/stream_dvd.c | 25 ++----------------------- stream/stream_dvdnav.c | 6 ------ 5 files changed, 24 insertions(+), 40 deletions(-) diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 0d4113180f..33337548b9 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -2526,17 +2526,6 @@ demux_mkv_open (demuxer_t *demuxer) demuxer->movi_start = s->start_pos; demuxer->movi_end = s->end_pos; demuxer->seekable = 1; - if (demuxer->chapters && dvd_chapter>1 && dvd_chapter<=demuxer->num_chapters) - { - if (!mkv_d->has_first_tc) - { - mkv_d->first_tc = 0; - mkv_d->has_first_tc = 1; - } - demux_mkv_seek (demuxer, - demuxer->chapters[dvd_chapter-1].start/1000.0, 0.0, - SEEK_ABSOLUTE); - } } return DEMUXER_TYPE_MATROSKA; diff --git a/mencoder.c b/mencoder.c index 7fa12f5efe..f6a0783605 100644 --- a/mencoder.c +++ b/mencoder.c @@ -603,6 +603,11 @@ if(stream->type==STREAMTYPE_DVDNAV){ mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_CannotOpenDemuxer); mencoder_exit(1,NULL); } + + if(dvd_chapter>1) { + float pts; + demuxer_seek_chapter(demuxer, dvd_chapter-1, 1, &pts, NULL, NULL); + } d_audio=demuxer2 ? demuxer2->audio : demuxer->audio; d_video=demuxer->video; @@ -1098,6 +1103,11 @@ while(!at_eof){ --play_n_frames; if(play_n_frames<0) break; } + if(dvd_last_chapter>0) { + int cur_chapter = demuxer_get_current_chapter(demuxer); + if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter) + break; + } goto_redo_edl: if (next_edl_record && sh_video && sh_video->pts >= next_edl_record->start_sec) { diff --git a/mplayer.c b/mplayer.c index d2a1a807ce..50ea3109d7 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3278,6 +3278,11 @@ if (mpctx->demuxer && mpctx->demuxer->type==DEMUXER_TYPE_PLAYLIST) if(!mpctx->demuxer) goto goto_next_file; +if(dvd_chapter>1) { + float pts; + demuxer_seek_chapter(mpctx->demuxer, dvd_chapter-1, 1, &pts, NULL, NULL); +} + inited_flags|=INITED_DEMUXER; if (mpctx->stream->type != STREAMTYPE_DVD && mpctx->stream->type != STREAMTYPE_DVDNAV) { @@ -3644,6 +3649,13 @@ if (mpctx->stream->type == STREAMTYPE_DVDNAV) { while(!mpctx->eof){ float aq_sleep_time=0; + +if(dvd_last_chapter>0) { + int cur_chapter = demuxer_get_current_chapter(mpctx->demuxer); + if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter) + goto goto_next_file; +} + if(!mpctx->sh_audio && mpctx->d_audio->sh) { mpctx->sh_audio = mpctx->d_audio->sh; mpctx->sh_audio->ds = mpctx->d_audio; diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 1ec2efc24a..c5a22d8089 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -882,22 +882,6 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { } mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_CURRENT_TITLE=%d\n", dvd_title); --dvd_title; // remap 1.. -> 0.. - /** - * Make sure the chapter number is valid for this title. - */ - mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_DVDnumChapters, tt_srpt->title[dvd_title].nr_of_ptts); - if(dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts) { - mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter); - goto fail; - } - if(dvd_last_chapter>0) { - if(dvd_last_chaptertt_srpt->title[dvd_title].nr_of_ptts) { - mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidLastChapter, dvd_last_chapter); - goto fail; - } - } - --dvd_chapter; // remap 1.. -> 0.. - /* XXX No need to remap dvd_last_chapter */ /** * Make sure the angle number is valid for this title. */ @@ -1041,18 +1025,13 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { * Determine which program chain we want to watch. This is based on the * chapter number. */ - pgc_id = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgcn; // local - pgn = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgn; // local + pgc_id = vts_file->vts_ptt_srpt->title[ttn].ptt[0].pgcn; // local + pgn = vts_file->vts_ptt_srpt->title[ttn].ptt[0].pgn; // local d->cur_pgc_idx = pgc_id-1; d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here d->packs_left=-1; // for Navi stuff d->angle_seek=0; - /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */ - if(dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[dvd_title].nr_of_ptts) { - pgn=vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_last_chapter].pgn; - d->last_cell=d->cur_pgc->program_map[pgn-1] - 1; - } else d->last_cell=d->cur_pgc->nr_of_cells; if(d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 4ee9eef40a..633ff65b45 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -558,17 +558,11 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { } if(p->track > 0) { - if(dvd_chapter > 0 && dvd_last_chapter > 0 && dvd_chapter > dvd_last_chapter) { - mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, invalid chapter range: %d > %d\n", dvd_chapter, dvd_last_chapter); - return STREAM_UNSUPPORTED; - } priv->title = p->track; if(dvdnav_title_play(priv->dvdnav, p->track) != DVDNAV_STATUS_OK) { mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(priv->dvdnav)); return STREAM_UNSUPPORTED; } - if(dvd_chapter > 0) - dvdnav_part_play(priv->dvdnav, p->track, dvd_chapter); } else if (p->track == 0) { if(dvdnav_menu_call(priv->dvdnav, DVD_MENU_Root) != DVDNAV_STATUS_OK) dvdnav_menu_call(priv->dvdnav, DVD_MENU_Title); -- cgit v1.2.3