forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 70849e07ad7e30da44cd8a7f390dc93bfb49542eFiltered to crates/ec-h264/tests/encode.rsClear filter

2026-08-27

fix(h264): key ffmpeg/x264 scratch files per call, not per processAhmet Kaan Gümüş · 3c9d243
fix(h264): key ffmpeg/x264 scratch files per call, not per process

ffmpeg_decode and x264_encode_qp named their temp files by process id
plus stream length / qp alone. Both helpers are called from several
#[test] functions that cargo test runs on parallel threads, so two
concurrent calls with the same stream length or qp shared a path -- one
call's cleanup (remove_file) could delete a file another call's ffmpeg
child was still reading. An atomic per-call sequence number now makes
every path distinct, matching the ec-av1 fix in 9b60697.

Audited every other process::id()-keyed temp path in the repo
(ec-flac, ec-opus, ec-ogg, ec-mp3, ec-vorbis, ec-alac, ec-h265,
ec-probe, ec-truehd): each is either called from a single #[test] in
its binary or discriminated by a unique literal/tag per caller, so none
of those share a path across concurrent tests.

2026-08-25

feat(h264): 8x8 transform on by defaultAhmet Kaan Gümüş · e6fcc5c
feat(h264): 8x8 transform on by default

x264 codes the 8x8 transform by default at every preset that reaches
High profile, and measured on the library clips the flag is worth
+0.716 dB BD-PSNR on a 3840x1608 film clip (18.1% of macroblocks take
the 8x8 path) and +0.183 dB on a 2560x1440 screen capture (8.8%).

With it on, the encoder's whole-picture comparison against x264 over
q22/26/30/34 moves from -0.186 dB to +0.513 dB on the film clip and
from -0.482 dB to -0.315 dB on the screen capture.

Every default stream now carries profile_idc 100 and the High-profile
SPS tail. `production_lambda_tracks_transform_mode` asked the default
config for the 4x4 lambda, so it now clears the flag itself first.
test(bd): refuse a sample window with nothing in itAhmet Kaan Gümüş · 7642b35
test(bd): refuse a sample window with nothing in it

A clip-driven BD run whose sample window is a film's black head codes to
almost no bits and decodes back to the source exactly, so every point on
both curves sits at the 99 dB PSNR cap, the two cubics coincide, and the
gate prints +0.000 dB. That is not a measurement, and it read as one: an
ablation re-measure reported the same +0.000 for both arms of the knob.

Both BD gates now refuse such a window by name and say which variable
samples past it. The h265 gate also fails with "ladder collapsed" when
its QP shift clamps two ladder points onto the same QP, instead of the
"singular BD-PSNR fit" assert deep inside the cubic solver.

2026-08-24

ec-h264: probe container by bytes, accept Matroska alongside MP4Ahmet Kaan Gümüş · d5e9b8f
ec-h264: probe container by bytes, accept Matroska alongside MP4

Factor both demux call sites in tests/encode.rs onto one helper,
open_h264_source, that reads 12 bytes from the file head and dispatches
to ec_mp4::Mp4Demuxer (ftyp at offset 4) or ec_matroska::MatroskaDemuxer
(EBML magic 1A 45 DF A3) — never by extension. A non-H.264 video track
(AV1, HEVC) is refused with a message naming the codec, not a demuxer
panic. Add ec-matroska as a dev-dependency.

BD-PSNR ours vs x264 over q22/26/30/34: -0.732 dB (FMA 01, 1280x720,
H.264-in-Matroska, 24 pictures). AV1 .mkv refusal confirmed: 'video
track is Av1, not H.264 — this gate measures H.264 only'.
test(h264): report chroma per plane, and stop dropping the first x264 paramAhmet Kaan Gümüş · 8adad23
test(h264): report chroma per plane, and stop dropping the first x264 param

The gate compared two encoders on a pooled all-plane number without ever
saying which plane either one was losing. Print U and V separately per QP
for both sides; on the film clip they say our chroma trails x264 by
0.48-0.90 dB uniformly across QP while we spend more bits, which is a
prediction deficit rather than a starved one.

