[libbluray-devel] Replaced chapter tracking with more generic playmark tracking
hpi1
git at videolan.org
Fri Mar 8 15:18:40 CET 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Mar 8 15:57:28 2013 +0200| [24803933aa6e42c2d28709c80e931999153e2022] | committer: hpi1
Replaced chapter tracking with more generic playmark tracking
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=24803933aa6e42c2d28709c80e931999153e2022
---
src/libbluray/bdj/bdj.h | 1 +
src/libbluray/bluray.c | 64 ++++++++++++++++++++++++++++++++++++++---------
src/libbluray/bluray.h | 3 ++-
3 files changed, 55 insertions(+), 13 deletions(-)
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index 800fd03..2da2825 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -34,6 +34,7 @@ typedef enum {
BDJ_EVENT_END_OF_PLAYLIST,
BDJ_EVENT_PTS,
BDJ_EVENT_VK_KEY,
+ BDJ_EVENT_MARK,
} BDJ_EVENT;
typedef struct bdjava_s BDJAVA;
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 8a09a04..7d38874 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -138,8 +138,9 @@ struct bluray {
uint32_t angle_change_time;
unsigned request_angle;
- /* chapter tracking */
- uint64_t next_chapter_start;
+ /* mark tracking */
+ uint64_t next_mark_pos;
+ int next_mark;
/* aacs */
void *h_libaacs; // library handle
@@ -356,11 +357,9 @@ static void _update_clip_psrs(BLURAY *bd, NAV_CLIP *clip)
}
}
-
static void _update_chapter_psr(BLURAY *bd)
{
uint32_t current_chapter = bd_get_current_chapter(bd);
- bd->next_chapter_start = bd_chapter_pos(bd, current_chapter + 1);
bd_psr_write(bd->regs, PSR_CHAPTER, current_chapter + 1);
}
@@ -1359,6 +1358,48 @@ void bd_close(BLURAY *bd)
}
/*
+ * PlayMark tracking
+ */
+
+static void _find_next_playmark(BLURAY *bd)
+{
+ unsigned ii;
+
+ bd->next_mark = -1;
+ bd->next_mark_pos = (uint64_t)-1;
+ for (ii = 0; ii < bd->title->mark_list.count; ii++) {
+ uint64_t pos = (uint64_t)bd->title->mark_list.mark[ii].title_pkt * 192L;
+ if (pos > bd->s_pos) {
+ bd->next_mark = ii;
+ bd->next_mark_pos = pos;
+ return;
+ }
+ }
+
+ _update_chapter_psr(bd);
+}
+
+static void _playmark_reached(BLURAY *bd)
+{
+ BD_DEBUG(DBG_BLURAY, "PlayMark %d reached (%"PRIu64")\n", bd->next_mark, bd->next_mark_pos);
+
+ _queue_event(bd, BD_EVENT_PLAYMARK, bd->next_mark);
+ _bdj_event(bd, BDJ_EVENT_MARK, bd->next_mark);
+
+ /* update next mark */
+ bd->next_mark++;
+ if ((unsigned)bd->next_mark < bd->title->mark_list.count) {
+ bd->next_mark_pos = (uint64_t)bd->title->mark_list.mark[bd->next_mark].title_pkt * 192L;
+ } else {
+ bd->next_mark = -1;
+ bd->next_mark_pos = (uint64_t)-1;
+ }
+
+ /* chapter tracking */
+ _update_chapter_psr(bd);
+}
+
+/*
* seeking and current position
*/
@@ -1372,8 +1413,8 @@ static void _seek_internal(BLURAY *bd,
/* update title position */
bd->s_pos = (uint64_t)title_pkt * 192;
- /* chapter tracking */
- _update_chapter_psr(bd);
+ /* playmark tracking */
+ _find_next_playmark(bd);
/* reset PG decoder and controller */
if (bd->graphics_controller) {
@@ -1751,13 +1792,12 @@ static int _bd_read(BLURAY *bd, unsigned char *buf, int len)
bd->s_pos += size;
}
- /* chapter tracking */
- if (bd->s_pos > bd->next_chapter_start) {
- _update_chapter_psr(bd);
+ /* mark tracking */
+ if (bd->next_mark >= 0 && bd->s_pos > bd->next_mark_pos) {
+ _playmark_reached(bd);
}
BD_DEBUG(DBG_STREAM, "%d bytes read OK! (%p)\n", out_len, bd);
-
return out_len;
}
@@ -1921,12 +1961,12 @@ static int _open_playlist(BLURAY *bd, const char *f_name, unsigned angle)
bd->seamless_angle_change = 0;
bd->s_pos = 0;
- bd->next_chapter_start = bd_chapter_pos(bd, 1);
-
bd_psr_write(bd->regs, PSR_PLAYLIST, atoi(bd->title->name));
bd_psr_write(bd->regs, PSR_ANGLE_NUMBER, bd->title->angle + 1);
bd_psr_write(bd->regs, PSR_CHAPTER, 1);
+ _find_next_playmark(bd);
+
// Get the initial clip of the playlist
bd->st0.clip = nav_next_clip(bd->title, NULL);
if (_open_m2ts(bd, &bd->st0)) {
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index 3633ee4..8a702ff 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -546,6 +546,7 @@ typedef enum {
BD_EVENT_PLAYLIST = 6, /* current playlist (xxxxx.mpls) */
BD_EVENT_PLAYITEM = 7, /* current play item, 0...N-1 */
BD_EVENT_CHAPTER = 8, /* current chapter, 1...N */
+ BD_EVENT_PLAYMARK = 30, /* playmark reached */
BD_EVENT_END_OF_TITLE = 9,
/*
@@ -601,7 +602,7 @@ typedef enum {
/* 3D */
BD_EVENT_STEREOSCOPIC_STATUS = 27, /* 0 - 2D, 1 - 3D */
- /*BD_EVENT_LAST = 29, */
+ /*BD_EVENT_LAST = 30, */
} bd_event_e;
More information about the libbluray-devel
mailing list