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