Fixed stride calculation and added vertical padding calculation