My suggestions for improvements:
- Flags are always written out, while other things may depend on the flag values
- Added actual limits for non-binary syntax elements
- Added parsing of TU data (Cbfs)
- Simplified Mv derivation
- Removed some obsolete comments
- Added a second parsing function, which more or less emulates the decoder loop