| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.IO.Compression |
| | | 5 | | { |
| | | 6 | | /// <summary>Provides compression options to be used with Zstandard compression.</summary> |
| | | 7 | | [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] |
| | | 8 | | [System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] |
| | | 9 | | public sealed class ZstandardCompressionOptions |
| | | 10 | | { |
| | | 11 | | /// <summary>Gets the default compression quality level.</summary> |
| | 0 | 12 | | public static int DefaultQuality => ZstandardUtils.Quality_Default; |
| | | 13 | | |
| | | 14 | | /// <summary>Gets the minimum compression quality level.</summary> |
| | 0 | 15 | | public static int MinQuality => ZstandardUtils.Quality_Min; |
| | | 16 | | |
| | | 17 | | /// <summary>Gets the maximum compression quality level.</summary> |
| | 0 | 18 | | public static int MaxQuality => ZstandardUtils.Quality_Max; |
| | | 19 | | |
| | | 20 | | /// <summary>Gets the default base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | 0 | 21 | | public static int DefaultWindowLog2 => ZstandardUtils.WindowLog_Default; |
| | | 22 | | |
| | | 23 | | /// <summary>Gets the minimum base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | 0 | 24 | | public static int MinWindowLog2 => ZstandardUtils.WindowLog_Min; |
| | | 25 | | |
| | | 26 | | /// <summary>Gets the maximum base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | 0 | 27 | | public static int MaxWindowLog2 => ZstandardUtils.WindowLog_Max; |
| | | 28 | | |
| | | 29 | | /// <summary>Gets the minimum base-2 logarithm of the hash table size to use for Zstandard compression.</summary |
| | 0 | 30 | | public static int MinHashLog2 => ZstandardUtils.HashLog_Min; |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the maximum base-2 logarithm of the hash table size to use for Zstandard compression.</summary |
| | 0 | 33 | | public static int MaxHashLog2 => ZstandardUtils.HashLog_Max; |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the minimum base-2 logarithm of the chain table size to use for Zstandard compression.</summar |
| | 0 | 36 | | public static int MinChainLog2 => ZstandardUtils.ChainLog_Min; |
| | | 37 | | |
| | | 38 | | /// <summary>Gets the maximum base-2 logarithm of the chain table size to use for Zstandard compression.</summar |
| | 0 | 39 | | public static int MaxChainLog2 => ZstandardUtils.ChainLog_Max; |
| | | 40 | | |
| | | 41 | | /// <summary>Initializes a new instance of the <see cref="ZstandardCompressionOptions"/> class.</summary> |
| | 0 | 42 | | public ZstandardCompressionOptions() |
| | 0 | 43 | | { |
| | 0 | 44 | | } |
| | | 45 | | |
| | | 46 | | /// <summary>Gets or sets the compression quality to use for Zstandard compression.</summary> |
| | | 47 | | /// <value>The compression quality. The valid range is from <see cref="MinQuality"/> to <see cref="MaxQuality"/> |
| | | 48 | | /// <remarks> |
| | | 49 | | /// The compression quality determines the compression ratio and speed. |
| | | 50 | | /// Negative values extend the range of speed versus ratio preferences, where lower levels are faster but provid |
| | | 51 | | /// Value 0 indicates the implementation-defined default quality. |
| | | 52 | | /// Values 1-22 are normal compression levels, with <see cref="DefaultQuality"/> being the default. |
| | | 53 | | /// Values 20-22 require more memory and should be used with caution. |
| | | 54 | | /// </remarks> |
| | | 55 | | /// <exception cref="ArgumentOutOfRangeException">The value is not 0 and is not between <see cref="MinQuality"/> |
| | | 56 | | public int Quality |
| | | 57 | | { |
| | 0 | 58 | | get; |
| | | 59 | | set |
| | 0 | 60 | | { |
| | 0 | 61 | | if (value != 0) |
| | 0 | 62 | | { |
| | 0 | 63 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.Quality_Max, nameof(value)); |
| | 0 | 64 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.Quality_Min, nameof(value)); |
| | 0 | 65 | | } |
| | | 66 | | |
| | 0 | 67 | | field = value; |
| | 0 | 68 | | } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | /// <summary>Gets or sets the base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | | 72 | | /// <value>The base-2 logarithm of the window size for compression.</value> |
| | | 73 | | /// <remarks> |
| | | 74 | | /// The window size determines how much data the compressor can reference for finding matches. |
| | | 75 | | /// Larger window sizes can improve compression ratios for large files but require more memory. |
| | | 76 | | /// The valid range is from <see cref="MinWindowLog2"/> to <see cref="MaxWindowLog2"/>. |
| | | 77 | | /// Value 0 indicates the implementation-defined default window size. |
| | | 78 | | /// </remarks> |
| | | 79 | | /// <exception cref="ArgumentOutOfRangeException">The value is not 0 and is not between <see cref="MinWindowLog2 |
| | | 80 | | public int WindowLog2 |
| | | 81 | | { |
| | 0 | 82 | | get; |
| | | 83 | | set |
| | 0 | 84 | | { |
| | 0 | 85 | | if (value != 0) |
| | 0 | 86 | | { |
| | 0 | 87 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.WindowLog_Min, nameof(value)); |
| | 0 | 88 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.WindowLog_Max, nameof(value)); |
| | 0 | 89 | | } |
| | | 90 | | |
| | 0 | 91 | | field = value; |
| | 0 | 92 | | } |
| | | 93 | | } |
| | | 94 | | |
| | | 95 | | /// <summary>Gets or sets the dictionary to use for compression. If set, the quality specified during dictionary |
| | | 96 | | /// <value>The compression dictionary, or null if no dictionary is used.</value> |
| | 0 | 97 | | public ZstandardDictionary? Dictionary { get; set; } |
| | | 98 | | |
| | | 99 | | /// <summary>Gets or sets a hint for the size of the block sizes that the encoder will output. Smaller size lead |
| | | 100 | | /// <value>The target block size in bytes. Valid range is from 1340 to 131072 (2^17). A value of 0 indicates no |
| | | 101 | | public int TargetBlockSize |
| | | 102 | | { |
| | 0 | 103 | | get; |
| | | 104 | | set |
| | 0 | 105 | | { |
| | 0 | 106 | | if (value != 0) |
| | 0 | 107 | | { |
| | 0 | 108 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.TargetBlockSize_Min, nameof(value) |
| | 0 | 109 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.TargetBlockSize_Max, nameof(val |
| | 0 | 110 | | } |
| | | 111 | | |
| | 0 | 112 | | field = value; |
| | 0 | 113 | | } |
| | | 114 | | } |
| | | 115 | | |
| | | 116 | | /// <summary>Gets or sets a value indicating whether a 32-bit checksum will be appended at the end of the compre |
| | 0 | 117 | | public bool AppendChecksum { get; set; } |
| | | 118 | | |
| | | 119 | | /// <summary>Gets or sets a value indicating whether long-distance matching is enabled.</summary> |
| | | 120 | | /// <value><see langword="true"/> if long-distance matching is enabled; otherwise, <see langword="false"/>.</val |
| | | 121 | | /// <remarks>Setting this property to <see langword="true" /> might improve compression ratios for large files a |
| | 0 | 122 | | public bool EnableLongDistanceMatching { get; set; } |
| | | 123 | | |
| | | 124 | | /// <summary>Gets or sets the base-2 logarithm of the initial probe (hash) table size to use for Zstandard compr |
| | | 125 | | /// <value>The base-2 logarithm of the hash table size. The valid range is from <see cref="MinHashLog2"/> to <se |
| | | 126 | | /// <remarks> |
| | | 127 | | /// Value 0 indicates the implementation-defined default hash table size derived from <see cref="Quality"/>. |
| | | 128 | | /// </remarks> |
| | | 129 | | /// <exception cref="ArgumentOutOfRangeException">The value is not 0 and is not between <see cref="MinHashLog2"/ |
| | | 130 | | public int HashLog2 |
| | | 131 | | { |
| | 0 | 132 | | get; |
| | | 133 | | set |
| | 0 | 134 | | { |
| | 0 | 135 | | if (value != 0) |
| | 0 | 136 | | { |
| | 0 | 137 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.HashLog_Min, nameof(value)); |
| | 0 | 138 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.HashLog_Max, nameof(value)); |
| | 0 | 139 | | } |
| | | 140 | | |
| | 0 | 141 | | field = value; |
| | 0 | 142 | | } |
| | | 143 | | } |
| | | 144 | | |
| | | 145 | | /// <summary>Gets or sets the base-2 logarithm of the multi-probe search (chain) table size to use for Zstandard |
| | | 146 | | /// <value>The base-2 logarithm of the chain table size. The valid range is from <see cref="MinChainLog2"/> to < |
| | | 147 | | /// <remarks> |
| | | 148 | | /// Value 0 indicates the implementation-defined default chain table size derived from <see cref="Quality"/>. |
| | | 149 | | /// </remarks> |
| | | 150 | | /// <exception cref="ArgumentOutOfRangeException">The value is not 0 and is not between <see cref="MinChainLog2" |
| | | 151 | | public int ChainLog2 |
| | | 152 | | { |
| | 0 | 153 | | get; |
| | | 154 | | set |
| | 0 | 155 | | { |
| | 0 | 156 | | if (value != 0) |
| | 0 | 157 | | { |
| | 0 | 158 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.ChainLog_Min, nameof(value)); |
| | 0 | 159 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.ChainLog_Max, nameof(value)); |
| | 0 | 160 | | } |
| | | 161 | | |
| | 0 | 162 | | field = value; |
| | 0 | 163 | | } |
| | | 164 | | } |
| | | 165 | | } |
| | | 166 | | } |
| | | 167 | | |