Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ To undo it, remove the entries in Windows Security → App & browser control →
| **Video**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, Video CD (DAT), TS, M2TS, 3GP, OGV, VOB, …;<br>Wisenet WAVE / Nx Witness exports (NOV) read | MP4 (H.264, HEVC, AV1), WEBM, MOV, MKV, AVI, GIF, APNG, WEBP, MP3, M4A, 720p, split into parts;<br>subtitle tracks kept (MKV, MP4, MOV, WebM);<br>subtitles (SRT, ASS, WebVTT) |
| **Audio**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR, APE, WavPack, TTA, DSD (DSF, DFF), DTS, AC3, E-AC3, …;<br>tracker modules (XM, IT, S3M) read | MP3, M4A (AAC, ALAC), M4R (iPhone ringtone), WAV, FLAC, OGG, OPUS, AAC, WavPack, TTA, W64, AC3, E-AC3 |
| **Subtitles**: SRT, ASS/SSA, WebVTT, SAMI (SMI), LRC, KRC, TTML, MicroDVD, SCC | each other as UTF-8 (Korean CP949 files read correctly) |
| **Archives**: ZIP, ANSYS Workbench (WBPZ), 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, XZ, ISO, UDF, IMG, DMG, CAB, LHA, ARJ, ALZ, EGG, Garry's Mod addon (GMA), Valve pak (VPK), files packed into a Source map (BSP), …;<br>JAR, NuGet (NUPKG), Android packages (APKS, XAPK, APKM, AAB), Adobe extensions (ZXP) read | extract, ZIP, 7Z, TAR, TAR.GZ, TAR.XZ, XZ, GMA;<br>any files → one ZIP; folders → ZIP, ISO (Joliet or UDF 2.01), GMA |
| **Archives**: ZIP, ANSYS Workbench (WBPZ), 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, TAR.ZST, GZ, XZ, ZST, ISO, UDF, IMG, DMG, CAB, LHA, ARJ, ALZ, EGG, Garry's Mod addon (GMA), Valve pak (VPK), files packed into a Source map (BSP), …;<br>JAR, NuGet (NUPKG), Android packages (APKS, XAPK, APKM, AAB), Adobe extensions (ZXP) read | extract, ZIP, 7Z, TAR, TAR.GZ, TAR.XZ, XZ, GMA;<br>any files → one ZIP; folders → ZIP, ISO (Joliet or UDF 2.01), GMA |
| **CAD**: DWG, DXF<br>Gerber PCB layers (GBR, GTL, GBL, GTO, …) read;<br>G-code of 3D printers and CNC machines (GCODE, GCO, NGC) read | PDF, SVG, PNG, DWG ↔ DXF;<br>G-code → toolpath (from above or isometric) or the slicer's preview |
| **Fonts**: TTF, OTF, WOFF, WOFF2, EOT;<br>FON (Windows bitmap fonts) read | each other;<br>FON → one font per size |
| **Data**: JSON, JSON Lines, YAML, TOML, XML<br>vCard, iCalendar | each other, CSV and XLSX (tables);<br>vCard, iCalendar ↔ CSV |
Expand Down
7 changes: 4 additions & 3 deletions docs/ENGINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Filee chooses engines automatically. Settings → *Engines* shows their status,
| **Geospatial vector data** | built in | **GeoJSON, KML, KMZ, GPX, Shapefile ↔ each other and CSV** (longitude / latitude or WKT); Garmin FIT (activities) and OpenStreetMap XML (`.osm`), both read only, → each of them and CSV; projected Shapefiles (UTM, Web Mercator, Lambert, Albers) are converted to WGS 84; through CSV to XLSX, JSON, … (see below) |
| **Filee renderer** | built in, on by default (Settings → Engines → *Use the Filee renderer*) | **HWPX, HWP, Word documents (DOCX and DOC), ODT, RTF, TXT, Markdown, HTML, e-books, CSV / TSV, OFD, UYAP (UDF), the markup languages Filee reads itself (and Pandoc's formats) → PDF** with Filee's own layout engine; **PPTX, PPTM, POTX, POTM, PPSX, PPT ([PPT reader](#ppt-reader)), ODP, OTP, FODP ([ODP / ODG reader](#odp--odg-reader)) → PDF, PNG, JPG** with its slide renderer; files with what it doesn't draw yet take the HWPX writer and rhwp (see [Filee renderer: PDF output](#filee-renderer-pdf-output) and [slides](#filee-renderer-slides)) |
| rhwp | bundled with the installer (`engines/rhwp`, with the Microsoft C++ runtime, see below) | HWP/HWPX → PDF when the Filee renderer is off or can't draw a file yet, **HWPX → HWP** (HWP → HWPX too, ranked below the built-in HWP reader) |
| Archives | built in (SharpCompress, DiscUtils, .NET and Filee's own readers and writers); 7-Zip optional (Settings → *Engines*, ~2 MB download) | **in-process**: ZIP (including ANSYS Workbench WBPZ and Adobe ZXP, and Windows app packages MSIX / APPX), Minecraft and Modrinth packs, Garry's Mod addons (GMA), Valve paks (VPK), the files packed into Source maps (BSP), 7Z (solid ones too), RAR, TAR (+ GZ/BZ2/XZ/Z/7Z/LZ), GZ, BZ2, XZ, LZMA, Z, lzip, CPIO, DEB, RPM, ISO (UDF discs too), IMG and DMG disk images, split (.001), ALZ, EGG, CAB, LHA, ARJ; **7-Zip, when installed**: the rare variants the in-process readers leave to it (see [Archives](#archives)) **→ folder, ZIP, 7Z, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, BZ2, XZ, the packs, GMA** (in-process); "Compress into one archive" for any files |
| Archives | built in (SharpCompress, DiscUtils, .NET and Filee's own readers and writers); 7-Zip optional (Settings → *Engines*, ~2 MB download) | **in-process**: ZIP (including ANSYS Workbench WBPZ and Adobe ZXP, and Windows app packages MSIX / APPX), Minecraft and Modrinth packs, Garry's Mod addons (GMA), Valve paks (VPK), the files packed into Source maps (BSP), 7Z (solid ones too), RAR, TAR (+ GZ/BZ2/XZ/Z/7Z/LZ/ZST), GZ, BZ2, XZ, LZMA, Z, ZST, lzip, CPIO, DEB, RPM, ISO (UDF discs too), IMG and DMG disk images, split (.001), ALZ, EGG, CAB, LHA, ARJ; **7-Zip, when installed**: the rare variants the in-process readers leave to it (see [Archives](#archives)) **→ folder, ZIP, 7Z, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, BZ2, XZ, the packs, GMA** (in-process); "Compress into one archive" for any files |
| LibreOffice | **optional download** (~370 MB, 1.1 GB on disk) | older and rare formats only: Word 6.0 / 95 and Works documents, PowerPoint 95 and older PPT, binary Visio (`.vsd`), and ODP / ODG with what Filee doesn't draw yet (charts, OLE objects, 3D) → PDF; XLS, PPT, RTF and OpenDocument to each other, output as DOCX/ODT/ODS, and ODP for what the [ODP writer](#odp-writer) doesn't take (OpenDocument presentations themselves, Keynote, decks with charts, effects or 3D); read-only formats (see below) → PDF and their kind's editable formats; FODT, OpenDocument templates (OTT, OTS, OTP) and XLT out; SVG → EMF/WMF/ODG, a PDF page → SVG |
| Pandoc | **optional download** (~42 MB, 240 MB on disk) | Markdown ↔ DOCX/ODT/RTF, DOCX/ODT/HTML/RTF → Markdown, HTML ↔ DOCX/ODT, markup languages (LaTeX, AsciiDoc, Typst, man; and RTF / EPUB from the built-in ones) ↔ Markdown/HTML/DOCX/ODT and each other (and → RTF, EPUB, TXT); their AST feeds the built-in PPTX writer (Pandoc's own slides only where Filee assumes a Pandoc that isn't installed) |
| Ghostscript | **optional download** (~20 MB, 31 MB on disk) | EPS/PS → PDF, PostScript-based AI → PDF (images through PDF and PDFium), EPS/PS → PNG; PDF → EPS/PS only when moved above the built-in PostScript writer; smaller PDFs when a preset asks for it; PDF/A-2b for PDF/A presets; renders CMYK PDF/AI pages for CMYK JPG/TIFF |
Expand Down Expand Up @@ -3478,11 +3478,12 @@ paths leaving the folder, bombs, entry floods) are final and never retried. Sett
| 7Z | Filee (`SevenZipReader`: Copy, LZMA, LZMA2, BCJ, BCJ2, ARM64, ARM, ARMT, PPC, SPARC, IA64, Delta, Deflate, BZip2; solid blocks decoded once, see below); other methods (PPMd, RISC-V …) by 7-Zip when it is installed, else SharpCompress, else the method is named in the "install 7-Zip" error | in-process (Filee's `SevenZipWriter`, LZMA2): UTF-16 names, times, attributes, empty folders |
| RAR 4 / 5 | SharpCompress (only unpacks, under the unRAR terms, see THIRD-PARTY-NOTICES), with the other volumes (`.part2.rar`, `.r00`) | — |
| TAR | .NET's System.Formats.Tar (ustar, PAX, GNU, V7): tells symbolic from hard links | in-process (System.Formats.Tar, PAX: UTF-8 names, times) |
| TAR.GZ, TAR.BZ2, TAR.XZ, TAR.Z, TAR.LZ, TAR.7Z | in two stages: the outer layer as below, then the TAR | TAR.GZ, TAR.BZ2 and TAR.XZ in-process |
| TAR.GZ, TAR.BZ2, TAR.XZ, TAR.Z, TAR.LZ, TAR.ZST, TAR.7Z | in two stages: the outer layer as below, then the TAR | TAR.GZ, TAR.BZ2 and TAR.XZ in-process |
| GZ | .NET's gzip decoder (CRC-32 checked) | in-process (GZipStream); one file only |
| BZ2 | SharpCompress | in-process (Filee's `Bzip2Writer`); one file only |
| XZ | Filee (`XzReader`) | in-process (Filee's `XzWriter`); one file only |
| LZMA (`.lzma`) | Filee (`LzmaRawReader`) | — |
| ZST (Zstandard, #1646) | SharpCompress through `ZstdReader`: frames one after another, skippable frames passed over; not starting with a frame is "not an archive"; windows over 128 MiB (`zstd --long=28` and up) are left to 7-Zip, as the zstd tool needs `--memory` for them | — (rule 5 of [FORMAT-RULES](FORMAT-RULES.md): a new output only developers make waits while that field is on by default) |
| Z (Unix compress) | Filee (`UnixCompressStream`: LZW, 9–16-bit codes, block mode with table clears) | — |
| LZ (lzip) | Filee: members found from the end, each LZMA stream decoded by SharpCompress, CRC-32 and sizes checked (data longer than the trailer states is refused) | — |
| CPIO | Filee (`CpioReader`: newc, crc with its byte sum checked, odc, old binary in either byte order; newc hard link groups become copies) | — |
Expand Down Expand Up @@ -3583,7 +3584,7 @@ paths leaving the folder, bombs, entry floods) are final and never retried. Sett
levels and chunk buffers over 64 MB are refused before DiscUtils reads them, and DiscUtils itself only reads through
a window with a budget per call (256 MB, plus the file being copied) and a stack check, so structures that lead in
circles end as damage instead of running on.
- **Single compressed streams** (GZ, BZ2, XZ, LZMA, Z, and the first stage of TAR.GZ, TAR.BZ2, TAR.XZ, TAR.Z) state
- **Single compressed streams** (GZ, BZ2, XZ, LZMA, Z, ZST, and the first stage of TAR.GZ, TAR.BZ2, TAR.XZ, TAR.Z, TAR.ZST) state
no size (bzip2) or one their author chose (gzip, modulo 4 GiB), so the listing can't be trusted: the in-process
decoders stop once one passes the room on the drive less a tenth of the free space (`ArchiveSafety.StreamLimit`,
"unpacks to more than …, but only … is free") and delete what was written; when 7-Zip decodes one (the fallback),
Expand Down
8 changes: 4 additions & 4 deletions src/Filee.Core/Formats/FormatFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ .. Enum.GetValues<FormatCategory>().Select(category => category.ToString().ToLow
"fodt", "fods", "fodp", "rst", "tex", "org", "adoc", "typ", "mediawiki", "dbk", "ipynb", "textile", "man",
"jsonl", "yaml", "toml", "har", "plist", "htmlz", "txtz", "chm", "dv", "mxf", "cavs", "usm", "m4s", "dav", "nov", "bik",
"h265", "h264", "ac3", "caf", "mp2", "dss", "wv", "tta", "w64", "eac3", "ape", "tak", "dsf", "dff",
"dts", "tar", "tgz", "tbz2", "txz", "tar7z", "tlz", "gz", "bz2", "xz", "lz", "lzma", "jar", "zxp", "nupkg", "apks",
"aab", "msix", "mcpack", "mcaddon", "mcworld", "mctemplate", "mrpack", "cab", "gerber",
"dts", "tar", "tgz", "tbz2", "txz", "tar7z", "tlz", "tzst", "gz", "bz2", "xz", "lz", "lzma", "zst", "jar", "zxp",
"nupkg", "apks", "aab", "msix", "mcpack", "mcaddon", "mcworld", "mctemplate", "mrpack", "cab", "gerber",
"cpio", "deb", "rpm", "dwg", "ttf", "otf", "woff", "woff2", "ass", "ssa", "ttml", "scc", "glb", "gltf",
"stl", "obj", "3mf", "ply", "fbx", "gcode", "geojson", "kml", "kmz", "gpx", "shp", "fit", "osm", "xm", "it", "ani", "vtf", "gma", "vpk", "bsp"
]),
Expand All @@ -107,8 +107,8 @@ .. Enum.GetValues<FormatCategory>().Select(category => category.ToString().ToLow
// ODF for version control, man pages, streaming segments, packages and compressed archives.
([
"ppm", "icns", "qoi", "cur", "ani", "xpm", "xbm", "pam", "pfm", "miff", "fodg", "fodt", "fods", "fodp", "man",
"jsonl", "yaml", "toml", "har", "plist", "m4s", "tar", "tgz", "tbz2", "txz", "tar7z", "tlz", "gz", "bz2", "xz",
"lz", "lzma", "jar", "zxp", "nupkg", "apks", "aab", "msix", "cab", "cpio", "deb", "rpm"
"jsonl", "yaml", "toml", "har", "plist", "m4s", "tar", "tgz", "tbz2", "txz", "tar7z", "tlz", "tzst", "gz", "bz2",
"xz", "lz", "lzma", "zst", "jar", "zxp", "nupkg", "apks", "aab", "msix", "cab", "cpio", "deb", "rpm"
], ["developer"]),
// Markup sources, papers and outlines, maintenance-doc drawings (CGM), Calibre's ebook formats.
(["cgm", "rst", "tex", "org", "adoc", "typ", "mediawiki", "dbk", "textile", "htmlz", "txtz"], ["writing"]),
Expand Down
4 changes: 4 additions & 0 deletions src/Filee.Core/Formats/FormatRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,16 @@ public static class FormatRegistry
new("tar7z", "TAR.7Z", FormatCategory.Archive, ["tar.7z"], Writable: false),
new("tlz", "TAR.LZ", FormatCategory.Archive, ["tar.lz", "tlz"], Writable: false),
new("tz", "TAR.Z", FormatCategory.Archive, ["tar.z", "tz"], Writable: false),
// Zstandard (#1646): read only. Writing would add a developer-only output, which docs/FORMAT-RULES.md rule 5
// keeps out while the developer field is on by default.
new("tzst", "TAR.ZST", FormatCategory.Archive, ["tar.zst", "tzst"], Writable: false),
new("gz", "GZ", FormatCategory.Archive, ["gz"]),
new("bz2", "BZ2", FormatCategory.Archive, ["bz2", "bz"]),
new("xz", "XZ", FormatCategory.Archive, ["xz"]),
new("lz", "LZ", FormatCategory.Archive, ["lz"], Writable: false),
new("lzma", "LZMA", FormatCategory.Archive, ["lzma"], Writable: false),
new("z", "Z", FormatCategory.Archive, ["z"], Writable: false),
new("zst", "ZST", FormatCategory.Archive, ["zst"], Writable: false),
new("jar", "JAR", FormatCategory.Archive, ["jar"], Writable: false),
// Adobe extension packages for After Effects, Premiere Pro, Photoshop … (#1382): signed ZIPs. Never a target,
// since installing one needs the signature its developer makes with Adobe's ZXPSignCmd.
Expand Down
2 changes: 1 addition & 1 deletion src/Filee.Core/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static bool IsFlipKeyAllowed(string key, IEnumerable<TriggerGesture> gest
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
public const int CurrentSchemaVersion = 103;
public const int CurrentSchemaVersion = 104;

public int SchemaVersion { get; set; } = CurrentSchemaVersion;

Expand Down
3 changes: 3 additions & 0 deletions src/Filee.Core/Settings/UserDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,9 @@ public static bool ApplyToLibrary(int from, List<Preset> presets, List<ToolbarPr
// v103: UYAP documents (.udf, #1338) learn their documents donut; custom claims stay put.
if (from < 103)
changed |= LearnExtensions(profiles, out _, ["udf"]);
// v104: Zstandard files (.zst, .tar.zst, .tzst, #1646) learn the archives donut; custom claims stay put.
if (from < 104)
changed |= LearnExtensions(profiles, out _, ["tar.zst", "tzst", "zst"]);
return changed;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Filee.Engines/Archives/ArchiveConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class ArchiveConverter : IConverter, IFileCombiner
private static readonly string[] ArchiveTargets = ["zip", "7z", "tar", "tgz", "tbz2", "txz", "gma", .. GamePacks.Formats];

/// <summary>Compressed single files (no names or folders inside); they convert among each other.</summary>
private static readonly string[] SingleFileSources = ["gz", "bz2", "xz", "lzma", "z", "lz"];
private static readonly string[] SingleFileSources = ["gz", "bz2", "xz", "lzma", "z", "lz", "zst"];

private static readonly IReadOnlyList<ConversionEdge> AllEdges = CreateEdges();

Expand Down
10 changes: 5 additions & 5 deletions src/Filee.Engines/Archives/ArchiveExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ internal sealed class ArchiveExtractor(SevenZip? sevenZip, Func<string, long>? s
public static readonly IReadOnlyList<string> BuiltInFormats =
[
"zip", "jar", "zxp", "nupkg", "apks", "aab", "msix", "7z", "rar", "tar", "tgz", "tbz2", "txz", "tar7z", "tz", "tlz",
"gz", "bz2", "xz", "lzma", "z", "lz", "cpio", "deb", "rpm", "iso", "alz", "egg", "split", "cab", "lha", "arj", "dmg",
"tzst", "gz", "bz2", "xz", "lzma", "z", "lz", "zst", "cpio", "deb", "rpm", "iso", "alz", "egg", "split", "cab", "lha", "arj", "dmg",
"img", "gma", "vpk", "bsp",
"mcpack", "mcaddon", "mcworld", "mctemplate", "mrpack",
];

/// <summary>Formats 7-Zip can read too, so it may try again after an in-process reader gave up.</summary>
private static readonly HashSet<string> SevenZipAlsoReads =
[
"zip", "jar", "zxp", "nupkg", "apks", "aab", "msix", "7z", "rar", "tar", "tgz", "tbz2", "txz", "tar7z", "tz", "gz",
"bz2", "xz", "lzma", "z", "cpio", "deb", "rpm", "iso", "split", "cab", "lha", "arj", "dmg", "img", "mcpack",
"zip", "jar", "zxp", "nupkg", "apks", "aab", "msix", "7z", "rar", "tar", "tgz", "tbz2", "txz", "tar7z", "tz", "tzst",
"gz", "bz2", "xz", "lzma", "z", "zst", "cpio", "deb", "rpm", "iso", "split", "cab", "lha", "arj", "dmg", "img", "mcpack",
"mcaddon", "mcworld", "mctemplate", "mrpack",
];

/// <summary>A TAR inside a compressed stream (or a 7z): unpacking the outer layer yields one .tar file.</summary>
private static readonly HashSet<string> TarWrapped = ["tgz", "tbz2", "txz", "tar7z", "tz", "tlz"];
private static readonly HashSet<string> TarWrapped = ["tgz", "tbz2", "txz", "tar7z", "tz", "tlz", "tzst"];

/// <summary>
/// One compressed stream, no names or sizes to check beforehand (bzip2 states no size, gzip one modulo 4 GiB that
/// its author chose).
/// </summary>
private static readonly HashSet<string> SingleStream = ["gz", "bz2", "xz", "lzma", "z", "zst", "tgz", "tbz2", "txz", "tz"];
private static readonly HashSet<string> SingleStream = ["gz", "bz2", "xz", "lzma", "z", "zst", "tgz", "tbz2", "txz", "tz", "tzst"];

/// <summary>Formats an RPM payload comes in (7-Zip shows it as one compressed CPIO file).</summary>
private static readonly HashSet<string> RpmPayload = ["cpio", "gz", "bz2", "xz", "lzma", "z", "zst"];
Expand Down
2 changes: 1 addition & 1 deletion src/Filee.Engines/Archives/Bzip2BlockEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private int MoveToFront(ReadOnlySpan<byte> bwt, ReadOnlySpan<byte> number, int i
run = 0;
}
var j = list[1..inUse].IndexOf(value) + 1;
list[..j].CopyTo(list[1..]);
Bzip2Decoder.MoveUp(list, j);
list[0] = value;
symbols[count++] = (ushort)(j + 1);
frequencies[j + 1]++;
Expand Down
32 changes: 23 additions & 9 deletions src/Filee.Engines/Archives/Bzip2Decoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

using System.Buffers;
using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;

namespace Filee.Engines.Archives;

Expand Down Expand Up @@ -299,15 +302,7 @@ private Block ReadBlock(int[] tt, int blockMax, uint? expectedCrc)
if (index >= inUseCount)
throw new InvalidDataException("invalid bzip2 symbol");
var front = mtf[index];
if (index < 16)
{
for (var k = index; k > 0; k--)
mtf[k] = mtf[k - 1];
}
else
{
mtf[..index].CopyTo(mtf[1..]);
}
MoveUp(mtf, index);
mtf[0] = front;
var b = seqToUnseq[front];
counts[b]++;
Expand Down Expand Up @@ -340,6 +335,25 @@ int NextSymbol()
}
}

/// <summary>
/// Moves the first <paramref name="count"/> bytes of the 256-byte move-to-front list one place up (count below
/// 256): 16 bytes at a time from the top while there are that many, each load taken before the store above it,
/// then byte by byte. One thread decodes the symbols of every block (the inverse transforms run on others), so
/// this step sets the pace; Bzip2BlockEncoder uses it too.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void MoveUp(Span<byte> mtf, int count)
{
if ((uint)count >= (uint)mtf.Length || mtf.Length < 256)
throw new ArgumentOutOfRangeException(nameof(count));
ref var list = ref MemoryMarshal.GetReference(mtf);
var i = count;
for (; i >= 16; i -= 16)
Vector128.LoadUnsafe(ref list, (nuint)(i - 16)).StoreUnsafe(ref list, (nuint)(i - 15));
for (; i > 0; i--)
Unsafe.Add(ref list, i) = Unsafe.Add(ref list, i - 1);
}

/// <summary>
/// Canonical Huffman decode tables as in the reference bzip2 (limit / base / perm per code length), plus a table
/// of the codes of up to <see cref="FastBits"/> bits found the same way.
Expand Down
Loading
Loading