[SCM] morituri/master: * morituri/common/checksum.py: * morituri/common/common.py: * morituri/image/image.py: * morituri/image/table.py: * morituri/program/cdparanoia.py: Move constants to common

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


The following commit has been merged in the master branch:
commit 59cb5d0dcb182d95acdaabcf1b827ea244837a40
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sat May 16 09:21:55 2009 +0000

    	* morituri/common/checksum.py:
    	* morituri/common/common.py:
    	* morituri/image/image.py:
    	* morituri/image/table.py:
    	* morituri/program/cdparanoia.py:
    	  Move constants to common

diff --git a/ChangeLog b/ChangeLog
index a87fdf5..08baf28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2009-05-16  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+	* morituri/common/checksum.py:
+	* morituri/common/common.py:
+	* morituri/image/image.py:
+	* morituri/image/table.py:
+	* morituri/program/cdparanoia.py:
+	  Move constants to common
+
+2009-05-16  Thomas Vander Stichele  <thomas at apestaart dot org>
+
 	* examples/readdisc.py:
 	  Get our metadata only from the toc.
 
diff --git a/morituri/common/checksum.py b/morituri/common/checksum.py
index 94dd6f2..517d75f 100644
--- a/morituri/common/checksum.py
+++ b/morituri/common/checksum.py
@@ -28,15 +28,10 @@ import zlib
 import gobject
 import gst
 
-from morituri.common import task
+from morituri.common import common, task
 
 # checksums are not CRC's. a CRC is a specific type of checksum.
 
-SAMPLES_PER_FRAME = 588
-WORDS_PER_FRAME = SAMPLES_PER_FRAME * 2
-BYTES_PER_FRAME = SAMPLES_PER_FRAME * 4
-FRAMES_PER_SECOND = 75
-
 class ChecksumTask(task.Task):
     """
     I am a task that calculates a checksum.
@@ -110,8 +105,8 @@ class ChecksumTask(task.Task):
             gst.SEEK_TYPE_SET, self._frameStart,
             gst.SEEK_TYPE_SET, self._frameEnd + 1) # half-inclusive interval
         gst.debug('CRCing %s from sector %d to sector %d' % (
-            self._path, self._frameStart / SAMPLES_PER_FRAME,
-            (self._frameEnd + 1) / SAMPLES_PER_FRAME))
+            self._path, self._frameStart / common.SAMPLES_PER_FRAME,
+            (self._frameEnd + 1) / common.SAMPLES_PER_FRAME))
         # FIXME: sending it with frameEnd set screws up the seek, we don't get
         # everything for flac; fixed in recent -good
         result = sink.send_event(event)
@@ -149,9 +144,9 @@ class ChecksumTask(task.Task):
         # see http://bugzilla.gnome.org/show_bug.cgi?id=576505
         self._adapter.push(buffer)
 
-        while self._adapter.available() >= BYTES_PER_FRAME:
+        while self._adapter.available() >= common.BYTES_PER_FRAME:
             # FIXME: in 0.10.14.1, take_buffer leaks a ref
-            buffer = self._adapter.take_buffer(BYTES_PER_FRAME)
+            buffer = self._adapter.take_buffer(common.BYTES_PER_FRAME)
 
             self._checksum = self.do_checksum_buffer(buffer, self._checksum)
             self._bytes += len(buffer)
@@ -242,13 +237,13 @@ class AccurateRipChecksumTask(ChecksumTask):
             # ... on 5th frame, only use last value
             elif self._discFrameCounter == 5:
                 values = struct.unpack("<I", buffer[-4:])
-                checksum += SAMPLES_PER_FRAME * 5 * values[0]
+                checksum += common.SAMPLES_PER_FRAME * 5 * values[0]
                 checksum &= 0xFFFFFFFF
                 return checksum
  
         # on last track, skip last 5 CD frames
         if self._trackNumber == self._trackCount:
-            discFrameLength = self._frameLength / SAMPLES_PER_FRAME
+            discFrameLength = self._frameLength / common.SAMPLES_PER_FRAME
             if self._discFrameCounter > discFrameLength - 5:
                 self.debug('skipping frame %d', self._discFrameCounter)
                 return checksum
@@ -260,9 +255,9 @@ class AccurateRipChecksumTask(ChecksumTask):
             sum += (self._bytes / 4 + i + 1) * value
             sum &= 0xFFFFFFFF
             # offset = self._bytes / 4 + i + 1
-            # if offset % SAMPLES_PER_FRAME == 0:
+            # if offset % common.SAMPLES_PER_FRAME == 0:
             #    print 'THOMAS: frame %d, ends before %d, last value %08x, CRC %08x' % (
-            #        offset / SAMPLES_PER_FRAME, offset, value, sum)
+            #        offset / common.SAMPLES_PER_FRAME, offset, value, sum)
 
         checksum += sum
         checksum &= 0xFFFFFFFF
diff --git a/morituri/common/common.py b/morituri/common/common.py
index 75f3971..298628e 100644
--- a/morituri/common/common.py
+++ b/morituri/common/common.py
@@ -24,6 +24,11 @@ import os
 import tempfile
 import shutil
 
+SAMPLES_PER_FRAME = 588
+WORDS_PER_FRAME = SAMPLES_PER_FRAME * 2
+BYTES_PER_FRAME = SAMPLES_PER_FRAME * 4
+FRAMES_PER_SECOND = 75
+
 def msfToFrames(msf):
     """
     Converts a string value in MM:SS:FF to frames
