diff options
author | phintuka <phintuka> | 2009-11-08 20:44:16 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2009-11-08 20:44:16 +0000 |
commit | df3187ccdd20f4a6f49613cc48266bb1c8f14c28 (patch) | |
tree | 930f5b3e9c994dd6355b0ef96861746587786bed /xine/BluRay/input_bluray.c | |
parent | fd05421bd094683886465f86858d12cc2b3fff74 (diff) | |
download | xineliboutput-df3187ccdd20f4a6f49613cc48266bb1c8f14c28.tar.gz xineliboutput-df3187ccdd20f4a6f49613cc48266bb1c8f14c28.tar.bz2 |
Use navigation data to clip seeks to nearest random access point
Diffstat (limited to 'xine/BluRay/input_bluray.c')
-rw-r--r-- | xine/BluRay/input_bluray.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/xine/BluRay/input_bluray.c b/xine/BluRay/input_bluray.c index 0d2715e2..9e4a286c 100644 --- a/xine/BluRay/input_bluray.c +++ b/xine/BluRay/input_bluray.c @@ -152,15 +152,39 @@ static off_t bluray_plugin_seek (input_plugin_t *this_gen, off_t offset, int ori { bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen; - if (!this->bdh) + if (!this || !this->bdh) return -1; + /* convert relative seeks to absolute */ + if (origin == SEEK_CUR) { offset = this->bdh->s_pos + offset; - origin = SEEK_SET; } - if (origin != SEEK_SET) - return this->bdh->s_pos; + else if (origin == SEEK_END) { + if (offset < this->bdh->s_size) + offset = this->bdh->s_size - offset; + else + offset = 0; + } + + /* clip seek point to nearest random access point */ + + if (this->nav_title) { + uint32_t in_pkt = offset / 192; + uint32_t out_pkt = in_pkt; + nav_packet_search(this->nav_title, in_pkt, &out_pkt); + lprintf("bluray_plugin_seek() seeking to %"PRId64" (packet %d)\n", offset, in_pkt); + offset = (off_t)192 * (off_t)out_pkt; + lprintf("Nearest random access point at %"PRId64" (packet %d)\n", offset, out_pkt); + } + + /* clip to aligned unit start */ + + offset -= (offset % ALIGNED_UNIT_SIZE); + + /* seek */ + + lprintf("bluray_plugin_seek() seeking to %lld (aligned unit)\n", (long long)offset); return bd_seek (this->bdh, offset); } |