Fix reading subchannels from BlindWrite 5/6 images.

This commit is contained in:
2020-06-18 02:11:55 +01:00
parent 3f1e417774
commit 6f1a89d2ed

View File

@@ -1513,7 +1513,32 @@ namespace Aaru.DiscImages
break; break;
} }
case SectorTagType.CdSectorSubchannel: case SectorTagType.CdSectorSubchannel:
throw new NotImplementedException("Packed subchannel not yet supported"); {
switch(chars.Subchannel)
{
case TrackSubchannelType.PackedInterleaved:
{
sectorOffset = 2352;
sectorSize = 96;
sectorSkip = 0;
break;
}
case TrackSubchannelType.Q16Interleaved:
{
sectorOffset = 2352;
sectorSize = 16;
sectorSkip = 0;
break;
}
default: throw new ArgumentOutOfRangeException();
}
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
} }
@@ -1579,7 +1604,32 @@ namespace Aaru.DiscImages
break; break;
} }
case SectorTagType.CdSectorSubchannel: case SectorTagType.CdSectorSubchannel:
throw new NotImplementedException("Packed subchannel not yet supported"); {
switch(chars.Subchannel)
{
case TrackSubchannelType.PackedInterleaved:
{
sectorOffset = 2352;
sectorSize = 96;
sectorSkip = 0;
break;
}
case TrackSubchannelType.Q16Interleaved:
{
sectorOffset = 2352;
sectorSize = 16;
sectorSkip = 0;
break;
}
default: throw new ArgumentOutOfRangeException();
}
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
} }
@@ -1620,7 +1670,32 @@ namespace Aaru.DiscImages
break; break;
} }
case SectorTagType.CdSectorSubchannel: case SectorTagType.CdSectorSubchannel:
throw new NotImplementedException("Packed subchannel not yet supported"); {
switch(chars.Subchannel)
{
case TrackSubchannelType.PackedInterleaved:
{
sectorOffset = 2352;
sectorSize = 96;
sectorSkip = 0;
break;
}
case TrackSubchannelType.Q16Interleaved:
{
sectorOffset = 2352;
sectorSize = 16;
sectorSkip = 0;
break;
}
default: throw new ArgumentOutOfRangeException();
}
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
} }
@@ -1630,13 +1705,41 @@ namespace Aaru.DiscImages
switch(tag) switch(tag)
{ {
case SectorTagType.CdSectorSubchannel: case SectorTagType.CdSectorSubchannel:
throw new NotImplementedException("Packed subchannel not yet supported"); {
switch(chars.Subchannel)
{
case TrackSubchannelType.PackedInterleaved:
{
sectorOffset = 2352;
sectorSize = 96;
sectorSkip = 0;
break;
}
case TrackSubchannelType.Q16Interleaved:
{
sectorOffset = 2352;
sectorSize = 16;
sectorSkip = 0;
break;
}
default: throw new ArgumentOutOfRangeException();
}
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
} }
break;
} }
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type"); default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
} }
if(tag != SectorTagType.CdSectorSubchannel)
switch(chars.Subchannel) switch(chars.Subchannel)
{ {
case TrackSubchannelType.None: case TrackSubchannelType.None:
@@ -1675,11 +1778,15 @@ namespace Aaru.DiscImages
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
} }
if(tag == SectorTagType.CdSectorSubchannel && if(tag != SectorTagType.CdSectorSubchannel)
chars.Subchannel == TrackSubchannelType.Q16Interleaved)
return Subchannel.ConvertQToRaw(buffer);
return buffer; return buffer;
return chars.Subchannel switch
{
TrackSubchannelType.Q16Interleaved => Subchannel.ConvertQToRaw(buffer),
TrackSubchannelType.PackedInterleaved => Subchannel.Interleave(buffer),
_ => buffer
};
} }
public byte[] ReadSectorLong(ulong sectorAddress) => ReadSectorsLong(sectorAddress, 1); public byte[] ReadSectorLong(ulong sectorAddress) => ReadSectorsLong(sectorAddress, 1);