pcmdec: change default of channels parameter to 1

This was previously implicitly done in ff_raw_read_header().
Fixes fate tests with pcm input.
ffv1: set the range coder state in decode_slice_header
lavc: add lavfi metadata support.

This commit introduces a new AVPacket side data type:
AV_PKT_DATA_STRINGS_METADATA. Its main goal is to provide a way to
transmit the metadata from the AVFilterBufferRef up to the AVFrame. This
is at the moment "only" useful for lavfi input from libavdevice:
lavd/lavfi only outputs packets, and the metadata from the buffer ref
kept in its context needs to be transmitted from the packet to the frame
by the decoders. The buffer ref can be destroyed at any time (along with
the metadata), and a duplication of the AVPacket needs to duplicate the
metadata as well, so the choice of using the side data to store them was
selected.

Making sure lavd/lavfi raises the metadata is useful to allow tools like
ffprobe to access the filters metadata (it is at the moment the only
way); ffprobe will now automatically show the AVFrame metadata in any
customizable output format for users. API users will also be able to
access the AVFrame->metadata pointer the same way ffprobe does
(av_frame_get_metadata).

All the changes are done in this single commit to avoid some memory
leaks: for instances, the changes in lavfi/avcodec.c are meant to
duplicate the metadata from the buffer ref into the AVFrame. Unless we
have an internal way of freeing the AVFrame->metadata automatically, it
will leak in most of the user apps. To fix this problem, we introduce
AVCodecContext->metadata and link avctx->metadata to the current
frame->metadata and free it at each decode frame call (and in the codec
closing callback for the last one). But doing this also means to update
the way the tiff decoder already handles the AVFrame->metadata (it's the
only one decoder with frame metadata at the moment), by making sure it
is not trying to free a pointer already freed by the lavc internals.

The lavfi/avcodec.c buffer ref code is based on an old Thomas Kühnel
work, the rest of the code belongs to the commit author.

Signed-off-by: Thomas Kühnel <kuehnelth@googlemail.com>
Signed-off-by: Clément Bœsch <ubitux@gmail.com>
lavfi/select: store scene score in buf ref metadata.
lavfi/silencedetect: export silence info to metadata.
compat/getopt: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/cook: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/vorbisenc: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
bavformat/mov: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/movenc: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/mpegvideodec: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/mxfenc: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/oggenc: add {} to complex ifs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
h264: add support for AFD detection

Signed-off-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Kieran Kunhya <kierank@ob-encoder.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Merge remote-tracking branch 'cus/stable'

* cus/stable:
  ffplay: if there is no audio stream, use external clock by default
  ffplay: use get_master_sync_type where necessary
  ffplay: add get_master_sync_type function
  ffplay: only check external clock if current frame serial matches the displayed frame serial
  ffplay: add serial field to PacketQueue entry and populate it
  ffplay: fix external time sync mode
  ffplay: initialize audio and video pts drift
  ffplay: fix nosync threshold check in synchronize_audio
  ffplay: use framedrop by default when sync is not done to video

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Improve MPEG-PS-in-MOV detection.

Fixes issue 1520.
fate: fix filter metadata dependency to ffprobe.
doc/muxers: document mov faststart option.
mpegaudiodec: Fix buffer handling on random access

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
lavc/utils: provide more feedback in case of experimental codec