I'll add my two cents as a short video producer with a film degree. In that sequence, I think there are only 4 shots that actually show Jamie Foxx holding the whip and hitting the guy. The rest of the shots either show Jamie by himself marching forward and flinging the whip around, or show the guy on the ground with a whip landing next to him, or show SOMEONE dressed like Jamie Foxx whipping the guy on the ground.
In the shots of Jamie marching forward, brandishing the whip, while the other guy wasn't in the shot, there was no need for the other guy to be anywhere nearby.
In the shots of the guy on the ground, with or without the person with the whip (who is only seen from the back or not at all), the person with the whip could have been a trained whip expert, who could hit the ground near the actor to kick up dust without actually hurting the actor. During this the actor could have been wearing protective padding under his clothes.
In other shots that actually show Jamie and the other guy at the same time, Jamie could have been holding a lightweight foam whip that wouldn't hurt but would still have looked convincing.
If you add the sounds of screaming, whip sound effects, and so on, and you cut the shots together quickly enough and with the right flow, it appears as though Jamie Foxx is delivering a merciless and brutal lashing to the guy on the ground. But it's all "movie magic".