pts fix and related fixes
Originally committed as revision 2452 to svn://svn.ffmpeg.org/ffmpeg/trunk