[libbluray-devel] main title selection: prefer "known" playlists
hpi1
git at videolan.org
Fri May 12 08:12:55 CEST 2017
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu May 11 14:40:12 2017 +0300| [d09df711f672457a409055ea541b41e44cc05727] | committer: hpi1
main title selection: prefer "known" playlists
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=d09df711f672457a409055ea541b41e44cc05727
---
src/libbluray/bdnav/navigation.c | 28 ++++++++++++++++++++++++++--
src/libbluray/disc/disc.h | 3 ++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/libbluray/bdnav/navigation.c b/src/libbluray/bdnav/navigation.c
index a14d7389..d2fbb9b0 100644
--- a/src/libbluray/bdnav/navigation.c
+++ b/src/libbluray/bdnav/navigation.c
@@ -290,7 +290,9 @@ static int _cmp_audio_props(const MPLS_PL *p1, const MPLS_PL *p2)
return hda2 - hda1;
}
-static int _pl_guess_main_title(MPLS_PL *p1, MPLS_PL *p2)
+static int _pl_guess_main_title(MPLS_PL *p1, MPLS_PL *p2,
+ const char *mpls_id1, const char *mpls_id2,
+ const char *known_mpls_ids)
{
uint32_t d1 = _pl_duration(p1);
uint32_t d2 = _pl_duration(p2);
@@ -321,6 +323,18 @@ static int _pl_guess_main_title(MPLS_PL *p1, MPLS_PL *p2)
BD_DEBUG(DBG_MAIN_PL, "main title: audio properties difference %d\n", aud_diff);
return aud_diff;
}
+
+ /* prefer "known good" playlists */
+ if (known_mpls_ids) {
+ int known1 = !!str_strcasestr(known_mpls_ids, mpls_id1);
+ int known2 = !!str_strcasestr(known_mpls_ids, mpls_id2);
+ int known_diff = known2 - known1;
+ if (known_diff) {
+ BD_DEBUG(DBG_MAIN_PL, "main title (%s,%s): prefer \"known\" playlist %s\n",
+ mpls_id1, mpls_id2, known_diff < 0 ? mpls_id1 : mpls_id2);
+ return known_diff;
+ }
+ }
}
/* compare playlist duration, select longer playlist */
@@ -348,6 +362,7 @@ NAV_TITLE_LIST* nav_get_title_list(BD_DISC *disc, uint32_t flags, uint32_t min_t
int res;
NAV_TITLE_LIST *title_list = NULL;
unsigned int title_info_alloc = 100;
+ char *known_mpls_ids;
dir = disc_open_dir(disc, "BDMV" DIR_SEP "PLAYLIST");
if (dir == NULL) {
@@ -366,6 +381,11 @@ NAV_TITLE_LIST* nav_get_title_list(BD_DISC *disc, uint32_t flags, uint32_t min_t
return NULL;
}
+ known_mpls_ids = disc_property_get(disc, DISC_PROPERTY_MAIN_FEATURE);
+ if (!known_mpls_ids) {
+ known_mpls_ids = disc_property_get(disc, DISC_PROPERTY_PLAYLISTS);
+ }
+
ii = 0;
for (res = dir_read(dir, &ent); !res; res = dir_read(dir, &ent)) {
@@ -415,7 +435,10 @@ NAV_TITLE_LIST* nav_get_title_list(BD_DISC *disc, uint32_t flags, uint32_t min_t
if (_filter_dup(pl_list, ii, pl) &&
_filter_repeats(pl, 2)) {
- if (_pl_guess_main_title(pl_list[ii], pl_list[title_list->main_title_idx]) <= 0) {
+ if (_pl_guess_main_title(pl_list[ii], pl_list[title_list->main_title_idx],
+ ent.d_name,
+ title_list->title_info[title_list->main_title_idx].name,
+ known_mpls_ids) <= 0) {
title_list->main_title_idx = ii;
}
}
@@ -434,6 +457,7 @@ NAV_TITLE_LIST* nav_get_title_list(BD_DISC *disc, uint32_t flags, uint32_t min_t
for (ii = 0; ii < title_list->count; ii++) {
mpls_free(&pl_list[ii]);
}
+ X_FREE(known_mpls_ids);
X_FREE(pl_list);
return title_list;
}
diff --git a/src/libbluray/disc/disc.h b/src/libbluray/disc/disc.h
index 612a5473..6b5a3e62 100644
--- a/src/libbluray/disc/disc.h
+++ b/src/libbluray/disc/disc.h
@@ -103,7 +103,8 @@ BD_PRIVATE int disc_property_put(BD_DISC *disc, const char *property, const ch
BD_PRIVATE char *disc_property_get(BD_DISC *disc, const char *property);
/* "Known" playlists */
-#define DISC_PROPERTY_PLAYLISTS "Playlists"
+#define DISC_PROPERTY_PLAYLISTS "Playlists"
+#define DISC_PROPERTY_MAIN_FEATURE "MainFeature"
/*
*
More information about the libbluray-devel
mailing list