I'm looking for a programmable comparator which has a digital or open-drain output and a voltage reference which can be programmed over I2C. My searches at my favourite sites of Microchip and Farnell haven't brought up anything interesting.
If this isn't possible I'd be looking at making an external R-2R (or R = 2^n) divider (precision not critical) from 4-5 IO pins to get 16 or 32 levels granularity. The setpoint needs to be adjusted to compensate for varying video levels.
Edit: such comparator should also have <1µs response time. Most comparators satisfy this, but there are a few cheap ones that don't.