forge
Explore
Log in

Don't you dare go Hollow

h264: record what coefficient-level RD quantisation measured

Browse files at this commit

cf13a824bbdba5bb831c092b50d53800ea1b7785Ahmet Kaan GümüşParent: dbbd3cc
x264's trellis is worth 0.193 dB on the film clip and 0.208 on the screen
capture, re-measured against `trellis=0` now that the mode decision has
changed. A coefficient-level walk-back, with a scan-position-aware bit
estimate and the finished macroblocks picked on exact coded bits, buys
about 0.02 of that, so it is not landed: it doubles the inter coding work
for a fiftieth of the distance.

Two results worth keeping. A superset of candidates chosen on exact local
cost measured 0.05 dB worse than a pair of them, which is local
rate-distortion being myopic about a reference picture the next nine
predict from. And the generator walks levels on an estimate rather than
against the CABAC context that will actually code them, which is where
x264's version gets its order of magnitude.
lanes/h264x264-r2.report.mdmodified+47 -0
@@ -211,3 +211,50 @@ nothing reads them any more: the twelve-bit intra signalling estimate and the
211 Rate-distortion quantisation (x264's trellis) is worth 0.20 dB on film and 0.10211 Rate-distortion quantisation (x264's trellis) is worth 0.20 dB on film and 0.10
212 on the screen capture by the ablation in this report, and we still have none.212 on the screen capture by the ablation in this report, and we still have none.
213 That is the next slice.213 That is the next slice.
214+
215+## Addendum: rate-distortion quantisation, attempted and not landed
216+
217+x264's trellis is still worth what the ablation said after the mode decision
218+changed -- re-measured, because a stale premise is the failure mode this lane
219+has already hit twice. Ours against x264 with `trellis=0` reads -0.535 dB on
220+the film clip and -0.270 on the screen capture, against -0.728 and -0.478 with
221+x264 at its default: 0.193 and 0.208 dB of real headroom.
222+
223+A coefficient-level walk-back was built and measured against it. For each inter
224+luma 4x4 block, levels are stepped toward zero from the end of the scan while
225+squared error plus lambda times bits falls; the bit estimate was made
226+scan-position aware, since a significance flag is only sent up to the last
227+non-zero level and that saving is the whole reason the technique pays. Then the
228+whole macroblock was coded once per candidate strength and the winner picked on
229+*exact* coded bits, using the trial machinery the mode decision already has.
230+
231+It buys about 0.02 dB, an order of magnitude short:
232+
233+| candidates (multiples of the zero-block lambda) | synthetic | film | screen |
234+|-------------------------------------------------|-----------|--------|--------|
235+| none (landed) | -4.523 | -0.728 | -0.478 |
236+| 0, 0.5 | -4.523 | -- | -- |
237+| 0, 1 | -4.512 | -0.728 | -0.480 |
238+| 0, 2 | -4.520 | -- | -- |
239+| 0, 1, 2, 4 | -4.563 | -- | -- |
240+| 0, 4 | -4.538 | -- | -- |
241+| 0, 8 | -4.564 | -- | -- |
242+
243+Two findings, both of which the next attempt has to answer:
244+
245+ * **A superset of candidates chosen on exact cost measured worse.** Adding 2
246+ and 4 to the candidate set can only lower the local cost of every
247+ macroblock, and it lost 0.05 dB against the pair. Local rate-distortion on
248+ a reference picture is myopic: what a blurrier block saves now, the nine
249+ pictures predicting from it pay for. Nothing in the metric sees that.
250+ * **The candidate generator is rate-blind where it matters.** The levels are
251+ walked using an estimate; exact bits only pick between finished
252+ macroblocks. x264 decides each coefficient against its actual CABAC
253+ context cost, which is why its version is worth ten times ours.
254+
255+So the machinery is not landed -- it doubles the inter coding work for 0.02 dB.
256+The next attempt should decide levels where the contexts exist, at write time,
257+which inter luma allows because its reconstruction does not feed the next
258+block's prediction the way intra's does; and it needs a term for what a
259+reference picture's quality is worth to the pictures that predict from it,
260+without which more search measures worse.