Estrada hits 2-run HR in 9th, Giants edge Pirates 8-7