backported r19987 by michael Originally committed as revision 21717 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5