inspired by a patch from Fabian Groffen, grobian gentoo org Originally committed as revision 17537 to svn://svn.ffmpeg.org/ffmpeg/trunk