Fix a bug causing the generated stream to be corrupt if the buffer
contains NAL units previous to the IDR where the SPS/PPS was inserted.

Ok:ed by Benoit on irc.

Originally committed as revision 11482 to svn://svn.ffmpeg.org/ffmpeg/trunk