diff --git a/morituri/image/image.py b/morituri/image/image.py
index efb31c5..11c4207 100644
--- a/morituri/image/image.py
+++ b/morituri/image/image.py
@@ -29,11 +29,9 @@ import struct
 
 import gst
 
-from morituri.common import task, checksum, log
+from morituri.common import task, checksum, log, common
 from morituri.image import cue, table
 
-from morituri.test import common
-
 class Image(object, log.Loggable):
     """
     @ivar table: The Table of Contents for this image.
@@ -116,8 +114,8 @@ class AccurateRipChecksumTask(task.MultiSeparateTask):
             path = image.getRealPath(index.path)
             checksumTask = checksum.AccurateRipChecksumTask(path,
                 trackNumber=trackIndex + 1, trackCount=len(cue.table.tracks),
-                frameStart=index.relative * checksum.SAMPLES_PER_FRAME,
-                frameLength=length * checksum.SAMPLES_PER_FRAME)
+                frameStart=index.relative * common.SAMPLES_PER_FRAME,
+                frameLength=length * common.SAMPLES_PER_FRAME)
             self.addTask(checksumTask)
 
     def stop(self):
@@ -195,8 +193,8 @@ class ImageVerifyTask(task.MultiSeparateTask):
         for trackIndex, track, taskk in self._tasks:
             # print '%d has length %d' % (trackIndex, taskk.length)
             index = track.indexes[1]
-            assert taskk.length % checksum.SAMPLES_PER_FRAME == 0
-            end = taskk.length / checksum.SAMPLES_PER_FRAME
+            assert taskk.length % common.SAMPLES_PER_FRAME == 0
+            end = taskk.length / common.SAMPLES_PER_FRAME
             self.lengths[trackIndex] = end - index.relative
 
         task.MultiSeparateTask.stop(self)
diff --git a/morituri/image/table.py b/morituri/image/table.py
index f37480e..126158b 100644
--- a/morituri/image/table.py
+++ b/morituri/image/table.py
@@ -29,7 +29,7 @@ import struct
 
 import gst
 
-from morituri.common import task, checksum, common, log
+from morituri.common import task, common, log
 
 # FIXME: taken from libcdio, but no reference found for these
 
@@ -204,20 +204,20 @@ class IndexTable(object, log.Loggable):
 
         # CD's have a standard lead-in time of 2 seconds
         # which gets added for CDDB disc id's
-        delta = 2 * checksum.FRAMES_PER_SECOND
+        delta = 2 * common.FRAMES_PER_SECOND
         #if self.getTrackStart(1) > 0:
         #    delta = 0
 
         for track in self.tracks:
             offset = self.getTrackStart(track.number) + delta
-            seconds = offset / checksum.FRAMES_PER_SECOND
+            seconds = offset / common.FRAMES_PER_SECOND
             n += self._cddbSum(seconds)
 
         last = self.tracks[-1]
         # the 'real' leadout, not offset by 150 frames
         leadout = self.getTrackEnd(last.number) + 1
-        startSeconds = self.getTrackStart(1) / checksum.FRAMES_PER_SECOND
-        leadoutSeconds = leadout / checksum.FRAMES_PER_SECOND
+        startSeconds = self.getTrackStart(1) / common.FRAMES_PER_SECOND
+        leadoutSeconds = leadout / common.FRAMES_PER_SECOND
         t = leadoutSeconds - startSeconds
 
         value = (n % 0xff) << 24 | t << 8 | len(self.tracks)
diff --git a/morituri/program/cdparanoia.py b/morituri/program/cdparanoia.py
index e3103b1..d8a2bed 100644
--- a/morituri/program/cdparanoia.py
+++ b/morituri/program/cdparanoia.py
@@ -194,14 +194,14 @@ class ReadTrackTask(task.Task):
         size = os.stat(self.path)[stat.ST_SIZE]
         # wav header is 44 bytes
         offsetLength = self._stop - self._start + 1
-        expected = offsetLength * checksum.BYTES_PER_FRAME + 44
+        expected = offsetLength * common.BYTES_PER_FRAME + 44
         if size != expected:
             # FIXME: handle errors better
             self.warning('file size %d did not match expected size %d',
                 size, expected)
-            if (size - expected) % checksum.BYTES_PER_FRAME == 0:
+            if (size - expected) % common.BYTES_PER_FRAME == 0:
                 print 'ERROR: %d frames difference' % (
-                    (size - expected) / checksum.BYTES_PER_FRAME)
+                    (size - expected) / common.BYTES_PER_FRAME)
 
             self.exception = FileSizeError(self.path)
 

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list