Initial working decoder.  API is unstable.