avcodec_close() does nothing in case the argument is NULL. Simplify.
That example shows how the decoding process works, not only the demuxing.