patch by Michael Kostylev, michael.kostylev gmail com Originally committed as revision 19227 to svn://svn.ffmpeg.org/ffmpeg/trunk