>From d7b93a89908b66423dbb4e866d6a631a86bb8334 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Janne=20Kujanp=C3=A4=C3=A4?= <jikuja@iki.fi>
Date: Thu, 22 Sep 2011 21:18:06 +0300
Subject: [PATCH] Added option to disable chapter generation from marks file.

---
 modules/access/vdr.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/modules/access/vdr.c b/modules/access/vdr.c
index 873d93f..bf49b04 100644
--- a/modules/access/vdr.c
+++ b/modules/access/vdr.c
@@ -848,9 +848,22 @@ static void ImportMarks( access_t *p_access )
     /* parse lines of the form "0:00:00.00 foobar" */
     char *line = NULL;
     size_t line_len;
+    /* first cutmark could be "0:00:00.00" */
+    #define MIN_GAP_FOR_CHAPTER_GEN 45
+    int64_t i_last_frame = -MIN_GAP_FOR_CHAPTER_GEN;
+
     while( ReadLine( &line, &line_len, marksfile ) )
     {
         int64_t i_frame = ParseFrameNumber( line, p_sys->fps );
+        /* ParseFrameNumber returns frame number instead of PCR
+         * => no need to check overflow. 12-15 frames realistic*/
+        if ( i_frame - i_last_frame < MIN_GAP_FOR_CHAPTER_GEN )
+        {
+            msg_Info( p_access, "Detected %"PRId64" frames between marks. "\
+                "Not creating chapters.", i_frame - i_last_frame );
+            return;
+        }
+        i_last_frame = i_frame;
 
         /* move chapters (simple workaround for inaccurate cut marks) */
         if( i_frame > -i_chapter_offset )
-- 
1.7.6.3

