fix IDR management (flush memory when an IDR is encountered)