Block matching algorithm in video processing