A discrepancy-based penalty method for extended waveform inversion