superg / redumper

Low level CD dumper utility
GNU General Public License v3.0
221 stars 20 forks source link

Feature Request - Refine mode - Utilize EDC/ECC data when available to evaluate corrections #30

Open ehw opened 1 year ago

ehw commented 1 year ago

CDs that utilize data tracks can often times carry error correction and error detection data as part of the sectors in the given data track. Data tracks can consist of different sector structures, such as Mode 1, Mode 2 Form 1, Mode 2 Form 2. The various structures can carry either both EDC/ECC data, just the EDC data, or none at all (like formless Mode 2). These modes can all be determined by the sector header at specific offsets within the sector itself.

Right now, Redumper does sample based refining for error correction by using C2 status bits. However, utilizing C2 status bits alone might lead to results that contain errors. This is especially the case if there are tons of c2 errors that affect a range of sectors grouped together.

What I propose is to utilize EDC/ECC data, if present, to strengthen sample corrections so that it can be determined if the sample corrections being returned by the drive are truly fixing the sector.

For instance, let's say Redumper returns a c2 bit that's good for a sample previous marked bad. Apply the correction, then run tests on the data written in the scram if its been determined that the sector contains either EDC or ECC data. If the sample that got written affects a part of the sector that can be verified by the EDC/ECC data, determine if the P or Q channel for bytes that sample affects passes. If it does, then the sample correction was correct. If not, then the returned C2 error bit might've been wrong and to mark the bit in the .state file for a retry. You could probably even strengthen this algorithm for specific scenarios, such as if the reported checksums for the sector match a predetermined common pattern that be assumed (like a sector with all 00s in the user data area).

Check the attached zip for a visual representation of how EDC/ECC applies to a sector and how it can be used to verify P and Q channels separately for errors.

Virtua_Fighter_4_Preview_February_2002-report.zip

Unfortunately this won't help for audio tracks since there are no other error detection or correction mechanisms in place.