patch by Martin Storsjö (martin AT martin DOT st) Originally committed as revision 18375 to svn://svn.ffmpeg.org/ffmpeg/trunk