Originally committed as revision 18186 to svn://svn.ffmpeg.org/ffmpeg/trunk
rewrite it for greater clarity in the process. Originally committed as revision 18185 to svn://svn.ffmpeg.org/ffmpeg/trunk