pan/mdg: Factor out mir_adjust_constant