lavc: Move the libtwolame encoder registration to the list for external libraries

This makes sure the default behaviour of using the internal encoder
stays the same regardless if libtwolame is enabled or not (as for
any external library).

This fixes fate-lavf-mpg if libav is built with libtwolame enabled.

CC: libav-stable@libav.org
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
xwma: Do not leak on failure path

CC: libav-stable@libav.org
Bug-Id: CID 1087092
lavfi: clean memory on error in ADD_FORMAT()

CC: libav-stable@libav.org
Bug-Id: CID 1250334
libtwolame: prevent a NULL pointer dereference

CC: libav-stable@libav.org
Bug-Id: CID 1250330 / CID 1250335
dvdsubdec: Do not leak on failure path

CC: libav-stable@libav.org
Bug-Id: CID 1198262
vp9: Use the correct upper bound for seg_id

And use a macro to make apparent why the value.

Bug-Id: CID 1108595
qdm2: avoid integer overflow

CC: libav-stable@libav.org
Bug-Id: CID 700555
hevc: Spin the mv_mpv_mode calls in a stand alone function

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
flvenc: Remove an unused variable

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Remove a redundant include of sys/stat.h

The same file already includes this header a few lines further
above.

Signed-off-by: Martin Storsjö <martin@martin.st>
dashenc: Don't require the stream bitrate to be known

Don't write any bitrate attribute if it isn't known. As long as one
doesn't want automatic bitrate switching, playback can work just
fine even if it isn't set.

If strict standard compliance is requested, this is still considered
an error, since the attribute is mandatory according to the spec.

Based on a patch by Rodger Combs.

Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Add a flag for indicating a discontinuous fragment

This allows creating a later mp4 fragment without sequentially
writing the earlier ones before.

Normally when writing a fragmented mp4 file sequentially, the
first timestamps of a fragment are adjusted to match the
end of the previous fragment, to make sure the timestamp is the
same, even if it is calculated as the sum of previous fragment
durations.

When writing an individual mp4 fragment discontinuously like this
(with potentially writing the earlier fragments separately later),
there's a risk of getting a gap in the timeline if the duration
field of the last packet in the previous fragment doesn't match up
with the start time of the next fragment.

Using this requires setting -avoid_negative_ts make_non_negative
(or -avoid_negative_ts 0).
movenc: Expose the fragment index as an avoption

This allows setting the right fragment number if doing
random-access writing of fragments.
dashenc: Test: Allow skipping writing some segments
movenc: Store the tag name used for free/wide atoms

This simplifies cases where similar placeholders are needed
in other places as well.
movenc: Use start_dts instead of cluster[0].dts for writing edit lists
movenc: Add a placeholder for edts/elst when writing empty_moov in seekable files

Update the placeholder as soon as we know the start timestamp.
movenc: Add an option for delaying writing the moov with empty_moov

This delays writing the moov until the first fragment is written,
or can be flushed by the caller explicitly when wanted. If the first
sample in all streams is available at this point, we can write
proper edts at this point.

This isn't added to the normal behaviour for empty_moov, since
the behaviour that ftyp+moov is written during avformat_write_header
would be changed. Callers that split the output stream into header+segments
(either by flushing manually, with the custom_frag flag set, or by
just differentiating between data written during avformat_write_header
and the rest) will need to be adjusted to take this option into use.

The alternative would be to use different kinds of heuristics for
guessing the start dts (using AVCodecContext delay or has_b_frames
together with the frame rate), but this is not reliable and doesn't
necessarily work well with stream copy.
dashenc: Use delay_moov
movenc: Allow setting the nominal start time of streams

This allows doing random-access writing of fragments,
while writing a correct edit list.