# HG changeset patch # User nicodvb # Date 1202767414 0 # Node ID eff9e1b2574384c1ac4db1d0a7d29974aaa906ce # Parent 0b0d71ca6a924e28778f0846d5570602f01d737e -chapter is now handled uniformly calling demuxer_seek_chapter() instead of letting individual demuxers and stream readers do their nasty job diff -r 0b0d71ca6a92 -r eff9e1b25743 libmpdemux/demux_mkv.c --- a/libmpdemux/demux_mkv.c Mon Feb 11 21:24:21 2008 +0000 +++ b/libmpdemux/demux_mkv.c Mon Feb 11 22:03:34 2008 +0000 @@ -2526,17 +2526,6 @@ 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 -r 0b0d71ca6a92 -r eff9e1b25743 mencoder.c --- a/mencoder.c Mon Feb 11 21:24:21 2008 +0000 +++ b/mencoder.c Mon Feb 11 22:03:34 2008 +0000 @@ -603,6 +603,11 @@ 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 @@ --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 -r 0b0d71ca6a92 -r eff9e1b25743 mplayer.c --- a/mplayer.c Mon Feb 11 21:24:21 2008 +0000 +++ b/mplayer.c Mon Feb 11 22:03:34 2008 +0000 @@ -3278,6 +3278,11 @@ 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 @@ 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 -r 0b0d71ca6a92 -r eff9e1b25743 stream/stream_dvd.c --- a/stream/stream_dvd.c Mon Feb 11 21:24:21 2008 +0000 +++ b/stream/stream_dvd.c Mon Feb 11 22:03:34 2008 +0000 @@ -883,22 +883,6 @@ 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. */ mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_DVDnumAngles, tt_srpt->title[dvd_title].nr_of_angles); @@ -1041,18 +1025,13 @@ * 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 -r 0b0d71ca6a92 -r eff9e1b25743 stream/stream_dvdnav.c --- a/stream/stream_dvdnav.c Mon Feb 11 21:24:21 2008 +0000 +++ b/stream/stream_dvdnav.c Mon Feb 11 22:03:34 2008 +0000 @@ -558,17 +558,11 @@ } 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);