flxdec: rewrite logic based on GstByteReader/Writer