Merlyn said:
If you need to pump more than 4K into the input buffer but can't start reading the output until after that, and the output hits 4K, you're toast.
Yeah, I realized that after I posted it. The "edge case" of where the last buffer filled is 0 or 4060 is a problem. More thinking is needed.