mkv: Refactor mkv_write_packet

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
mkv: Add options for specifying cluster limits

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
mkv: Flush the old cluster before writing a new one

This simplifies keeping track of cluster boundaries for e.g.
livestreaming of WebM.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
mkv: Allow flushing the current cluster in progress

Allow emitting the current cluster that is being written before
starting a new one, simplifying how to figure out where clusters
are positioned in the output stream (for live streaming).

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
mov: Set the timescale for data streams

Data streams have a defined timebase, do not ignore it.
mov: Compute max duration among the tracks with a timescale

Prevent an assert.
mov: Prevent segfaults on mov_write_hdlr_tag

Do not segfault when writing tracks such as tmcd by writing them down
as generic DataHandlers if not known.
Merge commit '148fbdd1c2a2a88a78ba9fd152c81c840bdb205a'

* commit '148fbdd1c2a2a88a78ba9fd152c81c840bdb205a':
  mkv: Refactor mkv_write_packet

Conflicts:
	libavformat/matroskaenc.c

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

* commit '98308bd44face14ea3142b501d16226eec23b75a':
  mkv: Add options for specifying cluster limits

Conflicts:
	libavformat/matroskaenc.c

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

* commit '59f595921eb2b848a80a74aa81b6bb43038c9ebe':
  mkv: Flush the old cluster before writing a new one

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

* commit 'b886f5c2f1e71b3e60e4265c500158d392b4b9a4':
  mkv: Allow flushing the current cluster in progress

Conflicts:
	libavformat/matroskaenc.c
	libavformat/version.h

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

* commit '39523030108815242178ac5e209c83070bd1baef':
  mov: Set the timescale for data streams

Conflicts:
	libavformat/movenc.c

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

* commit '22de0f8369f1f3edf1a55e1d275f3c07c617b53e':
  mov: Compute max duration among the tracks with a timescale

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge remote-tracking branch 'qatar/master'

* qatar/master:
  mov: Prevent segfaults on mov_write_hdlr_tag

Conflicts:
	libavformat/movenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avformat: Fix references to removed av_close_input_file in Doxygen
movenc: ilbc needs audio_vbr set.

Without this the block_align or bitrate value is not available to the decoder

Fixes Ticket2858

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
movenc: Allow chapter track in default MODE_MP4

Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Allow chapters to be written in trailer

This allows creation of frame accurate chapter marks from sources
like DVD and BD where the precise chapter location is not known until
the chapter mark has been reached during reading.

Signed-off-by: Martin Storsjö <martin@martin.st>
swr: clean layouts before checking sanity

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
swr/rematrix: Fix handling of AV_CH_LAYOUT_STEREO_DOWNMIX output

Fixes Ticket2859

Note, testcases related to the downmix channels are welcome.
(id like to make sure this is working correctly now, as obviously it didnt
 work before ...)

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