Flux pinning, granularity and the irreversibility line of the high-Tc superconductor HgBa2Cu04+x