Extend #980 with --max-quality support