Fix detection of same-frame to speed up simple encodes (#548).