+/* Information about the available compression types for the WIM format. */
+static const struct {
+ const tchar *name;
+ u32 min_chunk_size;
+ u32 max_chunk_size;
+ u32 default_nonsolid_chunk_size;
+ u32 default_solid_chunk_size;
+} wim_ctype_info[] = {
+ [WIMLIB_COMPRESSION_TYPE_NONE] = {
+ .name = T("None"),
+ .min_chunk_size = 0,
+ .max_chunk_size = 0,
+ .default_nonsolid_chunk_size = 0,
+ .default_solid_chunk_size = 0,
+ },
+ [WIMLIB_COMPRESSION_TYPE_XPRESS] = {
+ .name = T("XPRESS"),
+ .min_chunk_size = 4096,
+ .max_chunk_size = 65536,
+ .default_nonsolid_chunk_size = 32768,
+ .default_solid_chunk_size = 32768,
+ },
+ [WIMLIB_COMPRESSION_TYPE_LZX] = {
+ .name = T("LZX"),
+ .min_chunk_size = 32768,
+ .max_chunk_size = 2097152,
+ .default_nonsolid_chunk_size = 32768,
+ .default_solid_chunk_size = 32768,
+ },
+ [WIMLIB_COMPRESSION_TYPE_LZMS] = {
+ .name = T("LZMS"),
+ .min_chunk_size = 32768,
+ .max_chunk_size = 1073741824,
+ .default_nonsolid_chunk_size = 131072,
+ .default_solid_chunk_size = 67108864,
+ },
+};
+
+/* Is the specified compression type valid? */
+static bool
+wim_compression_type_valid(enum wimlib_compression_type ctype)
+{
+ return (unsigned)ctype < ARRAY_LEN(wim_ctype_info) &&
+ wim_ctype_info[(unsigned)ctype].name != NULL;
+}
+
+/* Is the specified chunk size valid for the compression type? */
+static bool
+wim_chunk_size_valid(u32 chunk_size, enum wimlib_compression_type ctype)
+{
+ if (!(chunk_size == 0 || is_power_of_2(chunk_size)))
+ return false;
+
+ return chunk_size >= wim_ctype_info[(unsigned)ctype].min_chunk_size &&
+ chunk_size <= wim_ctype_info[(unsigned)ctype].max_chunk_size;
+}
+
+/* Return the default chunk size to use for the specified compression type in
+ * non-solid resources. */
+static u32
+wim_default_nonsolid_chunk_size(enum wimlib_compression_type ctype)
+{
+ return wim_ctype_info[(unsigned)ctype].default_nonsolid_chunk_size;
+}
+
+/* Return the default chunk size to use for the specified compression type in
+ * solid resources. */
+static u32
+wim_default_solid_chunk_size(enum wimlib_compression_type ctype)
+{
+ return wim_ctype_info[(unsigned)ctype].default_solid_chunk_size;
+}
+
+/* Return the default compression type to use in solid resources. */
+static enum wimlib_compression_type
+wim_default_solid_compression_type(void)
+{
+ return WIMLIB_COMPRESSION_TYPE_LZMS;
+}