Skip to content

Deblock interlaced output per field; keep Deblock after Deinterlace - #146

Merged
StuartCameronCode merged 2 commits into
mainfrom
probe-deblock-order
Nov 3, 2026
Merged

StuartCameronCode merged 2 commits into
mainfrom
probe-deblock-order

Conversation

@StuartCameronCode

Copy link
Copy Markdown
Owner

A user asked whether deblocking should run before deinterlacing (advice from a Gemini chat). This measures it, and fixes the one case where the order did matter.

Report: docs/reports/2026-11-deblock-order/index.html (screenshots, scripts, CSVs). Two 720×576 TFF fixtures, MPEG-2 at 1000/1500/3000 kbps with +ildct+ilme, scored against clean references with PSNR, SSIM, VMAF and blockdetect.

Findings

  • Deinterlacing on: moving Deblock ahead of QTGMC, per field, gains ≤0.05 dB at the default strength, and blockiness is unchanged. The pipeline order stays as it is.
  • Deinterlacing off on an interlaced source: Deblock ran on the woven frame. Per field won all 14 edge-deblocker comparisons (+0.03 to +0.30 dB). DCTFilter on the woven frame was destructive: 1.5–3.7 dB below no filtering. It attenuates the alternation between fields on moving edges, which blends them.
  • Side finding: at 1000 kbps, Deblock_QED 36/44 gained about 3× what the default 24/26 does. That's not a reason to change the default without its own probe.

Change

  • {{#DEBLOCK_PER_FIELD}} in both templates: SeparateFields → deblock → DoubleWeave[::2] for every method whenever ScriptGenerator::still_interlaced_tff holds (deinterlacing off and a detected field order). The border code now uses the same check. Splitting and re-weaving is bit-exact, with frame props restored.
  • 4:2:0 at 486 lines (odd chroma field height) can't be split, so it keeps the woven-frame path.
  • Deinterlaced output is unchanged.

Tests

  • Rust test_183: all 3 methods × both field orders × encode and preview scripts, plus the progressive cases.
  • integration_filter_parameters_test: the filter call sits between the split and the weave, for every method.
  • integration_new_passes_test (heavy): encodes all 3 methods. Per-field DCTFilter moves frame 45 by 0.55 levels from the source, against 2.22 woven (the woven reference is a job with no detected field order).
  • Locally on macOS arm64: Rust suite green except test_subtitle_generation_srt_file, which needs the Whisper add-on and fails the same way on main. Flutter script tests 54/54. Heavy high-bit-depth, borders and filter-pipeline suites 262/262; the high-bit-depth suite now runs the per-field path at 8/10/12/16-bit.

Not tested: NTSC, DV, interlaced H.264, hardware-encoded MPEG-2, x86.

🤖 Generated with Claude Code

StuartCameronCode and others added 2 commits November 3, 2026 20:47
Measured on blocky interlaced MPEG-2: moving Deblock ahead of QTGMC gains
<=0.05 dB at default strength, so the order stays. With deinterlacing off,
per-field deblocking beat woven-frame deblocking in all 14 comparisons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With deinterlacing off and a detected field order, every Deblock method
ran on the woven frame, filtering vertically across both fields. For
DCTFilter that was destructive: 1.5-3.7 dB below no filtering at all,
because it attenuates the field-to-field alternation on moving edges.
The edge deblockers lost 0.03-0.30 dB against per-field.

Now SeparateFields -> deblock -> DoubleWeave[::2] (bit-exact round trip)
whenever ScriptGenerator::still_interlaced_tff says the picture is still
interlaced; the border code shares that check. A 4:2:0 frame with an odd
chroma field height keeps the woven path. Deinterlaced output is
unchanged: moving Deblock ahead of QTGMC measured <=0.05 dB.

Report updated with the DCTFilter measurements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StuartCameronCode
StuartCameronCode merged commit 2ca176c into main Nov 3, 2026
4 checks passed
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