Skip to content

SECAM VHS Method 1 IF clamp and ME-SECAM block-anchored band-pass filter - #348

Merged
harrypm merged 2 commits into
oyvindln:vhs_decodefrom
JustinTArthur:secam-clamp-and-block-anchored-bpf
Aug 4, 2026
Merged

SECAM VHS Method 1 IF clamp and ME-SECAM block-anchored band-pass filter#348
harrypm merged 2 commits into
oyvindln:vhs_decodefrom
JustinTArthur:secam-clamp-and-block-anchored-bpf

Conversation

@JustinTArthur

Copy link
Copy Markdown

Checklist

  • I have searched the open pull requests to confirm this change has not already been submitted.
  • My branch is up to date with the target branch.
  • I have tested my changes and all existing tests pass.
  • I have updated documentation where necessary.
  • My code follows the project's coding standards (see CONTRIBUTING.md).

Description

Two quality improvements for time-base-corrected SECAM output, one a fix for a regression in ME-SECAM filtering, the other a clamp on SECAM Method 1 intermediate chroma bandwidth.

ME-SECAM filter regression

9dadc1c added a super-Gaussian FFT mask anchored on fSC, but the restored SECAM FM block sits ~106 kHz below it. The mask also dropped the tight +0.55 MHz top edge that suppressed high-side FM splatter at saturated
transitions.

SECAM VHS method 1 clamping to studio-range/broadcast-safe SECAM

The VHS color-under channel truncates FM sidebands of pre-emphasized edges, the resulting instantaneous-frequency transients swing outside SECAM's legal deviation range, the x4 phase multiplication scales them up fourfold, and every downstream SECAM decoder's de-emphasis then smears them into streaks. These excursions are provably not signal, so they can be removed at the one stage where they are still small: the under-carrier domain, before the 4x multiply.

Motivation

I performed a new battery of visual quality testing against SECAM VHS method 1 and ME-SECAM samples with upcoming chroma decoding tooling.

Changes Made

  • Restore the block-anchored FChromaFinal Butterworth for ME-SECAM. PAL and NTSC keep the fancy super-Gaussian FFT mask.
  • Clamp the instantaneous frequency of the color-under 1/4 carrier of SECAM VHS method 1 recordings to be within the original signal's legal range.

Testing

  • All existing tests pass (pytest --output-on-failure)
  • Tested manually with: SECAM and ME-SECAM RF samples
  • New tests added for:

Screenshots (if applicable)

Before IF clamping:
SECAM1 Before IF Clamp
After IF clamping:
SECAM1 After IF Clamp

Additional Notes

For specification of the broadcast-safe studio-legal SECAM bandwidth constraints used in the clamping:

Demodulate the band-passed under carrier to instantaneous frequency,
clip it to the carrier pair +-87.5 kHz, and reintegrate the phase for
the x4 multiplication. The clipping removes noise and truncation
transients that otherwise smear into streaky "fire" in downstream
de-emphasis.
The super-Gaussian FFT mask from 9dadc1c anchors on fsc, but the
restored SECAM FM block sits at conversion_lo - color_under
(4.328125 MHz), ~106 kHz below it, and the mask also drops the tight
+0.55 MHz top edge that suppressed high-side FM splatter at saturated
transitions. Restore the block-anchored FChromaFinal Butterworth for
MESECAM; PAL and NTSC keep the FFT mask.
@JustinTArthur JustinTArthur changed the title Secam clamp and block anchored bpf SECAM VHS Method 1 IF clamp and ME-SECAM block-anchored band-pass filter Aug 2, 2026
harrypm pushed a commit to harrypm/tape-decode-rust-gui that referenced this pull request Aug 4, 2026
Port of vhs-decode e5d5db5d (oyvindln/vhs-decode#348). The colour-under
channel truncates the FM sidebands of pre-emphasized edges; the resulting
instantaneous-frequency transients swing outside SECAM's legal deviation
range, the x4 phase multiplication scales them up fourfold, and every
downstream decoder's de-emphasis then smears them into streaks at
saturated transitions. They are provably not signal, so remove them at
the one stage where they are still small: the under-carrier domain,
before the multiply.

BT.470-6 table 2 item 2.12 and BT.1700 part C table 4 item 10e put the
per-component deviation maxima at D'B -350/+506 kHz and D'R -506/+350
kHz, which mirror across the carrier pair, so both components share the
foB - 350 kHz .. foR + 350 kHz corridor.

The Python reference clips np.gradient of the unwrapped phase and
reintegrates by cumsum. This port already carries per-sample wrapped
phase increments, which are that derivative, so the clamp lands on them
directly and the existing phase accumulator reintegrates implicitly. Two
consequences, documented at the call site: a legal signal passes through
untouched (the gradient/cumsum round trip is a 2-tap average that
perturbs the phase even where nothing clips), and the clip bites harder
on one-sample transients that the central difference would spread over
two.

The second half of #348 - restoring the block-anchored final chroma
band-pass for ME-SECAM - needs no counterpart here: the super-Gaussian
FFT mask that regressed it upstream was never ported, and
chroma_bandpass_final already anchors the band on color_under *
carrier_mult with the tight +0.55 MHz top edge.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@harrypm
harrypm merged commit ad1c661 into oyvindln:vhs_decode Aug 4, 2026
9 checks passed
@harrypm harrypm added enhancement New feature or request Signal Processing Related to decodes signal processing and filtering code. labels Aug 4, 2026
@JustinTArthur
JustinTArthur deleted the secam-clamp-and-block-anchored-bpf branch August 4, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Signal Processing Related to decodes signal processing and filtering code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants