mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Fix CDRWin indexes.
This commit is contained in:
2
.idea/.idea.Aaru/.idea/contentModel.xml
generated
2
.idea/.idea.Aaru/.idea/contentModel.xml
generated
@@ -5,8 +5,6 @@
|
||||
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.1/resharper-host/local/Transient/ReSharperHost/v201/SolutionCaches/_Aaru.232757112.00" t="ExcludeRecursive" />
|
||||
<e p="$APPLICATION_CONFIG_DIR$/consoles/db" t="IncludeRecursive" />
|
||||
<e p="$APPLICATION_CONFIG_DIR$/extensions" t="IncludeRecursive" />
|
||||
<e p="$APPLICATION_CONFIG_DIR$/scratches" t="IncludeRecursive" />
|
||||
<e p="$USER_HOME$/.config/git/ignore" t="IncludeRecursive" />
|
||||
<e p="$APPLICATION_PLUGINS_DIR$/puppet/lib/stubs" t="IncludeRecursive" />
|
||||
<e p="$PROJECT_DIR$" t="IncludeFlat">
|
||||
<e p=".git/info/exclude" t="IncludeRecursive" />
|
||||
|
||||
@@ -38,14 +38,14 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
public partial class CdrWin
|
||||
{
|
||||
static ulong CdrWinMsfToLba(string msf)
|
||||
static int CdrWinMsfToLba(string msf)
|
||||
{
|
||||
string[] msfElements = msf.Split(':');
|
||||
ulong minute = ulong.Parse(msfElements[0]);
|
||||
ulong second = ulong.Parse(msfElements[1]);
|
||||
ulong frame = ulong.Parse(msfElements[2]);
|
||||
int minute = int.Parse(msfElements[0]);
|
||||
int second = int.Parse(msfElements[1]);
|
||||
int frame = int.Parse(msfElements[2]);
|
||||
|
||||
ulong sectors = (minute * 60 * 75) + (second * 75) + frame;
|
||||
int sectors = (minute * 60 * 75) + (second * 75) + frame;
|
||||
|
||||
return sectors;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
var aaruTrack = new Track
|
||||
{
|
||||
TrackDescription = cdrTrack.Title, TrackPregap = cdrTrack.Pregap,
|
||||
TrackDescription = cdrTrack.Title, TrackPregap = (ulong)cdrTrack.Pregap,
|
||||
TrackSession = cdrTrack.Session, TrackSequence = cdrTrack.Sequence,
|
||||
TrackType = CdrWinTrackTypeToTrackType(cdrTrack.TrackType),
|
||||
TrackFile = cdrTrack.TrackFile.DataFilter.GetFilename(),
|
||||
@@ -83,22 +83,33 @@ namespace Aaru.DiscImages
|
||||
TrackBytesPerSector = CdrWinTrackTypeToCookedBytesPerSector(cdrTrack.TrackType)
|
||||
};
|
||||
|
||||
if(aaruTrack.TrackSequence == 1)
|
||||
{
|
||||
aaruTrack.TrackPregap = 150;
|
||||
aaruTrack.Indexes[0] = -150;
|
||||
}
|
||||
|
||||
if(previousTrackFile == aaruTrack.TrackFile ||
|
||||
previousTrackFile == "")
|
||||
{
|
||||
if(!cdrTrack.Indexes.TryGetValue(0, out aaruTrack.TrackStartSector))
|
||||
if(!cdrTrack.Indexes.TryGetValue(1, out aaruTrack.TrackStartSector))
|
||||
aaruTrack.TrackStartSector += previousStartSector;
|
||||
}
|
||||
if(cdrTrack.Indexes.TryGetValue(0, out int idx0))
|
||||
if(idx0 > 0)
|
||||
aaruTrack.TrackStartSector = (ulong)idx0;
|
||||
else
|
||||
aaruTrack.TrackStartSector = 0;
|
||||
else if(cdrTrack.Indexes.TryGetValue(1, out int idx1))
|
||||
aaruTrack.TrackStartSector = (ulong)idx1;
|
||||
else
|
||||
aaruTrack.TrackStartSector += previousStartSector;
|
||||
else
|
||||
aaruTrack.TrackStartSector += previousStartSector;
|
||||
|
||||
foreach((ushort index, int position) in cdrTrack.Indexes)
|
||||
aaruTrack.Indexes[index] = position;
|
||||
|
||||
if(_discImage.IsRedumpGigadisc &&
|
||||
cdrTrack.Session == 2 &&
|
||||
previousStartSector < gdRomSession2Offset)
|
||||
{
|
||||
aaruTrack.TrackStartSector = gdRomSession2Offset;
|
||||
}
|
||||
|
||||
previousTrackFile = cdrTrack.TrackFile.DataFilter.GetFilename();
|
||||
|
||||
|
||||
@@ -117,15 +117,15 @@ namespace Aaru.DiscImages
|
||||
|
||||
var currentTrack = new CdrWinTrack
|
||||
{
|
||||
Indexes = new Dictionary<int, ulong>()
|
||||
Indexes = new Dictionary<ushort, int>()
|
||||
};
|
||||
|
||||
var currentFile = new CdrWinTrackFile();
|
||||
ulong currentFileOffsetSector = 0;
|
||||
var currentFile = new CdrWinTrackFile();
|
||||
long currentFileOffsetSector = 0;
|
||||
|
||||
int trackCount = 0;
|
||||
|
||||
Dictionary<byte, ulong> leadouts = new Dictionary<byte, ulong>();
|
||||
Dictionary<byte, int> leadouts = new Dictionary<byte, int>();
|
||||
|
||||
while(_cueStream.Peek() >= 0)
|
||||
{
|
||||
@@ -627,8 +627,8 @@ namespace Aaru.DiscImages
|
||||
if(!inTrack)
|
||||
throw new FeatureUnsupportedImageException($"Found INDEX before a track {lineNumber}");
|
||||
|
||||
int index = int.Parse(matchIndex.Groups[1].Value);
|
||||
ulong offset = CdrWinMsfToLba(matchIndex.Groups[2].Value);
|
||||
ushort index = ushort.Parse(matchIndex.Groups[1].Value);
|
||||
int offset = CdrWinMsfToLba(matchIndex.Groups[2].Value);
|
||||
|
||||
if(index != 0 &&
|
||||
index != 1 &&
|
||||
@@ -641,7 +641,8 @@ namespace Aaru.DiscImages
|
||||
if((int)(currentTrack.Sequence - 2) >= 0 &&
|
||||
offset > 1)
|
||||
{
|
||||
cueTracks[currentTrack.Sequence - 2].Sectors = offset - currentFileOffsetSector;
|
||||
cueTracks[currentTrack.Sequence - 2].Sectors =
|
||||
(ulong)(offset - (int)currentFileOffsetSector);
|
||||
|
||||
currentFile.Offset +=
|
||||
cueTracks[currentTrack.Sequence - 2].Sectors *
|
||||
@@ -665,7 +666,7 @@ namespace Aaru.DiscImages
|
||||
AaruConsole.DebugWriteLine("CDRWin plugin", "Sets currentFile.offset to {0}",
|
||||
offset * currentTrack.Bps);
|
||||
|
||||
currentFile.Offset = offset * currentTrack.Bps;
|
||||
currentFile.Offset = (ulong)(offset * currentTrack.Bps);
|
||||
}
|
||||
|
||||
currentFileOffsetSector = offset;
|
||||
@@ -758,7 +759,7 @@ namespace Aaru.DiscImages
|
||||
|
||||
currentTrack = new CdrWinTrack
|
||||
{
|
||||
Indexes = new Dictionary<int, ulong>(),
|
||||
Indexes = new Dictionary<ushort, int>(),
|
||||
Sequence = uint.Parse(matchTrack.Groups[1].Value)
|
||||
};
|
||||
|
||||
@@ -827,28 +828,39 @@ namespace Aaru.DiscImages
|
||||
sessions[s - 1].StartTrack = cueTracks[firstSessionTrk].Sequence;
|
||||
sessions[s - 1].EndTrack = cueTracks[lastSessionTrack].Sequence;
|
||||
|
||||
if(leadouts.TryGetValue((byte)s, out ulong leadout))
|
||||
if(leadouts.TryGetValue((byte)s, out int leadout))
|
||||
{
|
||||
sessions[s - 1].EndSector = leadout - 1;
|
||||
sessions[s - 1].EndSector = (ulong)(leadout - 1);
|
||||
|
||||
if(!cueTracks[lastSessionTrack].Indexes.TryGetValue(0, out ulong startSector))
|
||||
if(!cueTracks[lastSessionTrack].Indexes.TryGetValue(0, out int startSector))
|
||||
cueTracks[lastSessionTrack].Indexes.TryGetValue(1, out startSector);
|
||||
|
||||
cueTracks[lastSessionTrack].Sectors = leadout - startSector;
|
||||
cueTracks[lastSessionTrack].Sectors = (ulong)(leadout - startSector);
|
||||
}
|
||||
else
|
||||
sessions[s - 1].EndSector = (sessions[s - 1].StartSector + sessionSectors) - 1;
|
||||
|
||||
CdrWinTrack firstSessionTrack = cueTracks.OrderBy(t => t.Sequence).First(t => t.Session == s);
|
||||
|
||||
firstSessionTrack.Indexes.TryGetValue(0, out firstSessionTrack.Pregap);
|
||||
|
||||
if(firstSessionTrack.Pregap < 150)
|
||||
firstSessionTrack.Pregap = 150;
|
||||
|
||||
if(cueTracks.All(i => i.TrackFile.DataFilter.GetFilename() ==
|
||||
cueTracks.First().TrackFile.DataFilter.GetFilename()))
|
||||
{
|
||||
if(firstSessionTrack.Indexes.TryGetValue(0, out sessions[s - 1].StartSector))
|
||||
continue;
|
||||
if(firstSessionTrack.Indexes.TryGetValue(0, out int sessionStart))
|
||||
{
|
||||
sessions[s - 1].StartSector = (ulong)sessionStart;
|
||||
|
||||
if(firstSessionTrack.Indexes.TryGetValue(1, out sessions[s - 1].StartSector))
|
||||
continue;
|
||||
}
|
||||
|
||||
if(firstSessionTrack.Indexes.TryGetValue(1, out sessionStart))
|
||||
{
|
||||
sessions[s - 1].StartSector = (ulong)sessionStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,8 +869,8 @@ namespace Aaru.DiscImages
|
||||
|
||||
for(int t = 1; t <= cueTracks.Length; t++)
|
||||
{
|
||||
if(cueTracks[t - 1].Indexes.TryGetValue(0, out ulong idx0) &&
|
||||
cueTracks[t - 1].Indexes.TryGetValue(1, out ulong idx1))
|
||||
if(cueTracks[t - 1].Indexes.TryGetValue(0, out int idx0) &&
|
||||
cueTracks[t - 1].Indexes.TryGetValue(1, out int idx1))
|
||||
cueTracks[t - 1].Pregap = idx1 - idx0;
|
||||
|
||||
_discImage.Tracks.Add(cueTracks[t - 1]);
|
||||
@@ -1064,7 +1076,7 @@ namespace Aaru.DiscImages
|
||||
|
||||
AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tIndexes:");
|
||||
|
||||
foreach(KeyValuePair<int, ulong> kvp in _discImage.Tracks[i].Indexes)
|
||||
foreach(KeyValuePair<ushort, int> kvp in _discImage.Tracks[i].Indexes)
|
||||
AaruConsole.DebugWriteLine("CDRWin plugin", "\t\t\tIndex {0} starts at sector {1}", kvp.Key,
|
||||
kvp.Value);
|
||||
|
||||
@@ -1124,7 +1136,7 @@ namespace Aaru.DiscImages
|
||||
|
||||
var partition = new Partition();
|
||||
|
||||
if(!_discImage.Tracks[i].Indexes.TryGetValue(1, out ulong _))
|
||||
if(!_discImage.Tracks[i].Indexes.TryGetValue(1, out _))
|
||||
throw new ImageNotSupportedException($"Track {_discImage.Tracks[i].Sequence} lacks index 01");
|
||||
|
||||
if(_discImage.IsRedumpGigadisc &&
|
||||
|
||||
@@ -51,48 +51,48 @@ namespace Aaru.DiscImages
|
||||
public string FileType;
|
||||
}
|
||||
|
||||
struct CdrWinTrack
|
||||
class CdrWinTrack
|
||||
{
|
||||
/// <summary>Track #</summary>
|
||||
public uint Sequence;
|
||||
/// <summary>Track title (from CD-Text)</summary>
|
||||
public string Title;
|
||||
/// <summary>Track genre (from CD-Text)</summary>
|
||||
public string Genre;
|
||||
/// <summary>Track arranger (from CD-Text)</summary>
|
||||
public string Arranger;
|
||||
/// <summary>Bytes per sector</summary>
|
||||
public ushort Bps;
|
||||
/// <summary>Track composer (from CD-Text)</summary>
|
||||
public string Composer;
|
||||
/// <summary>Track performer (from CD-Text)</summary>
|
||||
public string Performer;
|
||||
/// <summary>Track song writer (from CD-Text)</summary>
|
||||
public string Songwriter;
|
||||
/// <summary>Track ISRC</summary>
|
||||
public string Isrc;
|
||||
/// <summary>File struct for this track</summary>
|
||||
public CdrWinTrackFile TrackFile;
|
||||
/// <summary>Indexes on this track</summary>
|
||||
public Dictionary<int, ulong> Indexes;
|
||||
/// <summary>Track pre-gap in sectors</summary>
|
||||
public ulong Pregap;
|
||||
/// <summary>Track post-gap in sectors</summary>
|
||||
public ulong Postgap;
|
||||
/// <summary>Digital Copy Permitted</summary>
|
||||
public bool FlagDcp;
|
||||
/// <summary>Track is quadraphonic</summary>
|
||||
public bool Flag4ch;
|
||||
/// <summary>Digital Copy Permitted</summary>
|
||||
public bool FlagDcp;
|
||||
/// <summary>Track has pre-emphasis</summary>
|
||||
public bool FlagPre;
|
||||
/// <summary>Track has SCMS</summary>
|
||||
public bool FlagScms;
|
||||
/// <summary>Bytes per sector</summary>
|
||||
public ushort Bps;
|
||||
/// <summary>Track genre (from CD-Text)</summary>
|
||||
public string Genre;
|
||||
/// <summary>Indexes on this track</summary>
|
||||
public Dictionary<ushort, int> Indexes;
|
||||
/// <summary>Track ISRC</summary>
|
||||
public string Isrc;
|
||||
/// <summary>Track performer (from CD-Text)</summary>
|
||||
public string Performer;
|
||||
/// <summary>Track post-gap in sectors</summary>
|
||||
public int Postgap;
|
||||
/// <summary>Track pre-gap in sectors</summary>
|
||||
public int Pregap;
|
||||
/// <summary>Sectors in track</summary>
|
||||
public ulong Sectors;
|
||||
/// <summary>Track type</summary>
|
||||
public string TrackType;
|
||||
/// <summary>Track #</summary>
|
||||
public uint Sequence;
|
||||
/// <summary>Track session</summary>
|
||||
public ushort Session;
|
||||
/// <summary>Track song writer (from CD-Text)</summary>
|
||||
public string Songwriter;
|
||||
/// <summary>Track title (from CD-Text)</summary>
|
||||
public string Title;
|
||||
/// <summary>File struct for this track</summary>
|
||||
public CdrWinTrackFile TrackFile;
|
||||
/// <summary>Track type</summary>
|
||||
public string TrackType;
|
||||
}
|
||||
|
||||
struct CdrWinDisc
|
||||
|
||||
Reference in New Issue
Block a user