(NOTE: these are notes I’m taking before hopefully the last rewrite of this code, and will hopefully cover the design of said rewrite before this is done :) )

Framing Overview

Common background for both NTSC and PAL:

The VSYNC period consists of these three components:

After the last equalizing pulses, there are then several vertical interval lines that are not displayed, which have vertical interval test signals and laserdisc metadata.

Interlacing/field order is determined by where the VSYNC block is relative to the field’s actual display lines.

Terms

Standard-specific details

Field ordering and line number counting gets very confusing, especially since PAL and NTSC handle it completely differently.

NTSC

For color NTSC, there is a 4 field sequence: (table goes here)

PAL

There is an 8 field chroma burst sequence, but detecting that in ld-decode is not implemented yet. The PAL colour burst system is much more sophisticated than NTSC’s. Page 22 of [SPEC:CCIR] has details.

ld-decode rev5 implementation details

The framer code takes (at least some) advantage of the fact that unlike an LD player, a field can be processed as a whole.

Frame detection/framing overview

First a list of sync pulses is built up using numpy magic, which consists of areas between -20 to -50IRE (NTSC, PAL is similar). This filters out spikes and dropouts. Then a search within those is made for core VSYNC blocks.

Once the (assumed) beginning and ending areas of the two VSYNCs are found, distance comparisons are made between them. (This should allow for stable decoding as long as any two of the four edges are correct.) Refinement is then made based on the actual line length between the two.

(If it turns out more anchor points are needed, I can add the beginning and ending of the equalization cycles, but I don’t think it’ll come to that… yet.)

Then the list of sync pulses can be processed. Any valid pulses are added to a dictionary, which is then passed to further refinement stages - -20IRE zero crossing, then color burst (NTSC) or pilot (PAL) fine alignment.

References