contribs: bluray: improve menuless playlist selection
authorFrancois Cartegnie <fcvlcdev@free.fr>
Tue, 5 Feb 2019 13:47:19 +0000 (14:47 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Tue, 5 Feb 2019 14:00:42 +0000 (15:00 +0100)
contrib/src/bluray/0001-improve-main-playlist-guess.patch [new file with mode: 0644]
contrib/src/bluray/rules.mak

diff --git a/contrib/src/bluray/0001-improve-main-playlist-guess.patch b/contrib/src/bluray/0001-improve-main-playlist-guess.patch
new file mode 100644 (file)
index 0000000..d1e6beb
--- /dev/null
@@ -0,0 +1,54 @@
+From c11f3fcb34a8b7af864f4e2addcf28b0e7851605 Mon Sep 17 00:00:00 2001
+From: Francois Cartegnie <fcartegnie@free.fr>
+Date: Tue, 5 Feb 2019 14:40:07 +0100
+Subject: [PATCH] improve main playlist guess
+
+---
+ src/libbluray/bdnav/navigation.c | 24 +++++++++++++++++++++++-
+ 1 file changed, 23 insertions(+), 1 deletion(-)
+
+diff --git a/src/libbluray/bdnav/navigation.c b/src/libbluray/bdnav/navigation.c
+index f72d253..e48461a 100644
+--- a/src/libbluray/bdnav/navigation.c
++++ b/src/libbluray/bdnav/navigation.c
+@@ -71,6 +71,25 @@ _pl_chapter_count(MPLS_PL *pl)
+     return chapters;
+ }
++static uint32_t
++_pl_streams_score(MPLS_PL *pl)
++{
++    MPLS_PI *pi;
++    uint32_t i_num_audio = 0;
++    uint32_t i_num_pg = 0;
++
++    for (int ii = 0; ii < pl->list_count; ii++) {
++        pi = &pl->play_item[ii];
++        if(pi->stn.num_audio > i_num_audio)
++            i_num_audio= pi->stn.num_audio;
++
++        if(pi->stn.num_pg > i_num_pg)
++            i_num_pg = pi->stn.num_pg;
++    }
++
++    return i_num_audio * 2 + i_num_pg;
++}
++
+ /*
+  * Check if two playlists are the same
+  */
+@@ -353,7 +372,10 @@ static int _pl_guess_main_title(MPLS_PL *p1, MPLS_PL *p2,
+         return -1;
+     }
+-    return 0;
++    /* prefer playlist with higher number of tracks */
++    int sc1 = _pl_streams_score(p1);
++    int sc2 = _pl_streams_score(p2);
++    return sc2 - sc1;
+ }
+ /*
+-- 
+2.20.1
+
index 4211c38..f9ad559 100644 (file)
@@ -52,6 +52,7 @@ bluray: libbluray-$(BLURAY_VERSION).tar.bz2 .sum-bluray
        $(APPLY) $(SRC)/bluray/0001-keep-on-with-menuless-user-selected-streams-between-.patch
        $(APPLY) $(SRC)/bluray/0001-install-bdjo_data-header.patch
        $(APPLY) $(SRC)/bluray/0001-library-paths-Explicitly-add-usr-local-lib.patch
+       $(APPLY) $(SRC)/bluray/0001-improve-main-playlist-guess.patch
        $(call pkg_static,"src/libbluray.pc.in")
        $(MOVE)