More fixes to encode/decode but need to fix mplay stack smashing detected.