frame: Implement frame header decoding. This is the first piece of the new frame API.