[vlc-commits] access: bluray: avoid being spammed with menu chapters

Francois Cartegnie git at videolan.org
Thu Nov 8 21:55:50 CET 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Nov  8 21:53:25 2018 +0100| [6b146206086881599894f74eb5b8e1062a778ec3] | committer: Francois Cartegnie

access: bluray: avoid being spammed with menu chapters

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6b146206086881599894f74eb5b8e1062a778ec3
---

 modules/access/bluray.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 3d60dfba42..de0fbc320e 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -2052,6 +2052,37 @@ static void bluraySendOverlayToVout(demux_t *p_demux, bluray_overlay_t *p_ov)
     p_ov->status = Outdated;
 }
 
+static bool blurayTitleIsRepeating(BLURAY_TITLE_INFO *title_info,
+                                   unsigned repeats, unsigned ratio)
+{
+    char clip_id[6] = {0};
+    unsigned maxrepeats = 0;
+    unsigned sequence = 0;
+    if(!title_info->chapter_count)
+        return false;
+
+    for (unsigned int j = 0; j < title_info->chapter_count; j++)
+    {
+        unsigned i = title_info->chapters[j].clip_ref;
+        if(i < title_info->clip_count)
+        {
+            if(memcmp(title_info->clips[i].clip_id, clip_id, 6))
+            {
+                sequence = 0;
+                memcpy(clip_id, title_info->clips[i].clip_id, 6);
+                continue;
+            }
+            else
+            {
+                if(maxrepeats < sequence++)
+                    maxrepeats = sequence;
+            }
+        }
+    }
+    return (maxrepeats > repeats &&
+            (100 * maxrepeats / title_info->chapter_count) >= ratio);
+}
+
 static void blurayUpdateTitleInfo(input_title_t *t, BLURAY_TITLE_INFO *title_info)
 {
     t->i_length = FROM_SCALE_NZ(title_info->duration);
@@ -2060,6 +2091,10 @@ static void blurayUpdateTitleInfo(input_title_t *t, BLURAY_TITLE_INFO *title_inf
         vlc_seekpoint_Delete( t->seekpoint[i] );
     TAB_CLEAN(t->i_seekpoint, t->seekpoint);
 
+    /* FIXME: have libbluray expose repeating titles */
+    if(blurayTitleIsRepeating(title_info, 10, 90))
+        return;
+
     for (unsigned int j = 0; j < title_info->chapter_count; j++) {
         seekpoint_t *s = vlc_seekpoint_New();
         if (!s) {



More information about the vlc-commits mailing list