You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
1.6 KiB

diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 1aedf2c..e519650 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1637,6 +1637,39 @@ int64_t bd_seek_time(BLURAY *bd, uint64_t tick)
return bd->s_pos;
}
+int64_t bd_find_seek_point(BLURAY *bd, uint64_t tick)
+{
+ uint32_t clip_pkt, out_pkt;
+ NAV_CLIP *clip;
+
+ if (tick >> 33) {
+ BD_DEBUG(DBG_BLURAY | DBG_CRIT, "bd_find_seek_point(%"PRIu64") failed: invalid timestamp\n", tick);
+ return bd->s_pos;
+ }
+
+ tick /= 2;
+
+ bd_mutex_lock(&bd->mutex);
+
+ if (bd->title &&
+ tick < bd->title->duration) {
+
+ // Find the closest access unit to the requested position
+ clip = nav_time_search(bd->title, (uint32_t)tick, &clip_pkt, &out_pkt);
+
+ bd_mutex_unlock(&bd->mutex);
+
+ return (int64_t)out_pkt * 192;
+
+ } else {
+ BD_DEBUG(DBG_BLURAY | DBG_CRIT, "bd_find_seek_point(%u) failed\n", (unsigned int)tick);
+ }
+
+ bd_mutex_unlock(&bd->mutex);
+
+ return bd->s_pos;
+}
+
uint64_t bd_tell_time(BLURAY *bd)
{
uint32_t clip_pkt = 0, out_pkt = 0, out_time = 0;
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index ae9f412..8ce6ddd 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -493,6 +493,16 @@ int64_t bd_seek_time(BLURAY *bd, uint64_t tick);
/**
*
+ * Find the byte position to specific time in 90Khz ticks
+ *
+ * @param bd BLURAY ojbect
+ * @param tick tick count
+ * @return position
+ */
+int64_t bd_find_seek_point(BLURAY *bd, uint64_t tick);
+
+/**
+ *
* Seek to a chapter. First chapter is 0
*
* @param bd BLURAY object