Fix brain-dead parts of r11216, specifically:
Actually unreference removed pics
And check for too many reference frames as originally intended, not equal
to max reference frames.

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