GRIM: Reimplement Blocky16 based on FFmpeg's code. Fix #909

The previous implementation was directly converted from the assembly,
and it was nearly unreadable. This is much more structured and
safer.