Calculate mpvflags and d2aflags only once