On 08/20/2013 07:10 AM, Martin Storsjö wrote:
> On Mon, 19 Aug 2013, John Stebbins wrote:
>
>> From: Clément Bœsch <[email protected]>
>>
>> The old method doesn't work when moov is relocated to beginning of file
>> ---
>> libavformat/movenc.c | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> index 6df84f6..0fc173a 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 is_co64_required(const MOVTrack *track)
>> +{
>> +    if (track->cluster[track->entry - 1].pos + track->data_offset > 
>> UINT32_MAX)
>> +        return 1;
>> +    return 0;
>> +}
> I didn't check right now, but does this need a check for entry>0, or are 
> we positive that it won't ever be called in that case?

ahh, yes, this could possibly be called with entry == 0 when fragments are 
enabled.
update attached.

-- 
John      GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7

From fc5d0229d26895c0140d835ebaa5004b89c042c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <[email protected]>
Date: Tue, 20 Aug 2013 07:46:09 -0700
Subject: [PATCH] movenc: fix detection of 64bit offset requirement

The old method doesn't work when moov is relocated to beginning of file
---
 libavformat/movenc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6df84f6..be28b19 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");
-- 
1.8.3.1

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to