EC_H264_X264_PARAMS was spliced in with a colon of its own, so a value
written with a leading colon produced "::subme=1" -- and ffmpeg drops the
token that follows an empty one. The parameter silently did not apply and
the sweep read as "this x264 feature is worth nothing". Trim the colons off
the value instead. Corrected attribution of x264's lead on the film clip,
as BD-PSNR-YUV: its RD mode decision is worth 0.739 dB, its trellis
quantisation 0.206, and the two are additive -- with both stripped we lead
by 0.278 dB.
feat(h264): measure all three planes, and a chroma coded_block_pattern testAhmet Kaan Gümüş · 49e08f5
feat(h264): measure all three planes, and a chroma coded_block_pattern test

The rate-quality gate measured PSNR on the luma plane alone, so any decision
that could trade chroma bits for luma bits read as a pure gain. It now also
reports an all-plane PSNR, pooled by sample count the way x264 reports it --
luma 6, each chroma plane 1 for 4:2:0 -- as BD-PSNR-YUV beside the luma number.

Chroma gets the group test luma already has: cbp_chroma is 0, 1 (DC) or 2 (DC
and AC), so one surviving AC block takes the pattern to 2 and makes the other
seven each spend a coded_block_flag saying they are empty. The eight AC blocks
are pooled, coding them is compared against zeroing them all, and the pattern
step is charged CBP_CHROMA_BIT.

Swept at 0, 4, 8, 16, 32 and 64 bits the charge reads -0.688/-0.681/-0.659/
-0.653/-0.670/-0.742 dB all-plane BD on a 3840x1608 film clip and -0.537/
-0.527/-0.530/-0.517/-0.524/-0.522 on a 2560x1440 screen capture; both turn
over at sixteen. Read on luma alone the same sweep climbs monotonically to
+0.079 dB at 64, which is the encoder buying luma by throwing chroma away.

On the all-plane number the gap to x264 is -0.65 dB on the film clip against
-0.18 luma, and -0.52 against -0.23 on the screen capture: chroma is the larger
half of what is left, and nothing in this lane had been able to see it.
feat(h264): decide the coded_block_pattern group by rate-distortionAhmet Kaan Gümüş · 835b128
feat(h264): decide the coded_block_pattern group by rate-distortion

Our residual luma still ran 10 to 17 per cent over x264's at a PSNR
above x264's: blocks coded that x264 declines to code. The per-block
zero test decides one block at a time, so a block surviving alone in its
8x8 group drags a coded_block_pattern bit behind it uncounted.

x264 settles that with `decimate`, a count of how tightly the levels
cluster at the front of the scan. Ported exactly, its optimum runs
monotonically opposite on the two real clips -- camera grain wants it
off, screen capture wants it harder than x264 sets it -- so it is a
heuristic standing in for a test the encoder can run. Run the test
instead: code the group only when its blocks buy more squared error than
their levels plus the pattern bit are worth.

That test needs the rate to be right. On the per-block estimate it
reproduced the same content split; against CABAC's own cost for the same
levels -- already in the encoder for RDOQ, in 256ths of a bit -- screen
capture develops an interior optimum it never had. Both lambda and the
pattern charge are swept, tables in their doc comments.

BD-PSNR against x264 at matched features, consecutive pictures, at the
balanced preset: 3840x1608 film -0.329 -> -0.321 dB, 2560x1440 screen
capture -0.310 -> -0.252 dB.

The same test on the 8x8 transform path is worth nothing across its
sweep and is not kept; the negative result is recorded where the
constant lives. The transform_8x8 flag gate pins the delta between two
arms and drops from 0.255 to 0.230 dB because the flag-off arm is the
path that improved -- the absolute synthetic comparison against x264
moves from -4.060 to -3.969 dB -- so it is re-pinned with that written
beside it.

2026-08-23

feat(h264): code P_8x8, and count shapes as well as bitsAhmet Kaan Gümüş · 2b1c4a3
feat(h264): code P_8x8, and count shapes as well as bits

The encoder had no partition smaller than 8x16. It now codes P_8x8 with
four P_L0_8x8 sub-partitions, including the sub_mb_type writer both
entropy coders were missing.

