Skip to content

+ derived specification of what differs between the xBRZ releases - #22

Merged
Hawkynt merged 2 commits into
mainfrom
feat/xbrz-versions
Sep 21, 2026
Merged

Hawkynt merged 2 commits into
mainfrom
feat/xbrz-versions

Conversation

@Hawkynt

@Hawkynt Hawkynt commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Groundwork for Hawkynt/2dimagefilter#30 ("xBRz implementation out of date"). No behaviour change — this adds the derived material the implementation will be produced from.

Why a document and not a patch

xBRZ is GPL-3.0 and this library ships LGPL-3.0-or-later, so it sits on rung 2 of the re-use ladder: read the source to build a specification, a set of test cases and an oracle, then implement from that material. Not copy it, not transliterate it. This is that material. It contains none of Zenju's code — only a description of behaviour, with provenance recorded.

What reading the releases actually showed

The issue says the implementation is out of date. It is, but far less than it looks, and not where I first thought. Three suspected gaps, two of which are not gaps:

Suspected Verdict
Missing centerDirectionBias (1.7) not a gap — 1.7 only turned a hard-coded 4 into a config field defaulting to 4. Xbrz.cs already uses 4 for that term.
Asymmetric colour distance (1.7) not a gap — it came from packing channel differences into a byte-indexed lookup table (+46 unpacked as 45, -46 as -47). This port calls a colour metric directly and never had it.
ARGB outside-area transparent (1.8) not needed — OutOfBoundsMode already exposes that per axis, configurably. A 1.8 variant would duplicate an existing knob.

So the existing xBRZ entry is 1.7-equivalent and should keep its name — no version suffix, so existing scripts and saved settings keep working.

What is genuinely missing: 1.9

Two exact, integer changes, both real here:

  1. Steep direction threshold 2.2 → 2.4. Encoded as x * 22 <= y * 10; 1.9 is * 24. Ten sites — the shallow and steep test in each of the five scale kernels.
  2. Weighted blends round to nearest instead of truncating. ColorLerpInt does (a.C1 * w1 + b.C1 * w2) / total, which truncates, matching pre-1.9.

Both re-verified against this branch's base after rebasing onto current main.

Open design question, deliberately not decided here

ILerp is chosen by the pipeline, not by the scaler, so a 1.9 variant cannot simply select a rounding lerp. Either a rounding counterpart to Color3BLerpInt/Color4BLerpInt that the 1.9 path picks, or rounding inside the xBRZ kernels. The first is more correct, the second less invasive to an interface used well beyond xBRZ. Noted in the document rather than settled unilaterally.

Verification

2dimagefilter builds and its 665 tests pass against this branch, so nothing here disturbs the consumer.

Rung 2 of the re-use ladder: xBRZ is GPL-3.0 and this library ships LGPL, so
the releases were read to build material rather than copied. This is that
material - a description of the behaviour, written so an implementation can be
produced from it and checked, containing none of Zenju's code.

Two of the three suspected gaps turned out not to be gaps at all.

"Center direction bias", added in 1.7, only made a hard-coded factor of 4 into
a configuration field whose default is also 4; this implementation already uses
4 for that term. The asymmetric colour distance fixed in 1.7 came from packing
channel differences into a byte-indexed lookup table, which this implementation
never used - it calls a colour metric directly, so distance was always
symmetric. The existing entry is therefore 1.7-equivalent and needs no version
suffix.

1.8 makes the area outside an ARGB image transparent. That decision is already
exposed here per axis as OutOfBoundsMode, so a 1.8 variant would duplicate an
existing knob.

That leaves 1.9, which differs twice over: the steep direction threshold moves
from 2.2 to 2.4, and the weighted blend rounds to nearest where it used to
truncate. ColorLerpInt truncates today, so both are real.
@Hawkynt
Hawkynt merged commit fa2ad74 into main Sep 21, 2026
9 checks passed
@Hawkynt
Hawkynt deleted the feat/xbrz-versions branch September 21, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant