SECAM pre-emphasis and bell-filter error
Incorrect colour-difference pre-emphasis or transmitter anti-bell tuning leaves colour transients after nominal receiver correction, while settled colour and luma remain unchanged in the ideal model.
Visible effect
The colour edge takes a detour
Look just to the right of a colour transition. Missing pre-emphasis lets the old colour linger; excessive pre-emphasis leaves an overshoot before the new colour settles. The middle of a wide patch keeps its colour. Compare the two isolated faults with Matched filters, then combine them.
The default source uses modest colour steps at constant encoded luma. That makes a colour transient visible without adding a brightness edge. The upper half reduces red while the lower half increases blue. SECAM’s red-difference signal uses a negative scale; the equations below make that sign explicit. The grey ramp is the other useful test: these filters have no colour difference to work on there, so it stays grey. The colour test chart adds fine patterns and picture regions; the two videos let you follow the same colour-edge errors through moving scenes.
This is a sampled, noiseless SECAM colour-path experiment. It changes the transmitter’s pre-emphasis strength and anti-bell centre frequency; the receiver retains nominal bell correction and de-emphasis. The controls exaggerate faults for comparison and are not service tolerances.
Physics
Two corrections, on opposite sides of FM
SECAM alternates the red and blue colour differences D′R and D′B. Each changes the instantaneous frequency of a subcarrier: a wave carrying colour within the video signal. The SECAM colour path introduces those coordinates and the receiver's one-line memory.
Pre-emphasis boosts faster changes in the difference before frequency modulation, or FM. Receiver de-emphasis reverses it after demodulation. Their nominal low-frequency gain is one. A missing or excessive boost therefore changes an edge's recovery rather than the final plateau.
The transmitter's anti-bell filter shapes the modulated carrier around 4.286 MHz. Its relative amplitude has a minimum there. The receiver's reciprocal bell restores amplitude and phase before frequency detection. Mistuning the transmitter leaves a mismatch across the FM sidebands: the nearby spectral components created by modulation.
Before FM · missing pre-emphasis
Receiver de-emphasis remains nominal
After FM · detuned anti-bell
Transmitter +120 kHz → nominal receiver bell
Follow a constant patch first. Filtering multiplies its single-frequency wave by a fixed complex number: amplitude and phase offset change, but its frequency does not. An ideal detector still reads the same colour difference. At an edge the wave contains several frequencies; unequal amplitude and phase changes can distort its instantaneous frequency. That is the anti-bell fault shown here.
This article owns incorrect transmitter correction. A mistuned receiver bell can produce related symptoms, but would belong to Receiver. The model holds receiver filters, discriminator scales, resting carriers and component identification nominal. It recovers both differences assuming equal colour on neighbouring lines; actual memory mixing at vertical boundaries is outside the experiment.
The filter-response explanation connects convolution, magnitude, phase and group delay. Those linear filter operations occur before and after the nonlinear FM frequency detector, in the order described here.
Mathematics
Filter the wave before reading its frequency
All RGB and difference values are dimensionless encoded video signals. Y′ = 0.299R′ + 0.587G′ + 0.114B′, D′R = −1.902(R′ − Y′), and D′B = 1.505(B′ − Y′). The prime marks encoded rather than linear-light values. The model keeps Y′ separate and unchanged.
In the first equation f is the frequency of a change in a colour difference, not the carrier frequency. The imaginary unit j represents the second component of a complex value; magnitude specifies gain and angle specifies phase. The strength α changes the boost: zero bypasses it, one is nominal, and two doubles the correction above the unchanged DC response. DC means the constant component, at zero frequency.
P(0) = 1; its high-frequency gain approaches three. At 85 kHz its magnitude is about 1.342. The code uses sample rate fs = 16 MHz and discretises this filter with the bilinear substitution s = 2fs(1 − z⁻¹)/(1 + z⁻¹), where s is continuous complex frequency and z⁻¹ is a one-sample delay operator. It uses the exact reciprocal discrete filter for nominal receiver de-emphasis, so the matched pair cancels at every sampled frequency.
For anti-bell shaping, f now means carrier-spectrum frequency in Hz and fc means filter centre. The standard response below omits the common amplitude scale M₀, which cancels in the ideal detector. The transmitter offset δf is in Hz; the UI converts its kHz control by multiplying by 1000.
At f = 0 the response is its finite limit 16/1.26. For negative frequencies use the conjugate response. With zero offset, H = 1. Applying only the magnitude would discard the phase distortion we are trying to measure.
Let D* be the pre-emphasised difference and fs = 16 MHz the sample rate. For the red line use f₀ = 4.40625 MHz and k = 280 kHz per difference unit; for blue use 4.250 MHz and 230 kHz per unit. Phase φ is in radians. Integrate frequency before constructing the complex carrier z; a cosine of the instantaneous frequency alone would not be FM.
A fast Fourier transform, or FFT, separates z into frequency bins. Multiply each bin by H, then invert the transform to obtain the filtered wave w. Measure the phase increment between successive samples; the bar denotes complex conjugation, and arg means angle.
The phase increment must remain between −π and π, and the wave must retain nonzero amplitude. The modest default steps stay within that domain. Saturated, sharp source details with exaggerated faults may approach detector limits; this is not a detector for arbitrary damaged composite video. Nominal de-emphasis then produces the recovered differences, marked with hats.
Green is solved from the original luma equation. This preserves encoded luma before display clipping; it does not claim constant physical luminance after display gamma. Grey has zero differences and stays neutral. An incorrect deviation gain instead changes settled colour and is covered by SECAM chroma frequency-deviation error.
Code
Apply the prepared filter on the GPU
The implementation separates filter preparation from signal processing. The CPU prepares coefficients and lookup textures. GPU passes use those tables to perform pre-emphasis, FM, complex carrier filtering, phase detection and de-emphasis. The diagnostic step uses the same shader passes.
Colour sampling and luma preservation
The correction acts on D′R and D′B while Y′ travels unchanged. A row contains 832 colour samples across the 52 µs active span at 16 MHz. After decoding, the shader subtracts the input colour differences from the recovered ones and converts that difference into an RGB correction. It adds the correction to the source RGB, so the signal-processing grid does not resample the separate luma path. Display clipping happens after blending.
Why these optimisations help
- Prepare a small complex LUT on the CPU. H is sampled at 2048 FFT bins only when transmitter detuning changes. The GPU multiplies each carrier-spectrum bin by the prepared complex value. Both amplitude and phase are retained. The table is shared by both colour components and every row; it is a filter curve, not a per-pixel RGB lookup.
- Prepare invariant FFT data once. Address pairs, signed phase factors and resting-carrier phasors become lookup textures when the renderer starts. Shader passes fetch them instead of repeatedly calculating trigonometry and bit reversal across every picture row.
- Parallelise the signal history. Doubling-distance prefix passes implement the first-order recurrences. Pre-emphasis and its cumulative phase are combined in one scan. A fragment reads the preceding span's accumulated result, preserving left-to-right filter history. Red and blue use the same passes, packed together. De-emphasis stops once the remaining feedback falls below 10⁻⁸, beneath the picture's floating-point precision needs.
- Keep intermediate values on the GPU. Two float framebuffer textures alternate between passes; a third retains the active colour correction. No video pixels are read back to JavaScript. Only the one-row diagnostic is read after its controls change, to draw the SVG traces.
- Use exact cancellation. At zero anti-bell offset, the carrier filters cancel. The remaining difference response Pα/P = α + (1 − α)/P needs only nominal de-emphasis and a blend, avoiding FM and FFT processing. Matched filters and zero Effect mix bypass picture filtering.
- Reuse results and bound latency. Unchanged pictures reuse their uploaded source and correction. A mix change only redraws presentation; resizing recalculates the correction if its required row count changes. Video capture follows the browser's frame counter rather than an assumed frame rate. A nonblocking GPU fence prevents a new picture decode from being queued before the preceding one finishes. Both panes share one source snapshot per render turn, independently of the animation clock; buffers update in place.
The renderer uses WebGL2 with floating-point framebuffer support. Intermediate values retain sign and excursions outside the display range; only the final RGB output is clipped.
Prepare the LUT and discrete coefficients
carrierRatioLut prepares N = 2048 complex values for H. The renderer uploads the returned Float32Array with texImage2D using internal format RG32F, pixel format RG and type FLOAT. One texel stores the real and imaginary parts for one FFT bin; bins above N/2 represent negative frequencies. The LUT uses nearest sampling, and pass 5 reads the exact bin with texelFetch. fftLut stores the butterfly's two input addresses and its signed complex phase factor; restingCarrierLut supplies the fixed carrier phase. These tables depend on filter settings and sampling, so their preparation is independent of the picture.
// WHAT: Prepare SECAM correction coefficients and small GPU lookup textures.
// HOW: Sample the complex carrier response and precompute FFT addressing.
// WHY: Filter curves depend on controls, not on picture pixels or rows.
export interface CorrectionParameters {
emphasis: number;
bellOffsetKhz: number;
mix: number;
}
export const SAMPLE_RATE = 16_000_000;
export const ACTIVE_SAMPLES = 832;
export const BLOCK_SAMPLES = 2048;
export const PAD = (BLOCK_SAMPLES - ACTIVE_SAMPLES) / 2;
export const FFT_STAGES = 11;
type Complex = [number, number];
const divide = ([ar, ai]: Complex, [br, bi]: Complex): Complex => {
const norm = br * br + bi * bi;
return [(ar * br + ai * bi) / norm, (ai * br - ar * bi) / norm];
};
/** ITU-R BT.470-6 Table 2 §2.13, omitting common amplitude M0. */
export function antiBellResponse(f: number, offsetKhz: number): Complex {
if (f === 0) return [16 / 1.26, 0];
const centre = 4_286_000 + offsetKhz * 1000;
const detuning = f / centre - centre / f;
return divide([1, 16 * detuning], [1, 1.26 * detuning]);
}
/** Bilinear first-order coefficients [b0, b1, feedback]. */
export function differenceCoefficients(strength: number, inverse: boolean): [number, number, number] {
const tau = 1 / (2 * Math.PI * 85_000);
const denominator = 1 + 2 * SAMPLE_RATE * tau / 3;
const b0 = (1 + 2 * SAMPLE_RATE * tau) / denominator;
const b1 = (1 - 2 * SAMPLE_RATE * tau) / denominator;
const a1 = (1 - 2 * SAMPLE_RATE * tau / 3) / denominator;
return inverse ? [1 / b0, a1 / b0, -b1 / b0]
: [1 + strength * (b0 - 1), a1 + strength * (b1 - a1), -a1];
}
export function carrierRatioLut(offsetKhz: number): Float32Array<ArrayBuffer> {
const result = new Float32Array(BLOCK_SAMPLES * 2);
for (let n = 0; n < BLOCK_SAMPLES; n++) {
const frequency = (n <= BLOCK_SAMPLES / 2 ? n : n - BLOCK_SAMPLES) * SAMPLE_RATE / BLOCK_SAMPLES;
result.set(divide(antiBellResponse(frequency, offsetKhz), antiBellResponse(frequency, 0)), n * 2);
}
return result;
}
/** Addresses and signed twiddles for both directions of a radix-2 FFT. */
export function fftLut(): Float32Array<ArrayBuffer> {
const result = new Float32Array(BLOCK_SAMPLES * FFT_STAGES * 4);
const reversed = (n: number) => {
let value = 0;
for (let bit = 0; bit < FFT_STAGES; bit++) { value = value * 2 + (n & 1); n >>= 1; }
return value;
};
for (let stage = 0; stage < FFT_STAGES; stage++) {
const length = 2 ** (stage + 1), half = length / 2;
for (let n = 0; n < BLOCK_SAMPLES; n++) {
const j = n % half, a = Math.floor(n / length) * length + j, b = a + half;
const angle = -2 * Math.PI * j / length, sign = n % length < half ? 1 : -1;
result.set([stage === 0 ? reversed(a) : a, stage === 0 ? reversed(b) : b,
sign * Math.cos(angle), sign * Math.sin(angle)], (stage * BLOCK_SAMPLES + n) * 4);
}
}
return result;
}
export function restingCarrierLut(): Float32Array<ArrayBuffer> {
const result = new Float32Array(BLOCK_SAMPLES * 4);
for (let n = 0; n < BLOCK_SAMPLES; n++) {
const red = 2 * Math.PI * 4_406_250 * (n + 1) / SAMPLE_RATE;
const blue = 2 * Math.PI * 4_250_000 * (n + 1) / SAMPLE_RATE;
result.set([Math.cos(red), Math.sin(red), Math.cos(blue), Math.sin(blue)], n * 4);
}
return result;
}Executed GPU passes
The pass numbers follow the runtime's dispatch: 0 seeds the difference recurrence; repeated passes 1 accumulate its history and FM phase; 3 constructs the carrier; eleven passes 4 perform the FFT; 5 applies the LUT; eleven inverse passes 4 recover the wave; 6 and repeated passes 1 detect and de-emphasise it; 8 retains the active correction; 9 presents it. The forward FFT divides by two at every stage, giving a total scale of 1/N, while the inverse is unscaled. Their pair therefore preserves amplitude. At zero anti-bell offset, the cancellation shortcut uses only 0, 1, 8 and 9.
// WHAT: Apply SECAM transmitter correction and receiver recovery on the GPU.
// HOW: Parallel IIR scans, phase integration, complex FFT/LUT/FFT and detection.
// WHY: Keep source detail and process all rows without CPU frame readbacks.
uniform sampler2D u_input,u_source,u_ratio,u_fft,u_rest;
uniform int u_pass,u_stride,u_stage,u_rows;
uniform float u_feedback,u_fftScale,u_mix,u_da,u_imageAspect,u_emphasis;
uniform vec2 u_coefficients;
uniform vec2 u_phaseFeedback;
uniform bool u_inverse,u_diagnostic,u_bypass,u_integrate,u_matchedCarrier;
in vec2 v_uv;
out vec4 outColor;
const int ACTIVE=832,BLOCK=2048,PAD=608;
const float FS=16000000.0,TAU=6.283185307179586;
const vec2 REST=vec2(4406250.0,4250000.0),SLOPE=vec2(280000.0,230000.0);
vec2 multiplyComplex(vec2 a,vec2 b){return vec2(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}
vec2 sourceDifference(ivec2 p){
int x=clamp(p.x-PAD,0,ACTIVE-1);
if(u_diagnostic)return texelFetch(u_source,ivec2(x,0),0).rg;
vec3 rgb=texture(u_source,vec2((float(x)+.5)/float(ACTIVE),(float(p.y)+.5)/float(u_rows))).rgb;
float y=dot(rgb,vec3(.299,.587,.114));
return vec2(-1.902*(rgb.r-y),1.505*(rgb.b-y));
}
vec2 demodulate(ivec2 p){
if(p.x<=0)return sourceDifference(p);
vec4 a=texelFetch(u_input,p,0),b=texelFetch(u_input,p-ivec2(1,0),0);
vec2 increment=vec2(atan(a.y*b.x-a.x*b.y,dot(a.xy,b.xy)),atan(a.w*b.z-a.z*b.w,dot(a.zw,b.zw)));
return (increment*FS/TAU-REST)/SLOPE;
}
vec2 linearCorrection(vec2 uv){
vec2 pixel=uv*vec2(ACTIVE,u_rows)-.5;
ivec2 base=ivec2(floor(pixel));vec2 f=fract(pixel);
ivec2 limit=ivec2(ACTIVE-1,u_rows-1);
vec2 a=texelFetch(u_input,clamp(base,ivec2(0),limit),0).rg;
vec2 b=texelFetch(u_input,clamp(base+ivec2(1,0),ivec2(0),limit),0).rg;
vec2 c=texelFetch(u_input,clamp(base+ivec2(0,1),ivec2(0),limit),0).rg;
vec2 d=texelFetch(u_input,clamp(base+ivec2(1,1),ivec2(0),limit),0).rg;
return mix(mix(a,b,f.x),mix(c,d,f.x),f.y);
}
void main(){
ivec2 p=ivec2(gl_FragCoord.xy);
if(u_pass==0){ // Pre-emphasis recurrence seed, with steady-state first sample.
vec2 current=sourceDifference(p),previous=sourceDifference(p-ivec2(1,0));
vec2 seed=p.x==0?current:u_coefficients.x*current+u_coefficients.y*previous;
outColor=vec4(seed,seed*SLOPE*TAU/FS);
}else if(u_pass==1){ // Parallel prefix recurrence and cumulative FM phase.
vec4 value=texelFetch(u_input,p,0);
if(p.x>=u_stride){
vec4 previous=texelFetch(u_input,p-ivec2(u_stride,0),0);
value.rg+=u_feedback*previous.rg;
if(u_integrate)value.ba+=previous.ba+u_phaseFeedback*previous.rg;
}
outColor=value;
}else if(u_pass==3){ // Construct both complex FM carriers from integrated phase.
vec2 phase=texelFetch(u_input,p,0).ba;vec4 rest=texelFetch(u_rest,ivec2(p.x,0),0);
outColor=vec4(multiplyComplex(vec2(cos(phase.x),sin(phase.x)),rest.xy),multiplyComplex(vec2(cos(phase.y),sin(phase.y)),rest.zw));
}else if(u_pass==4){ // One FFT butterfly stage; the first includes bit reversal.
vec4 entry=texelFetch(u_fft,ivec2(p.x,u_stage),0);
vec4 a=texelFetch(u_input,ivec2(int(entry.x),p.y),0),b=texelFetch(u_input,ivec2(int(entry.y),p.y),0);
vec2 twiddle=entry.zw;if(u_inverse)twiddle.y=-twiddle.y;
outColor=(a+vec4(multiplyComplex(b.xy,twiddle),multiplyComplex(b.zw,twiddle)))*u_fftScale;
}else if(u_pass==5){ // Apply the CPU-prepared complex frequency-response LUT.
vec4 wave=texelFetch(u_input,p,0);vec2 ratio=texelFetch(u_ratio,ivec2(p.x,0),0).rg;
outColor=vec4(multiplyComplex(wave.xy,ratio),multiplyComplex(wave.zw,ratio));
}else if(u_pass==6){ // Nominal de-emphasis seed, fused with phase detection.
vec2 current=demodulate(p),previous=demodulate(p-ivec2(1,0));
outColor=vec4(p.x==0?current:u_coefficients.x*current+u_coefficients.y*previous,0,0);
}else if(u_pass==8){ // Retain a colour correction; source/luma detail stays native.
ivec2 samplePosition=p+ivec2(PAD,0);
vec2 recovered=texelFetch(u_input,samplePosition,0).rg;
if(u_matchedCarrier)recovered=mix(recovered,sourceDifference(samplePosition),u_emphasis);
outColor=vec4(u_diagnostic?recovered:recovered-sourceDifference(samplePosition),0,1);
}else{ // Present the same full-resolution source, adding only colour differences.
vec2 fraction=vec2(1);
if(u_imageAspect>u_da)fraction.x=u_da/u_imageAspect;else fraction.y=u_imageAspect/u_da;
vec2 uv=.5+(v_uv-.5)*fraction;uv.y=1.-uv.y;
vec3 rgb=texture(u_source,uv).rgb;
if(!u_bypass){
vec2 delta=linearCorrection(uv)*u_mix;
float r=-delta.x/1.902,b=delta.y/1.505;
rgb+=vec3(r,(-.299*r-.114*b)/.587,b);
}
outColor=vec4(rgb,1);
}
}- Native encoded RGB image or videoNative picture detail · 832 colour samples per full row
- GPU line encode and decodeFloat textures · parallel recurrences + complex FFT · CPU-prepared filter LUT
- Hold luma and form D′R/D′B
- Apply transmitter pre-emphasis
- Integrate FM phase
- Apply anti-bell / nominal anti-bell ratio
- Measure phase increments
- Apply nominal de-emphasis
- Retain the recovered colour correction
- Native-detail presentationOne fullscreen GPU pass · native video snapshots
- Add colour correction to the native RGB source
- Blend, clip and retain source aspect
- Present the same captured frame in both panes
- Recovered picture
Why these steps are here
- Retain filter history. Pre-emphasis and de-emphasis preserve the recurrence across a complete source row using parallel prefix passes. They begin in the first patch's steady state.
- Extend the edges. A 2048-sample block adds 608 samples, or 38 µs, of constant extension at each end. This guards the active region from the circular FFT boundary; it is numerical padding, not transmitted blanking.
- Filter complex bins. The anti-bell/bell ratio changes both amplitude and phase. Carrier amplitude is never multiplied into the recovered colour difference.
- Take phase differences. Multiplying by the previous sample's conjugate removes absolute phase. The nominal resting frequency is subtracted before division by the correct component slope.
Notes
- This is a noiseless, unbounded complex-carrier model. It omits actual chroma bandwidth filters, deviation limiting, composite luma/chroma separation, RF transport, receiver noise thresholds and colour suppression. The modest source steps isolate filter mismatch. The colour test chart and videos explore more complex pictures; their sharp saturated details can exaggerate an unbounded response. Do not use the implementation as a calibrated full SECAM encoder.
- The anti-bell offset changes the transmitter filter centre, not either resting carrier. The ±120 kHz range exaggerates mistuning; BT.470-6 specifies a much smaller ±20 kHz centre-alignment allowance.
- Finite FFT blocks approximate linear convolution in their guarded centre. Sampling at 16 MHz also limits representable sidebands; sharp discontinuities are not a broadband analogue simulation. The blocks do not reproduce line-start blanking or reset transients. The phase detector is ideal and does not simulate a particular receiver's loop.
- The diagnostic step is sharper than the picture's smooth, quantised source step. The interactive diagnostic and picture use the same shader processor, but their peak sample values need not match. Their direction and settling behaviour are the comparison.
- Both components use the same row to approximate equal adjacent-line colour. Vertical memory-boundary effects and D′R/D′B sequencing faults need their own experiments.
- The anti-bell amplitude graph and static article remain usable without WebGL. The picture and recovered-step traces require floating-point WebGL2; traces are hidden during context loss and recomputed with the current controls after restoration. The displayed picture is an encoded-signal experiment rather than a conversion to historical SECAM display primaries.
References
ITU-R BT.470-6 — Table 2 §§2.5, 2.7, 2.11–2.13 and Figures 6–7 — defines the historical SECAM colour coordinates, 85/255 kHz difference-signal correction, FM scales, complex anti-bell response and 4.286 MHz centre. Strength interpolation, sampled filtering and exaggerated offset controls are this article’s teaching model.
Philips/NXP — SAA7114, rev. 03 §8.1.3.1 and Fig. 10 — documents amplitude/phase bell correction before a phase demodulator and differentiator, followed by de-emphasis and SECAM line-delay recombination. The experiment uses an ideal phase-increment detector, not a simulation of this chip.