apps/opt: refactor input format parsing