rpza: switch to bytestream2
rpza: use fixed-width int types
rpza: move some variables to the blocks where they are used
rpza: limit the number of blocks to the total remaining blocks in the frame

Fixes invalid writes.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org