Implements issue1452. Originally committed as revision 20687 to svn://svn.ffmpeg.org/ffmpeg/trunk
Originally committed as revision 20394 to svn://svn.ffmpeg.org/ffmpeg/trunk