qt-faststart: Increase the copy buffer size to 64 KB

Copying data in chunks of 1 KB is a little wasteful.

64 KB should still easily fit on the stack, so there's no need
to allocate it dynamically.

Signed-off-by: Martin Storsjö <martin@martin.st>
qt-faststart: Simplify code by using a MIN() macro

qt-faststart doesn't use the normal libav headers at all since
it's supposed to be a completely standalone tool, so we implement
the macro locally in this file.

Signed-off-by: Martin Storsjö <martin@martin.st>
qt-faststart: Check fseeko() return codes

Signed-off-by: Martin Storsjö <martin@martin.st>
qt-faststart: Fix the signedness of variables keeping the ftello return values

These variables are assigned the return values of ftello, which
returns an off_t, which is a signed type. On errors, ftello returns
-1, thus make sure this error return value can be stored properly.

Signed-off-by: Martin Storsjö <martin@martin.st>
qt-faststart: Check the ftello() return codes

This silences a warning in the coverity static analyzer.

Signed-off-by: Martin Storsjö <martin@martin.st>
qt-faststart: Check offset_count before reading from the moov_atom buffer

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
qt-faststart: Avoid unintentionally sign extending BE_32

Without this cast, the BE_32() expression is sign extended when
assigned to an uint64_t, since the uint8_t|uint8_t expression
is promoted to an int.

Also avoid undefined behaviour when left shifting an uint8_t
by 24 by casting it to an uint32_t explicitly before shifting.

Based on a patch by Michael Niedermayer.

Signed-off-by: Martin Storsjö <martin@martin.st>
qt-faststart: Add a note about the -movflags +faststart feature

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