lavu: Add av_gettime_relative

Since av_gettime() is used in a number of places where actual
real time clock is required, the monotonic clock introduced in
ebef9f5a5 would have consequences that are hard to handle. Instead
split it into a separate function that can be used in the cases
where only relative time is desired.

On platform where no monotonic clock is available, the difference
between the two av_gettime functions is not clear, and one could
mistakenly use the relative clock where an absolute one is
required. Therefore add an offset, to make it evident that the
time returned from av_gettime_relative never is actual current
real time, even though it is based on av_gettime.

Based on a patch by Olivier Langlois.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavc: Use av_gettime_relative

Whenever av_gettime() is used to measure relative period of time,
av_gettime_relative() is prefered as it guarantee monotonic time
on supported platforms.

Signed-off-by: Martin Storsjö <martin@martin.st>
tools: Use av_gettime_relative

Whenever av_gettime() is used to measure relative period of time,
av_gettime_relative() is prefered as it guarantee monotonic time
on supported platforms.

Signed-off-by: Martin Storsjö <martin@martin.st>
avplay: Use av_gettime_relative

Signed-off-by: Martin Storsjö <martin@martin.st>
avconv: Use av_gettime_relative

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Use av_gettime_relative

The ones left using av_gettime are NTP timestamps (for RTCP,
which is specified to send the actual current realtime clock
in RTCP SR packets), and the NUT muxer timestamper, which is
documented as using wallclock time.

Signed-off-by: Martin Storsjö <martin@martin.st>
mp3dec: fix reading the Xing tag

The quality scale field is only supposed to be present if the fourth bit
is set. In practice, lame always sets it, but other tools might not.

CC:libav-stable@libav.org
doc: reword the mp3 muxer documentation

Make it more structured.
avconv: copy stream-level side data when streamcopying
mp3enc: write full LAME frame

Most importantly, it contains the encoder delay and replaygain info.
avfilter: check filter link validity

Remove now redundant check.

CC: libav-stable@libav.org
Bug-Id: CID 700371
audiointerleave: check av_new_packet return value

CC: libav-stable@libav.org
Bug-Id: CID 1087078
img2dec: check av_new_packet return value

CC: libav-stable@libav.org
Bug-Id: CID 1087077
flac_picture: prevent a possible out of bound write

At "mimetype[len] = 0;" mimetype is a 64 element array and len might be
equal to or greater than that.

CC: libav-stable@libav.org
Bug-Id: CID 1061055
lavf: replace rename() with ff_rename()

The new function wraps errno so that its value is correctly reported
when other functions overwrite it (eg. in case of logging).

CC: libav-stable@libav.org
Bug-Id: CID 1135748
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
matroskadec: fix leak on error

CC: libav-stable@libav.org
Bug-Id: CID 1026767
matroskadec: check return values

CC: libav-stable@libav.org
Bug-Id: CID 733712
matroskaenc: check avio_open_dyn_buf return value

CC: libav-stable@libav.org
Bug-Id: CID 703629
mxfdec: add missing break

CC: libav-stable@libav.org
Bug-Id: CID 732232
mxfenc: Fix possible integer overflows

None of these are likely unless the user is writing a file with two billion
streams or a duration of around two months.

CC: libav-stable@libav.org
Bug-Id: CID 700568 / CID 700569 / CID 700570 /
        CID 700571 / CID 700572 / CID 700573