As weird as it looks, there actually is about a pixel of safe space at the top of the Piranha Plants mouth. The hit box is a little lower than the actual tip of the spite. It's easy to replicate this jump, you just have to get Mario to jump as high possible.