Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / libparanoia / README.paranoia
1 # @(#)README.paranoia   1.1 97/04/04 J. Schilling from Monty (xiphmont@mit.edu)
2 README.paranoia
3
4 Paranoia II:
5 (c) Monty
6 xiphmont@mit.edu
7
8 Hi there.
9
10 All CDROM drives are not created equal.  You're probably using this
11 patch because yours is a little less equal than others-- or maybe you
12 just keep your CD collection in a box of full of gravel.  Jewel cases
13 are for wimps; you know what I'm talking about.
14
15 This patch adds extra-robust interframe syncronization, code to detect
16 scratches (and hold sync across the scratch) and finally routines to
17 filter out scratches as best possible.  These are all handled
18 automatically by fairly modular code.
19
20 1) extra interframe syncronization -------------------------------------
21
22 Some CD drives can read audio data from an exact starting point to an
23 exact ending point flawlessly; these are rare.  A larger number of
24 drives read from only an approximately correct starting point, but do
25 manage to get all the data in-tact from wherever they manage to begin
26 the read.  Stock cdda2wav is coded with this in mind.
27
28 More drives, especially IDE-like and recent ATAPI drives, suffer from
29 framing misalignments within atomic multi-sector read operations.
30 Cdda2wav is also set, by default, to read 75 sectors at a time from
31 ATAPI drives, which Linux's IDE driver breaks into multiple 8 sector
32 reads to conserve kernel memory.  Both of these things will break
33 cdda2wav; the symptoms include cracks or pops within the read sample.
34
35 The "Paranoia" patch will verify the alignment of *every* byte read by
36 cdda2wav.  The goal is data integrity, not performance: a minimum 50%
37 speed hit will result from the patch, likely more if your CDROM
38 suffers from the framing bugs the patch corrects.  
39
40 2) scratch detection and tolerance ------------------------------------
41
42 Because overlap syncronization requires matching exact, perfect sample
43 sections, scratched CDs typically cause normal cdda2wav to bail when
44 overlap syncronization is turned on.  The second part of the
45 "Paranoia" patch ignores scratches in the read bitstream and
46 syncronizes using the data that can still be "trusted".  This step
47 also collects first-pass scratch detection information used by the
48 third section of the patch.
49
50 Expect performance to drop through the floor on a badly scratched CD;
51 the code can no longer use a simple case of exact matching for speedy
52 correlation.  Maintaining solid sync across a scratch is processor
53 bound; later I'll add speedier algorithms for correlation than the
54 brute force method currently used.  Scratch detection imposes little
55 additional overhead on a non-scratched CD.
56
57 3) scratch repair -----------------------------------------------------
58
59 Scratches are an irrevocable loss of data.  Still, it's usually
60 possible to reconstruct a sample closer to the original data than the
61 raw hissing, fluttering and crackling that severe scratches in the CD
62 surface produce.
63
64 Scratch filtering is the 'hard part' of this patch.  It needs to do
65 two things; first, find the 'pops' that escaped detection in section 2
66 of the patch and secondly fill in the gaps.  Both are acheived using
67 delta (slew) averaging and forward and backward linear predictive
68 interpolation (with IIR filters) to fill in known gaps as well as look
69 for 'problem values' in stretches of sample known to be scratched.
70
71 THE SCRATCH DETECTION IS NOT PERFECT.  Nor is the repair perfect,
72 although it is easier than detecting scratches reliably.  Both are
73 cases of coming arbitrarily close to perfection; Paranoia is designed
74 with light to moderate damage in mind, but will still recover a
75 listenable sample from heavy damage.  
76
77 Paranoia still has quite a bit of room for improvement in the scratch
78 repair code... If cdda2wav + Paranoia is not doing an acceptable job
79 on CDs that you just gotta have, drop me a line; I didn't want to sink
80 months into a project I wasn't certain anyone would ever use :-)
81
82 Monty
83