into a separate function. Originally committed as revision 19263 to svn://svn.ffmpeg.org/ffmpeg/trunk