The first measurement of it read flat, as had the split-gate sweep before
it, and a shape histogram said why: the partition search runs only at
Preset::Balanced, and the x264 comparison runs Preset::Fast by default,
so 1,200,000 macroblocks were coded whole and nothing was ever split.
Measured where the shapes are searched, P_8x8 is worth 0.005 dB BD-PSNR
on the film clip and 0.016 on the screen capture, with the optimum at
twelve bits of signalling on both.

The bit-exactness sweeps ran the default preset too, so no sub_mb_type
had ever faced another decoder: balanced_partitions_decode_bit_exactly
encodes at Balanced under CABAC and CAVLC, requires ffmpeg to reproduce
the reconstruction sample for sample, and requires every shape to appear.
The decoder now reports MbShapes alongside BitAccount, which puts our
partition mix next to x264's: we still split about half as often.
feat(h264): count CABAC bits by syntax class in the decoderAhmet Kaan Gümüş · 0723a49
feat(h264): count CABAC bits by syntax class in the decoder

The rate gate says how much we overspend against x264; it cannot say on
what. BitAccount marks the arithmetic decoder's position before and after
each syntax element and attributes the difference to one of eight classes,
so any conforming stream -- ours or x264's -- is measured by one
instrument. bit_account_vs_x264 encodes both, decodes both, prints the
table.

The answer is the same on all three sources: we spend fewer bits than
x264 on skip, mb_type and mvd, and more on residual luma, cbp+qp and
intra modes. x264 buys a cheaper residual by paying more for the motion
field. That points the next lane at prediction, not at entropy coding.
h264: choose inter luma levels against the CABAC coder's own priceAhmet Kaan Gümüş · 47083d3
h264: choose inter luma levels against the CABAC coder's own price

Rate-distortion quantisation for inter luma 4x4: each level is offered the
cheaper magnitudes below it, and takes one when the squared error it gives up
costs less than the bits it saves.

The rate is exact. `CabacEnc::residual_block_cost` runs the same bins
`residual_block` writes -- one body behind a `BinSink` the writer and the
price share -- against a copy of the context state, charging each bin -log2(p)
for its state and moving the state as the coder would. Over 400 random blocks
it predicts 2649288/256 bits where the coder then spends 2650112/256, an error
of 0.03%, which is asserted rather than assumed: a wrong price is invisible in
the stream and shows up only as lost dB.

An exact rate on its own was worth almost nothing (film -0.728 -> -0.732,
screen capture -0.500 -> -0.449). The half that pays is the dead zone: a search
that can only walk levels down cannot see a level the quantiser's 1/6 dead
zone already threw away, so it was choosing among the survivors of the decision
it was meant to replace. Quantising the searched path at 1/2 and letting the
search take the levels back down is worth 0.102 dB on the film clip and 0.301
on the synthetic gate. Deciding the whole-block zero on exact bits too adds
0.142 dB there.

BD-PSNR against x264 at matched features: film 3840x1608 -0.728 -> -0.628,
screen capture 2560x1440 -0.500 -> -0.471, synthetic -4.523 -> -4.073, the
floor moved to -4.15. Bounding the search to levels of 2 or less keeps it free
(synthetic run 1.08 s before, 1.09 s after; unbounded it was 3.53 s).

Intra stays out: its reconstruction is what the next block in the macroblock
predicts from. Inter chroma AC and the 8x8 path are not covered yet.
h264: decide intra against inter on real coded costAhmet Kaan Gümüş · dbbd3cc
h264: decide intra against inter on real coded cost

The comparison was a prediction-domain SATD, discounted by a fixed 3/4 for
the Intra_4x4 that usually follows, against a coded inter cost, with the
intra side's signalling paid for by a guessed twelve bits. Both branches
are now coded for real and the one with the smaller squared error plus
lambda times its actual bits is kept -- the decision x264 makes from subme
6 up, and the mode half of the 0.83 dB the ablation in the lane report put
behind its refinement.

BD-PSNR against x264 at GOP 10 over QP 22/26/30/34: the film clip goes
-1.043 to -0.728, the screen capture -1.064 to -0.500, and the bit premium
falls with the distance rather than being traded for it (the screen capture
spends +17.2% over x264 at QP 22 where it spent +34.4%). The synthetic clip
loses 0.074 dB; it prefers a heavier rate term in that decision, which the
two real clips do not, so the standard multiplier goes in unscaled and its
floor moves -4.5 to -4.6.

