Please excuse how vague I am on the technical explanation but I'm of the understanding that DVB streams on most channels in the UK have an indicator which the broadcasters can use (some do, some don't) to signal the start of a programme and also the start and end of ad breaks. I have a dedicated YouView box and the recordings for most channels start almost perfectly on time. I've seen this in action with TVHeadEnd which I used to run but wondered if it was something which could be used to enhance the advert detection (or indeed whether that was already in use).
I've found a thread on the TVHeadEnd forums which discusses this (didn't want to link in case it breaks your terms) but apparently the data is embedded in the EIT data.