[SCM] morituri/master: * morituri/test/capital.1.toc (added): * morituri/test/capital.2.toc (added): Add two .toc's for two sessions of a 2 session disc * morituri/image/table.py: Add a merge method to merge in a second session. * morituri/test/Makefile.am: * morituri/test/test_image_toc.py: Add a test for merging the Das Capital sessions, gets the CDDB disc id right.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:09:04 UTC 2014


The following commit has been merged in the master branch:
commit c793211f2898cfe0a29d5221c22d7a70557c28fc
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sun May 24 21:30:21 2009 +0000

    	* morituri/test/capital.1.toc (added):
    	* morituri/test/capital.2.toc (added):
    	  Add two .toc's for two sessions of a 2 session disc
    	* morituri/image/table.py:
    	  Add a merge method to merge in a second session.
    	* morituri/test/Makefile.am:
    	* morituri/test/test_image_toc.py:
    	  Add a test for merging the Das Capital sessions, gets
    	  the CDDB disc id right.

diff --git a/ChangeLog b/ChangeLog
index efaf915..1a9cb8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2009-05-24  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+	* morituri/test/capital.1.toc (added):
+	* morituri/test/capital.2.toc (added):
+	  Add two .toc's for two sessions of a 2 session disc
+	* morituri/image/table.py:
+	  Add a merge method to merge in a second session.
+	* morituri/test/Makefile.am:
+	* morituri/test/test_image_toc.py:
+	  Add a test for merging the Das Capital sessions, gets
+	  the CDDB disc id right.
+
+2009-05-24  Thomas Vander Stichele  <thomas at apestaart dot org>
+
 	* morituri/common/common.py:
 	  Add a persisted cache so that we can store pickles on discs.
 	  Automatically delete them if the class version is newer than
diff --git a/morituri/image/table.py b/morituri/image/table.py
index 3dd4498..9ccafc4 100644
--- a/morituri/image/table.py
+++ b/morituri/image/table.py
@@ -24,6 +24,8 @@
 Wrap Table of Contents.
 """
 
+import copy
+
 from morituri.common import task, common, log
 
 # FIXME: taken from libcdio, but no reference found for these
@@ -85,6 +87,12 @@ class Track:
         indexes.sort()
         return self.indexes[indexes[0]]
 
+    def getLastIndex(self):
+        indexes = self.indexes.keys()
+        indexes.sort()
+        return self.indexes[indexes[-1]]
+
+
 class Index:
     """
     @ivar counter: counter for the index source; distinguishes between
@@ -487,6 +495,46 @@ class Table(object, log.Loggable):
             except IndexError:
                 break
 