Each P macroblock is coded twice and the loser's reconstruction and entropy
writer are thrown away: one measurement run went 28.8 s to 30.8 s wall.
Intra_4x4 in P pictures was re-swept under the new decision and stays on
everywhere; the two constants of the old decision are deleted rather than
re-swept, because nothing reads them any more.
perf(h264): iterate sub-sample refinement to convergence at every presetAhmet Kaan Gümüş · f7bce7d
perf(h264): iterate sub-sample refinement to convergence at every preset

The refinement stopped after a single pass at Fast. Running it to convergence
is worth 0.111 dB BD-PSNR against x264 on the film clip and 0.035 on the screen
capture, for 2% of the comparison's wall clock; the synthetic floor tightens to
-4.5.

Attribution of what is left, measured by disabling x264's features one at a
time: its whole-sample search pattern is worth 0.04 dB, its rate-distortion
quantisation 0.20, and its sub-sample and mode refinement 0.83 -- so the
rate-distortion mode decision is where the remaining distance is.
fix(h264): measure the encoder on consecutive pictures, and pay for going intraAhmet Kaan Gümüş · ba061b6
fix(h264): measure the encoder on consecutive pictures, and pay for going intra

The real-clip comparison against x264 sampled one picture a second, so P
pictures had nothing to predict from and the P path was never really under
test: on a film clip our P slices ran 93.2% intra, 6.3% skip, 0.5% coded inter.
The sampler now takes consecutive pictures, with EC_H264_CLIP_STRIDE to restore
a wider spacing and EC_H264_CLIP_SKIP to pass over a film's titles first.

Corrected, the encoder read -1.521 dB BD-PSNR on film and -1.904 on screen
capture, spending 20-42% more bits than x264 with the premium growing with QP.
Two defects the old sampler had hidden:

- The intra side of the mode decision carried no rate term at all, while the
  inter side paid for its motion vector. Twelve bits for the macroblock type
  and the prediction modes is the overlap of the two contents' flat parts; a
  previous sweep of this same constant landed zero on the uncorrelated content.
- Sub-sample refinement chose on SAD, which reads interpolation's smoothing as
  a better match. It now costs candidates on SATD.

Together: film -1.521 -> -1.154 dB, screen capture -1.904 -> -0.696, synthetic
-5.718 -> -4.542, and the bit premium is flat in QP again (+14-18%) instead of
growing to +42%. The synthetic floor tightens to -4.6.

The other P-path constants swept under the old sampler were re-swept and all
held: Intra_4x4 in P pictures, the P_Skip rebate, and the Intra_4x4 discount.
perf(h264): stop penalising intra macroblocks in P picturesAhmet Kaan Gümüş · 942a61a
perf(h264): stop penalising intra macroblocks in P pictures

The intra-versus-inter comparison added an eight-bit penalty to the
intra side, on the theory that an intra macroblock in a P picture also
costs the next picture's prediction quality. Measured, it costs the
opposite -- the intra macroblocks it suppressed were stopping drift from
accumulating across the GOP.

BD-PSNR against x264 -preset medium at GOP 10:

  3840x1608 film             -1.404 -> -0.233 dB
  2560x1440 screen capture   -0.033 -> +0.068 dB

and it is not a rate-quality trade: at every one of QP 22/26/30/34 the
unpenalised encoder is both smaller and 0.15-1.2 dB better on the film
clip. Penalties of 1, 2, 4 and 8 bits all measured worse and negative
ones measured the same, so zero is the flat part of the curve rather
than a tuned value.

The synthetic gate clip disagrees: it spends 5% more bits for the same
quality, because smooth ramps are what inter prediction is best at and
any intra macroblock there is waste, so the floor moves -5.40 -> -5.75.
The two contents disagreeing in sign is the signal that this decision
belongs on real coded cost rather than on a SATD comparison -- that is
the next slice, and the floor comment says so. Full ec-h264 suite green.
perf(h264): re-cost the Intra_4x4 mode survivors with real quantisationAhmet Kaan Gümüş · 8cda34e
perf(h264): re-cost the Intra_4x4 mode survivors with real quantisation

