current code wouldn't always error out on errors.
Based on patch by Stephen d'Angelo <sdangelo evertz com>.
Originally committed as revision 25260 to svn://svn.ffmpeg.org/ffmpeg/trunk
Therefore, init it with NULL to prevent a crash on invalid streams.
Patch by Zhentan Feng <spyfeng gmail com>.
Originally committed as revision 24960 to svn://svn.ffmpeg.org/ffmpeg/trunk
Zhentan Feng <spyfeng gmail com> as part of Google's Summer of Code program.
Originally committed as revision 24861 to svn://svn.ffmpeg.org/ffmpeg/trunk