Patch by Gwenole Beauchesne. Originally committed as revision 17634 to svn://svn.ffmpeg.org/ffmpeg/trunk