Forgive me, not in a patch format... copied from irc: <JEEB> since this code originates in mplayer and I wasn't able to find an up-to-date web-viewable SVN repo, this might be applicable to mplayer as well https://github.com/mpv-player/mpv/commit/d0c530919d8cd4d7a774e38ab064e0fabdae34e6