[SCM] morituri/master: WIP: try to set relative offset correctly based on sources

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:10:12 UTC 2014


The following commit has been merged in the master branch:
commit e3e3a87547f6617bc0877d7302d57d39a95b6ad1
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Mon Aug 19 00:18:53 2013 +0200

    WIP: try to set relative offset correctly based on sources

diff --git a/morituri/image/toc.py b/morituri/image/toc.py
index 9cc0c89..189de75 100644
--- a/morituri/image/toc.py
+++ b/morituri/image/toc.py
@@ -119,6 +119,16 @@ class Sources(log.Loggable):
 
         return self._sources[-1]
 
+    def getCounterStart(self, counter):
+        """
+        Retrieve the absolute offset of the first source for this counter
+        """
+        for i, (c, o, s) in enumerate(self._sources):
+            if c == counter:
+                return self._sources[i][1]
+
+        return self._sources[-1][1]
+
 
 class TocFile(object, log.Loggable):
 
@@ -197,7 +207,6 @@ class TocFile(object, log.Loggable):
                 # set index 1 of previous track if there was one, using
                 # pregapLength if applicable
                 if currentTrack:
-                    # FIXME: why not set absolute offsets too ?
                     currentTrack.index(1, path=currentFile.path,
                         absolute=absoluteOffset + pregapLength,
                         relative=currentFile.start + pregapLength,
@@ -310,6 +319,11 @@ class TocFile(object, log.Loggable):
 
                 length = common.msfToFrames(m.group('length'))
                 c, o, s = sources.get(absoluteOffset)
+                self.debug('at abs offset %d, we are in source %r' % (
+                    absoluteOffset, s))
+                counterStart = sources.getCounterStart(c)
+                relativeOffset = absoluteOffset - counterStart
+
                 currentTrack.index(0, path=s and s.path or None,
                     absolute=absoluteOffset,
                     relative=relativeOffset, counter=c)
diff --git a/morituri/test/test_image_toc.py b/morituri/test/test_image_toc.py
index a5bd4de..2a451e6 100644
--- a/morituri/test/test_image_toc.py
+++ b/morituri/test/test_image_toc.py
@@ -130,9 +130,16 @@ class BlocTestCase(common.TestCase):
         self.assertEquals(self.toc.getTrackLength(t), -1)
 
     def testIndexes(self):
-        t = self.toc.table.tracks[0]
-        self.assertEquals(t.getIndex(0).relative, 0)
-        self.assertEquals(t.getIndex(1).relative, 15220)
+        firstTrack = self.toc.table.tracks[0]
+        index0 = firstTrack.getIndex(0)
+        self.assertEquals(index0.absolute, 0)
+        self.assertEquals(index0.relative, 0)
+        self.assertEquals(index0.counter, 0)
+
+        index1 = firstTrack.getIndex(1)
+        self.assertEquals(index1.absolute, 15220)
+        self.assertEquals(index1.relative, 0)
+        self.assertEquals(index1.counter, 1)
 
     # This disc has a pre-gap, so is a good test for .CUE writing
 

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list