Apply nocompress option in dicformat for sector prefix, suffix and subchannel blocks.

This commit is contained in:
2018-02-02 22:21:29 +00:00
parent 448d55b547
commit 88bef522bf

View File

@@ -3626,13 +3626,25 @@ namespace DiscImageChef.DiscImages
identifier = BlockType.DataBlock,
type = DataType.CdSectorPrefix,
length = (uint)sectorPrefix.Length,
crc64 = BitConverter.ToUInt64(blockCrc, 0)
crc64 = BitConverter.ToUInt64(blockCrc, 0),
sectorSize = 16
};
byte[] lzmaProperties = null;
if(nocompress)
{
prefixBlock.compression = CompressionType.None;
prefixBlock.cmpCrc64 = prefixBlock.crc64;
prefixBlock.cmpLength = prefixBlock.length;
blockStream = new MemoryStream(sectorPrefix);
}
else
{
blockStream = new MemoryStream();
lzmaBlockStream = new LzmaStream(lzmaEncoderProperties, false, blockStream);
lzmaBlockStream.Write(sectorPrefix, 0, sectorPrefix.Length);
byte[] lzmaProperties = lzmaBlockStream.Properties;
lzmaProperties = lzmaBlockStream.Properties;
lzmaBlockStream.Close();
Crc64Context.Data(blockStream.ToArray(), out blockCrc);
@@ -3641,6 +3653,7 @@ namespace DiscImageChef.DiscImages
prefixBlock.compression = CompressionType.Lzma;
lzmaBlockStream = null;
}
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(prefixBlock));
structureBytes = new byte[Marshal.SizeOf(prefixBlock)];
@@ -3652,6 +3665,7 @@ namespace DiscImageChef.DiscImages
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length);
index.RemoveAll(t => t.blockType == BlockType.DataBlock &&
t.dataType == DataType.CdSectorPrefix);
@@ -3674,9 +3688,19 @@ namespace DiscImageChef.DiscImages
identifier = BlockType.DataBlock,
type = DataType.CdSectorSuffix,
length = (uint)sectorSuffix.Length,
crc64 = BitConverter.ToUInt64(blockCrc, 0)
crc64 = BitConverter.ToUInt64(blockCrc, 0),
sectorSize = 288
};
if(nocompress)
{
prefixBlock.compression = CompressionType.None;
prefixBlock.cmpCrc64 = prefixBlock.crc64;
prefixBlock.cmpLength = prefixBlock.length;
blockStream = new MemoryStream(sectorSuffix);
}
else
{
blockStream = new MemoryStream();
lzmaBlockStream = new LzmaStream(lzmaEncoderProperties, false, blockStream);
lzmaBlockStream.Write(sectorSuffix, 0, sectorSuffix.Length);
@@ -3689,6 +3713,7 @@ namespace DiscImageChef.DiscImages
prefixBlock.compression = CompressionType.Lzma;
lzmaBlockStream = null;
}
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(prefixBlock));
structureBytes = new byte[Marshal.SizeOf(prefixBlock)];
@@ -3726,13 +3751,25 @@ namespace DiscImageChef.DiscImages
identifier = BlockType.DataBlock,
type = DataType.CdSectorSubchannel,
length = (uint)sectorSubchannel.Length,
crc64 = BitConverter.ToUInt64(blockCrc, 0)
crc64 = BitConverter.ToUInt64(blockCrc, 0),
sectorSize = 96
};
byte[] lzmaProperties = null;
if(nocompress)
{
subchannelBlock.compression = CompressionType.None;
subchannelBlock.cmpCrc64 = subchannelBlock.crc64;
subchannelBlock.cmpLength = subchannelBlock.length;
blockStream = new MemoryStream(sectorSubchannel);
}
else
{
blockStream = new MemoryStream();
lzmaBlockStream = new LzmaStream(lzmaEncoderProperties, false, blockStream);
lzmaBlockStream.Write(sectorSubchannel, 0, sectorSubchannel.Length);
byte[] lzmaProperties = lzmaBlockStream.Properties;
lzmaProperties = lzmaBlockStream.Properties;
lzmaBlockStream.Close();
Crc64Context.Data(blockStream.ToArray(), out blockCrc);
@@ -3741,6 +3778,7 @@ namespace DiscImageChef.DiscImages
subchannelBlock.compression = CompressionType.Lzma;
lzmaBlockStream = null;
}
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(subchannelBlock));
structureBytes = new byte[Marshal.SizeOf(subchannelBlock)];
@@ -3873,10 +3911,37 @@ namespace DiscImageChef.DiscImages
crc64 = BitConverter.ToUInt64(blockCrc, 0)
};
switch(imageInfo.MediaType)
{
case MediaType.AppleSonySS:
case MediaType.AppleSonyDS:
subchannelBlock.sectorSize = 12;
break;
case MediaType.AppleFileWare:
case MediaType.AppleProfile:
case MediaType.AppleWidget:
subchannelBlock.sectorSize = 20;
break;
case MediaType.PriamDataTower:
subchannelBlock.sectorSize = 24;
break;
}
byte[] lzmaProperties = null;
if(nocompress)
{
subchannelBlock.compression = CompressionType.None;
subchannelBlock.cmpCrc64 = subchannelBlock.crc64;
subchannelBlock.cmpLength = subchannelBlock.length;
blockStream = new MemoryStream(sectorSubchannel);
}
else
{
blockStream = new MemoryStream();
lzmaBlockStream = new LzmaStream(lzmaEncoderProperties, false, blockStream);
lzmaBlockStream.Write(sectorSubchannel, 0, sectorSubchannel.Length);
byte[] lzmaProperties = lzmaBlockStream.Properties;
lzmaProperties = lzmaBlockStream.Properties;
lzmaBlockStream.Close();
Crc64Context.Data(blockStream.ToArray(), out blockCrc);
@@ -3885,6 +3950,7 @@ namespace DiscImageChef.DiscImages
subchannelBlock.compression = CompressionType.Lzma;
lzmaBlockStream = null;
}
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(subchannelBlock));
structureBytes = new byte[Marshal.SizeOf(subchannelBlock)];