[FFmpeg-cvslog] movenc: fix detection of 64bit offset requirement

Clément Bœsch git at videolan.org
Thu Aug 22 14:21:13 CEST 2013


ffmpeg | branch: master | Clément Bœsch <ubitux at gmail.com> | Tue Aug 20 07:46:09 2013 -0700| [60198742ff851f11a3757c713fc75a9c19b88566] | committer: 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: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=60198742ff851f11a3757c713fc75a9c19b88566
---

 libavformat/movenc.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 86c9461..0c6b09d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -82,15 +82,21 @@ static int64_t update_size(AVIOContext *pb, int64_t 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 */
 static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track)
 {
     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);
     avio_wb32(pb, 0); /* size */
-    if (pos > UINT32_MAX) {
-        mode64 = 1;
+    if (mode64) {
         ffio_wfourcc(pb, "co64");
     } else
         ffio_wfourcc(pb, "stco");



More information about the ffmpeg-cvslog mailing list