Re-arrange things to avoid code duplication and duplicate yuv->y4m operations.