Skip to content

Chroma amplitude correction from the luma FM carrier - #357

Draft
eshaz wants to merge 4 commits into
oyvindln:vhs_decodefrom
eshaz:chroma-amp-correction
Draft

Chroma amplitude correction from the luma FM carrier#357
eshaz wants to merge 4 commits into
oyvindln:vhs_decodefrom
eshaz:chroma-amp-correction

Conversation

@eshaz

@eshaz eshaz commented Aug 31, 2026

Copy link
Copy Markdown

Features

  • Chroma amplitude correction from the luma FM carrier (see below)
    • --chroma_env_gain <amount> | Default 1 | Wet/dry mix of the correction. 0 disables it. On by default.
    • --dp luma_noise plots the carrier amplitude, the demodulated luma, and the correction's confidence weight
  • Chroma automatic gain control averaging over multiple fields.
    • --cagc <fields> | Default 0 | Averages the chroma automatic gain control over N fields. Useful for camcorder recordings.
    • The averaging is split into even and odd fields, since it's likely that chroma levels differ at record time between the two field paths.
  • performance: Use numpy arrays to store the video data.
    • Previously this was using a packed record type which significantly harms sequential access to the data that stores all the demodulated data into a dictionary of arrays.
    • This is a huge performance win. On my machine, it is about 50% faster now, i.e. 6fps -> ~10fps

Fixes

  • Fix chroma_to_u16 overflow so that clipping saturates rather than overflows.
    • TODO: Perhaps a warning should be emitted for this scenario.

Chroma amplitude correction from the luma FM carrier

Corrects color-under amplitude using the luma FM carrier's envelope as a reference, recovering saturation through dropouts and modulation noise observed in the luma channel.

Premise

An FM carrier should hold constant amplitude, so every departure from constant is imposed by the tape. The luma FM carrier and the color-under were written by the same head, onto the same oxide, at the same instant — head-to-medium separation loss is shared between them and scales with wavelength. The luma envelope therefore measures, at full sample rate, the amplitude damage the color burst only samples once per line.

How it works

The luma channel is used as a reference to correct amplitude noise in the color under signal. This can be done since the luma is ideally a fixed amplitude (FM encoded). This means that any noise or changes in this amplitude represent noise introduced after it was written to the tape (tape noise, dropouts, other noise sources).

Measuring the luma noise

The demodulated luma represents the instantaneous frequency of the luma signal. An interesting property emerges from this frequency measurement because of the high frequency roll off of magnetic tape. The amplitude of the recorded luma is altered depending on the carrier frequency. By subtracting out the amplitude that correlates with the instantaneous frequency, we can isolate only the noise from the luma channel. This subtraction gives us the differential between the expected luma and the measured luma because the expected luma a fixed amplitude.

Applying the correction to the chroma

The correction is very simple since all that is needed is to inverse the luma's noise profile onto the chroma channel. This removes all of the noise that was measured in the luma channel.

Results

This performs very well, and I don't see any downsides in all of my tests. Examples coming soon.

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