Commit 60198742 authored by Clément Bœsch's avatar Clément Bœsch Committed by Martin Storsjö

movenc: fix detection of 64bit offset requirement

The old method doesn't work when moov is relocated to beginning of file
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent fe5d5a8f
...@@ -82,15 +82,21 @@ static int64_t update_size(AVIOContext *pb, int64_t pos) ...@@ -82,15 +82,21 @@ static int64_t update_size(AVIOContext *pb, int64_t pos)
return curpos - pos; return curpos - pos;
} }
static int co64_required(const MOVTrack *track)
{
if (track->entry > 0 && track->cluster[track->entry - 1].pos + track->data_offset > UINT32_MAX)
return 1;
return 0;
}
/* Chunk offset atom */ /* Chunk offset atom */
static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track) static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track)
{ {
int i; int i;
int mode64 = 0; // use 32 bit size variant if possible int mode64 = co64_required(track); // use 32 bit size variant if possible
int64_t pos = avio_tell(pb); int64_t pos = avio_tell(pb);
avio_wb32(pb, 0); /* size */ avio_wb32(pb, 0); /* size */
if (pos > UINT32_MAX) { if (mode64) {
mode64 = 1;
ffio_wfourcc(pb, "co64"); ffio_wfourcc(pb, "co64");
} else } else
ffio_wfourcc(pb, "stco"); ffio_wfourcc(pb, "stco");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment