Split out counting of frame bits into a separate function.