Patch by Anton Khirnov, wyskas at gmail Originally committed as revision 23468 to svn://svn.ffmpeg.org/ffmpeg/trunk