[libbluray-devel] main title selection: prefer HD over SD, H.264/VC1 over MPEG1/2

hpi1 git at videolan.org
Thu Mar 3 10:19:51 CET 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Mar  3 11:04:14 2016 +0200| [cf90e6d703b0f5d3a3923b34650e0bcd9b7473c6] | committer: hpi1

main title selection: prefer HD over SD, H.264/VC1 over MPEG1/2

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=cf90e6d703b0f5d3a3923b34650e0bcd9b7473c6
---

 src/libbluray/bdnav/navigation.c |   40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/src/libbluray/bdnav/navigation.c b/src/libbluray/bdnav/navigation.c
index b4e8108..a5995e5 100644
--- a/src/libbluray/bdnav/navigation.c
+++ b/src/libbluray/bdnav/navigation.c
@@ -1,6 +1,7 @@
 /*
  * This file is part of libbluray
  * Copyright (C) 2009-2010  John Stebbins
+ * Copyright (C) 2010-2016  Petri Hintukainen
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,6 +26,7 @@
 
 #include "clpi_parse.h"
 #include "mpls_parse.h"
+#include "bdparse.h"
 
 #include "disc/disc.h"
 
@@ -207,6 +209,38 @@ _filter_repeats(MPLS_PL *pl, unsigned repeats)
 
 #define DBG_MAIN_PL DBG_NAV
 
+static void _video_props(MPLS_STN *s, int *full_hd, int *mpeg12)
+{
+    unsigned ii;
+    *mpeg12 = 1;
+    *full_hd = 0;
+    for (ii = 0; ii < s->num_video; ii++) {
+        if (s->video[ii].coding_type > 4) {
+            *mpeg12 = 0;
+        }
+        if (s->video[ii].format == BD_VIDEO_FORMAT_1080I || s->video[ii].format == BD_VIDEO_FORMAT_1080P) {
+            *full_hd = 1;
+        }
+    }
+}
+
+static int _cmp_video_props(const MPLS_PL *p1, const MPLS_PL *p2)
+{
+    MPLS_STN *s1 = &p1->play_item[0].stn;
+    MPLS_STN *s2 = &p2->play_item[0].stn;
+    int fhd1, fhd2, mp12_1, mp12_2;
+
+    _video_props(s1, &fhd1, &mp12_1);
+    _video_props(s2, &fhd2, &mp12_2);
+
+    /* prefer Full HD over HD/SD */
+    if (fhd1 != fhd2)
+        return fhd2 - fhd1;
+
+    /* prefer H.264/VC1 over MPEG1/2 */
+    return mp12_2 - mp12_1;
+}
+
 static int _pl_guess_main_title(MPLS_PL *p1, MPLS_PL *p2)
 {
     uint32_t d1 = _pl_duration(p1);
@@ -223,6 +257,12 @@ static int _pl_guess_main_title(MPLS_PL *p1, MPLS_PL *p2)
             return chap_diff;
         }
 
+        /* Check video: prefer HD over SD, H.264/VC1 over MPEG1/2 */
+        int vid_diff = _cmp_video_props(p1, p2);
+        if (vid_diff) {
+            BD_DEBUG(DBG_MAIN_PL, "main title: video properties difference %d\n", vid_diff);
+            return vid_diff;
+        }
     }
 
     /* compare playlist duration, select longer playlist */



More information about the libbluray-devel mailing list