[FFmpeg-cvslog] lavf/movenc: make mov_write_stco_tag() not use the offset pos for mode64 heuristic.

Clément Bœsch git at videolan.org
Thu Sep 27 08:59:53 CEST 2012


ffmpeg | branch: master | Clément Bœsch <clement.boesch at smartjog.com> | Thu Sep 20 10:39:04 2012 +0200| [f379a108a45a800bff059034f939224e4535a8e7] | committer: Clément Bœsch

lavf/movenc: make mov_write_stco_tag() not use the offset pos for mode64 heuristic.

At the moment, the moov header is written at the end of the file, so we
can use the current offset (which focus on the end of the mdat already
written) to guess if 64-bits offset will be required or not.

Though, the next commits will make possible the writing of this table at
the beginning, so this heuristic can't work. As a consequence, we check
all the values within the potential offset table for any value >
32-bits.

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

 libavformat/movenc.c |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1d09420..a514b59 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -82,17 +82,29 @@ static int64_t update_size(AVIOContext *pb, int64_t pos)
     return curpos - pos;
 }
 
+static int is_co64_required(const MOVTrack *track)
+{
+    int i;
+
+    for (i = 0; i < track->entry; i++) {
+        if (!track->cluster[i].chunkNum)
+            continue;
+        if (track->cluster[i].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 = is_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
+    else
         ffio_wfourcc(pb, "stco");
     avio_wb32(pb, 0); /* version & flags */
     avio_wb32(pb, track->chunkCount); /* entry count */



More information about the ffmpeg-cvslog mailing list