Ablating the reference showed x264's rate-distortion mode decision is
worth 0.80 dB intra of its lead, so the mode decision is where the
distance is. This does the first half of it: SATD still ranks the nine
Intra_4x4 modes, but the top three are re-costed by actually quantising
and reconstructing the block and charging reconstruction SSD plus coded
bits. A mode that predicts slightly worse can quantise to far fewer
levels, and SATD cannot see that.

Measured with bd_psnr_vs_x264 against x264 -preset medium:

  clip                        all-intra          GOP 10
  3840x1608 film              -0.749 -> -0.620   -1.557 -> -1.495
  2560x1440 screen capture    -0.225 -> -0.137   +0.173 -> +0.216

for 3-4% encode time. Three survivors is where it saturates: all nine
landed within 0.002 dB of three for 7% more time.

The rate term needs the same ZERO_BLOCK_LAMBDA correction the zero-block
test uses -- block_bits counts CAVLC-ish widths, and with the full term
the search loses 0.065 dB instead of gaining, and loses more the more
candidates it sees.

The synthetic clip pays 0.157 dB for this (-5.140 -> -5.297) and the floor
moves to -5.40. Its smooth ramps quantise unlike anything in a real frame;
all four measurements on real content gain. Full ec-h264 suite green.
test(h264): attribute x264's lead to its mode decision, not trellisAhmet Kaan Gümüş · b36a1af
test(h264): attribute x264's lead to its mode decision, not trellis

EC_H264_X264_PARAMS appends to the parameter list the gate hands libx264,
so a single reference feature can be switched off and the distance
re-measured. On the 3840x1608 clip:

  x264 configuration            GOP 10     all-intra
  -preset medium (the gate's)   -1.557 dB  -0.749 dB
  trellis=0                     -1.456 dB  -0.587 dB
  trellis=2                     -1.642 dB  -0.811 dB
  trellis=0:subme=1:me=dia      -0.873 dB  +0.216 dB

Trellis is worth 0.10 dB inter and 0.16 dB intra, so RDOQ is not the lever
it looked like. x264's rate-distortion mode decision is worth 0.80 dB intra
and a further 0.58 dB inter -- with it off we are ahead of x264 all-intra.

We pick macroblock and prediction modes on SATD plus an estimated rate;
x264 picks the survivors on true coded bits against reconstruction SSD.
That is where the remaining 1.4 dB is.
perf(h264): try Intra_4x4 in P pictures at every presetAhmet Kaan Gümüş · f0a6733
perf(h264): try Intra_4x4 in P pictures at every preset

The BD-PSNR gate against x264 put us 2.992 dB behind on a 3840x1608 clip
from the library at Preset::Fast, and 1.587 dB behind at Preset::Balanced.
Ablating the four places the two presets differ shows the whole difference
sits in one of them: allowing Intra_4x4 in P pictures reads -1.557 dB on
its own, while a 48-sample search range (-3.039 dB), the half-macroblock
partitions (-3.009 dB) and the subpel refinement (-3.035 dB) each land
inside the noise of the -2.992 dB baseline.

So Intra_4x4 is now tried in P pictures at every preset. The cost is about
5% encode time (21.75 s against 20.67 s for the 24-picture measurement),
which is what a 1.4 dB rate-quality move is worth. Against x264 on that
clip we now spend 5-10% more bits instead of 19%, at 0.3-1.3 dB lower
PSNR instead of 1.0-1.7 dB.

The synthetic floor moves with the default: -5.202 dB to -5.140 dB, and
the constant is retightened to -5.25. No test in the repo pins encoder
bytes, so nothing else re-pins.
test(h264): gate on content prediction can win, not on noiseAhmet Kaan Gümüş · 5370748
test(h264): gate on content prediction can win, not on noise

The default clip for `bd_psnr_vs_x264` was `Clip::render`, whose
per-sample noise field is incompressible. On it x264 reads as 2x
cheaper mostly by throwing residual away -- at QP 30 it spends 224k
bits to our 672k and lands 0.5 dB *below* us -- so the BD-PSNR there
measured how willing each encoder is to abandon noise, not how well
either predicts. The tell: our `Preset::Balanced` scored worse
(-3.861 dB) than `Preset::Fast` (-2.640 dB) on that clip while scoring
much better on real content.

`Clip::render_smooth` replaces it for this test: gradients, a
sinusoidal texture band and a box translating by sub-sample amounts,
no noise. Its signature now matches the library clip's -- we spend
34-48% more bits and land 0.6-2.1 dB lower at the same quantiser --
and the floor moves to -5.40 dB from a -5.202 dB measurement. The
other tests keep `render`, which is the right source for them.

`EC_H264_PRESET_BALANCED` joins `EC_H264_GOP` as a diagnostic knob:
on the 3840x1608 library clip Balanced is -1.587 dB against Fast's
-2.992 dB for 40% more encode time, so over a dB of the P-picture
distance is search effort our default preset declines to spend.
fix(h264/test): match x264's quantiser, and split the gap intra vs interAhmet Kaan Gümüş · cd63f57
fix(h264/test): match x264's quantiser, and split the gap intra vs inter

The gate as committed asked x264 for a constant QP and did not get one:
x264's CQP mode scales the I-picture quantiser by `ipratio` (1.4 by
default), so its I pictures were coded finer than the QP under test.
That flattered x264 on the intra side and made the whole comparison a
different-quantiser comparison. `ipratio=1.0:pbratio=1.0:qcomp=1.0:
chroma-qp-offset=0` pins it; the synthetic BD-PSNR moves from -2.442 dB
to -2.640 dB, and the floor with it.

