patch by Anton Khirnov, wyskas gmail com Originally committed as revision 20006 to svn://svn.ffmpeg.org/ffmpeg/trunk