avcodec/gdv: Optimize and factorize scaling loops