changeset 31816:ab9824b6acc7

dvd: Improve seeking by chapters. The current code seeks to the start of the chapter. From this position, it then tries to figure out the starting cell. This is completely suboptimal and error prone since the starting cell can be directly deduced from the chapter. patch by Olivier Rolland, billl users.sourceforge net
author diego
date Sun, 01 Aug 2010 22:51:15 +0000
parents 61517b367d31
children cb769a111f7a
files stream/stream_dvd.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_dvd.c	Sun Aug 01 22:48:01 2010 +0000
+++ b/stream/stream_dvd.c	Sun Aug 01 22:51:15 2010 +0000
@@ -507,7 +507,7 @@
 
 static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no, int chapter)
 {
-    int cell;
+    dvd_priv_t *d = stream->priv;
     ptt_info_t ptt;
     pgc_t *pgc;
     off_t pos;
@@ -530,11 +530,18 @@
     ptt = vts_file->vts_ptt_srpt->title[title_no].ptt[chapter];
     pgc = vts_file->vts_pgcit->pgci_srp[ptt.pgcn-1].pgc;
 
-    cell = pgc->program_map[ptt.pgn - 1] - 1;
-    pos = (off_t) pgc->cell_playback[cell].first_sector * 2048;
+    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;
+    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 = (off_t) d->cur_pack * 2048;
     mp_msg(MSGT_OPEN,MSGL_V,"\r\nSTREAM_DVD, seeked to chapter: %d, cell: %u, pos: %"PRIu64"\n",
-        chapter, pgc->cell_playback[cell].first_sector, pos);
-    stream_seek(stream, pos);
+        chapter, d->cur_pack, pos);
 
     return chapter;
 }