changeset 2440:69e2592531b6 libavformat

Write unknown size if the size given is too large for EBML (greater than 2^56-1)
author conrad
date Wed, 05 Sep 2007 00:23:06 +0000
parents 04ae6910d903
children c3ae0caeb9bf
files matroskaenc.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/matroskaenc.c	Wed Sep 05 00:23:03 2007 +0000
+++ b/matroskaenc.c	Wed Sep 05 00:23:06 2007 +0000
@@ -46,11 +46,12 @@
 static void put_ebml_size(ByteIOContext *pb, uint64_t size, int minbytes)
 {
     int bytes = minbytes;
-    while (size >> (bytes*7 + 7)) bytes++;
 
     // sizes larger than this are currently undefined in EBML
-    // XXX: error condition?
-    if (size > (1ULL<<56)-1) return;
+    // so write "unknown" size
+    size = FFMIN(size, (1ULL<<56)-1);
+
+    while (size >> (bytes*7 + 7)) bytes++;
 
     put_byte(pb, (0x80 >> bytes) | (size >> bytes*8));
     for (bytes -= 1; bytes >= 0; bytes--)