[3.0] demux: mp4: backport some patches from 4.0
The MP4 demuxer has evolved a lot in 4.0 and 3.0 is lagging. In particular it has some memory issues fixed by the last patch of this MR.
This is an alternative to !2443 (merged) without the vlc_tick_t
changes nor the interim changes to get to the last commit. Now the commits are not following their natural parent commit so there might be unexpected side effects. It does work in my test and fixes the same memory issue as !2443 (merged).