They both use Qualcomm chips with the same DAC, I believe. I have the S3, and as far as I can tell it's decent. At low volume I can hear noise and hiss through my Superlux HD668B, but maybe that's a consequence of me using CyanogenMod. The volume gets quite loud (in fact even the lowest volume level is a bit too loud for me).
EDIT: the S3 supports USB DACs out of the box. There is a thread here dedicated to discussing USB DACs for Android phones. The Nexus 4 has ROMs with that capability.
EDIT2: Anandtech's Nexus review included measurements that you can check out.
Edited by lidavidm - 7/9/13 at 7:05am