fate: Use bitexact conversions in the dpxparser test

This fixes fate on e.g. ppc.

Signed-off-by: Martin Storsjö <martin@martin.st>
dashenc: Fix writing of timelines that don't start at t=0

When writing an explicit time, reset the cur_time variable to this
value as well. This avoids writing excessive time attributes for each
segment in the timeline, as long as the segments are continuous.

Signed-off-by: Martin Storsjö <martin@martin.st>
dashenc: Remove some stray double spaces

Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Factorize writing ftyp and other identification tags to a separate function
movenc: Remove an unnecessary condition when flushing fragments

If fragments == 0 it means we haven't written any moov atom yet.
If the empty_moov flag is set, we already have written an empty moov
atom at startup. Thus, the check for empty_moov is redundant.

This is in preparation for allowing writing the moov atom later,
even when using the empty moov flag.
movenc: Use start_dts/cts instead of cluster[0] for writing edit lists

This allows writing edit lists even when track->entry == 0, if
the start times have been set.
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
a proper editlist at this point, allowing streams to start at
something else than dts=0. For AC3 and DNXHD, a packet is
needed in order to write the moov header properly.

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.

For handling streams that start at something else than dts=0, an
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, and wouldn't work for getting
the right initialization data for AC3 or DNXHD either.
movenc: Get rid of a hack for updating the dvc1 atom

Use the more generic approach with the delay_moov flag, instead of
having a update mechanism specific to this one single atom.
dashenc: Use delay_moov
dashenc: Add an option for writing segments starting at an index other than one

Based on patches by Rodger Combs.
dashenc: Use pts for MPD timeline timestamps

This should be more correct. This also should give more sensible
switching between video streams with different amount of b-frame
delay.

The current dash.js release (1.2.0) fails to start playback of
such files from the start (if the start pts is > 0), but this has
been fixed in the current git version of dash.js.

Also enable the use of edit lists, so that streams in many cases
start at pts=0.
movenc: Check start_dts instead of track->entry to see whether all streams have been initialized

This is a preparatory refactoring, to allow flushing to write a
moov atom before the first packets have been written (as long as
the start times have been set).
RFC: movenc: Allow setting the nominal start time of streams

This allows writing a moov with an edit list even before the first
packet has been written.

This allows doing random-access writing of fragments when the
start dts of the stream isn't zero, so that the edit list in the moov
is written based on timestamps from the nominal start time set via
an option, while the first packet written corresponds to a later
fragment.

This is incredibly ugly - is there any better way of achieving
the same (private avoptions per stream)?
TEST/EXAMPLE ONLY: dashenc: Allow skipping writing some segments

To show how to handle random-access writing, allow skipping writing
earlier segments. No packets for the skipped segments are sent to
the actual mp4 muxer.