Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute AccurateRip v2 checksum instead of v1. #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions morituri/common/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ def do_checksum_buffer(self, buf, checksum):
# ... on 5th frame, only use last value
elif self._discFrameCounter == 5:
values = struct.unpack("<I", buf[-4:])
checksum += common.SAMPLES_PER_FRAME * 5 * values[0]
mvalue = common.SAMPLES_PER_FRAME * 5 * values[0]
(hi, lo) = divmod(mvalue, 2 ** 32)
checksum += lo + hi
checksum &= 0xFFFFFFFF
return checksum

Expand All @@ -314,7 +316,9 @@ def do_checksum_buffer(self, buf, checksum):
values = struct.unpack("<%dI" % (len(buf) / 4), buf)
for i, value in enumerate(values):
# self._bytes is updated after do_checksum_buffer
checksum += (self._bytes / 4 + i + 1) * value
mvalue = (self._bytes / 4 + i + 1) * value
(hi, lo) = divmod(mvalue, 2 ** 32)
checksum += lo + hi
checksum &= 0xFFFFFFFF
# offset = self._bytes / 4 + i + 1
# if offset % common.SAMPLES_PER_FRAME == 0:
Expand Down