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.
a64: remove unneeded struct qualifier
a64: check that extradata exists before reading from it
yuv4mpeg: split the demuxer and muxer into separate files
yuv4mpegdec: do not set coded_frame properties

coded_frame is not meant to be changed from outside of lavc, and is not
used for decoding.
Set AVCodecContext.field_order instead.
yop: only set extradata size after it has been successfully allocated

Do not leave a non-zero extradata_size set on failure
avienc: sanitize variable naming in write_header()

Do not call an AVCodecContext 'stream', that is highly confusing.
Also, add a local variable for the current AVStream in the loop over all
streams.
lavf: extend avg_frame_rate documentation.
avconv: set output avg_frame_rate when known
dv: do not set codec timebase

It is not supposed to be set from outside of libavcodec.
Set average framerate instead.