* examples/ARcue.py:
* morituri/common/checksum.py: * morituri/image/image.py: * morituri/image/toc.py: * examples/gtkchecksum.py (added): * examples/gtkcrc.py (deleted): More crc->checksum changes.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
||||
2009-04-15 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* examples/ARcue.py:
|
||||
* morituri/common/checksum.py:
|
||||
* morituri/image/image.py:
|
||||
* morituri/image/toc.py:
|
||||
* examples/gtkchecksum.py (added):
|
||||
* examples/gtkcrc.py (deleted):
|
||||
More crc->checksum changes.
|
||||
|
||||
2009-04-15 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* examples/ARcue.py:
|
||||
|
||||
@@ -117,7 +117,8 @@ def main(argv):
|
||||
response = r
|
||||
else:
|
||||
assert r == response, \
|
||||
"CRC %s for %d matches wrong response %d, checksum %s" % (
|
||||
"checksum %s for %d matches wrong response %d, "\
|
||||
"checksum %s" % (
|
||||
checksum, i + 1, j + 1, response.checksums[i])
|
||||
status = 'rip accurate '
|
||||
archecksum = checksum
|
||||
@@ -133,8 +134,8 @@ def main(argv):
|
||||
if confidence < maxConfidence:
|
||||
c = "(confidence %3d of %3d)" % (confidence, maxConfidence)
|
||||
|
||||
ar = " AR [%s]" % response.checksums[i]
|
||||
print "Track %2d: %s %s mine [%08x] %s" % (
|
||||
ar = ", AR [%s]" % response.checksums[i]
|
||||
print "Track %2d: %s %s [%08x]%s" % (
|
||||
i + 1, status, c, checksum, ar)
|
||||
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ from morituri.common import task
|
||||
|
||||
# checksums are not CRC's. a CRC is a specific type of checksum.
|
||||
|
||||
FRAMES_PER_DISC_FRAME = 588
|
||||
SAMPLES_PER_DISC_FRAME = FRAMES_PER_DISC_FRAME * 4
|
||||
DISC_FRAMES_PER_SECOND = 75
|
||||
SAMPLES_PER_FRAME = 588
|
||||
BYTES_PER_FRAME = SAMPLES_PER_FRAME * 4
|
||||
FRAMES_PER_SECOND = 75
|
||||
|
||||
class ChecksumTask(task.Task):
|
||||
"""
|
||||
@@ -104,8 +104,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 / FRAMES_PER_DISC_FRAME,
|
||||
(self._frameEnd + 1) / FRAMES_PER_DISC_FRAME))
|
||||
self._path, self._frameStart / SAMPLES_PER_FRAME,
|
||||
(self._frameEnd + 1) / 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)
|
||||
@@ -143,9 +143,9 @@ class ChecksumTask(task.Task):
|
||||
# see http://bugzilla.gnome.org/show_bug.cgi?id=576505
|
||||
self._adapter.push(buffer)
|
||||
|
||||
while self._adapter.available() >= SAMPLES_PER_DISC_FRAME:
|
||||
while self._adapter.available() >= BYTES_PER_FRAME:
|
||||
# FIXME: in 0.10.14.1, take_buffer leaks a ref
|
||||
buffer = self._adapter.take_buffer(SAMPLES_PER_DISC_FRAME)
|
||||
buffer = self._adapter.take_buffer(BYTES_PER_FRAME)
|
||||
|
||||
self._checksum = self.do_checksum_buffer(buffer, self._checksum)
|
||||
self._bytes += len(buffer)
|
||||
@@ -224,13 +224,13 @@ class AccurateRipChecksumTask(ChecksumTask):
|
||||
# ... on 5th frame, only use last value
|
||||
elif self._discFrameCounter == 5:
|
||||
values = struct.unpack("<I", buffer[-4:])
|
||||
checksum += FRAMES_PER_DISC_FRAME * 5 * values[0]
|
||||
checksum += 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 / FRAMES_PER_DISC_FRAME
|
||||
discFrameLength = self._frameLength / SAMPLES_PER_FRAME
|
||||
if self._discFrameCounter > discFrameLength - 5:
|
||||
self.debug('skipping frame %d' % self._discFrameCounter)
|
||||
return checksum
|
||||
@@ -242,9 +242,9 @@ class AccurateRipChecksumTask(ChecksumTask):
|
||||
sum += (self._bytes / 4 + i + 1) * value
|
||||
sum &= 0xFFFFFFFF
|
||||
# offset = self._bytes / 4 + i + 1
|
||||
# if offset % FRAMES_PER_DISC_FRAME == 0:
|
||||
# if offset % SAMPLES_PER_FRAME == 0:
|
||||
# print 'THOMAS: frame %d, ends before %d, last value %08x, CRC %08x' % (
|
||||
# offset / FRAMES_PER_DISC_FRAME, offset, value, sum)
|
||||
# offset / SAMPLES_PER_FRAME, offset, value, sum)
|
||||
|
||||
checksum += sum
|
||||
checksum &= 0xFFFFFFFF
|
||||
|
||||
@@ -171,8 +171,8 @@ class AccurateRipChecksumTask(MultiTask):
|
||||
path = image.getRealPath(file.path)
|
||||
checksumTask = checksum.AccurateRipChecksumTask(path,
|
||||
trackNumber=trackIndex + 1, trackCount=len(cue.tracks),
|
||||
frameStart=offset * checksum.FRAMES_PER_DISC_FRAME,
|
||||
frameLength=length * checksum.FRAMES_PER_DISC_FRAME)
|
||||
frameStart=offset * checksum.SAMPLES_PER_FRAME,
|
||||
frameLength=length * checksum.SAMPLES_PER_FRAME)
|
||||
self.addTask(checksumTask)
|
||||
|
||||
def stop(self):
|
||||
@@ -252,8 +252,8 @@ class ImageVerifyTask(MultiTask):
|
||||
# print '%d has length %d' % (trackIndex, taskk.length)
|
||||
index = track._indexes[1]
|
||||
offset = index[0]
|
||||
assert taskk.length % checksum.FRAMES_PER_DISC_FRAME == 0
|
||||
end = taskk.length / checksum.FRAMES_PER_DISC_FRAME
|
||||
assert taskk.length % checksum.SAMPLES_PER_FRAME == 0
|
||||
end = taskk.length / checksum.SAMPLES_PER_FRAME
|
||||
self.lengths[trackIndex] = end - offset
|
||||
|
||||
MultiTask.stop(self)
|
||||
|
||||
@@ -134,14 +134,14 @@ class TOC:
|
||||
# CD's have a standard lead-in time of 2 seconds
|
||||
# which gets added for CDDB disc id's
|
||||
offset = self.getTrackStart(track.number) + \
|
||||
2 * checksum.DISC_FRAMES_PER_SECOND
|
||||
seconds = offset / checksum.DISC_FRAMES_PER_SECOND
|
||||
2 * checksum.FRAMES_PER_SECOND
|
||||
seconds = offset / checksum.FRAMES_PER_SECOND
|
||||
n += self._cddbSum(seconds)
|
||||
|
||||
last = self.tracks[-1]
|
||||
leadout = self.getTrackEnd(last.number)
|
||||
frameLength = leadout - self.getTrackStart(1)
|
||||
t = frameLength / checksum.DISC_FRAMES_PER_SECOND
|
||||
t = frameLength / checksum.FRAMES_PER_SECOND
|
||||
|
||||
value = (n % 0xff) << 24 | t << 8 | len(self.tracks)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user