lavc: remove the locking code in avcodec_close()

This function should not modify any global state, so there should be no
reason for any locking.
lavc: add avcodec_free_context().

Right now, the caller has to manually manage some allocated
AVCodecContext fields, like extradata or subtitle_header. This is
fragile and prone to leaks, especially if we want to add more such
fields in the future.

The only reason for this behaviour is so that the AVStream codec context
can be reused for decoding. Such reuse is discouraged anyway, so this
commit is the first step to deprecating it.
4xm: allocate extradata properly.

Pad it with the required amount of zeros, check for malloc failure.
Merge commit 'e1b66778b6ee82a192b5895e23c4e135f7269326'

* commit 'e1b66778b6ee82a192b5895e23c4e135f7269326':
  lavc: remove the locking code in avcodec_close()

Conflicts:
	libavcodec/utils.c

Note, if someone knows of a external codec lib/API, hwaccel or other that requires
locking on its close/free side, please contact ffmpeg-devel.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit 'fd056029f45a9f6d213d9fce8165632042511d4f'

* commit 'fd056029f45a9f6d213d9fce8165632042511d4f':
  lavc: add avcodec_free_context().

Conflicts:
	doc/APIchanges
	libavcodec/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit 'd256ed78ffe202a4dcc8d625becffc716bfa3977'

* commit 'd256ed78ffe202a4dcc8d625becffc716bfa3977':
  4xm: allocate extradata properly.

Merged-by: Michael Niedermayer <michaelni@gmx.at>