With the quantiser actually matched, `EC_H264_GOP` splits the distance.
On the 3840x1608 clip from the library:

    GOP 10 : -2.992 dB, ours +19% bits at 1.1-1.7 dB lower PSNR
    GOP  1 : -0.749 dB, ours +2-4% bits at 0.4-0.8 dB lower PSNR

So the intra path is close and roughly two thirds of the distance is in
P pictures: our inter path searches 16x16 only at `Preset::Fast`
(halves at Balanced, never 8x8 sub-partitions) with no rate-distortion
subpel refinement, and a worse prediction costs both bits and PSNR at
the same quantiser. That is the next lane's target, now measured
instead of assumed.

Ours is also read off ffmpeg's decode of our own stream rather than off
the encoder's reconstruction, matching how x264 is read; the two are
asserted equal within 0.05 dB.
test(h264): BD-PSNR gate against x264, the encoder's first referenceAhmet Kaan Gümüş · 5e93348
test(h264): BD-PSNR gate against x264, the encoder's first reference

The repo could measure the H.264 decoder against ffmpeg, the FLAC and
ALAC encoders against their references, and the audio encoders against
libopus/libvorbis, but the H.264 encoder only against itself: the
`transform_8x8` BD-PSNR test compares flag-on to flag-off, not us to
anyone. `bd_psnr_vs_x264` supplies the missing anchor.

Both curves are (bits, luma PSNR against the same source pictures) over
QP 22/26/30/34, and both are measured on decoder output rather than on
an encoder's own reconstruction, so the two halves are read the same
way; ours additionally asserts that its reconstruction and its decoded
stream agree within 0.05 dB, which turns a silent drift between the
encoder and the decoder into a failure here.

x264 is matched to what our encoder actually codes -- Main profile
(CABAC, no 8x8 transform), one reference, no B pictures, the same GOP
-- with adaptive quantisation, psy and scenecut off so both spend bits
by the same rule. Effort is each encoder's own default: our
`Preset::Fast` against x264's `-preset medium`.

First measurements: -2.442 dB on the synthetic clip (352x288, 24
pictures) and -2.961 dB on a 3840x1608 clip from the library, where we
spend 14-19% more bits and land 1-2 dB lower at the same QP. The
synthetic number becomes the floor at -2.60 dB so the distance can only
shrink; a clip named by EC_H264_CLIP prints but does not gate, its
content not being pinned. The test runs by default rather than behind
`#[ignore]`, because an invisible test rots.

