nocompress => !compress

This commit is contained in:
2020-03-10 00:04:19 +00:00
parent 563d391f5a
commit 0a0d458f91
3 changed files with 20 additions and 20 deletions

View File

@@ -92,6 +92,7 @@ namespace Aaru.DiscImages
MemoryStream blockStream; MemoryStream blockStream;
/// <summary>Provides checksum for deduplication of sectors.</summary> /// <summary>Provides checksum for deduplication of sectors.</summary>
SHA256 checksumProvider; SHA256 checksumProvider;
bool compress;
/// <summary>Provides CRC64.</summary> /// <summary>Provides CRC64.</summary>
Crc64Context crc64; Crc64Context crc64;
/// <summary>Header of the currently writing block.</summary> /// <summary>Header of the currently writing block.</summary>
@@ -131,7 +132,6 @@ namespace Aaru.DiscImages
/// <summary>Cache of media tags.</summary> /// <summary>Cache of media tags.</summary>
Dictionary<MediaTagType, byte[]> mediaTags; Dictionary<MediaTagType, byte[]> mediaTags;
byte[] mode2Subheaders; byte[] mode2Subheaders;
bool nocompress;
/// <summary>If DDT is on-disk, this is the image stream offset at which it starts.</summary> /// <summary>If DDT is on-disk, this is the image stream offset at which it starts.</summary>
long outMemoryDdtPosition; long outMemoryDdtPosition;
bool rewinded; bool rewinded;

View File

@@ -71,8 +71,8 @@ namespace Aaru.DiscImages
("deduplicate", typeof(bool), ("deduplicate", typeof(bool),
"Store only unique sectors. This consumes more memory and is slower, but it's enabled by default", "Store only unique sectors. This consumes more memory and is slower, but it's enabled by default",
(object)true), (object)true),
("nocompress", typeof(bool), "Don't compress user data blocks. Other blocks will still be compressed", ("compress", typeof(bool), "Compress user data blocks. Other blocks will always be compressed",
(object)false) (object)true)
}; };
public IEnumerable<string> KnownExtensions => new[] public IEnumerable<string> KnownExtensions => new[]
{ {

View File

@@ -166,17 +166,17 @@ namespace Aaru.DiscImages
else else
deduplicate = true; deduplicate = true;
if(options.TryGetValue("nocompress", out tmpValue)) if(options.TryGetValue("compress", out tmpValue))
{ {
if(!bool.TryParse(tmpValue, out nocompress)) if(!bool.TryParse(tmpValue, out compress))
{ {
ErrorMessage = "Invalid value for nocompress option"; ErrorMessage = "Invalid value for compress option";
return false; return false;
} }
} }
else else
nocompress = false; compress = true;
} }
else else
{ {
@@ -188,7 +188,7 @@ namespace Aaru.DiscImages
doSha256 = false; doSha256 = false;
doSpamsum = false; doSpamsum = false;
deduplicate = true; deduplicate = true;
nocompress = false; compress = true;
} }
// This really, cannot happen // This really, cannot happen
@@ -1125,14 +1125,14 @@ namespace Aaru.DiscImages
{ {
currentBlockHeader = new BlockHeader currentBlockHeader = new BlockHeader
{ {
identifier = BlockType.DataBlock, type = DataType.UserData, identifier = BlockType.DataBlock,
compression = nocompress ? CompressionType.None : CompressionType.Lzma, type = DataType.UserData,
sectorSize = (uint)data.Length compression = compress ? CompressionType.Lzma : CompressionType.None, sectorSize = (uint)data.Length
}; };
if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc && if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc &&
trk.TrackType == TrackType.Audio && trk.TrackType == TrackType.Audio &&
!nocompress) compress)
currentBlockHeader.compression = CompressionType.Flac; currentBlockHeader.compression = CompressionType.Flac;
// JaguarCD stores data in audio tracks. FLAC is too inefficient, use LZMA there. // JaguarCD stores data in audio tracks. FLAC is too inefficient, use LZMA there.
@@ -1142,7 +1142,7 @@ namespace Aaru.DiscImages
imageInfo.MediaType == MediaType.VideoNowColor || imageInfo.MediaType == MediaType.VideoNowColor ||
imageInfo.MediaType == MediaType.VideoNowXp) && imageInfo.MediaType == MediaType.VideoNowXp) &&
trk.TrackType == TrackType.Audio && trk.TrackType == TrackType.Audio &&
!nocompress && compress &&
currentBlockHeader.compression == CompressionType.Flac) currentBlockHeader.compression == CompressionType.Flac)
currentBlockHeader.compression = CompressionType.Lzma; currentBlockHeader.compression = CompressionType.Lzma;
@@ -2416,7 +2416,7 @@ namespace Aaru.DiscImages
byte[] lzmaProperties = null; byte[] lzmaProperties = null;
if(nocompress) if(!compress)
{ {
prefixBlock.compression = CompressionType.None; prefixBlock.compression = CompressionType.None;
prefixBlock.cmpCrc64 = prefixBlock.crc64; prefixBlock.cmpCrc64 = prefixBlock.crc64;
@@ -2479,7 +2479,7 @@ namespace Aaru.DiscImages
sectorSize = 288 sectorSize = 288
}; };
if(nocompress) if(!compress)
{ {
prefixBlock.compression = CompressionType.None; prefixBlock.compression = CompressionType.None;
prefixBlock.cmpCrc64 = prefixBlock.crc64; prefixBlock.cmpCrc64 = prefixBlock.crc64;
@@ -2699,7 +2699,7 @@ namespace Aaru.DiscImages
lzmaProperties = null; lzmaProperties = null;
if(nocompress) if(!compress)
{ {
prefixBlock.compression = CompressionType.None; prefixBlock.compression = CompressionType.None;
prefixBlock.cmpCrc64 = prefixBlock.crc64; prefixBlock.cmpCrc64 = prefixBlock.crc64;
@@ -2766,7 +2766,7 @@ namespace Aaru.DiscImages
lzmaProperties = null; lzmaProperties = null;
if(nocompress) if(!compress)
{ {
suffixBlock.compression = CompressionType.None; suffixBlock.compression = CompressionType.None;
suffixBlock.cmpCrc64 = suffixBlock.crc64; suffixBlock.cmpCrc64 = suffixBlock.crc64;
@@ -2836,7 +2836,7 @@ namespace Aaru.DiscImages
byte[] lzmaProperties = null; byte[] lzmaProperties = null;
if(nocompress) if(!compress)
{ {
subheaderBlock.compression = CompressionType.None; subheaderBlock.compression = CompressionType.None;
subheaderBlock.cmpCrc64 = subheaderBlock.crc64; subheaderBlock.cmpCrc64 = subheaderBlock.crc64;
@@ -2906,7 +2906,7 @@ namespace Aaru.DiscImages
byte[] lzmaProperties = null; byte[] lzmaProperties = null;
if(nocompress) if(!compress)
{ {
subchannelBlock.compression = CompressionType.None; subchannelBlock.compression = CompressionType.None;
subchannelBlock.cmpCrc64 = subchannelBlock.crc64; subchannelBlock.cmpCrc64 = subchannelBlock.crc64;
@@ -3090,7 +3090,7 @@ namespace Aaru.DiscImages
byte[] lzmaProperties = null; byte[] lzmaProperties = null;
if(nocompress) if(!compress)
{ {
subchannelBlock.compression = CompressionType.None; subchannelBlock.compression = CompressionType.None;
subchannelBlock.cmpCrc64 = subchannelBlock.crc64; subchannelBlock.cmpCrc64 = subchannelBlock.crc64;