Rate-distortion optimal joint macroblock mode selection and motion estimation for mpeg-like video coders