bug-ccd2cue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug fix patch


From: Ken Arromdee
Subject: Bug fix patch
Date: Mon, 26 Apr 2021 00:42:14 -0400 (EDT)
User-agent: Alpine 2.11 (LMD 23 2013-08-11)

This patch solves my problem with ccd files that only produced a single line.  
There are some cue files (which I found for PC Engine CD and Saturn disk 
images) where there are no track entries, but there are TOC entries that 
provide some of the same information.

I have a couple of PC Engine CD and Saturn cue files found in the wild with the 
corresponding ccd files.  This patch produces cue files matching those except 
possibly for the pregap length; I have no idea where to find it and I 
arbitrarily chose 150, which is a common value but not the only one.

This is very incomplete, but it'll add a bunch of working cases.  It won't work 
for Playstation, which is MODE2/2352 (I have no idea what values mean that) nor 
will it work for anything that needs the ALBA values.  The magic number 128 is 
arbitrary since the actual values that it needs to find are 0xa0 or above.

This patch is under Creative Commons CC0 if that matters.  Go put it in ccd2cue 
if anyone's still maintaining it.  If not, maybe someone who needs it might 
still find it in the mailing list archives.

*** old/convert.c       2015-03-05 19:22:06.000000000 -0500
--- convert.c   2021-04-25 16:51:33.524464108 -0400
***************
*** 178,183 ****
--- 178,223 ----
        }

      }
+ /* KAA */
+     else if (ccd->Disc.TocEntries > 0) {
+       size_t i;
+       int skipped = 0;
+
+       cue->FILE[0].TrackEntries = ccd->Disc.TocEntries;
+       // Track numbers are 1-based while TOC entries are 0-based.  Beware.
+       cue->FILE[0].FirstTrack = 1;
+       cue->FILE[0].TRACK = cue_TRACK_init (cue->FILE[0].TrackEntries + 1);
+
+       // Hack for Saturn and PC Engine CDs.
+
+       for (i = cue->FILE[0].FirstTrack; i <= ccd->Disc.TocEntries; i++)
+       {
+           int inputindex, outputindex;
+
+           inputindex = i-1;
+           if (ccd->Entry[inputindex].Point >= 128) {
+               skipped++;
+               continue;
+           }
+           outputindex = i-skipped;
+           assert(ccd->Entry[inputindex].Point == outputindex);
+           if (ccd->Entry[inputindex].Control == 4)
+               cue->FILE[0].TRACK[outputindex].datatype = MODE1_2352;
+           else
+               cue->FILE[0].TRACK[outputindex].datatype = AUDIO_2352;
+           cue->FILE[0].TRACK[outputindex].IndexEntries = 2;
+           cue->FILE[0].TRACK[outputindex].INDEX = xmalloc (sizeof 
(*cue->FILE[0].TRACK[outputindex].INDEX) * 2);
+           // INDEX[0] is the pregap.  There is no pregap before the first
+           // track.
+           // Pregap of 150 (2 seconds) is arbitrary but seems common in the
+           // wild.  I've also seen 149, 3 sec, 4 sec, etc.  This does not seem
+           // to be related to the 150 used to compute PLBA in the first place.
+           if (ccd->Entry[inputindex].PLBA != 0)
+               frames2msf (ccd->Entry[inputindex].PLBA - 150, 
&cue->FILE[0].TRACK[outputindex].INDEX[0]);
+           frames2msf (ccd->Entry[inputindex].PLBA, 
&cue->FILE[0].TRACK[outputindex].INDEX[1]);
+       }
+       cue->FILE[0].TrackEntries -= skipped;
+     }

    /* Return success. */
    return cue;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]