Tweaked the numbers to fit with my scope which has video trigger. The only minor nick-nack is the 4th line on the even field is close to the vertical sync, so this one specifically doesn't work. Otherwise, it seems to be all fine.
This is the fully working version. The code should be documented well enough to reproduce the design. It generates a stable jitter-free trigger output (rising edge) for any scope.