Patch by Martin Storsjö <$firstname()$firstname,st>. Originally committed as revision 21149 to svn://svn.ffmpeg.org/ffmpeg/trunk