The picture-extraction half of `real_clip_t8x8_bd_psnr` moves out to
`clip_sources` and is shared, unchanged in behaviour.
test(h264rd/r2): real-clip BD-PSNR harness for transform_8x8Ahmet Kaan Gümüş · 04d77cb
test(h264rd/r2): real-clip BD-PSNR harness for transform_8x8

One #[ignore]d test in the existing encode.rs binary: EC_H264_CLIP names
a file, ec-mp4 + the crate decoder yield the first 30 pictures 1 s apart,
and a q22/26/30/34 sweep (gop 10, CABAC, full size) prints the flag-on vs
flag-off BD-PSNR and 8x8 MB share. Asserts nothing: the number gates the
lane, not the suite.

Baselines on the two lane clips (post-3165e8c pricing):
  natural 720p film  BD +0.796 dB, 8x8 share 13.5%
  obs 1440p capture  BD -0.007 dB, 8x8 share 1.9%

2026-08-21

2026-08-20

feat(h264-enc): honest 8x8 rate term, dead-zone 8x8 quantiser, 8x8 gain testAhmet Kaan Gümüş · b397db5
feat(h264-enc): honest 8x8 rate term, dead-zone 8x8 quantiser, 8x8 gain test

The 8x8 quantiser now rounds with the same 1/3 (intra) / 1/6 (inter)
dead zone as the 4x4 one, and the mode decision charges a level's
position in a 64-coefficient significance map: without it Intra_8x8 was
picked on 28 macroblocks that cost 44 real bits more each. The gain test
codes curved shading, a 20-sample texture and glyph rows at qp 26: +0.30
dB at equal bits, 7.4% of macroblocks 8x8 (100 intra, 123 inter). The
conformance gates assert 8x8 macroblocks of both kinds across their
sweeps, and the VA-API decode runs with the flag on.
feat(h264-enc): Intra_8x8 prediction and the 8x8 transform for inter residuals, chosen on rate-distortion costAhmet Kaan Gümüş · 4e4673b
feat(h264-enc): Intra_8x8 prediction and the 8x8 transform for inter residuals, chosen on rate-distortion cost

transform_size_8x8_flag now follows a real decision: Intra_8x8 is coded
alongside Intra_4x4 and Intra_16x16 (decoder's filtered reference samples
and neighbour-mode rule), P macroblocks try both transform sizes on the
same prediction, and the residual writer takes the cat-5 / interleaved
path. Encoder::transform_8x8_mbs() counts what was chosen; the
reconstruction, ffmpeg and VA-API gates run with 8x8 macroblocks present.
feat(h264-enc): transform_size_8x8_flag emission + cat-5 / interleaved-CAVLC 8x8 residual writers (E3)Ahmet Kaan Gümüş · 655dfcc
feat(h264-enc): transform_size_8x8_flag emission + cat-5 / interleaved-CAVLC 8x8 residual writers (E3)

Flag written (always 0 for now) wherever the decoder reads it under
transform_8x8_mode_flag; CABAC residual_block_8x8 mirrors the decoder's
cat-5 path (no coded_block_flag for 4:2:0); CAVLC sub_block_4x4 interleave
helper. Round-trip unit tests through the decoder's own readers; encode
integration tests gain transform_8x8=true variants.

2026-08-14

test(h264): both entropy coders across the encoder sweepAhmet Kaan Gümüş · db36daa
test(h264): both entropy coders across the encoder sweep

The encoder defaults to CABAC now, so the reconstruction sweep and the ffmpeg
bit-exactness sweep both run each configuration under CAVLC as well: an
entropy coder nothing exercises is one that silently rots.
test(h264): encoder conformance against both decoders and the libraryAhmet Kaan Gümüş · 2fb37fb
test(h264): encoder conformance against both decoders and the library

Every stream the encoder writes decodes to the encoder's own reconstruction
sample for sample — in this crate's decoder, in ffmpeg and, at 60 dB, on
this machine's VA-API decoder. The sweep covers a QP ladder, both presets,
one and four threads, sizes that are not macroblock multiples, constant
bitrate, and real 1080p+ pictures demuxed by ec-mp4 and decoded by this
crate.