+    def merge(self, other, session=2):
+        """
+        Merges the given table at the end.
+        The other table is assumed to be from an additional session,
+
+
+        @type  other: L{Table}
+        """
+        # From cdrecord multi-session info:
+        # For the first additional session this is 11250 sectors
+        # lead-out/lead-in overhead + 150 sectors for the pre-gap of the first
+        # track after the lead-in = 11400 sectos.
+
+        # For all further session this is 6750 sectors lead-out/lead-in
+        # overhead + 150 sectors for the pre-gap of the first track after the
+        # lead-in = 6900 sectors.
+
+        gap = 11400
+        if session > 2:
+            gap = 6900
+
+        trackCount = len(self.tracks)
+        sourceCounter = self.tracks[-1].getLastIndex().counter
+
+        for track in other.tracks:
+            t = copy.deepcopy(track)
+            t.number = track.number + trackCount
+            for i in t.indexes.values():
+                if i.absolute is not None:
+                    i.absolute += self.leadout + gap
+                    self.debug('Fixing track %02d, index %02d, absolute %d' % (
+                        t.number, i.number, i.absolute))
+                if i.counter is not None:
+                    i.counter += sourceCounter
+                    self.debug('Fixing track %02d, index %02d, counter %d' % (
+                        t.number, i.number, i.counter))
+            self.tracks.append(t)
+
+        self.leadout += other.leadout + gap # FIXME
+
     ### lookups
     def getNextTrackIndex(self, track, index):
         """
diff --git a/morituri/test/Makefile.am b/morituri/test/Makefile.am
index 38d6634..a5aeb02 100644
--- a/morituri/test/Makefile.am
+++ b/morituri/test/Makefile.am
@@ -16,6 +16,8 @@ EXTRA_DIST = \
 	breeders.cue \
 	breeders.toc \
 	capital.fast.toc \
+	capital.1.toc \
+	capital.2.toc \
 	cure.cue \
 	cure.toc \
 	dBAR-011-0010e284-009228a3-9809ff0b.bin \
diff --git a/morituri/test/capital.fast.toc b/morituri/test/capital.1.toc
similarity index 63%
copy from morituri/test/capital.fast.toc
copy to morituri/test/capital.1.toc
index 1553080..fc8526d 100644
--- a/morituri/test/capital.fast.toc
+++ b/morituri/test/capital.1.toc
@@ -1,4 +1,4 @@
-CD_ROM
+CD_DA
 
 
 // Track 1
@@ -7,7 +7,9 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300350"
-FILE "data.wav" 0 04:33:60
+SILENCE 05:22:20
+FILE "data.wav" 0 04:32:55
+START 05:22:20
 
 
 // Track 2
@@ -16,7 +18,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300351"
-FILE "data.wav" 04:33:60 04:16:35
+FILE "data.wav" 04:32:55 04:16:02
+START 00:01:05
 
 
 // Track 3
@@ -25,7 +28,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300352"
-FILE "data.wav" 08:50:20 03:03:70
+FILE "data.wav" 08:48:57 03:03:65
+START 00:01:38
 
 
 // Track 4
@@ -34,7 +38,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300353"
-FILE "data.wav" 11:54:15 02:16:10
+FILE "data.wav" 11:52:47 02:16:03
+START 00:01:43
 
 
 // Track 5
@@ -43,7 +48,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300355"
-FILE "data.wav" 14:10:25 03:32:25
+FILE "data.wav" 14:08:50 03:32:55
+START 00:01:50
 
 
 // Track 6
@@ -52,7 +58,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300356"
-FILE "data.wav" 17:42:50 03:09:50
+FILE "data.wav" 17:41:30 03:09:70
+START 00:01:20
 
 
 // Track 7
@@ -61,7 +68,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300357"
-FILE "data.wav" 20:52:25 02:26:60
+FILE "data.wav" 20:51:25 02:27:25
+START 00:01:00
 
 
 // Track 8
@@ -70,7 +78,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300358"
-FILE "data.wav" 23:19:10 02:46:60
+FILE "data.wav" 23:18:50 02:46:35
+START 00:00:35
 
 
 // Track 9
@@ -79,7 +88,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300359"
-FILE "data.wav" 26:05:70 05:02:72
+FILE "data.wav" 26:05:10 05:02:72
+START 00:00:60
 
 
 // Track 10
@@ -88,7 +98,8 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300360"
-FILE "data.wav" 31:08:67 03:50:43
+FILE "data.wav" 31:08:07 03:50:38
+START 00:00:60
 
 
 // Track 11
@@ -97,13 +108,6 @@ NO COPY
 NO PRE_EMPHASIS
 TWO_CHANNEL_AUDIO
 ISRC "GBAAA0300361"
-FILE "data.wav" 34:59:35 06:04:20
-
-
-// Track 12
-TRACK MODE1
-NO COPY
-ZERO MODE1 00:02:00
-DATAFILE "data_12" 27:30:00 // length in bytes: 253440000
-START 00:02:00
+FILE "data.wav" 34:58:45 03:35:10
+START 00:00:65
 
diff --git a/morituri/test/capital.2.toc b/morituri/test/capital.2.toc
new file mode 100644
index 0000000..61de0f7
--- /dev/null
+++ b/morituri/test/capital.2.toc
@@ -0,0 +1,8 @@
+CD_ROM
+
+
+// Track 1
+TRACK MODE1
+NO COPY
+DATAFILE "data_1" 27:30:00 // length in bytes: 253440000
+
diff --git a/morituri/test/test_image_toc.py b/morituri/test/test_image_toc.py
index c8a7386..6b6c6aa 100644
--- a/morituri/test/test_image_toc.py
+++ b/morituri/test/test_image_toc.py
@@ -2,6 +2,7 @@
 # vi:si:et:sw=4:sts=4:ts=4
 
 import os
+import copy
 import unittest
 
 from morituri.image import toc
@@ -196,3 +197,28 @@ class CapitalTestCase(unittest.TestCase):
         # b910140c 12 24320 44855 64090 77885 88095 104020 118245 129255 141765 164487 181780 209250 4440
     testCDDBId.skip = 'not implemented yet'
 
+class CapitalMergeTestCase(unittest.TestCase):
+    def setUp(self):
+        self.toc1 = toc.TocFile(os.path.join(os.path.dirname(__file__),
+            'capital.1.toc'))
+        self.toc1.parse()
+        self.assertEquals(len(self.toc1.table.tracks), 11)
+        self.failUnless(self.toc1.table.tracks[-1].audio)
+
+        self.toc2 = toc.TocFile(os.path.join(os.path.dirname(__file__),
+            'capital.2.toc'))
+        self.toc2.parse()
+        self.assertEquals(len(self.toc2.table.tracks), 1)
+        self.failIf(self.toc2.table.tracks[-1].audio)
+
+        self.table = copy.deepcopy(self.toc1.table)
+        self.table.merge(self.toc2.table)
+
+
+    def testCDDBId(self):
+        self.table.absolutize()
+        self.assertEquals(self.table.getCDDBDiscId(), 'b910140c')
+        # output from cd-discid:
+        # b910140c 12 24320 44855 64090 77885 88095 104020 118245 129255 141765 164487 181780 209250 4440
+    testCDDBId.skip = 'not implemented yet'
+

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list