Try to fix crashes introduced by r25218

r25218 made assumptions about the existence of past reference frames that
weren't necessarily true.

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