[libbluray-devel] split _filter_dup()

hpi1 git at videolan.org
Wed Jun 11 12:42:10 CEST 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Jun 11 13:02:50 2014 +0300| [99e16ed61859add135097f2b3f76967421f79b3f] | committer: hpi1

split _filter_dup()

simplify logic / exit condition

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

 src/libbluray/bdnav/navigation.c |   54 +++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 21 deletions(-)

diff --git a/src/libbluray/bdnav/navigation.c b/src/libbluray/bdnav/navigation.c
index ab1890d..ab9f719 100644
--- a/src/libbluray/bdnav/navigation.c
+++ b/src/libbluray/bdnav/navigation.c
@@ -32,33 +32,45 @@
 #include <stdlib.h>
 #include <string.h>
 
-static int _filter_dup(MPLS_PL *pl_list[], unsigned count, MPLS_PL *pl)
+static int _pi_cmp(MPLS_PI *pi1, MPLS_PI *pi2)
 {
-    unsigned ii, jj;
+    if (memcmp(pi1->clip[0].clip_id, pi2->clip[0].clip_id, 5) != 0 ||
+        pi1->in_time != pi2->in_time ||
+        pi1->out_time != pi2->out_time) {
+        return 1;
+    }
 
-    for (ii = 0; ii < count; ii++) {
-        if (pl->list_count != pl_list[ii]->list_count) {
-            continue;
-        }
-        if (pl->mark_count != pl_list[ii]->mark_count) {
-            continue;
-        }
-        for (jj = 0; jj < pl->list_count; jj++) {
-            MPLS_PI *pi1, *pi2;
+    return 0;
+}
 
-            pi1 = &pl->play_item[jj];
-            pi2 = &pl_list[ii]->play_item[jj];
+static int _pl_cmp(MPLS_PL *pl1, MPLS_PL *pl2)
+{
+    unsigned ii;
 
-            if (memcmp(pi1->clip[0].clip_id, pi2->clip[0].clip_id, 5) != 0 ||
-                pi1->in_time != pi2->in_time ||
-                pi1->out_time != pi2->out_time) {
-                break;
-            }
+    if (pl1->list_count != pl2->list_count) {
+        return 1;
+    }
+    if (pl1->mark_count != pl2->mark_count) {
+        return 1;
+    }
+    for (ii = 0; ii < pl1->list_count; ii++) {
+        if (_pi_cmp(&pl1->play_item[ii], &pl2->play_item[ii])) {
+            return 1;
         }
-        if (jj != pl->list_count) {
-            continue;
+    }
+
+    return 0;
+}
+
+/* return 0 if duplicate playlist */
+static int _filter_dup(MPLS_PL *pl_list[], unsigned count, MPLS_PL *pl)
+{
+    unsigned ii;
+
+    for (ii = 0; ii < count; ii++) {
+        if (!_pl_cmp(pl, pl_list[ii])) {
+            return 0;
         }
-        return 0;
     }
     return 1;
 }



More information about the libbluray-devel mailing list